Created
January 28, 2015 23:14
-
-
Save sumdog/f16f7e528ae404d703c8 to your computer and use it in GitHub Desktop.
Local Actions don't seem to work on ansible 1.8.2
This file contains hidden or 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
# 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