commit | author | age
|
1d2130
|
1 |
--- |
S |
2 |
- name: Step 00xxxxx software |
3c6889
|
3 |
hosts: bastions |
GC |
4 |
gather_facts: false |
1d2130
|
5 |
become: false |
S |
6 |
tasks: |
3c6889
|
7 |
- when: install_ocp4 | bool |
GC |
8 |
block: |
|
9 |
- name: Get awscli bundle |
|
10 |
get_url: |
|
11 |
url: https://s3.amazonaws.com/aws-cli/awscli-bundle.zip |
|
12 |
dest: /tmp/awscli-bundle.zip |
1d2130
|
13 |
|
3c6889
|
14 |
- name: Unzip awscli-bundle.zip |
GC |
15 |
unarchive: |
|
16 |
src: /tmp/awscli-bundle.zip |
|
17 |
dest: /tmp/ |
|
18 |
remote_src: yes |
|
19 |
|
|
20 |
- name: Install awscli |
|
21 |
command: /tmp/awscli-bundle/install -i /usr/local/aws -b /bin/aws |
|
22 |
args: |
|
23 |
creates: /usr/local/aws |
|
24 |
become: yes |
|
25 |
|
|
26 |
- name: cleanup archive and tmp files |
|
27 |
file: |
|
28 |
path: "{{ item }}" |
|
29 |
state: absent |
|
30 |
loop: |
|
31 |
- /tmp/awscli-bundle |
|
32 |
- /tmp/awscli-bundle.zip |
|
33 |
|
|
34 |
- name: Create .aws directory |
|
35 |
file: |
|
36 |
path: ~/.aws |
|
37 |
state: directory |
|
38 |
|
|
39 |
- name: Add aws credentials |
|
40 |
blockinfile: |
|
41 |
path: ~/.aws/credentials |
|
42 |
block: |- |
|
43 |
[default] |
53992b
|
44 |
aws_access_key_id = {{ hostvars.localhost.student_access_key_id }} |
GC |
45 |
aws_secret_access_key = {{ hostvars.localhost.student_secret_access_key }} |
3c6889
|
46 |
|
GC |
47 |
- hosts: localhost |
|
48 |
|
|
49 |
- name: Install Packages |
|
50 |
become: yes |
|
51 |
package: |
|
52 |
name: |
|
53 |
- golang |
|
54 |
- python2-boto3 |
|
55 |
- unzip |
|
56 |
|
|
57 |
- name: Get OS (var) |
|
58 |
shell: "/usr/bin/go env GOOS" |
|
59 |
register: GOOS_VAR |
|
60 |
|
|
61 |
- name: Get Arch (var) |
|
62 |
shell: "/usr/bin/go env GOARCH" |
|
63 |
register: GOARCH_VAR |
|
64 |
|
|
65 |
- name: Make sure directory /usr/local/bin exists |
|
66 |
become: yes |
|
67 |
file: |
|
68 |
path: /usr/local/bin |
|
69 |
state: directory |
|
70 |
|
|
71 |
- name: Get the OpenShift Installer |
|
72 |
become: yes |
|
73 |
get_url: |
|
74 |
url: "https://github.com/openshift/installer/releases/download/{{ ocp4_installer_version }}/openshift-install-{{ GOOS_VAR.stdout }}-{{ GOARCH_VAR.stdout }}" |
|
75 |
dest: /usr/local/bin/openshift-install |
|
76 |
mode: 0775 |
|
77 |
owner: root |
|
78 |
group: root |
|
79 |
|
|
80 |
- name: Get the OpenShift CLI |
|
81 |
become: yes |
|
82 |
unarchive: |
|
83 |
src: "https://mirror.openshift.com/pub/openshift-v3/clients/{{ oc_client_version }}/linux/oc.tar.gz" |
|
84 |
remote_src: yes |
|
85 |
dest: /usr/local/bin |
|
86 |
mode: 0775 |
|
87 |
owner: root |
|
88 |
group: root |
|
89 |
|
|
90 |
- name: Generate SSH keys |
|
91 |
shell: ssh-keygen -b 2048 -t rsa -f ~/.ssh/id_rsa -q -N "" |
|
92 |
args: |
|
93 |
creates: ~/.ssh/id_rsa |
|
94 |
|
|
95 |
- name: Generate SSH pub key |
|
96 |
shell: ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub |
|
97 |
args: |
|
98 |
creates: ~/.ssh/id_rsa.pub |
|
99 |
|
41fa25
|
100 |
- name: Slurp public key |
GC |
101 |
slurp: |
|
102 |
path: /home/{{ ansible_user }}/.ssh/id_rsa.pub |
|
103 |
register: idrsapub |
|
104 |
|
|
105 |
- name: Create cluster directory |
|
106 |
file: |
|
107 |
path: /home/{{ ansible_user }}/cluster-{{ guid }} |
|
108 |
state: directory |
|
109 |
|
2fa6d3
|
110 |
- stat: |
GC |
111 |
path: files/install-config.yaml.{{ ocp4_installer_version }}.j2 |
|
112 |
register: rconfig |
|
113 |
delegate_to: localhost |
|
114 |
|
|
115 |
- name: Use version-specific template for install-config-yaml |
|
116 |
set_fact: |
|
117 |
install_config_template_path: files/install-config.yaml.{{ ocp4_installer_version }}.j2 |
|
118 |
when: rconfig.stat.exists |
|
119 |
|
|
120 |
- name: Use default template for install-config-yaml |
|
121 |
set_fact: |
|
122 |
install_config_template_path: files/install-config.yaml.j2 |
|
123 |
when: not rconfig.stat.exists |
|
124 |
|
ddb412
|
125 |
- name: Generate config install-config.yaml |
41fa25
|
126 |
template: |
2fa6d3
|
127 |
src: "{{ install_config_template_path }}" |
ddb412
|
128 |
dest: /home/{{ ansible_user }}/cluster-{{ guid }}/install-config.yaml |
41fa25
|
129 |
|
GC |
130 |
- name: Run the installer |
|
131 |
command: openshift-install create cluster --dir=/home/{{ ansible_user }}/cluster-{{ guid }}/ |
6c3e38
|
132 |
|
GC |
133 |
- name: Fetch kube config |
|
134 |
fetch: |
|
135 |
flat: yes |
41fa25
|
136 |
src: /home/{{ ansible_user }}/cluster-{{ guid }}/auth/{{ item }} |
6c3e38
|
137 |
dest: "{{ hostvars.localhost.output_dir }}/{{ env_type }}_{{ guid }}_{{ item }}" |
GC |
138 |
loop: |
|
139 |
- kubeconfig |
|
140 |
- kubeadmin-password |
|
141 |
|
|
142 |
- name: Get kubeadmin password |
|
143 |
slurp: |
41fa25
|
144 |
path: /home/{{ ansible_user }}/cluster-{{ guid }}/auth/kubeadmin-password |
6c3e38
|
145 |
register: kubeadminr |
GC |
146 |
|
|
147 |
- name: Get console route |
|
148 |
environment: |
41fa25
|
149 |
KUBECONFIG: /home/{{ ansible_user }}/cluster-{{ guid }}/auth/kubeconfig |
6c3e38
|
150 |
command: oc get route -n openshift-console console -o json |
GC |
151 |
register: routeconsole |
6d23a2
|
152 |
retries: 5 |
GC |
153 |
delay: 30 |
|
154 |
until: routeconsole is succeeded |
|
155 |
ignore_errors: yes |
|
156 |
|
|
157 |
- name: Set webconsole address |
|
158 |
set_fact: |
|
159 |
webconsole: "http://{{ routeconsole.stdout | from_json | json_query('spec.host') }}" |
|
160 |
when: routeconsole is succeeded |
|
161 |
|
|
162 |
# sometimes the route is not ready, guess it |
|
163 |
- name: Guess webconsole address |
|
164 |
set_fact: |
|
165 |
webconsole: "http://console-openshift-console.apps.cluster-{{ guid }}.{{ guid }}.{{ subdomain_base }}" |
|
166 |
when: routeconsole is failed |
6c3e38
|
167 |
|
72d7f0
|
168 |
- name: Get API for command line |
GC |
169 |
environment: |
|
170 |
KUBECONFIG: /home/{{ ansible_user }}/cluster-{{ guid }}/auth/kubeconfig |
|
171 |
command: oc whoami --show-server |
|
172 |
register: showserver |
|
173 |
|
6c3e38
|
174 |
- name: Print Overview |
GC |
175 |
debug: |
|
176 |
msg: "{{ item }}" |
|
177 |
with_items: |
|
178 |
- "user.info: Kubeadmin user / password: kubeadmin / {{ kubeadminr.content | b64decode }}" |
6d23a2
|
179 |
- "user.info: Openshift Master Console: {{ webconsole }}" |
72d7f0
|
180 |
- "user.info: Openshift API for command line 'oc' client: {{ showserver.stdout | trim }}" |
06aaa8
|
181 |
- "user.info: Download oc client from https://mirror.openshift.com/pub/openshift-v3/clients/{{ oc_client_version }}" |
53992b
|
182 |
|
c6f7e1
|
183 |
- name: Step 00xxxxx software |
GC |
184 |
hosts: localhost |
|
185 |
gather_facts: false |
|
186 |
become: false |
|
187 |
tasks: |
53992b
|
188 |
# NOT Pre-installed |
c6f7e1
|
189 |
- name: Print Student aws access as user.info |
GC |
190 |
debug: |
|
191 |
msg: "{{ item }}" |
|
192 |
with_items: |
|
193 |
- "user.info: WARNING: with great power comes great responsability. We monitor usage." |
|
194 |
- "user.info: Your AWS programatic access: {{ student_access_key_id }} / {{ student_secret_access_key }}" |
|
195 |
when: |
|
196 |
- not install_ocp4 | bool |
|
197 |
- student_access_key_id is defined |
|
198 |
- student_secret_access_key is defined |