Skip to content

Commit

Permalink
Update playbooks
Browse files Browse the repository at this point in the history
Signed-off-by: Petr "Stone" Hracek <[email protected]>
  • Loading branch information
phracek committed Sep 17, 2019
1 parent b061f0e commit d077b59
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 40 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
install_openshift:
ansible-playbook -vvvv -c local -i localhost, ./openshift4-installer.yaml -e pull_secret=./pull-secret

run_openshift: install_openshift
run_openshift:
ansible-playbook -vvvv -c local -i localhost, ./openshift4-runner.yaml

stop_openshift:
ansible-playbook -vvvv -c local -i localhost, ./openshift4-stop.yaml

test_openshift_versions:
ansible-playbook -vvvv -c local -i localhost, ./openshift4-versions.yaml
19 changes: 18 additions & 1 deletion crc-versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,21 @@
- name: Set architecture for MacOS
set_fact:
arch_name: "macos"
when: ansible_os_family == "Darwin"
when: ansible_os_family == "Darwin"

- name: Get content of 'https://mirror.openshift.com/pub/openshift-v4/clients/crc/latest'
get_url:
url: https://mirror.openshift.com/pub/openshift-v4/clients/crc/latest/sha256sum.txt
dest: /tmp/sha256sum.txt
mode: '0664'

- name: Get crc_virtualbox_*.crcbundle filename
shell: "cat sha256sum.txt| grep crc_virtualbox | cut -f3 -d' ' | cut -f2 -d'/'"
register: crc_file_name

- file:
path: /tmp/sha256sum.txt
state: absent

- name: CRC bundle file name is
debug: msg="{{ crc_file_name.stdout }}"
36 changes: 9 additions & 27 deletions openshift4-installer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

- name: Set variable crc_dir_name
set_fact:
crc_dir_name: "{{ ansible_env.HOME }}/crc-{{ arch_name }}-amd64"
crc_dir_name: "{{ ansible_env.HOME }}/crc-{{ arch_name }}-{{ version }}-amd64"

- name: Check for presence pull-secret file
stat:
Expand All @@ -35,7 +35,7 @@
get_url:
url: 'https://mirror.openshift.com/pub/openshift-v4/clients/crc/latest/crc-{{ arch_name }}-amd64.tar.xz'
dest: '{{ crc_tar_name }}'
when: file_details.stat.exists == false
when: dir_details.stat.exists == false

- name: Check for presence ~/.crc directory
stat:
Expand All @@ -46,56 +46,38 @@
file:
path: "{{ ansible_env.HOME }}/.crc"
state: directory
when: dir_details.stat.exists == false

- name: Check if CRC directory is present
stat:
path: "{{ ansible_env.HOME }}/crc-{{ arch_name }}-{{ version }}-amd64/"
register: crc_dir_exist
when: crc_details.stat.exists == false

- name: Check for CRC Bundle presence
stat:
path: "{{ ansible_env.HOME }}/.crc/crc_virtualbox_{{ crc_version }}.crcbundle"
path: "{{ ansible_env.HOME }}/.crc/{{ crc_file_name.stdout }}"
register: crc_present

- name: Get VirtualBox CRC bundle
get_url:
url: "https://mirror.openshift.com/pub/openshift-v4/clients/crc/latest/crc_virtualbox_{{ crc_version }}.crcbundle"
url: "https://mirror.openshift.com/pub/openshift-v4/clients/crc/latest/{{ crc_file_name.stdout }}"
dest: "{{ ansible_env.HOME }}/.crc/"
when: crc_present.stat.exists == false

- name: Untar CRC code
unarchive:
src: '{{ crc_tar_name }}'
dest: '{{ ansible_env.HOME }}'
when: ansible_os_family == "RedHat"
when: ansible_os_family == "RedHat" and dir_details.stat.exists == false

- name: Gunzip CRC code
command: "gunzip -v {{ ansible_env.HOME }}/crc-{{ arch_name }}-amd64.tar.xz"
when: ansible_os_family == "Darwin"
when: ansible_os_family == "Darwin" and dir_details.stat.exists == false

- name: Untar CRC code
command: "tar -xvf {{ ansible_env.HOME }}/crc-{{ arch_name }}-amd64.tar -C {{ ansible_env.HOME }}"
when: ansible_os_family == "Darwin"
when: ansible_os_family == "Darwin" and dir_details.stat.exists == false

- name: Delete CRC tar source
file:
state: absent
path: "{{ ansible_env.HOME }}/crc-{{ arch_name }}-amd64.tar"
when: dir_details.stat.exists == false

- name: CRC setup
command: "{{ ansible_env.HOME }}/crc-{{ arch_name }}-{{ version }}-amd64/crc setup"
when: crc_dir_exist.stat.exists == false

- name: Copy pull-secret to crc directory
copy:
src: "{{ pull_secret }}"
dest: "{{ ansible_env.HOME }}/crc-{{ arch_name }}-{{ version }}-amd64/pull-secret"

- name: CRC Start
command: "{{ ansible_env.HOME }}/crc-{{ arch_name }}-{{ version }}-amd64/crc start --pull-secret-file {{ ansible_env.HOME }}/crc-{{ arch_name }}-{{ version }}-amd64/pull-secret"


# Important links
# http://cdk-builds.usersys.redhat.com/builds/crc/4.1.9/
# https://cloud.redhat.com/openshift/install/metal/user-provisioned
10 changes: 0 additions & 10 deletions openshift4-runner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,3 @@

- name: CRC Start
command: "{{ ansible_env.HOME }}/crc-{{ arch_name }}-{{ version }}-amd64/crc start --pull-secret-file {{ ansible_env.HOME }}/crc-{{ arch_name }}-{{ version }}-amd64/pull-secret"
async: 1000
poll: 0
register: crc_sleeper

- name: 'CRC - check on async task'
async_status:
jid: "{{ crc_sleeper.ansible_job_id }}
register: job_result
until: job_result.finished
retries: 100
5 changes: 4 additions & 1 deletion openshift4-stop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@
tasks:
- include_tasks: ./crc-versions.yaml

- name: CRC Start
- name: CodeReadyContainers stop
command: "{{ ansible_env.HOME }}/crc-{{ arch_name }}-{{ version }}-amd64/crc stop"

- name: CodeReadyContainers delete
command: "{{ ansible_env.HOME }}/crc-{{ arch_name }}-{{ version }}-amd64/crc delete"
5 changes: 5 additions & 0 deletions openshift4-versions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- name: Versions OpenShift 4
hosts: all
tasks:
- include_tasks: ./crc-versions.yaml

0 comments on commit d077b59

Please sign in to comment.