--- # Copyright Red Hat, Inc. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. - name: Ensure directories exist tags: - always ansible.builtin.file: path: "{{ item }}" state: directory mode: "0755" loop: - "{{ cifmw_rhol_crc_basedir }}/artifacts" - "{{ cifmw_rhol_crc_basedir }}/logs" - "{{ cifmw_rhol_crc_binary_folder }}" - name: Initialize manage_secrets tags: - always ansible.builtin.import_role: name: manage_secrets - name: Verify CRC status tags: - always ansible.builtin.import_tasks: find_crc.yml - name: Fail if crc domain is already defined tags: - always when: - crc_present | bool - not cifmw_rhol_crc_force_cleanup | bool - not cifmw_rhol_crc_reuse | bool ansible.builtin.fail: msg: >- The crc domain already exist. Set cifmw_rhol_crc_force_cleanup to true to force the cleanup. Interrupting tasks. - name: Ensure pull-secret is in place if we need to configure CRC tags: - always when: - (cifmw_rhol_crc_force_cleanup | bool) or (not crc_present | bool) or (not crc_running | bool) vars: cifmw_manage_secrets_pullsecret_dest: "{{ cifmw_rhol_crc_pullsecret_dest }}" ansible.builtin.include_role: name: manage_secrets tasks_from: pull_secret.yml - name: Clean/deploy CRC block: - name: Retrieve RHOL/CRC if not existing when: (cifmw_rhol_crc_force_cleanup|bool) or not crc_present|bool block: - name: Get wanted RHOL/CRC version binary if needed when: - (not crc_bin_available | bool) or (crc_version is defined and cifmw_rhol_crc_version is not version(crc_version, '==')) ansible.builtin.include_tasks: binary.yml - name: Setup sudoers file for sudo commands in RHOL/CRC setup ansible.builtin.include_tasks: sudoers_grant.yml - name: Clean RHOL/CRC if wanted when: - crc_present|bool - cifmw_rhol_crc_force_cleanup | bool ansible.builtin.include_tasks: cleanup.yml - name: Configure and start RHOL/CRC when: (cifmw_rhol_crc_force_cleanup|bool) or not crc_running|bool block: - name: Setup if RHOL/CRC does not exists when: - not crc_present | bool block: - name: Set RHOL/CRC configuration options ansible.builtin.include_tasks: configuration.yml - name: Setup RHOL/CRC ansible.builtin.shell: cmd: >- set -o pipefail; {{ cifmw_rhol_crc_binary }} setup 2>&1 | tee {{ cifmw_rhol_crc_basedir }}/logs/crc-setup.log register: cifmw_rhol_crc_cmd_setup - name: Start RHOL/CRC ansible.builtin.shell: cmd: >- set -o pipefail; {{ cifmw_rhol_crc_binary }} start 2>&1 | tee {{ cifmw_rhol_crc_basedir }}/logs/crc-start.log register: cifmw_rhol_crc_cmd_start - name: Attach default network to CRC when: cifmw_rhol_crc_use_installyamls|bool vars: cifmw_libvirt_manager_net_prefix_add: false vm_name: crc network: name: default block: - name: List VMs register: _vm_list community.libvirt.virt: command: "list_vms" - name: Output VMs ansible.builtin.debug: var: _vm_list - name: List networks register: _net_list community.libvirt.virt_net: command: "list_nets" - name: Output networks ansible.builtin.debug: var: _net_list - name: Attach default network vars: networks: "{{ _net_list.list_nets }}" ansible.builtin.import_role: name: libvirt_manager tasks_from: attach_interface.yml always: - name: Delete sudoers file ansible.builtin.import_tasks: sudoers_revoke.yml - name: Set OpenShift CRC credentials ansible.builtin.import_tasks: set_cluster_fact.yml - name: Add crc kubeconfig when: cifmw_rhol_crc_creds | bool ansible.builtin.import_tasks: add_crc_creds.yml # Note(Lewis): Only needed for CRC => 2.32.0-4.14.8 - name: Configure DNS in CRC VM delegate_to: crc vars: _crc_ip: "192.168.122.10" _dnsmasq_config: "/etc/dnsmasq.d/crc-dnsmasq.conf" when: - cifmw_use_crc is defined - cifmw_use_crc | bool block: - name: Check if using systemd dnsmasq register: _dnsmasq ansible.builtin.stat: path: "{{ _dnsmasq_config }}" get_attributes: false get_checksum: false get_mime: false - name: Configure dnsmasq and restart service when: _dnsmasq.stat.exists block: - name: Configure dnsmasq listen-address to listen on both br-ex and ospbr become: true ansible.builtin.lineinfile: path: "{{ _dnsmasq_config }}" insertafter: "^listen-address=" line: "listen-address={{ _crc_ip | ansible.utils.ipaddr('address') }}" - name: Restart DNS in CRC VM become: true ansible.builtin.service: name: dnsmasq state: restarted