Open edgan opened 2 years ago
@edgan The module already supports this:
- hosts: localhost
gather_facts: no
tasks:
- kubernetes.core.helm_repository:
repo_url: https://charts.bitnami.com/bitnami
name: bitnami
- kubernetes.core.helm_repository:
repo_url: https://charts.bitnami.com/bitnami
name: bitnami
PLAY [localhost] ****************************************************************************************************************************
TASK [kubernetes.core.helm_repository] ******************************************************************************************************
changed: [localhost]
TASK [kubernetes.core.helm_repository] ******************************************************************************************************
ok: [localhost]
PLAY RECAP **********************************************************************************************************************************
localhost : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Could you provide more information about what version of the collection and what version of ansible you are using? Also, could you provide the output from running the playbook using -vvv
?
I got here because I got the Repository already have a repository named $foo
error, but it happened to me because I already had it listed with a different URL.
I can reproduce the exact error with:
- hosts: localhost
gather_facts: no
tasks:
- kubernetes.core.helm_repository:
repo_url: https://charts.bitnami.com/bitnami
name: bitnami
- kubernetes.core.helm_repository:
repo_url: https://charts.bitnami.com/bitnami/ # note the trailing "/"
name: bitnami
$ ansible-playbook ansible-helm-repo.yaml
TASK [kubernetes.core.helm_repository]
changed: [localhost]
TASK [kubernetes.core.helm_repository]
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Repository already have a repository named bitnami"}
Maybe this was issue for the original reporter as well?
Note that helm
gives a different message, but still does not point out that the issue is the different URL. I know it should be obvious, but my brain sometimes goes on vacation. :)
$helm repo add bitnami https://charts.gitlab.io/
Error: repository name (bitnami) already exists, please specify a different name
SUMMARY
kubernetes.core.helm_repository, or a new function, should be stateful, as in
state: present
. Currently it installs a repository, but can't verify if it is already installed. If it is already installed it will just throw an error saying it is already installed.ISSUE TYPE
COMPONENT NAME
kubernetes.core.helm_repository
ADDITIONAL INFORMATION
Workaround code: