Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare crc job for architecture repo #1794

Merged
merged 1 commit into from
Aug 22, 2024
Merged
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
61 changes: 61 additions & 0 deletions ci/playbooks/architecture_crc/prepare-architecture-crc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
- hosts: "{{ cifmw_target_host | default('localhost') }}"
tasks:
# jgilaber: we need to make sure nncp does not touch the vlans, otherwise
# it'll create them with the same MAC address as the ospbr bridge and that
# causes problems when trying to reach the dnsmasq service from the compute
# node. Changing the interface and connnection name to what is used in the
# nncp CR avoids the issue
- name: Change vlan interface and connection names
delegate_to: "crc"
become: true
vars:
old_connn_name: "ci-{{ item.name }}-{{ item.vlan }}"
ansible.builtin.shell: |
nmcli con down {{ old_connn_name }}
nmcli con modify {{ old_connn_name }} connection.interface-name {{ item.name }}
nmcli con modify {{ old_connn_name }} connection.id {{ item.name }}
nmcli con up {{ item.name }}
loop:
- name: internalapi
vlan: 20
- name: storage
vlan: 21
- name: tenant
vlan: 22

- name: Read os-net-info file
ansible.builtin.slurp:
src: "/etc/ci/env/os-net-info.yml"
register: _ci_bootstrap_os_net_info

- name: Translate os_net_info into interfaces-info
vars:
_ci_bootstrap_os_parsed: "{{ _ci_bootstrap_os_net_info['content'] | b64decode | from_yaml }}"
_ci_bootstrap_macs: "{{ _ci_bootstrap_os_parsed.ci_bootstrap_os_mac_addr_map }}"
ansible.builtin.copy:
dest: "{{ cifmw_basedir }}/parameters/interfaces-info.yml"
content: |
{% for node, net_list in _ci_bootstrap_macs.items() %}
{{ node }}:
{% for net, mac in net_list.items() %}
- network: {{ net }}
mac: {{ mac }}
{% endfor %}
{% endfor %}

- name: Call networking_mapper again to make sure interfaces names are set in the networking enviornment file
ansible.builtin.import_role:
name: networking_mapper

- hosts: computes
tasks:
- name: Setup repos
ansible.builtin.include_role:
name: repo_setup

- name: Set hostname to inventory hostname for ceph deployment
become: true
ansible.builtin.hostname:
name: "{{ inventory_hostname }}"
use: "systemd"
72 changes: 72 additions & 0 deletions ci/playbooks/architecture_crc/run-architecture-crc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
# Usage and expected parameters
# $ ansible-playbook run-architecture-crc.yml \
# -e cifmw_architecture_repo=$HOME/architecture \
# -e cifmw_architecture_scenario=hci \
# -e cifmw_networking_mapper_networking_env_def_path=$HOME/net-env.yml
# [any other parameter/files your VA/DT might need]
#
# cifmw_architecture_repo: location of the architecture repository.
# cifmw_architecture_scenario: the scenario you want to test.
# cifmw_networking_mapper_networking_env_def_path: path to the
# networking-mapper environment definition file.
#
# Special parameters set in the playbook (you can override them)
# cifmw_basedir: defaults to ~/ci-framework-data
# cifmw_zuul_target_host: target host. Defaults to localhost

- name: Test architecture automations
hosts: "{{ cifmw_zuul_target_host | default('controller') }}"
gather_facts: true
vars:
_homedir: "{{ ansible_user_dir | default(lookup('env', 'HOME')) }}"
cifmw_basedir: >-
{{
(_homedir,
'ci-framework-data') |
path_join
}}
cifmw_path: >-
{{
['~/bin',
ansible_env.PATH] | join(':')
}}
ci_framework_src_dir: "{{ ansible_user_dir }}/src/github.com/openstack-k8s-operators/ci-framework"
pre_tasks:
- name: Create needed directories
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be done via the ci_setup/directories tasks file (you have to provide directory_state: directory )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a good idea, but I'd still need an extra task to create parameters dir, since it's not created by the ci_setup

- "{{ cifmw_manifests | default(cifmw_ci_setup_basedir ~ '/artifacts/manifests') }}/\
and it's needed to store the interfaces-info.yml file

ansible.builtin.file:
path: "{{ item }}"
state: directory
mode: "0755"
loop:
- "{{ cifmw_basedir }}/logs"
- "{{ cifmw_basedir }}/artifacts"
- "{{ cifmw_basedir }}/parameters"

tasks:
- name: Run preparation steps for VA deployment in crc
ansible.builtin.command: >
ansible-playbook -i {{ cifmw_basedir }}/artifacts/zuul_inventory.yml
ci/playbooks/architecture_crc/prepare-architecture-crc.yml
-e cifmw_basedir="{{ cifmw_basedir }}"
{%- if cifmw_extras is defined %}
{%- for extra_vars in cifmw_extras %}
-e "{{ extra_vars }}"
{%- endfor %}
{%- endif %}
args:
chdir: "{{ ci_framework_src_dir }}"

- name: Deploy VA with crc
ansible.builtin.command: >
ansible-playbook -i {{ cifmw_basedir }}/artifacts/zuul_inventory.yml
deploy-edpm.yml
-e cifmw_basedir="{{ cifmw_basedir }}"
-e "@{{ ansible_user_dir }}/ci-framework-data/artifacts/nodepool_params.yml"
{%- if cifmw_extras is defined %}
{%- for extra_vars in cifmw_extras %}
-e "{{ extra_vars }}"
{%- endfor %}
{%- endif %}
args:
chdir: "{{ ci_framework_src_dir }}"
10 changes: 5 additions & 5 deletions ci/playbooks/multinode-customizations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@
}}
_crc_default_net_ip: >-
{{
_decoded_net_env.crc_ci_bootstrap_networks_out.crc.default.ip
_decoded_net_env.crc_ci_bootstrap_networks_out.crc[cifmw_crc_default_network | default('default')].ip
}}
block:
- name: Manage name resolution and interfaces
become: true
vars:
_crc_default_iface: >-
{{
_decoded_net_env.crc_ci_bootstrap_networks_out.crc.default.iface
_decoded_net_env.crc_ci_bootstrap_networks_out.crc[cifmw_crc_default_network | default('default')].iface
}}
_crc_default_gw: >-
{{
_decoded_net_env.crc_ci_bootstrap_networks_out.crc.default.gw
_decoded_net_env.crc_ci_bootstrap_networks_out.crc[cifmw_crc_default_network | default('default')].gw
}}
_crc_private_connection_name: >-
{{
_decoded_net_env.crc_ci_bootstrap_networks_out.crc.default.connection
_decoded_net_env.crc_ci_bootstrap_networks_out.crc[cifmw_crc_default_network | default('default')].connection
}}
block:
- name: Ensure crc knows about its second NIC
Expand Down Expand Up @@ -290,7 +290,7 @@
}}
_crc_default_net_ip: >-
{{
_decoded_net_env.crc_ci_bootstrap_networks_out.crc.default.ip |
_decoded_net_env.crc_ci_bootstrap_networks_out.crc[cifmw_crc_default_network | default('default')].ip |
ansible.utils.ipaddr('address')
}}
dns_servers_string: >-
Expand Down
12 changes: 12 additions & 0 deletions ci/playbooks/pre-ci-bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@
ansible.builtin.include_role:
name: networking_mapper

- name: Store nodepool data if defined so we can set mtu depending on provider
when: nodepool is defined
ansible.builtin.copy:
dest: "{{ ansible_user_dir }}/ci-framework-data/artifacts/nodepool_params.yml"
content: |
nodepool:
{{ nodepool | to_nice_yaml | indent(2) }}
mode: '0644'

- name: Run networking_mapper playbook
environment:
ANSIBLE_HOST_KEY_CHECKING: false
Expand All @@ -23,3 +32,6 @@
-i {{ ansible_user_dir }}/ci-framework-data/artifacts/zuul_inventory.yml
-e @scenarios/centos-9/base.yml
-e "@{{ ansible_user_dir }}/ci-framework-data/artifacts/parameters/zuul-params.yml"
{% if nodepool is defined %}
-e "@{{ ansible_user_dir }}/ci-framework-data/artifacts/nodepool_params.yml"
{% endif %}
1 change: 1 addition & 0 deletions docs/dictionary/en-custom.txt
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ unclaim
undefine
unittest
unmanaged
untagged
uoyt
uri
usermod
Expand Down
1 change: 1 addition & 0 deletions docs/source/usage/01_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ are shared among multiple roles:
- `cifmw_nolog`: (Bool) Toggle `no_log` value for selected tasks. Defaults to `true` (hiding those logs by default).
- `cifmw_parent_scenario`: (String or List(String)) path to existing scenario/parameter file to inherit from.
- `cifmw_configure_switches`: (Bool) Specifies whether switches should be configured. Computes in `reproducer.yml` playbook. Defaults to `false`.
- `cifmw_crc_default_network`: (String) name of the untagged network used to address DNS on the crc node. Default is `default`.

```{admonition} Words of caution
:class: danger
Expand Down
17 changes: 8 additions & 9 deletions playbooks/06-deploy-architecture.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,14 @@
{{ lookup('file', _ssh_file ~ '.pub', rstrip=False)}}
cifmw_ci_gen_kustomize_values_migration_priv_key: >-
{{ lookup('file', _ssh_file, rstrip=False) }}
cifmw_ci_gen_kustomize_values_sshd_ranges: >-
{{
[cifmw_networking_env_definition.networks.ctlplane.network_v4] +
(
[
_ipv4_network_data.network + '/' + _ipv4_network_data.prefix
]
) if (_ipv4_network_data | length > 0) else []
}}
# jgilaber: the previous way of collecting the
# sshd ranges sometimes did not work well in vexxhost, if
# the controller node ends-up in a different subnet than the
# executor node, then the executor would be prevented from
# accessing the compute nodes after the edpm deployment, which
# would cause post_failures when trying to collect logs
cifmw_ci_gen_kustomize_values_sshd_ranges:
- 0.0.0.0/0
rescue:
- name: Debug _ctl_data
ansible.builtin.debug:
Expand Down
Loading