我正在尝试在本地运行剧本,但我希望角色的 task/main.yml 文件中的所有变量都引用特定清单文件中的 group_var。
不幸的是,剧本无法访问 group_vars 目录,就像无法识别角色中指定的变量一样。
运行的命令如下:
/usr/local/bin/ansible-playbook --connection=local /opt/ansible/playbooks/create.yml -i ./inventory-file
但在/group_vars 目录下的清单文件的同一目录级别中找不到 group_vars
fatal: [127.0.0.1]: FAILED! => {
"msg": "The task includes an option with an undefined variable. The error was: 'admin_user_name' is undefined\n\nThe error appears to have been in '/opt/roles/create/tasks/main.yml': line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n---\n- name: create org\n ^ here\n"
}
Run Code Online (Sandbox Code Playgroud)
这是我的配置:
ansible-playbook 2.7.5
config file = /etc/ansible/ansible.cfg
configured module …Run Code Online (Sandbox Code Playgroud) ansible ×1