I have a sub playbook like this.
{{
- vars:
appHome: /opt/app
aliasName: webbuild
- stat:
path: "{{ appHome }}/{{ aliasName }}"
register: folder_stat
- name: Print vars
debug:
msg: >
{{ appHome }}/{{ aliasName }}
{{ folder_stat }}
- set_fact:
oldVersion: "{{ folder_stat.stat.lnk_source }}"
when: folder_stat.stat.islnk is defined and folder_stat.stat.islnk == true
- set_fact:
oldVersion: "{{ appHome }}/{{ aliasName }}"
when: folder_stat.stat.islnk is defined and folder_stat.stat.islnk == false
- name: Print oldVersion
debug:
msg: "{{ oldVersion }}"
}}
When I run this play book, it return:
"TASK [backupService : set_fact] **********************************************************************************************************************
task path: /opt/ansible/bullion/ansible/playbooks/roles/backupService/tasks/app01.yml:16
skipping: [STG-app-1] => {
"changed": false,
"skip_reason": "Conditional result was False"
}
"
Can anyone please help me to explain:
- Is my syntax with {{
"when: folder_stat.stat.islnk is defined and folder_stat.stat.islnk == true" and " folder_stat.stat.islnk is defined and folder_stat.stat.islnk == false "}} - If my syntax is wrong, how's about the right syntax to return the oldVersion like
{{
"/opt/app/webbuild"}}
Thanks you guys so much!