-
Notifications
You must be signed in to change notification settings - Fork 16
/
scale_compute_vms.yml
129 lines (107 loc) · 4.5 KB
/
scale_compute_vms.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
- hosts: localhost
gather_facts: yes
tasks:
- name: generate local_hosts inventory file needed for infrared virsh pre playbook
template:
dest: "{{ infrared_workspaces_dir }}/active/local_hosts"
src: inventory.j2
- name: set controller nodes
set_fact:
controller_nodes: "{{ controller_nodes|default([]) + [(oc_instackenv_content.nodes[item | int]|combine({'name': 'controller-'+item}))] }}"
with_sequence: 0-{{ controller_count-1 }}
- name: set hypervisor nodes for compute VMs
set_fact:
hypervisor_nodes: "{{ oc_instackenv_content.nodes[controller_count:] }}"
- name: set overcloud_instackenv content to controller nodes
set_fact:
oc_instackenv_content: "{{ {} | combine({'nodes': controller_nodes}, recursive=True) }}"
- name: create overcloud_instackenv.json file
copy:
dest: "{{ overcloud_instackenv_path }}"
content: "{{ oc_instackenv_content }}"
- name: get hypervisor hosts
shell: |
echo "{{ hypervisor_nodes[item | int].pm_addr | replace('mgmt-','') | replace('-drac', '') }}"
with_sequence: 0-{{ (hypervisor_nodes|length - 1) }}
register: host_list
- name: hostname list
set_fact:
hostname_list: "{{ hostname_list|default([]) + [item.stdout] }}"
with_items: "{{ host_list.results }}"
- include_tasks: tasks/get_interpreter.yml
vars:
hostname: "{{ hostname_list[0] }}"
user: "root"
- name: add hypervisors to inventory file
add_host:
name: "{{ hyp }}"
groups: "hypervisor"
ansible_host: "{{ hyp }}"
ansible_ssh_private_key_file: "{{ ansible_ssh_key }}"
ansible_user: "root"
ansible_python_interpreter: "{{ python_interpreter }}"
with_items: "{{ hostname_list }}"
loop_control:
loop_var: hyp
- name: set rhel 7 interfaces for hypervisors
vars:
lab_vars: "{{ (lab_name == 'scale') | ternary(scale, alias) }}"
set_fact:
hyp_ifaces: "{{ lab_vars['machine_types'][vendor][machine_type]['rhel8_interfaces'] }}"
- hosts: hypervisor
tasks:
- name: Clean network interfaces
shell: |
/root/clean-interfaces.sh --nuke
changed_when: false
- name: install packages
package:
name: "{{ item }}"
state: installed
loop: ['gcc', 'libffi-devel', 'openssl-devel', 'python3-virtualenv', 'libvirt', 'qemu-kvm']
- name: start libvirtd
systemd:
state: started
name: libvirtd
# workaround for infrared issue https://github.com/redhat-openstack/infrared/issues/396
- name: create network script file for interfaces
vars:
hyp_ifaces: "{{ hostvars['localhost']['hyp_ifaces'] }}"
shell: |
touch /etc/sysconfig/network-scripts/ifcfg-{{ hyp_ifaces[0] }}
touch /etc/sysconfig/network-scripts/ifcfg-{{ hyp_ifaces[1] }}
touch /etc/sysconfig/network-scripts/ifcfg-{{ hyp_ifaces[2] }}
touch /etc/sysconfig/network-scripts/ifcfg-{{ hyp_ifaces[3] }}
- hosts: localhost
vars:
topology_network_path: "{{ ansible_user_dir }}/4_nets_multi_hypervisor.yml"
tasks:
- name: remove existing inmemory inventory especially hypervisor
meta: refresh_inventory
- name: create topology network file
vars:
isolated_interface: "{{ hyp_ifaces[0] }}"
ctlplane_interface: "{{ hyp_ifaces[1] }}"
tenant_interface: "{{ hyp_ifaces[2] }}"
external_interface: "{{ hyp_ifaces[3] }}"
template:
src: 4_nets_multi_hypervisor.yml.j2
dest: "{{ topology_network_path }}"
- name: prepare host address variable
set_fact:
host_address: "--host-address {{ hostname_list | join(' --host-address ') }}"
- name: run virsh for multi hypervisor
shell: |
source .venv/bin/activate
infrared virsh {{ host_address }} --host-key {{ ansible_ssh_key }} --topology-nodes compute:{{ compute_count|default(1) }} --topology-network {{ topology_network_path }} --host-memory-overcommit True > {{ log_directory }}/virsh.log 2>&1
args:
chdir: "{{ infrared_dir }}"
- name: reload inventory content created by virsh command
meta: refresh_inventory
- name: hybrid deployment params
set_fact:
hybrid_params: " --specific-node-ids true --hybrid {{ overcloud_instackenv_path }} --vbmc-host hypervisor"
- name: set deployment_timeout to 2400
set_fact:
deployment_timeout: 2400
- import_playbook: add_undercloud_to_inventory.yml