Use slurp to collect the repo_server ssh keys

Extracting the ssh public key using cat and storing the result in a
fact has resulted in periodic failures in the collection of the key,
and thereafter the failure to appropriately place that key into the
authorised_keys file.

This patch changes the collection method to use the Ansible slurp
module which has been found to be more reliable.

Change-Id: I68699e7b59630cc3bc6113285edcb1ab936160ce
This commit is contained in:
Jesse Pretorius 2016-02-29 13:29:26 +00:00 committed by Jimmy McCrory
parent 4ee0d39710
commit 6ea680c062
2 changed files with 4 additions and 4 deletions

View File

@ -16,7 +16,7 @@
- name: Create authorized keys file from host vars - name: Create authorized keys file from host vars
authorized_key: authorized_key:
user: "{{ repo_service_user_name }}" user: "{{ repo_service_user_name }}"
key: "{{ hostvars[item]['repo_pubkey'] }}" key: "{{ hostvars[item]['repo_pubkey'] | b64decode }}"
with_items: groups['repo_all'] with_items: groups['repo_all']
tags: tags:
- repo-key - repo-key

View File

@ -14,8 +14,8 @@
# limitations under the License. # limitations under the License.
- name: Get public key contents and store as var - name: Get public key contents and store as var
command: | slurp:
cat {{ repo_service_home_folder }}/.ssh/id_rsa.pub src: "{{ repo_service_home_folder }}/.ssh/id_rsa.pub"
register: repo_pub register: repo_pub
changed_when: false changed_when: false
tags: tags:
@ -24,7 +24,7 @@
- name: Register a fact for the repo user pub key - name: Register a fact for the repo user pub key
set_fact: set_fact:
repo_pubkey: "{{ repo_pub.stdout }}" repo_pubkey: "{{ repo_pub.content }}"
tags: tags:
- repo-key - repo-key
- repo-key-create - repo-key-create