add install oc file

This commit is contained in:
willtome
2023-10-24 12:45:09 -04:00
parent 3266a94ff8
commit 4a62ecd0fa
2 changed files with 40 additions and 1 deletions

39
.install_oc.yaml Normal file
View File

@@ -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