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

Add role to deploy 17.1 env for adoption #2297

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
108 changes: 108 additions & 0 deletions deploy-osp-adoption.yml
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 2 additions & 0 deletions docs/dictionary/en-custom.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ dnsdata
dnsmasq
dockerfile
dryrun
dts
ecdsa
edecb
edploy
Expand Down Expand Up @@ -516,6 +517,7 @@ uhv
uidmap
unclaim
undefine
undercloud
unittest
unmanaged
untagged
Expand Down
141 changes: 141 additions & 0 deletions hooks/playbooks/adoption_deploy_ceph.yml
Original file line number Diff line number Diff line change
@@ -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 }}"
32 changes: 32 additions & 0 deletions roles/adoption_osp_deploy/README.md
Original file line number Diff line number Diff line change
@@ -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
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