practical 4
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
Check if report_status.sh
copied earlier to web2
remote host is executable or not. If it is not executable, log the message: File report_status.sh is not executable, making it executable...
in file /tmp/change.log
on web2
remote host and make it executable.
Develop a playbook /home/thor/playbooks/make_it_executable.yml
and use the inventory file /home/thor/playbooks/inventory
=======================
---
- hosts: web2
gather_facts: no
vars:
remote_dest: /usr/local/bin/report_status.sh
tasks:
- stat:
path: "{{remote_dest}}"
register: file_status
- debug: var=file_status
- shell: echo "File report_status.sh is not executable, making it executable..." > /tmp/change.log
when: file_status.stat.exists and file_status.stat.executable == false
- name: Make the script executable
file:
path: "{{remote_dest}}"
mode: '0755'
~
Comments
Post a Comment