|
| 1 | +--- |
| 2 | +- name: Verify Photon deployment |
| 3 | + hosts: all |
| 4 | + gather_facts: false |
| 5 | + vars: |
| 6 | + photon_database_path: /tmp/molecule-photon-data |
| 7 | + tasks: |
| 8 | + - name: Inspect Photon container |
| 9 | + community.docker.docker_container_info: |
| 10 | + name: photon |
| 11 | + register: photon_container |
| 12 | + |
| 13 | + - name: Assert Photon container configuration |
| 14 | + ansible.builtin.assert: |
| 15 | + that: |
| 16 | + - photon_container.container.State.Status == 'running' |
| 17 | + - photon_container.container.Config.Image == 'python:3.13-alpine' |
| 18 | + - photon_container.container.HostConfig.RestartPolicy.Name == 'always' |
| 19 | + - >- |
| 20 | + photon_container.container.HostConfig.PortBindings['2322/tcp'][0].HostPort |
| 21 | + == '12322' |
| 22 | + - >- |
| 23 | + photon_container.container.Mounts | selectattr('Destination', 'equalto', |
| 24 | + '/photon/photon_data') | list | length == 1 |
| 25 | + - >- |
| 26 | + (photon_container.container.Mounts | |
| 27 | + selectattr('Destination', 'equalto', '/photon/photon_data') | |
| 28 | + map(attribute='Source') | first) == photon_database_path |
| 29 | + - photon_container.container.Config.Env is contains('PHOTON_UPDATE_STRATEGY=CONTINUOUS') |
| 30 | + - photon_container.container.Config.Env is contains('PHOTON_UPDATE_INTERVAL=3600') |
| 31 | + |
| 32 | + - name: Check Photon API endpoint from the container |
| 33 | + community.docker.docker_container_exec: |
| 34 | + container: photon |
| 35 | + command: >- |
| 36 | + python -c "from urllib.request import urlopen; |
| 37 | + assert urlopen('http://127.0.0.1:2322/').status == 200" |
| 38 | + register: photon_api_check |
| 39 | + changed_when: false |
| 40 | + |
| 41 | + - name: Assert Photon API endpoint succeeded |
| 42 | + ansible.builtin.assert: |
| 43 | + that: photon_api_check.rc == 0 |
0 commit comments