• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News Comments FAQ Related Articles

How to Update Modified Group Policy in Windows by using Ansible Playbook on Oracle Linux 8.5

  • 00:37 cat /etc/os-release
  • 00:54 yum list ansible
  • 01:10 yum list python3
  • 01:35 pip3 list | grep pywinrm
  • 01:51 vim /etc/ansible/hosts
  • 02:20 vi policy.yml
  • 05:10 ansible-playbook policy.yml --syntax-check
  • 05:41 ansible-playbook policy.yml
{{postValue.id}}

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

snap 1

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.

Tags:
albertcarl
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

How does Ansible communicate with Linux?

A

Ansible uses SSH protocol to connect to servers and run tasks.

Q

Which port number does Ansible use to control windows?

A

5986 is the port number does Ansible use to control windows.

Q

What is Ansible used for in Linux?

A

Ansible is an open-source automation platform that includes configuration management, application deployment, and infrastructure orchestration.

Q

What is an inventory file in Ansible?

A

The Ansible inventory file defines the hosts and groups of hosts upon which commands, modules, and tasks in a playbook operate.

Q

How do I test the Ansible connection?

A

To test that Ansible is able to connect and run commands and playbooks on your nodes, you can use the following command: ansible all -m ping.

Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help David Lopez Guillen ?
Ayuda urgente instale SSL para servidor Opensuse y ahora no funciona tengo servicio web

hola segui este tutorial para tener un certificado ssl y ahora no se ve mi app en la red, espero alguien pueda ayudarme, tengo M9oodle en3.5 en un servidor open suse y ahora no funciona por favor ayuda.

https://www.linuxhelp.com/how-to-create-ssl-certificate-in-opensuse

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.