• 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 extract a downloaded file on windows by using the Ansible playbook

  • 00:46 lsb_release -a
  • 00:55 apt list -a ansible
  • 01:08 apt list -a python3
  • 01:23 pip list | grep pywinrm
  • 01:52 vi /etc/ansible/hosts
  • 02:45 vi test.yml
  • 07:22 ansible-playbook test.yml --syntax-check
  • 07:45 ansible-playbook test.yml
{{postValue.id}}

To Extract a Downloaded file on Windows by using Ansible Playbook

Introduction:

Ansible is an automatic configuration tool used in wide range of windows and UNIX like systems. win_unzip is the module which is used for manage Achieved files.

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 below 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 by using the below command

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 by using the below command

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 by using the below command

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

Step 5: Create inventory for Windows node system by using the below command

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 in the name of test.yml by using the below command

root@linuxhelp:~# vi test.yml
- hosts: windows
gather_facts: true
tasks:
- name: Copy the zip file
win_get_url:
url: ftp://192.168.7.150/Operating-system/WINDOWS/group-policy/with-modification.zip
url_username: ftpadmin
url_password: sys#ad$004
dest: E:\Apps
- name: Extracting Files
win_unzip:
src: E:\Apps\with-modification.zip
dest: C:\Windows\System32\GroupPolicy 

Step 7: Check the destination folder as shown in the below image snap 1

Step 8: Check the syntax of the test.yml ansible playbook by using the below command

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

playbook: test.yml

Step 9: Run the test.yml playbook by using the below command

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

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

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

TASK [Copy the zip file] *********************************************************************************
changed: [192.168.6.104]

TASK [Extracting Files] **********************************************************************************
changed: [192.168.6.104]

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

Step 10: The files are extracted in the destination folder by ansible playbook as shown in the below image. snap 2

By this to extract a downloaded file on windows by using Ansible playbook has been completed.

Tags:
connor
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

What are the Modules in Ansible?

A

Modules are discrete units of code that can be used from the command line or in a playbook task.

Q

What does win_unzip do?

A

It is the windows module used to manage the zip files by ansible.

Q

In what language are Ansible modules written?

A

Most modules delivered with Ansible are written in Python

Q

Where the Ansible plugins are located?

A

Ansible modules are located in (~/.ansible/plugins/)

Q

Where was the Ansible inventory file located?

A

Ansible inventory file is located in (/etc/ansible/hosts)

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.