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
> <https://docs.ansible.com/ansible/latest/user_guide/playbooks_best_practices.html#alternative-directory-layout>*
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.ym*l 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?
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/a2cdf19b-92f2-42dd-8271-4d00d8cb0e3b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.