Answer the question
In order to leave comments, you need to log in
Ansible. How to specify encrypt: sha512_crypt in the --extra-vars argument?
There is a script for adding a Linux user with the following parameters
vars_prompt:
- name: 'username'
prompt: 'Username'
private: no
- name: 'userpass'
prompt: 'Password'
private: no
encrypt: "sha512_crypt"
ansible-playbook add.yml --extra-vars "username=user userpass=passwoRD"
Answer the question
In order to leave comments, you need to log in
tasks:
- name: 'Add user'
user: 'name={{ username }} password={{ userpass |password_hash("sha512") }} update_password=on_create shell=/usr/bin/lshell move_home=yes home=/var/www/{{ username }}'
It is necessary to transfer an already encrypted password, you have a security hole otherwise
The code is inconsistent. You either leave vars_promt or vars passed via --extra-vars Enable
ansible-playbook debug add.yml -vvv
---
- hosts: local
gather_facts: no
vars_prompt:
- name: 'username'
prompt: 'Username'
private: no
- name: 'userpass'
prompt: 'Password'
private: no
encrypt: "sha512_crypt"
tasks:
- name: username
shell: echo my username is {{username}}
- name: look we crypted a password
shell: echo my password is {{userpass}}
- debug: var=userpass
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question