forked from openstack-k8s-operators/ci-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy-osp-adoption.yml
105 lines (94 loc) · 3.61 KB
/
deploy-osp-adoption.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
---
# 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
}}
_target_host: "{{ cifmw_target_host | default('localhost') }}"
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: "{{ _target_host }}"
- name: Load source adoption scenario
ansible.builtin.include_vars:
file: "{{ _adoption_source_scenario_file }}"
name: cifmw_adoption_osp_deploy_scenario
- 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: "{{ _target_host }}"
ansible.builtin.find:
paths: "{{ ansible_user_dir }}/ci-framework-data/reproducer-inventory/"
file_type: file
patterns: '*.yml,*.yaml'
register: "_all_groups"
- name: Read groups inventory
delegate_to: "{{ _target_host }}"
ansible.builtin.slurp:
path: "{{ item.path }}"
register: _reproducer_inventory_files
loop: "{{ _all_groups.files }}"
- name: Set groups fact
when: "'all' != _group_name"
vars:
_content: "{{ _inventory_file.content | b64decode | from_yaml }}"
_group_name: "{{ _content | list | first }}"
_nodes: "{{ _content[_group_name]['hosts'].keys() }}"
_group_nodes: >-
{%- set group = {} -%}
{%- set _ = group.update({_group_name: _nodes}) -%}
{{ group }}
ansible.builtin.set_fact:
_vm_groups: >-
{{ _vm_groups | default({}) | combine(_group_nodes) }}
loop: "{{ _reproducer_inventory_files.results }}"
loop_control:
loop_var: "_inventory_file"
- name: Gather ansible_user_id from playbook target for hooks
ansible.builtin.setup:
gather_subset:
- user_id
- user_dir
- name: Ensure parameters folder exists
ansible.builtin.file:
path: "{{ cifmw_basedir }}/artifacts/parameters"
state: "directory"
- name: Save variables for use with hooks
vars:
_content:
cifmw_adoption_osp_deploy_ntp_server: "{{ cifmw_adoption_osp_deploy_ntp_server }}"
cifmw_adoption_source_scenario_path: "{{ cifmw_adoption_source_scenario_path }}"
cifmw_adoption_osp_deploy_scenario: "{{ cifmw_adoption_osp_deploy_scenario }}"
_vm_groups: "{{ _vm_groups }}"
ansible.builtin.copy:
dest: "{{ cifmw_basedir }}/artifacts/parameters/adoption_osp.yml"
content: "{{ _content | to_nice_yaml }}"
- name: Set inventory_file for localhost to use with hooks
ansible.builtin.set_fact:
inventory_file: "{{ hostvars[_target_host]['inventory_file'] }}"
- name: Deploy source osp environment
ansible.builtin.import_role:
name: "adoption_osp_deploy"