Skip to content

Commit

Permalink
Add role to deploy 17.1 env for adoption
Browse files Browse the repository at this point in the history
Add a new role that will deploy a tripleo environment that will serve as
source for adoption. This role is expected to cosume the infra created
by [1], and a 17.1 scenario definition from the data-plane-adoption
repo, introduced by [2].

It also introduce a small fix to the deploy-ocp.yml so the resulting ocp
cluster is ready (the nodes needed to be uncordoned).

[1] #2285
[2] openstack-k8s-operators/data-plane-adoption#597
  • Loading branch information
cescgina committed Sep 30, 2024
1 parent 4cad2d3 commit c7b98d7
Show file tree
Hide file tree
Showing 17 changed files with 1,423 additions and 3 deletions.
18 changes: 18 additions & 0 deletions deploy-ocp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,21 @@
ansible.builtin.import_role:
name: "libvirt_manager"
tasks_from: "deploy_layout.yml"

# Run from the hypervisor
- name: Ensure OCP cluster is stable
vars:
_auth_path: >-
{{
(
cifmw_devscripts_repo_dir,
'ocp',
cifmw_devscripts_config.cluster_name,
'auth'
) | ansible.builtin.path_join
}}
cifmw_openshift_adm_op: "stable"
cifmw_openshift_kubeconfig: >-
{{ (_auth_path, 'kubeconfig') | ansible.builtin.path_join }}
ansible.builtin.include_role:
name: openshift_adm
98 changes: 98 additions & 0 deletions deploy-osp-adoption.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
---
# 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:
_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: Read inventory groups
delegate_to: "{{ cifmw_target_host }}"
ansible.builtin.slurp:
path: "{{ cifmw_basedir }}/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: "{{ cifmw_basedir }}/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) }}
_inventory_sources:
{{ ansible_inventory_sources | to_nice_yaml(indent=2) | indent(width=2) }}
- name: Deploy source osp environment
ansible.builtin.import_role:
name: "adoption_osp_deploy"
148 changes: 148 additions & 0 deletions hooks/playbooks/adoption_deploy_ceph.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
---
# 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: Create block devices on compute nodes using ceph playbook
ansible.builtin.command:
cmd: >-
ansible-playbook -vvvv {{ playbook_dir }}/../../playbooks/ceph.yml
-i {{ _inventory_sources | join(' -i ') }} --tags block -e cifmw_num_osds_perhost=1
-e cifmw_ceph_target=osp-computes
- 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 }}"
34 changes: 34 additions & 0 deletions roles/adoption_osp_deploy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 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_skip_stages`: (String or List) Stages to skip
deploying. Can be `undercloud` or `overcloud`.
* `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
27 changes: 27 additions & 0 deletions roles/adoption_osp_deploy/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -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
30 changes: 30 additions & 0 deletions roles/adoption_osp_deploy/meta/main.yml
Original file line number Diff line number Diff line change
@@ -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: []
Loading

0 comments on commit c7b98d7

Please sign in to comment.