Fix uploading workshop user's ssh pubkey to Gerrit 20/14920/1
authorTrevor Bramwell <tbramwell@linuxfoundation.org>
Wed, 13 Mar 2019 22:41:12 +0000 (15:41 -0700)
committerTrevor Bramwell <tbramwell@linuxfoundation.org>
Wed, 13 Mar 2019 22:41:12 +0000 (15:41 -0700)
By default the 'uri' module will use "Content-Type: 'raw'", while Gerrit
only accepts 'text/plain' when uploading sshkeys. Forcing basic auth
also ensures the request passes username/password instead of looking for
an 401 HTTP response before submitting the data.

Change-Id: Idadfa50a4b6e81f6c8cfc5d6f839c53df8be5417
Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
init/playbooks/site.yaml

index 60b8a8b..88ee798 100644 (file)
             method: 'POST'
             body: "username=workshop&password=workshop"
             status_code: 302
-      - name: Remove ssh-rsa from sshkey
-        set_fact:
-            workshop_ssh_key_modified: "{{ lookup('file', '{{ workshop_ssh_keyfile }}.pub') }}"
       - name: Upload sshkey to Admin user
         uri:
             url: 'http://gerrit:8080/a/accounts/self/sshkeys'
             method: 'POST'
             user: 'workshop'
             password: 'workshop'
-            body: "{{ workshop_ssh_key_modified }}"
+            force_basic_auth: true
+            headers:
+                Content-Type: 'text/plain'
+            body: "{{ lookup('file', '{{ workshop_ssh_keyfile }}.pub') }}"
             status_code: 201
       - name: Wait for Gerrit SSH Interface
         wait_for: