diff --git a/.devfile.yaml b/.devfile.yaml index 1c7d483a3..c52483637 100644 --- a/.devfile.yaml +++ b/.devfile.yaml @@ -14,7 +14,7 @@ components: commands: - id: oc-install exec: - commandLine: '/usr/local/bin/ansible-playbook ${PROJECT_SOURCE}/playbooks/install_oc.yml' + commandLine: '/usr/local/bin/ansible-playbook ${PROJECT_SOURCE}/.install_oc.yaml' workingDir: ${PROJECT_SOURCE} group: kind: build diff --git a/.install_oc.yaml b/.install_oc.yaml new file mode 100644 index 000000000..1cce46bc7 --- /dev/null +++ b/.install_oc.yaml @@ -0,0 +1,39 @@ +--- +- name: Create + hosts: localhost + connection: local + gather_facts: false + no_log: false + vars: + molecule_pip_dependencies: + - kubernetes + tasks: + + - name: Store user ENVs + ansible.builtin.set_fact: + molecule_user_home_dir: "{{ lookup('ansible.builtin.env', 'HOME') }}" + molecule_user_path: "{{ lookup('ansible.builtin.env', 'PATH') }}" + + - name: Create local bin directory + ansible.builtin.file: + path: "{{ molecule_user_home_dir }}/bin" + state: directory + mode: 0770 + + - name: Download oc binary from OCP downloads svc endpoint + ansible.builtin.get_url: + url: http://downloads.openshift-console.svc.cluster.local/amd64/linux/oc + dest: "{{ molecule_user_home_dir }}/bin/oc" + mode: '0770' + + - name: Add another bin dir to system-wide $PATH. + ansible.builtin.lineinfile: + path: "{{ molecule_user_home_dir }}/.bashrc" + line: 'PATH=$PATH:{{ molecule_user_home_dir }}/bin' + state: present + + - name: Ensure python dependencies are installed + ansible.builtin.pip: + name: "{{ molecule_pip_dependencies }}" + state: present + when: molecule_pip_dependencies is defined