Skip to content

Commit

Permalink
Fix roles that used end_play in playbooks by spliting out the section…
Browse files Browse the repository at this point in the history
…s into separate task files with conditions

Signed-off-by: Markus Katharina Brechtel <markus.katharina.brechtel@thengo.net>
  • Loading branch information
mkbrechtel committed Jan 26, 2025
1 parent 6876d7a commit e83e998
Show file tree
Hide file tree
Showing 9 changed files with 302 additions and 318 deletions.
33 changes: 33 additions & 0 deletions roles/ceph/tasks/install_apt.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---

- name: Create keyring path
file:
path: /etc/apt/keyrings/
mode: 0755
state: directory
when: 'ceph_roles|length > 0 and ceph_release != "distro"'

- name: Add ceph GPG key
copy:
src: ceph.asc
dest: /etc/apt/keyrings/ansible-ceph.asc
notify: Update apt
when: 'ceph_roles|length > 0 and ceph_release != "distro"'

- name: Get local architecture
shell: dpkg --print-architecture
register: dpkg_architecture
changed_when: false
check_mode: no
when: 'ceph_roles|length > 0 and ceph_release != "distro"'

- name: Add ceph package sources
template:
src: ceph.sources.tpl
dest: /etc/apt/sources.list.d/ansible-ceph.sources
notify: Update apt
when: 'ceph_roles|length > 0 and ceph_release != "distro"'


- name: Run all notified handlers
meta: flush_handlers
31 changes: 31 additions & 0 deletions roles/ceph/tasks/install_rpm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---

- name: Import ceph GPG key
ansible.builtin.rpm_key:
state: present
key: https://download.ceph.com/keys/release.asc
when: 'ceph_roles|length > 0 and ceph_release != "distro"'

- name: Configure ceph stable community repository
ansible.builtin.yum_repository:
name: ceph_stable
description: Ceph Stable repo
state: present
baseurl: "https://download.ceph.com/rpm-{{ ceph_release }}/el{{ ansible_facts['distribution_major_version'] }}/$basearch"
file: ceph_stable
priority: 2
when: 'ceph_roles|length > 0 and ceph_release != "distro"'

- name: Configure ceph stable noarch community repository
ansible.builtin.yum_repository:
name: ceph_stable_noarch
description: Ceph Stable noarch repo
state: present
baseurl: "https://download.ceph.com/rpm-{{ ceph_release }}/el{{ ansible_facts['distribution_major_version'] }}/noarch"
file: ceph_stable
priority: 2
when: 'ceph_roles|length > 0 and ceph_release != "distro"'


- name: Run all notified handlers
meta: flush_handlers
75 changes: 4 additions & 71 deletions roles/ceph/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,80 +1,13 @@
---

- name: Run all notified handlers
meta: flush_handlers

# Ceph - Add package repository (apt)
- name: Check if distribution is supported
meta: end_play
- name: Add package repository (apt)
import_tasks: install_apt.yaml
when: 'ansible_distribution not in ("Ubuntu", "Debian")'

- name: Create keyring path
file:
path: /etc/apt/keyrings/
mode: 0755
state: directory
when: 'ceph_roles|length > 0 and ceph_release != "distro"'

- name: Add ceph GPG key
copy:
src: ceph.asc
dest: /etc/apt/keyrings/ansible-ceph.asc
notify: Update apt
when: 'ceph_roles|length > 0 and ceph_release != "distro"'

- name: Get local architecture
shell: dpkg --print-architecture
register: dpkg_architecture
changed_when: false
check_mode: no
when: 'ceph_roles|length > 0 and ceph_release != "distro"'

- name: Add ceph package sources
template:
src: ceph.sources.tpl
dest: /etc/apt/sources.list.d/ansible-ceph.sources
notify: Update apt
when: 'ceph_roles|length > 0 and ceph_release != "distro"'


- name: Run all notified handlers
meta: flush_handlers

# Ceph - Add package repository (rpm)
- name: Check if distribution is supported
meta: end_play
- name: Add package repository (rpm)
import_tasks: install_rpm.yaml
when: 'ansible_distribution != "CentOS"'

- name: Import ceph GPG key
ansible.builtin.rpm_key:
state: present
key: https://download.ceph.com/keys/release.asc
when: 'ceph_roles|length > 0 and ceph_release != "distro"'

- name: Configure ceph stable community repository
ansible.builtin.yum_repository:
name: ceph_stable
description: Ceph Stable repo
state: present
baseurl: "https://download.ceph.com/rpm-{{ ceph_release }}/el{{ ansible_facts['distribution_major_version'] }}/$basearch"
file: ceph_stable
priority: 2
when: 'ceph_roles|length > 0 and ceph_release != "distro"'

- name: Configure ceph stable noarch community repository
ansible.builtin.yum_repository:
name: ceph_stable_noarch
description: Ceph Stable noarch repo
state: present
baseurl: "https://download.ceph.com/rpm-{{ ceph_release }}/el{{ ansible_facts['distribution_major_version'] }}/noarch"
file: ceph_stable
priority: 2
when: 'ceph_roles|length > 0 and ceph_release != "distro"'


- name: Run all notified handlers
meta: flush_handlers

# Ceph - Install packages
- name: Install ceph-common
ansible.builtin.package:
Expand Down
48 changes: 48 additions & 0 deletions roles/incus/tasks/install_apt.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
- name: Create apt keyring path
file:
path: /etc/apt/keyrings/
mode: 0755
state: directory
when: 'incus_roles|length > 0 and incus_release != "distro"'

- name: Add Zabbly repository key
copy:
src: zabbly.asc
dest: /etc/apt/keyrings/ansible-zabbly.asc
notify: Update apt
when: 'incus_roles|length > 0 and incus_release != "distro"'

- name: Get DPKG architecture
shell: dpkg --print-architecture
register: dpkg_architecture
changed_when: false
check_mode: no
when: 'incus_roles|length > 0 and incus_release != "distro"'

- name: Add Zabbly package source
template:
src: incus.sources.tpl
dest: /etc/apt/sources.list.d/ansible-zabbly-incus-{{ incus_release }}.sources
notify: Update apt
when: 'incus_roles|length > 0 and incus_release != "distro"'

- name: Run all notified handlers
meta: flush_handlers

- name: Install the Incus package (deb)
apt:
name:
- incus
install_recommends: no
state: present
register: install_deb
when: 'ansible_distribution in ("Debian", "Ubuntu") and incus_roles | length > 0'

- name: Install the Incus UI package (deb)
apt:
name:
- incus-ui-canonical
install_recommends: no
state: present
when: 'ansible_distribution in ("Debian", "Ubuntu") and "ui" in incus_roles'
16 changes: 16 additions & 0 deletions roles/incus/tasks/install_rpm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---

- name: Add COPR repository
community.general.copr:
chroot: "epel-9-x86_64"
name: "neil/incus"
state: enabled
when: 'incus_roles|length > 0 and incus_release != "distro"'

- name: Install the Incus package (rpm)
ansible.builtin.package:
name:
- incus
state: present
register: install_rpm
when: 'ansible_distribution == "CentOS" and incus_roles | length > 0'
78 changes: 4 additions & 74 deletions roles/incus/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,85 +3,15 @@
- name: Run all notified handlers
meta: flush_handlers

# Incus - Add package repository (apt)
- name: Check if distribution is supported
meta: end_play
- name: Add package repository (apt)
import_tasks: install_apt.yaml
when: 'ansible_distribution not in ("Ubuntu", "Debian")'

- name: Create apt keyring path
file:
path: /etc/apt/keyrings/
mode: 0755
state: directory
when: 'incus_roles|length > 0 and incus_release != "distro"'

- name: Add Zabbly repository key
copy:
src: zabbly.asc
dest: /etc/apt/keyrings/ansible-zabbly.asc
notify: Update apt
when: 'incus_roles|length > 0 and incus_release != "distro"'

- name: Get DPKG architecture
shell: dpkg --print-architecture
register: dpkg_architecture
changed_when: false
check_mode: no
when: 'incus_roles|length > 0 and incus_release != "distro"'

- name: Add Zabbly package source
template:
src: incus.sources.tpl
dest: /etc/apt/sources.list.d/ansible-zabbly-incus-{{ incus_release }}.sources
notify: Update apt
when: 'incus_roles|length > 0 and incus_release != "distro"'


- name: Run all notified handlers
meta: flush_handlers

# Incus - Add package repository (rpm)
- name: Check if distribution is supported
meta: end_play
- name: Add package repository (rpm)
import_tasks: install_rpm.yaml
when: 'ansible_distribution != "CentOS"'

- name: Add COPR repository
community.general.copr:
chroot: "epel-9-x86_64"
name: "neil/incus"
state: enabled
when: 'incus_roles|length > 0 and incus_release != "distro"'


- name: Run all notified handlers
meta: flush_handlers

# Incus - Install packages and bootstrap
- name: Install the Incus package (deb)
apt:
name:
- incus
install_recommends: no
state: present
register: install_deb
when: 'ansible_distribution in ("Debian", "Ubuntu") and incus_roles | length > 0'

- name: Install the Incus package (rpm)
ansible.builtin.package:
name:
- incus
state: present
register: install_rpm
when: 'ansible_distribution == "CentOS" and incus_roles | length > 0'

- name: Install the Incus UI package (deb)
apt:
name:
- incus-ui-canonical
install_recommends: no
state: present
when: 'ansible_distribution in ("Debian", "Ubuntu") and "ui" in incus_roles'

- name: Install btrfs tools
ansible.builtin.package:
name:
Expand Down
91 changes: 91 additions & 0 deletions roles/ovn/tasks/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
- name: Create OVN config directory
file:
path: /etc/ovn
mode: 0755
state: directory
when: 'ovn_roles | length > 0'

- name: Transfer OVN CA certificate
copy:
src: "{{ ovn_pki_path }}/ca.crt"
dest: /etc/ovn/{{ ovn_name }}.ca.crt
mode: 0644
when: 'ovn_roles | length > 0'

- name: Transfer OVN server certificate
copy:
src: "{{ ovn_pki_path }}/{{ inventory_hostname }}.crt"
dest: /etc/ovn/{{ ovn_name }}.server.crt
mode: 0644
when: 'ovn_roles | length > 0'

- name: Transfer OVN server key
copy:
src: "{{ ovn_pki_path }}/{{ inventory_hostname }}.key"
dest: /etc/ovn/{{ ovn_name }}.server.key
mode: 0600
when: 'ovn_roles | length > 0'
notify:
- Configure OVN central northbound DB for SSL (certs)
- Configure OVN central northbound DB for SSL (ports)
- Configure OVN central southbound DB for SSL (certs)
- Configure OVN central southbound DB for SSL (ports)
- Configure OVN IC northbound DB for SSL (certs)
- Configure OVN IC northbound DB for SSL (ports)
- Configure OVN IC southbound DB for SSL (certs)
- Configure OVN IC southbound DB for SSL (ports)

- name: Configure OVN central database
template:
src: ovn-central.tpl
dest: /etc/default/ovn-central
notify:
- Restart OVN central
- Configure OVN AZ name
- Enable OVN IC route sharing
when: '"central" in ovn_roles'

- name: Configure OVN host
template:
src: ovn-host.tpl
dest: /etc/default/ovn-host
notify:
- Restart OVN host
when: '"host" in ovn_roles'

- name: Create OVN IC override directory
file:
path: /etc/systemd/system/ovn-ic.service.d
mode: 0755
state: directory
when: '"ic" in ovn_roles'

- name: Transfer OVN IC override
copy:
content: |
[Service]
EnvironmentFile=-/etc/default/ovn-ic
ExecStart=
ExecStart=/usr/share/ovn/scripts/ovn-ctl start_ic --no-monitor $OVN_CTL_OPTS
dest: /etc/systemd/system/ovn-ic.service.d/ansible.conf
notify: Restart OVN IC
when: '"ic" in ovn_roles'

- name: Configure OVN IC database
template:
src: ovn-ic.tpl
dest: /etc/default/ovn-ic
notify:
- Restart OVN IC databases
- Restart OVN IC
when: '"ic" in ovn_roles or "ic-db" in ovn_roles'

- name: Transfer OVN aliases
template:
src: alias.sh.tpl
dest: /etc/ovn/alias.sh
when: 'ovn_roles | length > 0'

- name: Run all notified handlers
meta: flush_handlers
Loading

0 comments on commit e83e998

Please sign in to comment.