带变量定义的Ansible skip import_剧本

带变量定义的Ansible skip import_剧本,ansible,Ansible,我有一个main.yaml如下: - import_playbook: 1.yaml - import_playbook: 2.yaml vars: allow2: False when: allow2 文件2.yaml: - name: Go1 hosts: test gather_facts: false tasks: - debug: msg="Message from 1.yaml" - name: Go2 hosts: test

我有一个
main.yaml
如下:

- import_playbook: 1.yaml - import_playbook: 2.yaml vars: allow2: False when: allow2 文件
2.yaml

- name: Go1 hosts: test gather_facts: false tasks: - debug: msg="Message from 1.yaml" - name: Go2 hosts: test gather_facts: false tasks: - debug: msg="Message from 2.yaml" -姓名:Go2 主持人:测试 收集事实:错误 任务: -调试:msg=“来自2.yaml的消息” 输出为:

$ ansible-playbook main.yaml PLAY [Go1] *********** TASK [debug] ********* Thursday 05 October 2017 03:10:12 -0400 (0:00:00.116) 0:00:00.116 ****** ok: [test1] => {} MSG: Message from 1.yaml PLAY [Go2] ************ TASK [debug] ************ Thursday 05 October 2017 03:10:12 -0400 (0:00:00.090) 0:00:00.206 ****** skipping: [test1] $ansible playbook main.yaml 播放[Go1]*********** 任务[调试]********* 2017年10月5日星期四03:10:12-0400(0:00:00.116)0:00:00.116**** 确定:[test1]=>{} 味精: 来自1.yaml的消息 播放[Go2]************ 任务[调试]************ 2017年10月5日星期四03:10:12-0400(0:00:00.090)0:00:00.206**** 跳过:[test1] 您可以说
2.yaml
中的任务也被调用,但被跳过。 但是我不希望在
2.yaml
中调用任何任务


可能吗?

不,这种方式不可能

请参阅服务器上关于故障的答案


import\u playbook
是静态的,因此当
语句附加到其中的所有内容时,它总是执行

对于动态
include\u playbook
功能提出了一个问题-