diff --git a/deploy-osp-adoption.yml b/deploy-osp-adoption.yml new file mode 100644 index 0000000000..ccea67e456 --- /dev/null +++ b/deploy-osp-adoption.yml @@ -0,0 +1,108 @@ +--- +# 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: Deploy 17.1 for adoption + hosts: '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.include_role: + name: networking_mapper + tasks_from: load_env_definition.yml + apply: + delegate_to: "{{ cifmw_target_host | default('localhost') }}" + + - name: Load source adoption scenario + ansible.builtin.include_vars: + file: "{{ _adoption_source_scenario_file }}" + name: _adoption_source_scenario + + - name: Gather ansible_user_id from {{ cifmw_target_host }} + delegate_to: "{{ cifmw_target_host }}" + ansible.builtin.setup: + gather_subset: + - user_id + - user_dir + + - name: Read inventory groups + delegate_to: "{{ cifmw_target_host }}" + ansible.builtin.slurp: + path: "{{ ansible_user_dir }}/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 + delegate_to: "{{ cifmw_target_host | default('localhost') }}" + vars: + _group_name: "{{ item.key[:-1] }}" + _path_inventories: "{{ ansible_user_dir }}/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: Ensure parameters folder exists + ansible.builtin.file: + path: "{{ cifmw_basedir }}/artifacts/parameters" + state: "directory" + + - name: Save variables for use with hooks + ansible.builtin.copy: + dest: "{{ cifmw_basedir }}/artifacts/parameters/adoption_osp.yml" + content: | + --- + cifmw_adoption_osp_deploy_ntp_server: {{ cifmw_adoption_osp_deploy_ntp_server }} + cifmw_adoption_source_scenario_path: {{ cifmw_adoption_source_scenario_path }} + _adoption_source_scenario: + {{ _adoption_source_scenario | to_nice_yaml(indent=2) | indent(width=2) }} + _vm_groups: + {{ _vm_groups | to_nice_yaml(indent=2) | indent(width=2) }} + + - name: Set inventory_file for localhost to use with hooks + ansible.builtin.set_fact: + inventory_file: "{{ hostvars[cifmw_target_host]['inventory_file'] }}" + + - name: Deploy source osp environment + ansible.builtin.import_role: + name: "adoption_osp_deploy" diff --git a/docs/dictionary/en-custom.txt b/docs/dictionary/en-custom.txt index 3b633102e5..34b62e6185 100644 --- a/docs/dictionary/en-custom.txt +++ b/docs/dictionary/en-custom.txt @@ -139,6 +139,7 @@ dnsdata dnsmasq dockerfile dryrun +dts ecdsa edecb edploy @@ -516,6 +517,7 @@ uhv uidmap unclaim undefine +undercloud unittest unmanaged untagged diff --git a/hooks/playbooks/adoption_deploy_ceph.yml b/hooks/playbooks/adoption_deploy_ceph.yml new file mode 100644 index 0000000000..6e96f0f7fe --- /dev/null +++ b/hooks/playbooks/adoption_deploy_ceph.yml @@ -0,0 +1,141 @@ +--- +# 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 ceph for 17.1 deployment + hosts: "{{ cifmw_target_host | default('localhost') }}" + tasks: + - name: Gather ansible_user_dir from undercloud + delegate_to: "osp-undercloud-0" + ansible.builtin.setup: + gather_subset: + - user_dir + + - name: Deploy 17.1 ceph + vars: + _roles_file: >- + {{ + [cifmw_adoption_source_scenario_path, + _adoption_source_scenario.overcloud.roles_file + ] | path_join + }} + _roles_file_name: "{{ _roles_file | basename }}" + _roles_file_dest: "{{ ansible_user_dir }}/{{ _roles_file_name }}" + _network_data_file: >- + {{ + [cifmw_adoption_source_scenario_path, + _adoption_source_scenario.overcloud.network_data_file + ] | path_join + }} + _network_data_file_name: "{{ _network_data_file | basename }}" + _network_data_file_dest: "{{ ansible_user_dir }}/{{ _network_data_file_name }}" + _ceph_osd_spec_file: >- + {{ + [cifmw_adoption_source_scenario_path, + _adoption_source_scenario.overcloud.ceph_osd_spec_file + ] | path_join + }} + _ceph_osd_spec_file_name: "{{ _ceph_osd_spec_file | basename }}" + _ceph_osd_spec_file_dest: "{{ ansible_user_dir }}/{{ _ceph_osd_spec_file_name }}" + _cloud_domain: "{{ _adoption_source_scenario.cloud_domain }}" + _source_cmd: "source {{ ansible_user_dir }}/stackrc" + block: + - name: Copy network data file + delegate_to: "osp-undercloud-0" + ansible.builtin.copy: + src: "{{ _network_data_file }}" + dest: "{{ _network_data_file_dest }}" + + - name: Copy roles file + delegate_to: "osp-undercloud-0" + ansible.builtin.copy: + src: "{{ _roles_file }}" + dest: "{{ _roles_file_dest }}" + + - name: Copy ceph osd file + delegate_to: "osp-undercloud-0" + ansible.builtin.copy: + src: "{{ _ceph_osd_spec_file }}" + dest: "{{ _ceph_osd_spec_file_dest }}" + + - name: Ensure ceph_spec file does not exist + delegate_to: "osp-undercloud-0" + ansible.builtin.file: + path: "{{ ansible_user_dir }}/ceph_spec.yaml" + state: absent + + - name: Generate ceph_spec file + delegate_to: "osp-undercloud-0" + vars: + _ceph_spec_cmd: >- + openstack overcloud ceph spec {{ ansible_user_dir }}/config-download.yaml + --tld {{ _cloud_domain }} + --osd-spec {{ _ceph_osd_spec_file_dest }} + --roles-data {{ _roles_file_dest }} + -o {{ansible_user_dir}}/ceph_spec.yaml + cifmw.general.ci_script: + chdir: "{{ ansible_user_dir }}" + output_dir: "{{ cifmw_basedir }}/artifacts" + script: "{{ _source_cmd }}; {{ _ceph_spec_cmd }}" + + - name: Ensure deployed_ceph file does not exist + delegate_to: "osp-undercloud-0" + ansible.builtin.file: + path: "{{ ansible_user_dir }}/deployed_ceph.yaml" + state: absent + + - name: Gather overcloud tripleo nodes + when: group.key is in _hostname_map_translation + vars: + _hostname_map_translation: >- + {{ + _adoption_source_scenario.hostname_groups_map + }} + ansible.builtin.set_fact: + _tripleo_nodes: >- + {{ + _tripleo_nodes | default([]) + + group.value + }} + loop: "{{ _vm_groups | dict2items }}" + loop_control: + loop_var: group + label: "{{ group.key }}" + + - name: Install packages needed for ceph deployment on the overcloud nodes + become: true + delegate_to: "{{ item }}" + ansible.builtin.dnf: + name: + - lvm2 + - jq + state: present + loop: "{{ _tripleo_nodes }}" + + - name: Deploy ceph + delegate_to: "osp-undercloud-0" + vars: + _ceph_deploy_cmd: >- + openstack overcloud ceph deploy + --tld {{ _cloud_domain }} + --ntp-server {{ cifmw_adoption_osp_deploy_ntp_server }} + --ceph-spec ceph_spec.yaml + --network-data {{ _network_data_file_dest }} + --cephadm-default-container + --output {{ ansible_user_dir }}/deployed_ceph.yaml + cifmw.general.ci_script: + chdir: "{{ ansible_user_dir }}" + output_dir: "{{ cifmw_basedir }}/artifacts" + script: "{{ _source_cmd }}; {{ _ceph_deploy_cmd }}" diff --git a/roles/adoption_osp_deploy/README.md b/roles/adoption_osp_deploy/README.md new file mode 100644 index 0000000000..979d825d71 --- /dev/null +++ b/roles/adoption_osp_deploy/README.md @@ -0,0 +1,32 @@ +# adoption_osp_deploy + +Deploy OSP 17.1 environment for adoption based on DTs. + +## Privilege escalation +None + +## Parameters +* `cifmw_adoption_osp_deploy_ntp_server`: (String) NTP server to use in the 17.1 +deployment. Defaults to `pool.ntp.org` +* `cifmw_adoption_osp_deploy_repos`: (List) List of 17.1 repos to enable. Defaults to +`[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]` +* `cifmw_adoption_osp_deploy_stopper`: (String) Step at which to stop the run. See `Break point` section below for possible values. + +### Break point + +You can also stop the automated deploy by setting +`cifmw_adoption_osp_deploy_stopper` +parameter to a specific value. + +Break point names are built using either `undercloud` or `overcloud`, +and the code currently supports the following seven different stoppers: + +- Before calling pre undercloud hook: `before_pre_hook_undercloud` +- Before deploying undercloud: `before_deploy_undercloud` +- After deploying undercloud: `after_deploy_undercloud` +- After calling post undercloud hook: `after_post_hook_undercloud` +- Before calling pre overcloud hook: `before_pre_hook_overcloud` +- Before deploying overcloud: `before_deploy_overcloud` +- After deploying overcloud: `after_deploy_overcloud` + +## 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..4dbae15b8c --- /dev/null +++ b/roles/adoption_osp_deploy/defaults/main.yml @@ -0,0 +1,27 @@ +--- +# 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" +cifmw_adoption_osp_deploy_ntp_server: "pool.ntp.org" +cifmw_adoption_osp_deploy_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 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/tasks/config_files.yml b/roles/adoption_osp_deploy/tasks/config_files.yml new file mode 100644 index 0000000000..1b2067a50e --- /dev/null +++ b/roles/adoption_osp_deploy/tasks/config_files.yml @@ -0,0 +1,201 @@ +--- +# 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 and reachable + vars: + _cifmw_libvirt_manager_layout: + vms: + controllers: + start: true + disk_file_name: "dummy" + osp-underclouds: + start: true + disk_file_name: "dummy" + cifmw_libvirt_manager_all_vms: >- + {%- set vms = {} -%} + {%- for vm in _vm_groups['osp-underclouds'] -%} + {%- set _ = vms.update({vm: 'osp-underclouds'}) -%} + {%- endfor -%} + {%- for vm in _vm_groups['controllers'] -%} + {%- set _ = vms.update({vm: 'controllers'}) -%} + {%- endfor -%} + {{ vms }} + ansible_libvirt_pools: {} + ansible.builtin.include_role: + name: "libvirt_manager" + tasks_from: "start_vms.yml" + apply: + delegate_to: "{{ cifmw_target_host | default('localhost') }}" + +- name: Gather ansible_user_id from undercloud + delegate_to: "osp-undercloud-0" + ansible.builtin.setup: + gather_subset: + - user_id + - user_dir + +- 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() if network != 'ocpbm' %} + {%- set subnet = cifmw_networking_env_definition.networks[network].network_v4 -%} + {%- set network_name = ['storage_mgmt'] if network == 'storagemgmt' else [network] -%} + {%- set network_name = ['internal_api'] if network == 'internalapi' else [network] -%} + {%- set _ = nodeport[node].update( + { + network_name[0]: { + '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: "{{ ansible_user_dir }}/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_overcloud.yml b/roles/adoption_osp_deploy/tasks/deploy_overcloud.yml new file mode 100644 index 0000000000..cba9f8fb1d --- /dev/null +++ b/roles/adoption_osp_deploy/tasks/deploy_overcloud.yml @@ -0,0 +1,80 @@ +--- +# 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 + }} + _roles_file_name: "{{ _roles_file | basename }}" + _roles_file_dest: "{{ ansible_user_dir }}/{{ _roles_file_name }}" + _network_data_file: >- + {{ + [cifmw_adoption_source_scenario_path, + _adoption_source_scenario.overcloud.network_data_file + ] | path_join + }} + _network_data_file_name: "{{ _network_data_file | basename }}" + _network_data_file_dest: "{{ ansible_user_dir }}/{{ _network_data_file_name }}" + _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') + }} + block: + - name: Copy network data file + delegate_to: "osp-undercloud-0" + ansible.builtin.copy: + src: "{{ _network_data_file }}" + dest: "{{ _network_data_file_dest }}" + + - name: Copy roles file + delegate_to: "osp-undercloud-0" + ansible.builtin.copy: + src: "{{ _roles_file }}" + dest: "{{ _roles_file_dest }}" + + - name: Run overcloud deploy + delegate_to: "osp-undercloud-0" + vars: + _overcloud_deploy_cmd: >- + openstack overcloud deploy + --stack {{ _overcloud_name }} + {{ _overcloud_args }} + --roles-file {{ _roles_file_dest }} + -n {{ _network_data_file_dest }} + --ntp-server {{ cifmw_adoption_osp_deploy_ntp_server }} + -e {{ _overcloud_vars }} + -e {{ ansible_user_dir }}/containers-prepare-parameters.yaml + -e {{ ansible_user_dir }}/config-download.yaml + -e {{ ansible_user_dir }}/vips_provision_out.yaml + -e {{ ansible_user_dir }}/network_provision_out.yaml + _source_cmd: "source {{ ansible_user_dir }}/stackrc" + cifmw.general.ci_script: + chdir: "{{ ansible_user_dir }}" + output_dir: "{{ cifmw_basedir }}/artifacts" + script: "{{ _source_cmd }}; {{ _overcloud_deploy_cmd }}" 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..237dbfb58d --- /dev/null +++ b/roles/adoption_osp_deploy/tasks/deploy_undercloud.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. + +- name: Deploy 17.1 undercloud + delegate_to: "osp-undercloud-0" + cifmw.general.ci_script: + chdir: "{{ ansible_user_dir }}" + output_dir: "{{ cifmw_basedir }}/artifacts" + script: "openstack undercloud install" diff --git a/roles/adoption_osp_deploy/tasks/login_registries.yml b/roles/adoption_osp_deploy/tasks/login_registries.yml new file mode 100644 index 0000000000..cf454c8f8d --- /dev/null +++ b/roles/adoption_osp_deploy/tasks/login_registries.yml @@ -0,0 +1,50 @@ +--- +# 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: Activate red hat subscription + when: + - cifmw_adoption_osp_deploy_rhsm_org is defined + - cifmw_adoption_osp_deploy_rhsm_key is defined + become: true + no_log: true + ansible.builtin.command: >- + subscription-manager register --force + --org "{{ cifmw_adoption_osp_deploy_rhsm_org }}" + --activationkey "{{ cifmw_adoption_osp_deploy_rhsm_key }}" + +- name: Login in container registry + when: + - cifmw_adoption_osp_deploy_container_user is defined + - cifmw_adoption_osp_deploy_container_password is defined + - cifmw_adoption_osp_deploy_container_registry is defined + block: + - name: Install podman for container registry login + become: true + ansible.builtin.dnf: + name: podman + state: present + + - name: Login to container registry both zuul and root users + become: "{{ item == 'root' }}" + no_log: true + ansible.builtin.command: > + podman login + --username "{{ cifmw_adoption_osp_deploy_container_user }}" + --password "{{ cifmw_adoption_osp_deploy_container_password }}" + {{ cifmw_adoption_osp_deploy_container_registry }} + loop: + - zuul + - root diff --git a/roles/adoption_osp_deploy/tasks/main.yml b/roles/adoption_osp_deploy/tasks/main.yml new file mode 100644 index 0000000000..448b64557a --- /dev/null +++ b/roles/adoption_osp_deploy/tasks/main.yml @@ -0,0 +1,151 @@ +--- +# 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: Generate configuration files + ansible.builtin.import_tasks: config_files.yml + +- name: Prepare undercloud enviornment + tags: + - undercloud + ansible.builtin.import_tasks: prepare_undercloud.yml + +- name: Stop before running pre undercloud hooks + tags: + - undercloud + vars: + _stage_stopper: "before_pre_hook_undercloud" + when: + - cifmw_adoption_osp_deploy_stopper is defined + - cifmw_adoption_osp_deploy_stopper in _stage_stopper + ansible.builtin.fail: + msg: "Failing on demand {{ cifmw_adoption_osp_deploy_stopper }}" + +- name: Run pre undercloud deploy hooks + tags: + - undercloud + vars: + hooks: "{{ _adoption_source_scenario.pre_uc_run | default([]) }}" + step: "pre_undercloud" + ansible.builtin.include_role: + name: run_hook + +- name: Stop before deploying undercloud + tags: + - undercloud + vars: + _stage_stopper: "before_deploy_undercloud" + when: + - cifmw_adoption_osp_deploy_stopper is defined + - cifmw_adoption_osp_deploy_stopper in _stage_stopper + ansible.builtin.fail: + msg: "Failing on demand {{ cifmw_adoption_osp_deploy_stopper }}" + +- name: Deploy undercloud + tags: + - undercloud + ansible.builtin.import_tasks: deploy_undercloud.yml + +- name: Stop after deploying undercloud + tags: + - undercloud + vars: + _stage_stopper: "after_deploy_undercloud" + when: + - cifmw_adoption_osp_deploy_stopper is defined + - cifmw_adoption_osp_deploy_stopper in _stage_stopper + ansible.builtin.fail: + msg: "Failing on demand {{ cifmw_adoption_osp_deploy_stopper }}" + +- name: Run post undercloud deploy hooks + tags: + - undercloud + vars: + hooks: "{{ _adoption_source_scenario.post_uc_run | default([]) }}" + step: "post_undercloud" + ansible.builtin.include_role: + name: run_hook + +- name: Stop after running post undercloud hooks + tags: + - undercloud + vars: + _stage_stopper: "after_post_hook_undercloud" + when: + - cifmw_adoption_osp_deploy_stopper is defined + - cifmw_adoption_osp_deploy_stopper in _stage_stopper + ansible.builtin.fail: + msg: "Failing on demand {{ cifmw_adoption_osp_deploy_stopper }}" + +- name: Overcloud preparation + tags: + - overcloud + ansible.builtin.import_tasks: prepare_overcloud.yml + +- name: Stop before running pre overcloud hooks + tags: + - overcloud + vars: + _stage_stopper: "before_pre_hook_overcloud" + when: + - cifmw_adoption_osp_deploy_stopper is defined + - cifmw_adoption_osp_deploy_stopper in _stage_stopper + ansible.builtin.fail: + msg: "Failing on demand {{ cifmw_adoption_osp_deploy_stopper }}" + +- name: Run pre overcloud deploy hooks + tags: + - overcloud + vars: + hooks: "{{ _adoption_source_scenario.pre_oc_run | default([]) }}" + step: "pre_undercloud" + ansible.builtin.include_role: + name: run_hook + +- name: Stop before deploying the overcloud + tags: + - overcloud + vars: + _stage_stopper: "before_deploy_overcloud" + when: + - cifmw_adoption_osp_deploy_stopper is defined + - cifmw_adoption_osp_deploy_stopper in _stage_stopper + ansible.builtin.fail: + msg: "Failing on demand {{ cifmw_adoption_osp_deploy_stopper }}" + +- name: Deploy overcloud + tags: + - overcloud + ansible.builtin.import_tasks: deploy_overcloud.yml + +- name: Stop after deploying the overcloud + tags: + - overcloud + vars: + _stage_stopper: "post_deploy_overcloud" + when: + - cifmw_adoption_osp_deploy_stopper is defined + - cifmw_adoption_osp_deploy_stopper in _stage_stopper + ansible.builtin.fail: + msg: "Failing on demand {{ cifmw_adoption_osp_deploy_stopper }}" + +- name: Run post overcloud deploy hooks + tags: + - overcloud + vars: + hooks: "{{ _adoption_source_scenario.post_oc_run | default([]) }}" + step: "post_overcloud" + 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..7069d89e4d --- /dev/null +++ b/roles/adoption_osp_deploy/tasks/prepare_overcloud.yml @@ -0,0 +1,206 @@ +--- +# 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: + _network_data_file: >- + {{ + [cifmw_adoption_source_scenario_path, + _adoption_source_scenario.overcloud.network_data_file + ] | path_join + }} + _network_data_file_name: "{{ _network_data_file | basename }}" + _network_data_file_dest: "{{ ansible_user_dir }}/{{ _network_data_file_name }}" + _vips_data_file: >- + {{ + [cifmw_adoption_source_scenario_path, + _adoption_source_scenario.overcloud.vips_data_file + ] | path_join + }} + _vips_data_file_name: "{{ _vips_data_file | basename }}" + _vips_data_file_dest: "/home/zuul/{{ _vips_data_file_name }}" + _source_cmd: "source {{ ansible_user_dir }}/stackrc" + block: + - name: Ensure overcloud vms are started + vars: + _cifmw_libvirt_manager_layout: >- + {%- set layout = {'vms': {}} -%} + {%- for group in _adoption_source_scenario.hostname_groups_map -%} + {%- set _ = layout['vms'].update({ + group: {'start': true, 'disk_file_name': 'dummy'}}) + -%} + {%- endfor -%} + {{ layout }} + cifmw_libvirt_manager_all_vms: >- + {%- set vms = {} -%} + {%- for group in _adoption_source_scenario.hostname_groups_map -%} + {%- for vm in _vm_groups[group] -%} + {%- set _ = vms.update({vm: group}) -%} + {%- endfor -%} + {%- endfor -%} + {{ vms }} + ansible_libvirt_pools: {} + ansible.builtin.include_role: + name: "libvirt_manager" + tasks_from: "start_vms.yml" + apply: + delegate_to: "{{ cifmw_target_host | default('localhost') }}" + + - name: Ensure needed logins + ansible.builtin.include_tasks: login_registries.yml + args: + apply: + delegate_to: "{{ _vm }}" + loop: "{{ _tripleo_nodes }}" + loop_control: + loop_var: _vm + pause: 1 + + - name: Ensure repos are setup in overcloud nodes + when: "'undercloud' not in _vm" + delegate_to: "{{ _vm }}" + become: true + ansible.builtin.command: + cmd: "subscription-manager repos --enable {{ cifmw_adoption_osp_deploy_repos | join(' --enable ') }}" + loop: "{{ _tripleo_nodes }}" + loop_control: + loop_var: _vm + pause: 1 + + - name: Copy network data file + delegate_to: "osp-undercloud-0" + ansible.builtin.copy: + src: "{{ _network_data_file }}" + dest: "{{ _network_data_file_dest }}" + + - name: Ensure network_provision_out file does not exist + delegate_to: "osp-undercloud-0" + ansible.builtin.file: + path: "{{ ansible_user_dir }}/network_provision_out.yaml" + state: absent + + - name: Provision openstack networks + delegate_to: "osp-undercloud-0" + vars: + _network_provision_cmd: >- + openstack overcloud network provision + --output {{ ansible_user_dir }}/network_provision_out.yaml + {{ _network_data_file_dest }} + cifmw.general.ci_script: + chdir: "{{ ansible_user_dir }}" + output_dir: "{{ cifmw_basedir }}/artifacts" + script: "{{ _source_cmd }}; {{ _network_provision_cmd }}" + + - name: Copy vips data file + delegate_to: "osp-undercloud-0" + ansible.builtin.copy: + src: "{{ _vips_data_file }}" + dest: "{{ _vips_data_file_dest }}" + + - name: Ensure network_provision_out file does not exist + delegate_to: "osp-undercloud-0" + ansible.builtin.file: + path: "{{ ansible_user_dir }}/vips_provision_out.yaml" + state: absent + + - name: Provision virtual ips + delegate_to: "osp-undercloud-0" + vars: + _overcloud_name: >- + {{ + _adoption_source_scenario.overcloud.stackname | + default('overcloud') + }} + _vip_provision_cmd: >- + openstack overcloud network vip provision + --stack {{ _overcloud_name }} + --output {{ansible_user_dir}}/vips_provision_out.yaml + {{ _vips_data_file_dest }} + cifmw.general.ci_script: + output_dir: "{{ cifmw_basedir }}/artifacts" + script: "{{ _source_cmd }}; {{ _vip_provision_cmd }}" + + - name: Create tripleo ansible inventory + delegate_to: "osp-undercloud-0" + ansible.builtin.template: + src: "tripleo-ansible-inventory.yaml.j2" + dest: "{{ ansible_user_dir }}/overcloud-deploy/overcloud/tripleo-ansible-inventory.yaml" + + - name: Ensure os-net-config and openvswitch is installed in overcloud nodes + become: true + delegate_to: "{{ overcloud_vm }}" + ansible.builtin.dnf: + name: + - os-net-config + - openvswitch + state: present + loop: "{{ _tripleo_nodes }}" + loop_control: + loop_var: overcloud_vm + + - name: Ensure os-net-config folder exists in overcloud nodes + become: true + delegate_to: "{{ overcloud_vm }}" + ansible.builtin.file: + path: "/etc/os-net-config" + state: directory + mode: '0755' + loop: "{{ _tripleo_nodes }}" + loop_control: + loop_var: overcloud_vm + + - name: Generate os-net-config file for overcloud nodes + become: true + delegate_to: "{{ overcloud_vm }}" + vars: + _node_net: "{{ cifmw_networking_env_definition.instances[overcloud_vm] }}" + ctlplane_ip: "{{ _node_net.networks.ctlplane.ip_v4 }}" + _ctlplane_net: "{{ cifmw_networking_env_definition.networks.ctlplane }}" + dns_server: "{{ _ctlplane_net.dns_v4 }}" + gateway_ip: "{{ _ctlplane_net.gw_v4 }}" + interface_mtu: "{{ _node_net.networks.ctlplane.mtu }}" + ctlplane_cidr: "{{ _node_net.networks.ctlplane.prefix_length_v4 }}" + ansible.builtin.template: + src: "os_net_config_overcloud.yml.j2" + dest: /etc/os-net-config/tripleo_config.yaml + loop: "{{ _tripleo_nodes }}" + loop_control: + loop_var: overcloud_vm + + - name: Configure network interfaces for overcloud nodes + become: true + delegate_to: "{{ overcloud_vm }}" + ansible.builtin.command: + cmd: "os-net-config -c /etc/os-net-config/tripleo_config.yaml" + loop: "{{ _tripleo_nodes }}" + loop_control: + loop_var: overcloud_vm + + - name: Slurp undercloud public key for ssh access to overcloud nodes + delegate_to: "osp-undercloud-0" + ansible.builtin.slurp: + path: "{{ ansible_user_dir }}/.ssh/id_rsa.pub" + register: undercloud_ssh_pub + + + - name: Place undercloud public key in authorized_keys for zuul and root + delegate_to: "{{ overcloud_vm }}" + ansible.posix.authorized_key: + user: "{{ ansible_user_id }}" + key: "{{ undercloud_ssh_pub['content'] | b64decode | trim }}" + loop: "{{ _tripleo_nodes }}" + loop_control: + loop_var: overcloud_vm 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..5837823cfc --- /dev/null +++ b/roles/adoption_osp_deploy/tasks/prepare_undercloud.yml @@ -0,0 +1,217 @@ +--- +# 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 needed logins + ansible.builtin.include_tasks: login_registries.yml + args: + apply: + delegate_to: "osp-undercloud-0" + +- name: Ensure repos are setup + become: true + delegate_to: "osp-undercloud-0" + ansible.builtin.command: + cmd: "subscription-manager repos --enable {{ cifmw_adoption_osp_deploy_repos | join(' --enable ') }}" + +- name: Install director packages + become: true + delegate_to: "osp-undercloud-0" + 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 + {{ ansible_user_dir }}/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: Ensure os-net-config folder exists + become: true + delegate_to: "osp-undercloud-0" + ansible.builtin.file: + path: "/etc/os-net-config" + state: directory + mode: '0755' + +- name: Generate os-net-config file + become: true + delegate_to: "osp-undercloud-0" + vars: + _undercloud_name: "{{ _vm_groups['osp-underclouds'] | first }}" + _undercloud_net: "{{ cifmw_networking_env_definition.instances[_undercloud_name] }}" + ctlplane_ip: "{{ _undercloud_net.networks.ctlplane.ip_v4 }}" + ctlplane_vip: "{{ _adoption_source_scenario.undercloud.ctlplane_vip }}" + _ctlplane_net: "{{ cifmw_networking_env_definition.networks.ctlplane }}" + dns_server: "{{ _ctlplane_net.dns_v4 }}" + gateway_ip: "{{ _ctlplane_net.gw_v4 }}" + interface_mtu: "{{ _undercloud_net.networks.ctlplane.mtu }}" + ctlplane_cidr: "{{ _undercloud_net.networks.ctlplane.prefix_length_v4 }}" + ansible.builtin.template: + src: "os_net_config_undercloud.yml.j2" + dest: /etc/os-net-config/tripleo_config.yaml + +- 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: "{{ ansible_user_dir }}/undercloud.conf" + remote_src: true + +- name: Add environment specific vars for undercloud + vars: + _undercloud_name: "{{ _vm_groups['osp-underclouds'] | first }}" + _undercloud_net: "{{ cifmw_networking_env_definition.instances[_undercloud_name] }}" + _undercloud_ip: "{{ _undercloud_net.networks.ctlplane.ip_v4 }}" + _undercloud_net_prefix: "{{ _undercloud_net.networks.ctlplane.prefix_length_v4 }}" + _ctlplane_cidr: "{{ cifmw_networking_env_definition.networks.ctlplane.network_v4 }}" + _interface_mtu: "{{ _undercloud_net.networks.ctlplane.mtu }}" + _env_undercloud: + config: + - section: DEFAULT + option: local_ip + value: "{{ _undercloud_ip }}/{{ _undercloud_net_prefix }}" + - section: DEFAULT + option: local_mtu + value: "{{ _interface_mtu }}" + - section: DEFAULT + option: undercloud_ntp_servers + value: "{{ cifmw_adoption_osp_deploy_ntp_server }}" + - section: DEFAULT + option: container_images_file + value: "{{ ansible_user_dir }}/containers-prepare-parameters.yaml" + - section: DEFAULT + option: net_config_override + value: "/etc/os-net-config/tripleo_config.yaml" + - section: DEFAULT + option: undercloud_public_host + value: "{{ _ctlplane_cidr | ansible.utils.nthhost(122) }}" + - section: DEFAULT + option: undercloud_admin_host + value: "{{ _ctlplane_cidr | ansible.utils.nthhost(123) }}" + - section: "ctlplane-subnet" + option: "cidr" + value: "{{ _ctlplane_cidr }}" + - section: "ctlplane-subnet" + option: "dhcp_start" + value: "{{ _ctlplane_cidr | ansible.utils.nthhost(110) }}" + - section: "ctlplane-subnet" + option: "dhcp_end" + value: "{{ _ctlplane_cidr | ansible.utils.nthhost(130) }}" + - section: "ctlplane-subnet" + option: "gateway" + value: "{{ cifmw_networking_env_definition.networks.ctlplane.gw_v4 }}" + - section: "ctlplane-subnet" + option: "inspection_iprange" + value: "{{ _ctlplane_cidr | ansible.utils.nthhost(200) }},{{ _ctlplane_cidr | ansible.utils.nthhost(220) }}" + - section: "ctlplane-subnet" + option: "masquerade" + value: true + ansible.builtin.set_fact: + _undercloud_conf: >- + {{ + _adoption_source_scenario.undercloud | + combine(_env_undercloud, recursive=true, list_merge="append_rp") + }} + +- name: Copy undercloud overrides file if present and amend undercloud conf + when: _adoption_source_scenario.undercloud.undercloud_parameters_override is defined + vars: + _undercloud_overrides_path: >- + {{ + [cifmw_adoption_source_scenario_path, + _adoption_source_scenario.undercloud.undercloud_parameters_override + ] | path_join + }} + _filename: "{{ _undercloud_overrides_path | basename }}" + _dest_path: "{{ ansible_user_dir }}/{{ _filename }}" + block: + - name: Copy overrides file + delegate_to: "osp-undercloud-0" + ansible.builtin.copy: + src: "{{ _undercloud_overrides_path }}" + dest: "{{ _dest_path }}" + + - name: Amend undercloud conf + vars: + _undercloud_overrides: + config: + - section: DEFAULT + option: hieradata_override + value: "{{ _dest_path }}" + ansible.builtin.set_fact: + _undercloud_conf: >- + {{ + _undercloud_conf | + combine(_undercloud_overrides, recursive=true, list_merge="append_rp") + }} + +- name: Copy undercloud parameter defaults file if present and amend undercloud conf + when: _adoption_source_scenario.undercloud.undercloud_parameters_defaults is defined + vars: + _undercloud_defaults_path: >- + {{ + [cifmw_adoption_source_scenario_path, + _adoption_source_scenario.undercloud.undercloud_parameters_defaults + ] | path_join + }} + _filename: "{{ _undercloud_defaults_path | basename }}" + _dest_path: "{{ ansible_user_dir }}/{{ _filename }}" + block: + - name: Copy defaults file + delegate_to: "osp-undercloud-0" + ansible.builtin.copy: + src: "{{ _undercloud_defaults_path }}" + dest: "{{ _dest_path }}" + + - name: Amend undercloud conf + vars: + _undercloud_overrides: + config: + - section: DEFAULT + option: custom_env_files + value: "{{ _dest_path }}" + ansible.builtin.set_fact: + _undercloud_conf: >- + {{ + _undercloud_conf | + combine(_undercloud_overrides, recursive=true, list_merge="append_rp") + }} + +- name: Generate undercloud.conf with scenario specific values + delegate_to: "osp-undercloud-0" + community.general.ini_file: + path: "{{ ansible_user_dir }}/undercloud.conf" + section: "{{ item.section }}" + option: "{{ item.option }}" + value: "{{ item.value }}" + state: "present" + loop: "{{ _undercloud_conf.config }}" diff --git a/roles/adoption_osp_deploy/templates/os_net_config_overcloud.yml.j2 b/roles/adoption_osp_deploy/templates/os_net_config_overcloud.yml.j2 new file mode 100644 index 0000000000..85fd915e0c --- /dev/null +++ b/roles/adoption_osp_deploy/templates/os_net_config_overcloud.yml.j2 @@ -0,0 +1,42 @@ +#jinja2: trim_blocks:True, lstrip_blocks:True +network_config: +- type: ovs_bridge + name: br-ex + mtu: {{ interface_mtu }} + use_dhcp: false + dns_servers: + {% for dns_ip in dns_server | default([]) %} + - {{ dns_ip }} + {% endfor %} + - {{ gateway_ip }} + domain: [] + addresses: + - ip_netmask: {{ ctlplane_ip }}/{{ ctlplane_cidr }} + {% if _adoption_source_scenario.overcloud.routes is defined %} + {%- for route in _adoption_source_scenario.overcloud.routes %} + routes: + - ip_netmask: {{ route.ip_netmask }} + next_hop: {{ route.next_hop }} + default: {{ route.default }} + {% endfor %} + {%- else %} + routes: [] + {% endif %} + members: + - type: interface + name: {{ _adoption_source_scenario.overcloud.os_net_config_iface | + default('nic2') }} + mtu: {{ interface_mtu }} + # force the MAC address of the bridge to this interface + primary: true + {% for network_name, net in _node_net.networks.items() %} + {% if 'vlan_id' in net %} + # {{ network_name }} + - type: vlan + mtu: {{ net.mtu }} + vlan_id: {{ net.vlan_id }} + addresses: + - ip_netmask: {{ net.ip_v4 }}/{{ net.prefix_length_v4 }} + routes: [] + {% endif %} + {% endfor %} diff --git a/roles/adoption_osp_deploy/templates/os_net_config_undercloud.yml.j2 b/roles/adoption_osp_deploy/templates/os_net_config_undercloud.yml.j2 new file mode 100644 index 0000000000..6a6e652abf --- /dev/null +++ b/roles/adoption_osp_deploy/templates/os_net_config_undercloud.yml.j2 @@ -0,0 +1,45 @@ +#jinja2: trim_blocks:True, lstrip_blocks:True +network_config: +- type: ovs_bridge + name: br-ctlplane + mtu: {{ interface_mtu }} + use_dhcp: false + dns_servers: + {% for dns_ip in dns_server | default([]) %} + - {{ dns_ip }} + {% endfor %} + - {{ gateway_ip }} + domain: [] + addresses: + - ip_netmask: {{ ctlplane_ip }}/{{ ctlplane_cidr }} + - ip_netmask: {{ ctlplane_ip }}/32 + - ip_netmask: {{ ctlplane_vip }}/32 + {% if _adoption_source_scenario.undercloud.routes is defined %} + {%- for route in _adoption_source_scenario.undercloud.routes %} + routes: + - ip_netmask: {{ route.ip_netmask }} + next_hop: {{ route.next_hop }} + default: {{ route.default }} + {% endfor %} + {%- else %} + routes: [] + {% endif %} + members: + - type: interface + name: {{ _adoption_source_scenario.undercloud.os_net_config_iface | + default('nic2') }} + mtu: {{ interface_mtu }} + # force the MAC address of the bridge to this interface + primary: true + {% for network_name, net in _undercloud_net.networks.items() %} + {% if 'vlan_id' in net %} + # {{ network_name }} + - type: vlan + mtu: {{ net.mtu }} + vlan_id: {{ net.vlan_id }} + addresses: + - ip_netmask: {{ net.ip_v4 }}/{{ net.prefix_length_v4 }} + - ip_netmask: {{ net.ip_v4.split('.')[:3] | join('.') }}.2/32 + routes: [] + {% endif %} + {% endfor %} diff --git a/roles/adoption_osp_deploy/templates/tripleo-ansible-inventory.yaml.j2 b/roles/adoption_osp_deploy/templates/tripleo-ansible-inventory.yaml.j2 new file mode 100644 index 0000000000..262b7b0d63 --- /dev/null +++ b/roles/adoption_osp_deploy/templates/tripleo-ansible-inventory.yaml.j2 @@ -0,0 +1,36 @@ +#jinja2: trim_blocks:True, lstrip_blocks:True +{% for group, role in _adoption_source_scenario.roles_groups_map.items() %} +{{ role }}: + hosts: + {% for node in _vm_groups[group] %} + {% set node_nets = cifmw_networking_env_definition.instances[node] %} + {{ node }}: + ansible_host: {{ node_nets.networks.ctlplane.ip_v4 }} + canonical_hostname: {{ node }}.{{ _adoption_source_scenario.cloud_domain }} + ctlplane_ip: {{ node_nets.networks.ctlplane.ip_v4 }} + {% for network_name, net in node_nets.networks.items() %} + {% if 'vlan_id' in net %} + {% set net_name = ['storage_mgmt'] if network_name == 'storagemgmt' else [network_name] %} + {% set net_name = ['internal_api'] if network_name == 'internalapi' else [network_name] %} + {{ net_name[0] }}_ip: {{ net.ip_v4 }} + {% endif %} + {% endfor %} + {% endfor %} + vars: + ansible_ssh_common_args: -o StrictHostKeyChecking=no + ansible_ssh_user: zuul +{% endfor %} +Undercloud: + hosts: + undercloud: {} + vars: + ansible_connection: local + ansible_host: localhost +allovercloud: + children: + {% for _, role in _adoption_source_scenario.roles_groups_map.items() %} + {{ role }}: {} + {% endfor %} +computes: + children: + {{ _adoption_source_scenario.roles_groups_map['osp-computes'] }}: {} diff --git a/scenarios/adoption/hci.yml b/scenarios/adoption/hci.yml index 0d4bad93a2..c2b8e11cc4 100644 --- a/scenarios/adoption/hci.yml +++ b/scenarios/adoption/hci.yml @@ -50,19 +50,36 @@ libvirt_manager_patch_layout: memory: 4 cpus: 4 disksize: 20 + extra_disks_num: 1 + extra_disks_size: 30G nets: - ocpbm - osp_trunk networking_mapper_definition_patch: + networks: + external: + network: "172.21.0.0/24" + vlan: 44 + mtu: 1496 group-templates: - osp-controllers: + computes: network-template: + # ensure this range does not collide with osp-computes one, even if we + # don't create any vms for the compute group (the computes for + # greenfield jobs) we need to make sure their ip ranges do not overlap range: start: 200 + length: 1 + osp-controllers: + network-template: + range: + start: 103 length: 3 networks: &osp_nets ctlplane: {} + external: + trunk-parent: ctlplane internalapi: trunk-parent: ctlplane tenant: @@ -74,12 +91,12 @@ networking_mapper_definition_patch: osp-computes: network-template: range: - start: 210 + start: 106 length: 3 networks: *osp_nets osp-underclouds: network-template: range: - start: 199 + start: 100 length: 1 networks: *osp_nets