variables - when condition not being evaluated with include statement -
i have tikitaka3.yml (main yml file) , tikitaka3a.yml (playbook included) . when prompt user variable , in tasks section when call it, so:
--- - hosts: vars: khan: # contents: "{{ lookup('file', '/home/imran/desktop/tobefetched/file1.txt') }}" vars_prompt: - name: targetenv prompt: 1.)epc 2.)clients 3)testers private: false default: "1" gather_facts: no tasks: - name: inlude playbook tikitaka3a include: /home/khan/desktop/playbooks/tikitaka3a.yml target=umar when: targetenv.stdout|int < 2 #this statement has no effect #when: targetenv == 1 #neither statement #when: targetenc == "1" #and neither statement have affect #- name: stuff n stuff # task give error if not commented # debug: var=targetenv.stdout
the include statement comes affect, without when condition ever being evaluated
when include ansible task file attach when:
condition included tasks. means see tasks displayed when when:
condition false though tasks skipped.
one problem code above targetenv.stdout
, here working version proper formatting:
- hosts: gather_facts: no vars_prompt: - name: targetenv prompt: 1.)epc 2.)clients 3)testers private: false default: "1" tasks: - name: inlude playbook tikitaka3a include: roles/test/tasks/tikitaka3a.yml target=umar when: targetenv|int < 2
Comments
Post a Comment