- hosts: "review" tasks: - name: Wait for Gerrit to be up uri: url: http://localhost:8081/a/accounts/admin/sshkeys method: GET user: admin password: secret register: result until: result.status == 200 and not result.redirected delay: 1 retries: 120 - name: Create openstack-project-creator user uri: url: http://localhost:8081/a/accounts/openstack-project-creator method: PUT user: admin password: secret body_format: json body: username: 'openstack-project-creator' name: 'Project Creator' email: 'project.creator@example.com' http_password: 'secret' groups: - Administrators status_code: 201 - name: Create CI group uri: url: 'http://localhost:8081/a/groups/CI-tools' method: PUT user: admin password: secret body_format: json body: description: 'Continuous Integration Tools' status_code: 201 - name: Create Zuul user uri: url: http://localhost:8081/a/accounts/zuul method: PUT user: admin password: secret body_format: json body: name: 'Zuul' email: 'zuul@example.com' http_password: 'secret' status_code: 201 - name: Add Zuul to group uri: url: 'http://localhost:8081/a/groups/CI-tools/members/zuul' method: PUT user: admin password: secret status_code: 201 - name: Get group UUID uri: url: 'http://localhost:8081/a/groups/CI-tools' method: GET user: admin password: secret status_code: 200 return_content: yes register: group_raw - name: Debug serialized json debug: var: group_raw - name: Deserialize returned data to internal variable. set_fact: # The first 4 bytes of the returned data are )]}' which is # invalid json. group_json: '{{ group_raw.content | regex_replace("^....", "") | from_json }}' - name: Debug deserialized json debug: var: group_json - name: Setup key and initial gerrit config shell: executable: /bin/bash cmd: | set -xe ssh-keygen -t ed25519 -f /root/.ssh/id_25519 -P "" curl -X POST --user "admin:secret" -H "Content-Type: text/plain" -d@/root/.ssh/id_25519.pub http://localhost:8081/a/accounts/admin/sshkeys git config --global user.name "Admin" git config --global user.email "admin@example.com" git clone http://admin:secret@localhost:8081/a/All-Projects pushd All-Projects echo "{{ group_json.id }} CI-tools" >> groups # noqa 203 git commit -a -m "Add CI-tools group" git push origin HEAD:refs/meta/config cat >> project.config << EOF [label "Verified"] function = MaxWithBlock value = -2 Fails value = -1 Doesn't seem to work value = 0 No score value = +1 Works for me value = +2 Verified [access "refs/heads/*"] label-Verified = -2..+2 group CI-tools EOF git commit -a -m 'Update All-Project configuration' git push origin HEAD:refs/meta/config popd # openstack-project-creator bootstrapping curl -X POST --user "openstack-project-creator:secret" -H "Content-Type: text/plain" -d@/home/gerrit2/review_site/etc/ssh_project_rsa_key.pub http://localhost:8081/a/accounts/openstack-project-creator/sshkeys # This is helpful on a held node when you're trying to fix/enhance # the Zuul summary plugin. You can build it locally, scp the new # .jar to /tmp and run this to deploy your changes. - name: Create summary plugin helper script shell: executable: /bin/bash cmd: | set -xe cat > /root/deploy-zuul-results-summary.sh << EOF #!/bin/bash echo "Copying plugin" docker cp /tmp/zuul-results-summary.jar \ gerrit-compose_gerrit_1:/var/gerrit/plugins/ echo "Reloading" ssh -i /root/.ssh/id_25519 -p 29418 admin@localhost \ gerrit plugin reload zuul-results-summary echo "Done" EOF chmod a+x /root/deploy-zuul-results-summary.sh - name: Create temp dir for project creation shell: mktemp -d register: project_tmp - name: Create project project in Gerrit uri: url: http://localhost:8081/a/projects/y%2Ftestproject method: PUT user: admin password: secret status_code: 201 - name: Create initial commit and change in testproject shell: executable: /bin/sh chdir: "{{ project_tmp.stdout }}" cmd: | set -x git init . cat >.gitreview <file-1.txt <file-2.txt <file-3.txt <