[英]ansible include_vars issue with ignore_files
我正在劇本中嘗試include_vars
,但我想排除一個文件並包含其余文件。 嘗試過ignore_files: 'b.yml'
但是刪除了包括所有文件的文件后,它沒有加載任何文件。
# tree
.
├── myvars
│ ├── a.yml
│ └── b.yml
└── test.yml
1 directory, 3 files
# cat test.yml
---
- hosts: all
tasks:
- include_vars:
dir: 'myvars'
ignore_files: 'b.yml'
extensions: ['yml']
- debug:
msg: "{{ name }}"
# cat myvars/a.yml
---
name: IronMan
#
參見include vars輸出,沒有任何文件被加載。
# ansible-playbook test.yml -i "localhost," -c local -vv
PLAYBOOK: test.yml ***************************************************************************************************************************
1 plays in test.yml
PLAY [all] ***********************************************************************************************************************************
TASK [Gathering Facts] ***********************************************************************************************************************
ok: [localhost]
META: ran handlers
TASK [include_vars] **************************************************************************************************************************
task path: /root/test.yml:4
ok: [localhost] => {"ansible_facts": {}, "ansible_included_var_files": [], "changed": false, "failed": false}
TASK [debug] *********************************************************************************************************************************
task path: /root/test.yml:9
fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'name' is undefined\n\nThe error appears to have been in '/root/test.yml': line 9, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - debug:\n ^ here\n\nexception type: <class 'ansible.errors.AnsibleUndefinedVariable'>\nexception: 'name' is undefined"}
to retry, use: --limit @/root/test.retry
PLAY RECAP ***********************************************************************************************************************************
localhost : ok=2 changed=0 unreachable=0 failed=1
始終檢查參數類型:
- ignore_files
List of file names to ignore.
[Default: None]
version_added: 2.2
將您的arg更改為列表:
- include_vars:
dir: 'myvars'
ignore_files: ['b.yml']
extensions: ['yml']
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.