Skip to content

Commit 2e8cced

Browse files
committed
Initial Zuul config and testing migration
1 parent 0035b8e commit 2e8cced

File tree

16 files changed

+157
-22
lines changed

16 files changed

+157
-22
lines changed

.ansible-lint

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ exclude_paths:
55
- changelogs/
66
- .github/
77

8+
mock_roles:
9+
- ensure-docker
10+
- ensure-pip
11+
- ensure-podman
12+
- ensure-output-dirs
13+
814
skip_list:
915
- var-naming[no-role-prefix]
1016

.github/workflows/test.yml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,6 @@ on:
99
- master
1010

1111
jobs:
12-
lint:
13-
runs-on: ubuntu-latest
14-
strategy:
15-
fail-fast: false
16-
steps:
17-
# Checks-out the repository under $GITHUB_WORKSPACE, so it's accessible to the job
18-
- uses: actions/checkout@v3
19-
20-
- name: Install dependencies
21-
run: |
22-
python -m pip install --upgrade pip
23-
pip install -r test-requirements.txt
24-
25-
- name: Linting code
26-
run: |
27-
ansible-lint -v --force-color
28-
antsibull-changelog lint
29-
3012
ansible-test:
3113
runs-on: ubuntu-latest
3214
strategy:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
# ansible-test output
55
/tests/output
6+
/.ansible
67

78
# Byte-compiled / optimized / DLL files
89
__pycache__/

lint-requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ansible
2+
ansible-lint<26

roles/cephadm/tasks/bootstrap.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
cmd: "cephadm shell -- ceph config set mon public_network {{ cephadm_public_network }}"
4444
become: true
4545
changed_when: true
46+
when: cephadm_public_network | length > 0
4647

4748
- name: Set cluster network
4849
command:
@@ -67,15 +68,16 @@
6768

6869
- name: Get cluster fsid
6970
command:
70-
cmd: "cephadm shell -- ceph fsid"
71+
cmd: "cephadm ls --no-detail"
7172
when: cephadm_fsid | length == 0
7273
become: true
7374
changed_when: false
7475
register: cephadm_fsid_current
7576

7677
- name: Template out cluster.yml
7778
vars:
78-
fsid: "{{ cephadm_fsid if cephadm_fsid | length > 0 else cephadm_fsid_current.stdout }}"
79+
current_fsid: "{{ cephadm_fsid_current.stdout | from_json | selectattr('name', 'search', 'mon') | map(attribute='fsid') | first }}"
80+
fsid: "{{ cephadm_fsid if cephadm_fsid | length > 0 else current_fsid }}"
7981
template:
8082
src: "templates/cluster.yml.j2"
8183
dest: "/var/run/ceph/{{ fsid }}/cephadm_cluster.yml"

roles/cephadm/tasks/prechecks.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11
---
2+
- name: Assert that required Ansible groups exist
3+
ansible.builtin.assert:
4+
that: "'{{ item }}' in group_names"
5+
msg: "Ansible '{{ item }}' group does not exist - please create one"
6+
loop:
7+
- ceph
8+
- mons
9+
- mgrs
10+
- osds
11+
12+
- name: Assert that cephadm_public_interface is set
13+
ansible.builtin.assert:
14+
that: cephadm_public_interface | length > 0
15+
msg: "Ansible Cephadm interface variable 'cephadm_public_interface' is not set"
16+
217
- name: Populate service facts
318
service_facts:
419

roles/cephadm/templates/cluster.yml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
---
33
service_type: host
44
hostname: {{ hostvars[host].ansible_facts.nodename }}
5-
{% set cephadm_admin_interface = hostvars[host]['cephadm_admin_interface'] %}
5+
{% set cephadm_admin_interface = hostvars[host]['cephadm_admin_interface'] | default(cephadm_admin_interface) %}
66
addr: {{ hostvars[host]['ansible_facts'][cephadm_admin_interface | replace('-', '_')]['ipv4']['address'] }}
77
labels:
88
{% if host in groups['mons'] %}

test-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ansible>=2.9
2-
ansible-lint<7
2+
ansible-lint<26
33
antsibull-changelog
44
mock
55
pytest

tests/playbooks/post.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
- name: Prepare logs
3+
hosts: all
4+
vars:
5+
zuul_output_dir: "{{ ansible_user_dir }}/zuul-output"
6+
tasks:
7+
- name: Print all facts
8+
copy:
9+
content: "{{ hostvars[inventory_hostname] | to_nice_json }}"
10+
dest: "{{ zuul_output_dir }}/facts.json"
11+
mode: "0600"

tests/playbooks/pre.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
- name: Prepare environment
3+
hosts: all
4+
any_errors_fatal: true
5+
vars:
6+
logs_dir: "/tmp/logs"
7+
roles:
8+
- ensure-output-dirs
9+
- ensure-pip
10+
- role: "ensure-docker"
11+
when: cephadm_container_engine == "docker"
12+
- role: "ensure-podman"
13+
when: cephadm_container_engine == "podman"

tests/playbooks/run.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
- name: Install catatonit package for Podman
3+
hosts: all
4+
any_errors_fatal: true
5+
tasks:
6+
- name: Install catatonit package for Podman
7+
package:
8+
name: catatonit
9+
state: present
10+
become: true
11+
12+
- name: Run tests
13+
hosts: all
14+
any_errors_fatal: true
15+
roles:
16+
- role: cephadm
17+
vars:
18+
cephadm_public_interface: "{{ ansible_default_ipv4.interface }}"

tox.ini

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[tox]
2+
minversion = 3.18
3+
envlist = py3,linters
4+
ignore_basepython_conflict = True
5+
skipsdist = True
6+
7+
[testenv]
8+
basepython = python3
9+
usedevelop = True
10+
allowlist_externals = bash
11+
find
12+
rm
13+
deps = -r{toxinidir}/test-requirements.txt
14+
passenv = http_proxy,HTTP_PROXY,https_proxy,HTTPS_PROXY,no_proxy,NO_PROXY, \
15+
OS_STDOUT_CAPTURE,OS_STDERR_CAPTURE,OS_LOG_CAPTURE,OS_TEST_TIMEOUT, \
16+
PYTHON,OS_TEST_PATH,LISTOPT,IDOPTION
17+
18+
[testenv:linters]
19+
deps =
20+
-r{toxinidir}/lint-requirements.txt
21+
allowlist_externals = bash
22+
find
23+
commands =
24+
{[testenv:ansible-lint]commands}
25+
26+
[testenv:ansible-lint]
27+
setenv = {[testenv:linters]setenv}
28+
deps = {[testenv:linters]deps}
29+
commands =
30+
ansible-lint -p --exclude zuul.d

zuul.d/base.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
- job:
3+
parent: base
4+
name: cephadm-base
5+
pre-run: tests/playbooks/pre.yml
6+
run: tests/playbooks/run.yml
7+
post-run: tests/playbooks/post.yml
8+
timeout: 7200
9+
post-timeout: 1800

zuul.d/jobs.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
- job:
3+
name: cephadm-jammy-singlenode-docker-reef
4+
parent: cephadm-base
5+
nodeset: cephadm-jammy-single
6+
vars:
7+
cephadm_ceph_release: reef
8+
cephadm_container_engine: docker
9+
10+
- job:
11+
name: cephadm-jammy-singlenode-podman-reef
12+
parent: cephadm-base
13+
nodeset: cephadm-jammy-single
14+
vars:
15+
cephadm_ceph_release: reef
16+
cephadm_container_engine: podman

zuul.d/nodesets.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
- nodeset:
3+
name: cephadm-jammy-single
4+
nodes:
5+
- name: primary
6+
label: ubuntu-jammy
7+
groups:
8+
- name: ceph
9+
nodes:
10+
- primary
11+
- name: mons
12+
nodes:
13+
- primary
14+
- name: mgrs
15+
nodes:
16+
- primary
17+
- name: osds
18+
nodes:
19+
- primary

zuul.d/project.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
- project:
3+
check:
4+
jobs:
5+
- cephadm-jammy-singlenode-docker-reef
6+
- cephadm-jammy-singlenode-podman-reef
7+
- tox-linters
8+
gate:
9+
jobs:
10+
- cephadm-jammy-singlenode-docker-reef
11+
- cephadm-jammy-singlenode-podman-reef

0 commit comments

Comments
 (0)