diff options
author | Pedro Alvarez <pedro.alvarez@codethink.co.uk> | 2014-07-14 15:10:09 +0000 |
---|---|---|
committer | Pedro Alvarez <pedro.alvarez@codethink.co.uk> | 2014-07-14 15:10:09 +0000 |
commit | 160fd3f2f1d372751836c0073bdc944df1cfbb91 (patch) | |
tree | d6b46ce1ec600400883e53b82e12b390fa73f262 /ansible/roles/trove-setup/tasks/gitano-admin-setup.yml | |
parent | eafba37e2bfc3897e3e7f65f2ce087fbee358f43 (diff) | |
parent | d349c9a35d3d53ebfc9f26df373e84fa5986a1b6 (diff) | |
download | trove-setup-160fd3f2f1d372751836c0073bdc944df1cfbb91.tar.gz |
Merge branch 'baserock/pedroalvarez/trove-ansible3'
Reviewed-by: Richard Maw
Reviewed-by: Lars Wirzenius
Diffstat (limited to 'ansible/roles/trove-setup/tasks/gitano-admin-setup.yml')
-rw-r--r-- | ansible/roles/trove-setup/tasks/gitano-admin-setup.yml | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/ansible/roles/trove-setup/tasks/gitano-admin-setup.yml b/ansible/roles/trove-setup/tasks/gitano-admin-setup.yml new file mode 100644 index 0000000..c4c3eb2 --- /dev/null +++ b/ansible/roles/trove-setup/tasks/gitano-admin-setup.yml @@ -0,0 +1,39 @@ +# Depends on: +# - gitano-setup.yml +--- +- name: Check if the admin user is configured in gitano (This task can fail) + shell: su git -c 'ssh git@localhost user' | grep '^'{{ TROVE_ADMIN_USER|regex_replace('(\\W)', '\\\\\\1')|quote}}':' + register: gitano_admin_user + changed_when: False + ignore_errors: True +# If the admin user doesn't exist +- name: Create the admin user + shell: su git -c 'ssh git@localhost user add '{{ TROVE_ADMIN_USER|quote|quote|quote}}' '{{ TROVE_ADMIN_EMAIL|quote|quote|quote }}' '{{ TROVE_ADMIN_NAME|quote|quote|quote }} + when: gitano_admin_user|failed + +- name: Check if admin user is in trove-admin group in gitano (This task can fail) + shell: su git -c 'ssh git@localhost as '{{ TROVE_ADMIN_USER|quote|quote|quote }}' whoami' | grep 'trove-admin. Trove-local administration' + register: gitano_admin_group + changed_when: False + ignore_errors: True +# If the admin user is not in the trove-admin group +- name: Add the admin user to the trove-admin group in gitano + shell: su git -c 'ssh git@localhost group adduser trove-admin '{{ TROVE_ADMIN_USER|quote|quote|quote }} + when: gitano_admin_group|failed + +- name: Check if admin user has a sshkey configured in gitano (This task can fail) + shell: su git -c 'ssh git@localhost as '{{ TROVE_ADMIN_USER|quote|quote|quote }}' sshkey' 2>&1 | grep WARNING + register: gitano_admin_key + changed_when: False + ignore_errors: True +# If admin user doesn't have an sshkey configured +- name: Create /home/git/keys/ to store sshkeys + file: path=/home/git/keys state=directory owner=git group=git + when: gitano_admin_key|success +- name: Copy the TROVE_ADMIN_SSH_PUBKEY to /home/git/keys/admin.key.pub + copy: src={{ TROVE_ADMIN_SSH_PUBKEY }} dest=/home/git/keys/admin.key.pub mode=0644 + when: gitano_admin_key|success + +- name: Add /home/git/keys/admin.key.pub ssh key to the admin user in gitano. + shell: su git -c 'ssh git@localhost as '{{ TROVE_ADMIN_USER|quote|quote|quote}}' sshkey add default < /home/git/keys/admin.key.pub' + when: gitano_admin_key|success |