palvarez89

Untitled

Jul 11th, 2014
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.35 KB | None | 0 0
  1. diff --git a/ansible/roles/trove-setup/tasks/check.yml b/ansible/roles/trove-setup/tasks/check.yml
  2. index 7da6a57..d873030 100644
  3. --- a/ansible/roles/trove-setup/tasks/check.yml
  4. +++ b/ansible/roles/trove-setup/tasks/check.yml
  5. @@ -42,7 +42,7 @@
  6. when: MASON_PORT is not defined
  7.  
  8. - name: Calculate ESC_PREFIX
  9. - shell: echo -n {{ TROVE_ID | quote }} | perl -pe 's/([-+\(\).%*?^$\[\]])/%$1/g'
  10. + shell: echo -n {{ TROVE_ID|quote }} | perl -pe 's/([-+\(\).%*?^$\[\]])/%$1/g'
  11. register: var_esc_prefix
  12. changed_when: False
  13.  
  14. @@ -62,9 +62,9 @@
  15.  
  16. - name: Check if the ssh keys are unique
  17. shell: |
  18. - cat {{ TROVE_ADMIN_SSH_PUBKEY | quote}} \
  19. - {{ LORRY_SSH_PUBKEY | quote }} \
  20. - {{ WORKER_SSH_PUBKEY | quote }} \
  21. + cat {{ TROVE_ADMIN_SSH_PUBKEY|quote}} \
  22. + {{ LORRY_SSH_PUBKEY|quote }} \
  23. + {{ WORKER_SSH_PUBKEY|quote }} \
  24. | cut -d ' ' -f 1,2 | sort -u | wc -l
  25. changed_when: False
  26. register: number_ssh_keys
  27. diff --git a/ansible/roles/trove-setup/tasks/gitano-admin-setup.yml b/ansible/roles/trove-setup/tasks/gitano-admin-setup.yml
  28. index 59a7685..c4c3eb2 100644
  29. --- a/ansible/roles/trove-setup/tasks/gitano-admin-setup.yml
  30. +++ b/ansible/roles/trove-setup/tasks/gitano-admin-setup.yml
  31. @@ -2,27 +2,27 @@
  32. # - gitano-setup.yml
  33. ---
  34. - name: Check if the admin user is configured in gitano (This task can fail)
  35. - shell: su git -c 'ssh git@localhost user' | grep '^{{ TROVE_ADMIN_USER | regex_replace('(\\W)', '\\\\\\1') }}:'
  36. + shell: su git -c 'ssh git@localhost user' | grep '^'{{ TROVE_ADMIN_USER|regex_replace('(\\W)', '\\\\\\1')|quote}}':'
  37. register: gitano_admin_user
  38. changed_when: False
  39. ignore_errors: True
  40. # If the admin user doesn't exist
  41. - name: Create the admin user
  42. - shell: su git -c 'ssh git@localhost user add {{ TROVE_ADMIN_USER | quote}} {{ TROVE_ADMIN_EMAIL | quote }} {{ TROVE_ADMIN_NAME | quote }}'
  43. + 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 }}
  44. when: gitano_admin_user|failed
  45.  
  46. - name: Check if admin user is in trove-admin group in gitano (This task can fail)
  47. - shell: su git -c 'ssh git@localhost as {{ TROVE_ADMIN_USER | quote }} whoami' | grep 'trove-admin. Trove-local administration'
  48. + shell: su git -c 'ssh git@localhost as '{{ TROVE_ADMIN_USER|quote|quote|quote }}' whoami' | grep 'trove-admin. Trove-local administration'
  49. register: gitano_admin_group
  50. changed_when: False
  51. ignore_errors: True
  52. # If the admin user is not in the trove-admin group
  53. - name: Add the admin user to the trove-admin group in gitano
  54. - shell: su git -c 'ssh git@localhost group adduser trove-admin {{ TROVE_ADMIN_USER | quote }}'
  55. + shell: su git -c 'ssh git@localhost group adduser trove-admin '{{ TROVE_ADMIN_USER|quote|quote|quote }}
  56. when: gitano_admin_group|failed
  57.  
  58. - name: Check if admin user has a sshkey configured in gitano (This task can fail)
  59. - shell: su git -c 'ssh git@localhost as {{ TROVE_ADMIN_USER | quote }} sshkey' 2>&1 | grep WARNING
  60. + shell: su git -c 'ssh git@localhost as '{{ TROVE_ADMIN_USER|quote|quote|quote }}' sshkey' 2>&1 | grep WARNING
  61. register: gitano_admin_key
  62. changed_when: False
  63. ignore_errors: True
  64. @@ -35,5 +35,5 @@
  65. when: gitano_admin_key|success
  66.  
  67. - name: Add /home/git/keys/admin.key.pub ssh key to the admin user in gitano.
  68. - shell: su git -c 'ssh git@localhost as {{ TROVE_ADMIN_USER | quote }} sshkey add default < /home/git/keys/admin.key.pub'
  69. + shell: su git -c 'ssh git@localhost as '{{ TROVE_ADMIN_USER|quote|quote|quote}}' sshkey add default < /home/git/keys/admin.key.pub'
  70. when: gitano_admin_key|success
  71. diff --git a/ansible/roles/trove-setup/tasks/hostname.yml b/ansible/roles/trove-setup/tasks/hostname.yml
  72. index 6a2021b..b43284b 100644
  73. --- a/ansible/roles/trove-setup/tasks/hostname.yml
  74. +++ b/ansible/roles/trove-setup/tasks/hostname.yml
  75. @@ -2,7 +2,7 @@
  76. # - check.yml
  77. ---
  78. - name: Check the /etc/hostname and compare it with HOSTNAME (This task can fail)
  79. - shell: su -c '[ "$(cat /etc/hostname)" == {{ HOSTNAME | quote }} ]'
  80. + shell: su -c '[ "$(cat /etc/hostname)" == "'{{ HOSTNAME|quote }}'" ]'
  81. register: hostname_file
  82. ignore_errors: True
  83. changed_when: False
  84. @@ -10,11 +10,11 @@
  85.  
  86. # If /etc/hostname doesn't match with HOSTNAME
  87. - name: Rewrite /etc/hostname with HOSTNAME
  88. - shell: echo {{ HOSTNAME | quote }} > /etc/hostname
  89. + shell: echo {{ HOSTNAME|quote }} > /etc/hostname
  90. when: hostname_file|failed
  91.  
  92. - name: Check the actual hostname with `hostname` and compare it with HOSTNAME (This task can fail)
  93. - shell: sh -c '[ "$(hostname)" == {{ HOSTNAME | quote}} ]'
  94. + shell: sh -c '[ "$(hostname)" == "'{{ HOSTNAME|quote}}'" ]'
  95. register: actual_hostname
  96. ignore_errors: True
  97. changed_when: False
  98. @@ -22,5 +22,5 @@
  99.  
  100. # If `hostname` doesn't match with HOSTNAME
  101. - name: Change the hostname to HOSTNAME
  102. - shell: hostname {{ HOSTNAME | quote }}
  103. + shell: hostname {{ HOSTNAME|quote }}
  104. when: actual_hostname|failed
  105. diff --git a/ansible/roles/trove-setup/tasks/known-hosts-setup.yml b/ansible/roles/trove-setup/tasks/known-hosts-setup.yml
  106. index 7ebc0f7..6e988e0 100644
  107. --- a/ansible/roles/trove-setup/tasks/known-hosts-setup.yml
  108. +++ b/ansible/roles/trove-setup/tasks/known-hosts-setup.yml
  109. @@ -3,5 +3,5 @@
  110. ---
  111. - name: Add localhost and UPSTREAM_TROVE to /etc/ssh/ssh_known_hosts
  112. shell: |
  113. - ssh-keyscan localhost {{ UPSTREAM_TROVE | quote }} > /etc/ssh/ssh_known_hosts
  114. + ssh-keyscan localhost {{ UPSTREAM_TROVE|quote }} > /etc/ssh/ssh_known_hosts
  115. creates=/etc/ssh/ssh_known_hosts
  116. diff --git a/ansible/roles/trove-setup/tasks/lorry-controller-setup.yml b/ansible/roles/trove-setup/tasks/lorry-controller-setup.yml
  117. index 5f5cfbd..6ef321c 100644
  118. --- a/ansible/roles/trove-setup/tasks/lorry-controller-setup.yml
  119. +++ b/ansible/roles/trove-setup/tasks/lorry-controller-setup.yml
  120. @@ -4,7 +4,7 @@
  121. ---
  122. - name: Create the TROVE_ID/local-config/lorries repository
  123. shell: |
  124. - su git -c "ssh localhost create {{ TROVE_ID | quote }}/local-config/lorries"
  125. + su git -c 'ssh localhost create '{{ TROVE_ID|quote }}'/local-config/lorries'
  126. creates=/home/git/repos/{{ TROVE_ID }}/local-config/lorries.git
  127. - name: Create a temporary folder to copy templates
  128. shell: su git -c 'mktemp -d'
  129. @@ -21,15 +21,15 @@
  130.  
  131. - name: Configure the lorry-controller
  132. shell: |
  133. - su git -c "git clone ssh://localhost/{{ TROVE_ID | quote }}/local-config/lorries.git {{ lorry_controller_repository.stdout }}/lorries"
  134. - su git -c "cp {{ lorry_controller_templates.stdout }}/lorry-controller.conf {{ lorry_controller_repository.stdout }}/lorries/lorry-controller.conf"
  135. - su git -c "cp {{ lorry_controller_templates.stdout }}/README.lorry-controller {{ lorry_controller_repository.stdout }}/lorries/README"
  136. - su git -c "mkdir {{ lorry_controller_repository.stdout }}/lorries//open-source-lorries"
  137. - su git -c "cp /usr/share/trove-setup/open-source-lorries/README {{ lorry_controller_repository.stdout }}/lorries/open-source-lorries/README"
  138. - su git -c "mkdir {{ lorry_controller_repository.stdout }}/lorries/closed-source-lorries"
  139. - su git -c "cp /usr/share/trove-setup/closed-source-lorries/README {{ lorry_controller_repository.stdout }}/lorries/closed-source-lorries/README"
  140. - su git -c "cd {{ lorry_controller_repository.stdout }}/lorries; git add README lorry-controller.conf open-source-lorries/README closed-source-lorries/README; git commit -m 'Initial configuration'; git push origin master"
  141. - su git -c "rm -rf {{ lorry_controller_repository.stdout }}"
  142. + su git -c 'git clone ssh://localhost/'{{ TROVE_ID|quote|quote }}'/local-config/lorries.git '{{ lorry_controller_repository.stdout|quote|quote }}'/lorries'
  143. + su git -c 'cp '{{ lorry_controller_templates.stdout|quote|quote }}'/lorry-controller.conf '{{ lorry_controller_repository.stdout|quote|quote }}'/lorries/lorry-controller.conf'
  144. + su git -c 'cp '{{ lorry_controller_templates.stdout|quote|quote }}'/README.lorry-controller '{{ lorry_controller_repository.stdout|quote|quote }}'/lorries/README'
  145. + su git -c 'mkdir '{{ lorry_controller_repository.stdout|quote|quote }}'/lorries/open-source-lorries'
  146. + su git -c 'cp /usr/share/trove-setup/open-source-lorries/README '{{ lorry_controller_repository.stdout|quote|quote }}'/lorries/open-source-lorries/README'
  147. + su git -c 'mkdir '{{ lorry_controller_repository.stdout|quote|quote }}'/lorries/closed-source-lorries'
  148. + su git -c 'cp /usr/share/trove-setup/closed-source-lorries/README '{{ lorry_controller_repository.stdout|quote|quote }}'/lorries/closed-source-lorries/README'
  149. + su git -c 'cd '{{ lorry_controller_repository.stdout|quote|quote }}'/lorries; git add README lorry-controller.conf open-source-lorries/README closed-source-lorries/README; git commit -m "Initial configuration"; git push origin master'
  150. + su git -c 'rm -rf '{{ lorry_controller_repository.stdout|quote|quote }}
  151. creates=/home/git/repos/{{ TROVE_ID }}/local-config/lorries.git/refs/heads/master
  152.  
  153. # Migration: Remove the old lorry-controller cronjob if exists
  154. diff --git a/ansible/roles/trove-setup/tasks/releases.yml b/ansible/roles/trove-setup/tasks/releases.yml
  155. index 565f10c..2c20c6f 100644
  156. --- a/ansible/roles/trove-setup/tasks/releases.yml
  157. +++ b/ansible/roles/trove-setup/tasks/releases.yml
  158. @@ -3,7 +3,7 @@
  159. ---
  160. - name: Create the releases repository
  161. shell: |
  162. - su git -c 'ssh localhost create {{ TROVE_ID | quote }}/site/releases'
  163. + su git -c 'ssh localhost create '{{ TROVE_ID|quote|quote|quote }}'/site/releases'
  164. creates=/home/git/repos/{{ TROVE_ID }}/site/releases.git
  165.  
  166. - name: Create temporary folder to copy templates
  167. @@ -17,10 +17,10 @@
  168. register: releases_repository
  169. - name: Configure the releases repository
  170. shell: |
  171. - su git -c "git clone ssh://localhost/{{ TROVE_ID | quote }}/site/releases.git {{ releases_repository.stdout }}/releases"
  172. - su git -c "cp {{ releases_templates.stdout }}/releases-repo-README {{ releases_repository.stdout }}/releases/README"
  173. - su git -c "cd {{ releases_repository.stdout }}/releases; git add README; git commit -m 'Add README'; git push origin master"
  174. - su -c "rm -Rf {{ releases_repository.stdout }}"
  175. + su git -c 'git clone ssh://localhost/'{{ TROVE_ID|quote|quote }}'/site/releases.git '{{ releases_repository.stdout|quote|quote }}'/releases'
  176. + su git -c 'cp '{{ releases_templates.stdout|quote|quote }}'/releases-repo-README '{{ releases_repository.stdout|quote|quote }}'/releases/README'
  177. + su git -c 'cd '{{ releases_repository.stdout|quote|quote }}'/releases; git add README; git commit -m "Add README"; git push origin master'
  178. + su -c "rm -Rf {{ releases_repository.stdout|quote|quote }}"
  179. creates=/home/git/repos/{{ TROVE_ID }}/site/releases.git/refs/heads/master
  180.  
  181. - name: Link the releases repository to enable the access throught browser
  182. diff --git a/ansible/roles/trove-setup/tasks/site-groups.yml b/ansible/roles/trove-setup/tasks/site-groups.yml
  183. index 14d0153..e4aff14 100644
  184. --- a/ansible/roles/trove-setup/tasks/site-groups.yml
  185. +++ b/ansible/roles/trove-setup/tasks/site-groups.yml
  186. @@ -3,7 +3,7 @@
  187. ---
  188. # First of all check if the site groups are created.
  189. - name: Check for site groups (This task can fail)
  190. - shell: su git -c 'ssh git@localhost group list' | grep '^{{ item.name }}:'
  191. + shell: su git -c 'ssh git@localhost group list' | grep '^'{{ item.name|quote }}':'
  192. changed_when: False
  193. ignore_errors: True
  194. with_items:
  195. @@ -67,13 +67,13 @@
  196. # }
  197.  
  198. - name: Create the site groups needed.
  199. - shell: su git -c 'ssh git@localhost group add {{ item.item.name }} {{ item.item.description }}'
  200. + shell: su git -c 'ssh git@localhost group add '{{ item.item.name|quote|quote|quote }}' '{{ item.item.description|quote|quote|quote }}
  201. when: item|failed
  202. with_items: gitano_groups.results
  203.  
  204. # When the groups are created, check if they are linked.
  205. - name: Check for linked groups (This task can fail)
  206. - shell: su git -c 'ssh git@localhost group show {{ item.name }}' | grep '^ \[] {{ item.super_group }}'
  207. + shell: su git -c 'ssh git@localhost group show '{{ item.name|quote|quote|quote }} | grep '^ \[] '{{ item.super_group|quote }}
  208. changed_when: False
  209. ignore_errors: True
  210. with_items:
  211. @@ -83,6 +83,6 @@
  212. register: gitano_linked_groups
  213.  
  214. # Link the groups that weren't linked following the same strategy as for the groups
  215. -- shell: su git -c 'ssh git@localhost group addgroup {{ item.item.name }} {{ item.item.super_group }}'
  216. +- shell: su git -c 'ssh git@localhost group addgroup '{{ item.item.name|quote|quote|quote }}' '{{ item.item.super_group|quote|quote|quote }}
  217. when: item|failed
  218. with_items: gitano_linked_groups.results
  219. diff --git a/ansible/roles/trove-setup/tasks/users.yml b/ansible/roles/trove-setup/tasks/users.yml
  220. index 272fb77..c1ab866 100644
  221. --- a/ansible/roles/trove-setup/tasks/users.yml
  222. +++ b/ansible/roles/trove-setup/tasks/users.yml
  223. @@ -15,7 +15,7 @@
  224. - name: Create known_hosts for all the users
  225. shell: |
  226. cat /etc/ssh/ssh_host_*_key.pub | cut -d\ -f1,2 | \
  227. - sed -e"s/^/{{ TROVE_HOSTNAME | regex_replace('(\\W)', '\\\\\\1') }},localhost /" > \
  228. + sed -e's/^/'{{ TROVE_HOSTNAME|regex_replace('(\\W)', '\\\\\\1')|quote }}',localhost /' > \
  229. /home/{{ item }}/.ssh/known_hosts
  230. chown {{ item }}:{{ item }} /home/{{ item }}/.ssh/known_hosts
  231. chmod 600 /home/{{ item }}/.ssh/known_hosts
Advertisement
Add Comment
Please, Sign In to add comment