From 85ec3aecfd60543a36a8c4ec325ceb547cfb1e12 Mon Sep 17 00:00:00 2001 From: Trevor Bramwell Date: Wed, 13 Mar 2019 15:41:12 -0700 Subject: [PATCH] Fix uploading workshop user's ssh pubkey to Gerrit 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 --- init/playbooks/site.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/init/playbooks/site.yaml b/init/playbooks/site.yaml index 60b8a8b..88ee798 100644 --- a/init/playbooks/site.yaml +++ b/init/playbooks/site.yaml @@ -23,16 +23,16 @@ 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: -- 2.16.6