Here is the approach that I took. My paths will be different from yours:
1 => on the Jump server:
cd /home/thor/ansible
sudo vi ansible.cfg
# set your inventory file and remote user
[defaults]
inventory = ./inventory
remote_user = thor
host_key_checking = False
sudo vi playbook.yml
# note: {{ ansible_user }} is defined in the inventory file
- name: Unzip data & send to all 3 App Servers
hosts: stapp01, stapp02, stapp03
become: yes
tasks:
- name: Extract the archive and set the owner/permissions
unarchive:
src: /usr/src/security/devops.zip
dest: /opt/security/
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"
mode: "0777"
# run
sudo ansible-playbook -i inventory playbook.yml
# check that file exists on all 3 servers
ansible -m command -a "ls /opt/security/" -i inventory all -b
# or manually log into each server and check to see that files were copied
cd /opt/security/
cat /opt/security/unarchive/web.txt
Hi @juliettet This helped me.
But can you please let me know why this was not working before.
I agree that the approach was long and I was not using the variables.
hosts: stapp01
tasks:
name: Unzipping the file
ansible.builtin.unarchive:
src: /usr/src/sysops/nautilus.zip
dest: /opt/sysops/
user: tony
group: tony
mode: 0644
hosts: stapp02
tasks:
name: Unzipping the file
ansible.builtin.unarchive:
src: /usr/src/sysops/nautilus.zip
dest: /opt/sysops/
user: steve
group: steve
mode: 0644