Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge upstream #3

Merged
merged 127 commits into from
Sep 18, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
a23d454
Add failing test for service in check mode
willthames May 4, 2020
34137c4
Fix apply patching results in check mode
willthames May 4, 2020
f45d332
Remove ANSIBLE_METADATA
orjan May 14, 2020
4e40ac3
Merge pull request #95 from orjan/91-remove-metadata
geerlingguy May 14, 2020
3e60cca
Fixes #96: Sanity test finds incorrect deprecated usage.
geerlingguy May 14, 2020
600fa44
Merge pull request #97 from geerlingguy/96-sanity-deprecated
geerlingguy May 14, 2020
aad3ec7
Add version_added to docs for each of the new collection modules.
geerlingguy May 14, 2020
8e9093c
Merge pull request #98 from geerlingguy/92-verison-added
geerlingguy May 14, 2020
35ffd0e
Improve k8s Deployment and Daemonset wait conditions
willthames May 4, 2020
9ccec43
Merge pull request #84 from willthames/k8s_apply_check_mode_fix
fabianvf May 15, 2020
e7736cb
Don't run project coverage on patches
willthames May 19, 2020
8aea1b6
Merge pull request #102 from willthames/remove_coverage_failure_check
geerlingguy May 19, 2020
2f7b552
Merge pull request #35 from willthames/wait_conditions
fabianvf May 19, 2020
d9ece47
Fix the docs for the inventory plugins.
abadger May 20, 2020
00200cf
Add test for openshift apply bug
willthames May 21, 2020
a519cee
Merge pull request #103 from abadger/fix-docs
geerlingguy May 21, 2020
3bdfb47
Merge pull request #94 from willthames/apply_nested_dict
fabianvf May 21, 2020
beebe98
Fix scale wait and add tests
willthames May 22, 2020
5aed266
Update setup-kind action to 0.4.0
willthames May 22, 2020
aa70416
Fix scale wait and add tests
willthames May 29, 2020
1ed3b65
Merge pull request #100 from willthames/scale_improvements
geerlingguy May 29, 2020
b46a5ee
Add action groups for playbooks with module_defaults (#107)
s-hertel May 30, 2020
641fbd9
helm: minor code refactoring
Akasurde Jun 1, 2020
86a2420
Add helm and extra k8s modules to action_groups config. (#112)
geerlingguy Jun 2, 2020
9a95269
Minor documentation fix (#113)
Akasurde Jun 2, 2020
01399ea
Merge pull request #110 from Akasurde/helm_fix
fabianvf Jun 4, 2020
3078131
Minor doc fixes (#114)
Akasurde Jun 5, 2020
c8ef0ae
Minor refactor in helm_info and helm_repository (#117)
Akasurde Jun 5, 2020
18dfb68
Handle set object retrieved from lookup plugin (#118)
Akasurde Jun 5, 2020
4b7db6f
Use improved kubernetes diffs where possible
willthames May 27, 2020
1fb38fa
Add setup.cfg
willthames Jun 9, 2020
5934806
F401: Remove unused imports
willthames Jun 9, 2020
43ae966
W504 Move binary operator to start of line from end of line
willthames Jun 9, 2020
510a069
F841 remove unused variables
willthames Jun 9, 2020
61c3372
Turn on flake8 checks in molecule tests
willthames Jun 9, 2020
cdeab63
Merge pull request #105 from willthames/improve_diffs
fabianvf Jun 9, 2020
e55053c
Issue #125: Add requires_ansible version constraints to runtime.yml.
geerlingguy Jun 10, 2020
e3f138a
Remove action_groups_redirection entry from meta/runtime.yml
s-hertel Jun 10, 2020
6588706
Merge pull request #127 from s-hertel/remove_unused_field
geerlingguy Jun 13, 2020
0e92889
Merge pull request #123 from willthames/flake8
geerlingguy Jun 15, 2020
3004c8d
Handle invalid kubeconfig parsing error (#119)
Akasurde Jun 16, 2020
9d46d7b
Merge pull request #126 from geerlingguy/125-requires-ansible
geerlingguy Jun 16, 2020
c3796da
Fixes #129: Add 2.11 sanity ignore file.
geerlingguy Jun 16, 2020
a9aab12
Merge pull request #130 from geerlingguy/129-2-11-sanity-ignore
geerlingguy Jun 16, 2020
5b70464
helm: Add option 'atomic'
Akasurde Jun 18, 2020
e6773fd
Merge pull request #115 from Akasurde/i109
geerlingguy Jun 18, 2020
e80e3fa
Issue #40: Add changelog and fragments and document new changelog pro…
geerlingguy Jun 16, 2020
2dd81d6
Issue #40: Fix YAML lint issues from changelog configs.
geerlingguy Jun 16, 2020
49e25c8
Issue #40: gitignore the .plugin-cache.yml file.
geerlingguy Jun 17, 2020
938b019
Issue #40: Generate CHANGELOG.rst in root dir.
geerlingguy Jun 17, 2020
d3dc3e2
Issue #40: Manually override module namespace so extra info isn't out…
geerlingguy Jun 17, 2020
8674a44
Issue #40: Add PR and issue refs to fragments, and update CHANGELOG.rst.
geerlingguy Jun 22, 2020
10b332d
Merge pull request #131 from geerlingguy/40-changelogs
geerlingguy Jun 22, 2020
9fb808c
k8s: Fix a bug when manifest file ends with '---' (#139)
Akasurde Jun 24, 2020
881ca3d
Fixes #145: Use FQCN in module docs and in plugin examples.
geerlingguy Jun 29, 2020
4ffe372
Merge pull request #146 from geerlingguy/145-fqcn
geerlingguy Jul 1, 2020
efcf870
Release 0.11.1 prep - add missing changelog fragments.
geerlingguy Jul 1, 2020
cc7d6af
Prepare for release 0.11.1.
geerlingguy Jul 1, 2020
7056800
Merge pull request #149 from geerlingguy/release-0-11-1
geerlingguy Jul 1, 2020
ef6722d
helm: Add support for K8S_AUTH_CONTEXT, K8S_AUTH_KUBECONFIG env (#141)
Akasurde Jul 2, 2020
48a45de
helm_: Add context aliases for kube_context
Akasurde Jul 6, 2020
9aa85e8
Update openshift requirements in k8s module doc
yselkowitz Jul 6, 2020
2e86b56
Merge pull request #153 from multi-arch/master
fabianvf Jul 6, 2020
e3223a8
Ensure check mode results are as expected
willthames Jul 8, 2020
dd4ebf2
Merge pull request #152 from Akasurde/context_aliases
fabianvf Jul 10, 2020
806c808
Merge pull request #155 from willthames/check_mode_results
fabianvf Jul 10, 2020
3e971e0
Create ns with helm (#157)
LucasBoisserie Jul 11, 2020
6b28ef3
kubectl: redacted token and password from console log (#159)
Akasurde Jul 11, 2020
c4f3e5a
k8s_info: Update example using vars (#156)
Akasurde Jul 13, 2020
a16ac42
Issue #148: Switch links and CI process to main from master branch.
geerlingguy Jul 17, 2020
6d2567b
Fixes #167: Re-order ansible installation so it doesn't break on mole…
geerlingguy Jul 20, 2020
4a2b1b9
Issue #167: Make yamllint less bothersome and install ansible-base in…
geerlingguy Jul 20, 2020
f4f4ec6
Issue #167: More fixes, oops.
geerlingguy Jul 20, 2020
6c059bd
helm_plugin and helm_plugin_info: new module (#154)
Akasurde Jul 22, 2020
3aaf182
k8s_exec: Return rc for the command executed (#158)
Akasurde Jul 23, 2020
9c0f7fe
Issue #167: Attempt installing ansible's stable-2.10 branch.
geerlingguy Jul 23, 2020
bab4e38
Issue #167: Install ansible-base via pip with --pre.
geerlingguy Jul 23, 2020
0473ac9
Issue #167: Try Ansible's stable release.
geerlingguy Jul 23, 2020
85e6ccc
Merge pull request #168 from geerlingguy/167-fix-ci
geerlingguy Jul 23, 2020
9f099a4
Update docs links in README for plugins.
geerlingguy Jul 23, 2020
cfcdf4a
Issue #165: Add plugin_routing information for deprecated plugins.
geerlingguy Jul 20, 2020
8bf59c5
Merge pull request #166 from geerlingguy/165-plugin-routing
geerlingguy Jul 23, 2020
1f3d123
Merge pull request #172 from geerlingguy/docs-links
geerlingguy Jul 23, 2020
b51bbdf
Issue #171: Update changelog fragments for 1.0.0 release.
geerlingguy Jul 28, 2020
1ef28bc
Issue #171: Update changelog and make sure things are ready for 1.0.0…
geerlingguy Jul 28, 2020
81494e2
Issue #171: Update fragment for PR #152 to include link.
geerlingguy Jul 28, 2020
e29d4f1
Issue #171: Add links for new modules in README.
geerlingguy Jul 28, 2020
f38cae3
Merge pull request #173 from geerlingguy/1-0-0-release
geerlingguy Jul 28, 2020
666b75e
Fix typo in Readme. (#182)
geerlingguy Aug 6, 2020
4f33ba7
raw: Handle exception raised by underlying APIs (#180)
Akasurde Aug 11, 2020
f58e648
Add contrib page
Akasurde Aug 12, 2020
4eea323
Issue #43: Update README to reflect new Zuul automated tag build and …
geerlingguy Aug 18, 2020
d3dd21b
Merge pull request #191 from Akasurde/contrib
geerlingguy Aug 18, 2020
7acd460
Issue #53: Add probot/stale bot configuration to ID and close stale i…
geerlingguy Aug 18, 2020
ab77b79
k8s_info: Update documentation
Akasurde Aug 24, 2020
fec3d17
Merge pull request #196 from geerlingguy/53-probot-stale
fabianvf Aug 24, 2020
2d50bb0
Merge pull request #203 from Akasurde/k8s_info
fabianvf Aug 24, 2020
b4a3ef3
Merge pull request #194 from geerlingguy/43-zuul-new-versions
geerlingguy Aug 25, 2020
d39fcfc
k8s_*: Add support for vaulted kubeconfig and src (#193)
Akasurde Aug 26, 2020
16059a8
k8s_*: Group argument_spec accroding to usage (#199)
Akasurde Aug 26, 2020
3885eb1
add Makefile, downstream build script, enable CI for downstream
maxamillion Aug 18, 2020
5f34d84
PR #196 follow-up: Adjust stale bot exemptLabels.
geerlingguy Aug 26, 2020
f9fc0f7
fix README, use Makefile everywhere
maxamillion Aug 26, 2020
b5eba33
fix makefile
maxamillion Aug 26, 2020
f205348
fix downstream molecule tests
maxamillion Aug 26, 2020
ec74038
need flake8 setup.cfg for downstream tests also
maxamillion Aug 26, 2020
1c5a8fd
Set the connection plugin and transport separately, add tests
fabianvf Aug 26, 2020
8c7ea12
only test downstream against Ansible 2.9.x
maxamillion Aug 26, 2020
20bd37f
Merge pull request #206 from geerlingguy/stale-exempt-labels
geerlingguy Aug 27, 2020
604cae9
Merge pull request #197 from maxamillion/downstream_build
geerlingguy Aug 27, 2020
91c1621
Merge pull request #208 from fabianvf/inventory_set_connection_plugin
fabianvf Aug 27, 2020
8278073
fix CI tests, helm picked up the same argspec addition as some k8s mo…
maxamillion Aug 28, 2020
e9d8bf7
Merge pull request #210 from maxamillion/heml/fix_sanity_tests
geerlingguy Aug 28, 2020
d17858c
fix downstream ci names
maxamillion Aug 28, 2020
c6fe654
Merge pull request #212 from maxamillion/downstream/fix_ci_round_2
geerlingguy Aug 28, 2020
23f9588
kubectl: correct usage in console (#204)
Akasurde Aug 31, 2020
60c762b
fix downstream collection name kubernetes.base -> kubernetes.core (#213)
maxamillion Aug 31, 2020
c49f896
helm: Add replace parameter (#214)
Akasurde Sep 7, 2020
ffb7032
handle exception raised due to DynamicClient
Akasurde Sep 7, 2020
527859c
Refactor module_utils (#223)
Akasurde Sep 8, 2020
0afe40e
Do not mark task as changed when diff is irrelevant
fabianvf Sep 14, 2020
f2b1b26
helm: Support vaulted kubeconfig
Akasurde Sep 15, 2020
571406c
Merge pull request #224 from Akasurde/handle_exc
fabianvf Sep 15, 2020
1ea0fa1
Merge pull request #229 from Akasurde/helm_kubeconfig_fix
fabianvf Sep 15, 2020
28dcf76
Merge pull request #228 from fabianvf/ignore-diff-with-warning
fabianvf Sep 15, 2020
51cadb7
Replace KubernetesAnsibleModule class with dummy class (#227)
Akasurde Sep 16, 2020
46fdbe0
Merge remote-tracking branch 'upstream/main' into merge-upstream
shaunsmiley-xevo Sep 18, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
helm: Add replace parameter (ansible-collections#214)
Fixes: ansible-collections#106

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
  • Loading branch information
Akasurde authored Sep 7, 2020
commit c49f896fa089c689d1344f8599c461dc982a7a6e
2 changes: 2 additions & 0 deletions changelogs/fragments/106-helm_replace.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- helm - add replace parameter (https://github.com/ansible-collections/community.kubernetes/issues/106).
57 changes: 57 additions & 0 deletions molecule/default/roles/helm/tasks/tests_chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,63 @@
that:
- install is not changed

# Test --replace
- name: Install chart for replace option
helm:
binary_path: "{{ helm_binary }}"
name: test-0001
chart_ref: "{{ chart_source }}"
chart_version: "{{ chart_source_version | default(omit) }}"
namespace: "{{ helm_namespace }}"
register: install

- name: "Assert that {{ chart_test }} chart is installed from {{ source }}"
assert:
that:
- install is changed

- name: Remove {{ chart_test }} with --purge
helm:
binary_path: "{{ helm_binary }}"
state: absent
name: test-0001
purge: False
namespace: "{{ helm_namespace }}"
register: install

- name: Check if chart is removed
assert:
that:
- install is changed

- name: Install chart again with same name test-0001
helm:
binary_path: "{{ helm_binary }}"
name: test-0001
chart_ref: "{{ chart_source }}"
chart_version: "{{ chart_source_version | default(omit) }}"
namespace: "{{ helm_namespace }}"
replace: True
register: install

- name: "Assert that {{ chart_test }} chart is installed from {{ source }}"
assert:
that:
- install is changed

- name: Remove {{ chart_test }} (cleanup)
helm:
binary_path: "{{ helm_binary }}"
state: absent
name: test-0001
namespace: "{{ helm_namespace }}"
register: install

- name: Check if chart is removed
assert:
that:
- install is changed

- name: Remove helm namespace
k8s:
api_version: v1
Expand Down
35 changes: 29 additions & 6 deletions plugins/modules/helm.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@
type: bool
default: False
version_added: "0.11.1"
replace:
description:
- Reuse the given name, only if that name is a deleted release which remains in the history.
- This is unsafe in production environment.
type: bool
default: False
version_added: "1.11.0"
extends_documentation_fragment:
- community.kubernetes.helm_common_options
'''
Expand Down Expand Up @@ -320,14 +327,20 @@ def fetch_chart_info(command, chart_ref):
return yaml.safe_load(out)


def deploy(command, release_name, release_values, chart_name, wait, wait_timeout, disable_hook, force, atomic=False, create_namespace=False):
def deploy(command, release_name, release_values, chart_name, wait,
wait_timeout, disable_hook, force, atomic=False, create_namespace=False,
replace=False):
"""
Install/upgrade/rollback release chart
"""
deploy_command = command + " upgrade -i" # install/upgrade
if replace:
# '--replace' is not supported by 'upgrade -i'
deploy_command = command + " install"
else:
deploy_command = command + " upgrade -i" # install/upgrade

# Always reset values to keep release_values equal to values released
deploy_command += " --reset-values"
# Always reset values to keep release_values equal to values released
deploy_command += " --reset-values"

if wait:
deploy_command += " --wait"
Expand All @@ -340,6 +353,9 @@ def deploy(command, release_name, release_values, chart_name, wait, wait_timeout
if force:
deploy_command += " --force"

if replace:
deploy_command += " --replace"

if disable_hook:
deploy_command += " --no-hooks"

Expand Down Expand Up @@ -399,6 +415,7 @@ def main():
wait_timeout=dict(type='str'),
atomic=dict(type='bool', default=False),
create_namespace=dict(type='bool', default=False),
replace=dict(type='bool', default=False),
),
required_if=[
('release_state', 'present', ['release_name', 'chart_ref']),
Expand Down Expand Up @@ -432,6 +449,7 @@ def main():
wait_timeout = module.params.get('wait_timeout')
atomic = module.params.get('atomic')
create_namespace = module.params.get('create_namespace')
replace = module.params.get('replace')

if bin_path is not None:
helm_cmd_common = bin_path
Expand All @@ -455,6 +473,9 @@ def main():
# keep helm_cmd_common for get_release_status in module_exit_json
helm_cmd = helm_cmd_common
if release_state == "absent" and release_status is not None:
if replace:
module.fail_json(msg="replace is not applicable when state is absent")

helm_cmd = delete(helm_cmd, release_name, purge, disable_hook)
changed = True
elif release_state == "present":
Expand All @@ -470,13 +491,15 @@ def main():

if release_status is None: # Not installed
helm_cmd = deploy(helm_cmd, release_name, release_values, chart_ref, wait, wait_timeout,
disable_hook, False, atomic=atomic, create_namespace=create_namespace)
disable_hook, False, atomic=atomic, create_namespace=create_namespace,
replace=replace)
changed = True

elif force or release_values != release_status['values'] \
or (chart_info['name'] + '-' + chart_info['version']) != release_status["chart"]:
helm_cmd = deploy(helm_cmd, release_name, release_values, chart_ref, wait, wait_timeout,
disable_hook, force, atomic=atomic, create_namespace=create_namespace)
disable_hook, force, atomic=atomic, create_namespace=create_namespace,
replace=replace)
changed = True

if module.check_mode:
Expand Down