From 87dd37860ec63f23427beea374c174356740729a Mon Sep 17 00:00:00 2001 From: jgilaber Date: Tue, 3 Sep 2024 15:29:53 +0200 Subject: [PATCH] [POC] Add role to deploy 17.1 env for adoption --- deploy-osp-adoption.yml | 76 ++++++++ roles/adoption_osp_deploy/README.md | 12 ++ roles/adoption_osp_deploy/defaults/main.yml | 19 ++ roles/adoption_osp_deploy/meta/main.yml | 30 ++++ .../molecule/default/converge.yml | 21 +++ .../molecule/default/molecule.yml | 11 ++ .../molecule/default/prepare.yml | 21 +++ .../tasks/config_files.yml | 170 ++++++++++++++++++ .../adoption_osp_deploy/tasks/deploy_ceph.yml | 72 ++++++++ .../tasks/deploy_overcloud.yml | 66 +++++++ .../tasks/deploy_undercloud.yml | 21 +++ roles/adoption_osp_deploy/tasks/main.yml | 54 ++++++ .../tasks/prepare_overcloud.yml | 82 +++++++++ .../tasks/prepare_undercloud.yml | 82 +++++++++ roles/adoption_osp_deploy/vars/main.yml | 22 +++ 15 files changed, 759 insertions(+) create mode 100644 deploy-osp-adoption.yml create mode 100644 roles/adoption_osp_deploy/README.md create mode 100644 roles/adoption_osp_deploy/defaults/main.yml create mode 100644 roles/adoption_osp_deploy/meta/main.yml create mode 100644 roles/adoption_osp_deploy/molecule/default/converge.yml create mode 100644 roles/adoption_osp_deploy/molecule/default/molecule.yml create mode 100644 roles/adoption_osp_deploy/molecule/default/prepare.yml create mode 100644 roles/adoption_osp_deploy/tasks/config_files.yml create mode 100644 roles/adoption_osp_deploy/tasks/deploy_ceph.yml create mode 100644 roles/adoption_osp_deploy/tasks/deploy_overcloud.yml create mode 100644 roles/adoption_osp_deploy/tasks/deploy_undercloud.yml create mode 100644 roles/adoption_osp_deploy/tasks/main.yml create mode 100644 roles/adoption_osp_deploy/tasks/prepare_overcloud.yml create mode 100644 roles/adoption_osp_deploy/tasks/prepare_undercloud.yml create mode 100644 roles/adoption_osp_deploy/vars/main.yml diff --git a/deploy-osp-adoption.yml b/deploy-osp-adoption.yml new file mode 100644 index 0000000000..427a0639c9 --- /dev/null +++ b/deploy-osp-adoption.yml @@ -0,0 +1,76 @@ +--- +# Purpose of this playbook: +# This playbook deploy OSP 17.1 on previously created +# infra for adoption. The main goal of this playbook +# is to be called as a standalone piece of a bigger +# job, mostly in the adoption context. +# +# You would typically run this playbook after the +# "create-infra.yml" + +- name: Parent scenario if needed + hosts: "{{ cifmw_target_host | default('localhost') }}" + gather_facts: true + vars: + cifmw_basedir: "{{ ansible_user_dir }}/ci-framework-data" + _adoption_source_scenario_file: >- + {{ + [cifmw_adoption_source_scenario_path, + cifmw_architecture_scenario ~ '.yaml'] | path_join + }} + tasks: + - name: Inherit from parent scenarios if needed + ansible.builtin.include_tasks: + file: "ci/playbooks/tasks/inherit_parent_scenario.yml" + + - name: Ensure networking data is loaded + ansible.builtin.import_role: + name: networking_mapper + tasks_from: load_env_definition.yml + + - name: Load source adoption scenario + ansible.builtin.include_vars: + file: "{{ _adoption_source_scenario_file }}" + name: _adoption_source_scenario + + - name: Read inventory groups + ansible.builtin.slurp: + path: "/home/zuul/ci-framework-data/reproducer-inventory/all-group.yml" + register: "_all_groups" + + - name: Generate groups + vars: + _parsed_all_groups: "{{ _all_groups['content'] | b64decode | from_yaml }}" + block: + - name: Read groups inventory + vars: + _group_name: "{{ item.key[:-1] }}" + _path_inventories: "/home/zuul/ci-framework-data/reproducer-inventory" + ansible.builtin.slurp: + path: "{{ _path_inventories }}/{{ _group_name }}-group.yml" + register: _files + loop: >- + {{ + _parsed_all_groups.all.children | dict2items + }} + + - name: Set groups fact + when: "'all' != _group_name" + vars: + _content: "{{ _inventory_file.content | b64decode | from_yaml }}" + _group_name: "{{ _inventory_file.source | basename | regex_replace('-group.yml', '') }}" + _nodes: "{{ _content[_group_name~'s']['hosts'].keys() }}" + _group_nodes: >- + {%- set group = {} -%} + {%- set _ = group.update({_group_name~'s': _nodes}) -%} + {{ group }} + ansible.builtin.set_fact: + _vm_groups: >- + {{ _vm_groups | default({}) | combine(_group_nodes) }} + loop: "{{ _files.results }}" + loop_control: + loop_var: "_inventory_file" + + - name: Deploy source osp environment + ansible.builtin.import_role: + name: "adoption_osp_deploy" diff --git a/roles/adoption_osp_deploy/README.md b/roles/adoption_osp_deploy/README.md new file mode 100644 index 0000000000..6f3888bd84 --- /dev/null +++ b/roles/adoption_osp_deploy/README.md @@ -0,0 +1,12 @@ +# adoption_osp_deploy + +Deploy OSP 17.1 environment for adoption based on DTs. + +## Privilege escalation +None + +## Parameters +* `adoption_osp_deploy_ntp_server`: (String) NTP server to use in the 17.1 +deployment. Defaults to `pool.ntp.org` + +## Examples diff --git a/roles/adoption_osp_deploy/defaults/main.yml b/roles/adoption_osp_deploy/defaults/main.yml new file mode 100644 index 0000000000..b1a0fb2722 --- /dev/null +++ b/roles/adoption_osp_deploy/defaults/main.yml @@ -0,0 +1,19 @@ +--- +# Copyright Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +# All variables intended for modification should be placed in this file. +# All variables within this role should have a prefix of "cifmw_adoption_osp_deploy" diff --git a/roles/adoption_osp_deploy/meta/main.yml b/roles/adoption_osp_deploy/meta/main.yml new file mode 100644 index 0000000000..6c046d0d32 --- /dev/null +++ b/roles/adoption_osp_deploy/meta/main.yml @@ -0,0 +1,30 @@ +--- +# Copyright Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +galaxy_info: + author: CI Framework + description: CI Framework Role -- adoption_osp_deploy + company: Red Hat + license: Apache-2.0 + min_ansible_version: "2.14" + namespace: cifmw + galaxy_tags: + - cifmw + +# List your role dependencies here, one per line. Be sure to remove the '[]' above, +# if you add dependencies to this list. +dependencies: [] diff --git a/roles/adoption_osp_deploy/molecule/default/converge.yml b/roles/adoption_osp_deploy/molecule/default/converge.yml new file mode 100644 index 0000000000..9eb41ce816 --- /dev/null +++ b/roles/adoption_osp_deploy/molecule/default/converge.yml @@ -0,0 +1,21 @@ +--- +# Copyright Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +- name: Converge + hosts: all + roles: + - role: "adoption_osp_deploy" diff --git a/roles/adoption_osp_deploy/molecule/default/molecule.yml b/roles/adoption_osp_deploy/molecule/default/molecule.yml new file mode 100644 index 0000000000..fda947cafe --- /dev/null +++ b/roles/adoption_osp_deploy/molecule/default/molecule.yml @@ -0,0 +1,11 @@ +--- +# Mainly used to override the defaults set in .config/molecule/ +# By default, it uses the "config_podman.yml" - in CI, it will use +# "config_local.yml". +log: true + +provisioner: + name: ansible + log: true + env: + ANSIBLE_STDOUT_CALLBACK: yaml diff --git a/roles/adoption_osp_deploy/molecule/default/prepare.yml b/roles/adoption_osp_deploy/molecule/default/prepare.yml new file mode 100644 index 0000000000..d3594acc41 --- /dev/null +++ b/roles/adoption_osp_deploy/molecule/default/prepare.yml @@ -0,0 +1,21 @@ +--- +# Copyright Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +- name: Prepare + hosts: all + roles: + - role: test_deps diff --git a/roles/adoption_osp_deploy/tasks/config_files.yml b/roles/adoption_osp_deploy/tasks/config_files.yml new file mode 100644 index 0000000000..b6ff0793f2 --- /dev/null +++ b/roles/adoption_osp_deploy/tasks/config_files.yml @@ -0,0 +1,170 @@ +--- +# Copyright Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +- name: Debug + ansible.builtin.debug: + msg: "{{ _adoption_source_scenario }}" + +- name: Load scenario config-download + vars: + _config_download_path: >- + {{ + [cifmw_adoption_source_scenario_path, + _adoption_source_scenario.overcloud.config_download_file + ] | path_join + }} + ansible.builtin.slurp: + path: "{{ _config_download_path }}" + register: _original_config_download + delegate_to: "localhost" + +- name: Generate config download file + vars: + _config_download: > + {{ + _original_config_download['content'] | + b64decode | from_yaml + }} + _new_config_download_fields: {} + _ctlplane_net: "{{ cifmw_networking_env_definition.networks.ctlplane }}" + _hostname_map_translation: >- + {{ + _adoption_source_scenario.hostname_groups_map + }} + block: + - name: Gather overcloud tripleo nodes + when: group.key is in _hostname_map_translation + ansible.builtin.set_fact: + _tripleo_nodes: >- + {{ + _tripleo_nodes | default([]) + + group.value + }} + loop: "{{ _vm_groups | dict2items }}" + loop_control: + loop_var: group + label: "{{ group.key }}" + + - name: Generate Hostnamemap field + when: group.key is in _hostname_map_translation + vars: + _tripleo_name: "{{ _hostname_map_translation[group.key] }}" + _group_nodes: >- + {%- set hosts = {} -%} + {%- for node in group.value -%} + {%- set key = _tripleo_name ~ '-' ~ loop.index0 | string -%} + {%- set _ = hosts.update({key: node}) -%} + {%- endfor -%} + {{ hosts }} + ansible.builtin.set_fact: + _hostname_map: >- + {{ + _hostname_map | default({}) | + combine(_group_nodes) + }} + loop: "{{ _vm_groups | dict2items }}" + loop_control: + loop_var: group + label: "{{ group.key }}" + + - name: Generate DeployedServerPortMap field + vars: + _node_instance_net: "{{ cifmw_networking_env_definition.instances[node] }}" + _key_name: "{{ node }}-ctlplane" + _ctlplane_ip: "{{ _node_instance_net.networks.ctlplane.ip_v4 }}" + _server_port: >- + {%- set port = {_key_name: {}} -%} + {%- set _ = port[_key_name].update({ + 'fixed_ips': [ + { 'ip_address': _ctlplane_ip } + ], + 'subnets': [ + {'cidr': _ctlplane_net.network_v4} + ], + 'network': { + 'tags': [ _ctlplane_net.network_v4 ] + }}) -%} + {{ port }} + ansible.builtin.set_fact: + _deployedserverport_map: >- + {{ + _deployedserverport_map | default({}) | + combine(_server_port, recursive=true) + }} + loop: "{{ _tripleo_nodes }}" + loop_control: + loop_var: node + label: "{{ node }}" + + - name: Generate NodePortMap field + vars: + _node_instance_net: "{{ cifmw_networking_env_definition.instances[node] }}" + _node_port: > + {%- set nodeport = {node: {}} -%} + {% for network, net_info in _node_instance_net.networks.items() %} + {%- set subnet = cifmw_networking_env_definition.networks[network].network_v4 -%} + {%- set _ = nodeport[node].update( + { + network: { + 'ip_address': net_info.ip_v4, + 'ip_address_uri': net_info.ip_v4, + 'ip_subnet': subnet + } + } + ) -%} + {%- endfor -%} + {{ nodeport }} + ansible.builtin.set_fact: + _nodeport_map: >- + {{ + _nodeport_map | default({}) | + combine(_node_port, recursive=true) + }} + loop: "{{ _tripleo_nodes }}" + loop_control: + loop_var: node + label: "{{ node }}" + + - name: Generate CtlplaneNetworkAttributes field + vars: + _cloud_domain: "{{ _adoption_source_scenario.cloud_domain }}" + _dns_server: >- + {{ + (_ctlplane_net.dns_v4 | length > 0) | + ternary(_ctlplane_net.dns_v4, _ctlplane_net.gw_v4) + }} + ansible.builtin.set_fact: + _ctlplanenet_attributes: + network: + dns_domain: "{{ _cloud_domain }}" + mtu: "{{ _ctlplane_net.mtu }}" + subnets: + ctlplane-subnet: + dns_nameservers: "{{ _dns_server }}" + gateway_ip: "{{ _ctlplane_net.gw_v4 }}" + + - name: Create new config download file + vars: + _new_config_download_fields: + parameter_defaults: + HostnameMap: "{{ _hostname_map }}" + DeployedServerPortMap: "{{ _deployedserverport_map }}" + NodePortMap: "{{ _nodeport_map }}" + CtlplaneNetworkAttributes: "{{ _ctlplanenet_attributes }}" + ansible.builtin.copy: + dest: "/home/zuul/config-download.yaml" + content: "{{ _config_download | combine(_new_config_download_fields, recursive=true) | to_nice_yaml(indent=2, sort_keys=false) }}" + delegate_to: "osp-undercloud-0" diff --git a/roles/adoption_osp_deploy/tasks/deploy_ceph.yml b/roles/adoption_osp_deploy/tasks/deploy_ceph.yml new file mode 100644 index 0000000000..347d74d90f --- /dev/null +++ b/roles/adoption_osp_deploy/tasks/deploy_ceph.yml @@ -0,0 +1,72 @@ +--- +# Copyright Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +- name: Create block devices on compute nodes using ceph playbook + ansible.builtin.command: + cmd: >- + ansible-playbook ceph.yml + -i inventory.yaml --tags block -e cifmw_num_osds_perhost=1 + -e cifmw_ceph_target=osp-computes + +- name: Deploy 17.1 ceph + vars: + _roles_file: >- + {{ + [cifmw_adoption_source_scenario_path, + _adoption_source_scenario.overcloud.roles_file + ] | path_join + }} + _network_data_file: >- + {{ + [cifmw_adoption_source_scenario_path, + _adoption_source_scenario.overcloud.network_data_file + ] | path_join + }} + _ceph_osd_spec_file: >- + {{ + [cifmw_adoption_source_scenario_path, + _adoption_source_scenario.overcloud.ceph_osd_spec_file + ] | path_join + }} + _cloud_domain: {{ _adoption_source_scenario.cloud_domain }} + block: + - name: Generate ceph_spec file + vars: + _ceph_spec_cmd: >- + openstack overcloud ceph spec config-download.yaml + --tld {{ _cloud_domain }} + --osd-spec {{ _ceph_osd_spec_file }} + --roles-file {{ _roles_file }} + -o ceph_spec.yaml + cifmw.general.ci_script: + output_dir: "{{ cifmw_basedir }}/artifacts" + script: "{{ _ceph_spec_cmd }}" + delegate_to: "osp-undercloud-0" + + - name: Deploy ceph + vars: + _ceph_deploy_cmd: >- + openstack openstack ceph deploy + --tld {{ _cloud_domain }} + --ntp-server {{ adoption_osp_deploy_ntp_server }} + --ceph-spec ceph_spec.yaml + --network-data {{ _network_data_file }} + --cephadm-default-container + --output ceph_spec.yaml + cifmw.general.ci_script: + output_dir: "{{ cifmw_basedir }}/artifacts" + script: "{{ _ceph_deploy_cmd }}" + delegate_to: "osp-undercloud-0" diff --git a/roles/adoption_osp_deploy/tasks/deploy_overcloud.yml b/roles/adoption_osp_deploy/tasks/deploy_overcloud.yml new file mode 100644 index 0000000000..eddc59bc28 --- /dev/null +++ b/roles/adoption_osp_deploy/tasks/deploy_overcloud.yml @@ -0,0 +1,66 @@ +--- +# Copyright Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +- name: Deploy 17.1 overcloud + vars: + _roles_file: >- + {{ + [cifmw_adoption_source_scenario_path, + _adoption_source_scenario.overcloud.roles_file + ] | path_join + }} + _network_data_file: >- + {{ + [_cifmw_adoption_source_scenario_path, + _adoption_source_scenario.overcloud.network_data_file + ] | path_join + }} + _overcloud_services_file: >- + {{ + [_cifmw_adoption_source_scenario_path, + _adoption_source_scenario.overcloud.services_file + ] | path_join + }} + _overcloud_args: >- + {{ + _adoption_source_scenario.overcloud.args | join(' ') + }} + _overcloud_vars: >- + {{ + _adoption_source_scenario.overcloud.vars | join(' -e ') + }} + _overcloud_name: >- + {{ + _adoption_source_scenario.overcloud.stackname | + default('overcloud') + }} + _overcloud_deploy_cmd: >- + openstack openstack overcloud deploy + --stack {{ _overcloud_name }} + {{ _overcloud_args }} + --roles-file {{ _roles_file }} + -n {{ _network_data_file }} + --ntp-server {{ adoption_osp_deploy_ntp_server }} + {{ _overcloud_vars }} + -e /home/zuul/containers-prepare-parameters.yaml + -e {{ overcloud_services_file }} + -e /home/zuul/config-download.yaml + -e /home/zuul/vips_provision_out.yaml + -e /home/zuul/network_provision_out.yaml + cifmw.general.ci_script: + output_dir: "{{ cifmw_basedir }}/artifacts" + script: "{{ _overcloud_deploy_cmd }}" + delegate_to: "osp-undercloud-0" diff --git a/roles/adoption_osp_deploy/tasks/deploy_undercloud.yml b/roles/adoption_osp_deploy/tasks/deploy_undercloud.yml new file mode 100644 index 0000000000..f36d372aae --- /dev/null +++ b/roles/adoption_osp_deploy/tasks/deploy_undercloud.yml @@ -0,0 +1,21 @@ +--- +# Copyright Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +- name: Deploy 17.1 undercloud + cifmw.general.ci_script: + output_dir: "{{ cifmw_basedir }}/artifacts" + script: "openstack undercloud install" + delegate_to: "osp-undercloud-0" diff --git a/roles/adoption_osp_deploy/tasks/main.yml b/roles/adoption_osp_deploy/tasks/main.yml new file mode 100644 index 0000000000..c44e24cd45 --- /dev/null +++ b/roles/adoption_osp_deploy/tasks/main.yml @@ -0,0 +1,54 @@ +--- +# Copyright Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +- name: Prepare undercloud enviornment + ansible.builtin.import_tasks: prepare_undercloud.yml + +- name: Generate configuration files + ansible.builtin.import_tasks: config_files.yml + +- name: Run pre undercloud deploy hooks + vars: + hooks: "{{ _adoption_source_scenario.pre_uc_run | default([]) }}" + ansible.builtin.include_role: + name: run_hook + +- name: Deploy undercloud + ansible.builtin.import_tasks: deploy_undercloud.yml + +- name: Run post undercloud deploy hooks + vars: + hooks: "{{ _adoption_source_scenario.post_uc_run | default([]) }}" + ansible.builtin.include_role: + name: run_hook + +- name: Overcloud preparation + ansible.builtin.import_tasks: prepare_overcloud.yml + +- name: Run pre overcloud deploy hooks + vars: + hooks: "{{ _adoption_source_scenario.pre_oc_run | default([]) }}" + ansible.builtin.include_role: + name: run_hook + +- name: Deploy overcloud + ansible.builtin.import_tasks: deploy_overcloud.yml + +- name: Run post overcloud deploy hooks + vars: + hooks: "{{ _adoption_source_scenario.post_oc_run | default([]) }}" + ansible.builtin.include_role: + name: run_hook diff --git a/roles/adoption_osp_deploy/tasks/prepare_overcloud.yml b/roles/adoption_osp_deploy/tasks/prepare_overcloud.yml new file mode 100644 index 0000000000..a79717fe30 --- /dev/null +++ b/roles/adoption_osp_deploy/tasks/prepare_overcloud.yml @@ -0,0 +1,82 @@ +--- +# Copyright Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +- name: Prepare enviornment for 17.1 overcloud deployment + vars: + _architecture_path: "{{ cifmw_architecture_repo }}/automation/vars" + _network_data_file: >- + {{ + [_architecture_path, + _cifmw_scenario_content.adoption.overcloud.network_data_file + ] | path_join + }} + _vips_data_file: >- + {{ + [_architecture_path, + _cifmw_scenario_content.adoption.overcloud.vips_data_file + ] | path_join + }} + block: + - name: Ensure overcloud vms are started + community.libvirt.virt: + state: running + name: "cifmw-{{ _vm }}" + uri: "qemu:///system" + loop: "{{ _tripleo_nodes }}" + loop_control: + loop_var: _vm + pause: 1 + + - name: Ensure repos are setup in overcloud nodes + when: "'undercloud' not in _vm" + vars: + osp_17_repos: + - rhel-9-for-x86_64-baseos-eus-rpms + - rhel-9-for-x86_64-appstream-eus-rpms + - rhel-9-for-x86_64-highavailability-eus-rpms + - openstack-17.1-for-rhel-9-x86_64-rpms + - fast-datapath-for-rhel-9-x86_64-rpms + - rhceph-6-tools-for-rhel-9-x86_64-rpms + become: true + ansible.builtin.command: + cmd: "subscription-manager repos --enable {{ osp_17_repos | join(' --enable ') }}" + loop: "{{ _tripleo_nodes }}" + loop_control: + loop_var: _vm + pause: 1 + delegate_to: "{{ _vm }}" + + - name: Provision openstack networks + vars: + _network_provision_cmd: >- + openstack overcloud network provision + --output network_provision_out.yaml + {{ _network_data_file }} + cifmw.general.ci_script: + output_dir: "{{ cifmw_basedir }}/artifacts" + script: "{{ _network_provision_cmd }}" + delegate_to: "osp-undercloud-0" + + - name: Provision virtual ips + vars: + _vip_provision_cmd: >- + openstack overcloud network vip provision + --output vips_provision_out.yaml + {{ _vips_data_file }} + cifmw.general.ci_script: + output_dir: "{{ cifmw_basedir }}/artifacts" + script: "{{ _vip_provision_cmd }}" + delegate_to: "osp-undercloud-0" diff --git a/roles/adoption_osp_deploy/tasks/prepare_undercloud.yml b/roles/adoption_osp_deploy/tasks/prepare_undercloud.yml new file mode 100644 index 0000000000..a1b1b2d884 --- /dev/null +++ b/roles/adoption_osp_deploy/tasks/prepare_undercloud.yml @@ -0,0 +1,82 @@ +--- +# Copyright Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +- name: Ensure controller and undercloud vms are started + community.libvirt.virt: + state: running + name: "cifmw-{{ _vm }}" + uri: "qemu:///system" + loop: "{{ _vm_groups['osp-underclouds']+_vm_groups['controllers'] }}" + loop_control: + loop_var: _vm + pause: 1 + +- name: Ensure repos are setup + vars: + osp_17_repos: + - rhel-9-for-x86_64-baseos-eus-rpms + - rhel-9-for-x86_64-appstream-eus-rpms + - rhel-9-for-x86_64-highavailability-eus-rpms + - openstack-17.1-for-rhel-9-x86_64-rpms + - fast-datapath-for-rhel-9-x86_64-rpms + - rhceph-6-tools-for-rhel-9-x86_64-rpms + become: true + ansible.builtin.command: + cmd: "subscription-manager repos --enable {{ osp_17_repos | join(' --enable ') }}" + delegate_to: "osp-undercloud-0" + +- name: Install director packages + become: true + ansible.builtin.package: + name: python3-tripleoclient + +- name: Ensure ci-framework-data folder is created in undercloud + vars: + cifmw_ci_setup_basedir: "{{ cifmw_basedir }}" + directory_state: directory + ansible.builtin.include_role: + name: "ci_setup" + tasks_from: "directories.yml" + apply: + delegate_to: "osp-undercloud-0" + +- name: Create containers-prepare-parameters if needed + delegate_to: "osp-undercloud-0" + vars: + _container_prepare_cmd: >- + openstack tripleo container image prepare + default --output-env-file + /home/zuul/containers-prepare-parameters.yaml + cifmw.general.ci_script: + output_dir: "{{ cifmw_basedir }}/artifacts" + script: "{{ _container_prepare_cmd }}" + when: _adoption_source_scenario.container_prepare_params is not defined + +- name: Copy undercloud.conf file to location to edit it + delegate_to: "osp-undercloud-0" + ansible.builtin.copy: + src: "/usr/share/python-tripleoclient/undercloud.conf.sample" + dest: "/home/zuul/undercloud.conf" + +- name: Generate undercloud.conf with scenario specific values + delegate_to: "osp-undercloud-0" + community.general.ini_file: + path: "/home/zuul/undercloud.conf" + section: "{{ item.section }}" + option: "{{ item.option }}" + value: "{{ item.value }}" + state: "present" + loop: "{{ _adoption_source_scenario.undercloud.config }}" diff --git a/roles/adoption_osp_deploy/vars/main.yml b/roles/adoption_osp_deploy/vars/main.yml new file mode 100644 index 0000000000..cbb0eb46a3 --- /dev/null +++ b/roles/adoption_osp_deploy/vars/main.yml @@ -0,0 +1,22 @@ +--- +# Copyright Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +# While options found within the vars/ path can be overridden using extra +# vars, items within this path are considered part of the role and not +# intended to be modified. + +# All variables within this role should have a prefix of "cifmw_adoption_osp_deploy"