gerritlib/tools/playbooks/setup.yaml

56 lines
1.9 KiB
YAML

- hosts: localhost
gather_facts: false
tasks:
- name: Wait for Gerrit to start
wait_for:
host: gerrit
port: 29418
- name: Generate admin SSH key for Gerrit
command: ssh-keygen -f /var/ssh/admin -N ''
args:
creates: /var/ssh/admin.pub
# The Gerrit container puts up a helpful info page the first time
# you hit the web server; get past that.
- name: Get Gerrit first login screen
uri:
url: http://gerrit:8080/a/accounts/self/sshkeys
method: GET
user: admin
password: secret
ignore_errors: true
- name: Add admin SSH key to Gerrit
uri:
url: http://gerrit:8080/a/accounts/self/sshkeys
method: POST
user: admin
password: secret
body: "{{ lookup('file', '/var/ssh/admin.pub') }}"
status_code: 201
HEADER_Content-Type: text/plain
- name: Create temp dir for Gerrit config update
shell: mktemp -d
register: gerrit_tmp
- name: Set All-Project repo location
set_fact:
all_projects_repo: "{{ gerrit_tmp.stdout }}/All-Projects"
- name: Checkout All-Projects config
git:
repo: ssh://gerrit:29418/All-Projects/
ssh_opts: "-o StrictHostKeyChecking=no -i /var/ssh/admin -l admin"
dest: "{{ all_projects_repo }}"
refspec: '+refs/meta/config:refs/meta/config'
version: refs/meta/config
- name: Copy new All-Projects config into place
copy:
src: "/var/playbooks/project.config"
dest: "{{ all_projects_repo }}/project.config"
- name: Update All-Projects config in Gerrit
shell: |
git config user.email 'admin@example.com'
git commit -a -m 'update config'
git push http://admin:secret@gerrit:8080/All-Projects +HEAD:refs/meta/config
args:
chdir: "{{ all_projects_repo }}"
warn: false