A playbook I ran, returned this failure:
TASK [create-admin-user : Create the non-root user account] ********************
fatal: [415.791.30.131]: FAILED! => {"msg": "The task includes an option with an undefined variable.
The error was: 'admin_user' is undefined\n\nThe error appears to have been in '/Users/pnotes/Code/terraform/pj1/ansi/roles/create-admin-user/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: Task 1\n ^ here\n"}
Given this directory structure:
├── ansible.cfg
├── inventories
│ └── test
│ ├── group_vars
│ │ └── all.yml
│ ├── host_vars
│ │ └── all.yml
│ └── hosts.ini
├── provision.yml
└── roles
└── create-admin-user
├── handlers
│ └── main.yml
└── tasks
└── main.yml
Note that is directory layout follows that given in the docs
And a role defined like this:
- name: Create the non-root user account
user:
name: "{{ admin_user.name }}"
password: "{{ admin_user.password | password_hash('sha512') }}"
update_password: on_create
group: sudo
groups: sudo
append: yes
create_home: yes
shell: /bin/bash
I expect the task, create-admin-user, defined above to pick variables defined in inventories/test/group_vars/all.yml and inventories/test/host_vars/all.yml but the error messages shows that these variables aren't.
This doesn't make sense to me given that group_vars && host_vars both follow this structure:
---
admin_user:
name: somename
password: "somepassword"
ssh_public_key: '/Users/pnotes/.ssh/path_to_priKey'
ansible_become_pass: "somepasswd2"
I am bit confused as to what is happening - what am I missing?