From 2610d6079fd909b1a224b727688f7a85b7507faf Mon Sep 17 00:00:00 2001 From: Francesco Pantano Date: Tue, 1 Oct 2024 16:29:52 +0200 Subject: [PATCH] Add TripleO requirements playbook This playbook represents a requirement for some storage services (e.g. Manila, but it can be extended to Glance NFS in the future) to prepare a TripleO based environment to perform the adoption. Manila, when a ceph-nfs backend is used, requires a cephadm based NFS cluster, and the goal of these tasks are: 1. Propagate the StorageNFS network to the Ceph target nodes 2. Deploy a CephNFS cluster to the specified VIP This is in line with the documentation and by executing this preliminary playbook we're able to simplify the Manila adoption process. Signed-off-by: Francesco Pantano --- Makefile | 5 +++ .../test_tripleo_adoption_requirements.yaml | 43 +++++++++++++++++++ tests/roles/ceph_migrate/defaults/main.yml | 2 + .../tasks/propagate_storage_nfs.yaml | 23 ++++++++++ .../roles/manila_adoption/defaults/main.yaml | 3 ++ 5 files changed, 76 insertions(+) create mode 100644 tests/playbooks/test_tripleo_adoption_requirements.yaml create mode 100644 tests/roles/ceph_migrate/tasks/propagate_storage_nfs.yaml diff --git a/Makefile b/Makefile index 488dc92c3..a7aecbdc1 100644 --- a/Makefile +++ b/Makefile @@ -34,6 +34,11 @@ test-with-ceph: ## Launch test suite with ceph mkdir -p tests/logs ANSIBLE_CONFIG=$(TEST_CONFIG) ansible-playbook -v -i $(TEST_INVENTORY) -e @$(TEST_VARS) -e @$(TEST_SECRETS) $(TEST_ARGS) tests/playbooks/test_with_ceph.yaml 2>&1 | tee $(TEST_OUTFILE) +test-tripleo-requirements: TEST_OUTFILE := tests/logs/test_tripleo_requirements_out_$(shell date +%FT%T%Z).log +test-tripleo-requirements: ## Launch test suite related to the ceph migration + mkdir -p tests/logs + ANSIBLE_CONFIG=$(TEST_CONFIG) ansible-playbook -v -i $(TEST_INVENTORY) -e @$(TEST_VARS) -e @$(TEST_CEPH_OVERRIDES) -e @$(TEST_SECRETS) $(TEST_ARGS) tests/playbooks/test_tripleo_adoption_requirements.yaml 2>&1 | tee $(TEST_OUTFILE) + test-ceph-migration: TEST_OUTFILE := tests/logs/test_ceph_migration_out_$(shell date +%FT%T%Z).log test-ceph-migration: ## Launch test suite related to the ceph migration mkdir -p tests/logs diff --git a/tests/playbooks/test_tripleo_adoption_requirements.yaml b/tests/playbooks/test_tripleo_adoption_requirements.yaml new file mode 100644 index 000000000..73e88069b --- /dev/null +++ b/tests/playbooks/test_tripleo_adoption_requirements.yaml @@ -0,0 +1,43 @@ +- name: TripleO adoption requirements + hosts: "{{ groups['overcloud'][0] | default([]) }}" + gather_facts: true + tasks: + # Propagate StorageNFS network + - name: Propagate Storage NFS network + when: + - manila_adoption | default(false) + - (manila_backend | default("cephfs")) == "cephnfs" + block: + - name: Load Ceph data + when: + - manila_adoption | default(false) + - (manila_backend | default("cephfs")) == "cephnfs" + ansible.builtin.import_role: + name: ceph_migrate + tasks_from: ceph_load + tags: + - ceph_load + - manila_adoption + + - name: Propagate Storage NFS network + when: + - target_nodes | default([]) | length > 0 + ansible.builtin.include_role: + name: ceph_migrate + tasks_from: propagate_storage_nfs + loop: "{{ target_nodes }}" + tags: + - manila_adoption + + # Create the Ceph-NFS cluster + - name: Create a ceph nfs cluster + when: + - manila_adoption | default(false) + - (manila_backend | default("cephfs")) == "cephnfs" + - ceph_nfs_vip is defined + - ceph_nfs_vip | ansible.util.ipaddr + ansible.builtin.include_role: + name: ceph_migrate + tasks_from: nfs + tags: + - manila_adoption diff --git a/tests/roles/ceph_migrate/defaults/main.yml b/tests/roles/ceph_migrate/defaults/main.yml index 0e0e08d29..20b706ebe 100644 --- a/tests/roles/ceph_migrate/defaults/main.yml +++ b/tests/roles/ceph_migrate/defaults/main.yml @@ -37,3 +37,5 @@ ceph_alertmanager_container_image: "quay.io/prometheus/alertmanager:v0.25.0" ceph_grafana_container_image: "quay.io/ceph/ceph-grafana:9.4.7" ceph_node_exporter_container_image: "quay.io/prometheus/node-exporter:v1.5.0" ceph_prometheus_container_image: "quay.io/prometheus/prometheus:v2.43.0" +ceph_storagenfs_nic: "nic2" +ceph_storagenfs_vlan_id: "70" diff --git a/tests/roles/ceph_migrate/tasks/propagate_storage_nfs.yaml b/tests/roles/ceph_migrate/tasks/propagate_storage_nfs.yaml new file mode 100644 index 000000000..86da93419 --- /dev/null +++ b/tests/roles/ceph_migrate/tasks/propagate_storage_nfs.yaml @@ -0,0 +1,23 @@ +- name: Patch net-config config and add the IP address (target node) + when: + - ceph_storagenfs_ipaddr is defined + - ceph_storagenfs_ipaddr | ansible.builtin.ipaddr + delegate_to: "{{ target_node }}" + become: true + ansible.builtin.blockinfile: + marker_begin: "BEGIN storageNFS network" + marker_end: "END storageNFS network" + path: "{{ os_net_conf_path }}" + block: | + - type: vlan + device: {{ ceph_storagenfs_nic }} + vlan_id: {{ ceph_storagenfs_vlan_id }} + addresses: + - ip_netmask: {{ ceph_storagenfs_ipaddr }}/24 + routes: [] + +- name: Refresh os-net-config (target_node) + become: true + delegate_to: "{{ target_node }}" + ansible.builtin.command: + "os-net-config -c {{ os_net_conf_path }}" diff --git a/tests/roles/manila_adoption/defaults/main.yaml b/tests/roles/manila_adoption/defaults/main.yaml index 33eb73334..85c184a92 100644 --- a/tests/roles/manila_adoption/defaults/main.yaml +++ b/tests/roles/manila_adoption/defaults/main.yaml @@ -1,2 +1,5 @@ # manila_backend can be 'cephfs' or 'cephnfs' manila_backend: cephfs +os_net_conf_path: "/etc/os-net-config/config.yaml" +manila_storagenfs_nic: "nic2" +manila_storagenfs_vlan_id: "70"