├── .ansible-lint ├── .github ├── FUNDING.yml └── workflows │ ├── ci.yml │ ├── release.yml │ └── stale.yml ├── .gitignore ├── .yamllint ├── LICENSE ├── README.md ├── defaults └── main.yml ├── meta └── main.yml ├── molecule └── default │ ├── converge.yml │ ├── molecule.yml │ └── verify.yml └── tasks └── main.yml /.ansible-lint: -------------------------------------------------------------------------------- 1 | skip_list: 2 | - 'yaml' 3 | - 'role-name' 4 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | --- 3 | github: geerlingguy 4 | patreon: geerlingguy 5 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: CI 3 | 'on': 4 | pull_request: 5 | push: 6 | branches: 7 | - master 8 | schedule: 9 | - cron: "30 4 * * 2" 10 | 11 | defaults: 12 | run: 13 | working-directory: 'geerlingguy.helm' 14 | 15 | jobs: 16 | 17 | lint: 18 | name: Lint 19 | runs-on: ubuntu-latest 20 | steps: 21 | - name: Check out the codebase. 22 | uses: actions/checkout@v4 23 | with: 24 | path: 'geerlingguy.helm' 25 | 26 | - name: Set up Python 3. 27 | uses: actions/setup-python@v5 28 | with: 29 | python-version: '3.x' 30 | 31 | - name: Install test dependencies. 32 | run: pip3 install yamllint 33 | 34 | - name: Lint code. 35 | run: | 36 | yamllint . 37 | 38 | molecule: 39 | name: Molecule 40 | runs-on: ubuntu-latest 41 | strategy: 42 | matrix: 43 | distro: 44 | # See: https://github.com/geerlingguy/docker-rockylinux9-ansible/issues/6 45 | # - rockylinux9 46 | - ubuntu2404 47 | - debian12 48 | 49 | steps: 50 | - name: Check out the codebase. 51 | uses: actions/checkout@v4 52 | with: 53 | path: 'geerlingguy.helm' 54 | 55 | - name: Set up Python 3. 56 | uses: actions/setup-python@v5 57 | with: 58 | python-version: '3.x' 59 | 60 | - name: Install test dependencies. 61 | run: pip3 install ansible molecule molecule-plugins[docker] docker 62 | 63 | - name: Run Molecule tests. 64 | run: molecule test 65 | env: 66 | PY_COLORS: '1' 67 | ANSIBLE_FORCE_COLOR: '1' 68 | MOLECULE_DISTRO: ${{ matrix.distro }} 69 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # This workflow requires a GALAXY_API_KEY secret present in the GitHub 3 | # repository or organization. 4 | # 5 | # See: https://github.com/marketplace/actions/publish-ansible-role-to-galaxy 6 | # See: https://github.com/ansible/galaxy/issues/46 7 | 8 | name: Release 9 | 'on': 10 | push: 11 | tags: 12 | - '*' 13 | 14 | defaults: 15 | run: 16 | working-directory: 'geerlingguy.helm' 17 | 18 | jobs: 19 | 20 | release: 21 | name: Release 22 | runs-on: ubuntu-latest 23 | steps: 24 | - name: Check out the codebase. 25 | uses: actions/checkout@v4 26 | with: 27 | path: 'geerlingguy.helm' 28 | 29 | - name: Set up Python 3. 30 | uses: actions/setup-python@v5 31 | with: 32 | python-version: '3.x' 33 | 34 | - name: Install Ansible. 35 | run: pip3 install ansible-core 36 | 37 | - name: Trigger a new import on Galaxy. 38 | run: >- 39 | ansible-galaxy role import --api-key ${{ secrets.GALAXY_API_KEY }} 40 | $(echo ${{ github.repository }} | cut -d/ -f1) $(echo ${{ github.repository }} | cut -d/ -f2) 41 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Close inactive issues 3 | 'on': 4 | schedule: 5 | - cron: "55 9 * * 0" # semi-random time 6 | 7 | jobs: 8 | close-issues: 9 | runs-on: ubuntu-latest 10 | permissions: 11 | issues: write 12 | pull-requests: write 13 | steps: 14 | - uses: actions/stale@v8 15 | with: 16 | days-before-stale: 120 17 | days-before-close: 60 18 | exempt-issue-labels: bug,pinned,security,planned 19 | exempt-pr-labels: bug,pinned,security,planned 20 | stale-issue-label: "stale" 21 | stale-pr-label: "stale" 22 | stale-issue-message: | 23 | This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution! 24 | 25 | Please read [this blog post](https://www.jeffgeerling.com/blog/2020/enabling-stale-issue-bot-on-my-github-repositories) to see the reasons why I mark issues as stale. 26 | close-issue-message: | 27 | This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details. 28 | stale-pr-message: | 29 | This pr has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution! 30 | 31 | Please read [this blog post](https://www.jeffgeerling.com/blog/2020/enabling-stale-issue-bot-on-my-github-repositories) to see the reasons why I mark issues as stale. 32 | close-pr-message: | 33 | This pr has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details. 34 | repo-token: ${{ secrets.GITHUB_TOKEN }} 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.retry 2 | */__pycache__ 3 | *.pyc 4 | .cache 5 | 6 | -------------------------------------------------------------------------------- /.yamllint: -------------------------------------------------------------------------------- 1 | --- 2 | extends: default 3 | 4 | rules: 5 | line-length: 6 | max: 200 7 | level: warning 8 | 9 | ignore: | 10 | .github/workflows/stale.yml 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2020 Jeff Geerling 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ansible Role: Helm 2 | 3 | [![CI](https://github.com/geerlingguy/ansible-role-helm/actions/workflows/ci.yml/badge.svg)](https://github.com/geerlingguy/ansible-role-helm/actions/workflows/ci.yml) 4 | 5 | This role installs the [Helm](https://helm.sh) binary on any supported host. 6 | 7 | ## Requirements 8 | 9 | N/A 10 | 11 | ## Role Variables 12 | 13 | Available variables are listed below, along with default values (see `defaults/main.yml`): 14 | 15 | helm_version: 'v3.2.1' 16 | helm_platform: linux 17 | helm_arch: amd64 18 | 19 | Controls for the version of Helm to be installed. See [available Helm releases](https://github.com/helm/helm/releases/). You can upgrade or downgrade versions by changing the `helm_version`. 20 | 21 | helm_repo_path: "https://get.helm.sh" 22 | 23 | The path to the main Helm repo. Unlessy you need to override this for special reasons (e.g. running on servers without public Internet access), you should leave it as the default. 24 | 25 | helm_bin_path: /usr/local/bin/helm 26 | 27 | The location where the Helm binary will be installed. 28 | 29 | ## Dependencies 30 | 31 | None. 32 | 33 | ## Example Playbook 34 | 35 | - hosts: all 36 | roles: 37 | - role: geerlingguy.helm 38 | 39 | ## License 40 | 41 | MIT / BSD 42 | 43 | ## Author Information 44 | 45 | This role was created in 2020 by [Jeff Geerling](https://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/). 46 | -------------------------------------------------------------------------------- /defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # See available releases: https://github.com/helm/helm/releases/ 3 | helm_version: 'v3.2.1' 4 | helm_platform: linux 5 | helm_arch: amd64 6 | 7 | helm_repo_path: "https://get.helm.sh" 8 | 9 | helm_bin_path: /usr/local/bin/helm 10 | -------------------------------------------------------------------------------- /meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: [] 3 | galaxy_info: 4 | author: geerlingguy 5 | role_name: helm 6 | description: Helm for Kubernetes. 7 | company: Midwestern Mac, LLC 8 | license: license (MIT) 9 | min_ansible_version: 2.10 10 | platforms: 11 | - name: GenericUNIX 12 | versions: 13 | - all 14 | - name: Fedora 15 | versions: 16 | - all 17 | - name: opensuse 18 | versions: 19 | - all 20 | - name: GenericBSD 21 | versions: 22 | - all 23 | - name: FreeBSD 24 | versions: 25 | - all 26 | - name: Ubuntu 27 | versions: 28 | - all 29 | - name: SLES 30 | versions: 31 | - all 32 | - name: GenericLinux 33 | versions: 34 | - all 35 | - name: Debian 36 | versions: 37 | - all 38 | galaxy_tags: 39 | - kubernetes 40 | - k8s 41 | - cloud 42 | - containers 43 | - helm 44 | - deployment 45 | -------------------------------------------------------------------------------- /molecule/default/converge.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Converge 3 | hosts: all 4 | #become: true 5 | 6 | pre_tasks: 7 | - name: Update apt cache. 8 | apt: update_cache=yes cache_valid_time=600 9 | when: ansible_os_family == 'Debian' 10 | changed_when: false 11 | 12 | roles: 13 | - role: geerlingguy.helm 14 | -------------------------------------------------------------------------------- /molecule/default/molecule.yml: -------------------------------------------------------------------------------- 1 | --- 2 | role_name_check: 1 3 | dependency: 4 | name: galaxy 5 | options: 6 | ignore-errors: true 7 | driver: 8 | name: docker 9 | platforms: 10 | - name: instance 11 | image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos8}-ansible:latest" 12 | command: ${MOLECULE_DOCKER_COMMAND:-""} 13 | volumes: 14 | - /sys/fs/cgroup:/sys/fs/cgroup:rw 15 | cgroupns_mode: host 16 | privileged: true 17 | pre_build_image: true 18 | provisioner: 19 | name: ansible 20 | playbooks: 21 | converge: ${MOLECULE_PLAYBOOK:-converge.yml} 22 | -------------------------------------------------------------------------------- /molecule/default/verify.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Verify 3 | hosts: all 4 | gather_facts: false 5 | 6 | vars_files: 7 | - ../../defaults/main.yml 8 | 9 | tasks: 10 | - name: Check Helm version. 11 | command: "{{ helm_bin_path }} version" 12 | changed_when: false 13 | register: helm_verify_version 14 | 15 | - name: Verify Helm's version is {{ helm_version }}. 16 | assert: 17 | that: 18 | - helm_version in helm_verify_version.stdout 19 | -------------------------------------------------------------------------------- /tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Check if Helm binary exists. 3 | stat: 4 | path: "{{ helm_bin_path }}" 5 | register: helm_check 6 | 7 | - name: Check Helm version. 8 | command: "{{ helm_bin_path }} version" 9 | failed_when: false 10 | changed_when: false 11 | register: helm_existing_version 12 | 13 | - name: Download helm. 14 | unarchive: 15 | src: "{{ helm_repo_path }}/helm-{{ helm_version }}-{{ helm_platform }}-{{ helm_arch }}.tar.gz" 16 | dest: /tmp 17 | remote_src: true 18 | mode: 0755 19 | register: helm_download 20 | when: > 21 | not helm_check.stat.exists 22 | or helm_version not in helm_existing_version.stdout 23 | 24 | - name: Copy helm binary into place. 25 | copy: 26 | src: "/tmp/{{ helm_platform }}-{{ helm_arch }}/helm" 27 | dest: "{{ helm_bin_path }}" 28 | mode: 0755 29 | remote_src: true 30 | become: true 31 | when: helm_download is changed 32 | --------------------------------------------------------------------------------