Ansible 组变量未加载
Ansible group vars not getting loaded
没有导入组变量。目录结构如下所示:
- ansible.cfg
- testt.yaml
- inventories
- production
- group_vars
- all.yaml
- host_vars
- hosts
- staging
- group_vars
- all.yaml
- check99.yaml
- host_vars
- hosts
ansible.cfg 看起来像这样:
inventory= inventories
staging/hosts 看起来像:
target99 ansible_connection=local
[check99]
target99
staging/group_vars/check99.yaml 看起来像:
hello: abc
testt.yaml 看起来像:
- hosts: target99
tasks:
- debug:
msg: >
{{hello}}
当我运行命令:ansible-playbook testt.yaml,我得到错误变量hello undefined,这里有什么问题?
您正在将库存设置到不正确的目录
尝试在 ansible.cfg
中设置库存
inventory=inventories/staging/
没有导入组变量。目录结构如下所示:
- ansible.cfg
- testt.yaml
- inventories
- production
- group_vars
- all.yaml
- host_vars
- hosts
- staging
- group_vars
- all.yaml
- check99.yaml
- host_vars
- hosts
ansible.cfg 看起来像这样:
inventory= inventories
staging/hosts 看起来像:
target99 ansible_connection=local
[check99]
target99
staging/group_vars/check99.yaml 看起来像:
hello: abc
testt.yaml 看起来像:
- hosts: target99
tasks:
- debug:
msg: >
{{hello}}
当我运行命令:ansible-playbook testt.yaml,我得到错误变量hello undefined,这里有什么问题?
您正在将库存设置到不正确的目录
尝试在 ansible.cfg
中设置库存inventory=inventories/staging/