Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions hooks/playbooks/adoption_bgp_post_overcloud.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
# 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: BGP post_overcloud hook
hosts: "{{ cifmw_target_host | default('localhost') }}"
gather_facts: false
tasks:
- name: Remove default route from OC nodes
delegate_to: "{{ _vm }}"
become: true
ansible.builtin.command:
cmd: ip route del default via 192.168.111.1
failed_when: false
loop: >-
{{
_vm_groups['osp-r0-computes'] | list +
_vm_groups['osp-r0-controllers'] | list +
_vm_groups['osp-r1-computes'] | list +
_vm_groups['osp-r1-controllers'] | list +
_vm_groups['osp-r2-computes'] | list +
_vm_groups['osp-r2-controllers'] | list
}}
loop_control:
loop_var: _vm
36 changes: 36 additions & 0 deletions hooks/playbooks/adoption_bgp_pre_overcloud.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
# 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: BGP pre_overcloud hook
hosts: "{{ cifmw_target_host | default('localhost') }}"
gather_facts: false
tasks:
- name: Add default route to OC nodes
delegate_to: "{{ _vm }}"
become: true
ansible.builtin.command:
cmd: ip route add default via 192.168.111.1
loop: >-
{{
_vm_groups['osp-r0-computes'] | list +
_vm_groups['osp-r0-controllers'] | list +
_vm_groups['osp-r1-computes'] | list +
_vm_groups['osp-r1-controllers'] | list +
_vm_groups['osp-r2-computes'] | list +
_vm_groups['osp-r2-controllers'] | list
}}
loop_control:
loop_var: _vm
69 changes: 69 additions & 0 deletions playbooks/bgp/prepare-bgp-spines-leaves.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,60 @@
---
- name: Start spines and leafs and add them to inventory
hosts: localhost
vars:
leafs_list:
- leaf-0
- leaf-1
- leaf-2
- leaf-3
- leaf-4
- leaf-5
spines_list:
- spine-0
- spine-1
routers_list:
- router-0
fabric_list: "{{ leafs_list + spines_list + routers_list }}"
tasks:
- name: Start spine and leaf VMs
delegate_to: hypervisor
become: true
community.libvirt.virt:
name: "cifmw-{{ item }}"
state: running
loop: "{{ fabric_list }}"

- name: Add leafs group to inventory
when: '"leafs" not in groups'
ansible.builtin.add_host:
name: "{{ item }}.utility"
group: leafs
loop: "{{ leafs_list }}"

- name: Add spines group to inventory
when: '"spines" not in groups'
ansible.builtin.add_host:
name: "{{ item }}.utility"
group: spines
loop: "{{ spines_list }}"

- name: Add routers group to inventory
when: '"routers" not in groups'
ansible.builtin.add_host:
name: "{{ item }}.utility"
group: routers
loop: "{{ routers_list }}"

- name: Check SSH connectivity
delegate_to: hypervisor
ansible.builtin.wait_for:
port: 22
host: "{{ item }}.utility"
search_regex: OpenSSH
delay: 10
timeout: 120
loop: "{{ fabric_list }}"

- name: Common spines and leaves configuration
hosts: "spines,leafs{{ router_bool | default(false) | ternary(',routers', '') }}"
tasks:
Expand Down Expand Up @@ -183,10 +239,13 @@
autoconnect: true
conn_name: "{{ item }}"
type: ethernet
ifname: "{{ router_downlink_ifs[loop_index | int] }}"
method4: disabled
method6: link-local
state: present
loop: "{{ router_downlink_conns }}"
loop_control:
index_var: loop_index

# uplink router IPv4 is configured for both IPv4 and IPv6 jobs
- name: Configure uplink router connections with nmcli when IPv4
Expand Down Expand Up @@ -453,6 +512,8 @@
autoconnect: true
conn_name: "{{ item }}"
ip4: "{{ leaf_ds_ip4 }}/30"
type: ethernet
ifname: "{{ downlink_ifs_rack3[loop_index | int] }}"
method4: manual
method6: link-local
state: present
Expand All @@ -470,6 +531,8 @@
autoconnect: true
conn_name: "{{ item }}"
ip4: "{{ leaf_ds_ip4 }}/30"
type: ethernet
ifname: "{{ leaf_downlink_ifs[loop_index | int] }}"
method4: manual
method6: link-local
state: present
Expand Down Expand Up @@ -513,6 +576,8 @@
conn_name: "{{ item }}"
ip4: "{{ _leaf_ds_ip4 }}/30"
ip6: "{{ _leaf_ds_ip6 }}/126"
type: ethernet
ifname: "{{ leaf_downlink_ifs[loop_index | int] }}"
method4: manual
method6: manual
state: present
Expand Down Expand Up @@ -549,8 +614,12 @@
conn_name: "{{ item }}"
method4: disabled
method6: link-local
type: ethernet
ifname: "{{ uplink_ifs[loop_index | int] }}"
state: present
loop: "{{ uplink_conns }}"
loop_control:
index_var: loop_index

- name: Enable FRR Zebra daemon
become: true
Expand Down
9 changes: 9 additions & 0 deletions roles/adoption_osp_deploy/tasks/config_files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,16 @@
register: _original_config_download
delegate_to: "localhost"

- name: Copy config download file as is (bgp)
when: bgp
delegate_to: "osp-undercloud-0"
ansible.builtin.copy:
content: "{{ _original_config_download['content'] |b64decode | from_yaml | to_nice_yaml(indent=2, sort_keys=false) }}"
dest: "{{ ansible_user_dir }}/config_download_{{ _stack.stackname }}.yaml"
mode: "0644"

- name: Generate config download file
when: not bgp
vars:
_ctlplane_net: "{{ cifmw_networking_env_definition.networks.ctlplane }}"
_hostname_map_translation: >-
Expand Down
20 changes: 20 additions & 0 deletions roles/adoption_osp_deploy/tasks/generate_adoption_vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- user_dir

- name: Generate adoption vars file
when: not bgp
delegate_to: "controller-0"
vars:
_undercloud_name: "{{ _vm_groups['osp-underclouds'] | first }}"
Expand All @@ -44,3 +45,22 @@
src: "adoption_vars.yaml.j2"
dest: "{{ ansible_user_dir }}/adoption_vars.yaml"
mode: "0644"


- name: Generate adoption vars file (BGP)
when: bgp
delegate_to: "controller-0"
vars:
_undercloud_name: "{{ _vm_groups['osp-underclouds'] | first }}"
_undercloud_net: "{{ cifmw_networking_env_definition.instances[_undercloud_name] }}"
_undercloud_ip: "{{ _undercloud_net.networks.ctlplaner0[ip_version|default('ip_v4')] }}"
_controller_1_name: "{{ _vm_groups['osp-r0-controllers'] | first }}"
_controller_1_net: "{{ cifmw_networking_env_definition.instances[_controller_1_name] }}"
_controller_1_internalapi_ip: "99.99.0.29"
_compute_1_name: "{{ _vm_groups['osp-r0-computes'] | first }}"
_compute_1_net: "{{ cifmw_networking_env_definition.instances[_compute_1_name] }}"
_compute_1_ip: "{{ _compute_1_net.networks.ctlplaner0[ip_version|default('ip_v4')] }}"
ansible.builtin.template:
src: "adoption_vars_bgp.yaml.j2"
dest: "{{ ansible_user_dir }}/adoption_vars.yaml"
mode: "0644"
42 changes: 42 additions & 0 deletions roles/adoption_osp_deploy/tasks/getent_registry_ips_bgp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
# 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: Obtain IPs whose routes need to be added to the undercloud (bgp)
ansible.builtin.getent:
database: ahosts
key: "{{ item }}"
register: _current_vm_getent
loop:
- registry.redhat.io
- cdn.redhat.com
- access.redhat.com
- cdn01.quay.io

- name: Accumulate IPs from this VM
ansible.builtin.set_fact:
_accumulated_ips: >-
{{
_accumulated_ips | default([]) +
(
_current_vm_getent.results |
map(attribute='ansible_facts.getent_ahosts') |
map('dict2items') |
flatten |
map(attribute='key') |
reject('match', '.*:.*') |
list
)
}}
93 changes: 93 additions & 0 deletions roles/adoption_osp_deploy/tasks/prepare_overcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,21 @@
script: "{{ _source_cmd }}; {{ _vip_provision_cmd }}"

- name: Create tripleo ansible inventory
when: not bgp
delegate_to: "osp-undercloud-0"
ansible.builtin.template:
src: "tripleo-ansible-inventory.yaml.j2"
dest: "{{ ansible_user_dir }}/overcloud-deploy/{{ _overcloud_name }}/tripleo-ansible-inventory.yaml"
mode: "0644"

- name: Create tripleo ansible inventory (BGP)
when: bgp
delegate_to: "osp-undercloud-0"
ansible.builtin.template:
src: "tripleo-ansible-inventory_bgp.yaml.j2"
dest: "{{ ansible_user_dir }}/overcloud-deploy/{{ _overcloud_name }}/tripleo-ansible-inventory.yaml"
mode: "0644"

- name: Ensure os-net-config and openvswitch is installed in overcloud nodes
become: true
delegate_to: "{{ overcloud_vm }}"
Expand Down Expand Up @@ -184,6 +193,90 @@
loop: "{{ _tripleo_nodes_stack[_overcloud_name] }}"
loop_control:
loop_var: overcloud_vm
when: not bgp

- name: Obtain IPs whose routes need to be added to the undercloud (bgp)
when: bgp
ansible.builtin.include_tasks: getent_registry_ips_bgp.yml
args:
apply:
delegate_to: "{{ _vm }}"
loop: "{{ _tripleo_nodes_stack[_overcloud_name] }}"
loop_control:
loop_var: _vm
pause: 1

- name: Generate os-net-config file for overcloud nodes (bgp)
become: true
delegate_to: "{{ overcloud_vm }}"
vars:
_node_net: "{{ cifmw_networking_env_definition.instances[overcloud_vm] }}"
_dns_server: "{{ _ctlplane_net.[dns_version|default('dns_v4')] }}"
_interface_mtu: 1500
_ips_for_oc_routes_list: "{{ _accumulated_ips | unique }}"
vms:
osp-r0-compute-0:
ctlplane: '192.168.122.100'
left: '100.64.0.2'
right: '100.65.0.2'
main: '99.99.0.2'
main6: 'f00d:f00d:f00d:f00d:f00d:f00d:f00d:0004'
osp-r0-compute-1:
ctlplane: '192.168.122.101'
left: '100.64.0.6'
right: '100.65.0.6'
main: '99.99.0.6'
main6: 'f00d:f00d:f00d:f00d:f00d:f00d:f00d:0005'
osp-r1-compute-0:
ctlplane: '192.168.123.105'
left: '100.64.1.2'
right: '100.65.1.2'
main: '99.99.1.2'
main6: 'f00d:f00d:f00d:f00d:f00d:f00d:f00d:0006'
osp-r1-compute-1:
ctlplane: '192.168.123.106'
left: '100.64.1.6'
right: '100.65.1.6'
main: '99.99.1.6'
main6: 'f00d:f00d:f00d:f00d:f00d:f00d:f00d:0007'
osp-r2-compute-0:
ctlplane: '192.168.124.110'
left: '100.64.2.2'
right: '100.65.2.2'
main: '99.99.2.2'
main6: 'f00d:f00d:f00d:f00d:f00d:f00d:f00d:0008'
osp-r2-compute-1:
ctlplane: '192.168.124.111'
left: '100.64.2.6'
right: '100.65.2.6'
main: '99.99.2.6'
main6: 'f00d:f00d:f00d:f00d:f00d:f00d:f00d:0009'
osp-r0-controller-0:
ctlplane: '192.168.122.140'
left: '100.64.0.26'
right: '100.65.0.26'
main: '99.99.0.29'
main6: 'f00d:f00d:f00d:f00d:f00d:f00d:f00d:0001'
osp-r1-controller-0:
ctlplane: '192.168.123.142'
left: '100.64.1.26'
right: '100.65.1.26'
main: '99.99.1.29'
main6: 'f00d:f00d:f00d:f00d:f00d:f00d:f00d:0002'
osp-r2-controller-0:
ctlplane: '192.168.124.144'
left: '100.64.2.26'
right: '100.65.2.26'
main: '99.99.2.29'
main6: 'f00d:f00d:f00d:f00d:f00d:f00d:f00d:0003'
ansible.builtin.template:
src: "os_net_config_overcloud_bgp.yml.j2"
dest: /etc/os-net-config/tripleo_config.yaml
mode: "0644"
loop: "{{ _tripleo_nodes_stack[_overcloud_name] }}"
loop_control:
loop_var: overcloud_vm
when: bgp

- name: Configure network interfaces for overcloud nodes
become: true
Expand Down
Loading
Loading