Hi. New ansible user here so just starting out. My first experiment is to create a user with sudo privileges on an Oracle Linux 8 server in my test environment. Here are the contents of the files in the /home/”user”/ansible/playbooks folder. I think I am missing something as when I run the playbook it runs successfully. I confirm that the account is created however when I attempt to ssh or login the attempt gets denied access.
Any help is appreciated.
Thank you,
user_pass.yml - encrypted using “ansible-vault create user_pass.yml” in group_vars folder
admin_group: wheel
password: #G00d4now
ansible.cfg
[defaults]
inventory = ./inventory
remote_user = (local user with authorized keys)
[privilege_escalation]
become = true
become_method = sudo
become_user = root
inventory
[ol8]
qansibletest
create_users.yml
- name: Create New Users
hosts: all
gather_facts: false
tasks:
- name: Create User Task
user:
name: devops
state: present
password: "{{ 'password' | password_hash('sha512','A512') }}"
shell: /bin/bash
groups: "{{ admin_group }}"
append: true
...
********************************
Rene Paquin - Systems Administrator
Wilfrid Laurier University
Waterloo, Ontario
(519)884-0710 x3795
rpa...@wlu.ca
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/YTXPR0101MB129555BCD8AC0A903654ECC4D8C40%40YTXPR0101MB1295.CANPRD01.PROD.OUTLOOK.COM.
Thanks for the suggestion. This just leads to more….
When I use this
password: "{{ passwrd | password_hash('sha512', 'A512') }}" I get the following error:
TASK [Create Users Task] **********************************************************************************************
fatal: [qreneansible.wlu.ca]: FAILED! => {"msg": "Unexpected templating type error occurred on ({{ passwd | password_hash('sha512', 'A512') }}): crypt() argument 1 must be str, not None"}
PLAY RECAP ************************************************************************************************************
qreneansible.wlu.ca : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
It seems that it cannot find the variable anywhere. In the playbook file I did add the following but it still cant find it. The file is encrypted as well.
vars_files:
- group_vars/ol8
Thanks again,
Rene
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CANhJoDyNfDCzR-WSXPoHwqkhLvFZA0HGkdybQ8qMnSXAPuEmeQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/YTXPR0101MB129567F2C94DBBEE7F9C7B32D8C40%40YTXPR0101MB1295.CANPRD01.PROD.OUTLOOK.COM.
I did. The contents of the encrypted file are:
admin_group: wheel
passwrd: #G00d4now
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CANhJoDzgUawHUUtHiFg0CqmAi2H3GcHFJ16OQEAwmAaN%2BJjKyw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/YTXPR0101MB1295613C7183FCE18635A07FD8C40%40YTXPR0101MB1295.CANPRD01.PROD.OUTLOOK.COM.
That did the trick. Thank you very much.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CANhJoDxPaPSVtzj-Xon8P_nCyQMvRyuf-5NDgeyTx7iLZZymLg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/YTXPR0101MB129597049F39E887DE1BC7B0D8C30%40YTXPR0101MB1295.CANPRD01.PROD.OUTLOOK.COM.