Skip to content

Commit

Permalink
Add improvements from reviews
Browse files Browse the repository at this point in the history
Add the following improvements from reviews:
- Allow network_data.yaml to be a template
- Build inventory for ceph migration in tripleo-ansible-inventory
- Generate adoption_vars to use with the adoption_tests
- Allow users to pass an overcloud_deploy command
- Support deploying multiple stacks
- Support not passing cifmw_target_host
- Add validation to scenario input
- Add role var for the 17.1 scenario
  • Loading branch information
cescgina committed Oct 10, 2024
1 parent c47caab commit e94bf89
Show file tree
Hide file tree
Showing 17 changed files with 516 additions and 250 deletions.
25 changes: 16 additions & 9 deletions deploy-osp-adoption.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
[cifmw_adoption_source_scenario_path,
cifmw_architecture_scenario ~ '.yaml'] | path_join
}}
_target_host: "{{ cifmw_target_host | default('localhost') }}"
tasks:
- name: Inherit from parent scenarios if needed
ansible.builtin.include_tasks:
Expand All @@ -28,22 +29,22 @@
name: networking_mapper
tasks_from: load_env_definition.yml
apply:
delegate_to: "{{ cifmw_target_host | default('localhost') }}"
delegate_to: "{{ _target_host }}"

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

- name: Gather ansible_user_id from {{ cifmw_target_host }}
delegate_to: "{{ cifmw_target_host }}"
- name: Gather ansible_user_id from {{ _target_host }}
delegate_to: "{{ _target_host }}"
ansible.builtin.setup:
gather_subset:
- user_id
- user_dir

- name: Read inventory groups
delegate_to: "{{ cifmw_target_host }}"
delegate_to: "{{ _target_host }}"
ansible.builtin.slurp:
path: "{{ ansible_user_dir }}/ci-framework-data/reproducer-inventory/all-group.yml"
register: "_all_groups"
Expand All @@ -53,7 +54,7 @@
_parsed_all_groups: "{{ _all_groups['content'] | b64decode | from_yaml }}"
block:
- name: Read groups inventory
delegate_to: "{{ cifmw_target_host | default('localhost') }}"
delegate_to: "{{ _target_host }}"
vars:
_group_name: "{{ item.key[:-1] }}"
_path_inventories: "{{ ansible_user_dir }}/ci-framework-data/reproducer-inventory"
Expand Down Expand Up @@ -82,6 +83,12 @@
loop_control:
loop_var: "_inventory_file"

- name: Gather ansible_user_id from controller for hooks
ansible.builtin.setup:
gather_subset:
- user_id
- user_dir

- name: Ensure parameters folder exists
ansible.builtin.file:
path: "{{ cifmw_basedir }}/artifacts/parameters"
Expand All @@ -94,14 +101,14 @@
---
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) }}
cifmw_adoption_osp_deploy_scenario:
{{ cifmw_adoption_osp_deploy_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'] }}"
inventory_file: "{{ hostvars[_target_host]['inventory_file'] }}"

- name: Deploy source osp environment
ansible.builtin.import_role:
Expand Down
52 changes: 27 additions & 25 deletions hooks/playbooks/adoption_deploy_ceph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,51 +25,51 @@

- name: Deploy 17.1 ceph
vars:
_roles_file: >-
_cifmw_basedir_undercloud: >-
{{
[cifmw_adoption_source_scenario_path,
_adoption_source_scenario.overcloud.roles_file
[ansible_user_dir,
'ci-framework-data'
] | path_join
}}
_roles_file_name: "{{ _roles_file | basename }}"
_roles_file_dest: "{{ ansible_user_dir }}/{{ _roles_file_name }}"
_network_data_file: >-
stack: >-
{{
cifmw_adoption_osp_deploy_scenario.stacks[stack_index | int]
}}
_overcloud_name: >-
{{
stack.stackname
}}
_roles_file: >-
{{
[cifmw_adoption_source_scenario_path,
_adoption_source_scenario.overcloud.network_data_file
stack.roles_file
] | path_join
}}
_network_data_file_name: "{{ _network_data_file | basename }}"
_network_data_file_dest: "{{ ansible_user_dir }}/{{ _network_data_file_name }}"
_roles_file_dest: "{{ ansible_user_dir }}/roles_{{ _overcloud_name }}.yaml"
_network_data_file_dest: "{{ ansible_user_dir }}/network_data_{{ _overcloud_name }}.yaml"
_ceph_osd_spec_file: >-
{{
[cifmw_adoption_source_scenario_path,
_adoption_source_scenario.overcloud.ceph_osd_spec_file
stack.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 }}"
_cloud_domain: "{{ cifmw_adoption_osp_deploy_scenario.cloud_domain }}"
_source_cmd: "source {{ ansible_user_dir }}/stackrc"
block:
- name: Copy network data file
- name: Copy ceph osd file
delegate_to: "osp-undercloud-0"
ansible.builtin.copy:
src: "{{ _network_data_file }}"
dest: "{{ _network_data_file_dest }}"
src: "{{ _ceph_osd_spec_file }}"
dest: "{{ _ceph_osd_spec_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:
Expand All @@ -80,14 +80,15 @@
delegate_to: "osp-undercloud-0"
vars:
_ceph_spec_cmd: >-
openstack overcloud ceph spec {{ ansible_user_dir }}/config-download.yaml
openstack overcloud ceph spec
{{ ansible_user_dir }}/config_download_{{ _overcloud_name }}.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"
output_dir: "{{ _cifmw_basedir_undercloud }}/artifacts"
script: "{{ _source_cmd }}; {{ _ceph_spec_cmd }}"

- name: Ensure deployed_ceph file does not exist
Expand All @@ -96,12 +97,13 @@
path: "{{ ansible_user_dir }}/deployed_ceph.yaml"
state: absent

- name: Gather overcloud tripleo nodes
- name: Gather nodes for stack {{ _overcloud_name }}
when: group.key is in _hostname_map_translation
vars:
_hostname_map_translation: >-
{{
_adoption_source_scenario.hostname_groups_map
cifmw_adoption_osp_deploy_scenario.hostname_groups_map |
ansible.utils.keep_keys(target=stack.stack_nodes)
}}
ansible.builtin.set_fact:
_tripleo_nodes: >-
Expand Down Expand Up @@ -137,5 +139,5 @@
--output {{ ansible_user_dir }}/deployed_ceph.yaml
cifmw.general.ci_script:
chdir: "{{ ansible_user_dir }}"
output_dir: "{{ cifmw_basedir }}/artifacts"
output_dir: "{{ _cifmw_basedir_undercloud }}/artifacts"
script: "{{ _source_cmd }}; {{ _ceph_deploy_cmd }}"
27 changes: 26 additions & 1 deletion roles/adoption_osp_deploy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,24 @@
Deploy OSP 17.1 environment for adoption based on DTs.

## Privilege escalation
None

`become` - Required in:
- `login_registries`: For running subscription manager if needed,
install packages and podman login as root.
- `prepare_overcloud`: For setting up repositories, installing packages,
create folders in /etc and running os-net-config.
- `prepare_undercloud`: For setting up repositories, installing packages,
create folders in /etc and running os-net-config.


## 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.
* `cifmw_adoption_osp_deploy_scenario`: (Dict) Define the parameter to
configure the OSP17.1 deployment.

### Break point

Expand All @@ -30,3 +40,18 @@ and the code currently supports the following seven different stoppers:
- After deploying overcloud: `after_deploy_overcloud`

## Examples

```YAML
- name: Deploy source osp environment
vars:
cifmw_adoption_osp_deploy_scenario:
undercloud:
config:
- section: DEFAULT
option: undercloud_hostname
value: undercloud.localdomain
stacks:
name: overcloud
ansible.builtin.import_role:
name: "adoption_osp_deploy"
```
37 changes: 6 additions & 31 deletions roles/adoption_osp_deploy/tasks/config_files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,45 +14,19 @@
# License for the specific language governing permissions and limitations
# under the License.

- name: Ensure controller and undercloud vms are started and reachable
vars:
_cifmw_libvirt_manager_layout:
vms:
controllers:
start: true
disk_file_name: "dummy"
osp-underclouds:
start: true
disk_file_name: "dummy"
cifmw_libvirt_manager_all_vms: >-
{%- set vms = {} -%}
{%- for vm in _vm_groups['osp-underclouds'] -%}
{%- set _ = vms.update({vm: 'osp-underclouds'}) -%}
{%- endfor -%}
{%- for vm in _vm_groups['controllers'] -%}
{%- set _ = vms.update({vm: 'controllers'}) -%}
{%- endfor -%}
{{ vms }}
ansible_libvirt_pools: {}
ansible.builtin.include_role:
name: "libvirt_manager"
tasks_from: "start_vms.yml"
apply:
delegate_to: "{{ cifmw_target_host | default('localhost') }}"

- name: Gather ansible_user_id from undercloud
delegate_to: "osp-undercloud-0"
ansible.builtin.setup:
gather_subset:
- user_id
- user_dir

- name: Load scenario config-download
- name: Load scenario config_download
vars:
_config_download_path: >-
{{
[cifmw_adoption_source_scenario_path,
_adoption_source_scenario.overcloud.config_download_file
_stack.config_download_file
] | path_join
}}
ansible.builtin.slurp:
Expand All @@ -71,7 +45,8 @@
_ctlplane_net: "{{ cifmw_networking_env_definition.networks.ctlplane }}"
_hostname_map_translation: >-
{{
_adoption_source_scenario.hostname_groups_map
cifmw_adoption_osp_deploy_scenario.hostname_groups_map |
ansible.utils.keep_keys(target=_stack.stack_nodes)
}}
block:
- name: Gather overcloud tripleo nodes
Expand Down Expand Up @@ -171,7 +146,7 @@

- name: Generate CtlplaneNetworkAttributes field
vars:
_cloud_domain: "{{ _adoption_source_scenario.cloud_domain }}"
_cloud_domain: "{{ cifmw_adoption_osp_deploy_scenario.cloud_domain }}"
_dns_server: >-
{{
(_ctlplane_net.dns_v4 | length > 0) |
Expand All @@ -196,6 +171,6 @@
NodePortMap: "{{ _nodeport_map }}"
CtlplaneNetworkAttributes: "{{ _ctlplanenet_attributes }}"
ansible.builtin.copy:
dest: "{{ ansible_user_dir }}/config-download.yaml"
dest: "{{ ansible_user_dir }}/config_download_{{ _stack.stackname }}.yaml"
content: "{{ _config_download | combine(_new_config_download_fields, recursive=true) | to_nice_yaml(indent=2, sort_keys=false) }}"
delegate_to: "osp-undercloud-0"
56 changes: 28 additions & 28 deletions roles/adoption_osp_deploy/tasks/deploy_overcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,39 @@
# License for the specific language governing permissions and limitations
# under the License.

- name: Gather ansible_user_id from undercloud
delegate_to: "osp-undercloud-0"
ansible.builtin.setup:
gather_subset:
- user_id
- user_dir

- name: Deploy 17.1 overcloud
vars:
_roles_file: >-
_overcloud_name: >-
{{
[cifmw_adoption_source_scenario_path,
_adoption_source_scenario.overcloud.roles_file
] | path_join
_stack.stackname |
default('overcloud')
}}
_roles_file_name: "{{ _roles_file | basename }}"
_roles_file_dest: "{{ ansible_user_dir }}/{{ _roles_file_name }}"
_network_data_file: >-
_roles_file: >-
{{
[cifmw_adoption_source_scenario_path,
_adoption_source_scenario.overcloud.network_data_file
_stack.roles_file
] | path_join
}}
_network_data_file_name: "{{ _network_data_file | basename }}"
_network_data_file_dest: "{{ ansible_user_dir }}/{{ _network_data_file_name }}"
_roles_file_dest: "{{ ansible_user_dir }}/roles_{{ _overcloud_name }}.yaml"
_network_data_file_dest: "{{ ansible_user_dir }}/network_data_{{ _overcloud_name }}.yaml"
_overcloud_args: >-
{{
_adoption_source_scenario.overcloud.args | join(' ')
_stack.args | join(' ')
}}
_overcloud_vars: >-
{{
_adoption_source_scenario.overcloud.vars | join(' -e ')
}}
_overcloud_name: >-
{{
_adoption_source_scenario.overcloud.stackname |
default('overcloud')
_stack.vars | join(' -e ')
}}
_network_provision_output: "network_provision_{{ _overcloud_name }}_out.yaml"
_vips_provision_output: "vips_provision_{{ _overcloud_name }}_out.yaml"
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:
Expand All @@ -70,11 +65,16 @@
--ntp-server {{ cifmw_adoption_osp_deploy_ntp_server }}
-e {{ _overcloud_vars }}
-e {{ ansible_user_dir }}/containers-prepare-parameters.yaml
-e {{ ansible_user_dir }}/config-download.yaml
-e {{ ansible_user_dir }}/vips_provision_out.yaml
-e {{ ansible_user_dir }}/network_provision_out.yaml
-e {{ ansible_user_dir }}/config_download_{{ _overcloud_name }}.yaml
-e {{ ansible_user_dir }}/{{ _vips_provision_output }}
-e {{ ansible_user_dir }}/{{ _network_provision_output }}
_source_cmd: "source {{ ansible_user_dir }}/stackrc"
_default_overcloud_deploy_cmd: "{{ _source_cmd }}; {{ _overcloud_deploy_cmd }}"
cifmw.general.ci_script:
chdir: "{{ ansible_user_dir }}"
output_dir: "{{ cifmw_basedir }}/artifacts"
script: "{{ _source_cmd }}; {{ _overcloud_deploy_cmd }}"
output_dir: "{{ ansible_user_dir }}/ci-framework-data/artifacts"
script: >
{{
_stack.deploy_command |
default(_default_overcloud_deploy_cmd)
}}
Loading

0 comments on commit e94bf89

Please sign in to comment.