So I created this Ansible playbook to:
- copy a zip file and unzip it
- copy a zip file and unzip it
- make script inside the file executable
- run the script
- enable 2 services
- name: fideliplaybook
hosts: k8scluster
tasks:
- name: copying file with playbook
become: true
copy:
src: /home/lc/lc.zip
dest: /home/lc/
mode: 755
- name: Update apt cache and install unzip
become: true
command: apt install unzip
- name: unzip file
become: true
unarchive:
src: /home/lc/lc.zip
dest: /home/lc/
- name: make script executable
become: true
file: dest=/home/lc/lc/install.sh mode=755
- name: Execute the script
become: true
command: sh /home/lc/lc/install.sh
- name: Enable service 1
become: true
command: systemctl enable service1.service
- name: Enable service 2
become: true
command: systemctl enable service1.service
the issue that I am facing here that when ansible is trying to execut the script "install.sh" it somehow fails becuse script cant find 2 other scripts although the other scripts are in the same file.
so 3 scripts are in lc.zip but when running install.sh with ansible it cant find the 2 other scripts. I fixed the issue by typing the full path of the 2 scripts inside the first script. but anyone have an idea why this issue occuers.
one more quistion when i used ansible hosts file to define hosts and variables it didnt worked with INI like this:
[webservers]
www[01:50].example.com
It only woks In YAML:
...
webservers:
hosts:
www[01:50].example.com:
Anyone know why?