我有一个收藏,其中包括一本剧本:
example/example/
├── docs
│ └── README.md
├── FILES.json
├── MANIFEST.json
├── meta
│ └── main.yml
├── playbooks
│ └── example_playbook.yml
└── roles
└── èxample_role
我有一个文件夹,其中包括剧本、角色和变量:
ansible-example/
├── inventory
│ └── inventory.ini
├── roles
│ ├── role1
│ └── role2
├── templates
│ └── README.j2
├── Another_role.yml
└── vars
├── environment.yml
└── config.yml
现在我想在想要包含变量和当前目录清单的文件夹中example_playbook.yml
运行剧本:ansible-example
- hosts: hosts
vars_files:
- vars/config.yml
roles:
- example.example.èxample_role
请注意,应加载当前目录中的变量。这不起作用,因为 ansible 只是在寻找集合中 playbook 的目录vars_file
。playbook_dir
ERROR! vars file vars/config.yml was not found
Could not find file on the Ansible Controller.
If you are using a module and expect the file to exist on the remote, see the remote_src option
我也尝试将变量包含在内,但include_vars
也没有成功。
是否有可能从运行剧本的当前目录中包含 vars_file?
谢谢你的帮助!