How to Update Modified Group Policy in Windows by using Ansible Playbook on Oracle Linux 8.5
How To Update Modified Group Policy On Windows By Using Ansible Playbook
Introduction:
Ansible is an automatic configuration tool that runs on a wide range of windows and UNIX-like systems. The win_shell module is used to run commands on windows systems. The win_unzip module is used to manage achieved files.
Procedure:
Master Server Requirements:
ansible
python3-pip
pywinrm (python package)
Windows Requirements:
powershell 3+
Dot net 4
Installation Procedure:
Step 1: Check the OS version by using the following command
[root@linuxhelp ~]# cat /etc/os-release
NAME="Oracle Linux Server"
VERSION="8.5"
ID="ol"
ID_LIKE="fedora"
Step 2: Check the availability of Ansible package, python3-pip package, pywinrm by using the below command
[root@linuxhelp ~]# yum list ansible
ansible.noarch 2.9.27-1.el8 @ol8_developer_EPEL
Available Packages
ansible.src 2.9.27-1.el8 ol8_developer_EPEL
[root@linuxhelp ~]# yum list python3
Last metadata expiration check: 1:28:13 ago on Sun 11 Sep 2022 03:22:41 PM IST.
Available Packages
python3.src 3.6.8-45.0.1.el8 ol8_baseos_latest
python3.src 3.6.8-45.0.1.el8 ol8_appstream
[root@linuxhelp ~]# pip3 list | grep pywinrm
pywinrm (0.4.3)
Step 3: Create inventory for Windows node system by using the below command
[root@linuxhelp ~]# vim /etc/ansible/hosts
[windows]
192.168.6.51
[windows:vars]
ansible_user=Admin
ansible_password=Linuxc#4
ansible_port=5986
ansible_connection=winrm
ansible_winrm_server_cert_validation=ignore
Step 4: Create playbook in the name of policy.yml by using the below command
root@linuxhelp:~# vi policy.yml
- hosts: windows
gather_facts: true
tasks:
- name: Extract the zip file
win_unzip:
src: D:\gpt.zip
dest: C:\Windows\System32\GroupPolicy
- name: Updating the Group Policy
win_shell: gpupdate /force
Step 5: Check the syntax of the policy.yml ansible playbook by using the below command
root@linuxhelp:~# ansible-playbook policy.yml --syntax-check
playbook: policy.yml
Step6: Run the Policy.yml playbook by using the below command
[root@linuxhelp ~]# ansible-playbook policy.yml
PLAY [windows] *****************************************************************************
TASK [Gathering Facts] *********************************************************************
ok: [192.168.6.51]
TASK [Extract the zip file] ****************************************************************
changed: [192.168.6.51]
TASK [Updating the Group Policy] ***********************************************************
changed: [192.168.6.51]
PLAY RECAP *********************************************************************************
192.168.6.51 : ok=3 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Step 7: The Group policy updated in windows client system by Ansible playbook as shown in the below image
Conclusion:
We have reached the end of this article. In this guide, we have walked you through the steps required to update modified group policy in windows by using ansible Playbook on Oracle Linux 8.5. Your feedback is much welcome.
Comments ( 0 )
No comments available