--- - name: List packages to install tags: - bootstrap - packages ansible.builtin.debug: var: cifmw_ci_setup_packages - name: Install needed packages # noqa: package-latest become: true tags: - bootstrap - packages ansible.builtin.package: name: "{{ cifmw_ci_setup_packages }}" state: latest - name: Gather version of openshift client register: _oc_version environment: >- {{ {'PATH': cifmw_path} if cifmw_path is defined else {} }} ansible.builtin.command: cmd: "oc version --client -o yaml" changed_when: false failed_when: false - name: Install openshift client tags: - bootstrap - packages when: >- _oc_version.rc != 0 or ( ((_oc_version.stdout | from_yaml).releaseClientVersion | split('.') | first | int) >= cifmw_ci_setup_openshift_minimum_version ) block: - name: Ensure openshift client install path is present ansible.builtin.file: path: "{{ cifmw_ci_setup_oc_install_path }}" state: directory mode: "0755" - name: Install openshift client ansible.builtin.unarchive: src: "{{ cifmw_ci_setup_openshift_client_download_uri }}/{{ cifmw_ci_setup_openshift_client_version }}/openshift-client-linux.tar.gz" dest: "{{ cifmw_ci_setup_oc_install_path }}" remote_src: true mode: "0755" creates: "{{ cifmw_ci_setup_oc_install_path }}/oc" - name: Add the OC path to cifmw_path if needed vars: _cifmw_paths_list: >- {{ cifmw_path | split(':') if cifmw_path is defined else [] }} when: cifmw_ci_setup_oc_install_path not in _cifmw_paths_list ansible.builtin.set_fact: cifmw_path: "{{ cifmw_ci_setup_oc_install_path }}:{{ ansible_env.PATH }}" cacheable: true - name: Inject oc completion in local profile block: - name: Create completion file ansible.builtin.shell: # noqa: risky-shell-pipe cmd: >- {{ cifmw_ci_setup_oc_install_path }}/oc completion bash | tee -a ~/.oc_completion creates: "{{ ansible_user_dir }}/.oc_completion" no_log: "{{ cifmw_nolog | default(true) | bool }}" - name: Source completion from within .bashrc ansible.builtin.blockinfile: create: true mode: "0644" path: "{{ ansible_user_dir }}/.bashrc" block: |- if [ -f ~/.oc_completion ]; then source ~/.oc_completion fi