-
Notifications
You must be signed in to change notification settings - Fork 2
/
fetch_latest_oc_client.yaml
executable file
·33 lines (26 loc) · 1.23 KB
/
fetch_latest_oc_client.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env ansible-playbook
---
- hosts: localhost
connection: local
gather_facts: False
vars:
openshift_client_url: "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/"
operating_system: "mac"
tasks:
- name: Looking for available clients
uri: url={{ openshift_client_url }} return_content=True
register: available_content
- name: Fetching the latest version for "{{ operating_system }}"
set_fact: client_filename={{ available_content.content | regex_search("(openshift-client-"+operating_system+"-\d{1,3}\.\d{1,3}\.\d{1,3}\.tar\.gz)") }}
- name: Deleting any existing file
file: path={{ item }} state=absent
with_items: ["README.md", "oc", "kubectl", "{{ client_filename }}"]
- name: "Downloading: {{ client_filename }}"
uri: url={{ openshift_client_url }}{{ client_filename }} dest=./{{ client_filename }} validate_certs=False
- name: "Unarchiving: {{ client_filename }}"
unarchive: src=./{{ client_filename }} dest=./
# - name: Making the file executable
# file: name=./oc mode="a+x"
- name: Cleaning up
file: name={{ item }} state=absent
with_items: ["README.md", "{{ client_filename }}"]