diff --git a/roles/adoption_osp_deploy/defaults/main.yml b/roles/adoption_osp_deploy/defaults/main.yml index b1a0fb2722..dac408fad6 100644 --- a/roles/adoption_osp_deploy/defaults/main.yml +++ b/roles/adoption_osp_deploy/defaults/main.yml @@ -17,3 +17,4 @@ # 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" diff --git a/roles/adoption_osp_deploy/tasks/deploy_ceph.yml b/roles/adoption_osp_deploy/tasks/deploy_ceph.yml index 347d74d90f..7942fb347b 100644 --- a/roles/adoption_osp_deploy/tasks/deploy_ceph.yml +++ b/roles/adoption_osp_deploy/tasks/deploy_ceph.yml @@ -61,7 +61,7 @@ _ceph_deploy_cmd: >- openstack openstack ceph deploy --tld {{ _cloud_domain }} - --ntp-server {{ adoption_osp_deploy_ntp_server }} + --ntp-server {{ cifmw_adoption_osp_deploy_ntp_server }} --ceph-spec ceph_spec.yaml --network-data {{ _network_data_file }} --cephadm-default-container diff --git a/roles/adoption_osp_deploy/tasks/deploy_overcloud.yml b/roles/adoption_osp_deploy/tasks/deploy_overcloud.yml index eddc59bc28..e773f18925 100644 --- a/roles/adoption_osp_deploy/tasks/deploy_overcloud.yml +++ b/roles/adoption_osp_deploy/tasks/deploy_overcloud.yml @@ -53,7 +53,7 @@ {{ _overcloud_args }} --roles-file {{ _roles_file }} -n {{ _network_data_file }} - --ntp-server {{ adoption_osp_deploy_ntp_server }} + --ntp-server {{ cifmw_adoption_osp_deploy_ntp_server }} {{ _overcloud_vars }} -e /home/zuul/containers-prepare-parameters.yaml -e {{ overcloud_services_file }} diff --git a/roles/adoption_osp_deploy/tasks/prepare_undercloud.yml b/roles/adoption_osp_deploy/tasks/prepare_undercloud.yml index a1dbe1e54d..fd01b1ec7b 100644 --- a/roles/adoption_osp_deploy/tasks/prepare_undercloud.yml +++ b/roles/adoption_osp_deploy/tasks/prepare_undercloud.yml @@ -14,15 +14,38 @@ # 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 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 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.builtin.include_role: + name: "libvirt_manager" + tasks_from: "start_vms.yml" - name: Ensure repos are setup vars: @@ -66,6 +89,38 @@ 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.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: Ensure os-net-config package is installed + become: true + delegate_to: "osp-undercloud-0" + ansible.builtin.package: + name: os-net-config + - name: Copy undercloud.conf file to location to edit it delegate_to: "osp-undercloud-0" ansible.builtin.copy: @@ -75,22 +130,28 @@ - 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 }}" _env_undercloud: config: - section: DEFAULT option: local_ip - value: "{{ undercloud_ip }}" + value: "{{ _undercloud_ip }}" - section: DEFAULT option: undercloud_ntp_servers - value: "{{ adoption_osp_deploy_ntp_server }}" + value: "{{ cifmw_adoption_osp_deploy_ntp_server }}" - section: DEFAULT option: container_images_file value: "/home/zuul/containers-prepare-parameters.yaml" + - section: DEFAULT + option: net_config_override + value: "/etc/os-net-config/tripleo_config.yaml" ansible.builtin.set_fact: _undercloud_conf: >- {{ - _adoption_source_scenario.undercloud.config | - combine(_env_undercloud, recursive=true) + _adoption_source_scenario.undercloud | + combine(_env_undercloud, recursive=true, list_merge="append_rp") }} - name: Copy undercloud overrides file if present and amend undercloud conf @@ -99,7 +160,7 @@ _undercloud_overrides_path: >- {{ [cifmw_adoption_source_scenario_path, - _adoption_source_scenario.overcloud.config_download_file + _adoption_source_scenario.undercloud.undercloud_parameters_override ] | path_join }} _filename: "{{ _undercloud_overrides_path | basename }}" @@ -112,7 +173,7 @@ - name: Amend undercloud conf vars: - overrides: + _undercloud_overrides: config: - section: DEFAULT option: hieradata_override @@ -121,7 +182,39 @@ _undercloud_conf: >- {{ _undercloud_conf | - combine(_env_undercloud, recursive=true) + 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: "/home/zuul/{{ _filename }}" + block: + - name: Copy overrides file + 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 @@ -132,4 +225,4 @@ option: "{{ item.option }}" value: "{{ item.value }}" state: "present" - loop: "{{ _env_undercloud }}" + loop: "{{ _undercloud_conf.config }}" 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..ae4c17e12f --- /dev/null +++ b/roles/adoption_osp_deploy/templates/os_net_config_undercloud.yml.j2 @@ -0,0 +1,41 @@ +network_config: +- type: ovs_bridge + name: br-ctlplane + mtu: {{ interface_mtu }} + use_dhcp: false + dns_servers: + {% if dns_server %} + - {{ dns_server }} + {% endif %} + - {{ 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 ... %} + # external + - type: vlan + mtu: {{ interface_mtu }} + vlan_id: {{ vland_id }} + addresses: + - ip_netmask: {{ ip_address }}/{{ prefix_length_v4 }} + - ip_netmask: {{ ip_network }}.2/32 + routes: [] + {% endfor %}