mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-05-07 13:32:37 +00:00
helm: add support for the K8S_ envvars (#319)
Add support for: - K8S_AUTH_HOST - K8S_AUTH_API_KEY - K8S_AUTH_VERIFY_SSL - K8S_AUTH_SSL_CA_CERT This commit also refactor the way we pass K8S related configuration to `helm`: All the calls are now done in a new module_utils module (`helm.py`). The handling of the `kube_*` variables has also been moved in this new module. We need https://github.com/helm/helm/pull/8622 to be able to ignore the certificate validation. As a workaround, the generate a temporary kubeconfig configuration file. Closes: #279
This commit is contained in:
@@ -121,8 +121,7 @@ except ImportError:
|
||||
IMP_YAML = False
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||
|
||||
module = None
|
||||
from ansible_collections.community.kubernetes.plugins.module_utils.helm import run_helm
|
||||
|
||||
|
||||
# Get repository from all repositories added
|
||||
@@ -135,10 +134,10 @@ def get_repository(state, repo_name):
|
||||
|
||||
|
||||
# Get repository status
|
||||
def get_repository_status(command, repository_name):
|
||||
def get_repository_status(module, command, repository_name):
|
||||
list_command = command + " repo list --output=yaml"
|
||||
|
||||
rc, out, err = module.run_command(list_command)
|
||||
rc, out, err = run_helm(module, list_command, fails_on_error=False)
|
||||
|
||||
# no repo => rc=1 and 'no repositories to show' in output
|
||||
if rc == 1 and "no repositories to show" in err:
|
||||
@@ -208,7 +207,7 @@ def main():
|
||||
else:
|
||||
helm_cmd = module.get_bin_path('helm', required=True)
|
||||
|
||||
repository_status = get_repository_status(helm_cmd, repo_name)
|
||||
repository_status = get_repository_status(module, helm_cmd, repo_name)
|
||||
|
||||
if repo_state == "absent" and repository_status is not None:
|
||||
helm_cmd = delete_repository(helm_cmd, repo_name)
|
||||
@@ -225,7 +224,7 @@ def main():
|
||||
elif not changed:
|
||||
module.exit_json(changed=False, repo_name=repo_name, repo_url=repo_url)
|
||||
|
||||
rc, out, err = module.run_command(helm_cmd)
|
||||
rc, out, err = run_helm(module, helm_cmd)
|
||||
|
||||
if repo_password is not None:
|
||||
helm_cmd = helm_cmd.replace(repo_password, '******')
|
||||
|
||||
Reference in New Issue
Block a user