Created
March 18, 2013 22:18
-
-
Save 13rac1/5191334 to your computer and use it in GitHub Desktop.
Create a user in an Ansible playbook with a set, but unknown password so the account is not locked. Makes it possible to log on the account with a public key. This example requires mkpasswd, but that can be replaced with any other password generator.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: all | |
gather_facts: yes | |
## | |
# Create the password then create the user | |
# | |
- name: Users | Generate password for new user | |
shell: makepasswd --chars=20 | |
register: user_password | |
- name: Users | Create new user | |
user: name=new-user createhome=yes home=/home/new-user generate_ssh_key=yes shell=/bin/bash password=${user_password.stdout} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment