Skip to content

Commit

Permalink
fixing variables
Browse files Browse the repository at this point in the history
  • Loading branch information
hgeaydem committed Oct 18, 2021
1 parent cbc2df2 commit d0681be
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 44 deletions.
48 changes: 24 additions & 24 deletions tasks/deploy_cluster_ipi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,107 +8,107 @@
- name: Get exact OpenShift version in use
ansible.builtin.command: oc version --client=false
register: ocp_client_output
when: deploy_type == "ipi"
when: ocp4_aio_deploy_type == "ipi"

- set_fact:
ocp_client_version: "{{ ocp_client_output.stdout.split('\n')[0].split(':')[1] | trim }}"
when: deploy_type == "ipi"
when: ocp4_aio_deploy_type == "ipi"

- name: Check if OpenShift Installer binary exists
stat:
path: /root/openshift-baremetal-install
register: installer_exists
when: deploy_type == "ipi"
when: ocp4_aio_deploy_type == "ipi"

- name: Extract OpenShift Baremetal Installer for IPI
ansible.builtin.command: >
oc adm release extract --registry-config /root/pull-secret.json
--command=openshift-baremetal-install --to /root {{ ocp_client_version }}
when:
- deploy_type == "ipi"
- ocp4_aio_deploy_type == "ipi"
- not installer_exists.stat.exists

- name: Get OpenShift installer commit ID for IPI
ansible.builtin.command: /root/openshift-baremetal-install version
register: installer_version
when: deploy_type == "ipi"
when: ocp4_aio_deploy_type == "ipi"

- set_fact:
installer_commit: "{{ installer_version.stdout_lines[1].split('commit')[1] | trim }}"
when: deploy_type == "ipi"
when: ocp4_aio_deploy_type == "ipi"

- name: Check if RHCOS file descriptor exists
stat:
path: /root/openshift-baremetal-install
register: installer_exists
when: deploy_type == "ipi"
when: ocp4_aio_deploy_type == "ipi"

- name: Get the RHCOS file descriptor for IPI deployments
ansible.builtin.get_url:
url: "https://raw.githubusercontent.com/openshift/installer/{{ installer_commit }}/data/data/rhcos.json"
dest: /tmp/rhcos.json
mode: 0644
when: deploy_type == "ipi"
when: ocp4_aio_deploy_type == "ipi"

- name: Slurp the RHCOS json data
slurp:
path: /tmp/rhcos.json
register: rhcos_slurp
when: deploy_type == "ipi"
when: ocp4_aio_deploy_type == "ipi"

- name: Decode the RHCOS json data
set_fact:
rhcos_json: "{{ rhcos_slurp.content | b64decode }}"
when: deploy_type == "ipi"
when: ocp4_aio_deploy_type == "ipi"

- name: Get RHCOS OpenStack image URL
set_fact:
rhcos_openstack_url: "{{ rhcos_json.baseURI }}{{ rhcos_json.images.openstack.path }}"
when: deploy_type == "ipi"
when: ocp4_aio_deploy_type == "ipi"

- name: Get RHCOS QEMU image URL
set_fact:
rhcos_qemu_url: "{{ rhcos_json.baseURI }}{{ rhcos_json.images.qemu.path }}"
when: deploy_type == "ipi"
when: ocp4_aio_deploy_type == "ipi"

- name: Get RHCOS OpenStack sha265 checksum
set_fact:
rhcos_openstack_sha256: "{{ rhcos_json.images.openstack.sha256 }}"
when: deploy_type == "ipi"
when: ocp4_aio_deploy_type == "ipi"

- name: Get RHCOS QEMU sha265 checksum
set_fact:
rhcos_qemu_sha256: "{{ rhcos_json.images.qemu[\"uncompressed-sha256\"] }}"
when: deploy_type == "ipi"
when: ocp4_aio_deploy_type == "ipi"

- name: Check if RHCOS OpenStack image exists
stat:
path: /var/www/html/rhcos-openstack.x86_64.qcow2.gz
register: openstack_exists
when: deploy_type == "ipi"
when: ocp4_aio_deploy_type == "ipi"

- name: Download the RHCOS OpenStack image
ansible.builtin.get_url:
url: "{{ rhcos_openstack_url }}"
dest: /var/www/html/rhcos-openstack.x86_64.qcow2.gz
mode: 0644
when:
- deploy_type == "ipi"
- ocp4_aio_deploy_type == "ipi"
- not openstack_exists.stat.exists

- name: Check if RHCOS QEMU image exists
stat:
path: /var/www/html/rhcos-qemu.x86_64.qcow2.gz
register: qemu_exists
when: deploy_type == "ipi"
when: ocp4_aio_deploy_type == "ipi"

- name: Download the RHCOS QEMU image
ansible.builtin.get_url:
url: "{{ rhcos_qemu_url }}"
dest: /var/www/html/rhcos-qemu.x86_64.qcow2.gz
mode: 0644
when:
- deploy_type == "ipi"
- ocp4_aio_deploy_type == "ipi"
- not qemu_exists.stat.exists

- name: Ensure ocp-install directory is removed
Expand All @@ -132,14 +132,14 @@
path: /root/ocp-install/install-config.yaml
regexp: 'RHCOS_OPENSTACK_IMAGE'
replace: "http://192.168.123.100:81/rhcos-openstack.x86_64.qcow2.gz?sha256={{ rhcos_openstack_sha256 }}"
when: deploy_type == "ipi"
when: ocp4_aio_deploy_type == "ipi"

- name: Update OpenStack image location in install-config
ansible.builtin.replace:
path: /root/ocp-install/install-config.yaml
regexp: 'RHCOS_QEMU_IMAGE'
replace: "http://192.168.123.100:81/rhcos-qemu.x86_64.qcow2.gz?sha256={{ rhcos_qemu_sha256 }}"
when: deploy_type == "ipi"
when: ocp4_aio_deploy_type == "ipi"

- name: Make a backup of the install-config from ocp-install directory
ansible.builtin.copy:
Expand All @@ -151,7 +151,7 @@
ansible.builtin.command: >
/root/openshift-baremetal-install
--dir=/root/ocp-install/ create manifests
when: deploy_type == "ipi"
when: ocp4_aio_deploy_type == "ipi"

- name: Copy over MachineConfigs for chrony and networking
ansible.builtin.copy:
Expand All @@ -166,7 +166,7 @@
ansible.builtin.copy:
src: 97_masters_empty_enp3s0.yaml
dest: /root/ocp-install/openshift
when: deploy_compact | bool
when: ocp4_aio_deploy_compact | bool

- name: Pull required images for OpenShift logging
containers.podman.podman_image:
Expand Down Expand Up @@ -197,7 +197,7 @@
/root/openshift-baremetal-install
--dir=/root/ocp-install/ --log-level=debug
create cluster
when: deploy_type == "ipi"
when: ocp4_aio_deploy_type == "ipi"
ignore_errors: true
register: ipi_install

Expand All @@ -207,7 +207,7 @@
--dir=/root/ocp-install/ --log-level=debug
wait-for install-complete
when:
- deploy_type == "ipi"
- ocp4_aio_deploy_type == "ipi"
- ipi_install is failed

- name: Make .kube directory
Expand Down
34 changes: 17 additions & 17 deletions tasks/deploy_cluster_upi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
- name: Create OpenShift manifests for UPI
ansible.builtin.command: >
openshift-install --dir=/root/ocp-install/ create manifests
when: deploy_type == "upi"
when: ocp4_aio_deploy_type == "upi"

- name: Copy over MachineConfigs for chrony and networking
ansible.builtin.copy:
Expand All @@ -45,19 +45,19 @@
ansible.builtin.copy:
src: 97_masters_empty_enp3s0.yaml
dest: /root/ocp-install/openshift
when: deploy_compact | bool
when: ocp4_aio_deploy_compact | bool

- name: Copy install-config back into ocp-install directory for UPI
ansible.builtin.copy:
remote_src: yes
src: /root/install-config.yaml.bak
dest: /root/ocp-install/install-config.yaml
when: deploy_type == "upi"
when: ocp4_aio_deploy_type == "upi"

- name: Create Ignition Configs for UPI
ansible.builtin.command: >
openshift-install --dir=/root/ocp-install/ create ignition-configs
when: deploy_type == "upi"
when: ocp4_aio_deploy_type == "upi"

- name: Copy Ignition configs into /var/www/html for UPI
ansible.builtin.copy:
Expand All @@ -70,7 +70,7 @@
- "/root/ocp-install/bootstrap.ign"
- "/root/ocp-install/master.ign"
- "/root/ocp-install/worker.ign"
when: deploy_type == "upi"
when: ocp4_aio_deploy_type == "upi"

- name: Pull required images for OpenShift logging
containers.podman.podman_image:
Expand Down Expand Up @@ -111,7 +111,7 @@
- "ocp4-master1"
- "ocp4-master2"
- "ocp4-master3"
when: deploy_type == "upi"
when: ocp4_aio_deploy_type == "upi"

- name: Power on Workers for UPI installation
virt:
Expand All @@ -121,17 +121,17 @@
- "ocp4-worker1"
- "ocp4-worker2"
when:
- not deploy_compact
- deploy_type == "upi"
- not ocp4_aio_deploy_compact
- ocp4_aio_deploy_type == "upi"

- name: Power on third worker for UPI installation
virt:
name: "ocp4-worker3"
state: running
when:
- deploy_ocs
- not deploy_compact
- deploy_type == "upi"
- ocp4_aio_deploy_ocs
- not ocp4_aio_deploy_compact
- ocp4_aio_deploy_type == "upi"

# - name: Make sure deployment is proceeding
# gather_facts: false
Expand All @@ -144,7 +144,7 @@
register: bootstrap_wait
failed_when: bootstrap_wait.rc > 0
retries: 1
when: deploy_type == "upi"
when: ocp4_aio_deploy_type == "upi"

# - name: Destroy bootstrap machine via target
# hosts: target
Expand All @@ -156,7 +156,7 @@
name: "ocp4-bootstrap"
state: destroyed
when:
- deploy_type == "upi"
- ocp4_aio_deploy_type == "upi"

# - name: Make sure deployment is proceeding
# gather_facts: false
Expand All @@ -166,27 +166,27 @@
- name: Sleeping whilst nodes come up for UPI
ansible.builtin.pause:
minutes: 10
when: deploy_type == "upi"
when: ocp4_aio_deploy_type == "upi"

- name: Approve outstanding CSR's for UPI
ansible.builtin.shell: "oc get csr -o name | xargs oc adm certificate approve"
environment:
KUBECONFIG: "/root/ocp-install/auth/kubeconfig"
when: deploy_type == "upi"
when: ocp4_aio_deploy_type == "upi"

- name: Wait for OpenShift install-complete for UPI
ansible.builtin.command: >
openshift-install --dir=/root/ocp-install wait-for install-complete
register: install_wait
failed_when: install_wait.rc > 0
retries: 1
when: deploy_type == "upi"
when: ocp4_aio_deploy_type == "upi"

- name: Approve outstanding CSR's for UPI for a second time
ansible.builtin.shell: "oc get csr -o name | xargs oc adm certificate approve"
environment:
KUBECONFIG: "/root/ocp-install/auth/kubeconfig"
when: deploy_type == "upi"
when: ocp4_aio_deploy_type == "upi"

- name: Make .kube directory
ansible.builtin.file:
Expand Down
6 changes: 3 additions & 3 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
- name: Deploy UPI cluster
import_tasks: deploy_cluster_upi.yml
when: deploy_type == 'upi'
when: ocp4_aio_deploy_type == 'upi'

- name: Deploy IPI cluster
import_tasks: deploy_cluster_ipi.yml
when: deploy_type == 'ipi'
when: ocp4_aio_deploy_type == 'ipi'

- name: deploy SNO cluster
import_tasks: deploy_cluster_sno_iso.yml
when: deploy_type == 'sno'
when: ocp4_aio_deploy_type == 'sno'

0 comments on commit d0681be

Please sign in to comment.