forked from redhat-partner-solutions/crucible
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7374f73
commit 7e9af72
Showing
16 changed files
with
199 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
- name: Monitor install process via assisted installer | ||
hosts: bastion | ||
gather_facts: False | ||
roles: | ||
- monitor_assisted_installer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
- name: Monitor install process | ||
hosts: bastion | ||
gather_facts: False | ||
roles: | ||
- monitor_assisted_installer | ||
- monitor_kubeapi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
- name: Monitor install process via the oc command | ||
hosts: bastion | ||
gather_facts: False | ||
roles: | ||
- monitor_kubeapi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
generated_dir: "{{ repo_root_path }}/generated" | ||
cluster_manifest_parent_dir: "{{ generated_dir}}/{{ cluster_name }}" | ||
cluster_manifest_parent_dir: "{{ generated_dir}}/{{ cluster_name }}" | ||
download_agent_dest_file: "{{ cluster_name }}/agent.iso" | ||
download_dest_path: "{{ iso_download_dest_path | default('/opt/http_store/data') }}" | ||
billi_executable: "{{ repo_root_path }}/../billi" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
roles/generate_manifests/templates/cluster-image-set.yaml.j2-working
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: hive.openshift.io/v1 | ||
kind: ClusterImageSet | ||
metadata: | ||
name: openshift-{{ openshift_version }} | ||
spec: | ||
releaseImage: {{ (release_images_defaults |json_query(version_filter))[0].url }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
generated_dir: "{{ repo_root_path }}/generated" | ||
cluster_manifest_parent_dir: "{{ generated_dir}}/{{ cluster_name }}" | ||
assisted_installer_ip_regex: "SERVICE_BASE_URL.*http://(((1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\\.){3}(1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])):8090" | ||
|
||
kube_filename: "{{ kubeconfig_dest_filename | default(cluster_name + '-kubeconfig') }}" | ||
dest_dir: "{{ kubeconfig_dest_dir | default(ansible_env.HOME) }}" | ||
kubeconfig_path: "{{ dest_dir }}/{{ kube_filename }}" | ||
kubeadmin_vault_name: "{{ kubeadmin_dest_filename | default(cluster_name +'-kubeadmin.vault.yml') }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
- name: Load state data | ||
set_fact: | ||
assisted_installer_ip: "{{ (lookup('file', cluster_manifest_parent_dir + '/.openshift_install_state.json') | string | regex_search(assisted_installer_ip_regex, '\\1')| list)[0] }}" | ||
|
||
- name: Distribute assisted_installer_ip | ||
vars: | ||
assisted_installer_ip_reference: "{{ assisted_installer_ip }}" | ||
set_fact: | ||
assisted_installer_ip: "{{ assisted_installer_ip_reference }}" | ||
loop: "{{ groups['nodes'] }}" | ||
delegate_to: "{{ item }}" | ||
delegate_facts: True | ||
|
||
- name: Wait for up to 30 minutes for the assisted installer to come online | ||
uri: | ||
url: "http://{{ assisted_installer_ip }}:8090/api/assisted-install/v2/openshift-versions" | ||
method: GET | ||
status_code: [200] | ||
register: versions_reply | ||
until: versions_reply is succeeded | ||
retries: 60 | ||
delay: 30 | ||
|
||
- name: Fail if resturned version is incorrect as something has gone wrong | ||
fail: | ||
msg: "Something went wrong with the version incorrect" | ||
when: | ||
- openshift_version not in (versions_reply.json.keys() | list) | ||
- openshift_full_version != versions_reply.json[openshift_version].display_name | ||
|
||
- name: Wait for up to 30 minutes for cluster definition | ||
uri: | ||
url: "http://{{ assisted_installer_ip }}:8090/api/assisted-install/v2/clusters" | ||
method: GET | ||
status_code: [200, 201] | ||
register: cluster_reply | ||
until: cluster_reply.json | length > 0 | ||
retries: 60 | ||
delay: 30 | ||
|
||
- name: Fail if more than one cluster | ||
fail: | ||
msg: more than one cluster defined | ||
when: cluster_reply.json | length > 1 | ||
|
||
- name: Get cluster_id | ||
set_fact: | ||
cluster_id: "{{ cluster_reply.json[0].id }}" | ||
|
||
- name: Set number_of_nodes | ||
set_fact: | ||
number_of_nodes: "{{ (groups['masters'] + (groups['workers'] | default([]))) | length | int }}" | ||
|
||
- name: Allow up to 20 minutes for all hosts to be discovered | ||
uri: | ||
url: "http://{{ assisted_installer_ip }}:8090/api/assisted-install/v2/clusters/{{ cluster_id }}/hosts" | ||
method: GET | ||
status_code: [200, 201] | ||
return_content: True | ||
register: cluster | ||
until: ((cluster.json | default([])) | list | length | int) == (number_of_nodes | int) | ||
retries: 30 | ||
delay: 60 | ||
|
||
- name: Wait up to an hour to get the credentials | ||
uri: | ||
url: "http://{{ assisted_installer_ip }}:8090/api/assisted-install/v2/clusters/{{ cluster_id }}//downloads/credentials?file_name=kubeadmin-password" | ||
return_content: yes | ||
status_code: [200, 201] | ||
register: kubeadmin_password_reply | ||
until: kubeadmin_password_reply is succeeded | ||
retries: 60 | ||
delay: 60 | ||
|
||
- name: Vault content | ||
set_fact: | ||
vault_content: | ||
password: "{{ kubeadmin_password_reply.content | quote }}" | ||
|
||
- name: Save kubeadmin_password to file | ||
copy: | ||
content: "{{ vault_content | to_nice_json }}" | ||
dest: "{{ dest_dir }}/{{ kubeadmin_vault_name }}" | ||
mode: 0600 | ||
|
||
- name: Save credentials to vault | ||
shell: | ||
cmd: "ansible-vault encrypt --vault-password-file {{ kubeadmin_vault_password_file_path }} {{ dest_dir }}/{{ kubeadmin_vault_name }}" | ||
when: (kubeadmin_vault_password_file_path is defined) and (kubeadmin_vault_password_file_path is file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
generated_dir: "{{ repo_root_path }}/generated" | ||
cluster_manifest_parent_dir: "{{ generated_dir}}/{{ cluster_name }}" | ||
assisted_installer_ip_regex: "SERVICE_BASE_URL.*http://(((1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\\.){3}(1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])):8090" | ||
|
||
kube_filename: "{{ kubeconfig_dest_filename | default(cluster_name + '-kubeconfig') }}" | ||
dest_dir: "{{ kubeconfig_dest_dir | default(ansible_env.HOME) }}" | ||
kubeconfig_path: "{{ dest_dir }}/{{ kube_filename }}" | ||
kubeadmin_vault_name: "{{ kubeadmin_dest_filename | default(cluster_name +'-kubeadmin.vault.yml') }}" | ||
kubeadmin_vault_path: "{{ dest_dir }}/{{ kubeadmin_vault_name }}" | ||
kubeadmin_password: "{{ (lookup('file', kubeadmin_vault_path) | from_json).password }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
- name: Wait for cluster to come up | ||
wait_for: | ||
host: "{{ api_vip }}" | ||
port: 6443 | ||
timeout: 3600 | ||
sleep: 60 | ||
|
||
- name: oc stuff | ||
environment: | ||
KUBECONFIG: "{{ cluster_manifest_parent_dir }}/auth/kubeconfig" | ||
block: | ||
- name: Wait for up to 30 mins to login as kubeadmin | ||
shell: | ||
cmd: "oc login --insecure-skip-tls-verify=true -u kubeadmin -p '{{ kubeadmin_password }}'" | ||
register: login_result | ||
until: ('Login successful.' in login_result.stdout) | ||
retries: 60 | ||
delay: 30 | ||
|
||
- name: Check status of cluster operators | ||
block: | ||
- name: Wait up to 20 mins for cluster to become functional | ||
shell: | ||
cmd: oc wait clusteroperators --all --for=condition=Available --timeout=20m | ||
rescue: | ||
- name: Get better info for failure message | ||
shell: oc get clusteroperators | ||
register: co_result | ||
|
||
- fail: # noqa unnamed-task | ||
msg: | | ||
Cluster has not come up correctly: | ||
{{ co_result.stdout }} | ||
- name: Get clusterversion after login | ||
vars: | ||
expected_message: "Cluster version is {{ openshift_full_version }}" | ||
shell: | ||
cmd: "oc get clusterversion" | ||
register: clusterversion | ||
until: expected_message in clusterversion.stdout | ||
retries: 60 | ||
delay: 30 |