Created
June 1, 2018 03:25
-
-
Save gonoph/0fb9560f09c54bdd701052df2992b6c9 to your computer and use it in GitHub Desktop.
Randomize Satellite Username and Password
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
# vim: sw=2 ai expandtab | |
--- | |
- name: Randomize Satellite Username and Password | |
hosts: satellites | |
gather_facts: false | |
connection: smart | |
become: false | |
force_handlers: True | |
handlers: | |
- name: delete temp user | |
ignore_errors: true | |
command: "hammer -u {{ admin_username }} -p {{ admin_password }} user delete --login temp_user" | |
- name: display user and password | |
debug: | |
var: display | |
vars: | |
display: | |
user: "{{ admin_username }}" | |
pass: "{{ admin_password }}" | |
tasks: | |
- name: generate memory only passwords and usernames | |
set_fact: | |
temp_password: "{{ lookup('pipe', genpass) }}" | |
admin_password: "{{ lookup('pipe', genpass+' ') }}" | |
admin_username: "{{ lookup('pipe', genpass+' ') }}" | |
vars: | |
genpass: "dd if=/dev/urandom bs=32 count=1 2>/dev/null | base64 -w 0 | tr -cd 'A-Za-z' | dd bs=16 count=1 2>/dev/null" | |
- name: create temp user | |
command: "hammer user create --admin 1 --login temp_user --password {{ temp_password }} --firstname Temp --lastname User --default-organization-id 1 --default-location-id 2 --auth-source-id 1 --mail example@example.com" | |
notify: delete temp user | |
- name: update admin user | |
command: "hammer -u temp_user -p {{ temp_password }} user update --login admin --new-login {{ admin_username }} --password {{ admin_password }}" | |
notify: display user and password |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment