如果我有这样的东西:
- include_vars: this_file_doesnt_exist.yml
ansible会抛出错误 "input file not found at ..." 并停止配置过程。
我想知道是否可以 在文件不存在的情况下允许配置过程继续。
我的用例如下:
- 尝试加载变量文件
- 如果这些变量存在,则执行任务
示例:
- include_vars: aptcacher.yml
- name: use apt-cache
template: src=01_proxy.j2 dest=/etc/apt/apt.conf.d/01_proxy owner=root group=root mode=644
sudo: true
when: aptcacher_host is defined
Ansible版本:1.9.1
include_vars
作为任务吗?你尝试过我上面发布的playbook了吗? - ProfHase85ansible-playbook test.yml
或ansible-playbook -i /path/to/inventory test.yml
。 - ProfHase85localhost ansible_connection=local
的内容(请参阅文档)。 - ProfHase85