-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[POC] Add role to deploy 17.1 env for adoption
- Loading branch information
Showing
15 changed files
with
759 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--- | ||
# 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: Deploy source osp environment | ||
ansible.builtin.import_role: | ||
name: "adoption_osp_deploy" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# adoption_osp_deploy | ||
|
||
Deploy OSP 17.1 environment for adoption based on DTs. | ||
|
||
## Privilege escalation | ||
None | ||
|
||
## Parameters | ||
* `adoption_osp_deploy_ntp_server`: (String) NTP server to use in the 17.1 | ||
deployment. Defaults to `pool.ntp.org` | ||
|
||
## Examples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
# 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
--- | ||
# 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: Debug | ||
ansible.builtin.debug: | ||
msg: "{{ _adoption_source_scenario }}" | ||
|
||
- name: Load scenario config-download | ||
vars: | ||
_config_download_path: >- | ||
{{ | ||
[cifmw_adoption_source_scenario_path, | ||
_adoption_source_scenario.overcloud.config_download_file | ||
] | path_join | ||
}} | ||
ansible.builtin.slurp: | ||
path: "{{ _config_download_path }}" | ||
register: _original_config_download | ||
delegate_to: "localhost" | ||
|
||
- name: Generate config download file | ||
vars: | ||
_config_download: > | ||
{{ | ||
_original_config_download['content'] | | ||
b64decode | from_yaml | ||
}} | ||
_new_config_download_fields: {} | ||
_ctlplane_net: "{{ cifmw_networking_env_definition.networks.ctlplane }}" | ||
_hostname_map_translation: >- | ||
{{ | ||
_adoption_source_scenario.hostname_groups_map | ||
}} | ||
block: | ||
- name: Gather overcloud tripleo nodes | ||
when: group.key is in _hostname_map_translation | ||
ansible.builtin.set_fact: | ||
_tripleo_nodes: >- | ||
{{ | ||
_tripleo_nodes | default([]) + | ||
group.value | ||
}} | ||
loop: "{{ _vm_groups | dict2items }}" | ||
loop_control: | ||
loop_var: group | ||
label: "{{ group.key }}" | ||
|
||
- name: Generate Hostnamemap field | ||
when: group.key is in _hostname_map_translation | ||
vars: | ||
_tripleo_name: "{{ _hostname_map_translation[group.key] }}" | ||
_group_nodes: >- | ||
{%- set hosts = {} -%} | ||
{%- for node in group.value -%} | ||
{%- set key = _tripleo_name ~ '-' ~ loop.index0 | string -%} | ||
{%- set _ = hosts.update({key: node}) -%} | ||
{%- endfor -%} | ||
{{ hosts }} | ||
ansible.builtin.set_fact: | ||
_hostname_map: >- | ||
{{ | ||
_hostname_map | default({}) | | ||
combine(_group_nodes) | ||
}} | ||
loop: "{{ _vm_groups | dict2items }}" | ||
loop_control: | ||
loop_var: group | ||
label: "{{ group.key }}" | ||
|
||
- name: Generate DeployedServerPortMap field | ||
vars: | ||
_node_instance_net: "{{ cifmw_networking_env_definition.instances[node] }}" | ||
_key_name: "{{ node }}-ctlplane" | ||
_ctlplane_ip: "{{ _node_instance_net.networks.ctlplane.ip_v4 }}" | ||
_server_port: >- | ||
{%- set port = {_key_name: {}} -%} | ||
{%- set _ = port[_key_name].update({ | ||
'fixed_ips': [ | ||
{ 'ip_address': _ctlplane_ip } | ||
], | ||
'subnets': [ | ||
{'cidr': _ctlplane_net.network_v4} | ||
], | ||
'network': { | ||
'tags': [ _ctlplane_net.network_v4 ] | ||
}}) -%} | ||
{{ port }} | ||
ansible.builtin.set_fact: | ||
_deployedserverport_map: >- | ||
{{ | ||
_deployedserverport_map | default({}) | | ||
combine(_server_port, recursive=true) | ||
}} | ||
loop: "{{ _tripleo_nodes }}" | ||
loop_control: | ||
loop_var: node | ||
label: "{{ node }}" | ||
|
||
- name: Generate NodePortMap field | ||
vars: | ||
_node_instance_net: "{{ cifmw_networking_env_definition.instances[node] }}" | ||
_node_port: > | ||
{%- set nodeport = {node: {}} -%} | ||
{% for network, net_info in _node_instance_net.networks.items() %} | ||
{%- set subnet = cifmw_networking_env_definition.networks[network].network_v4 -%} | ||
{%- set _ = nodeport[node].update( | ||
{ | ||
network: { | ||
'ip_address': net_info.ip_v4, | ||
'ip_address_uri': net_info.ip_v4, | ||
'ip_subnet': subnet | ||
} | ||
} | ||
) -%} | ||
{%- endfor -%} | ||
{{ nodeport }} | ||
ansible.builtin.set_fact: | ||
_nodeport_map: >- | ||
{{ | ||
_nodeport_map | default({}) | | ||
combine(_node_port, recursive=true) | ||
}} | ||
loop: "{{ _tripleo_nodes }}" | ||
loop_control: | ||
loop_var: node | ||
label: "{{ node }}" | ||
|
||
- name: Generate CtlplaneNetworkAttributes field | ||
vars: | ||
_cloud_domain: "{{ _adoption_source_scenario.cloud_domain }}" | ||
_dns_server: >- | ||
{{ | ||
(_ctlplane_net.dns_v4 | length > 0) | | ||
ternary(_ctlplane_net.dns_v4, _ctlplane_net.gw_v4) | ||
}} | ||
ansible.builtin.set_fact: | ||
_ctlplanenet_attributes: | ||
network: | ||
dns_domain: "{{ _cloud_domain }}" | ||
mtu: "{{ _ctlplane_net.mtu }}" | ||
subnets: | ||
ctlplane-subnet: | ||
dns_nameservers: "{{ _dns_server }}" | ||
gateway_ip: "{{ _ctlplane_net.gw_v4 }}" | ||
|
||
- name: Create new config download file | ||
vars: | ||
_new_config_download_fields: | ||
parameter_defaults: | ||
HostnameMap: "{{ _hostname_map }}" | ||
DeployedServerPortMap: "{{ _deployedserverport_map }}" | ||
NodePortMap: "{{ _nodeport_map }}" | ||
CtlplaneNetworkAttributes: "{{ _ctlplanenet_attributes }}" | ||
ansible.builtin.copy: | ||
dest: "/home/zuul/config-download.yaml" | ||
content: "{{ _config_download | combine(_new_config_download_fields, recursive=true) | to_nice_yaml(indent=2, sort_keys=false) }}" | ||
delegate_to: "osp-undercloud-0" |
Oops, something went wrong.