Use slurp to collect the swift 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.

Closes-Bug: #1506291
Change-Id: I3ba5cdc944f38c67762860dc0d06bd5c35eeb269
This commit is contained in:
Jesse Pretorius 2016-01-13 11:16:00 +00:00 committed by Jesse Pretorius (odyssey4me)
parent 3a53450adc
commit d954d599bd
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: "{{ swift_system_user_name }}" user: "{{ swift_system_user_name }}"
key: "{{ hostvars[item]['swift_pubkey'] }}" key: "{{ hostvars[item]['swift_pubkey'] | b64decode }}"
with_items: groups['swift_all'] + groups['swift_remote_all'] with_items: groups['swift_all'] + groups['swift_remote_all']
tags: tags:
- swift-key - swift-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 {{ swift_system_home_folder }}/.ssh/id_rsa.pub src: "{{ swift_system_home_folder }}/.ssh/id_rsa.pub"
register: swift_pub register: swift_pub
changed_when: false changed_when: false
tags: tags:
@ -24,7 +24,7 @@
- name: Register a fact for the swift pub key - name: Register a fact for the swift pub key
set_fact: set_fact:
swift_pubkey: "{{ swift_pub.stdout }}" swift_pubkey: "{{ swift_pub.content }}"
tags: tags:
- swift-key - swift-key
- swift-key-create - swift-key-create