Initial commit.
parent
54bd58260a
commit
5e8d09951f
@ -1,2 +1,42 @@
|
|||||||
# helm-ansible-role
|
Role Name
|
||||||
|
=========
|
||||||
|
|
||||||
|
An Ansible role to install helm.
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
------------
|
||||||
|
|
||||||
|
None
|
||||||
|
|
||||||
|
Role Variables
|
||||||
|
--------------
|
||||||
|
|
||||||
|
```yml
|
||||||
|
helm_version: 3.7.2
|
||||||
|
helm_arch: amd64
|
||||||
|
```
|
||||||
|
|
||||||
|
Dependencies
|
||||||
|
------------
|
||||||
|
|
||||||
|
None
|
||||||
|
|
||||||
|
Example Playbook
|
||||||
|
----------------
|
||||||
|
|
||||||
|
```yml
|
||||||
|
- name: Install helm.
|
||||||
|
hosts: all
|
||||||
|
roles:
|
||||||
|
- { role: install_helm, helm_version: 3.7,2, helm_arch: amd64 }
|
||||||
|
```
|
||||||
|
|
||||||
|
License
|
||||||
|
-------
|
||||||
|
|
||||||
|
MIT
|
||||||
|
|
||||||
|
Author Information
|
||||||
|
------------------
|
||||||
|
|
||||||
|
This role was created by [shnee](https://github.com/shnee).
|
||||||
|
|||||||
@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
helm_version: 3.7.2
|
||||||
|
helm_arch: amd64
|
||||||
|
helm_install_dir: /usr/local/bin
|
||||||
|
helm_release_base_url: https://get.helm.sh
|
||||||
|
helm_download_sha256:
|
||||||
|
3.7.2:
|
||||||
|
amd64: 4ae30e48966aba5f807a4e140dad6736ee1a392940101e4d79ffb4ee86200a9e
|
||||||
|
arm64: b0214eabbb64791f563bd222d17150ce39bf4e2f5de49f49fdb456ce9ae8162f
|
||||||
|
|
||||||
|
# A temporary directory to extract the tar.gz helm release. It get's deleted by
|
||||||
|
# a handler if it's ever created.
|
||||||
|
tmp_dir: /tmp/helm-ansible
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- name: Clean up tmp dir
|
||||||
|
file:
|
||||||
|
path: "{{ tmp_dir }}"
|
||||||
|
state: absent
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
galaxy_info:
|
||||||
|
author: shnee
|
||||||
|
description: A ansible role to install helm.
|
||||||
|
|
||||||
|
license: MIT
|
||||||
|
|
||||||
|
min_ansible_version: 2.1
|
||||||
|
|
||||||
|
platforms:
|
||||||
|
- name: Ubuntu
|
||||||
|
versions:
|
||||||
|
- focal # 20.04
|
||||||
|
|
||||||
|
galaxy_tags:
|
||||||
|
- containers
|
||||||
|
- orchestration
|
||||||
|
- helm
|
||||||
|
- kubernetes
|
||||||
|
|
||||||
|
dependencies: []
|
||||||
@ -0,0 +1,60 @@
|
|||||||
|
---
|
||||||
|
- name: Check if helm is already installed.
|
||||||
|
stat:
|
||||||
|
path: "{{ helm_install_dir }}/helm"
|
||||||
|
failed_when: false
|
||||||
|
register: helm_stat
|
||||||
|
|
||||||
|
- name: >
|
||||||
|
"Check the installed helm version against the desired version
|
||||||
|
{{ helm_version }}."
|
||||||
|
command: "{{ helm_install_dir }}/helm version"
|
||||||
|
changed_when: false
|
||||||
|
failed_when: false
|
||||||
|
when: helm_stat.stat.exists
|
||||||
|
register: existing_helm_version
|
||||||
|
|
||||||
|
- name: Install helm
|
||||||
|
block:
|
||||||
|
|
||||||
|
- name: Create a tmp directory to extract helm tar.gz
|
||||||
|
file:
|
||||||
|
path: "{{ tmp_dir }}"
|
||||||
|
state: directory
|
||||||
|
mode: 0700
|
||||||
|
notify: Clean up tmp dir
|
||||||
|
|
||||||
|
- name: Download helm tar.gz.
|
||||||
|
get_url:
|
||||||
|
url: "{{ helm_release_base_url }}/\
|
||||||
|
helm-v{{ helm_version }}-linux-{{ helm_arch }}.tar.gz"
|
||||||
|
dest: "{{ tmp_dir }}"
|
||||||
|
checksum: "sha256:{{ helm_download_sha256[helm_version][helm_arch] }}"
|
||||||
|
mode: 0700
|
||||||
|
|
||||||
|
- name: Extract helm tar.gz
|
||||||
|
unarchive:
|
||||||
|
src: "{{ tmp_dir }}/\
|
||||||
|
helm-v{{ helm_version }}-linux-{{ helm_arch }}.tar.gz"
|
||||||
|
dest: "{{ tmp_dir }}"
|
||||||
|
remote_src: true
|
||||||
|
mode: 0700
|
||||||
|
|
||||||
|
- name: Make sure install directory exists.
|
||||||
|
file:
|
||||||
|
path: "{{ helm_install_dir }}"
|
||||||
|
state: directory
|
||||||
|
mode: 0755
|
||||||
|
become: true
|
||||||
|
|
||||||
|
- name: Copy helm binary from tmp folder to install location.
|
||||||
|
copy:
|
||||||
|
src: "{{ tmp_dir }}/linux-{{ helm_arch }}/helm"
|
||||||
|
remote_src: true
|
||||||
|
dest: "{{ helm_install_dir }}/helm"
|
||||||
|
mode: 0755
|
||||||
|
become: true
|
||||||
|
|
||||||
|
when: >
|
||||||
|
not helm_stat.stat.exists or
|
||||||
|
helm_version not in existing_helm_version.stdout
|
||||||
Loading…
Reference in New Issue