• 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 set or remove Windows Proxy by using Ansible playbook

  • 00:56 lsb_release -a
  • 01:14 apt list -a ansible
  • 01:29 apt list -a python3-pip
  • 01:49 pip list | grep pywinrm
  • 02:12 vi /etc/ansible/hosts
  • 03:10 vi proxyset.yml
  • 07:23 ansible-playbook proxyset.yml --syntax-check
  • 07:47 ansible-playbook proxyset.yml
  • 08:45 vi removeproxy.yml
  • 12:16 ansible-playbook removeproxy.yml --syntax-check
  • 12:33 ansible-playbook removeproxy.yml
{{postValue.id}}

To Set or Remove Windows Proxy by using Ansible playbook

Introduction:

Ansible is a tool for managing the configurations of both Unix-like as well as Windows-based systems The "win_init_proxy" module manages Windows proxy settings, which acts as a proxy server between the client and the server

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:~# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 21.04
Release:	21.04
Codename:	hirsute

Step 2: Check the availability of Ansible package

root@linuxhelp:~# apt list -a ansible
Listing... Done
ansible/hirsute,hirsute,now 4.8.0-1ppa~hirsute all [installed]
ansible/hirsute,hirsute 2.10.7-1 all

Step 3: Check the availability of python3-pip package

root@linuxhelp:~# apt list -a python3
Listing... Done
python3/hirsute,now 3.9.4-1 amd64 [installed,automatic]

python3/hirsute 3.9.4-1 i386

Step 4: Check the availability of python package pywinrm

root@linuxhelp:~# pip list | grep pywinrm
pywinrm                0.4.2

Step 5: Create inventory for Windows node system

root@linuxhelp:~# vi /etc/ansible/hosts 

[windows]
192.168.6.104

[windows:vars]
ansible_user=Admin
ansible_password=Admin@123
ansible_port=5986
ansible_connection=winrm
ansible_winrm_server_cert_validation=ignore

Step 6: Create a playbook for Setting Proxy

root@linuxhelp:~# vi proxyset.yml
- hosts: windows
  gather_facts: true
  tasks:
  - name: Apply proxy settings for all user
    ansible.windows.win_regedit:
      path: HKLM:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings
      name: ProxySettingsPerUser
      data: 0
      type: dword
      state: present
  - name: Configure to use proxy server
    win_inet_proxy:
      proxy: 192.168.7.200:3128

Step 7: Check the syntax of the proxyset.yml ansible playbook by using the following command

root@linuxhelp:~# ansible-playbook proxyset.yml --syntax-check

playbook: proxyset.ym

Step 8: Run the proxyset.yml playbook by using the following command

root@linuxhelp:~# ansible-playbook proxyset.yml 

PLAY [windows] *************************************************************************************************

TASK [Gathering Facts] *****************************************************************************************
ok: [192.168.6.104]

TASK [Apply proxy settings for all user] ***********************************************************************
changed: [192.168.6.104]

TASK [Configure to use proxy server] ***************************************************************************
ok: [192.168.6.104]

PLAY RECAP *****************************************************************************************************
192.168.6.104              : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

Step 9: Proxy settings applied on Windows Client system Snap 1

Step 10: Create playbook for removing Proxy

root@linuxhelp:~# vi removeproxy.yml
- hosts: windows
  gather_facts: true
  tasks:
  - name: Apply proxy for all users
    ansible.windows.win_regedit:
      path: HKLM:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings
      name: ProxySettingsPerUser
      data: 0
      type: dword
      state: absent
  - name: Remove proxy
    win_inet_proxy:
         proxy: 192.168.7.200:3128

Step 11: Check the syntax of the removeproxy.yml ansible playbook by using the following command

root@linuxhelp:~# ansible-playbook removeproxy.yml --syntax-check

playbook: removeproxy.yml

Step 12: Run the removeproxy.yml playbook by using the following command

root@linuxhelp:~# ansible-playbook removeproxy.yml 

PLAY [windows] *************************************************************************************************

TASK [Gathering Facts] *****************************************************************************************
ok: [192.168.6.104]

TASK [Apply proxy for all users] *******************************************************************************
changed: [192.168.6.104]

TASK [Remove proxy] ********************************************************************************************
ok: [192.168.6.104]

PLAY RECAP *****************************************************************************************************
192.168.6.104              : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

Step 13: Proxy settings removed on Windows Client system Snap 2

By this How to set or remove Windows Proxy by using Ansible playbook comes to end

Tags:
isaac
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

What is registry Keys ?

A

Registry contains the data of operation , application and services of windows.

Q

What is registry Keys used to set proxy ?

A

HKLM(HKEY_LOCAL_MACHINE) registry Key used to set proxy

Q

What is "win_regedit" module is for ?

A

"win_regedit" module is for Add, change, or remove registry keys and values.

Q

How to find registry Keys ?

A

Open run and type regedit to find registry Keys.

Q

Which port number does ansible use to control over windows ?

A

5986 is the port number does ansible use to control over windows

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 Sebastian ?
How to change non required to required field in SuiteCRM Custom/Default Modules

How to change not required to the required field in SuiteCRM Custom/Default Modules?

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.