practical 3

Help your friend fix this playbook /home/thor/playbooks/copy_file_only_if.yml.


Your firend is trying to copy this script /home/thor/playbooks/report_status.sh to web2 at location /usr/local/bin/report_status.sh based on a condition: if variable copy_file_only_if=true.

Problem is: Even though (s)he is passing True or true the boolean variable set this way is being evaulated as string and the conditional is being skipped as Conditional result was False

Please use the inventory file /home/thor/playbooks/inventory



================================================== 

---

- name: copy script if not present

  gather_facts: no

  hosts: web2

  vars:

    remote_dest: /usr/local/bin/report_status.sh

  tasks:

    - copy:

        src: report_status.sh

        dest: "{{remote_dest}}"

      when: copy_file_only_if is defined and copy_file_only_if | bool

Comments

Popular posts from this blog

exam 16

ansible 5