Skip to content

Commit 21b3b27

Browse files
committed
ci_dcn_site: Add removing and adding a node to a DCN site
1 parent 69f8180 commit 21b3b27

13 files changed

+786
-31
lines changed

playbooks/dcn.yml

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
when:
6262
- _subnet_network_range != ''
6363
- _ceph_bootstrap_node != ''
64-
- cifmw_ci_dcn_site_scaledown_az is not defined or cifmw_ci_dcn_site_scaledown_az == ""
6564
ansible.builtin.include_role:
6665
name: ci_dcn_site
6766

@@ -83,6 +82,49 @@
8382
name: ci_dcn_site
8483
when: cifmw_ci_dcn_site_scaledown_az is defined and cifmw_ci_dcn_site_scaledown_az != ""
8584

85+
- name: Remove a compute node from the deployment
86+
vars:
87+
_node_to_remove: "{{ cifmw_ci_dcn_site_scaledown_node }}"
88+
_az: "{{ cifmw_ci_dcn_site_scaledown_node_az | default('az1') }}"
89+
_group_name: "{{ az_to_group_map[_az] }}"
90+
_group_hosts: "{{ groups[_group_name] }}"
91+
_edpm_hosts: "{{ cifmw_baremetal_hosts | dict2items | selectattr('key', 'in', groups[_group_name]) | items2dict }}"
92+
_ceph_bootstrap_node: "{{ (_edpm_hosts | dict2items | first).key if _edpm_hosts | length > 0 else '' }}"
93+
when:
94+
- cifmw_ci_dcn_site_scaledown_node is defined and cifmw_ci_dcn_site_scaledown_node != ""
95+
ansible.builtin.include_role:
96+
name: ci_dcn_site
97+
tasks_from: remove_node.yml
98+
99+
- name: Add a compute node to a site
100+
when:
101+
- cifmw_ci_dcn_site_scaleout_node is defined and cifmw_ci_dcn_site_scaleout_node != ""
102+
block:
103+
# We need to update ci-framework related variable and inventory files to include the new host
104+
- name: Update ci-framework variables and inventory files
105+
vars:
106+
_node_to_add: "{{ cifmw_ci_dcn_site_scaleout_node }}"
107+
_az: "{{ cifmw_ci_dcn_site_scaleout_node_az | default('az1') }}"
108+
_subnet: "{{ cifmw_ci_dcn_site_scaleout_node_subnet | default('subnet2') }}"
109+
_group_name: "{{ az_to_group_map[_az] }}"
110+
ansible.builtin.include_role:
111+
name: ci_dcn_site
112+
tasks_from: update_conf_new_node.yml
113+
114+
- name: Add a compute node to dataplane
115+
vars:
116+
_node_to_add: "{{ cifmw_ci_dcn_site_scaleout_node }}"
117+
_az: "{{ cifmw_ci_dcn_site_scaleout_node_az | default('az1') }}"
118+
_subnet: "{{ cifmw_ci_dcn_site_scaleout_node_subnet | default('subnet2') }}"
119+
_subnet_network_range: "{{ _network_ranges[_az[-1] | int] }}"
120+
_group_name: "{{ az_to_group_map[_az] }}"
121+
_group_hosts: "{{ groups[_group_name] }}"
122+
_edpm_hosts: "{{ updated_cifmw_baremetal_hosts | dict2items | selectattr('key', 'in', groups[_group_name]) | items2dict }}"
123+
_ceph_bootstrap_node: "{{ (_edpm_hosts | dict2items | first).key if _edpm_hosts | length > 0 else '' }}"
124+
ansible.builtin.include_role:
125+
name: ci_dcn_site
126+
tasks_from: add_node.yml
127+
86128
- name: Find all created CRs
87129
ansible.builtin.find:
88130
paths: >-

roles/ci_dcn_site/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ with a collocated Ceph cluster.
1616
* `_group_name`: The name of the group of nodes to be deployed, e.g. `dcn1-computes`
1717
* `_subnet`: The name of the subnet the DCN site will use, e.g. `subnet2`
1818
* `_subnet_network_range`: The range of the subnet the DCN site will use, e.g. `192.168.133.0/24`
19+
* `_node_to_remove`: The hostname of the node to be removed from the DCN deployment.
20+
* `_node_to_add`: The hostname of the node to be added to the specified AZ.
1921

2022
## Examples
2123

roles/ci_dcn_site/tasks/add_node.yml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
---
2+
# Copyright Red Hat, Inc.
3+
# All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
17+
# We are scaling out and the ceph cluster already exists we can directly create the Nodeset utilizing the existing
18+
# "pre-ceph" values and then update it with "post-ceph" values which include additional ceph configuration and then
19+
# create and apply Deployment CR with full list of dataplane services.
20+
- name: Create a values.yaml.j2 file with full list of dataplane services
21+
ansible.builtin.copy:
22+
dest: "{{ ci_dcn_site_cifmw_repo_path }}/roles/ci_dcn_site/templates/deployment/values.yaml.j2"
23+
mode: '0644'
24+
content: |
25+
---
26+
# source: dcn/deployment/values.yaml.j2
27+
apiVersion: v1
28+
kind: ConfigMap
29+
metadata:
30+
name: edpm-deployment-values-post-ceph
31+
annotations:
32+
config.kubernetes.io/local-config: "true"
33+
data:
34+
nodeset_name: "{% raw %}{{ _group_name }}{% endraw %}-edpm"
35+
deployment:
36+
name: "add-node-{% raw %}{{ _group_name }}{% endraw %}"
37+
servicesOverride:
38+
- bootstrap
39+
- configure-network
40+
- validate-network
41+
- install-os
42+
- ceph-hci-pre
43+
- configure-os
44+
- ssh-known-hosts
45+
- run-os
46+
- reboot-os
47+
- install-certs
48+
- ceph-client
49+
- ovn
50+
- "neutron-metadata-cell{% raw %}{{ _all_azs.index(_az) +1 }}{% endraw %}"
51+
- libvirt
52+
- nova-custom-ceph-{% raw %}{{ _az }}{% endraw %}
53+
54+
- name: Initialize vars
55+
ansible.builtin.set_fact:
56+
_ceph_vars_list: []
57+
_all_azs: []
58+
59+
- name: Find all ceph .conf and .keyring files
60+
register: _ceph_conf_files
61+
ansible.builtin.find:
62+
paths: "/tmp"
63+
patterns: "ceph*.conf,ceph*.keyring,az*.conf,az*.keyring"
64+
recurse: false
65+
66+
- name: Load ceph configuration files
67+
ansible.builtin.set_fact:
68+
_ceph_files: "{{ _ceph_conf_files.files | map(attribute='path') | list }}"
69+
70+
- name: Render the NodeSet values.yaml
71+
vars:
72+
_edpm_instance_dict: "{{ cifmw_networking_env_definition.instances }}"
73+
_edpm_network_dict: "{{ cifmw_networking_env_definition.networks }}"
74+
_ssh_authorizedkeys: "{{ lookup('file', '~/.ssh/id_cifw.pub', rstrip=False) }}"
75+
_ssh_private_key: "{{ lookup('file', '~/.ssh/id_cifw', rstrip=False) }}"
76+
_ssh_public_key: "{{ lookup('file', '~/.ssh/id_cifw.pub', rstrip=False) }}"
77+
_migration_priv_key: "{{ lookup('file', '~/ci-framework-data/artifacts/nova_migration_key', rstrip=False) }}"
78+
_migration_pub_key: "{{ lookup('file', '~/ci-framework-data/artifacts/nova_migration_key.pub', rstrip=False) }}"
79+
ansible.builtin.template:
80+
backup: true
81+
src: "templates/edpm-pre-ceph/nodeset/values.yaml.j2"
82+
dest: "{{ ci_dcn_site_arch_path }}/edpm-pre-ceph/nodeset/values.yaml"
83+
mode: "0644"
84+
85+
- name: Kustomize NodeSet
86+
ansible.builtin.set_fact:
87+
nodeset_cr: >-
88+
{{ lookup('kubernetes.core.kustomize',
89+
dir=ci_dcn_site_arch_path + '/edpm-pre-ceph/nodeset') }}
90+
91+
- name: Save the NodeSet CR
92+
ansible.builtin.copy:
93+
mode: "0644"
94+
dest: "{{ ci_dcn_site_arch_path }}/dataplane-nodeset-pre-ceph_{{ _az }}.yaml"
95+
content: "{{ nodeset_cr }}"
96+
backup: true
97+
98+
- name: Render the values with updated ceph configuration, kustomize and apply CR of NodeSet and DataPlaneDeployment
99+
ansible.builtin.import_tasks: post-ceph.yml
100+
101+
- name: Set Network related facts
102+
ansible.builtin.include_tasks: set_network_facts.yml
103+
104+
- name: Deploy Ceph in DCN context
105+
ansible.builtin.include_tasks: ceph.yml
106+
107+
- name: Run Nova cell discovery for new DCN hosts
108+
kubernetes.core.k8s_exec:
109+
api_key: "{{ _auth_results.openshift_auth.api_key }}"
110+
namespace: openstack
111+
pod: nova-cell0-conductor-0
112+
command: nova-manage cell_v2 discover_hosts --verbose
113+
114+
- name: Add new hosts to AZ
115+
ansible.builtin.include_tasks: az.yml

roles/ci_dcn_site/tasks/ceph.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,25 @@
6767
dest: "~/ci-framework-data/parameters/ceph-{{ _az }}.yml"
6868
content: "{{ _content | to_nice_yaml }}"
6969

70+
- name: Check if ceph_client file already exists
71+
ansible.builtin.stat:
72+
path: "/tmp/ceph_client_{{_az}}.yml"
73+
register: ceph_file_stat
74+
75+
- name: Load ceph variables if the file exists
76+
ansible.builtin.include_vars:
77+
file: "/tmp/ceph_client_{{_az}}.yml"
78+
when: ceph_file_stat.stat.exists
79+
80+
- name: If It exists Add cifmw_cephadm_keys to ceph variables file
81+
ansible.builtin.blockinfile:
82+
path: "~/ci-framework-data/parameters/ceph-{{ _az }}.yml"
83+
block: |
84+
cifmw_cephadm_keys:
85+
{{ keys | default({}) | to_nice_yaml }}
86+
insertafter: EOF
87+
when: ceph_file_stat.stat.exists
88+
7089
- name: Deploy Ceph
7190
cifmw.general.ci_script:
7291
output_dir: "/home/zuul/ci-framework-data/artifacts"

roles/ci_dcn_site/tasks/post-ceph.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@
4747
ansible.builtin.set_fact:
4848
ci_dcn_site_glance_map: "{{ ci_dcn_site_glance_map | combine( { item: ['az0', item ] } ) }}"
4949

50+
- name: Get fsid of ceph cluster for currently deployed AZ
51+
ansible.builtin.set_fact:
52+
cifmw_ceph_client_fsid: "{{ _ceph_vars_list | selectattr('cifmw_ceph_client_cluster', 'equalto', _az) | map(attribute='cifmw_ceph_client_fsid') | first }}"
53+
5054
- name: Render the post-ceph values.yaml
5155
ansible.builtin.template:
5256
mode: "0644"

0 commit comments

Comments
 (0)