Skip to content

Instantly share code, notes, and snippets.

@sumdog
Created January 28, 2015 23:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sumdog/f16f7e528ae404d703c8 to your computer and use it in GitHub Desktop.
Save sumdog/f16f7e528ae404d703c8 to your computer and use it in GitHub Desktop.
Local Actions don't seem to work on ansible 1.8.2
# Check if password has been generated
- local_action: stat path={{ pgp_password_file }}
register: local_pgp_password_file
# Generate password if it doesn't exist
- local_action: command pwgen -s 25 1 #TODO: settings for length
register: password
when: local_pgp_password_file.stat.exists == False
- local_action: command mkdir -p {{ pgp_password_path }}
when: local_pgp_password_file.stat.exists == False
- local_action: shell echo {{ password.stdout }} | gpg --encrypt --armor -r {{ security.pgp_id }} > {{ pgp_password_file }} creates={{ pgp_password_file }}
when: local_pgp_password_file.stat.exists == False
# Decrypt password if it does exist
- local_action: command pgp --decrypt {{ pgp_password_file }}
register: password
when: when: local_pgp_password_file.stat.exists == True
# Set it in the VM
- local_action: shell echo {{ password.stdout }} | mkpasswd --method=SHA-512 --stdin
register: crypt_password
- user: name=root password=crypt_password.stdout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment