How to download a file from FTP on Windows by using Ansible playbook
To Download a File From Ftp on Windows by using Ansible playbook
Introduction:
Ansible is an automatic configuration tool used in wide range of systems and devices such as databases, storage devices, networks, firewalls. win_package is the module which is used for manages Windows packages.
Master Server Requirements:
ansible
python3-pip
pywinrm (python package)
Windows Requirements:
powershell 3+
Dot net 4
Step 1: Application already present in the system
Step 2: Checking the OS version by using 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 3: Checking 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 4: Checking 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 5: Checking the availability of python package pywinrm
root@linuxhelp:~# pip list | grep pywinrm
pywinrm 0.4.2
Step 6: Creating inventory for Windows node system
root@linuxhelp:~# vi /etc/ansible/hosts
[windows]
192.168.2.134
[windows:vars]
ansible_user=Admin
ansible_password=Admin@123
ansible_port=5986
ansible_connection=winrm
ansible_winrm_server_cert_validation=ignore
Step 7: Creating playbook for Downloading an Application from ftp and installing
root@linuxhelp:~# vi test.yml
- hosts: windows
gather_facts: true
tasks:
- name: copy file
win_get_url:
url: ftp://ftpadmin@192.168.7.150/ZoomInstaller.exe
url_username: ftpadmin
url_password: <password of ftp account>
dest: D:\Apps
- name: Install Zoom
win_package:
path: D:\Apps\ZoomInstaller.exe
state: present
Step 8: Checking the syntax of the test.yml ansible playbook by using following command
root@linuxhelp:~# ansible-playbook test.yml --syntax-check
playbook: test.yml
Step 9: Running the test.yml playbook by using the following command
root@linuxhelp:~# ansible-playbook test.yml
PLAY [windows] *******************************************************************************************************
TASK [Gathering Facts] ***********************************************************************************************
ok: [192.168.2.134]
TASK [copy file] *****************************************************************************************************
changed: [192.168.2.134]
TASK [Install Zoom] **************************************************************************************************
changed: [192.168.2.134]
PLAY RECAP ***********************************************************************************************************
192.168.2.134 : ok=3 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Step 10: Zoom Application Downloaded from ftp is installed
with this process of downloading a file from FTP using Ansible Comes to end
Comments ( 0 )
No comments available