mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-05-14 13:32:14 +00:00
t# This is a combination of 2 commits.
Add requested changes for helm
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
binary_path: "{{ helm_binary}}_fake"
|
binary_path: "{{ helm_binary}}_fake"
|
||||||
name: test
|
name: test
|
||||||
chart_ref: "{{ chart_test }}"
|
chart_ref: "{{ chart_test }}"
|
||||||
|
namespace: "{{ helm_namespace }}"
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
register: helm_missing_binary
|
register: helm_missing_binary
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
binary_path: "{{ helm_binary}}"
|
binary_path: "{{ helm_binary}}"
|
||||||
name: test
|
name: test
|
||||||
chart_ref: "{{ chart_test }}"
|
chart_ref: "{{ chart_test }}"
|
||||||
|
namespace: "{{ helm_namespace }}"
|
||||||
tiller_namespace: helm
|
tiller_namespace: helm
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
register: missing_tiller
|
register: missing_tiller
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ module: helm_cli
|
|||||||
short_description: Manages Kubernetes packages with the Helm package manager
|
short_description: Manages Kubernetes packages with the Helm package manager
|
||||||
description:
|
description:
|
||||||
- Install, upgrade, delete packages with the Helm package manager.
|
- Install, upgrade, delete packages with the Helm package manager.
|
||||||
version_added: "2.10"
|
|
||||||
author:
|
author:
|
||||||
- Lucas Boisserie (@LucasBoisserie)
|
- Lucas Boisserie (@LucasBoisserie)
|
||||||
- Matthieu Diehr (@d-matt)
|
- Matthieu Diehr (@d-matt)
|
||||||
@@ -31,73 +30,72 @@ options:
|
|||||||
type: path
|
type: path
|
||||||
chart_ref:
|
chart_ref:
|
||||||
description:
|
description:
|
||||||
- chart_reference on chart repository
|
- chart_reference on chart repository.
|
||||||
- path to a packaged chart
|
- path to a packaged chart.
|
||||||
- path to an unpacked chart directory
|
- path to an unpacked chart directory.
|
||||||
- absolute URL
|
- absolute URL.
|
||||||
- Required when I(release_state) is set to C(present)
|
- Required when I(release_state) is set to C(present).
|
||||||
required: false
|
required: false
|
||||||
type: path
|
type: path
|
||||||
chart_repo_url:
|
chart_repo_url:
|
||||||
description:
|
description:
|
||||||
- Chart repository URL where to locate the requested chart
|
- Chart repository URL where to locate the requested chart.
|
||||||
required: false
|
required: false
|
||||||
type: str
|
type: str
|
||||||
chart_repo_username:
|
chart_repo_username:
|
||||||
description:
|
description:
|
||||||
- Chart repository username where to locate the requested chart
|
- Chart repository username where to locate the requested chart.
|
||||||
- Required if I(chart_repo_password) is specified
|
- Required if I(chart_repo_password) is specified.
|
||||||
required: false
|
required: false
|
||||||
type: str
|
type: str
|
||||||
chart_repo_password:
|
chart_repo_password:
|
||||||
description:
|
description:
|
||||||
- Chart repository password where to locate the requested chart
|
- Chart repository password where to locate the requested chart.
|
||||||
- Required if I(chart_repo_username) is specified
|
- Required if I(chart_repo_username) is specified.
|
||||||
required: false
|
required: false
|
||||||
type: str
|
type: str
|
||||||
chart_version:
|
chart_version:
|
||||||
description:
|
description:
|
||||||
- Chart version to install. If this is not specified, the latest version is installed
|
- Chart version to install. If this is not specified, the latest version is installed.
|
||||||
required: false
|
required: false
|
||||||
type: str
|
type: str
|
||||||
release_name:
|
release_name:
|
||||||
description:
|
description:
|
||||||
- Release name to manage
|
- Release name to manage.
|
||||||
required: true
|
required: true
|
||||||
type: str
|
type: str
|
||||||
aliases: [ name ]
|
aliases: [ name ]
|
||||||
release_namespace:
|
release_namespace:
|
||||||
description:
|
description:
|
||||||
- Kubernetes namespace where the chart should be installed
|
- Kubernetes namespace where the chart should be installed.
|
||||||
- Can't be changed with helm 2
|
- Can't be changed with helm 2.
|
||||||
default: "default"
|
required: true
|
||||||
required: false
|
|
||||||
type: str
|
type: str
|
||||||
aliases: [ namespace ]
|
aliases: [ namespace ]
|
||||||
release_state:
|
release_state:
|
||||||
choices: ['present', 'absent']
|
choices: ['present', 'absent']
|
||||||
description:
|
description:
|
||||||
- Desirated state of release
|
- Desirated state of release.
|
||||||
required: false
|
required: false
|
||||||
default: present
|
default: present
|
||||||
aliases: [ state ]
|
aliases: [ state ]
|
||||||
type: str
|
type: str
|
||||||
release_values:
|
release_values:
|
||||||
description:
|
description:
|
||||||
- Value to pass to chart
|
- Value to pass to chart.
|
||||||
required: false
|
required: false
|
||||||
default: {}
|
default: {}
|
||||||
aliases: [ values ]
|
aliases: [ values ]
|
||||||
type: dict
|
type: dict
|
||||||
tiller_host:
|
tiller_host:
|
||||||
description:
|
description:
|
||||||
- Address of Tiller
|
- Address of Tiller.
|
||||||
- Ignored when is helm 3
|
- Ignored when is helm 3.
|
||||||
type: str
|
type: str
|
||||||
tiller_namespace:
|
tiller_namespace:
|
||||||
description:
|
description:
|
||||||
- Namespace of Tiller
|
- Namespace of Tiller.
|
||||||
- Ignored when is helm 3
|
- Ignored when is helm 3.
|
||||||
default: "kube-system"
|
default: "kube-system"
|
||||||
type: str
|
type: str
|
||||||
update_repo_cache:
|
update_repo_cache:
|
||||||
@@ -109,36 +107,36 @@ options:
|
|||||||
#Helm options
|
#Helm options
|
||||||
disable_hook:
|
disable_hook:
|
||||||
description:
|
description:
|
||||||
- Helm option to disable hook on install/upgrade/delete
|
- Helm option to disable hook on install/upgrade/delete.
|
||||||
default: False
|
default: False
|
||||||
type: bool
|
type: bool
|
||||||
force:
|
force:
|
||||||
description:
|
description:
|
||||||
- Helm option to force reinstall, ignore on new install
|
- Helm option to force reinstall, ignore on new install.
|
||||||
default: False
|
default: False
|
||||||
type: bool
|
type: bool
|
||||||
kube_context:
|
kube_context:
|
||||||
description:
|
description:
|
||||||
- Helm option to specify which kubeconfig context to use
|
- Helm option to specify which kubeconfig context to use.
|
||||||
type: str
|
type: str
|
||||||
kubeconfig_path:
|
kubeconfig_path:
|
||||||
description:
|
description:
|
||||||
- Helm option to specify kubeconfig path to use
|
- Helm option to specify kubeconfig path to use.
|
||||||
type: path
|
type: path
|
||||||
aliases: [ kubeconfig ]
|
aliases: [ kubeconfig ]
|
||||||
purge:
|
purge:
|
||||||
description:
|
description:
|
||||||
- Remove the release from the store and make its name free for later use
|
- Remove the release from the store and make its name free for later use.
|
||||||
default: True
|
default: True
|
||||||
type: bool
|
type: bool
|
||||||
wait:
|
wait:
|
||||||
description:
|
description:
|
||||||
- Wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment are in a ready state before marking the release as successful
|
- Wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment are in a ready state before marking the release as successful.
|
||||||
default: False
|
default: False
|
||||||
type: bool
|
type: bool
|
||||||
wait_timeout:
|
wait_timeout:
|
||||||
description:
|
description:
|
||||||
- Timeout when wait option is enabled (helm2 is a number of seconds, helm3 is a duration)
|
- Timeout when wait option is enabled (helm2 is a number of seconds, helm3 is a duration).
|
||||||
type: str
|
type: str
|
||||||
'''
|
'''
|
||||||
|
|
||||||
@@ -240,13 +238,16 @@ command:
|
|||||||
sample: helm upgrade ...
|
sample: helm upgrade ...
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import traceback
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import yaml
|
import yaml
|
||||||
HAS_YAML = True
|
IMP_YAML = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
HAS_YAML = False
|
IMP_YAML_ERR = traceback.format_exc()
|
||||||
|
IMP_YAML = False
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||||
|
|
||||||
module = None
|
module = None
|
||||||
is_helm_2 = True
|
is_helm_2 = True
|
||||||
@@ -296,7 +297,7 @@ def get_values(command, release_name, release_namespace):
|
|||||||
|
|
||||||
# Helm 3 return "null" string when no values are set
|
# Helm 3 return "null" string when no values are set
|
||||||
if not is_helm_2 and out.rstrip("\n") == "null":
|
if not is_helm_2 and out.rstrip("\n") == "null":
|
||||||
return yaml.safe_load('{}')
|
return {}
|
||||||
else:
|
else:
|
||||||
return yaml.safe_load(out)
|
return yaml.safe_load(out)
|
||||||
|
|
||||||
@@ -399,7 +400,7 @@ def deploy(command, release_name, release_namespace, release_values, chart_name,
|
|||||||
try:
|
try:
|
||||||
import tempfile
|
import tempfile
|
||||||
except ImportError:
|
except ImportError:
|
||||||
module.fail_json(msg="Could not import the tempfile python module. Please install `tempfile` package.")
|
module.fail_json(msg=missing_required_lib("tempfile"), exception=traceback.format_exc())
|
||||||
|
|
||||||
fd, path = tempfile.mkstemp(suffix='.yml')
|
fd, path = tempfile.mkstemp(suffix='.yml')
|
||||||
with open(path, 'w') as yaml_file:
|
with open(path, 'w') as yaml_file:
|
||||||
@@ -454,7 +455,7 @@ def main():
|
|||||||
chart_repo_password=dict(type='str', no_log=True),
|
chart_repo_password=dict(type='str', no_log=True),
|
||||||
chart_version=dict(type='str'),
|
chart_version=dict(type='str'),
|
||||||
release_name=dict(type='str', required=True, aliases=['name']),
|
release_name=dict(type='str', required=True, aliases=['name']),
|
||||||
release_namespace=dict(type='str', default='default', aliases=['namespace']),
|
release_namespace=dict(type='str', required=True, aliases=['namespace']),
|
||||||
release_state=dict(default='present', choices=['present', 'absent'], aliases=['state']),
|
release_state=dict(default='present', choices=['present', 'absent'], aliases=['state']),
|
||||||
release_values=dict(type='dict', default={}, aliases=['values']),
|
release_values=dict(type='dict', default={}, aliases=['values']),
|
||||||
tiller_host=dict(type='str'),
|
tiller_host=dict(type='str'),
|
||||||
@@ -481,8 +482,9 @@ def main():
|
|||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
if not HAS_YAML:
|
if not IMP_YAML:
|
||||||
module.fail_json(msg="Could not import the yaml python module. Please install `yaml` package.")
|
module.fail_json(msg=missing_required_lib("yaml"), exception=IMP_YAML_ERR)
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
|
|
||||||
bin_path = module.params.get('binary_path')
|
bin_path = module.params.get('binary_path')
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ module: helm_cli_info
|
|||||||
short_description: Get informations from Helm package deployed inside the cluster
|
short_description: Get informations from Helm package deployed inside the cluster
|
||||||
description:
|
description:
|
||||||
- Get informations (values, states, ...) from Helm package deployed inside the cluster
|
- Get informations (values, states, ...) from Helm package deployed inside the cluster
|
||||||
version_added: "2.10"
|
|
||||||
author:
|
author:
|
||||||
- Lucas Boisserie (@LucasBoisserie)
|
- Lucas Boisserie (@LucasBoisserie)
|
||||||
requirements:
|
requirements:
|
||||||
@@ -30,38 +29,37 @@ options:
|
|||||||
type: path
|
type: path
|
||||||
release_name:
|
release_name:
|
||||||
description:
|
description:
|
||||||
- Release name to manage
|
- Release name to manage.
|
||||||
required: true
|
required: true
|
||||||
type: str
|
type: str
|
||||||
aliases: [ name ]
|
aliases: [ name ]
|
||||||
release_namespace:
|
release_namespace:
|
||||||
description:
|
description:
|
||||||
- Kubernetes namespace where the chart should be installed
|
- Kubernetes namespace where the chart should be installed.
|
||||||
- Can't be changed with helm 2
|
- Can't be changed with helm 2.
|
||||||
default: "default"
|
required: true
|
||||||
required: false
|
|
||||||
type: str
|
type: str
|
||||||
aliases: [ namespace ]
|
aliases: [ namespace ]
|
||||||
tiller_host:
|
tiller_host:
|
||||||
description:
|
description:
|
||||||
- Address of Tiller
|
- Address of Tiller.
|
||||||
- Ignored when is helm 3
|
- Ignored when is helm 3.
|
||||||
type: str
|
type: str
|
||||||
tiller_namespace:
|
tiller_namespace:
|
||||||
description:
|
description:
|
||||||
- Namespace of Tiller
|
- Namespace of Tiller.
|
||||||
- Ignored when is helm 3
|
- Ignored when is helm 3.
|
||||||
default: "kube-system"
|
default: "kube-system"
|
||||||
type: str
|
type: str
|
||||||
|
|
||||||
#Helm options
|
#Helm options
|
||||||
kube_context:
|
kube_context:
|
||||||
description:
|
description:
|
||||||
- Helm option to specify which kubeconfig context to use
|
- Helm option to specify which kubeconfig context to use.
|
||||||
type: str
|
type: str
|
||||||
kubeconfig_path:
|
kubeconfig_path:
|
||||||
description:
|
description:
|
||||||
- Helm option to specify kubeconfig path to use
|
- Helm option to specify kubeconfig path to use.
|
||||||
type: path
|
type: path
|
||||||
aliases: [ kubeconfig ]
|
aliases: [ kubeconfig ]
|
||||||
'''
|
'''
|
||||||
@@ -120,13 +118,16 @@ status:
|
|||||||
description: Dict of Values used to deploy
|
description: Dict of Values used to deploy
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import traceback
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import yaml
|
import yaml
|
||||||
HAS_YAML = True
|
IMP_YAML = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
HAS_YAML = False
|
IMP_YAML_ERR = traceback.format_exc()
|
||||||
|
IMP_YAML = False
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||||
|
|
||||||
module = None
|
module = None
|
||||||
is_helm_2 = True
|
is_helm_2 = True
|
||||||
@@ -235,7 +236,7 @@ def main():
|
|||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
binary_path=dict(type='path'),
|
binary_path=dict(type='path'),
|
||||||
release_name=dict(type='str', required=True, aliases=['name']),
|
release_name=dict(type='str', required=True, aliases=['name']),
|
||||||
release_namespace=dict(type='str', default='default', aliases=['namespace']),
|
release_namespace=dict(type='str', required=True, aliases=['namespace']),
|
||||||
tiller_host=dict(type='str'),
|
tiller_host=dict(type='str'),
|
||||||
tiller_namespace=dict(type='str', default='kube-system'),
|
tiller_namespace=dict(type='str', default='kube-system'),
|
||||||
|
|
||||||
@@ -245,8 +246,9 @@ def main():
|
|||||||
),
|
),
|
||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
)
|
)
|
||||||
if not HAS_YAML:
|
|
||||||
module.fail_json(msg="Could not import the yaml python module. Please install `yaml` package.")
|
if not IMP_YAML:
|
||||||
|
module.fail_json(msg=missing_required_lib("yaml"), exception=IMP_YAML_ERR)
|
||||||
|
|
||||||
bin_path = module.params.get('binary_path')
|
bin_path = module.params.get('binary_path')
|
||||||
release_name = module.params.get('release_name')
|
release_name = module.params.get('release_name')
|
||||||
|
|||||||
Reference in New Issue
Block a user