Skip to content

Commit

Permalink
[POC] Add role to deploy 17.1 env for adoption
Browse files Browse the repository at this point in the history
  • Loading branch information
cescgina committed Sep 17, 2024
1 parent 15f7512 commit bfc7d98
Show file tree
Hide file tree
Showing 18 changed files with 1,331 additions and 0 deletions.
93 changes: 93 additions & 0 deletions deploy-osp-adoption.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
---
# 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: Parent scenario if needed
hosts: "{{ cifmw_target_host | default('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.import_role:
name: networking_mapper
tasks_from: load_env_definition.yml

- name: Load source adoption scenario
ansible.builtin.include_vars:
file: "{{ _adoption_source_scenario_file }}"
name: _adoption_source_scenario

- name: Read inventory groups
ansible.builtin.slurp:
path: "/home/zuul/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
vars:
_group_name: "{{ item.key[:-1] }}"
_path_inventories: "/home/zuul/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
delegate_to: "localhost"
ansible.builtin.file:
path: "{{ cifmw_basedir }}/artifacts/parameters"
state: "directory"

- name: Save variables for use with hooks
delegate_to: "localhost"
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) }}
- name: Deploy source osp environment
ansible.builtin.import_role:
name: "adoption_osp_deploy"
114 changes: 114 additions & 0 deletions hooks/playbooks/adoption_deploy_ceph.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
---
# 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 -vvv {{ playbook_dir }}/../../playbooks/ceph.yml
-i {{ vms_inventory }} --tags block -e cifmw_num_osds_perhost=1
-e cifmw_ceph_target=osp-computes
- 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: "/home/zuul/{{ _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: "/home/zuul/{{ _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: "/home/zuul/{{ _ceph_osd_spec_file_name }}"
_cloud_domain: "{{ _adoption_source_scenario.cloud_domain }}"
_source_cmd: "source /home/zuul/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 /home/zuul/config-download.yaml
--tld {{ _cloud_domain }}
--osd-spec {{ _ceph_osd_spec_file_dest }}
--roles-data {{ _roles_file_dest }}
-o 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: Deploy ceph
delegate_to: "osp-undercloud-0"
vars:
_ceph_deploy_cmd: >-
openstack openstack 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 deployed_ceph.yaml
cifmw.general.ci_script:
chdir: "{{ ansible_user_dir }}"
output_dir: "{{ cifmw_basedir }}/artifacts"
script: "{{ _source_cmd }}; {{ _ceph_deploy_cmd }}"
33 changes: 33 additions & 0 deletions roles/adoption_osp_deploy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 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`
`adoption_osp_deploy`
* `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
20 changes: 20 additions & 0 deletions roles/adoption_osp_deploy/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
# 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"
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: []
21 changes: 21 additions & 0 deletions roles/adoption_osp_deploy/molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# 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: Converge
hosts: all
roles:
- role: "adoption_osp_deploy"
11 changes: 11 additions & 0 deletions roles/adoption_osp_deploy/molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# Mainly used to override the defaults set in .config/molecule/
# By default, it uses the "config_podman.yml" - in CI, it will use
# "config_local.yml".
log: true

provisioner:
name: ansible
log: true
env:
ANSIBLE_STDOUT_CALLBACK: yaml
21 changes: 21 additions & 0 deletions roles/adoption_osp_deploy/molecule/default/prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# 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: Prepare
hosts: all
roles:
- role: test_deps
Loading

0 comments on commit bfc7d98

Please sign in to comment.