Skip to content

Commit 6d44736

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "CI: Move pre tasks into roles"
2 parents cfa266a + 96d6a94 commit 6d44736

File tree

3 files changed

+77
-195
lines changed

3 files changed

+77
-195
lines changed

.zuul.d/base.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@
126126
run: tests/playbooks/run.yml
127127
post-run: tests/playbooks/post.yml
128128
attempts: 5
129+
roles:
130+
- zuul: openstack/ansible-collection-kolla
129131
irrelevant-files:
130132
- ^.*\.rst$
131133
- ^doc/.*
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
- name: Create dir for kolla logs
3+
ansible.builtin.file:
4+
path: "{{ kolla_logs_dir }}"
5+
state: directory
6+
7+
- name: Dump host info to logs
8+
ansible.builtin.command: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/tools/dump_info.sh"
9+
args:
10+
chdir: "{{ kolla_logs_dir }}"
11+
12+
- name: Create dir for kolla build logs
13+
ansible.builtin.file:
14+
path: "{{ kolla_build_logs_dir }}"
15+
state: directory
16+
17+
- name: Install Python3 pip and setuptools
18+
ansible.builtin.package:
19+
name:
20+
- python3-pip
21+
- python3-setuptools
22+
become: true
23+
24+
# NOTE(hrw): On RedHat systems venv is part of python3-libs
25+
- name: Install Python3 venv on Debian systems
26+
ansible.builtin.package:
27+
name:
28+
- python3-venv
29+
become: true
30+
when: ansible_facts.os_family == "Debian"
31+
32+
- name: Install dbus-python dependencies on Debian systems
33+
ansible.builtin.package:
34+
name:
35+
- python3-dev
36+
- libdbus-glib-1-dev
37+
become: true
38+
when: ansible_facts.os_family == "Debian"
39+
40+
- name: Install dbus-python dependencies on EL systems
41+
ansible.builtin.package:
42+
name:
43+
- python3-devel
44+
- dbus-glib-devel
45+
- dbus-daemon
46+
become: true
47+
when: ansible_facts.os_family == "RedHat"
48+
49+
- name: Install kolla in a venv
50+
ansible.builtin.pip:
51+
name:
52+
- "pip"
53+
- "."
54+
state: latest
55+
virtualenv: "{{ virtualenv_path }}"
56+
virtualenv_command: "python3.{{ ansible_facts.python.version.minor }} -m venv"
57+
chdir: "{{ zuul.project.src_dir }}"
58+
59+
- name: Configure container engine
60+
ansible.builtin.include_role:
61+
name: "{{ container_engine }}"
62+
63+
- name: Install podman/docker_sdk in a venv
64+
vars:
65+
virtualenv: "{{ virtualenv_path }}"
66+
docker_sdk_virtualenv_owner: "{{ lookup('env', 'USER') }}"
67+
ansible.builtin.include_role:
68+
name: "{{ container_engine }}_sdk"
69+
70+
- name: Ensure container engine socket is world-writable
71+
ansible.builtin.file:
72+
path: "{{ '/run/docker.sock' if container_engine == 'docker' else '/run/podman/podman.sock' }}"
73+
mode: 0666
74+
become: true

tests/playbooks/pre.yml

Lines changed: 1 addition & 195 deletions
Original file line numberDiff line numberDiff line change
@@ -4,198 +4,4 @@
44
- ../vars/zuul.yml
55
roles:
66
- configure-ephemeral
7-
tasks:
8-
- name: Create dir for kolla logs
9-
file:
10-
path: "{{ kolla_logs_dir }}"
11-
state: directory
12-
13-
- name: Dump host info to logs
14-
command: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/tools/dump_info.sh"
15-
args:
16-
chdir: "{{ kolla_logs_dir }}"
17-
18-
- name: Create dir for kolla build logs
19-
file:
20-
path: "{{ kolla_build_logs_dir }}"
21-
state: directory
22-
23-
- name: Install Python3 pip and setuptools
24-
package:
25-
name:
26-
- python3-pip
27-
- python3-setuptools
28-
become: true
29-
30-
# NOTE(hrw): On RedHat systems venv is part of python3-libs
31-
- name: Install Python3 venv on Debian systems
32-
package:
33-
name:
34-
- python3-venv
35-
become: true
36-
when:
37-
ansible_os_family == "Debian"
38-
39-
- name: Create virtualenv
40-
command: python3 -m venv {{ virtualenv_path }}
41-
42-
- name: Install kolla
43-
command: "{{ virtualenv_path }}/bin/python -m pip install {{ zuul.project.src_dir }}"
44-
45-
- name: Install docker python library
46-
command: "{{ virtualenv_path }}/bin/python -m pip install docker"
47-
when: container_engine == "docker"
48-
49-
- name: Install podman python library
50-
command: "{{ virtualenv_path }}/bin/python -m pip install podman rich"
51-
when: container_engine == "podman"
52-
53-
- name: Configure Docker repo for Debian/Ubuntu
54-
block:
55-
- name: Add key for Docker APT repository
56-
apt_key:
57-
url: "{{ nodepool_docker_proxy }}/{{ ansible_distribution | lower }}/gpg"
58-
state: present
59-
60-
- name: Add Docker APT repository
61-
apt_repository:
62-
repo: "deb {{ nodepool_docker_proxy }}/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable"
63-
state: present
64-
65-
- name: Ensure AppArmor is installed
66-
package:
67-
name: apparmor
68-
state: present
69-
70-
when:
71-
- ansible_os_family == "Debian"
72-
- container_engine == "docker"
73-
become: true
74-
75-
- name: Configure Docker repo for CentOS
76-
block:
77-
- name: Add Docker repository
78-
yum_repository:
79-
name: docker
80-
description: Docker
81-
baseurl: "{{ nodepool_docker_proxy }}/centos/9/$basearch/stable"
82-
enabled: yes
83-
gpgcheck: yes
84-
gpgkey: "{{ nodepool_docker_proxy }}/centos/gpg"
85-
# module_hotfixes: True # enabled below (dnf, not yum, feature)
86-
87-
- name: Enable module_hotfixes in Docker YUM repository
88-
lineinfile:
89-
path: /etc/yum.repos.d/docker.repo
90-
line: 'module_hotfixes=True'
91-
when:
92-
- ansible_os_family == "RedHat"
93-
- container_engine == "docker"
94-
become: true
95-
96-
- name: Configure docker
97-
block:
98-
- name: Ensure /etc/docker exists
99-
become: true
100-
file:
101-
path: /etc/docker
102-
state: directory
103-
mode: 0755
104-
105-
- name: Configure registry-mirror in daemon.json
106-
become: true
107-
copy:
108-
dest: /etc/docker/daemon.json
109-
content: |
110-
{
111-
"registry-mirrors": [
112-
"http://{{ zuul_site_mirror_fqdn }}:8082/"
113-
]
114-
}
115-
116-
# NOTE(yoctozepto): We configure Docker before installing it because Debuntu starts services
117-
# during installation.
118-
- name: Install Docker
119-
package:
120-
name: docker-ce
121-
become: true
122-
123-
- name: Ensure Docker service is started
124-
service:
125-
name: docker
126-
state: started
127-
become: true
128-
129-
- name: Ensure Docker socket is world-writable
130-
file:
131-
path: /run/docker.sock
132-
mode: 0666
133-
become: true
134-
when:
135-
- container_engine == "docker"
136-
137-
- name: Configure podman
138-
block:
139-
- name: Ensure /etc/containers exists
140-
become: true
141-
file:
142-
path: /etc/containers
143-
state: directory
144-
mode: 0755
145-
146-
- name: Configure registries.conf
147-
become: true
148-
copy:
149-
dest: /etc/containers/registries.conf
150-
content: |
151-
unqualified-search-registries = ['docker.io']
152-
153-
[[registry]]
154-
prefix = "docker.io"
155-
location = "docker.io"
156-
157-
[[registry.mirror]]
158-
prefix = "docker.io"
159-
location = "{{ zuul_site_mirror_fqdn }}:8082"
160-
161-
- name: Install Podman
162-
package:
163-
name: podman
164-
become: true
165-
166-
# NOTE(jangutter): It appears that the default mount option
167-
# in the shipped `/etc/containers/storage.conf` for EL9 based distros
168-
# (Rocky, CentOS Stream, ...) has severe performance implications for
169-
# Kolla builds. This is because enabling `metacopy=on` disables `Native
170-
# Overlay Diff` This can be removed if the config is dropped from those
171-
# distros, or the underlying incompatibility can somehow be addressed.
172-
# Debian based distros do not ship `storage.conf` and seem
173-
# to be unaffected.
174-
- name: Remove metacopy, enable native overlay diff
175-
ini_file:
176-
path: /etc/containers/storage.conf
177-
section: storage.options.overlay
178-
option: mountopt
179-
value: '"nodev"'
180-
become: true
181-
when: ansible_os_family == "RedHat"
182-
183-
- name: Ensure Podman service is started
184-
service:
185-
name: podman
186-
state: started
187-
become: true
188-
189-
- name: Ensure Podman socket is world-writable
190-
file:
191-
path: /run/podman/podman.sock
192-
mode: 0666
193-
become: true
194-
when:
195-
- container_engine == "podman"
196-
197-
- name: Run multiarch/qemu-user-static image to support cross-arch build
198-
command:
199-
cmd: "{{ container_engine }} run --rm --privileged multiarch/qemu-user-static --reset -p yes"
200-
become: true
201-
when: ansible_facts.architecture != (base_arch | default('x86_64'))
7+
- kolla-build-deps

0 commit comments

Comments
 (0)