zuul/playbooks/tutorial/admin.yaml
James E. Blair 0df6e2d7ca Fix and improve Keycloak tutorial
The keycloak tutorial incorrectly instructed users to run
"docker-compose-compose".  Correct that.

Also, change the instructions to "stop" rather than "down" the
original containers so that the results of the quick-start tutorial
are still present.

Finally, verify that, and also add a verification that the intended
effect of the restart worked (by checking the available authn methods).

Change-Id: I43a17e27300126e8acdc1919ba2bbe98719ad604
2022-08-30 14:34:20 -07:00

79 lines
2.1 KiB
YAML

# Stop the basic tutorial
- name: Run docker-compose down
when: not local
shell:
cmd: docker-compose -p zuul-tutorial stop
chdir: src/opendev.org/zuul/zuul/doc/source/examples
- name: Run docker-compose down
when: local
shell:
cmd: docker-compose -p zuul-tutorial stop
chdir: ../../doc/source/examples
# Restart with the new config
- name: Run docker-compose up
when: not local
shell:
cmd: docker-compose -p zuul-tutorial up -d
chdir: src/opendev.org/zuul/zuul/doc/source/examples
environment:
ZUUL_TUTORIAL_CONFIG: "./keycloak/etc_zuul/"
- name: Run docker-compose up
when: local
shell:
cmd: docker-compose -p zuul-tutorial up -d
chdir: ../../doc/source/examples
environment:
ZUUL_TUTORIAL_CONFIG: "./keycloak/etc_zuul/"
# Start keycloak
- name: Run docker-compose up
when: not local
shell:
cmd: docker-compose -p zuul-tutorial-keycloak up -d
chdir: src/opendev.org/zuul/zuul/doc/source/examples/keycloak
- name: Run docker-compose up
when: local
shell:
cmd: docker-compose -p zuul-tutorial-keycloak up -d
chdir: ../../doc/source/examples/keycloak
# Verify that Zuul runs with the new config
- name: Wait for Zuul
uri:
url: http://localhost:9000/api/tenant/example-tenant/status
method: GET
return_content: true
status_code: 200
body_format: json
register: result
retries: 30
delay: 10
until: result.status == 200 and result.json["zuul_version"] is defined
changed_when: false
- name: Verify Keycloak authentication is available
uri:
url: http://localhost:9000/api/tenant/example-tenant/info
method: GET
return_content: true
status_code: 200
body_format: json
register: result
failed_when: result.json["info"]["capabilities"]["auth"]["realms"]["zuul-demo"]["authority"] != "http://keycloak:8082/realms/zuul-demo"
changed_when: false
- name: Verify that old builds are available
uri:
url: "http://localhost:9000/api/tenant/example-tenant/builds"
method: GET
return_content: true
status_code: 200
body_format: json
register: result
failed_when: "result.json | length < 4"
changed_when: false