我有一个像下面这样的Ansible剧本,我想使用这样的嵌套变量:
msg={{{{Component}}.community_release_num}},但是当我运行playbook时:
ansible-playbook vartest.yml -e 'version=version_402', it not work
[es@vpn-server nested-var]$ tree
.
??? vars
? ??? horizon.yml
? ??? version_402.yml
??? vartest.yml
1 directory, 3 files
[es@vpn-server nested-var]$ cat vartest.yml
---
- name: test
hosts: localhost
vars_files:
- vars/{{version}}.yml
tasks:
- debug: msg={{{{Component}}.community_release_num}}
- debug: msg={{{{Component}}.release_num}}
[es@vpn-server nested-var]$ cat vars/horizon.yml
Component: horizon
[es@vpn-server nested-var]$ cat vars/version_402.yml
- horizon:
community_release_num: '9.0.1'
release_num: '4.0.2'
[es@vpn-server nested-var]$
Run Code Online (Sandbox Code Playgroud)
错误消息
[es@vpn-server nested-var]$ ansible-playbook vartest.yml -e 'version=version_402'
/usr/lib64/python2.6/site-packages/cryptography/__init__.py:25: DeprecationWarning: Python 2.6 is no longer …Run Code Online (Sandbox Code Playgroud) 我有一个像下面这样的剧本,我想在块出错时控制救援的执行\xe3\x80\x82\n我在when: is_debug is defined救援\xef\xbc\x8c之后添加,但是当我运行时ansible-playbook dashboard.yml ,不给出is_debug值,救援是当块有错误时仍然执行。
我想知道如何控制ansible中rescue模块的执行?
\n\n[root@ansiable-test update]# cat dashboard.yml\n---\n- hosts: controller\n vars_files:\n - "vars/vars.yml"\n tasks:\n - name: update horizon\n - block:\n - include: "roles/dashboard/tasks/update-horizon.yml"\n rescue:\n when: is_debug is defined\n - debug: msg=\'An error occurred during the upgrade,roll back to the old version\'\n - include: "roles/dashboard/tasks/rollback.yml"\nRun Code Online (Sandbox Code Playgroud)\n