From 83e9f4dc5dcf42cd24b1dcd16f877943d8214bae Mon Sep 17 00:00:00 2001 From: xpk Date: Wed, 20 Feb 2019 17:34:24 +0800 Subject: [PATCH] feat: passwords will be randomly generated --- tasks/main.yml | 6 +++++- vars/main.yml | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 vars/main.yml diff --git a/tasks/main.yml b/tasks/main.yml index 73c66dd..832b1a5 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -8,7 +8,7 @@ name: "{{ user.name }}" shell: /bin/bash groups: "{{ user.group }},ssh_access" - password: "{{ user.pwhash }}" + password: "{{ hashed_pass }}" - name: Add user to sudoers lineinfile: @@ -18,3 +18,7 @@ mode: 0440 when: user.sudoers +- name: Display generated password + debug: + msg: "Generated password for user: {{ plain_pass }}" + diff --git a/vars/main.yml b/vars/main.yml new file mode 100644 index 0000000..28e5273 --- /dev/null +++ b/vars/main.yml @@ -0,0 +1,2 @@ +plain_pass: "{{ lookup('password', '/dev/null chars=ascii_letters,digits,hexdigits length=15') }}" +hashed_pass: "{{ plain_pass | password_hash('sha512') }}"