Hi,
Trying to write playbook with when conditional statement.
However, it always choose last command (/home/user//bin/) to execute even though condition matches with another domainname.
playbook.yml
command execution Ansible Playbooks
- hosts: “{{domainname}}”
remote_user:
vars_prompt: - name: “domainname”
prompt: “Enter domain name”
private: no
tasks: - name: Copy file to client
copy: src=/tmp/{{file_name}} dest=/tmp/ owner= group=user mode=0644
become: yes
become_method: su
tasks:
- name: installing something
command: /home/user//bin/
become: yes
become_method: su
when: (‘“{{domainname}}” == “test.com”’) or (‘“{{domainname}}” == “test1.com”’) - command: /home/user//bin/
become: yes
become_method: su
when: (‘“{{domainname}}” == “test5.com”’) or (‘“{{domainname}}” == “test5.com”’)
While running above if i will enter test.com as a domain name still it will execute command (/home/user//bin/) instead of (/home/user//bin/)
Please correct me where i am making mistake.