Skip to content

Initial Zuul config #160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ exclude_paths:
- changelogs/
- .github/

mock_roles:
- ensure-docker
- ensure-pip
- ensure-podman
- ensure-output-dirs

skip_list:
- var-naming[no-role-prefix]

Expand Down
18 changes: 0 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,6 @@ on:
- master

jobs:
lint:
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
# Checks-out the repository under $GITHUB_WORKSPACE, so it's accessible to the job
- uses: actions/checkout@v3

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r test-requirements.txt

- name: Linting code
run: |
ansible-lint -v --force-color
antsibull-changelog lint

ansible-test:
runs-on: ubuntu-latest
strategy:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

# ansible-test output
/tests/output
/.ansible

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
3 changes: 3 additions & 0 deletions lint-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ansible
ansible-lint<26
antsibull-changelog
6 changes: 4 additions & 2 deletions roles/cephadm/tasks/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
cmd: "cephadm shell -- ceph config set mon public_network {{ cephadm_public_network }}"
become: true
changed_when: true
when: cephadm_public_network | length > 0

- name: Set cluster network
command:
Expand All @@ -67,15 +68,16 @@

- name: Get cluster fsid
command:
cmd: "cephadm shell -- ceph fsid"
cmd: "cephadm ls --no-detail"
when: cephadm_fsid | length == 0
become: true
changed_when: false
register: cephadm_fsid_current

- name: Template out cluster.yml
vars:
fsid: "{{ cephadm_fsid if cephadm_fsid | length > 0 else cephadm_fsid_current.stdout }}"
current_fsid: "{{ cephadm_fsid_current.stdout | from_json | selectattr('name', 'search', 'mon') | map(attribute='fsid') | first }}"
fsid: "{{ cephadm_fsid if cephadm_fsid | length > 0 else current_fsid }}"
template:
src: "templates/cluster.yml.j2"
dest: "/var/run/ceph/{{ fsid }}/cephadm_cluster.yml"
Expand Down
15 changes: 15 additions & 0 deletions roles/cephadm/tasks/prechecks.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
---
- name: Assert that required Ansible groups exist
ansible.builtin.assert:
that: "'{{ item }}' in group_names"
msg: "Ansible '{{ item }}' group does not exist - please create one"
loop:
- ceph
- mons
- mgrs
- osds

- name: Assert that cephadm_public_interface is set
ansible.builtin.assert:
that: cephadm_public_interface | length > 0
msg: "Ansible Cephadm interface variable 'cephadm_public_interface' is not set"

- name: Populate service facts
service_facts:

Expand Down
2 changes: 1 addition & 1 deletion roles/cephadm/templates/cluster.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
---
service_type: host
hostname: {{ hostvars[host].ansible_facts.nodename }}
{% set cephadm_admin_interface = hostvars[host]['cephadm_admin_interface'] %}
{% set cephadm_admin_interface = hostvars[host]['cephadm_admin_interface'] | default(cephadm_admin_interface) %}
addr: {{ hostvars[host]['ansible_facts'][cephadm_admin_interface | replace('-', '_')]['ipv4']['address'] }}
labels:
{% if host in groups['mons'] %}
Expand Down
2 changes: 1 addition & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ansible>=2.9
ansible-lint<7
ansible-lint<26
antsibull-changelog
mock
pytest
Expand Down
11 changes: 11 additions & 0 deletions tests/playbooks/post.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
- name: Prepare logs
hosts: all
vars:
zuul_output_dir: "{{ ansible_user_dir }}/zuul-output"
tasks:
- name: Print all facts
copy:
content: "{{ hostvars[inventory_hostname] | to_nice_json }}"
dest: "{{ zuul_output_dir }}/facts.json"
mode: "0600"
13 changes: 13 additions & 0 deletions tests/playbooks/pre.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
- name: Prepare environment
hosts: all
any_errors_fatal: true
vars:
logs_dir: "/tmp/logs"
roles:
- ensure-output-dirs
- ensure-pip
- role: "ensure-docker"
when: cephadm_container_engine == "docker"
- role: "ensure-podman"
when: cephadm_container_engine == "podman"
18 changes: 18 additions & 0 deletions tests/playbooks/run.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
- name: Install catatonit package for Podman
hosts: all
any_errors_fatal: true
tasks:
- name: Install catatonit package for Podman
package:
name: catatonit
state: present
become: true

- name: Run tests
hosts: all
any_errors_fatal: true
roles:
- role: cephadm
vars:
cephadm_public_interface: "{{ ansible_default_ipv4.interface }}"
31 changes: 31 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[tox]
minversion = 3.18
envlist = py3,linters
ignore_basepython_conflict = True
skipsdist = True

[testenv]
basepython = python3
usedevelop = True
allowlist_externals = bash
find
rm
deps = -r{toxinidir}/test-requirements.txt
passenv = http_proxy,HTTP_PROXY,https_proxy,HTTPS_PROXY,no_proxy,NO_PROXY, \
OS_STDOUT_CAPTURE,OS_STDERR_CAPTURE,OS_LOG_CAPTURE,OS_TEST_TIMEOUT, \
PYTHON,OS_TEST_PATH,LISTOPT,IDOPTION

[testenv:linters]
deps =
-r{toxinidir}/lint-requirements.txt
allowlist_externals = bash
find
commands =
{[testenv:ansible-lint]commands}

[testenv:ansible-lint]
setenv = {[testenv:linters]setenv}
deps = {[testenv:linters]deps}
commands =
ansible-lint -p --exclude zuul.d
antsibull-changelog lint
9 changes: 9 additions & 0 deletions zuul.d/base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- job:
parent: base
name: cephadm-base
pre-run: tests/playbooks/pre.yml
run: tests/playbooks/run.yml
post-run: tests/playbooks/post.yml
timeout: 7200
post-timeout: 1800
16 changes: 16 additions & 0 deletions zuul.d/jobs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
- job:
name: cephadm-jammy-singlenode-docker-reef
parent: cephadm-base
nodeset: cephadm-jammy-single
vars:
cephadm_ceph_release: reef
cephadm_container_engine: docker

- job:
name: cephadm-jammy-singlenode-podman-reef
parent: cephadm-base
nodeset: cephadm-jammy-single
vars:
cephadm_ceph_release: reef
cephadm_container_engine: podman
19 changes: 19 additions & 0 deletions zuul.d/nodesets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
- nodeset:
name: cephadm-jammy-single
nodes:
- name: primary
label: ubuntu-jammy
groups:
- name: ceph
nodes:
- primary
- name: mons
nodes:
- primary
- name: mgrs
nodes:
- primary
- name: osds
nodes:
- primary
11 changes: 11 additions & 0 deletions zuul.d/project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
- project:
check:
jobs:
- cephadm-jammy-singlenode-docker-reef
- cephadm-jammy-singlenode-podman-reef
- tox-linters
gate:
jobs:
- cephadm-jammy-singlenode-docker-reef
- cephadm-jammy-singlenode-podman-reef