Skip to content

Commit

Permalink
Improve Ansible 2.9 compatibility (#306)
Browse files Browse the repository at this point in the history
* Adjust ignore-2.9.txt.

* Workaround for load_file_common_arguments's path option (similar to ansible-collections/community.crypto#14).

* Add changelog.
  • Loading branch information
felixfontein authored May 8, 2020
1 parent 5cdb646 commit 85cbc27
Show file tree
Hide file tree
Showing 5 changed files with 441 additions and 2,439 deletions.
4 changes: 4 additions & 0 deletions changelogs/fragments/306-ansible-2.9-compatibility.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bugfixes:
- "archive - make module compatible with older Ansible versions (https://github.com/ansible-collections/community.general/pull/306)."
- "maven_artifact - make module compatible with older Ansible versions (https://github.com/ansible-collections/community.general/pull/306)."
- "java_keystore - make module compatible with older Ansible versions (https://github.com/ansible-collections/community.general/pull/306)."
8 changes: 7 additions & 1 deletion plugins/modules/files/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,13 @@ def main():
msg='Unable to remove source file: %s' % to_native(e), exception=format_exc()
)

file_args = module.load_file_common_arguments(params, path=b_dest)
try:
file_args = module.load_file_common_arguments(params, path=b_dest)
except TypeError:
# The path argument is only supported in Ansible 2.10+. Fall back to
# pre-2.10 behavior for older Ansible versions.
params['path'] = b_dest
file_args = module.load_file_common_arguments(params)

if not check_mode:
changed = module.set_fs_attributes_if_different(file_args, changed)
Expand Down
8 changes: 7 additions & 1 deletion plugins/modules/packaging/language/maven_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,13 @@ def main():
except ValueError as e:
module.fail_json(msg=e.args[0])

file_args = module.load_file_common_arguments(module.params, path=dest)
try:
file_args = module.load_file_common_arguments(module.params, path=dest)
except TypeError:
# The path argument is only supported in Ansible 2.10+. Fall back to
# pre-2.10 behavior for older Ansible versions.
module.params['path'] = dest
file_args = module.load_file_common_arguments(module.params)
changed = module.set_fs_attributes_if_different(file_args, changed)
if changed:
module.exit_json(state=state, dest=dest, group_id=group_id, artifact_id=artifact_id, version=version, classifier=classifier,
Expand Down
8 changes: 7 additions & 1 deletion plugins/modules/system/java_keystore.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,13 @@ def create_jks(module, name, openssl_bin, keytool_bin, keystore_path, password):


def update_jks_perm(module, keystore_path):
file_args = module.load_file_common_arguments(module.params, path=keystore_path)
try:
file_args = module.load_file_common_arguments(module.params, path=keystore_path)
except TypeError:
# The path argument is only supported in Ansible 2.10+. Fall back to
# pre-2.10 behavior for older Ansible versions.
module.params['path'] = keystore_path
file_args = module.load_file_common_arguments(module.params)
module.set_fs_attributes_if_different(file_args, False)


Expand Down
Loading

0 comments on commit 85cbc27

Please sign in to comment.