forked from lxin-git/ocp4-vsphere-automation-airgap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tower_start.yml
98 lines (89 loc) · 3.21 KB
/
tower_start.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
---
- hosts: localhost
gather_facts: False
tasks:
- name: Generate var file to landing extra vars
copy:
content: "{{ ocpconfig | to_nice_yaml }}"
dest: "current_ocpconfig.yml"
- name: Loading current ocpconfig var file
include_vars: current_ocpconfig.yml
- name: Prepare helper vars-static var file
template:
src: vars-static.j2
dest: "{{ playbook_dir }}/vars-static.yml"
mode: 0644
force: yes
- name: Create VM for bastion host
import_role:
name: bastion
tasks_from: create_vm_bastion
- name: Add host to group [bastion]
add_host:
name: "{{ helper_vm.public_ip }}"
groups: bastion
ansible_ssh_user: "root"
ansible_ssh_pass: "{{ helper_vm.rootpassword }}"
host_key_checking: False
ansible_ssh_common_args: '-o StrictHostKeyChecking=no'
- name: Add host to group [webservers]
add_host:
name: "{{ helper_vm.public_ip }}"
groups: webservers
ansible_ssh_user: "root"
ansible_ssh_pass: "{{ helper_vm.rootpassword }}"
host_key_checking: False
ansible_ssh_common_args: '-o StrictHostKeyChecking=no'
- hosts: bastion
gather_facts: True
vars_files:
- roles/helper/vars/main.yml
environment:
PATH: "{{ ocpconfig.helper_vm.workdir }}/bin:{{ ansible_env.PATH }}"
GOVC_USERNAME: "{{ ocpconfig.vcenter.admin_username }}"
GOVC_PASSWORD: "{{ ocpconfig.vcenter.admin_password }}"
GOVC_URL: "https://{{ ocpconfig.vcenter.ip }}"
GOVC_INSECURE: 1
handlers:
- import_tasks: roles/helper/handlers/main.yml
tasks:
- name: Loading current ocpconfig var file to bastion node
include_vars: current_ocpconfig.yml
- name: include vars-static
include_vars: vars-static.yml
- name: validate hostnames
import_tasks: roles/helper/tasks/validate_host_names.yml
- name: Start helper function setup
import_role:
name: helper
- name: Set the cache of all the download links
include_role:
name: cache
when: restricted_network|default(False) == False
- name: Set the ocp_major_version facts, which will be used to identify ova/iso approach
set_fact:
ocp_major_version: "{{ download.clients_url | regex_search('openshift-v4/clients/ocp/(.+)', '\\1') | first |regex_replace('\\.[^.]+$') }}"
- name: Create local automation directory
file:
path: "{{ helper_vm.workdir }}"
state: directory
mode: '0755'
- name: Run all the common tasks
import_role:
name: common
- name: Run the vmware role to setup vCenter folder
import_role:
name: vmware
# If version <= V4.5, we will use ISO to launch VMs
- name: Run steps specific to static ip and the use of ISO files
import_role:
name: static_ips
when: ocp_major_version in ["4.3","4.4","4.5"]
# If version is V4.6+, we have to use OVA to launch VMs
- name: Run steps specific to static ip and the use of an OVA file
import_role:
name: static_ips_ova
when: ocp_major_version not in ["4.3","4.4","4.5"]
- name: Performing the postinstall check action
import_role:
name: postinstall