|
1 | 1 | # Ansible playbook to start the pulp service container and its supporting services |
2 | 2 | --- |
3 | | -- hosts: localhost |
| 3 | +- name: "Start CI Containers" |
| 4 | + hosts: "localhost" |
4 | 5 | gather_facts: false |
5 | 6 | vars_files: |
6 | | - - vars/main.yaml |
| 7 | + - "vars/main.yaml" |
7 | 8 | tasks: |
8 | 9 | - name: "Create Settings Directories" |
9 | | - file: |
| 10 | + ansible.builtin.file: |
10 | 11 | path: "{{ item }}" |
11 | | - state: directory |
| 12 | + state: "directory" |
12 | 13 | mode: "0755" |
13 | 14 | loop: |
14 | | - - settings |
15 | | - - ssh |
16 | | - - ~/.config/pulp_smash |
| 15 | + - "settings" |
17 | 16 |
|
18 | 17 | - name: "Generate Pulp Settings" |
19 | | - template: |
20 | | - src: settings.py.j2 |
21 | | - dest: settings/settings.py |
22 | | - |
23 | | - - name: "Configure pulp-smash" |
24 | | - copy: |
25 | | - src: smash-config.json |
26 | | - dest: ~/.config/pulp_smash/settings.json |
| 18 | + ansible.builtin.template: |
| 19 | + src: "settings.py.j2" |
| 20 | + dest: "settings/settings.py" |
27 | 21 |
|
28 | 22 | - name: "Setup docker networking" |
29 | | - docker_network: |
30 | | - name: pulp_ci_bridge |
| 23 | + community.docker.docker_network: |
| 24 | + name: "pulp_ci_bridge" |
31 | 25 |
|
32 | 26 | - name: "Start Service Containers" |
33 | | - docker_container: |
| 27 | + community.docker.docker_container: |
34 | 28 | name: "{{ item.name }}" |
35 | 29 | image: "{{ item.image }}" |
36 | 30 | auto_remove: true |
37 | 31 | recreate: true |
38 | 32 | privileged: true |
39 | 33 | networks: |
40 | | - - name: pulp_ci_bridge |
| 34 | + - name: "pulp_ci_bridge" |
41 | 35 | aliases: "{{ item.name }}" |
42 | 36 | volumes: "{{ item.volumes | default(omit) }}" |
43 | 37 | env: "{{ item.env | default(omit) }}" |
44 | 38 | command: "{{ item.command | default(omit) }}" |
45 | | - state: started |
| 39 | + state: "started" |
46 | 40 | loop: "{{ services | default([]) }}" |
47 | 41 |
|
48 | 42 | - name: "Retrieve Docker Network Info" |
49 | | - docker_network_info: |
50 | | - name: pulp_ci_bridge |
51 | | - register: pulp_ci_bridge_info |
| 43 | + community.docker.docker_network_info: |
| 44 | + name: "pulp_ci_bridge" |
| 45 | + register: "pulp_ci_bridge_info" |
52 | 46 |
|
53 | 47 | - name: "Update /etc/hosts" |
54 | | - lineinfile: |
55 | | - path: /etc/hosts |
| 48 | + ansible.builtin.lineinfile: |
| 49 | + path: "/etc/hosts" |
56 | 50 | regexp: "\\s{{ item.value.Name }}\\s*$" |
57 | | - line: "{{ item.value.IPv4Address | ipaddr('address') }}\t{{ item.value.Name }}" |
| 51 | + line: "{{ item.value.IPv4Address | ansible.utils.ipaddr('address') }}\t{{ item.value.Name }}" |
58 | 52 | loop: "{{ pulp_ci_bridge_info.network.Containers | dict2items }}" |
59 | 53 | become: true |
60 | 54 |
|
61 | 55 | - name: "Create Pulp Bucket" |
62 | 56 | amazon.aws.s3_bucket: |
63 | 57 | aws_access_key: "{{ minio_access_key }}" |
64 | 58 | aws_secret_key: "{{ minio_secret_key }}" |
65 | | - s3_url: "http://minio:9000" |
66 | | - region: eu-central-1 |
67 | | - name: pulp3 |
68 | | - state: present |
69 | | - when: s3_test | default(false) |
| 59 | + endpoint_url: "http://minio:9000" |
| 60 | + region: "eu-central-1" |
| 61 | + name: "pulp3" |
| 62 | + state: "present" |
| 63 | + when: "s3_test | default(false)" |
| 64 | + |
| 65 | + - name: "Wait on Services" |
| 66 | + block: |
| 67 | + - name: "Wait for azurite" |
| 68 | + ansible.builtin.uri: |
| 69 | + url: "http://ci-azurite:10000/" |
| 70 | + status_code: |
| 71 | + - 200 |
| 72 | + - 400 |
| 73 | + when: "azure_test | default(false)" |
| 74 | + retries: 2 |
| 75 | + delay: 5 |
70 | 76 |
|
71 | | - - block: |
72 | 77 | - name: "Wait for Pulp" |
73 | | - uri: |
74 | | - url: "http://pulp{{ lookup('env', 'PULP_API_ROOT') | default('\/pulp\/', True) }}api/v3/status/" |
75 | | - follow_redirects: all |
76 | | - validate_certs: no |
77 | | - register: result |
78 | | - until: result.status == 200 |
| 78 | + ansible.builtin.uri: |
| 79 | + url: "http://pulp{{ pulp_scenario_settings.api_root | default(pulp_settings.api_root | default('\/pulp\/', True), True) }}api/v3/status/" |
| 80 | + follow_redirects: "all" |
| 81 | + validate_certs: "no" |
| 82 | + register: "result" |
| 83 | + until: "result.status == 200" |
79 | 84 | retries: 12 |
80 | 85 | delay: 5 |
81 | 86 | rescue: |
82 | 87 | - name: "Output pulp container log" |
83 | | - command: "docker logs pulp" |
| 88 | + ansible.builtin.command: |
| 89 | + cmd: "docker logs pulp" |
84 | 90 | failed_when: true |
85 | 91 |
|
86 | 92 | - name: "Check version of component being tested" |
87 | | - assert: |
| 93 | + ansible.builtin.assert: |
88 | 94 | that: |
89 | | - - (result.json.versions | items2dict(key_name="component", value_name="version"))[item.app_label] | canonical_semver == (component_version | canonical_semver) |
| 95 | + - "(result.json.versions | items2dict(key_name='component', value_name='version'))[item.app_label] | canonical_semver == (component_version | canonical_semver)" |
90 | 96 | fail_msg: | |
91 | 97 | Component {{ item.app_label }} was expected to be installed in version {{ component_version }}. |
92 | 98 | Instead it is reported as version {{ (result.json.versions | items2dict(key_name="component", value_name="version"))[item.app_label] }}. |
93 | 99 | loop: "{{ 'plugins' | ansible.builtin.extract(lookup('ansible.builtin.file', '../../template_config.yml') | from_yaml) }}" |
94 | 100 |
|
95 | 101 | - name: "Set pulp password in .netrc" |
96 | | - copy: |
| 102 | + ansible.builtin.copy: |
97 | 103 | dest: "~/.netrc" |
98 | 104 | content: | |
99 | 105 | machine pulp |
100 | 106 | login admin |
101 | 107 | password password |
102 | 108 |
|
103 | | -- hosts: pulp |
| 109 | +- name: "Prepare Pulp Application Container" |
| 110 | + hosts: "pulp" |
104 | 111 | gather_facts: false |
105 | 112 | tasks: |
| 113 | + - name: "Create directory for pulp-smash config" |
| 114 | + ansible.builtin.file: |
| 115 | + path: "/var/lib/pulp/.config/pulp_smash/" |
| 116 | + state: "directory" |
| 117 | + mode: "0755" |
| 118 | + |
| 119 | + - name: "Configure pulp-smash" |
| 120 | + ansible.builtin.copy: |
| 121 | + src: "smash-config.json" |
| 122 | + dest: "/var/lib/pulp/.config/pulp_smash/settings.json" |
| 123 | + |
106 | 124 | - name: "Set pulp admin password" |
107 | | - command: |
| 125 | + ansible.builtin.command: |
108 | 126 | cmd: "pulpcore-manager reset-admin-password --password password" |
109 | 127 | ... |
0 commit comments