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>
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: