diff --git a/Makefile b/Makefile index 5193441..f396451 100644 --- a/Makefile +++ b/Makefile @@ -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 \ No newline at end of file diff --git a/crc-versions.yaml b/crc-versions.yaml index 372d367..11729f9 100644 --- a/crc-versions.yaml +++ b/crc-versions.yaml @@ -11,4 +11,21 @@ - name: Set architecture for MacOS set_fact: arch_name: "macos" - when: ansible_os_family == "Darwin" \ No newline at end of file + 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 }}" diff --git a/openshift4-installer.yaml b/openshift4-installer.yaml index d08f6e4..34ccb48 100644 --- a/openshift4-installer.yaml +++ b/openshift4-installer.yaml @@ -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: @@ -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: @@ -46,21 +46,16 @@ 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 @@ -68,34 +63,21 @@ 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 \ No newline at end of file diff --git a/openshift4-runner.yaml b/openshift4-runner.yaml index cc82784..9e179a3 100644 --- a/openshift4-runner.yaml +++ b/openshift4-runner.yaml @@ -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 diff --git a/openshift4-stop.yaml b/openshift4-stop.yaml index cd3a9fd..f0874a6 100644 --- a/openshift4-stop.yaml +++ b/openshift4-stop.yaml @@ -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" diff --git a/openshift4-versions.yaml b/openshift4-versions.yaml new file mode 100644 index 0000000..de7a807 --- /dev/null +++ b/openshift4-versions.yaml @@ -0,0 +1,5 @@ +--- +- name: Versions OpenShift 4 + hosts: all + tasks: + - include_tasks: ./crc-versions.yaml