我正在尝试使用ansible和ansible-vault来配置用户。这是我目前的目录结构:Ansible-vault没有正确传递到playbook
|-- ansible-test.out
|-- group_vars
|-- inventory
|-- roles
| |-- bsd_sudoers
| | |-- tasks
| | |-- templates
| | | `-- cde-admins
| | `-- vars
| `-- bsd_users
| |-- files
| |-- tasks
| | `-- main.yml
| |-- templates
| `-- vars
| `-- all.yml
|-- site.retry
|-- site.yml
`-- vars
`-- all.yml
这是我有我的剧本至今:
---
- name: Creating Users
user:
name: "{{ item.name }}"
system : "{{ item.sudoer }}"
shell: /bin/bash
password: "{{ item.password }}"
uid: "{{ item.uid }}"
home: "{{ item.home }}"
with_items: users
这里是什么,我有ansible库样本:
---
vars:
users:
- name: 'foo'
home: '/home/foo'
key: 'ssh-rsa ....'
password: '!!'
bash: '/bin/bash'
sudoer: yes
uid: "2049"
guid: '2049'
group: admin
当我运行剧本时,总会生成以下错误消息:
fatal: [ansible-test]: FAILED! => {"failed": true, "msg": "The task includes an option with an undefined variable. The error was: 'ansible.utils.unsafe_proxy.AnsibleUnsafeText object' has no attribute 'uid'\n\nThe error appears to have been in '/Users/ansible/playbooks/roles/bsd_users/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: Creating Users\n^here\n\nexception type: <class 'ansible.errors.AnsibleUndefinedVariable'>\nexception: 'ansible.utils.unsafe_proxy.AnsibleUnsafeText object' has no attribute 'uid'"}
to retry, use: --limit @/Users/ansible/playbooks/site.retry
为什么总是这样?我的印象是,Ansible自然会将加密变量传递给我的剧本,但似乎并非如此。
我会给你一个漩涡 – ryekayo
现在我得到的用户没有定义 – ryekayo
你的拱形变量文件位于哪里? –