Skip to content

Commit dbe778b

Browse files
mdellwegggainey
authored andcommitted
Modernize playbooks
1 parent a84a214 commit dbe778b

2 files changed

Lines changed: 33 additions & 16 deletions

File tree

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Ansible playbook to create the pulp service containers image
22
---
3-
- hosts: "localhost"
3+
- name: "Build CI Container Image"
4+
hosts: "localhost"
45
gather_facts: false
56
vars_files:
67
- "vars/main.yaml"
@@ -9,6 +10,7 @@
910
ansible.builtin.template:
1011
src: "Containerfile.j2"
1112
dest: "Containerfile"
13+
1214
- name: "Build pulp image"
1315
# We build from the ../.. (parent dir of pulpcore git repo) Docker build
1416
# "context" so that repos like pulp-smash are accessible to Docker
@@ -18,9 +20,20 @@
1820
# 1-off-builds and CI purposes (which has no cache across CI runs.)
1921
# Run build.yaml with -e cache=false if your builds are using outdated
2022
# layers.
21-
command: "docker build --network host --no-cache={{ not cache | default(true) | bool }} -t {{ image.name }}:{{ image.tag }} -f {{ playbook_dir }}/Containerfile ../../.."
23+
ansible.builtin.command:
24+
argv:
25+
- "docker"
26+
- "build"
27+
- "--network"
28+
- "host"
29+
- "--no-cache={{ not cache | default(true) | bool }}"
30+
- "-t"
31+
- "{{ image.name }}:{{ image.tag }}"
32+
- "-f"
33+
- "{{ playbook_dir }}/Containerfile"
34+
- "../../.."
2235

2336
- name: "Clean image cache"
24-
docker_prune:
25-
images : true
37+
community.docker.docker_prune:
38+
images: true
2639
...

templates/github/.ci/ansible/start_container.yaml

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Ansible playbook to start the pulp service container and its supporting services
22
---
3-
- hosts: "localhost"
3+
- name: "Start CI Containers"
4+
hosts: "localhost"
45
gather_facts: false
56
vars_files:
67
- "vars/main.yaml"
@@ -14,16 +15,16 @@
1415
- "settings"
1516

1617
- name: "Generate Pulp Settings"
17-
template:
18+
ansible.builtin.template:
1819
src: "settings.py.j2"
1920
dest: "settings/settings.py"
2021

2122
- name: "Setup docker networking"
22-
docker_network:
23+
community.docker.docker_network:
2324
name: "pulp_ci_bridge"
2425

2526
- name: "Start Service Containers"
26-
docker_container:
27+
community.docker.docker_container:
2728
name: "{{ item.name }}"
2829
image: "{{ item.image }}"
2930
auto_remove: true
@@ -39,12 +40,12 @@
3940
loop: "{{ services | default([]) }}"
4041

4142
- name: "Retrieve Docker Network Info"
42-
docker_network_info:
43+
community.docker.docker_network_info:
4344
name: "pulp_ci_bridge"
4445
register: "pulp_ci_bridge_info"
4546

4647
- name: "Update /etc/hosts"
47-
lineinfile:
48+
ansible.builtin.lineinfile:
4849
path: "/etc/hosts"
4950
regexp: "\\s{{ item.value.Name }}\\s*$"
5051
line: "{{ item.value.IPv4Address | ansible.utils.ipaddr('address') }}\t{{ item.value.Name }}"
@@ -61,7 +62,8 @@
6162
state: "present"
6263
when: "s3_test | default(false)"
6364

64-
- block:
65+
- name: "Wait on Services"
66+
block:
6567
- name: "Wait for azurite"
6668
ansible.builtin.uri:
6769
url: "http://ci-azurite:10000/"
@@ -83,11 +85,12 @@
8385
delay: 5
8486
rescue:
8587
- name: "Output pulp container log"
86-
command: "docker logs pulp"
88+
ansible.builtin.command:
89+
cmd: "docker logs pulp"
8790
failed_when: true
8891

8992
- name: "Check version of component being tested"
90-
assert:
93+
ansible.builtin.assert:
9194
that:
9295
- "(result.json.versions | items2dict(key_name='component', value_name='version'))[item.app_label] | canonical_semver == (component_version | canonical_semver)"
9396
fail_msg: |
@@ -96,14 +99,15 @@
9699
loop: "{{ 'plugins' | ansible.builtin.extract(lookup('ansible.builtin.file', '../../template_config.yml') | from_yaml) }}"
97100

98101
- name: "Set pulp password in .netrc"
99-
copy:
102+
ansible.builtin.copy:
100103
dest: "~/.netrc"
101104
content: |
102105
machine pulp
103106
login admin
104107
password password
105108
106-
- hosts: "pulp"
109+
- name: "Prepare Pulp Application Container"
110+
hosts: "pulp"
107111
gather_facts: false
108112
tasks:
109113
- name: "Create directory for pulp-smash config"
@@ -118,6 +122,6 @@
118122
dest: "/var/lib/pulp/.config/pulp_smash/settings.json"
119123

120124
- name: "Set pulp admin password"
121-
command:
125+
ansible.builtin.command:
122126
cmd: "pulpcore-manager reset-admin-password --password password"
123127
...

0 commit comments

Comments
 (0)