I am currently writing ansible playbook for adding user for local vm to local vm in ubuntu and also installing some stuff related to database.
Here is my project structure:
AnsibleProject:
---------------files
-------------authorizedkeys
------------savnpublickey
-------------group_vars
----all
--------all .yml files-------------playbooks
------------local
--------------------- all.yml
files,roles,groups_var(these all are files with content like …/…/group_vars--------------roles
-------------utility
---------------add-users—default |-------tasks
-------main.yml |--------main.yml--------------ansible.cfg
---------------hosts
in all.yml i included roles like this
- name: Pre Configuration
hosts: local
become: yes
any_errors_fatal: yes
roles:
- { role: utility/add-users,users: “{{ users_example }}” }
and in main.yml (roles->utility->add-users->tasks->main.yml)
- name: Add users
user: name=“{{ item }}” password=“{{ all_users[item].password|default(default_user_password_sha512) }}”
comment=“{{ all_users[item].name|default(item) }}” groups=“{{ all_users[item].groups|default(”“) }}”
append=yes update_password=on_create shell=/bin/bash expires=0
with_items: users
register: users_added
and in group_vars/all/user.yml
root_password_sha512: $7$.afghjkdaklllldVF95g/
default_user_password_sha512: $9poopppqeoooeo
all_users:
savn:
name: savn
groups: “sudo,wheel”
expire_password: no
ssh_key: “{{ lookup(‘file’, ‘…/…/files/authorized_keys/savnpublickey’) }}”
users_example :
- savn
In hosts file just added
[local]
180.122.135.196
In ansible.cfg
just added path to host file and path to roles
inventory = /etc/ansible/hosts
roles_path = /etc/ansible/roles
then iam running below command
$root> ansible local -m ping --ask-pass --ask-sudo-pass
entered username and password
response as
192.168.56.222 | SUCCESS => {
“changed”: false,
“ping”: “pong”
}
and then entered
$root> ansible-playbook --private-key=/vagrant/private_key -u vagrant -i /etc/ansible/hosts /etc/ansible/playbooks/local/all.yml -vvv
then iam getting error as
ERROR! Unexpected Exception: [Errno 20] Not a directory: ‘/vagrant/ansible/playbooks/local/group_vars’
the full traceback was:
Traceback (most recent call last):
File “/usr/bin/ansible-playbook”, line 103, in
exit_code = cli.run()
File “/usr/lib/python2.7/dist-packages/ansible/cli/playbook.py”, line 159, in run
results = pbex.run()
File “/usr/lib/python2.7/dist-packages/ansible/executor/playbook_executor.py”, line 82, in run
self._inventory.set_playbook_basedir(os.path.realpath(os.path.dirname(playbook_path)))
File “/usr/lib/python2.7/dist-packages/ansible/inventory/init.py”, line 752, in set_playbook_basedir
found_group_vars = self._find_group_vars_files(self._playbook_basedir)
File “/usr/lib/python2.7/dist-packages/ansible/inventory/init.py”, line 783, in _find_group_vars_files
found_vars = set(os.listdir(to_text(path)))
OSError: [Errno 20] Not a directory: '/vagrant/ansible/playbooks/local/group_vars
Iam working on ubuntu 14.0.2 and ansible 2.2.2.0
please help me in this context?
how to resolve this issue?