From 524fdf234bcf34874b70b40fa2f787f72d0d8c98 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Wed, 2 Nov 2022 22:30:02 +0100 Subject: [PATCH 0001/1810] The next expected release is 6.0.0. --- galaxy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/galaxy.yml b/galaxy.yml index b77ecfa020..0a3fe09b6e 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -5,7 +5,7 @@ namespace: community name: general -version: 6.0.0-a1 +version: 6.0.0 readme: README.md authors: - Ansible (https://github.com/ansible) From c181f2dd08ed7711cbac620b868ec3f1ec7584e0 Mon Sep 17 00:00:00 2001 From: Guillaume MARTINEZ Date: Thu, 3 Nov 2022 06:45:37 +0100 Subject: [PATCH 0002/1810] [Scaleway] Fix function namespace integration tests assertions (#5464) Signed-off-by: Lunik Signed-off-by: Lunik --- .../targets/scaleway_function_namespace/tasks/main.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/integration/targets/scaleway_function_namespace/tasks/main.yml b/tests/integration/targets/scaleway_function_namespace/tasks/main.yml index e760a4c7fa..78b7c95757 100644 --- a/tests/integration/targets/scaleway_function_namespace/tasks/main.yml +++ b/tests/integration/targets/scaleway_function_namespace/tasks/main.yml @@ -145,7 +145,7 @@ name: '{{ name }}' region: '{{ scaleway_region }}' project_id: '{{ scw_project }}' - description: '{{ description }}' + description: '{{ updated_description }}' environment_variables: '{{ environment_variables }}' secret_environment_variables: '{{ updated_secret_environment_variables }}' register: fn_update_secret_check_task @@ -165,7 +165,7 @@ name: '{{ name }}' region: '{{ scaleway_region }}' project_id: '{{ scw_project }}' - description: '{{ description }}' + description: '{{ updated_description }}' environment_variables: '{{ environment_variables }}' secret_environment_variables: '{{ updated_secret_environment_variables }}' register: fn_update_secret_task @@ -179,7 +179,7 @@ - fn_update_secret_task is success - fn_update_secret_task is changed - fn_update_secret_task.function_namespace.status == "ready" - - "'hashed_value' in fn_creation_task.function_namespace.secret_environment_variables[0]" + - "'hashed_value' in fn_update_secret_task.function_namespace.secret_environment_variables[0]" - name: Update function namespace secret variables (Confirmation) community.general.scaleway_function_namespace: @@ -187,7 +187,7 @@ name: '{{ name }}' region: '{{ scaleway_region }}' project_id: '{{ scw_project }}' - description: '{{ description }}' + description: '{{ updated_description }}' environment_variables: '{{ environment_variables }}' secret_environment_variables: '{{ updated_secret_environment_variables }}' register: fn_update_secret_confirmation_task @@ -201,7 +201,7 @@ - fn_update_secret_confirmation_task is success - fn_update_secret_confirmation_task is not changed - fn_update_secret_confirmation_task.function_namespace.status == "ready" - - "'hashed_value' in fn_creation_task.function_namespace.secret_environment_variables[0]" + - "'hashed_value' in fn_update_secret_confirmation_task.function_namespace.secret_environment_variables[0]" - name: Delete function namespace (Check) check_mode: yes From 1a97ca1a6f77cabca78d18bfd8a9f46939f11f8a Mon Sep 17 00:00:00 2001 From: Reto Kupferschmid Date: Fri, 4 Nov 2022 07:07:06 +0100 Subject: [PATCH 0003/1810] ldap_attrs: escape ldap search filter (#5435) * escape ldap search filter * move escape to separate line * add changelog fragment * Update changelogs/fragments/5435-escape-ldap-param.yml Co-authored-by: Felix Fontein * fix encoding * fixup! fix encoding Co-authored-by: Felix Fontein --- changelogs/fragments/5435-escape-ldap-param.yml | 2 ++ plugins/modules/ldap_attrs.py | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/5435-escape-ldap-param.yml diff --git a/changelogs/fragments/5435-escape-ldap-param.yml b/changelogs/fragments/5435-escape-ldap-param.yml new file mode 100644 index 0000000000..3f22f61759 --- /dev/null +++ b/changelogs/fragments/5435-escape-ldap-param.yml @@ -0,0 +1,2 @@ +bugfixes: + - ldap_attrs - fix bug which caused a ``Bad search filter`` error. The error was occuring when the ldap attribute value contained special characters such as ``(`` or ``*`` (https://github.com/ansible-collections/community.general/issues/5434, https://github.com/ansible-collections/community.general/pull/5435). diff --git a/plugins/modules/ldap_attrs.py b/plugins/modules/ldap_attrs.py index 97275c45d5..61ae291956 100644 --- a/plugins/modules/ldap_attrs.py +++ b/plugins/modules/ldap_attrs.py @@ -168,7 +168,7 @@ modlist: import traceback from ansible.module_utils.basic import AnsibleModule, missing_required_lib -from ansible.module_utils.common.text.converters import to_native, to_bytes +from ansible.module_utils.common.text.converters import to_native, to_bytes, to_text from ansible_collections.community.general.plugins.module_utils.ldap import LdapGeneric, gen_specs import re @@ -176,6 +176,7 @@ import re LDAP_IMP_ERR = None try: import ldap + import ldap.filter HAS_LDAP = True except ImportError: @@ -264,7 +265,8 @@ class LdapAttrs(LdapGeneric): def _is_value_present(self, name, value): """ True if the target attribute has the given value. """ try: - filterstr = "(%s=%s)" % (name, value.decode()) + escaped_value = ldap.filter.escape_filter_chars(to_text(value)) + filterstr = "(%s=%s)" % (name, escaped_value) dns = self.connection.search_s(self.dn, ldap.SCOPE_BASE, filterstr) is_present = len(dns) == 1 except ldap.NO_SUCH_OBJECT: From 8dc82b18900619977f3f873fafaa0d940aad7039 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Sat, 5 Nov 2022 23:35:39 +1300 Subject: [PATCH 0004/1810] sorted content of sanity/ignore-*.txt files (#5473) --- tests/sanity/ignore-2.11.txt | 38 +++++++++++++++++----------------- tests/sanity/ignore-2.12.txt | 36 ++++++++++++++++---------------- tests/sanity/ignore-2.13.txt | 36 ++++++++++++++++---------------- tests/sanity/ignore-2.14.txt | 40 ++++++++++++++++++------------------ tests/sanity/ignore-2.15.txt | 40 ++++++++++++++++++------------------ 5 files changed, 95 insertions(+), 95 deletions(-) diff --git a/tests/sanity/ignore-2.11.txt b/tests/sanity/ignore-2.11.txt index 7c555b4722..603981df04 100644 --- a/tests/sanity/ignore-2.11.txt +++ b/tests/sanity/ignore-2.11.txt @@ -1,41 +1,41 @@ -.azure-pipelines/scripts/publish-codecov.py replace-urlopen .azure-pipelines/scripts/publish-codecov.py compile-2.6!skip # Uses Python 3.6+ syntax .azure-pipelines/scripts/publish-codecov.py compile-2.7!skip # Uses Python 3.6+ syntax .azure-pipelines/scripts/publish-codecov.py compile-3.5!skip # Uses Python 3.6+ syntax .azure-pipelines/scripts/publish-codecov.py future-import-boilerplate .azure-pipelines/scripts/publish-codecov.py metaclass-boilerplate -plugins/modules/lxc_container.py validate-modules:use-run-command-not-popen -plugins/modules/lxd_project.py use-argspec-type-path # expanduser() applied to constants -plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice -plugins/modules/rax.py use-argspec-type-path # fix needed -plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice -plugins/modules/rax_files_objects.py use-argspec-type-path -plugins/modules/rax_scaling_group.py use-argspec-type-path # fix needed, expanduser() applied to dict values -plugins/modules/scaleway_organization_info.py validate-modules:return-syntax-error -plugins/modules/spotinst_aws_elastigroup.py validate-modules:parameter-list-no-elements -plugins/modules/spotinst_aws_elastigroup.py validate-modules:parameter-type-not-in-doc -plugins/modules/spotinst_aws_elastigroup.py validate-modules:undocumented-parameter -plugins/modules/udm_share.py validate-modules:parameter-list-no-elements -plugins/modules/udm_user.py validate-modules:parameter-list-no-elements +.azure-pipelines/scripts/publish-codecov.py replace-urlopen plugins/modules/consul.py validate-modules:doc-missing-type plugins/modules/consul.py validate-modules:undocumented-parameter plugins/modules/consul_session.py validate-modules:parameter-state-invalid-choice -plugins/modules/yarn.py use-argspec-type-path -plugins/modules/redhat_subscription.py validate-modules:return-syntax-error +plugins/modules/gconftool2.py validate-modules:parameter-state-invalid-choice +plugins/modules/iptables_state.py validate-modules:undocumented-parameter +plugins/modules/jenkins_plugin.py use-argspec-type-path +plugins/modules/lxc_container.py validate-modules:use-run-command-not-popen +plugins/modules/lxd_project.py use-argspec-type-path # expanduser() applied to constants plugins/modules/manageiq_policies.py validate-modules:parameter-state-invalid-choice plugins/modules/manageiq_provider.py validate-modules:doc-choices-do-not-match-spec # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:doc-missing-type # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:parameter-type-not-in-doc # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:undocumented-parameter # missing docs on suboptions plugins/modules/manageiq_tags.py validate-modules:parameter-state-invalid-choice -plugins/modules/gconftool2.py validate-modules:parameter-state-invalid-choice -plugins/modules/iptables_state.py validate-modules:undocumented-parameter plugins/modules/osx_defaults.py validate-modules:parameter-state-invalid-choice plugins/modules/parted.py validate-modules:parameter-state-invalid-choice plugins/modules/puppet.py use-argspec-type-path plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias - removed in 7.0.0 +plugins/modules/rax_files_objects.py use-argspec-type-path +plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice +plugins/modules/rax.py use-argspec-type-path # fix needed +plugins/modules/rax_scaling_group.py use-argspec-type-path # fix needed, expanduser() applied to dict values +plugins/modules/redhat_subscription.py validate-modules:return-syntax-error +plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice +plugins/modules/scaleway_organization_info.py validate-modules:return-syntax-error +plugins/modules/spotinst_aws_elastigroup.py validate-modules:parameter-list-no-elements +plugins/modules/spotinst_aws_elastigroup.py validate-modules:parameter-type-not-in-doc +plugins/modules/spotinst_aws_elastigroup.py validate-modules:undocumented-parameter plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path +plugins/modules/udm_share.py validate-modules:parameter-list-no-elements +plugins/modules/udm_user.py validate-modules:parameter-list-no-elements plugins/modules/xfconf.py validate-modules:return-syntax-error -plugins/modules/jenkins_plugin.py use-argspec-type-path +plugins/modules/yarn.py use-argspec-type-path tests/integration/targets/django_manage/files/base_test/simple_project/p1/manage.py compile-2.6 # django generated code tests/integration/targets/django_manage/files/base_test/simple_project/p1/manage.py compile-2.7 # django generated code diff --git a/tests/sanity/ignore-2.12.txt b/tests/sanity/ignore-2.12.txt index 53d2d47bd4..778f25ae53 100644 --- a/tests/sanity/ignore-2.12.txt +++ b/tests/sanity/ignore-2.12.txt @@ -1,34 +1,34 @@ .azure-pipelines/scripts/publish-codecov.py replace-urlopen -plugins/modules/lxc_container.py validate-modules:use-run-command-not-popen -plugins/modules/lxd_project.py use-argspec-type-path # expanduser() applied to constants -plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice -plugins/modules/rax.py use-argspec-type-path # fix needed -plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice -plugins/modules/rax_files_objects.py use-argspec-type-path -plugins/modules/rax_scaling_group.py use-argspec-type-path # fix needed, expanduser() applied to dict values -plugins/modules/scaleway_organization_info.py validate-modules:return-syntax-error -plugins/modules/spotinst_aws_elastigroup.py validate-modules:parameter-list-no-elements -plugins/modules/spotinst_aws_elastigroup.py validate-modules:parameter-type-not-in-doc -plugins/modules/spotinst_aws_elastigroup.py validate-modules:undocumented-parameter -plugins/modules/udm_share.py validate-modules:parameter-list-no-elements -plugins/modules/udm_user.py validate-modules:parameter-list-no-elements plugins/modules/consul.py validate-modules:doc-missing-type plugins/modules/consul.py validate-modules:undocumented-parameter plugins/modules/consul_session.py validate-modules:parameter-state-invalid-choice -plugins/modules/yarn.py use-argspec-type-path -plugins/modules/redhat_subscription.py validate-modules:return-syntax-error +plugins/modules/gconftool2.py validate-modules:parameter-state-invalid-choice +plugins/modules/iptables_state.py validate-modules:undocumented-parameter +plugins/modules/jenkins_plugin.py use-argspec-type-path +plugins/modules/lxc_container.py validate-modules:use-run-command-not-popen +plugins/modules/lxd_project.py use-argspec-type-path # expanduser() applied to constants plugins/modules/manageiq_policies.py validate-modules:parameter-state-invalid-choice plugins/modules/manageiq_provider.py validate-modules:doc-choices-do-not-match-spec # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:doc-missing-type # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:parameter-type-not-in-doc # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:undocumented-parameter # missing docs on suboptions plugins/modules/manageiq_tags.py validate-modules:parameter-state-invalid-choice -plugins/modules/gconftool2.py validate-modules:parameter-state-invalid-choice -plugins/modules/iptables_state.py validate-modules:undocumented-parameter plugins/modules/osx_defaults.py validate-modules:parameter-state-invalid-choice plugins/modules/parted.py validate-modules:parameter-state-invalid-choice plugins/modules/puppet.py use-argspec-type-path plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias - removed in 7.0.0 +plugins/modules/rax_files_objects.py use-argspec-type-path +plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice +plugins/modules/rax.py use-argspec-type-path # fix needed +plugins/modules/rax_scaling_group.py use-argspec-type-path # fix needed, expanduser() applied to dict values +plugins/modules/redhat_subscription.py validate-modules:return-syntax-error +plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice +plugins/modules/scaleway_organization_info.py validate-modules:return-syntax-error +plugins/modules/spotinst_aws_elastigroup.py validate-modules:parameter-list-no-elements +plugins/modules/spotinst_aws_elastigroup.py validate-modules:parameter-type-not-in-doc +plugins/modules/spotinst_aws_elastigroup.py validate-modules:undocumented-parameter plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path +plugins/modules/udm_share.py validate-modules:parameter-list-no-elements +plugins/modules/udm_user.py validate-modules:parameter-list-no-elements plugins/modules/xfconf.py validate-modules:return-syntax-error -plugins/modules/jenkins_plugin.py use-argspec-type-path +plugins/modules/yarn.py use-argspec-type-path diff --git a/tests/sanity/ignore-2.13.txt b/tests/sanity/ignore-2.13.txt index 53d2d47bd4..778f25ae53 100644 --- a/tests/sanity/ignore-2.13.txt +++ b/tests/sanity/ignore-2.13.txt @@ -1,34 +1,34 @@ .azure-pipelines/scripts/publish-codecov.py replace-urlopen -plugins/modules/lxc_container.py validate-modules:use-run-command-not-popen -plugins/modules/lxd_project.py use-argspec-type-path # expanduser() applied to constants -plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice -plugins/modules/rax.py use-argspec-type-path # fix needed -plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice -plugins/modules/rax_files_objects.py use-argspec-type-path -plugins/modules/rax_scaling_group.py use-argspec-type-path # fix needed, expanduser() applied to dict values -plugins/modules/scaleway_organization_info.py validate-modules:return-syntax-error -plugins/modules/spotinst_aws_elastigroup.py validate-modules:parameter-list-no-elements -plugins/modules/spotinst_aws_elastigroup.py validate-modules:parameter-type-not-in-doc -plugins/modules/spotinst_aws_elastigroup.py validate-modules:undocumented-parameter -plugins/modules/udm_share.py validate-modules:parameter-list-no-elements -plugins/modules/udm_user.py validate-modules:parameter-list-no-elements plugins/modules/consul.py validate-modules:doc-missing-type plugins/modules/consul.py validate-modules:undocumented-parameter plugins/modules/consul_session.py validate-modules:parameter-state-invalid-choice -plugins/modules/yarn.py use-argspec-type-path -plugins/modules/redhat_subscription.py validate-modules:return-syntax-error +plugins/modules/gconftool2.py validate-modules:parameter-state-invalid-choice +plugins/modules/iptables_state.py validate-modules:undocumented-parameter +plugins/modules/jenkins_plugin.py use-argspec-type-path +plugins/modules/lxc_container.py validate-modules:use-run-command-not-popen +plugins/modules/lxd_project.py use-argspec-type-path # expanduser() applied to constants plugins/modules/manageiq_policies.py validate-modules:parameter-state-invalid-choice plugins/modules/manageiq_provider.py validate-modules:doc-choices-do-not-match-spec # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:doc-missing-type # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:parameter-type-not-in-doc # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:undocumented-parameter # missing docs on suboptions plugins/modules/manageiq_tags.py validate-modules:parameter-state-invalid-choice -plugins/modules/gconftool2.py validate-modules:parameter-state-invalid-choice -plugins/modules/iptables_state.py validate-modules:undocumented-parameter plugins/modules/osx_defaults.py validate-modules:parameter-state-invalid-choice plugins/modules/parted.py validate-modules:parameter-state-invalid-choice plugins/modules/puppet.py use-argspec-type-path plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias - removed in 7.0.0 +plugins/modules/rax_files_objects.py use-argspec-type-path +plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice +plugins/modules/rax.py use-argspec-type-path # fix needed +plugins/modules/rax_scaling_group.py use-argspec-type-path # fix needed, expanduser() applied to dict values +plugins/modules/redhat_subscription.py validate-modules:return-syntax-error +plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice +plugins/modules/scaleway_organization_info.py validate-modules:return-syntax-error +plugins/modules/spotinst_aws_elastigroup.py validate-modules:parameter-list-no-elements +plugins/modules/spotinst_aws_elastigroup.py validate-modules:parameter-type-not-in-doc +plugins/modules/spotinst_aws_elastigroup.py validate-modules:undocumented-parameter plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path +plugins/modules/udm_share.py validate-modules:parameter-list-no-elements +plugins/modules/udm_user.py validate-modules:parameter-list-no-elements plugins/modules/xfconf.py validate-modules:return-syntax-error -plugins/modules/jenkins_plugin.py use-argspec-type-path +plugins/modules/yarn.py use-argspec-type-path diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt index 9d9d74bcb4..20f87d1af2 100644 --- a/tests/sanity/ignore-2.14.txt +++ b/tests/sanity/ignore-2.14.txt @@ -1,36 +1,36 @@ .azure-pipelines/scripts/publish-codecov.py replace-urlopen -plugins/modules/lxc_container.py validate-modules:use-run-command-not-popen -plugins/modules/lxd_project.py use-argspec-type-path # expanduser() applied to constants -plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice -plugins/modules/rax.py use-argspec-type-path # fix needed -plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice -plugins/modules/rax_files_objects.py use-argspec-type-path -plugins/modules/rax_scaling_group.py use-argspec-type-path # fix needed, expanduser() applied to dict values -plugins/modules/scaleway_organization_info.py validate-modules:return-syntax-error -plugins/modules/spotinst_aws_elastigroup.py validate-modules:parameter-list-no-elements -plugins/modules/spotinst_aws_elastigroup.py validate-modules:parameter-type-not-in-doc -plugins/modules/spotinst_aws_elastigroup.py validate-modules:undocumented-parameter -plugins/modules/udm_share.py validate-modules:parameter-list-no-elements -plugins/modules/udm_user.py validate-modules:parameter-list-no-elements -plugins/modules/udm_user.py import-3.11 # Uses deprecated stdlib library 'crypt' plugins/modules/consul.py validate-modules:doc-missing-type plugins/modules/consul.py validate-modules:undocumented-parameter plugins/modules/consul_session.py validate-modules:parameter-state-invalid-choice -plugins/modules/yarn.py use-argspec-type-path -plugins/modules/redhat_subscription.py validate-modules:return-syntax-error +plugins/modules/gconftool2.py validate-modules:parameter-state-invalid-choice +plugins/modules/homectl.py import-3.11 # Uses deprecated stdlib library 'crypt' +plugins/modules/iptables_state.py validate-modules:undocumented-parameter +plugins/modules/jenkins_plugin.py use-argspec-type-path +plugins/modules/lxc_container.py validate-modules:use-run-command-not-popen +plugins/modules/lxd_project.py use-argspec-type-path # expanduser() applied to constants plugins/modules/manageiq_policies.py validate-modules:parameter-state-invalid-choice plugins/modules/manageiq_provider.py validate-modules:doc-choices-do-not-match-spec # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:doc-missing-type # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:parameter-type-not-in-doc # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:undocumented-parameter # missing docs on suboptions plugins/modules/manageiq_tags.py validate-modules:parameter-state-invalid-choice -plugins/modules/gconftool2.py validate-modules:parameter-state-invalid-choice -plugins/modules/homectl.py import-3.11 # Uses deprecated stdlib library 'crypt' -plugins/modules/iptables_state.py validate-modules:undocumented-parameter plugins/modules/osx_defaults.py validate-modules:parameter-state-invalid-choice plugins/modules/parted.py validate-modules:parameter-state-invalid-choice plugins/modules/puppet.py use-argspec-type-path plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias - removed in 7.0.0 +plugins/modules/rax_files_objects.py use-argspec-type-path +plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice +plugins/modules/rax.py use-argspec-type-path # fix needed +plugins/modules/rax_scaling_group.py use-argspec-type-path # fix needed, expanduser() applied to dict values +plugins/modules/redhat_subscription.py validate-modules:return-syntax-error +plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice +plugins/modules/scaleway_organization_info.py validate-modules:return-syntax-error +plugins/modules/spotinst_aws_elastigroup.py validate-modules:parameter-list-no-elements +plugins/modules/spotinst_aws_elastigroup.py validate-modules:parameter-type-not-in-doc +plugins/modules/spotinst_aws_elastigroup.py validate-modules:undocumented-parameter plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path +plugins/modules/udm_share.py validate-modules:parameter-list-no-elements +plugins/modules/udm_user.py import-3.11 # Uses deprecated stdlib library 'crypt' +plugins/modules/udm_user.py validate-modules:parameter-list-no-elements plugins/modules/xfconf.py validate-modules:return-syntax-error -plugins/modules/jenkins_plugin.py use-argspec-type-path +plugins/modules/yarn.py use-argspec-type-path diff --git a/tests/sanity/ignore-2.15.txt b/tests/sanity/ignore-2.15.txt index 9d9d74bcb4..20f87d1af2 100644 --- a/tests/sanity/ignore-2.15.txt +++ b/tests/sanity/ignore-2.15.txt @@ -1,36 +1,36 @@ .azure-pipelines/scripts/publish-codecov.py replace-urlopen -plugins/modules/lxc_container.py validate-modules:use-run-command-not-popen -plugins/modules/lxd_project.py use-argspec-type-path # expanduser() applied to constants -plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice -plugins/modules/rax.py use-argspec-type-path # fix needed -plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice -plugins/modules/rax_files_objects.py use-argspec-type-path -plugins/modules/rax_scaling_group.py use-argspec-type-path # fix needed, expanduser() applied to dict values -plugins/modules/scaleway_organization_info.py validate-modules:return-syntax-error -plugins/modules/spotinst_aws_elastigroup.py validate-modules:parameter-list-no-elements -plugins/modules/spotinst_aws_elastigroup.py validate-modules:parameter-type-not-in-doc -plugins/modules/spotinst_aws_elastigroup.py validate-modules:undocumented-parameter -plugins/modules/udm_share.py validate-modules:parameter-list-no-elements -plugins/modules/udm_user.py validate-modules:parameter-list-no-elements -plugins/modules/udm_user.py import-3.11 # Uses deprecated stdlib library 'crypt' plugins/modules/consul.py validate-modules:doc-missing-type plugins/modules/consul.py validate-modules:undocumented-parameter plugins/modules/consul_session.py validate-modules:parameter-state-invalid-choice -plugins/modules/yarn.py use-argspec-type-path -plugins/modules/redhat_subscription.py validate-modules:return-syntax-error +plugins/modules/gconftool2.py validate-modules:parameter-state-invalid-choice +plugins/modules/homectl.py import-3.11 # Uses deprecated stdlib library 'crypt' +plugins/modules/iptables_state.py validate-modules:undocumented-parameter +plugins/modules/jenkins_plugin.py use-argspec-type-path +plugins/modules/lxc_container.py validate-modules:use-run-command-not-popen +plugins/modules/lxd_project.py use-argspec-type-path # expanduser() applied to constants plugins/modules/manageiq_policies.py validate-modules:parameter-state-invalid-choice plugins/modules/manageiq_provider.py validate-modules:doc-choices-do-not-match-spec # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:doc-missing-type # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:parameter-type-not-in-doc # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:undocumented-parameter # missing docs on suboptions plugins/modules/manageiq_tags.py validate-modules:parameter-state-invalid-choice -plugins/modules/gconftool2.py validate-modules:parameter-state-invalid-choice -plugins/modules/homectl.py import-3.11 # Uses deprecated stdlib library 'crypt' -plugins/modules/iptables_state.py validate-modules:undocumented-parameter plugins/modules/osx_defaults.py validate-modules:parameter-state-invalid-choice plugins/modules/parted.py validate-modules:parameter-state-invalid-choice plugins/modules/puppet.py use-argspec-type-path plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias - removed in 7.0.0 +plugins/modules/rax_files_objects.py use-argspec-type-path +plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice +plugins/modules/rax.py use-argspec-type-path # fix needed +plugins/modules/rax_scaling_group.py use-argspec-type-path # fix needed, expanduser() applied to dict values +plugins/modules/redhat_subscription.py validate-modules:return-syntax-error +plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice +plugins/modules/scaleway_organization_info.py validate-modules:return-syntax-error +plugins/modules/spotinst_aws_elastigroup.py validate-modules:parameter-list-no-elements +plugins/modules/spotinst_aws_elastigroup.py validate-modules:parameter-type-not-in-doc +plugins/modules/spotinst_aws_elastigroup.py validate-modules:undocumented-parameter plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path +plugins/modules/udm_share.py validate-modules:parameter-list-no-elements +plugins/modules/udm_user.py import-3.11 # Uses deprecated stdlib library 'crypt' +plugins/modules/udm_user.py validate-modules:parameter-list-no-elements plugins/modules/xfconf.py validate-modules:return-syntax-error -plugins/modules/jenkins_plugin.py use-argspec-type-path +plugins/modules/yarn.py use-argspec-type-path From ee39fd5c90ea07980bd9f9cc50d6be9da7ab82a4 Mon Sep 17 00:00:00 2001 From: Martin Date: Sat, 5 Nov 2022 12:43:28 +0100 Subject: [PATCH 0005/1810] Allow for DN's to have {x} prefix on first RDN (#5450) * Allow for DN's to have {x} prefix on first RDN * Update changelogs/fragments/5450-allow-for-xordered-dns.yaml Co-authored-by: Felix Fontein * Assign attrs to throw-away var * Update plugins/module_utils/ldap.py Co-authored-by: Felix Fontein * Escape DN before creating filter Co-authored-by: Felix Fontein --- .../5450-allow-for-xordered-dns.yaml | 2 ++ plugins/module_utils/ldap.py | 24 ++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/5450-allow-for-xordered-dns.yaml diff --git a/changelogs/fragments/5450-allow-for-xordered-dns.yaml b/changelogs/fragments/5450-allow-for-xordered-dns.yaml new file mode 100644 index 0000000000..1bb1d9c761 --- /dev/null +++ b/changelogs/fragments/5450-allow-for-xordered-dns.yaml @@ -0,0 +1,2 @@ +minor_changes: + - ldap_attrs - allow for DNs to have ``{x}`` prefix on first RDN (https://github.com/ansible-collections/community.general/issues/977, https://github.com/ansible-collections/community.general/pull/5450). diff --git a/plugins/module_utils/ldap.py b/plugins/module_utils/ldap.py index daf89f16d1..03acaa58c5 100644 --- a/plugins/module_utils/ldap.py +++ b/plugins/module_utils/ldap.py @@ -15,6 +15,8 @@ from ansible.module_utils.common.text.converters import to_native try: import ldap + import ldap.dn + import ldap.filter import ldap.sasl HAS_LDAP = True @@ -48,7 +50,6 @@ class LdapGeneric(object): self.module = module self.bind_dn = self.module.params['bind_dn'] self.bind_pw = self.module.params['bind_pw'] - self.dn = self.module.params['dn'] self.referrals_chasing = self.module.params['referrals_chasing'] self.server_uri = self.module.params['server_uri'] self.start_tls = self.module.params['start_tls'] @@ -58,6 +59,9 @@ class LdapGeneric(object): # Establish connection self.connection = self._connect_to_ldap() + # Try to find the X_ORDERed version of the DN + self.dn = self._find_dn() + def fail(self, msg, exn): self.module.fail_json( msg=msg, @@ -65,6 +69,24 @@ class LdapGeneric(object): exception=traceback.format_exc() ) + def _find_dn(self): + dn = self.module.params['dn'] + + explode_dn = ldap.dn.explode_dn(dn) + + if len(explode_dn) > 1: + try: + escaped_value = ldap.filter.escape_filter_chars(explode_dn[0]) + filterstr = "(%s)" % escaped_value + dns = self.connection.search_s(','.join(explode_dn[1:]), + ldap.SCOPE_ONELEVEL, filterstr) + if len(dns) == 1: + dn, dummy = dns[0] + except Exception: + pass + + return dn + def _connect_to_ldap(self): if not self.verify_cert: ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_NEVER) From db7e5f12f5065a9da850dd9a785b2e30910fced2 Mon Sep 17 00:00:00 2001 From: Guillaume MARTINEZ Date: Sat, 5 Nov 2022 21:43:47 +0100 Subject: [PATCH 0006/1810] [Scaleway] Add module to manage functions (#5463) * [Scaleway] Add module to manage function Signed-off-by: Lunik * fix integration tests assertions Signed-off-by: Lunik * Update plugins/modules/scaleway_function.py Co-authored-by: Felix Fontein Signed-off-by: Lunik Co-authored-by: Felix Fontein --- .github/BOTMETA.yml | 4 + plugins/modules/scaleway_function.py | 387 ++++++++++++++++++ plugins/modules/scaleway_function_info.py | 153 +++++++ .../targets/scaleway_function/aliases | 6 + .../scaleway_function/defaults/main.yml | 17 + .../targets/scaleway_function/tasks/main.yml | 284 +++++++++++++ .../targets/scaleway_function_info/aliases | 6 + .../scaleway_function_info/defaults/main.yml | 15 + .../scaleway_function_info/tasks/main.yml | 62 +++ 9 files changed, 934 insertions(+) create mode 100644 plugins/modules/scaleway_function.py create mode 100644 plugins/modules/scaleway_function_info.py create mode 100644 tests/integration/targets/scaleway_function/aliases create mode 100644 tests/integration/targets/scaleway_function/defaults/main.yml create mode 100644 tests/integration/targets/scaleway_function/tasks/main.yml create mode 100644 tests/integration/targets/scaleway_function_info/aliases create mode 100644 tests/integration/targets/scaleway_function_info/defaults/main.yml create mode 100644 tests/integration/targets/scaleway_function_info/tasks/main.yml diff --git a/.github/BOTMETA.yml b/.github/BOTMETA.yml index 559689d6fe..2ba562440b 100644 --- a/.github/BOTMETA.yml +++ b/.github/BOTMETA.yml @@ -472,6 +472,10 @@ files: maintainers: Lunik $modules/scaleway_function_namespace_info.py: maintainers: Lunik + $modules/scaleway_function.py: + maintainers: Lunik + $modules/scaleway_function_info.py: + maintainers: Lunik $modules/scaleway_image_info.py: maintainers: Spredzy $modules/scaleway_ip_info.py: diff --git a/plugins/modules/scaleway_function.py b/plugins/modules/scaleway_function.py new file mode 100644 index 0000000000..b54091c6ab --- /dev/null +++ b/plugins/modules/scaleway_function.py @@ -0,0 +1,387 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# Scaleway Serverless function management module +# +# Copyright (c) 2022, Guillaume MARTINEZ +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +DOCUMENTATION = ''' +--- +module: scaleway_function +short_description: Scaleway Function management +version_added: 6.0.0 +author: Guillaume MARTINEZ (@Lunik) +description: + - This module manages function on Scaleway account. +extends_documentation_fragment: + - community.general.scaleway + - community.general.scaleway_waitable_resource +requirements: + - passlib[argon2] >= 1.7.4 + +options: + state: + type: str + description: + - Indicate desired state of the function. + default: present + choices: + - present + - absent + + namespace_id: + type: str + description: + - Function namespace identifier. + required: true + + region: + type: str + description: + - Scaleway region to use (for example C(fr-par)). + required: true + choices: + - fr-par + - nl-ams + - pl-waw + + name: + type: str + description: + - Name of the function. + required: true + + description: + description: + - Description of the function. + type: str + default: '' + + min_scale: + description: + - Minimum number of replicas for the function. + type: int + + max_scale: + description: + - Maximum number of replicas for the function. + type: int + + environment_variables: + description: + - Environment variables of the function. + - Injected in function at runtime. + type: dict + default: {} + + secret_environment_variables: + description: + - Secret environment variables of the function. + - Updating thoses values will not output a C(changed) state in Ansible. + - Injected in function at runtime. + type: dict + default: {} + + runtime: + description: + - Runtime of the function + - See U(https://www.scaleway.com/en/docs/compute/functions/reference-content/functions-lifecycle/) for all available runtimes + type: str + required: true + + memory_limit: + description: + - Resources define performance characteristics of your function. + - They are allocated to your function at runtime. + type: int + + function_timeout: + description: + - The length of time your handler can spend processing a request before being stopped. + type: str + + handler: + description: + - The C(module-name.export) value in your function. + type: str + + privacy: + description: + - Privacy policies define whether a function can be executed anonymously. + - Choose C(public) to enable anonymous execution, or C(private) to protect your function with an authentication mechanism provided by the Scaleway API. + type: str + default: public + choices: + - public + - private + + redeploy: + description: + - Redeploy the function if update is required. + type: bool + default: false +''' + +EXAMPLES = ''' +- name: Create a function + community.general.scaleway_function: + namespace_id: '{{ scw_function_namespace }}' + region: fr-par + state: present + name: my-awesome-function + runtime: python3 + environment_variables: + MY_VAR: my_value + secret_environment_variables: + MY_SECRET_VAR: my_secret_value + register: function_creation_task + +- name: Make sure function is deleted + community.general.scaleway_function: + namespace_id: '{{ scw_function_namespace }}' + region: fr-par + state: absent + name: my-awesome-function +''' + +RETURN = ''' +function: + description: The function information. + returned: when I(state=present) + type: dict + sample: + cpu_limit: 140 + description: Function used for testing scaleway_function ansible module + domain_name: fnansibletestfxamabuc-fn-ansible-test.functions.fnc.fr-par.scw.cloud + environment_variables: + MY_VAR: my_value + error_message: null + handler: handler.handle + http_option: "" + id: ceb64dc4-4464-4196-8e20-ecef705475d3 + max_scale: 5 + memory_limit: 256 + min_scale: 0 + name: fn-ansible-test + namespace_id: 82737d8d-0ebb-4d89-b0ad-625876eca50d + privacy: public + region: fr-par + runtime: python310 + runtime_message: "" + secret_environment_variables: + - key: MY_SECRET_VAR + value: $argon2id$v=19$m=65536,t=1,p=2$tb6UwSPWx/rH5Vyxt9Ujfw$5ZlvaIjWwNDPxD9Rdght3NarJz4IETKjpvAU3mMSmFg + status: created + timeout: 300s +''' + +from copy import deepcopy + +from ansible_collections.community.general.plugins.module_utils.scaleway import ( + SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, + scaleway_waitable_resource_argument_spec, resource_attributes_should_be_changed, + SecretVariables +) +from ansible.module_utils.basic import AnsibleModule + +STABLE_STATES = ( + "ready", + "created", + "absent" +) + +VERIFIABLE_MUTABLE_ATTRIBUTES = ( + "description", + "min_scale", + "max_scale", + "environment_variables", + "runtime", + "memory_limit", + "timeout", + "handler", + "privacy", + "secret_environment_variables" +) + +MUTABLE_ATTRIBUTES = VERIFIABLE_MUTABLE_ATTRIBUTES + ( + "redeploy", +) + + +def payload_from_wished_fn(wished_fn): + payload = { + "namespace_id": wished_fn["namespace_id"], + "name": wished_fn["name"], + "description": wished_fn["description"], + "min_scale": wished_fn["min_scale"], + "max_scale": wished_fn["max_scale"], + "runtime": wished_fn["runtime"], + "memory_limit": wished_fn["memory_limit"], + "timeout": wished_fn["timeout"], + "handler": wished_fn["handler"], + "privacy": wished_fn["privacy"], + "redeploy": wished_fn["redeploy"], + "environment_variables": wished_fn["environment_variables"], + "secret_environment_variables": SecretVariables.dict_to_list(wished_fn["secret_environment_variables"]) + } + + return payload + + +def absent_strategy(api, wished_fn): + changed = False + + fn_list = api.fetch_all_resources("functions") + fn_lookup = dict((fn["name"], fn) + for fn in fn_list) + + if wished_fn["name"] not in fn_lookup: + return changed, {} + + target_fn = fn_lookup[wished_fn["name"]] + changed = True + if api.module.check_mode: + return changed, {"status": "Function would be destroyed"} + + api.wait_to_complete_state_transition(resource=target_fn, stable_states=STABLE_STATES, force_wait=True) + response = api.delete(path=api.api_path + "/%s" % target_fn["id"]) + if not response.ok: + api.module.fail_json(msg='Error deleting function [{0}: {1}]'.format( + response.status_code, response.json)) + + api.wait_to_complete_state_transition(resource=target_fn, stable_states=STABLE_STATES) + return changed, response.json + + +def present_strategy(api, wished_fn): + changed = False + + fn_list = api.fetch_all_resources("functions") + fn_lookup = dict((fn["name"], fn) + for fn in fn_list) + + payload_fn = payload_from_wished_fn(wished_fn) + + if wished_fn["name"] not in fn_lookup: + changed = True + if api.module.check_mode: + return changed, {"status": "A function would be created."} + + # Creation doesn't support `redeploy` parameter + del payload_fn["redeploy"] + + # Create function + api.warn(payload_fn) + creation_response = api.post(path=api.api_path, + data=payload_fn) + + if not creation_response.ok: + msg = "Error during function creation: %s: '%s' (%s)" % (creation_response.info['msg'], + creation_response.json['message'], + creation_response.json) + api.module.fail_json(msg=msg) + + api.wait_to_complete_state_transition(resource=creation_response.json, stable_states=STABLE_STATES) + response = api.get(path=api.api_path + "/%s" % creation_response.json["id"]) + return changed, response.json + + target_fn = fn_lookup[wished_fn["name"]] + decoded_target_fn = deepcopy(target_fn) + decoded_target_fn["secret_environment_variables"] = SecretVariables.decode(decoded_target_fn["secret_environment_variables"], + payload_fn["secret_environment_variables"]) + + patch_payload = resource_attributes_should_be_changed(target=decoded_target_fn, + wished=payload_fn, + verifiable_mutable_attributes=VERIFIABLE_MUTABLE_ATTRIBUTES, + mutable_attributes=MUTABLE_ATTRIBUTES) + + if not patch_payload: + return changed, target_fn + + changed = True + if api.module.check_mode: + return changed, {"status": "Function attributes would be changed."} + + fn_patch_response = api.patch(path=api.api_path + "/%s" % target_fn["id"], + data=patch_payload) + + if not fn_patch_response.ok: + api.module.fail_json(msg='Error during function attributes update: [{0}: {1}]'.format( + fn_patch_response.status_code, fn_patch_response.json['message'])) + + api.wait_to_complete_state_transition(resource=target_fn, stable_states=STABLE_STATES) + response = api.get(path=api.api_path + "/%s" % target_fn["id"]) + return changed, response.json + + +state_strategy = { + "present": present_strategy, + "absent": absent_strategy +} + + +def core(module): + SecretVariables.ensure_scaleway_secret_package(module) + + region = module.params["region"] + wished_function = { + "state": module.params["state"], + "namespace_id": module.params["namespace_id"], + "name": module.params["name"], + "description": module.params['description'], + "min_scale": module.params['min_scale'], + "max_scale": module.params['max_scale'], + "runtime": module.params["runtime"], + "memory_limit": module.params["memory_limit"], + "timeout": module.params["function_timeout"], + "handler": module.params["handler"], + "privacy": module.params["privacy"], + "redeploy": module.params["redeploy"], + "environment_variables": module.params['environment_variables'], + "secret_environment_variables": module.params['secret_environment_variables'] + } + + api = Scaleway(module=module) + api.api_path = "functions/v1beta1/regions/%s/functions" % region + + changed, summary = state_strategy[wished_function["state"]](api=api, wished_fn=wished_function) + + module.exit_json(changed=changed, function=summary) + + +def main(): + argument_spec = scaleway_argument_spec() + argument_spec.update(scaleway_waitable_resource_argument_spec()) + argument_spec.update(dict( + state=dict(type='str', default='present', choices=['absent', 'present']), + namespace_id=dict(type='str', required=True), + region=dict(type='str', required=True, choices=SCALEWAY_REGIONS), + name=dict(type='str', required=True), + description=dict(type='str', default=''), + min_scale=dict(type='int'), + max_scale=dict(type='int'), + runtime=dict(type='str', required=True), + memory_limit=dict(type='int'), + function_timeout=dict(type='str'), + handler=dict(type='str'), + privacy=dict(type='str', default='public', choices=['public', 'private']), + redeploy=dict(type='bool', default=False), + environment_variables=dict(type='dict', default={}), + secret_environment_variables=dict(type='dict', default={}, no_log=True) + )) + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + ) + + core(module) + + +if __name__ == '__main__': + main() diff --git a/plugins/modules/scaleway_function_info.py b/plugins/modules/scaleway_function_info.py new file mode 100644 index 0000000000..b6f2eefa71 --- /dev/null +++ b/plugins/modules/scaleway_function_info.py @@ -0,0 +1,153 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# Scaleway Serverless function info module +# +# Copyright (c) 2022, Guillaume MARTINEZ +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +DOCUMENTATION = ''' +--- +module: scaleway_function_info +short_description: Retrieve information on Scaleway Function +version_added: 6.0.0 +author: Guillaume MARTINEZ (@Lunik) +description: + - This module return information about a function on Scaleway account. +extends_documentation_fragment: + - community.general.scaleway + + +options: + namespace_id: + type: str + description: + - Container namespace identifier. + required: true + + region: + type: str + description: + - Scaleway region to use (for example C(fr-par)). + required: true + choices: + - fr-par + - nl-ams + - pl-waw + + name: + type: str + description: + - Name of the function. + required: true +''' + +EXAMPLES = ''' +- name: Get a function info + community.general.scaleway_function_info: + namespace_id: '{{ scw_function_namespace }}' + region: fr-par + name: my-awesome-function + register: function_info_task +''' + +RETURN = ''' +function: + description: The function information. + returned: always + type: dict + sample: + cpu_limit: 140 + description: Function used for testing scaleway_function ansible module + domain_name: fnansibletestfxamabuc-fn-ansible-test.functions.fnc.fr-par.scw.cloud + environment_variables: + MY_VAR: my_value + error_message: null + handler: handler.handle + http_option: "" + id: ceb64dc4-4464-4196-8e20-ecef705475d3 + max_scale: 5 + memory_limit: 256 + min_scale: 0 + name: fn-ansible-test + namespace_id: 82737d8d-0ebb-4d89-b0ad-625876eca50d + privacy: public + region: fr-par + runtime: python310 + runtime_message: "" + secret_environment_variables: SENSITIVE_VALUE + status: created + timeout: 300s +''' + +from ansible_collections.community.general.plugins.module_utils.scaleway import ( + SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, + filter_sensitive_attributes +) +from ansible.module_utils.basic import AnsibleModule + +SENSITIVE_ATTRIBUTES = ( + "secret_environment_variables", +) + + +def info_strategy(api, wished_fn): + fn_list = api.fetch_all_resources("functions") + fn_lookup = dict((fn["name"], fn) + for fn in fn_list) + + if wished_fn["name"] not in fn_lookup: + msg = "Error during function lookup: Unable to find function named '%s' in namespace '%s'" % (wished_fn["name"], + wished_fn["namespace_id"]) + + api.module.fail_json(msg=msg) + + target_fn = fn_lookup[wished_fn["name"]] + + response = api.get(path=api.api_path + "/%s" % target_fn["id"]) + if not response.ok: + msg = "Error during function lookup: %s: '%s' (%s)" % (response.info['msg'], + response.json['message'], + response.json) + api.module.fail_json(msg=msg) + + return response.json + + +def core(module): + region = module.params["region"] + wished_function = { + "namespace_id": module.params["namespace_id"], + "name": module.params["name"] + } + + api = Scaleway(module=module) + api.api_path = "functions/v1beta1/regions/%s/functions" % region + + summary = info_strategy(api=api, wished_fn=wished_function) + + module.exit_json(changed=False, function=filter_sensitive_attributes(summary, SENSITIVE_ATTRIBUTES)) + + +def main(): + argument_spec = scaleway_argument_spec() + argument_spec.update(dict( + namespace_id=dict(type='str', required=True), + region=dict(type='str', required=True, choices=SCALEWAY_REGIONS), + name=dict(type='str', required=True) + )) + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + ) + + core(module) + + +if __name__ == '__main__': + main() diff --git a/tests/integration/targets/scaleway_function/aliases b/tests/integration/targets/scaleway_function/aliases new file mode 100644 index 0000000000..a5ac5181f0 --- /dev/null +++ b/tests/integration/targets/scaleway_function/aliases @@ -0,0 +1,6 @@ +# Copyright (c) 2022, Guillaume MARTINEZ +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +cloud/scaleway +unsupported diff --git a/tests/integration/targets/scaleway_function/defaults/main.yml b/tests/integration/targets/scaleway_function/defaults/main.yml new file mode 100644 index 0000000000..df02a4665f --- /dev/null +++ b/tests/integration/targets/scaleway_function/defaults/main.yml @@ -0,0 +1,17 @@ +--- +# Copyright (c) 2022, Guillaume MARTINEZ +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +scaleway_region: fr-par +function_namespace_name: fn-ansible-test +name: fn-ansible-test +description: Function used for testing scaleway_function_infoansible module +updated_description: Function used for testing scaleway_function_info ansible module (Updated description) +environment_variables: + MY_VAR: my_value +secret_environment_variables: + MY_SECRET_VAR: my_secret_value +updated_secret_environment_variables: + MY_SECRET_VAR: my_other_secret_value +runtime: python310 diff --git a/tests/integration/targets/scaleway_function/tasks/main.yml b/tests/integration/targets/scaleway_function/tasks/main.yml new file mode 100644 index 0000000000..92ebfb8f7d --- /dev/null +++ b/tests/integration/targets/scaleway_function/tasks/main.yml @@ -0,0 +1,284 @@ +--- +#################################################################### +# WARNING: These are designed specifically for Ansible tests # +# and should not be used as examples of how to write Ansible roles # +#################################################################### + +# Copyright (c) 2022, Guillaume MARTINEZ +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +- name: Create function_namespace + community.general.scaleway_function_namespace: + state: present + name: '{{ function_namespace_name }}' + region: '{{ scaleway_region }}' + project_id: '{{ scw_project }}' + description: '{{ description }}' + register: integration_function_namespace + +- name: Create a function (Check) + check_mode: yes + community.general.scaleway_function: + state: present + name: '{{ name }}' + region: '{{ scaleway_region }}' + namespace_id: '{{ integration_function_namespace.function_namespace.id }}' + runtime: '{{ runtime }}' + description: '{{ description }}' + environment_variables: '{{ environment_variables }}' + secret_environment_variables: '{{ secret_environment_variables }}' + register: fn_creation_check_task + +- ansible.builtin.debug: + var: fn_creation_check_task + +- name: Check module call result + ansible.builtin.assert: + that: + - fn_creation_check_task is success + - fn_creation_check_task is changed + +- name: Create function + community.general.scaleway_function: + state: present + name: '{{ name }}' + region: '{{ scaleway_region }}' + namespace_id: '{{ integration_function_namespace.function_namespace.id }}' + runtime: '{{ runtime }}' + description: '{{ description }}' + environment_variables: '{{ environment_variables }}' + secret_environment_variables: '{{ secret_environment_variables }}' + register: fn_creation_task + +- ansible.builtin.debug: + var: fn_creation_task + +- name: Check module call result + ansible.builtin.assert: + that: + - fn_creation_task is success + - fn_creation_task is changed + - fn_creation_task.function.status in ["created", "ready"] + +- name: Create function (Confirmation) + community.general.scaleway_function: + state: present + name: '{{ name }}' + region: '{{ scaleway_region }}' + namespace_id: '{{ integration_function_namespace.function_namespace.id }}' + runtime: '{{ runtime }}' + description: '{{ description }}' + environment_variables: '{{ environment_variables }}' + secret_environment_variables: '{{ secret_environment_variables }}' + register: fn_creation_confirmation_task + +- ansible.builtin.debug: + var: fn_creation_confirmation_task + +- name: Check module call result + ansible.builtin.assert: + that: + - fn_creation_confirmation_task is success + - fn_creation_confirmation_task is not changed + - fn_creation_confirmation_task.function.status in ["created", "ready"] + +- name: Update function (Check) + check_mode: yes + community.general.scaleway_function: + state: present + name: '{{ name }}' + region: '{{ scaleway_region }}' + namespace_id: '{{ integration_function_namespace.function_namespace.id }}' + runtime: '{{ runtime }}' + description: '{{ updated_description }}' + environment_variables: '{{ environment_variables }}' + secret_environment_variables: '{{ secret_environment_variables }}' + register: fn_update_check_task + +- ansible.builtin.debug: + var: fn_update_check_task + +- name: Check module call result + ansible.builtin.assert: + that: + - fn_update_check_task is success + - fn_update_check_task is changed + +- name: Update function + community.general.scaleway_function: + state: present + name: '{{ name }}' + region: '{{ scaleway_region }}' + namespace_id: '{{ integration_function_namespace.function_namespace.id }}' + runtime: '{{ runtime }}' + description: '{{ updated_description }}' + environment_variables: '{{ environment_variables }}' + secret_environment_variables: '{{ secret_environment_variables }}' + register: fn_update_task + +- ansible.builtin.debug: + var: fn_update_task + +- name: Check module call result + ansible.builtin.assert: + that: + - fn_update_task is success + - fn_update_task is changed + - fn_update_task.function.status in ["created", "ready"] + +- name: Update function (Confirmation) + community.general.scaleway_function: + state: present + name: '{{ name }}' + region: '{{ scaleway_region }}' + namespace_id: '{{ integration_function_namespace.function_namespace.id }}' + runtime: '{{ runtime }}' + description: '{{ updated_description }}' + environment_variables: '{{ environment_variables }}' + secret_environment_variables: '{{ secret_environment_variables }}' + register: fn_update_confirmation_task + +- ansible.builtin.debug: + var: fn_update_confirmation_task + +- name: Check module call result + ansible.builtin.assert: + that: + - fn_update_confirmation_task is success + - fn_update_confirmation_task is not changed + - fn_update_confirmation_task.function.status in ["created", "ready"] + +- name: Update function secret variables (Check) + check_mode: yes + community.general.scaleway_function: + state: present + name: '{{ name }}' + region: '{{ scaleway_region }}' + namespace_id: '{{ integration_function_namespace.function_namespace.id }}' + runtime: '{{ runtime }}' + description: '{{ updated_description }}' + environment_variables: '{{ environment_variables }}' + secret_environment_variables: '{{ updated_secret_environment_variables }}' + register: fn_update_secret_check_task + +- ansible.builtin.debug: + var: fn_update_secret_check_task + +- name: Check module call result + ansible.builtin.assert: + that: + - fn_update_secret_check_task is success + - fn_update_secret_check_task is changed + +- name: Update function secret variables + community.general.scaleway_function: + state: present + name: '{{ name }}' + region: '{{ scaleway_region }}' + namespace_id: '{{ integration_function_namespace.function_namespace.id }}' + runtime: '{{ runtime }}' + description: '{{ updated_description }}' + environment_variables: '{{ environment_variables }}' + secret_environment_variables: '{{ updated_secret_environment_variables }}' + register: fn_update_secret_task + +- ansible.builtin.debug: + var: fn_update_secret_task + +- name: Check module call result + ansible.builtin.assert: + that: + - fn_update_secret_task is success + - fn_update_secret_task is changed + - fn_update_secret_task.function.status in ["created", "ready"] + - "'hashed_value' in fn_update_secret_task.function.secret_environment_variables[0]" + +- name: Update function secret variables (Confirmation) + community.general.scaleway_function: + state: present + name: '{{ name }}' + region: '{{ scaleway_region }}' + namespace_id: '{{ integration_function_namespace.function_namespace.id }}' + runtime: '{{ runtime }}' + description: '{{ updated_description }}' + environment_variables: '{{ environment_variables }}' + secret_environment_variables: '{{ updated_secret_environment_variables }}' + register: fn_update_secret_confirmation_task + +- ansible.builtin.debug: + var: fn_update_secret_confirmation_task + +- name: Check module call result + ansible.builtin.assert: + that: + - fn_update_secret_confirmation_task is success + - fn_update_secret_confirmation_task is not changed + - fn_update_secret_confirmation_task.function.status in ["created", "ready"] + - "'hashed_value' in fn_update_secret_confirmation_task.function.secret_environment_variables[0]" + +- name: Delete function (Check) + check_mode: yes + community.general.scaleway_function: + state: absent + name: '{{ name }}' + region: '{{ scaleway_region }}' + description: '{{ description }}' + namespace_id: '{{ integration_function_namespace.function_namespace.id }}' + runtime: '{{ runtime }}' + register: fn_deletion_check_task + +- ansible.builtin.debug: + var: fn_deletion_check_task + +- name: Check module call result + ansible.builtin.assert: + that: + - fn_deletion_check_task is success + - fn_deletion_check_task is changed + +- name: Delete function + community.general.scaleway_function: + state: absent + name: '{{ name }}' + region: '{{ scaleway_region }}' + description: '{{ description }}' + namespace_id: '{{ integration_function_namespace.function_namespace.id }}' + runtime: '{{ runtime }}' + register: fn_deletion_task + +- ansible.builtin.debug: + var: fn_deletion_task + +- name: Check module call result + ansible.builtin.assert: + that: + - fn_deletion_task is success + - fn_deletion_task is changed + +- name: Delete function (Confirmation) + community.general.scaleway_function: + state: absent + name: '{{ name }}' + region: '{{ scaleway_region }}' + description: '{{ description }}' + namespace_id: '{{ integration_function_namespace.function_namespace.id }}' + runtime: '{{ runtime }}' + register: fn_deletion_confirmation_task + +- ansible.builtin.debug: + var: fn_deletion_confirmation_task + +- name: Check module call result + ansible.builtin.assert: + that: + - fn_deletion_confirmation_task is success + - fn_deletion_confirmation_task is not changed + +- name: Delete function namespace + community.general.scaleway_function_namespace: + state: absent + name: '{{ function_namespace_name }}' + region: '{{ scaleway_region }}' + description: '{{ description }}' + project_id: '{{ scw_project }}' diff --git a/tests/integration/targets/scaleway_function_info/aliases b/tests/integration/targets/scaleway_function_info/aliases new file mode 100644 index 0000000000..a5ac5181f0 --- /dev/null +++ b/tests/integration/targets/scaleway_function_info/aliases @@ -0,0 +1,6 @@ +# Copyright (c) 2022, Guillaume MARTINEZ +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +cloud/scaleway +unsupported diff --git a/tests/integration/targets/scaleway_function_info/defaults/main.yml b/tests/integration/targets/scaleway_function_info/defaults/main.yml new file mode 100644 index 0000000000..71d2fe7803 --- /dev/null +++ b/tests/integration/targets/scaleway_function_info/defaults/main.yml @@ -0,0 +1,15 @@ +--- +# Copyright (c) 2022, Guillaume MARTINEZ +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +scaleway_region: fr-par +function_namespace_name: fn-ansible-test +name: fn-ansible-test +description: Container used for testing scaleway_function_info ansible module +updated_description: Container used for testing scaleway_function_info ansible module (Updated description) +environment_variables: + MY_VAR: my_value +secret_environment_variables: + MY_SECRET_VAR: my_secret_value +runtime: python310 diff --git a/tests/integration/targets/scaleway_function_info/tasks/main.yml b/tests/integration/targets/scaleway_function_info/tasks/main.yml new file mode 100644 index 0000000000..17b07f5f97 --- /dev/null +++ b/tests/integration/targets/scaleway_function_info/tasks/main.yml @@ -0,0 +1,62 @@ +--- +#################################################################### +# WARNING: These are designed specifically for Ansible tests # +# and should not be used as examples of how to write Ansible roles # +#################################################################### + +# Copyright (c) 2022, Guillaume MARTINEZ +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +- name: Create function_namespace + community.general.scaleway_function_namespace: + state: present + name: '{{ function_namespace_name }}' + region: '{{ scaleway_region }}' + project_id: '{{ scw_project }}' + description: '{{ description }}' + register: integration_function_namespace + +- name: Create function + community.general.scaleway_function: + state: present + name: '{{ name }}' + region: '{{ scaleway_region }}' + namespace_id: '{{ integration_function_namespace.function_namespace.id }}' + runtime: '{{ runtime }}' + description: '{{ description }}' + environment_variables: '{{ environment_variables }}' + secret_environment_variables: '{{ secret_environment_variables }}' + +- name: Get function info + community.general.scaleway_function_info: + name: '{{ name }}' + region: '{{ scaleway_region }}' + namespace_id: '{{ integration_function_namespace.function_namespace.id }}' + register: fn_info_task + +- ansible.builtin.debug: + var: fn_info_task + +- name: Check module call result + ansible.builtin.assert: + that: + - fn_info_task is success + - fn_info_task is not changed + +- name: Delete function + community.general.scaleway_function: + state: absent + name: '{{ name }}' + region: '{{ scaleway_region }}' + description: '{{ description }}' + namespace_id: '{{ integration_function_namespace.function_namespace.id }}' + runtime: '{{ runtime }}' + +- name: Delete function namespace + community.general.scaleway_function_namespace: + state: absent + name: '{{ function_namespace_name }}' + region: '{{ scaleway_region }}' + description: '{{ description }}' + project_id: '{{ scw_project }}' From 1e17ec13b88c697751708d7166304674713e04c8 Mon Sep 17 00:00:00 2001 From: Guillaume MARTINEZ Date: Sat, 5 Nov 2022 21:44:33 +0100 Subject: [PATCH 0007/1810] [Scaleway] Add module to manage container namespaces (#5416) * [Scaleway] Add module to manage container namespaces Signed-off-by: Lunik * Fix CI Signed-off-by: Lunik * fix botmeta Signed-off-by: Lunik * fix typo in loop var name Signed-off-by: Lunik * Add missing required lib check Signed-off-by: Lunik * fix integration tests assertions Signed-off-by: Lunik Signed-off-by: Lunik --- .github/BOTMETA.yml | 4 + .../modules/scaleway_container_namespace.py | 289 ++++++++++++++++++ .../scaleway_container_namespace_info.py | 145 +++++++++ .../scaleway_container_namespace/aliases | 6 + .../defaults/main.yml | 15 + .../tasks/main.yml | 255 ++++++++++++++++ .../scaleway_container_namespace_info/aliases | 6 + .../defaults/main.yml | 13 + .../tasks/main.yml | 41 +++ 9 files changed, 774 insertions(+) create mode 100644 plugins/modules/scaleway_container_namespace.py create mode 100644 plugins/modules/scaleway_container_namespace_info.py create mode 100644 tests/integration/targets/scaleway_container_namespace/aliases create mode 100644 tests/integration/targets/scaleway_container_namespace/defaults/main.yml create mode 100644 tests/integration/targets/scaleway_container_namespace/tasks/main.yml create mode 100644 tests/integration/targets/scaleway_container_namespace_info/aliases create mode 100644 tests/integration/targets/scaleway_container_namespace_info/defaults/main.yml create mode 100644 tests/integration/targets/scaleway_container_namespace_info/tasks/main.yml diff --git a/.github/BOTMETA.yml b/.github/BOTMETA.yml index 2ba562440b..1844ce49f1 100644 --- a/.github/BOTMETA.yml +++ b/.github/BOTMETA.yml @@ -462,6 +462,10 @@ files: maintainers: $team_scaleway $modules/scaleway_compute_private_network.py: maintainers: pastral + $modules/scaleway_container_namespace.py: + maintainers: Lunik + $modules/scaleway_container_namespace_info.py: + maintainers: Lunik $modules/scaleway_container_registry.py: maintainers: Lunik $modules/scaleway_container_registry_info.py: diff --git a/plugins/modules/scaleway_container_namespace.py b/plugins/modules/scaleway_container_namespace.py new file mode 100644 index 0000000000..4cfde73542 --- /dev/null +++ b/plugins/modules/scaleway_container_namespace.py @@ -0,0 +1,289 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# Scaleway Serverless container namespace management module +# +# Copyright (c) 2022, Guillaume MARTINEZ +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +DOCUMENTATION = ''' +--- +module: scaleway_container_namespace +short_description: Scaleway Container namespace management +version_added: 6.0.0 +author: Guillaume MARTINEZ (@Lunik) +description: + - This module manages container namespaces on Scaleway account. +extends_documentation_fragment: + - community.general.scaleway + - community.general.scaleway_waitable_resource +requirements: + - passlib[argon2] >= 1.7.4 + +options: + state: + type: str + description: + - Indicate desired state of the container namespace. + default: present + choices: + - present + - absent + + project_id: + type: str + description: + - Project identifier. + required: true + + region: + type: str + description: + - Scaleway region to use (for example C(fr-par)). + required: true + choices: + - fr-par + - nl-ams + - pl-waw + + name: + type: str + description: + - Name of the container namespace. + required: true + + description: + description: + - Description of the container namespace. + type: str + default: '' + + environment_variables: + description: + - Environment variables of the container namespace. + - Injected in containers at runtime. + type: dict + default: {} + + secret_environment_variables: + description: + - Secret environment variables of the container namespace. + - Updating thoses values will not output a C(changed) state in Ansible. + - Injected in containers at runtime. + type: dict + default: {} +''' + +EXAMPLES = ''' +- name: Create a container namespace + community.general.scaleway_container_namespace: + project_id: '{{ scw_project }}' + state: present + region: fr-par + name: my-awesome-container-namespace + environment_variables: + MY_VAR: my_value + secret_environment_variables: + MY_SECRET_VAR: my_secret_value + register: container_namespace_creation_task + +- name: Make sure container namespace is deleted + community.general.scaleway_container_namespace: + project_id: '{{ scw_project }}' + state: absent + region: fr-par + name: my-awesome-container-namespace +''' + +RETURN = ''' +container_namespace: + description: The container namespace information. + returned: when I(state=present) + type: dict + sample: + description: "" + environment_variables: + MY_VAR: my_value + error_message: null + id: 531a1fd7-98d2-4a74-ad77-d398324304b8 + name: my-awesome-container-namespace + organization_id: e04e3bdc-015c-4514-afde-9389e9be24b0 + project_id: d44cea58-dcb7-4c95-bff1-1105acb60a98 + region: fr-par + registry_endpoint: "" + registry_namespace_id: "" + secret_environment_variables: + - key: MY_SECRET_VAR + value: $argon2id$v=19$m=65536,t=1,p=2$tb6UwSPWx/rH5Vyxt9Ujfw$5ZlvaIjWwNDPxD9Rdght3NarJz4IETKjpvAU3mMSmFg + status: pending +''' + +from copy import deepcopy + +from ansible_collections.community.general.plugins.module_utils.scaleway import ( + SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, + scaleway_waitable_resource_argument_spec, + resource_attributes_should_be_changed, SecretVariables +) +from ansible.module_utils.basic import AnsibleModule + +STABLE_STATES = ( + "ready", + "absent" +) + +MUTABLE_ATTRIBUTES = ( + "description", + "environment_variables", + "secret_environment_variables" +) + + +def payload_from_wished_cn(wished_cn): + payload = { + "project_id": wished_cn["project_id"], + "name": wished_cn["name"], + "description": wished_cn["description"], + "environment_variables": wished_cn["environment_variables"], + "secret_environment_variables": SecretVariables.dict_to_list(wished_cn["secret_environment_variables"]) + } + + return payload + + +def absent_strategy(api, wished_cn): + changed = False + + cn_list = api.fetch_all_resources("namespaces") + cn_lookup = dict((cn["name"], cn) + for cn in cn_list) + + if wished_cn["name"] not in cn_lookup: + return changed, {} + + target_cn = cn_lookup[wished_cn["name"]] + changed = True + if api.module.check_mode: + return changed, {"status": "Container namespace would be destroyed"} + + api.wait_to_complete_state_transition(resource=target_cn, stable_states=STABLE_STATES, force_wait=True) + response = api.delete(path=api.api_path + "/%s" % target_cn["id"]) + if not response.ok: + api.module.fail_json(msg='Error deleting container namespace [{0}: {1}]'.format( + response.status_code, response.json)) + + api.wait_to_complete_state_transition(resource=target_cn, stable_states=STABLE_STATES) + return changed, response.json + + +def present_strategy(api, wished_cn): + changed = False + + cn_list = api.fetch_all_resources("namespaces") + cn_lookup = dict((cn["name"], cn) + for cn in cn_list) + + payload_cn = payload_from_wished_cn(wished_cn) + + if wished_cn["name"] not in cn_lookup: + changed = True + if api.module.check_mode: + return changed, {"status": "A container namespace would be created."} + + # Create container namespace + api.warn(payload_cn) + creation_response = api.post(path=api.api_path, + data=payload_cn) + + if not creation_response.ok: + msg = "Error during container namespace creation: %s: '%s' (%s)" % (creation_response.info['msg'], + creation_response.json['message'], + creation_response.json) + api.module.fail_json(msg=msg) + + api.wait_to_complete_state_transition(resource=creation_response.json, stable_states=STABLE_STATES) + response = api.get(path=api.api_path + "/%s" % creation_response.json["id"]) + return changed, response.json + + target_cn = cn_lookup[wished_cn["name"]] + decoded_target_cn = deepcopy(target_cn) + decoded_target_cn["secret_environment_variables"] = SecretVariables.decode(decoded_target_cn["secret_environment_variables"], + payload_cn["secret_environment_variables"]) + patch_payload = resource_attributes_should_be_changed(target=decoded_target_cn, + wished=payload_cn, + verifiable_mutable_attributes=MUTABLE_ATTRIBUTES, + mutable_attributes=MUTABLE_ATTRIBUTES) + + if not patch_payload: + return changed, target_cn + + changed = True + if api.module.check_mode: + return changed, {"status": "Container namespace attributes would be changed."} + + cn_patch_response = api.patch(path=api.api_path + "/%s" % target_cn["id"], + data=patch_payload) + + if not cn_patch_response.ok: + api.module.fail_json(msg='Error during container namespace attributes update: [{0}: {1}]'.format( + cn_patch_response.status_code, cn_patch_response.json['message'])) + + api.wait_to_complete_state_transition(resource=target_cn, stable_states=STABLE_STATES) + response = api.get(path=api.api_path + "/%s" % target_cn["id"]) + return changed, cn_patch_response.json + + +state_strategy = { + "present": present_strategy, + "absent": absent_strategy +} + + +def core(module): + SecretVariables.ensure_scaleway_secret_package(module) + + region = module.params["region"] + wished_container_namespace = { + "state": module.params["state"], + "project_id": module.params["project_id"], + "name": module.params["name"], + "description": module.params['description'], + "environment_variables": module.params['environment_variables'], + "secret_environment_variables": module.params['secret_environment_variables'] + } + + api = Scaleway(module=module) + api.api_path = "containers/v1beta1/regions/%s/namespaces" % region + + changed, summary = state_strategy[wished_container_namespace["state"]](api=api, wished_cn=wished_container_namespace) + + module.exit_json(changed=changed, container_namespace=summary) + + +def main(): + argument_spec = scaleway_argument_spec() + argument_spec.update(scaleway_waitable_resource_argument_spec()) + argument_spec.update(dict( + state=dict(type='str', default='present', choices=['absent', 'present']), + project_id=dict(type='str', required=True), + region=dict(type='str', required=True, choices=SCALEWAY_REGIONS), + name=dict(type='str', required=True), + description=dict(type='str', default=''), + environment_variables=dict(type='dict', default={}), + secret_environment_variables=dict(type='dict', default={}, no_log=True) + )) + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + ) + + core(module) + + +if __name__ == '__main__': + main() diff --git a/plugins/modules/scaleway_container_namespace_info.py b/plugins/modules/scaleway_container_namespace_info.py new file mode 100644 index 0000000000..daf5d7b1d6 --- /dev/null +++ b/plugins/modules/scaleway_container_namespace_info.py @@ -0,0 +1,145 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# Scaleway Serverless container namespace info module +# +# Copyright (c) 2022, Guillaume MARTINEZ +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +DOCUMENTATION = ''' +--- +module: scaleway_container_namespace_info +short_description: Retrieve information on Scaleway Container namespace +version_added: 6.0.0 +author: Guillaume MARTINEZ (@Lunik) +description: + - This module return information about a container namespace on Scaleway account. +extends_documentation_fragment: + - community.general.scaleway + + +options: + project_id: + type: str + description: + - Project identifier. + required: true + + region: + type: str + description: + - Scaleway region to use (for example C(fr-par)). + required: true + choices: + - fr-par + - nl-ams + - pl-waw + + name: + type: str + description: + - Name of the container namespace. + required: true +''' + +EXAMPLES = ''' +- name: Get a container namespace info + community.general.scaleway_container_namespace_info: + project_id: '{{ scw_project }}' + region: fr-par + name: my-awesome-container-namespace + register: container_namespace_info_task +''' + +RETURN = ''' +container_namespace: + description: The container namespace information. + returned: always + type: dict + sample: + description: "" + environment_variables: + MY_VAR: my_value + error_message: null + id: 531a1fd7-98d2-4a74-ad77-d398324304b8 + name: my-awesome-container-namespace + organization_id: e04e3bdc-015c-4514-afde-9389e9be24b0 + project_id: d44cea58-dcb7-4c95-bff1-1105acb60a98 + region: fr-par + registry_endpoint: "" + registry_namespace_id: "" + secret_environment_variables: SENSITIVE_VALUE + status: pending +''' + +from ansible_collections.community.general.plugins.module_utils.scaleway import ( + SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, + filter_sensitive_attributes +) +from ansible.module_utils.basic import AnsibleModule + +SENSITIVE_ATTRIBUTES = ( + "secret_environment_variables", +) + + +def info_strategy(api, wished_cn): + cn_list = api.fetch_all_resources("namespaces") + cn_lookup = dict((fn["name"], fn) + for fn in cn_list) + + if wished_cn["name"] not in cn_lookup: + msg = "Error during container namespace lookup: Unable to find container namespace named '%s' in project '%s'" % (wished_cn["name"], + wished_cn["project_id"]) + + api.module.fail_json(msg=msg) + + target_cn = cn_lookup[wished_cn["name"]] + + response = api.get(path=api.api_path + "/%s" % target_cn["id"]) + if not response.ok: + msg = "Error during container namespace lookup: %s: '%s' (%s)" % (response.info['msg'], + response.json['message'], + response.json) + api.module.fail_json(msg=msg) + + return response.json + + +def core(module): + region = module.params["region"] + wished_container_namespace = { + "project_id": module.params["project_id"], + "name": module.params["name"] + } + + api = Scaleway(module=module) + api.api_path = "containers/v1beta1/regions/%s/namespaces" % region + + summary = info_strategy(api=api, wished_cn=wished_container_namespace) + + module.exit_json(changed=False, container_namespace=filter_sensitive_attributes(summary, SENSITIVE_ATTRIBUTES)) + + +def main(): + argument_spec = scaleway_argument_spec() + argument_spec.update(dict( + project_id=dict(type='str', required=True), + region=dict(type='str', required=True, choices=SCALEWAY_REGIONS), + name=dict(type='str', required=True) + )) + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + ) + + core(module) + + +if __name__ == '__main__': + main() diff --git a/tests/integration/targets/scaleway_container_namespace/aliases b/tests/integration/targets/scaleway_container_namespace/aliases new file mode 100644 index 0000000000..a5ac5181f0 --- /dev/null +++ b/tests/integration/targets/scaleway_container_namespace/aliases @@ -0,0 +1,6 @@ +# Copyright (c) 2022, Guillaume MARTINEZ +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +cloud/scaleway +unsupported diff --git a/tests/integration/targets/scaleway_container_namespace/defaults/main.yml b/tests/integration/targets/scaleway_container_namespace/defaults/main.yml new file mode 100644 index 0000000000..876f8b7a63 --- /dev/null +++ b/tests/integration/targets/scaleway_container_namespace/defaults/main.yml @@ -0,0 +1,15 @@ +--- +# Copyright (c) 2022, Guillaume MARTINEZ +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +scaleway_region: fr-par +name: cn-ansible-test +description: Container namespace used for testing scaleway_container_namespace ansible module +updated_description: Container namespace used for testing scaleway_container_namespace ansible module (Updated description) +environment_variables: + MY_VAR: my_value +secret_environment_variables: + MY_SECRET_VAR: my_secret_value +updated_secret_environment_variables: + MY_SECRET_VAR: my_other_secret_value \ No newline at end of file diff --git a/tests/integration/targets/scaleway_container_namespace/tasks/main.yml b/tests/integration/targets/scaleway_container_namespace/tasks/main.yml new file mode 100644 index 0000000000..bab42ee13f --- /dev/null +++ b/tests/integration/targets/scaleway_container_namespace/tasks/main.yml @@ -0,0 +1,255 @@ +--- +#################################################################### +# WARNING: These are designed specifically for Ansible tests # +# and should not be used as examples of how to write Ansible roles # +#################################################################### + +# Copyright (c) 2022, Guillaume MARTINEZ +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +- name: Create a container namespace (Check) + check_mode: yes + community.general.scaleway_container_namespace: + state: present + name: '{{ name }}' + region: '{{ scaleway_region }}' + project_id: '{{ scw_project }}' + description: '{{ description }}' + environment_variables: '{{ environment_variables }}' + secret_environment_variables: '{{ secret_environment_variables }}' + register: cn_creation_check_task + +- ansible.builtin.debug: + var: cn_creation_check_task + +- name: Check module call result + ansible.builtin.assert: + that: + - cn_creation_check_task is success + - cn_creation_check_task is changed + +- name: Create container_namespace + community.general.scaleway_container_namespace: + state: present + name: '{{ name }}' + region: '{{ scaleway_region }}' + project_id: '{{ scw_project }}' + description: '{{ description }}' + environment_variables: '{{ environment_variables }}' + secret_environment_variables: '{{ secret_environment_variables }}' + register: cn_creation_task + +- ansible.builtin.debug: + var: cn_creation_task + +- name: Check module call result + ansible.builtin.assert: + that: + - cn_creation_task is success + - cn_creation_task is changed + - cn_creation_task.container_namespace.status == "ready" + +- name: Create container namespace (Confirmation) + community.general.scaleway_container_namespace: + state: present + name: '{{ name }}' + region: '{{ scaleway_region }}' + project_id: '{{ scw_project }}' + description: '{{ description }}' + environment_variables: '{{ environment_variables }}' + secret_environment_variables: '{{ secret_environment_variables }}' + register: cn_creation_confirmation_task + +- ansible.builtin.debug: + var: cn_creation_confirmation_task + +- name: Check module call result + ansible.builtin.assert: + that: + - cn_creation_confirmation_task is success + - cn_creation_confirmation_task is not changed + - cn_creation_confirmation_task.container_namespace.status == "ready" + +- name: Update container namespace (Check) + check_mode: yes + community.general.scaleway_container_namespace: + state: present + name: '{{ name }}' + region: '{{ scaleway_region }}' + project_id: '{{ scw_project }}' + description: '{{ updated_description }}' + environment_variables: '{{ environment_variables }}' + secret_environment_variables: '{{ secret_environment_variables }}' + register: cn_update_check_task + +- ansible.builtin.debug: + var: cn_update_check_task + +- name: Check module call result + ansible.builtin.assert: + that: + - cn_update_check_task is success + - cn_update_check_task is changed + +- name: Update container namespace + community.general.scaleway_container_namespace: + state: present + name: '{{ name }}' + region: '{{ scaleway_region }}' + project_id: '{{ scw_project }}' + description: '{{ updated_description }}' + environment_variables: '{{ environment_variables }}' + secret_environment_variables: '{{ secret_environment_variables }}' + register: cn_update_task + +- ansible.builtin.debug: + var: cn_update_task + +- name: Check module call result + ansible.builtin.assert: + that: + - cn_update_task is success + - cn_update_task is changed + - cn_update_task.container_namespace.status == "ready" + +- name: Update container namespace (Confirmation) + community.general.scaleway_container_namespace: + state: present + name: '{{ name }}' + region: '{{ scaleway_region }}' + project_id: '{{ scw_project }}' + description: '{{ updated_description }}' + environment_variables: '{{ environment_variables }}' + secret_environment_variables: '{{ secret_environment_variables }}' + register: cn_update_confirmation_task + +- ansible.builtin.debug: + var: cn_update_confirmation_task + +- name: Check module call result + ansible.builtin.assert: + that: + - cn_update_confirmation_task is success + - cn_update_confirmation_task is not changed + - cn_update_confirmation_task.container_namespace.status == "ready" + +- name: Update container namespace secret variables (Check) + check_mode: yes + community.general.scaleway_container_namespace: + state: present + name: '{{ name }}' + region: '{{ scaleway_region }}' + project_id: '{{ scw_project }}' + description: '{{ updated_description }}' + environment_variables: '{{ environment_variables }}' + secret_environment_variables: '{{ updated_secret_environment_variables }}' + register: cn_update_secret_check_task + +- ansible.builtin.debug: + var: cn_update_secret_check_task + +- name: Check module call result + ansible.builtin.assert: + that: + - cn_update_secret_check_task is success + - cn_update_secret_check_task is changed + +- name: Update container namespace secret variables + community.general.scaleway_container_namespace: + state: present + name: '{{ name }}' + region: '{{ scaleway_region }}' + project_id: '{{ scw_project }}' + description: '{{ updated_description }}' + environment_variables: '{{ environment_variables }}' + secret_environment_variables: '{{ updated_secret_environment_variables }}' + register: cn_update_secret_task + +- ansible.builtin.debug: + var: cn_update_secret_task + +- name: Check module call result + ansible.builtin.assert: + that: + - cn_update_secret_task is success + - cn_update_secret_task is changed + - cn_update_secret_task.container_namespace.status == "ready" + - "'hashed_value' in cn_update_secret_task.container_namespace.secret_environment_variables[0]" + +- name: Update container namespace secret variables (Confirmation) + community.general.scaleway_container_namespace: + state: present + name: '{{ name }}' + region: '{{ scaleway_region }}' + project_id: '{{ scw_project }}' + description: '{{ updated_description }}' + environment_variables: '{{ environment_variables }}' + secret_environment_variables: '{{ updated_secret_environment_variables }}' + register: cn_update_secret_congfirmation_task + +- ansible.builtin.debug: + var: cn_update_secret_confirmation_task + +- name: Check module call result + ansible.builtin.assert: + that: + - cn_update_secret_confirmation_task is success + - cn_update_secret_confirmation_task is not changed + - cn_update_secret_confirmation_task.container_namespace.status == "ready" + - "'hashed_value' in cn_update_secret_confirmation_task.container_namespace.secret_environment_variables[0]" + +- name: Delete container namespace (Check) + check_mode: yes + community.general.scaleway_container_namespace: + state: absent + name: '{{ name }}' + region: '{{ scaleway_region }}' + description: '{{ description }}' + project_id: '{{ scw_project }}' + register: cn_deletion_check_task + +- ansible.builtin.debug: + var: cn_deletion_check_task + +- name: Check module call result + ansible.builtin.assert: + that: + - cn_deletion_check_task is success + - cn_deletion_check_task is changed + +- name: Delete container namespace + community.general.scaleway_container_namespace: + state: absent + name: '{{ name }}' + region: '{{ scaleway_region }}' + description: '{{ description }}' + project_id: '{{ scw_project }}' + register: cn_deletion_task + +- ansible.builtin.debug: + var: cn_deletion_task + +- name: Check module call result + ansible.builtin.assert: + that: + - cn_deletion_task is success + - cn_deletion_task is changed + +- name: Delete container namespace (Confirmation) + community.general.scaleway_container_namespace: + state: absent + name: '{{ name }}' + region: '{{ scaleway_region }}' + description: '{{ description }}' + project_id: '{{ scw_project }}' + register: cn_deletion_confirmation_task + +- ansible.builtin.debug: + var: cn_deletion_confirmation_task + +- name: Check module call result + ansible.builtin.assert: + that: + - cn_deletion_confirmation_task is success + - cn_deletion_confirmation_task is not changed diff --git a/tests/integration/targets/scaleway_container_namespace_info/aliases b/tests/integration/targets/scaleway_container_namespace_info/aliases new file mode 100644 index 0000000000..a5ac5181f0 --- /dev/null +++ b/tests/integration/targets/scaleway_container_namespace_info/aliases @@ -0,0 +1,6 @@ +# Copyright (c) 2022, Guillaume MARTINEZ +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +cloud/scaleway +unsupported diff --git a/tests/integration/targets/scaleway_container_namespace_info/defaults/main.yml b/tests/integration/targets/scaleway_container_namespace_info/defaults/main.yml new file mode 100644 index 0000000000..238f79fe55 --- /dev/null +++ b/tests/integration/targets/scaleway_container_namespace_info/defaults/main.yml @@ -0,0 +1,13 @@ +--- +# Copyright (c) 2022, Guillaume MARTINEZ +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +scaleway_region: fr-par +name: cn-ansible-test +description: Container namespace used for testing scaleway_container_namespace_info ansible module +updated_description: Container namespace used for testing scaleway_container_namespace_info ansible module (Updated description) +environment_variables: + MY_VAR: my_value +secret_environment_variables: + MY_SECRET_VAR: my_secret_value diff --git a/tests/integration/targets/scaleway_container_namespace_info/tasks/main.yml b/tests/integration/targets/scaleway_container_namespace_info/tasks/main.yml new file mode 100644 index 0000000000..17ac07e81c --- /dev/null +++ b/tests/integration/targets/scaleway_container_namespace_info/tasks/main.yml @@ -0,0 +1,41 @@ +--- +#################################################################### +# WARNING: These are designed specifically for Ansible tests # +# and should not be used as examples of how to write Ansible roles # +#################################################################### + +# Copyright (c) 2022, Guillaume MARTINEZ +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +- name: Create container_namespace + community.general.scaleway_container_namespace: + state: present + name: '{{ name }}' + region: '{{ scaleway_region }}' + project_id: '{{ scw_project }}' + description: '{{ description }}' + +- name: Get container namespace info + community.general.scaleway_container_namespace_info: + name: '{{ name }}' + region: '{{ scaleway_region }}' + project_id: '{{ scw_project }}' + register: cn_info_task + +- ansible.builtin.debug: + var: cn_info_task + +- name: Check module call result + ansible.builtin.assert: + that: + - cn_info_task is success + - cn_info_task is not changed + +- name: Delete container namespace + community.general.scaleway_container_namespace: + state: absent + name: '{{ name }}' + region: '{{ scaleway_region }}' + description: '{{ description }}' + project_id: '{{ scw_project }}' From 5af84e57e4d7d720fe0248fcc7a14afb7fd54adb Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 5 Nov 2022 22:31:39 +0100 Subject: [PATCH 0008/1810] Sort BOTMETA. (#5474) --- .github/BOTMETA.yml | 1790 +++++++++++++++++++++---------------------- 1 file changed, 895 insertions(+), 895 deletions(-) diff --git a/.github/BOTMETA.yml b/.github/BOTMETA.yml index 1844ce49f1..4975f30c0e 100644 --- a/.github/BOTMETA.yml +++ b/.github/BOTMETA.yml @@ -55,15 +55,15 @@ files: $callbacks/diy.py: maintainers: theque5t $callbacks/elastic.py: - maintainers: v1v keywords: apm observability + maintainers: v1v $callbacks/hipchat.py: {} $callbacks/jabber.py: {} + $callbacks/log_plays.py: {} $callbacks/loganalytics.py: maintainers: zhcli $callbacks/logdna.py: {} $callbacks/logentries.py: {} - $callbacks/log_plays.py: {} $callbacks/logstash.py: maintainers: ujenmr $callbacks/mail.py: @@ -72,24 +72,24 @@ files: maintainers: rverchere $callbacks/null.py: {} $callbacks/opentelemetry.py: - maintainers: v1v keywords: opentelemetry observability + maintainers: v1v $callbacks/say.py: - notify: chris-short - maintainers: $team_macos - labels: macos say keywords: brew cask darwin homebrew macosx macports osx + labels: macos say + maintainers: $team_macos + notify: chris-short $callbacks/selective.py: {} $callbacks/slack.py: {} $callbacks/splunk.py: {} $callbacks/sumologic.py: - maintainers: ryancurrah labels: sumologic + maintainers: ryancurrah $callbacks/syslog_json.py: maintainers: imjoseangel $callbacks/unixy.py: - maintainers: akatch labels: unixy + maintainers: akatch $callbacks/yaml.py: {} $connections/: labels: connections @@ -101,28 +101,28 @@ files: maintainers: $team_ansible_core $connections/lxc.py: {} $connections/lxd.py: - maintainers: mattclay labels: lxd + maintainers: mattclay $connections/qubes.py: maintainers: kushaldas $connections/saltstack.py: - maintainers: mscherer labels: saltstack + maintainers: mscherer $connections/zone.py: maintainers: $team_ansible_core $doc_fragments/: labels: docs_fragments $doc_fragments/hpe3par.py: - maintainers: farhan7500 gautamphegde labels: hpe3par + maintainers: farhan7500 gautamphegde $doc_fragments/hwc.py: - maintainers: $team_huawei labels: hwc + maintainers: $team_huawei $doc_fragments/nomad.py: maintainers: chris93111 $doc_fragments/xenserver.py: - maintainers: bvitnik labels: xenserver + maintainers: bvitnik $filters/counter.py: maintainers: keilr $filters/crc32.py: @@ -149,8 +149,6 @@ files: $filters/random_mac.py: {} $filters/time.py: maintainers: resmo - $filters/unicode_normalize.py: - maintainers: Ajpantuso $filters/to_days.yml: maintainers: resmo $filters/to_hours.yml: @@ -169,6 +167,8 @@ files: maintainers: resmo $filters/to_years.yml: maintainers: resmo + $filters/unicode_normalize.py: + maintainers: Ajpantuso $filters/version_sort.py: maintainers: ericzolf $inventories/: @@ -177,31 +177,31 @@ files: maintainers: opoplawski $inventories/gitlab_runners.py: maintainers: morph027 + $inventories/icinga2.py: + maintainers: BongoEADGC6 $inventories/linode.py: - maintainers: $team_linode - labels: cloud linode keywords: linode dynamic inventory script + labels: cloud linode + maintainers: $team_linode $inventories/lxd.py: maintainers: conloos $inventories/nmap.py: {} $inventories/online.py: maintainers: remyleone $inventories/opennebula.py: - maintainers: feldsam - labels: cloud opennebula keywords: opennebula dynamic inventory script + labels: cloud opennebula + maintainers: feldsam $inventories/proxmox.py: maintainers: $team_virt ilijamt - $inventories/xen_orchestra.py: - maintainers: ddelnano shinuza - $inventories/icinga2.py: - maintainers: BongoEADGC6 $inventories/scaleway.py: - maintainers: $team_scaleway labels: cloud scaleway + maintainers: $team_scaleway $inventories/stackpath_compute.py: maintainers: shayrybak $inventories/virtualbox.py: {} + $inventories/xen_orchestra.py: + maintainers: ddelnano shinuza $lookups/: labels: lookups $lookups/bitwarden.py: @@ -213,22 +213,22 @@ files: $lookups/consul_kv.py: {} $lookups/credstash.py: {} $lookups/cyberarkpassword.py: - notify: cyberark-bizdev labels: cyberarkpassword + notify: cyberark-bizdev $lookups/dependent.py: maintainers: felixfontein $lookups/dig.py: - maintainers: jpmens labels: dig + maintainers: jpmens $lookups/dnstxt.py: maintainers: jpmens $lookups/dsv.py: - maintainers: delineaKrehl tylerezimmerman ignore: amigus - $lookups/etcd3.py: - maintainers: eric-belhomme + maintainers: delineaKrehl tylerezimmerman $lookups/etcd.py: maintainers: jpmens + $lookups/etcd3.py: + maintainers: eric-belhomme $lookups/filetree.py: maintainers: dagwieers $lookups/flattened.py: {} @@ -239,11 +239,11 @@ files: $lookups/lmdb_kv.py: maintainers: jpmens $lookups/manifold.py: - maintainers: galanoff labels: manifold + maintainers: galanoff $lookups/onepass: - maintainers: samdoran labels: onepassword + maintainers: samdoran $lookups/onepassword.py: maintainers: azenk scottsb $lookups/onepassword_raw.py: @@ -261,177 +261,733 @@ files: maintainers: RevBits $lookups/shelvefile.py: {} $lookups/tss.py: - maintainers: delineaKrehl tylerezimmerman ignore: amigus + maintainers: delineaKrehl tylerezimmerman $module_utils/: labels: module_utils $module_utils/gconftool2.py: - maintainers: russoz labels: gconftool2 + maintainers: russoz $module_utils/gitlab.py: - notify: jlozadad - maintainers: $team_gitlab - labels: gitlab keywords: gitlab source_control + labels: gitlab + maintainers: $team_gitlab + notify: jlozadad $module_utils/hwc_utils.py: - maintainers: $team_huawei - labels: huawei hwc_utils networking keywords: cloud huawei hwc + labels: huawei hwc_utils networking + maintainers: $team_huawei $module_utils/identity/keycloak/keycloak.py: maintainers: $team_keycloak $module_utils/ipa.py: - maintainers: $team_ipa labels: ipa + maintainers: $team_ipa $module_utils/manageiq.py: - maintainers: $team_manageiq labels: manageiq + maintainers: $team_manageiq $module_utils/memset.py: - maintainers: glitchcrab labels: cloud memset + maintainers: glitchcrab $module_utils/mh/: - maintainers: russoz labels: module_helper + maintainers: russoz $module_utils/module_helper.py: - maintainers: russoz labels: module_helper + maintainers: russoz $module_utils/net_tools/pritunl/: maintainers: Lowess $module_utils/oracle/oci_utils.py: - maintainers: $team_oracle labels: cloud + maintainers: $team_oracle $module_utils/pipx.py: - maintainers: russoz labels: pipx + maintainers: russoz $module_utils/pure.py: - maintainers: $team_purestorage labels: pure pure_storage + maintainers: $team_purestorage $module_utils/redfish_utils.py: - maintainers: $team_redfish labels: redfish_utils + maintainers: $team_redfish $module_utils/remote_management/lxca/common.py: maintainers: navalkp prabhosa $module_utils/scaleway.py: - maintainers: $team_scaleway labels: cloud scaleway + maintainers: $team_scaleway $module_utils/storage/hpe3par/hpe3par.py: maintainers: farhan7500 gautamphegde $module_utils/utm_utils.py: - maintainers: $team_e_spirit labels: utm_utils + maintainers: $team_e_spirit $module_utils/wdc_redfish_utils.py: - maintainers: $team_wdc labels: wdc_redfish_utils + maintainers: $team_wdc $module_utils/xenserver.py: - maintainers: bvitnik labels: xenserver + maintainers: bvitnik $module_utils/xfconf.py: - maintainers: russoz labels: xfconf + maintainers: russoz + $modules/aerospike_migrations.py: + maintainers: Alb0t + $modules/airbrake_deployment.py: + ignore: bpennypacker + labels: airbrake_deployment + maintainers: phumpal + $modules/aix: + keywords: aix efix lpar wpar + labels: aix + maintainers: $team_aix + $modules/aix_lvol.py: + maintainers: adejoux + $modules/alerta_customer.py: + maintainers: cwollinger $modules/ali_: maintainers: xiaozhu36 - $modules/atomic_container.py: - maintainers: giuseppe krsacme + $modules/alternatives.py: + ignore: DavidWittman jiuka + labels: alternatives + maintainers: mulby + $modules/ansible_galaxy_install.py: + maintainers: russoz + $modules/apache2_mod_proxy.py: + maintainers: oboukili + $modules/apache2_module.py: + ignore: robinro + maintainers: berendt n0trax + $modules/apk.py: + ignore: kbrebanov + labels: apk + maintainers: tdtrask + $modules/apt_repo.py: + maintainers: obirvalger + $modules/apt_rpm.py: + maintainers: evgkrsk + $modules/archive.py: + maintainers: bendoh $modules/atomic_: maintainers: krsacme + $modules/atomic_container.py: + maintainers: giuseppe krsacme + $modules/awall.py: + maintainers: tdtrask + $modules/beadm.py: + keywords: beadm dladm illumos ipadm nexenta omnios openindiana pfexec smartos solaris sunos zfs zpool + labels: beadm solaris + maintainers: $team_solaris + $modules/bearychat.py: + maintainers: tonyseek + $modules/bigpanda.py: + maintainers: hkariti + $modules/bitbucket_: + maintainers: catcombo + $modules/bower.py: + maintainers: mwarkentin + $modules/bundler.py: + maintainers: thoiberg + $modules/bzr.py: + maintainers: andreparames + $modules/campfire.py: + maintainers: fabulops + $modules/capabilities.py: + maintainers: natefoo + $modules/cargo.py: + maintainers: radek-sprta + $modules/catapult.py: + maintainers: Jmainguy + $modules/circonus_annotation.py: + maintainers: NickatEpic + $modules/cisco_webex.py: + maintainers: drew-russell $modules/clc_: maintainers: clc-runner + $modules/cloud_init_data_facts.py: + maintainers: resmo + $modules/cloudflare_dns.py: + labels: cloudflare_dns + maintainers: mgruener + $modules/cobbler_: + maintainers: dagwieers + $modules/composer.py: + ignore: resmo + maintainers: dmtrs + $modules/consul: + ignore: colin-nolan + maintainers: $team_consul + $modules/copr.py: + maintainers: schlupov + $modules/cpanm.py: + maintainers: fcuny russoz + $modules/cronvar.py: + maintainers: dougluce + $modules/crypttab.py: + maintainers: groks + $modules/datadog_downtime.py: + maintainers: Datadog + $modules/datadog_event.py: + ignore: arturaz + labels: datadog_event + maintainers: n0ts + $modules/datadog_monitor.py: + maintainers: skornehl + $modules/dconf.py: + maintainers: azaghal + $modules/deploy_helper.py: + maintainers: ramondelafuente $modules/dimensiondata_network.py: - maintainers: aimonb tintoy labels: dimensiondata_network + maintainers: aimonb tintoy $modules/dimensiondata_vlan.py: maintainers: tintoy + $modules/discord.py: + maintainers: cwollinger + $modules/django_manage.py: + ignore: scottanderson42 tastychutney + labels: django_manage + maintainers: russoz + $modules/dnf_versionlock.py: + maintainers: moreda + $modules/dnsimple.py: + maintainers: drcapulet + $modules/dnsimple_info.py: + maintainers: edhilgendorf + $modules/dnsmadeeasy.py: + maintainers: briceburg + $modules/dpkg_divert.py: + maintainers: quidame + $modules/easy_install.py: + maintainers: mattupstate + $modules/ejabberd_user.py: + maintainers: privateip + $modules/elasticsearch_plugin.py: + maintainers: ThePixelDeveloper samdoran + $modules/emc_vnx_sg_member.py: + maintainers: remixtj + $modules/etcd3.py: + ignore: vfauth + maintainers: evrardjp + $modules/facter.py: + labels: facter + maintainers: $team_ansible_core gamethis + $modules/filesize.py: + maintainers: quidame + $modules/filesystem.py: + labels: filesystem + maintainers: pilou- abulimov quidame + $modules/flatpak.py: + maintainers: $team_flatpak + $modules/flatpak_remote.py: + maintainers: $team_flatpak + $modules/flowdock.py: + ignore: mcodd + $modules/gandi_livedns.py: + maintainers: gthiemonge + $modules/gconftool2.py: + labels: gconftool2 + maintainers: Akasurde kevensen + $modules/gconftool2_info.py: + labels: gconftool2 + maintainers: russoz + $modules/gem.py: + labels: gem + maintainers: $team_ansible_core johanwiren + $modules/git_config.py: + maintainers: djmattyg007 mgedmin + $modules/github_: + maintainers: stpierre + $modules/github_deploy_key.py: + maintainers: bincyber + $modules/github_issue.py: + maintainers: Akasurde + $modules/github_key.py: + ignore: erydo + labels: github_key + maintainers: erydo + $modules/github_release.py: + maintainers: adrianmoisey + $modules/github_repo.py: + maintainers: atorrescogollo + $modules/gitlab_: + keywords: gitlab source_control + maintainers: $team_gitlab + notify: jlozadad + $modules/gitlab_branch.py: + maintainers: paytroff + $modules/gitlab_project_variable.py: + maintainers: markuman + $modules/gitlab_runner.py: + maintainers: SamyCoenen + $modules/gitlab_user.py: + maintainers: LennertMertens stgrace + $modules/grove.py: + maintainers: zimbatm + $modules/gunicorn.py: + maintainers: agmezr + $modules/hana_query.py: + maintainers: rainerleber + $modules/haproxy.py: + maintainers: ravibhure Normo $modules/heroku_collaborator.py: maintainers: marns93 + $modules/hg.py: + maintainers: yeukhon + $modules/hipchat.py: + maintainers: pb8226 shirou + $modules/homebrew.py: + ignore: ryansb + keywords: brew cask darwin homebrew macosx macports osx + labels: homebrew macos + maintainers: $team_macos andrew-d + notify: chris-short + $modules/homebrew_cask.py: + ignore: ryansb + keywords: brew cask darwin homebrew macosx macports osx + labels: homebrew_ macos + maintainers: $team_macos enriclluelles + notify: chris-short + $modules/homebrew_tap.py: + ignore: ryansb + keywords: brew cask darwin homebrew macosx macports osx + labels: homebrew_ macos + maintainers: $team_macos + notify: chris-short + $modules/homectl.py: + maintainers: jameslivulpi + $modules/honeybadger_deployment.py: + maintainers: stympy + $modules/hpilo_: + ignore: dagwieers + maintainers: haad + $modules/hponcfg.py: + ignore: dagwieers + maintainers: haad + $modules/htpasswd.py: + labels: htpasswd + maintainers: $team_ansible_core $modules/hwc_: - maintainers: $team_huawei huaweicloud keywords: cloud huawei hwc + maintainers: $team_huawei huaweicloud + $modules/ibm_sa_: + maintainers: tzure + $modules/icinga2_feature.py: + maintainers: nerzhul + $modules/icinga2_host.py: + maintainers: t794104 + $modules/idrac_: + ignore: jose-delarosa + maintainers: $team_redfish + $modules/ilo_: + ignore: jose-delarosa + maintainers: $team_redfish + $modules/imc_rest.py: + labels: cisco + maintainers: dagwieers + $modules/imgadm.py: + keywords: beadm dladm illumos ipadm nexenta omnios openindiana pfexec smartos solaris sunos zfs zpool + labels: solaris + maintainers: $team_solaris + $modules/infinity.py: + maintainers: MeganLiu + $modules/influxdb_: + maintainers: kamsz + $modules/influxdb_query.py: + maintainers: resmo + $modules/influxdb_user.py: + maintainers: zhhuta + $modules/influxdb_write.py: + maintainers: resmo + $modules/ini_file.py: + maintainers: jpmens noseka1 + $modules/installp.py: + keywords: aix efix lpar wpar + labels: aix installp + maintainers: $team_aix kairoaraujo + $modules/interfaces_file.py: + labels: interfaces_file + maintainers: obourdon hryamzik + $modules/ip_netns.py: + maintainers: bregman-arie + $modules/ipa_: + maintainers: $team_ipa + $modules/ipa_pwpolicy.py: + maintainers: adralioh + $modules/ipa_service.py: + maintainers: cprh + $modules/ipa_vault.py: + maintainers: jparrill + $modules/ipify_facts.py: + maintainers: resmo + $modules/ipinfoio_facts.py: + maintainers: akostyuk + $modules/ipmi_: + maintainers: bgaifullin cloudnull + $modules/iptables_state.py: + maintainers: quidame + $modules/ipwcli_dns.py: + maintainers: cwollinger + $modules/irc.py: + maintainers: jpmens sivel + $modules/iso_create.py: + maintainers: Tomorrow9 + $modules/iso_customize.py: + maintainers: ZouYuhua + $modules/iso_extract.py: + maintainers: dagwieers jhoekx ribbons + $modules/jabber.py: + maintainers: bcoca + $modules/java_cert.py: + maintainers: haad absynth76 + $modules/java_keystore.py: + maintainers: Mogztter quidame + $modules/jboss.py: + labels: jboss + maintainers: $team_jboss jhoekx + $modules/jenkins_build.py: + maintainers: brettmilford unnecessary-username + $modules/jenkins_job.py: + maintainers: sermilrod + $modules/jenkins_job_info.py: + maintainers: stpierre + $modules/jenkins_plugin.py: + maintainers: jtyr + $modules/jenkins_script.py: + maintainers: hogarthj + $modules/jira.py: + ignore: DWSR + labels: jira + maintainers: Slezhuk tarka pertoft + $modules/kernel_blacklist.py: + maintainers: matze + $modules/keycloak_: + maintainers: $team_keycloak + $modules/keycloak_authentication.py: + maintainers: elfelip Gaetan2907 + $modules/keycloak_client_rolemapping.py: + maintainers: Gaetan2907 + $modules/keycloak_clientscope.py: + maintainers: Gaetan2907 + $modules/keycloak_group.py: + maintainers: adamgoossens + $modules/keycloak_identity_provider.py: + maintainers: laurpaum + $modules/keycloak_realm.py: + maintainers: kris2kris + $modules/keycloak_realm_info.py: + maintainers: fynncfchen + $modules/keycloak_role.py: + maintainers: laurpaum + $modules/keycloak_user_federation.py: + maintainers: laurpaum + $modules/keycloak_user_rolemapping.py: + maintainers: bratwurzt + $modules/keyring.py: + maintainers: ahussey-redhat + $modules/keyring_info.py: + maintainers: ahussey-redhat + $modules/kibana_plugin.py: + maintainers: barryib + $modules/launchd.py: + maintainers: martinm82 + $modules/layman.py: + maintainers: jirutka + $modules/lbu.py: + maintainers: kunkku + $modules/ldap_attrs.py: + maintainers: drybjed jtyr noles + $modules/ldap_entry.py: + maintainers: jtyr + $modules/ldap_passwd.py: + maintainers: KellerFuchs jtyr + $modules/ldap_search.py: + maintainers: eryx12o45 jtyr + $modules/librato_annotation.py: + maintainers: Sedward $modules/linode: maintainers: $team_linode $modules/linode.py: maintainers: zbal + $modules/listen_ports_facts.py: + maintainers: ndavison + $modules/lldp.py: + ignore: andyhky + labels: lldp + $modules/locale_gen.py: + maintainers: AugustusKling + $modules/logentries.py: + ignore: ivanvanderbyl + labels: logentries + $modules/logentries_msg.py: + maintainers: jcftang + $modules/logstash_plugin.py: + maintainers: nerzhul + $modules/lvg.py: + maintainers: abulimov + $modules/lvol.py: + maintainers: abulimov jhoekx zigaSRC unkaputtbar112 $modules/lxc_container.py: maintainers: cloudnull + $modules/lxca_: + maintainers: navalkp prabhosa $modules/lxd_: ignore: hnakamur $modules/lxd_profile.py: maintainers: conloos $modules/lxd_project.py: maintainers: we10710aa + $modules/macports.py: + ignore: ryansb + keywords: brew cask darwin homebrew macosx macports osx + labels: macos macports + maintainers: $team_macos jcftang + notify: chris-short + $modules/mail.py: + maintainers: dagwieers + $modules/make.py: + maintainers: LinusU + $modules/manageiq_: + labels: manageiq + maintainers: $team_manageiq + $modules/manageiq_alert_profiles.py: + maintainers: elad661 + $modules/manageiq_alerts.py: + maintainers: elad661 + $modules/manageiq_group.py: + maintainers: evertmulder + $modules/manageiq_policies_info.py: + maintainers: russoz $team_manageiq + $modules/manageiq_tags_info.py: + maintainers: russoz $team_manageiq + $modules/manageiq_tenant.py: + maintainers: evertmulder + $modules/mas.py: + maintainers: lukasbestle mheap + $modules/matrix.py: + maintainers: jcgruenhage + $modules/mattermost.py: + maintainers: bjolivot + $modules/maven_artifact.py: + ignore: chrisisbeef + labels: maven_artifact + maintainers: tumbl3w33d turb $modules/memset_: maintainers: glitchcrab - $modules/cloud_init_data_facts.py: + $modules/mksysb.py: + labels: aix mksysb + maintainers: $team_aix + $modules/modprobe.py: + ignore: stygstra + labels: modprobe + maintainers: jdauphant mattjeffery + $modules/monit.py: + labels: monit + maintainers: dstoflet brian-brazil snopoke + $modules/mqtt.py: + maintainers: jpmens + $modules/mssql_db.py: + labels: mssql_db + maintainers: vedit Jmainguy kenichi-ogawa-1988 + $modules/mssql_script.py: + labels: mssql_script + maintainers: kbudde + $modules/nagios.py: + maintainers: tbielawa tgoetheyn + $modules/netcup_dns.py: + maintainers: nbuchwitz + $modules/newrelic_deployment.py: + ignore: mcodd + $modules/nexmo.py: + maintainers: sivel + $modules/nginx_status_info.py: maintainers: resmo + $modules/nictagadm.py: + keywords: beadm dladm illumos ipadm nexenta omnios openindiana pfexec smartos solaris sunos zfs zpool + labels: solaris + maintainers: $team_solaris SmithX10 + $modules/nmcli.py: + maintainers: alcamie101 + $modules/nomad_: + maintainers: chris93111 + $modules/nosh.py: + maintainers: tacatac + $modules/npm.py: + ignore: chrishoffman + labels: npm + maintainers: shane-walker xcambar + $modules/nsupdate.py: + maintainers: nerzhul + $modules/oci_vcn.py: + maintainers: $team_oracle rohitChaware + $modules/odbc.py: + maintainers: john-westcott-iv + $modules/office_365_connector_card.py: + maintainers: marc-sensenich + $modules/ohai.py: + labels: ohai + maintainers: $team_ansible_core mpdehaan + $modules/omapi_host.py: + maintainers: amasolov nerzhul + $modules/one_: + maintainers: $team_opennebula + $modules/one_host.py: + maintainers: rvalle + $modules/oneandone_: + maintainers: aajdinov edevenport + $modules/onepassword_info.py: + maintainers: Rylon + $modules/oneview_: + maintainers: adriane-cardozo fgbulsoni tmiotto + $modules/oneview_datacenter_info.py: + maintainers: aalexmonteiro madhav-bharadwaj ricardogpsf soodpr + $modules/oneview_fc_network.py: + maintainers: fgbulsoni + $modules/oneview_fcoe_network.py: + maintainers: fgbulsoni + $modules/online_: + maintainers: remyleone + $modules/open_iscsi.py: + maintainers: srvg + $modules/openbsd_pkg.py: + ignore: ryansb + keywords: doas dragonfly freebsd iocage jail netbsd openbsd opnsense pfsense + labels: bsd openbsd_pkg + maintainers: $team_bsd eest + $modules/opendj_backendprop.py: + maintainers: dj-wasabi + $modules/openwrt_init.py: + maintainers: agaffney + $modules/opkg.py: + maintainers: skinp + $modules/osx_defaults.py: + keywords: brew cask darwin homebrew macosx macports osx + labels: macos osx_defaults + maintainers: $team_macos notok + notify: chris-short + $modules/ovh_: + maintainers: pascalheraud + $modules/ovh_monthly_billing.py: + maintainers: fraff + $modules/pacemaker_cluster.py: + maintainers: matbu + $modules/packet_: + maintainers: nurfet-becirevic t0mk + $modules/packet_device.py: + maintainers: baldwinSPC t0mk teebes + $modules/packet_sshkey.py: + maintainers: t0mk + $modules/pacman.py: + ignore: elasticdog + labels: pacman + maintainers: elasticdog indrajitr tchernomax jraby + $modules/pacman_key.py: + labels: pacman + maintainers: grawlinson + $modules/pagerduty.py: + ignore: bpennypacker + labels: pagerduty + maintainers: suprememoocow thaumos + $modules/pagerduty_alert.py: + maintainers: ApsOps + $modules/pagerduty_change.py: + maintainers: adamvaughan + $modules/pagerduty_user.py: + maintainers: zanssa + $modules/pam_limits.py: + ignore: usawa + labels: pam_limits + maintainers: giovannisciortino + $modules/pamd.py: + maintainers: kevensen + $modules/parted.py: + maintainers: ColOfAbRiX rosowiecki jake2184 + $modules/pear.py: + ignore: jle64 + labels: pear + $modules/pids.py: + maintainers: saranyasridharan + $modules/pingdom.py: + maintainers: thaumos + $modules/pip_package_info.py: + maintainers: bcoca matburt maxamillion + $modules/pipx.py: + maintainers: russoz + $modules/pipx_info.py: + maintainers: russoz + $modules/pkg5: + keywords: beadm dladm illumos ipadm nexenta omnios openindiana pfexec smartos solaris sunos zfs zpool + labels: pkg5 solaris + maintainers: $team_solaris mavit + $modules/pkgin.py: + labels: pkgin solaris + maintainers: $team_solaris L2G jasperla szinck martinm82 + $modules/pkgng.py: + ignore: bleader + keywords: doas dragonfly freebsd iocage jail netbsd openbsd opnsense pfsense + labels: bsd pkgng + maintainers: $team_bsd bleader + $modules/pkgutil.py: + labels: pkgutil solaris + maintainers: $team_solaris dermute + $modules/pmem.py: + maintainers: mizumm + $modules/portage.py: + ignore: sayap + labels: portage + maintainers: Tatsh wltjr + $modules/portinstall.py: + ignore: ryansb + keywords: doas dragonfly freebsd iocage jail netbsd openbsd opnsense pfsense + labels: bsd portinstall + maintainers: $team_bsd berenddeboer + $modules/pritunl_: + maintainers: Lowess + $modules/profitbricks: + maintainers: baldwinSPC $modules/proxmox: - maintainers: $team_virt - labels: proxmox virt keywords: kvm libvirt proxmox qemu + labels: proxmox virt + maintainers: $team_virt $modules/proxmox.py: + ignore: skvidal maintainers: UnderGreen - ignore: skvidal + $modules/proxmox_disk.py: + maintainers: castorsky $modules/proxmox_kvm.py: - maintainers: helldorado ignore: skvidal + maintainers: helldorado $modules/proxmox_nic.py: maintainers: Kogelvis $modules/proxmox_tasks_info: maintainers: paginabianca $modules/proxmox_template.py: + ignore: skvidal maintainers: UnderGreen - ignore: skvidal - $modules/proxmox_disk.py: - maintainers: castorsky - $modules/rhevm.py: - maintainers: $team_virt TimothyVandenbrande - labels: rhevm virt - ignore: skvidal - keywords: kvm libvirt proxmox qemu - $modules/serverless.py: - ignore: ryansb - $modules/terraform.py: - maintainers: m-yosefpor rainerleber - ignore: ryansb - $modules/xenserver_facts.py: - maintainers: caphrim007 cheese - labels: xenserver_facts - ignore: andyhky ryansb - $modules/oneandone_: - maintainers: aajdinov edevenport - $modules/online_: - maintainers: remyleone - $modules/one_: - maintainers: $team_opennebula - $modules/one_host.py: - maintainers: rvalle - $modules/oci_vcn.py: - maintainers: $team_oracle rohitChaware - $modules/ovh_: - maintainers: pascalheraud - $modules/ovh_monthly_billing.py: - maintainers: fraff - $modules/packet_device.py: - maintainers: baldwinSPC t0mk teebes - $modules/packet_: - maintainers: nurfet-becirevic t0mk - $modules/packet_sshkey.py: - maintainers: t0mk - $modules/profitbricks: - maintainers: baldwinSPC $modules/pubnub_blocks.py: maintainers: parfeon pubnub - $modules/rax.py: - maintainers: omgjlk sivel + $modules/pulp_repo.py: + maintainers: sysadmind + $modules/puppet.py: + labels: puppet + maintainers: nibalizer emonty + $modules/pushbullet.py: + maintainers: willybarro + $modules/pushover.py: + maintainers: weaselkeeper wopfel + $modules/python_requirements_info.py: + ignore: ryansb + maintainers: willthames $modules/rax: ignore: ryansb sivel + $modules/rax.py: + maintainers: omgjlk sivel $modules/rax_cbs.py: maintainers: claco $modules/rax_cbs_attachments.py: maintainers: claco $modules/rax_cdb.py: maintainers: jails - $modules/rax_cdb_user.py: - maintainers: jails $modules/rax_cdb_database.py: maintainers: jails + $modules/rax_cdb_user.py: + maintainers: jails $modules/rax_clb.py: maintainers: claco $modules/rax_clb_nodes.py: @@ -444,8 +1000,6 @@ files: maintainers: angstwad $modules/rax_identity.py: maintainers: claco - $modules/rax_network.py: - maintainers: claco omgjlk $modules/rax_mon_alarm.py: maintainers: smashwilson $modules/rax_mon_check.py: @@ -456,30 +1010,91 @@ files: maintainers: smashwilson $modules/rax_mon_notification_plan.py: maintainers: smashwilson + $modules/rax_network.py: + maintainers: claco omgjlk $modules/rax_queue.py: maintainers: claco + $modules/read_csv.py: + maintainers: dagwieers + $modules/redfish_: + ignore: jose-delarosa + maintainers: $team_redfish + $modules/redhat_subscription.py: + labels: redhat_subscription + maintainers: barnabycourt alikins kahowell + $modules/redis.py: + maintainers: slok + $modules/redis_data.py: + maintainers: paginabianca + $modules/redis_data_incr.py: + maintainers: paginabianca + $modules/redis_data_info.py: + maintainers: paginabianca + $modules/redis_info.py: + maintainers: levonet + $modules/rhevm.py: + ignore: skvidal + keywords: kvm libvirt proxmox qemu + labels: rhevm virt + maintainers: $team_virt TimothyVandenbrande + $modules/rhn_channel.py: + labels: rhn_channel + maintainers: vincentvdk alikins $team_rhn + $modules/rhn_register.py: + labels: rhn_register + maintainers: jlaska $team_rhn + $modules/rhsm_release.py: + maintainers: seandst + $modules/rhsm_repository.py: + maintainers: giovannisciortino + $modules/riak.py: + maintainers: drewkerrigan jsmartin + $modules/rocketchat.py: + ignore: ramondelafuente + labels: rocketchat + maintainers: Deepakkothandan + $modules/rollbar_deployment.py: + maintainers: kavu + $modules/rpm_ostree_pkg.py: + maintainers: dustymabe Akasurde + $modules/rundeck_acl_policy.py: + maintainers: nerzhul + $modules/rundeck_job_executions_info.py: + maintainers: phsmith + $modules/rundeck_job_run.py: + maintainers: phsmith + $modules/rundeck_project.py: + maintainers: nerzhul + $modules/runit.py: + maintainers: jsumners + $modules/sap_task_list_execute: + maintainers: rainerleber + $modules/sapcar_extract.py: + maintainers: RainerLeber + $modules/say.py: + maintainers: $team_ansible_core mpdehaan $modules/scaleway_: maintainers: $team_scaleway $modules/scaleway_compute_private_network.py: maintainers: pastral $modules/scaleway_container_namespace.py: - maintainers: Lunik + maintainers: Lunik $modules/scaleway_container_namespace_info.py: - maintainers: Lunik + maintainers: Lunik $modules/scaleway_container_registry.py: - maintainers: Lunik + maintainers: Lunik $modules/scaleway_container_registry_info.py: - maintainers: Lunik + maintainers: Lunik $modules/scaleway_database_backup.py: maintainers: guillaume_ro_fr - $modules/scaleway_function_namespace.py: - maintainers: Lunik - $modules/scaleway_function_namespace_info.py: - maintainers: Lunik $modules/scaleway_function.py: - maintainers: Lunik + maintainers: Lunik $modules/scaleway_function_info.py: - maintainers: Lunik + maintainers: Lunik + $modules/scaleway_function_namespace.py: + maintainers: Lunik + $modules/scaleway_function_namespace_info.py: + maintainers: Lunik $modules/scaleway_image_info.py: maintainers: Spredzy $modules/scaleway_ip_info.py: @@ -499,195 +1114,18 @@ files: $modules/scaleway_snapshot_info.py: maintainers: Spredzy $modules/scaleway_volume.py: - labels: scaleway_volume ignore: hekonsek + labels: scaleway_volume $modules/scaleway_volume_info.py: maintainers: Spredzy - $modules/imgadm.py: - maintainers: $team_solaris - labels: solaris - keywords: beadm dladm illumos ipadm nexenta omnios openindiana pfexec smartos solaris sunos zfs zpool - $modules/nictagadm.py: - maintainers: $team_solaris SmithX10 - labels: solaris - keywords: beadm dladm illumos ipadm nexenta omnios openindiana pfexec smartos solaris sunos zfs zpool - $modules/smartos_image_info.py: - maintainers: $team_solaris - labels: solaris - keywords: beadm dladm illumos ipadm nexenta omnios openindiana pfexec smartos solaris sunos zfs zpool - $modules/vmadm.py: - maintainers: $team_solaris - labels: solaris - keywords: beadm dladm illumos ipadm nexenta omnios openindiana pfexec smartos solaris sunos zfs zpool - $modules/sl_vm.py: - maintainers: mcltn - $modules/spotinst_aws_elastigroup.py: - maintainers: talzur - $modules/udm_: - maintainers: keachi - $modules/webfaction_: - maintainers: quentinsf - $modules/xenserver_: - maintainers: bvitnik - $modules/consul: - maintainers: $team_consul - ignore: colin-nolan - $modules/etcd3.py: - maintainers: evrardjp - ignore: vfauth - $modules/nomad_: - maintainers: chris93111 - $modules/pacemaker_cluster.py: - maintainers: matbu - $modules/znode.py: - maintainers: treyperry - $modules/aerospike_migrations.py: - maintainers: Alb0t - $modules/influxdb_: - maintainers: kamsz - $modules/influxdb_query.py: - maintainers: resmo - $modules/influxdb_user.py: - maintainers: zhhuta - $modules/influxdb_write.py: - maintainers: resmo - $modules/elasticsearch_plugin.py: - maintainers: ThePixelDeveloper samdoran - $modules/kibana_plugin.py: - maintainers: barryib - $modules/odbc.py: - maintainers: john-westcott-iv - $modules/redis.py: - maintainers: slok - $modules/redis_info.py: - maintainers: levonet - $modules/redis_data_info.py: - maintainers: paginabianca - $modules/redis_data.py: - maintainers: paginabianca - $modules/redis_data_incr.py: - maintainers: paginabianca - $modules/riak.py: - maintainers: drewkerrigan jsmartin - $modules/mssql_db.py: - maintainers: vedit Jmainguy kenichi-ogawa-1988 - labels: mssql_db - $modules/mssql_script.py: - maintainers: kbudde - labels: mssql_script - $modules/hana_query.py: - maintainers: rainerleber - $modules/vertica_: - maintainers: dareko - $modules/archive.py: - maintainers: bendoh - $modules/filesize.py: - maintainers: quidame - $modules/ini_file.py: - maintainers: jpmens noseka1 - $modules/iso_create.py: - maintainers: Tomorrow9 - $modules/iso_customize.py: - maintainers: ZouYuhua - $modules/iso_extract.py: - maintainers: dagwieers jhoekx ribbons - $modules/read_csv.py: + $modules/sefcontext.py: maintainers: dagwieers - $modules/sapcar_extract.py: - maintainers: RainerLeber - $modules/xattr.py: - maintainers: bcoca - labels: xattr - $modules/xml.py: - maintainers: dagwieers magnus919 tbielawa cmprescott sm4rk0 - labels: m:xml xml - ignore: magnus919 - $modules/ipa_: - maintainers: $team_ipa - $modules/ipa_pwpolicy.py: - maintainers: adralioh - $modules/ipa_service.py: - maintainers: cprh - $modules/ipa_vault.py: - maintainers: jparrill - $modules/keycloak_: - maintainers: $team_keycloak - $modules/keycloak_authentication.py: - maintainers: elfelip Gaetan2907 - $modules/keycloak_clientscope.py: - maintainers: Gaetan2907 - $modules/keycloak_client_rolemapping.py: - maintainers: Gaetan2907 - $modules/keycloak_user_rolemapping.py: - maintainers: bratwurzt - $modules/keycloak_group.py: - maintainers: adamgoossens - $modules/keycloak_identity_provider.py: - maintainers: laurpaum - $modules/keycloak_realm_info.py: - maintainers: fynncfchen - $modules/keycloak_realm.py: - maintainers: kris2kris - $modules/keycloak_role.py: - maintainers: laurpaum - $modules/keycloak_user_federation.py: - maintainers: laurpaum - $modules/onepassword_info.py: - maintainers: Rylon - $modules/opendj_backendprop.py: - maintainers: dj-wasabi - $modules/airbrake_deployment.py: - maintainers: phumpal - labels: airbrake_deployment - ignore: bpennypacker - $modules/alerta_customer.py: - maintainers: cwollinger - $modules/bigpanda.py: - maintainers: hkariti - $modules/circonus_annotation.py: - maintainers: NickatEpic - $modules/datadog_event.py: - maintainers: n0ts - labels: datadog_event - ignore: arturaz - $modules/datadog_downtime.py: - maintainers: Datadog - $modules/datadog_monitor.py: - maintainers: skornehl - $modules/honeybadger_deployment.py: - maintainers: stympy - $modules/icinga2_feature.py: - maintainers: nerzhul - $modules/icinga2_host.py: - maintainers: t794104 - $modules/librato_annotation.py: - maintainers: Sedward - $modules/logentries.py: - labels: logentries - ignore: ivanvanderbyl - $modules/logstash_plugin.py: - maintainers: nerzhul - $modules/monit.py: - maintainers: dstoflet brian-brazil snopoke - labels: monit - $modules/nagios.py: - maintainers: tbielawa tgoetheyn - $modules/newrelic_deployment.py: - ignore: mcodd - $modules/pagerduty.py: - maintainers: suprememoocow thaumos - labels: pagerduty - ignore: bpennypacker - $modules/pagerduty_alert.py: - maintainers: ApsOps - $modules/pagerduty_change.py: - maintainers: adamvaughan - $modules/pagerduty_user.py: - maintainers: zanssa - $modules/pingdom.py: - maintainers: thaumos - $modules/rollbar_deployment.py: - maintainers: kavu + $modules/selinux_permissive.py: + maintainers: mscherer + $modules/selogin.py: + maintainers: bachradsusi dankeder jamescassell + $modules/sendgrid.py: + maintainers: makaimc $modules/sensu_: maintainers: dmsimard $modules/sensu_check.py: @@ -696,617 +1134,105 @@ files: maintainers: smbambling $modules/sensu_subscription.py: maintainers: andsens + $modules/seport.py: + maintainers: dankeder + $modules/serverless.py: + ignore: ryansb + $modules/shutdown.py: + maintainers: nitzmahone samdoran aminvakil + $modules/sl_vm.py: + maintainers: mcltn + $modules/slack.py: + maintainers: ramondelafuente + $modules/slackpkg.py: + maintainers: KimNorgaard + $modules/smartos_image_info.py: + keywords: beadm dladm illumos ipadm nexenta omnios openindiana pfexec smartos solaris sunos zfs zpool + labels: solaris + maintainers: $team_solaris + $modules/snap.py: + labels: snap + maintainers: angristan vcarceler + $modules/snap_alias.py: + labels: snap + maintainers: russoz + $modules/snmp_facts.py: + maintainers: ogenstad ujwalkomarla + $modules/solaris_zone.py: + keywords: beadm dladm illumos ipadm nexenta omnios openindiana pfexec smartos solaris sunos zfs zpool + labels: solaris + maintainers: $team_solaris pmarkham + $modules/sorcery.py: + maintainers: vaygr $modules/spectrum_device.py: maintainers: orgito $modules/spectrum_model_attrs.py: maintainers: tgates81 + $modules/spotinst_aws_elastigroup.py: + maintainers: talzur + $modules/ss_3par_cpg.py: + maintainers: farhan7500 gautamphegde + $modules/ssh_config.py: + maintainers: gaqzi Akasurde $modules/stackdriver.py: maintainers: bwhaley + $modules/stacki_host.py: + labels: stacki_host + maintainers: bsanders bbyhuy $modules/statsd.py: maintainers: mamercad $modules/statusio_maintenance.py: maintainers: bhcopeland - $modules/uptimerobot.py: - maintainers: nate-kingsley - $modules/cloudflare_dns.py: - maintainers: mgruener - labels: cloudflare_dns - $modules/dnsimple.py: - maintainers: drcapulet - $modules/dnsimple_info.py: - maintainers: edhilgendorf - $modules/dnsmadeeasy.py: - maintainers: briceburg - $modules/gandi_livedns.py: - maintainers: gthiemonge - $modules/haproxy.py: - maintainers: ravibhure Normo - $modules/infinity.py: - maintainers: MeganLiu - $modules/ip_netns.py: - maintainers: bregman-arie - $modules/ipify_facts.py: - maintainers: resmo - $modules/ipinfoio_facts.py: - maintainers: akostyuk - $modules/ipwcli_dns.py: - maintainers: cwollinger - $modules/ldap_attrs.py: - maintainers: drybjed jtyr noles - $modules/ldap_entry.py: - maintainers: jtyr - $modules/ldap_passwd.py: - maintainers: KellerFuchs jtyr - $modules/ldap_search.py: - maintainers: eryx12o45 jtyr - $modules/lldp.py: - labels: lldp - ignore: andyhky - $modules/netcup_dns.py: - maintainers: nbuchwitz - $modules/nsupdate.py: - maintainers: nerzhul - $modules/omapi_host.py: - maintainers: amasolov nerzhul - $modules/pritunl_: - maintainers: Lowess - $modules/nmcli.py: - maintainers: alcamie101 - $modules/snmp_facts.py: - maintainers: ogenstad ujwalkomarla - $modules/bearychat.py: - maintainers: tonyseek - $modules/campfire.py: - maintainers: fabulops - $modules/catapult.py: - maintainers: Jmainguy - $modules/cisco_webex.py: - maintainers: drew-russell - $modules/discord.py: - maintainers: cwollinger - $modules/flowdock.py: - ignore: mcodd - $modules/grove.py: - maintainers: zimbatm - $modules/hipchat.py: - maintainers: pb8226 shirou - $modules/irc.py: - maintainers: jpmens sivel - $modules/jabber.py: - maintainers: bcoca - $modules/logentries_msg.py: - maintainers: jcftang - $modules/mail.py: - maintainers: dagwieers - $modules/matrix.py: - maintainers: jcgruenhage - $modules/mattermost.py: - maintainers: bjolivot - $modules/mqtt.py: - maintainers: jpmens - $modules/nexmo.py: - maintainers: sivel - $modules/office_365_connector_card.py: - maintainers: marc-sensenich - $modules/pushbullet.py: - maintainers: willybarro - $modules/pushover.py: - maintainers: weaselkeeper wopfel - $modules/rocketchat.py: - maintainers: Deepakkothandan - labels: rocketchat - ignore: ramondelafuente - $modules/say.py: - maintainers: $team_ansible_core mpdehaan - $modules/sendgrid.py: - maintainers: makaimc - $modules/slack.py: - maintainers: ramondelafuente - $modules/syslogger.py: - maintainers: garbled1 - $modules/telegram.py: - maintainers: tyouxa loms lomserman - $modules/twilio.py: - maintainers: makaimc - $modules/typetalk.py: - maintainers: tksmd - $modules/ansible_galaxy_install.py: - maintainers: russoz - $modules/bower.py: - maintainers: mwarkentin - $modules/bundler.py: - maintainers: thoiberg - $modules/cargo.py: - maintainers: radek-sprta - $modules/composer.py: - maintainers: dmtrs - ignore: resmo - $modules/cpanm.py: - maintainers: fcuny russoz - $modules/easy_install.py: - maintainers: mattupstate - $modules/gem.py: - maintainers: $team_ansible_core johanwiren - labels: gem - $modules/maven_artifact.py: - maintainers: tumbl3w33d turb - labels: maven_artifact - ignore: chrisisbeef - $modules/npm.py: - maintainers: shane-walker xcambar - labels: npm - ignore: chrishoffman - $modules/pear.py: - labels: pear - ignore: jle64 - $modules/pip_package_info.py: - maintainers: bcoca matburt maxamillion - $modules/pipx.py: - maintainers: russoz - $modules/pipx_info.py: - maintainers: russoz - $modules/yarn.py: - maintainers: chrishoffman verkaufer - $modules/apk.py: - maintainers: tdtrask - labels: apk - ignore: kbrebanov - $modules/apt_repo.py: - maintainers: obirvalger - $modules/apt_rpm.py: - maintainers: evgkrsk - $modules/copr.py: - maintainers: schlupov - $modules/dnf_versionlock.py: - maintainers: moreda - $modules/flatpak.py: - maintainers: $team_flatpak - $modules/flatpak_remote.py: - maintainers: $team_flatpak - $modules/pkg5: - maintainers: $team_solaris mavit - labels: pkg5 solaris - keywords: beadm dladm illumos ipadm nexenta omnios openindiana pfexec smartos solaris sunos zfs zpool - $modules/homebrew.py: - notify: chris-short - maintainers: $team_macos andrew-d - labels: homebrew macos - ignore: ryansb - keywords: brew cask darwin homebrew macosx macports osx - $modules/homebrew_cask.py: - notify: chris-short - maintainers: $team_macos enriclluelles - labels: homebrew_ macos - ignore: ryansb - keywords: brew cask darwin homebrew macosx macports osx - $modules/homebrew_tap.py: - notify: chris-short - maintainers: $team_macos - labels: homebrew_ macos - ignore: ryansb - keywords: brew cask darwin homebrew macosx macports osx - $modules/installp.py: - maintainers: $team_aix kairoaraujo - labels: aix installp - keywords: aix efix lpar wpar - $modules/layman.py: - maintainers: jirutka - $modules/macports.py: - notify: chris-short - maintainers: $team_macos jcftang - labels: macos macports - ignore: ryansb - keywords: brew cask darwin homebrew macosx macports osx - $modules/mas.py: - maintainers: lukasbestle mheap - $modules/openbsd_pkg.py: - maintainers: $team_bsd eest - labels: bsd openbsd_pkg - ignore: ryansb - keywords: doas dragonfly freebsd iocage jail netbsd openbsd opnsense pfsense - $modules/opkg.py: - maintainers: skinp - $modules/pacman.py: - maintainers: elasticdog indrajitr tchernomax jraby - labels: pacman - ignore: elasticdog - $modules/pacman_key.py: - maintainers: grawlinson - labels: pacman - $modules/pkgin.py: - maintainers: $team_solaris L2G jasperla szinck martinm82 - labels: pkgin solaris - $modules/pkgng.py: - maintainers: $team_bsd bleader - labels: bsd pkgng - ignore: bleader - keywords: doas dragonfly freebsd iocage jail netbsd openbsd opnsense pfsense - $modules/pkgutil.py: - maintainers: $team_solaris dermute - labels: pkgutil solaris - $modules/portage.py: - maintainers: Tatsh wltjr - labels: portage - ignore: sayap - $modules/portinstall.py: - maintainers: $team_bsd berenddeboer - labels: bsd portinstall - ignore: ryansb - keywords: doas dragonfly freebsd iocage jail netbsd openbsd opnsense pfsense - $modules/pulp_repo.py: - maintainers: sysadmind - $modules/redhat_subscription.py: - maintainers: barnabycourt alikins kahowell - labels: redhat_subscription - $modules/rhn_channel.py: - maintainers: vincentvdk alikins $team_rhn - labels: rhn_channel - $modules/rhn_register.py: - maintainers: jlaska $team_rhn - labels: rhn_register - $modules/rhsm_release.py: - maintainers: seandst - $modules/rhsm_repository.py: - maintainers: giovannisciortino - $modules/rpm_ostree_pkg.py: - maintainers: dustymabe Akasurde - $modules/slackpkg.py: - maintainers: KimNorgaard - $modules/snap.py: - maintainers: angristan vcarceler - labels: snap - $modules/snap_alias.py: - maintainers: russoz - labels: snap - $modules/sorcery.py: - maintainers: vaygr - $modules/svr4pkg.py: - maintainers: $team_solaris brontitall - labels: solaris svr4pkg - $modules/swdepot.py: - maintainers: $team_hpux melodous - labels: hpux swdepot - keywords: hp-ux - $modules/swupd.py: - maintainers: hnanni albertomurillo - labels: swupd - $modules/urpmi.py: - maintainers: pmakowski - $modules/xbps.py: - maintainers: dinoocch the-maldridge - $modules/yum_versionlock.py: - maintainers: gyptazy aminvakil - $modules/zypper.py: - maintainers: $team_suse - labels: zypper - ignore: dirtyharrycallahan robinro - $modules/zypper_repository.py: - maintainers: $team_suse - labels: zypper - ignore: matze - $modules/cobbler_: - maintainers: dagwieers - $modules/hpilo_: - maintainers: haad - ignore: dagwieers - $modules/hponcfg.py: - maintainers: haad - ignore: dagwieers - $modules/imc_rest.py: - maintainers: dagwieers - labels: cisco - $modules/ipmi_: - maintainers: bgaifullin cloudnull - $modules/xcc_: - maintainers: panyy3 renxulei - $modules/lxca_: - maintainers: navalkp prabhosa - $modules/manageiq_: - labels: manageiq - maintainers: $team_manageiq - $modules/manageiq_alert_profiles.py: - maintainers: elad661 - $modules/manageiq_alerts.py: - maintainers: elad661 - $modules/manageiq_group.py: - maintainers: evertmulder - $modules/manageiq_policies_info.py: - maintainers: russoz $team_manageiq - $modules/manageiq_tags_info.py: - maintainers: russoz $team_manageiq - $modules/manageiq_tenant.py: - maintainers: evertmulder - $modules/oneview_: - maintainers: adriane-cardozo fgbulsoni tmiotto - $modules/oneview_datacenter_info.py: - maintainers: aalexmonteiro madhav-bharadwaj ricardogpsf soodpr - $modules/oneview_fc_network.py: - maintainers: fgbulsoni - $modules/oneview_fcoe_network.py: - maintainers: fgbulsoni - $modules/idrac_: - maintainers: $team_redfish - ignore: jose-delarosa - $modules/ilo_: - maintainers: $team_redfish - ignore: jose-delarosa - $modules/redfish_: - maintainers: $team_redfish - ignore: jose-delarosa - $modules/wdc_: - maintainers: $team_redfish - ignore: jose-delarosa - $modules/wdc_redfish_command.py: - maintainers: $team_wdc - $modules/wdc_redfish_info.py: - maintainers: $team_wdc - $modules/stacki_host.py: - maintainers: bsanders bbyhuy - labels: stacki_host - $modules/wakeonlan.py: - maintainers: dagwieers - $modules/bitbucket_: - maintainers: catcombo - $modules/bzr.py: - maintainers: andreparames - $modules/git_config.py: - maintainers: djmattyg007 mgedmin - $modules/github_deploy_key.py: - maintainers: bincyber - $modules/github_issue.py: - maintainers: Akasurde - $modules/github_key.py: - maintainers: erydo - labels: github_key - ignore: erydo - $modules/github_release.py: - maintainers: adrianmoisey - $modules/github_repo.py: - maintainers: atorrescogollo - $modules/github_: - maintainers: stpierre - $modules/gitlab_: - notify: jlozadad - maintainers: $team_gitlab - keywords: gitlab source_control - $modules/gitlab_project_variable.py: - maintainers: markuman - $modules/gitlab_runner.py: - maintainers: SamyCoenen - $modules/gitlab_user.py: - maintainers: LennertMertens stgrace - $modules/gitlab_branch.py: - maintainers: paytroff - $modules/hg.py: - maintainers: yeukhon - $modules/emc_vnx_sg_member.py: - maintainers: remixtj - $modules/ss_3par_cpg.py: - maintainers: farhan7500 gautamphegde - $modules/ibm_sa_: - maintainers: tzure - $modules/pmem.py: - maintainers: mizumm - $modules/vexata_: - maintainers: vexata - $modules/zfs: - maintainers: $team_solaris - labels: solaris - keywords: beadm dladm illumos ipadm nexenta omnios openindiana pfexec smartos solaris sunos zfs zpool - $modules/zfs.py: - maintainers: johanwiren - $modules/zfs_delegate_admin.py: - maintainers: natefoo - $modules/zpool_facts: - maintainers: $team_solaris - labels: solaris - keywords: beadm dladm illumos ipadm nexenta omnios openindiana pfexec smartos solaris sunos zfs zpool - $modules/aix: - maintainers: $team_aix - labels: aix - keywords: aix efix lpar wpar - $modules/alternatives.py: - maintainers: mulby - labels: alternatives - ignore: DavidWittman jiuka - $modules/aix_lvol.py: - maintainers: adejoux - $modules/awall.py: - maintainers: tdtrask - $modules/beadm.py: - maintainers: $team_solaris - labels: beadm solaris - keywords: beadm dladm illumos ipadm nexenta omnios openindiana pfexec smartos solaris sunos zfs zpool - $modules/capabilities.py: - maintainers: natefoo - $modules/cronvar.py: - maintainers: dougluce - $modules/crypttab.py: - maintainers: groks - $modules/dconf.py: - maintainers: azaghal - $modules/dpkg_divert.py: - maintainers: quidame - $modules/facter.py: - maintainers: $team_ansible_core gamethis - labels: facter - $modules/filesystem.py: - maintainers: pilou- abulimov quidame - labels: filesystem - $modules/gconftool2.py: - maintainers: Akasurde kevensen - labels: gconftool2 - $modules/gconftool2_info.py: - maintainers: russoz - labels: gconftool2 - $modules/homectl.py: - maintainers: jameslivulpi - $modules/interfaces_file.py: - maintainers: obourdon hryamzik - labels: interfaces_file - $modules/iptables_state.py: - maintainers: quidame - $modules/keyring.py: - maintainers: ahussey-redhat - $modules/keyring_info.py: - maintainers: ahussey-redhat - $modules/shutdown.py: - maintainers: nitzmahone samdoran aminvakil - $modules/java_cert.py: - maintainers: haad absynth76 - $modules/java_keystore.py: - maintainers: Mogztter quidame - $modules/kernel_blacklist.py: - maintainers: matze - $modules/launchd.py: - maintainers: martinm82 - $modules/lbu.py: - maintainers: kunkku - $modules/listen_ports_facts.py: - maintainers: ndavison - $modules/locale_gen.py: - maintainers: AugustusKling - $modules/lvg.py: - maintainers: abulimov - $modules/lvol.py: - maintainers: abulimov jhoekx zigaSRC unkaputtbar112 - $modules/make.py: - maintainers: LinusU - $modules/mksysb.py: - maintainers: $team_aix - labels: aix mksysb - $modules/modprobe.py: - maintainers: jdauphant mattjeffery - labels: modprobe - ignore: stygstra - $modules/nosh.py: - maintainers: tacatac - $modules/ohai.py: - maintainers: $team_ansible_core mpdehaan - labels: ohai - $modules/open_iscsi.py: - maintainers: srvg - $modules/openwrt_init.py: - maintainers: agaffney - $modules/osx_defaults.py: - notify: chris-short - maintainers: $team_macos notok - labels: macos osx_defaults - keywords: brew cask darwin homebrew macosx macports osx - $modules/pam_limits.py: - maintainers: giovannisciortino - labels: pam_limits - ignore: usawa - $modules/pamd.py: - maintainers: kevensen - $modules/parted.py: - maintainers: ColOfAbRiX rosowiecki jake2184 - $modules/pids.py: - maintainers: saranyasridharan - $modules/puppet.py: - maintainers: nibalizer emonty - labels: puppet - $modules/python_requirements_info.py: - maintainers: willthames - ignore: ryansb - $modules/runit.py: - maintainers: jsumners - $modules/sap_task_list_execute: - maintainers: rainerleber - $modules/sefcontext.py: - maintainers: dagwieers - $modules/selinux_permissive.py: - maintainers: mscherer - $modules/selogin.py: - maintainers: bachradsusi dankeder jamescassell - $modules/seport.py: - maintainers: dankeder - $modules/solaris_zone.py: - maintainers: $team_solaris pmarkham - labels: solaris - keywords: beadm dladm illumos ipadm nexenta omnios openindiana pfexec smartos solaris sunos zfs zpool - $modules/ssh_config.py: - maintainers: gaqzi Akasurde $modules/sudoers.py: maintainers: JonEllis + $modules/supervisorctl.py: + maintainers: inetfuture mattupstate $modules/svc.py: maintainers: bcoca + $modules/svr4pkg.py: + labels: solaris svr4pkg + maintainers: $team_solaris brontitall + $modules/swdepot.py: + keywords: hp-ux + labels: hpux swdepot + maintainers: $team_hpux melodous + $modules/swupd.py: + labels: swupd + maintainers: hnanni albertomurillo + $modules/syslogger.py: + maintainers: garbled1 $modules/syspatch.py: maintainers: precurse $modules/sysrc.py: maintainers: dlundgren $modules/sysupgrade.py: maintainers: precurse + $modules/taiga_issue.py: + maintainers: lekum + $modules/telegram.py: + maintainers: tyouxa loms lomserman + $modules/terraform.py: + ignore: ryansb + maintainers: m-yosefpor rainerleber $modules/timezone.py: maintainers: indrajitr jasperla tmshn + $modules/twilio.py: + maintainers: makaimc + $modules/typetalk.py: + maintainers: tksmd + $modules/udm_: + maintainers: keachi $modules/ufw.py: - notify: felixfontein - maintainers: ahtik ovcharenko pyykkis labels: ufw - $modules/vdo.py: - maintainers: rhawalsh bgurney-rh - $modules/xfconf.py: - maintainers: russoz jbenden - labels: xfconf - $modules/xfconf_info.py: - maintainers: russoz - labels: xfconf - $modules/xfs_quota.py: - maintainers: bushvin - $modules/apache2_mod_proxy.py: - maintainers: oboukili - $modules/apache2_module.py: - maintainers: berendt n0trax - ignore: robinro - $modules/deploy_helper.py: - maintainers: ramondelafuente - $modules/django_manage.py: - maintainers: russoz - ignore: scottanderson42 tastychutney - labels: django_manage - $modules/ejabberd_user.py: - maintainers: privateip - $modules/gunicorn.py: - maintainers: agmezr - $modules/htpasswd.py: - maintainers: $team_ansible_core - labels: htpasswd - $modules/jboss.py: - maintainers: $team_jboss jhoekx - labels: jboss - $modules/jenkins_build.py: - maintainers: brettmilford unnecessary-username - $modules/jenkins_job.py: - maintainers: sermilrod - $modules/jenkins_job_info.py: - maintainers: stpierre - $modules/jenkins_plugin.py: - maintainers: jtyr - $modules/jenkins_script.py: - maintainers: hogarthj - $modules/jira.py: - maintainers: Slezhuk tarka pertoft - ignore: DWSR - labels: jira - $modules/nginx_status_info.py: - maintainers: resmo - $modules/rundeck_acl_policy.py: - maintainers: nerzhul - $modules/rundeck_project.py: - maintainers: nerzhul - $modules/rundeck_job_run.py: - maintainers: phsmith - $modules/rundeck_job_executions_info.py: - maintainers: phsmith + maintainers: ahtik ovcharenko pyykkis + notify: felixfontein + $modules/uptimerobot.py: + maintainers: nate-kingsley + $modules/urpmi.py: + maintainers: pmakowski $modules/utm_: + keywords: sophos utm maintainers: $team_e_spirit - keywords: sophos utm - $modules/utm_proxy_auth_profile.py: - maintainers: $team_e_spirit stearz - keywords: sophos utm - $modules/utm_proxy_exception.py: - maintainers: $team_e_spirit RickS-C137 - keywords: sophos utm $modules/utm_ca_host_key_cert.py: maintainers: stearz $modules/utm_ca_host_key_cert_info.py: @@ -1315,24 +1241,98 @@ files: maintainers: steamx $modules/utm_network_interface_address_info.py: maintainers: steamx - $modules/supervisorctl.py: - maintainers: inetfuture mattupstate - $modules/taiga_issue.py: - maintainers: lekum + $modules/utm_proxy_auth_profile.py: + keywords: sophos utm + maintainers: $team_e_spirit stearz + $modules/utm_proxy_exception.py: + keywords: sophos utm + maintainers: $team_e_spirit RickS-C137 + $modules/vdo.py: + maintainers: rhawalsh bgurney-rh + $modules/vertica_: + maintainers: dareko + $modules/vexata_: + maintainers: vexata + $modules/vmadm.py: + keywords: beadm dladm illumos ipadm nexenta omnios openindiana pfexec smartos solaris sunos zfs zpool + labels: solaris + maintainers: $team_solaris + $modules/wakeonlan.py: + maintainers: dagwieers + $modules/wdc_: + ignore: jose-delarosa + maintainers: $team_redfish + $modules/wdc_redfish_command.py: + maintainers: $team_wdc + $modules/wdc_redfish_info.py: + maintainers: $team_wdc + $modules/webfaction_: + maintainers: quentinsf + $modules/xattr.py: + labels: xattr + maintainers: bcoca + $modules/xbps.py: + maintainers: dinoocch the-maldridge + $modules/xcc_: + maintainers: panyy3 renxulei + $modules/xenserver_: + maintainers: bvitnik + $modules/xenserver_facts.py: + ignore: andyhky ryansb + labels: xenserver_facts + maintainers: caphrim007 cheese + $modules/xfconf.py: + labels: xfconf + maintainers: russoz jbenden + $modules/xfconf_info.py: + labels: xfconf + maintainers: russoz + $modules/xfs_quota.py: + maintainers: bushvin + $modules/xml.py: + ignore: magnus919 + labels: m:xml xml + maintainers: dagwieers magnus919 tbielawa cmprescott sm4rk0 + $modules/yarn.py: + maintainers: chrishoffman verkaufer + $modules/yum_versionlock.py: + maintainers: gyptazy aminvakil + $modules/zfs: + keywords: beadm dladm illumos ipadm nexenta omnios openindiana pfexec smartos solaris sunos zfs zpool + labels: solaris + maintainers: $team_solaris + $modules/zfs.py: + maintainers: johanwiren + $modules/zfs_delegate_admin.py: + maintainers: natefoo + $modules/znode.py: + maintainers: treyperry + $modules/zpool_facts: + keywords: beadm dladm illumos ipadm nexenta omnios openindiana pfexec smartos solaris sunos zfs zpool + labels: solaris + maintainers: $team_solaris + $modules/zypper.py: + ignore: dirtyharrycallahan robinro + labels: zypper + maintainers: $team_suse + $modules/zypper_repository.py: + ignore: matze + labels: zypper + maintainers: $team_suse $tests/a_module.py: maintainers: felixfontein ######################### tests/: labels: tests - tests/unit/: - labels: unit - support: community tests/integration: labels: integration support: community - tests/utils/: - maintainers: gundalow + tests/unit/: labels: unit + support: community + tests/utils/: + labels: unit + maintainers: gundalow macros: actions: plugins/action becomes: plugins/become From be0b5e5f8c363791403246ca5e49f1a63adf4446 Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Sun, 6 Nov 2022 05:32:35 -0500 Subject: [PATCH 0009/1810] onepassword - Support v2 (#4728) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Begin building out separate classes to support different op cli versions Create separet base classes for each major version. Define the main interface in the base class. Create methods for getting the current version and instantiating the appropriate class based on the found version. * First pass at mostly working CLI version classes * Correct mismathched parameters * Update _run() method to allow updating enviroment This allows passing in the app secret as an env var, which is more secure than using a command line arg. * Continuing to improve the interface * Tear existing tests down to the studs These tests were based off of the LastPass unit tests. I’m going to just start from scratch given the new plugin code is vastly diffenent. * Fix sanity test * CLI config file path can be None * Improve required param checking - only report missing params - use proper grammer based on number of missing params * Change assert_logged_in() method return value Return a boolean value indicating whether or not account is signed in * Improve full login for v2 Have to do a bit of a dance to avoid hitting the interactive prompt if there are no accounts configured. * Remove unused methods * Add some tests * Fix linting errors * Move fixtures to separate file * Restructure mock test data and add more tests * Add boilerplate * Add test scenario for op v2 and increase coverage * Fix up copyright statements * Test v1 and v2 in all cases * Use a more descriptive variable name * Use docstrings rather than pass in abstract class This adds coverage to abstract methods with the least amount of hackery. * Increase test coverage for CLI classes * Sort test parameters to avoid collection errors * Update version tested in docs * Revere test parameter sorting for now The parameters need to be sorted to avoid the issue in older Python versions in CI, but I’m having trouble working out how to do that currently. * Allow passing kwargs to the lookup module under test * Favor label over id for v2 when looking for values Add tests * Display a warning for section on op v2 or greater There is no “value” in section fields. If we wanted to support sections in v2, we would also have to allow specifying the field name in order to override “value”. * Move test cases to their own file Getting a bit unwieldy having it in the test file * Move output into JSON files fore easier reuse * Switch to using get_options() * Add licenses for fixture files * Use get_option() since get_options() was added in Ansible Core 2.12 * Rearrange fixtures * Add changelog * Move common classes to module_utils * Move common classes back to lookup The plugin relies on AnsibleLookupError() quite a bit which is not available in module code. Remove use of display for errors since section isn’t actually deprecated. * Properly handle sections Still room for improvement, but this is at least a start. * Remove some comments that won’t be addressed * Make test gathering more deterministic to avoid failures * Update changelog fragment * Simple fix for making tests reliable --- changelogs/fragments/4728-onepassword-v2.yml | 2 + plugins/lookup/onepassword.py | 533 ++++++++++++++---- plugins/lookup/onepassword_raw.py | 17 +- .../plugins/lookup/onepassword/__init__.py | 0 .../unit/plugins/lookup/onepassword/common.py | 85 +++ .../plugins/lookup/onepassword/conftest.py | 39 ++ .../onepassword/fixtures/v1_out_01.json | 18 + .../fixtures/v1_out_01.json.license | 3 + .../onepassword/fixtures/v1_out_02.json | 18 + .../fixtures/v1_out_02.json.license | 3 + .../onepassword/fixtures/v1_out_03.json | 20 + .../fixtures/v1_out_03.json.license | 3 + .../onepassword/fixtures/v2_out_01.json | 35 ++ .../fixtures/v2_out_01.json.license | 3 + .../onepassword/fixtures/v2_out_02.json | 85 +++ .../fixtures/v2_out_02.json.license | 3 + .../onepassword/fixtures/v2_out_03.json | 103 ++++ .../fixtures/v2_out_03.json.license | 3 + .../lookup/onepassword/test_onepassword.py | 182 ++++++ .../onepassword/test_onepassword_cli_v1.py | 50 ++ .../onepassword/test_onepassword_cli_v2.py | 52 ++ tests/unit/plugins/lookup/test_onepassword.py | 322 ----------- .../plugins/module_utils/test_onepassword.py | 44 ++ 23 files changed, 1196 insertions(+), 427 deletions(-) create mode 100644 changelogs/fragments/4728-onepassword-v2.yml create mode 100644 tests/unit/plugins/lookup/onepassword/__init__.py create mode 100644 tests/unit/plugins/lookup/onepassword/common.py create mode 100644 tests/unit/plugins/lookup/onepassword/conftest.py create mode 100644 tests/unit/plugins/lookup/onepassword/fixtures/v1_out_01.json create mode 100644 tests/unit/plugins/lookup/onepassword/fixtures/v1_out_01.json.license create mode 100644 tests/unit/plugins/lookup/onepassword/fixtures/v1_out_02.json create mode 100644 tests/unit/plugins/lookup/onepassword/fixtures/v1_out_02.json.license create mode 100644 tests/unit/plugins/lookup/onepassword/fixtures/v1_out_03.json create mode 100644 tests/unit/plugins/lookup/onepassword/fixtures/v1_out_03.json.license create mode 100644 tests/unit/plugins/lookup/onepassword/fixtures/v2_out_01.json create mode 100644 tests/unit/plugins/lookup/onepassword/fixtures/v2_out_01.json.license create mode 100644 tests/unit/plugins/lookup/onepassword/fixtures/v2_out_02.json create mode 100644 tests/unit/plugins/lookup/onepassword/fixtures/v2_out_02.json.license create mode 100644 tests/unit/plugins/lookup/onepassword/fixtures/v2_out_03.json create mode 100644 tests/unit/plugins/lookup/onepassword/fixtures/v2_out_03.json.license create mode 100644 tests/unit/plugins/lookup/onepassword/test_onepassword.py create mode 100644 tests/unit/plugins/lookup/onepassword/test_onepassword_cli_v1.py create mode 100644 tests/unit/plugins/lookup/onepassword/test_onepassword_cli_v2.py delete mode 100644 tests/unit/plugins/lookup/test_onepassword.py create mode 100644 tests/unit/plugins/module_utils/test_onepassword.py diff --git a/changelogs/fragments/4728-onepassword-v2.yml b/changelogs/fragments/4728-onepassword-v2.yml new file mode 100644 index 0000000000..fbec3aa60d --- /dev/null +++ b/changelogs/fragments/4728-onepassword-v2.yml @@ -0,0 +1,2 @@ +minor_changes: + - onepassword - support version 2 of the OnePassword CLI (https://github.com/ansible-collections/community.general/pull/4728) diff --git a/plugins/lookup/onepassword.py b/plugins/lookup/onepassword.py index 42e07e9cbf..bbd11d6645 100644 --- a/plugins/lookup/onepassword.py +++ b/plugins/lookup/onepassword.py @@ -55,7 +55,7 @@ DOCUMENTATION = ''' - This lookup stores potentially sensitive data from 1Password as Ansible facts. Facts are subject to caching if enabled, which means this data could be stored in clear text on disk or in a database. - - Tested with C(op) version 0.5.3 + - Tested with C(op) version 2.7.2 ''' EXAMPLES = """ @@ -96,106 +96,123 @@ RETURN = """ elements: str """ -import errno -import json +import abc import os - -from subprocess import Popen, PIPE +import json +import subprocess from ansible.plugins.lookup import LookupBase from ansible.errors import AnsibleLookupError +from ansible.module_utils.common.process import get_bin_path from ansible.module_utils.common.text.converters import to_bytes, to_text +from ansible.module_utils.six import with_metaclass from ansible_collections.community.general.plugins.module_utils.onepassword import OnePasswordConfig -class OnePass(object): - def __init__(self, path='op'): - self.cli_path = path - self.logged_in = False - self.token = None - self.subdomain = None - self.domain = None - self.username = None - self.secret_key = None - self.master_password = None +class OnePassCLIBase(with_metaclass(abc.ABCMeta, object)): + bin = "op" - self._config = OnePasswordConfig() + def __init__(self, subdomain=None, domain="1password.com", username=None, secret_key=None, master_password=None): + self.subdomain = subdomain + self.domain = domain + self.username = username + self.master_password = master_password + self.secret_key = secret_key - def get_token(self): - # If the config file exists, assume an initial signin has taken place and try basic sign in - if os.path.isfile(self._config.config_file_path): + self._path = None + self._version = None - if not self.master_password: - raise AnsibleLookupError('Unable to sign in to 1Password. master_password is required.') + def _check_required_params(self, required_params): + non_empty_attrs = dict((param, getattr(self, param, None)) for param in required_params if getattr(self, param, None)) + missing = set(required_params).difference(non_empty_attrs) + if missing: + prefix = "Unable to sign in to 1Password. Missing required parameter" + plural = "" + suffix = ": {params}.".format(params=", ".join(missing)) + if len(missing) > 1: + plural = "s" - try: - args = ['signin', '--output=raw'] + msg = "{prefix}{plural}{suffix}".format(prefix=prefix, plural=plural, suffix=suffix) + raise AnsibleLookupError(msg) - if self.subdomain: - args = ['signin', self.subdomain, '--output=raw'] + @abc.abstractmethod + def _parse_field(self, data_json, field_name, section_title): + """Main method for parsing data returned from the op command line tool""" - rc, out, err = self._run(args, command_input=to_bytes(self.master_password)) - self.token = out.strip() + def _run(self, args, expected_rc=0, command_input=None, ignore_errors=False, environment_update=None): + command = [self.path] + args + call_kwargs = { + "stdout": subprocess.PIPE, + "stderr": subprocess.PIPE, + "stdin": subprocess.PIPE, + } - except AnsibleLookupError: - self.full_login() + if environment_update: + env = os.environ.copy() + env.update(environment_update) + call_kwargs["env"] = env - else: - # Attempt a full sign in since there appears to be no existing sign in - self.full_login() - - def assert_logged_in(self): - try: - rc, out, err = self._run(['get', 'account'], ignore_errors=True) - if rc == 0: - self.logged_in = True - if not self.logged_in: - self.get_token() - except OSError as e: - if e.errno == errno.ENOENT: - raise AnsibleLookupError("1Password CLI tool '%s' not installed in path on control machine" % self.cli_path) - raise e - - def get_raw(self, item_id, vault=None): - args = ["get", "item", item_id] - if vault is not None: - args += ['--vault={0}'.format(vault)] - if not self.logged_in: - args += [to_bytes('--session=') + self.token] - rc, output, dummy = self._run(args) - return output - - def get_field(self, item_id, field, section=None, vault=None): - output = self.get_raw(item_id, vault) - return self._parse_field(output, field, section) if output != '' else '' - - def full_login(self): - if None in [self.subdomain, self.username, self.secret_key, self.master_password]: - raise AnsibleLookupError('Unable to perform initial sign in to 1Password. ' - 'subdomain, username, secret_key, and master_password are required to perform initial sign in.') - - args = [ - 'signin', - '{0}.{1}'.format(self.subdomain, self.domain), - to_bytes(self.username), - to_bytes(self.secret_key), - '--output=raw', - ] - - rc, out, err = self._run(args, command_input=to_bytes(self.master_password)) - self.token = out.strip() - - def _run(self, args, expected_rc=0, command_input=None, ignore_errors=False): - command = [self.cli_path] + args - p = Popen(command, stdout=PIPE, stderr=PIPE, stdin=PIPE) + p = subprocess.Popen(command, **call_kwargs) out, err = p.communicate(input=command_input) rc = p.wait() + if not ignore_errors and rc != expected_rc: raise AnsibleLookupError(to_text(err)) + return rc, out, err - def _parse_field(self, data_json, field_name, section_title=None): + @abc.abstractmethod + def assert_logged_in(self): + """Check whether a login session exists""" + + @abc.abstractmethod + def full_signin(self): + """Performa full login""" + + @abc.abstractmethod + def get_raw(self, item_id, vault=None, token=None): + """Gets the specified item from the vault""" + + @abc.abstractmethod + def signin(self): + """Sign in using the master password""" + + @property + def path(self): + if self._path is None: + self._path = get_bin_path(self.bin) + + return self._path + + @property + def version(self): + if self._version is None: + self._version = self.get_current_version() + + return self._version + + @classmethod + def get_current_version(cls): + """Standalone method to get the op CLI version. Useful when determining which class to load + based on the current version.""" + try: + bin_path = get_bin_path(cls.bin) + except ValueError: + raise AnsibleLookupError("Unable to locate '%s' command line tool" % cls.bin) + + try: + b_out = subprocess.check_output([bin_path, "--version"], stderr=subprocess.PIPE) + except subprocess.CalledProcessError as cpe: + raise AnsibleLookupError("Unable to get the op version: %s" % cpe) + + return to_text(b_out).strip() + + +class OnePassCLIv1(OnePassCLIBase): + supports_version = "1" + + def _parse_field(self, data_json, field_name, section_title): """ Retrieves the desired field from the `op` response payload @@ -249,36 +266,356 @@ class OnePass(object): # check the details dictionary for `field_name` and return it immediately if it exists # when the entry is a "password" instead of a "login" item, the password field is a key # in the `details` dictionary: - if field_name in data['details']: - return data['details'][field_name] + if field_name in data["details"]: + return data["details"][field_name] # when the field is not found above, iterate through the fields list in the object details - for field_data in data['details'].get('fields', []): - if field_data.get('name', '').lower() == field_name.lower(): - return field_data.get('value', '') - for section_data in data['details'].get('sections', []): - if section_title is not None and section_title.lower() != section_data['title'].lower(): + for field_data in data["details"].get("fields", []): + if field_data.get("name", "").lower() == field_name.lower(): + return field_data.get("value", "") + + for section_data in data["details"].get("sections", []): + if section_title is not None and section_title.lower() != section_data["title"].lower(): continue - for field_data in section_data.get('fields', []): - if field_data.get('t', '').lower() == field_name.lower(): - return field_data.get('v', '') - return '' + + for field_data in section_data.get("fields", []): + if field_data.get("t", "").lower() == field_name.lower(): + return field_data.get("v", "") + + return "" + + def assert_logged_in(self): + args = ["get", "account"] + if self.subdomain: + account = "{subdomain}.{domain}".format(subdomain=self.subdomain, domain=self.domain) + args.extend(["--account", account]) + + rc, out, err = self._run(args, ignore_errors=True) + + return not bool(rc) + + def full_signin(self): + required_params = [ + "subdomain", + "username", + "secret_key", + "master_password", + ] + self._check_required_params(required_params) + + args = [ + "signin", + "{0}.{1}".format(self.subdomain, self.domain), + to_bytes(self.username), + to_bytes(self.secret_key), + "--raw", + ] + + return self._run(args, command_input=to_bytes(self.master_password)) + + def get_raw(self, item_id, vault=None, token=None): + args = ["get", "item", item_id] + if vault is not None: + args += ["--vault={0}".format(vault)] + + if token is not None: + args += [to_bytes("--session=") + token] + + return self._run(args) + + def signin(self): + self._check_required_params(['master_password']) + + args = ["signin", "--raw"] + if self.subdomain: + args.append(self.subdomain) + + return self._run(args, command_input=to_bytes(self.master_password)) + + +class OnePassCLIv2(OnePassCLIBase): + """ + CLIv2 Syntax Reference: https://developer.1password.com/docs/cli/upgrade#step-2-update-your-scripts + """ + supports_version = "2" + + def _parse_field(self, data_json, field_name, section_title=None): + """ + Schema reference: https://developer.1password.com/docs/cli/item-template-json + + Example Data: + + # Password item + { + "id": "ywvdbojsguzgrgnokmcxtydgdv", + "title": "Authy Backup", + "version": 1, + "vault": { + "id": "bcqxysvcnejjrwzoqrwzcqjqxc", + "name": "Personal" + }, + "category": "PASSWORD", + "last_edited_by": "7FUPZ8ZNE02KSHMAIMKHIVUE17", + "created_at": "2015-01-18T13:13:38Z", + "updated_at": "2016-02-20T16:23:54Z", + "additional_information": "Jan 18, 2015, 08:13:38", + "fields": [ + { + "id": "password", + "type": "CONCEALED", + "purpose": "PASSWORD", + "label": "password", + "value": "OctoberPoppyNuttyDraperySabbath", + "reference": "op://Personal/Authy Backup/password", + "password_details": { + "strength": "FANTASTIC" + } + }, + { + "id": "notesPlain", + "type": "STRING", + "purpose": "NOTES", + "label": "notesPlain", + "value": "Backup password to restore Authy", + "reference": "op://Personal/Authy Backup/notesPlain" + } + ] + } + + # Login item + { + "id": "awk4s2u44fhnrgppszcsvc663i", + "title": "Dummy Login", + "version": 2, + "vault": { + "id": "stpebbaccrq72xulgouxsk4p7y", + "name": "Personal" + }, + "category": "LOGIN", + "last_edited_by": "LSGPJERUYBH7BFPHMZ2KKGL6AU", + "created_at": "2018-04-25T21:55:19Z", + "updated_at": "2018-04-25T21:56:06Z", + "additional_information": "agent.smith", + "urls": [ + { + "primary": true, + "href": "https://acme.com" + } + ], + "sections": [ + { + "id": "linked items", + "label": "Related Items" + } + ], + "fields": [ + { + "id": "username", + "type": "STRING", + "purpose": "USERNAME", + "label": "username", + "value": "agent.smith", + "reference": "op://Personal/Dummy Login/username" + }, + { + "id": "password", + "type": "CONCEALED", + "purpose": "PASSWORD", + "label": "password", + "value": "Q7vFwTJcqwxKmTU]Dzx7NW*wrNPXmj", + "entropy": 159.6083697084228, + "reference": "op://Personal/Dummy Login/password", + "password_details": { + "entropy": 159, + "generated": true, + "strength": "FANTASTIC" + } + }, + { + "id": "notesPlain", + "type": "STRING", + "purpose": "NOTES", + "label": "notesPlain", + "reference": "op://Personal/Dummy Login/notesPlain" + } + ] + } + """ + data = json.loads(data_json) + for field in data.get("fields", []): + if section_title is None: + # If the field name exists in the section, return that value + if field.get(field_name): + return field.get(field_name) + + # If the field name doesn't exist in the section, match on the value of "label" + # then "id" and return "value" + if field.get("label") == field_name: + return field["value"] + + if field.get("id") == field_name: + return field["value"] + + # Look at the section data and get an indentifier. The value of 'id' is either a unique ID + # or a human-readable string. If a 'label' field exists, prefer that since + # it is the value visible in the 1Password UI when both 'id' and 'label' exist. + section = field.get("section", {}) + current_section_title = section.get("label", section.get("id")) + if section_title == current_section_title: + # In the correct section. Check "label" then "id" for the desired field_name + if field.get("label") == field_name: + return field["value"] + + if field.get("id") == field_name: + return field["value"] + + return "" + + def assert_logged_in(self): + args = ["account", "list"] + if self.subdomain: + account = "{subdomain}.{domain}".format(subdomain=self.subdomain, domain=self.domain) + args.extend(["--account", account]) + + rc, out, err = self._run(args) + + if out: + # Running 'op account get' if there are no accounts configured on the system drops into + # an interactive prompt. Only run 'op account get' after first listing accounts to see + # if there are any previously configured accounts. + args = ["account", "get"] + if self.subdomain: + account = "{subdomain}.{domain}".format(subdomain=self.subdomain, domain=self.domain) + args.extend(["--account", account]) + + rc, out, err = self._run(args) + + return not bool(rc) + + return False + + def full_signin(self): + required_params = [ + "subdomain", + "username", + "secret_key", + "master_password", + ] + self._check_required_params(required_params) + + args = [ + "account", "add", "--raw", + "--address", "{0}.{1}".format(self.subdomain, self.domain), + "--email", to_bytes(self.username), + "--signin", + ] + + environment_update = {"OP_SECRET_KEY": self.secret_key} + return self._run(args, command_input=to_bytes(self.master_password), environment_update=environment_update) + + def get_raw(self, item_id, vault=None, token=None): + args = ["item", "get", item_id, "--format", "json"] + if vault is not None: + args += ["--vault={0}".format(vault)] + if token is not None: + args += [to_bytes("--session=") + token] + + return self._run(args) + + def signin(self): + self._check_required_params(['master_password']) + + args = ["signin", "--raw"] + if self.subdomain: + args.extend(["--account", self.subdomain]) + + return self._run(args, command_input=to_bytes(self.master_password)) + + +class OnePass(object): + def __init__(self, subdomain=None, domain="1password.com", username=None, secret_key=None, master_password=None): + self.subdomain = subdomain + self.domain = domain + self.username = username + self.secret_key = secret_key + self.master_password = master_password + + self.logged_in = False + self.token = None + + self._config = OnePasswordConfig() + self._cli = self._get_cli_class() + + def _get_cli_class(self): + version = OnePassCLIBase.get_current_version() + for cls in OnePassCLIBase.__subclasses__(): + if cls.supports_version == version.split(".")[0]: + try: + return cls(self.subdomain, self.domain, self.username, self.secret_key, self.master_password) + except TypeError as e: + raise AnsibleLookupError(e) + + raise AnsibleLookupError("op version %s is unsupported" % version) + + def set_token(self): + if self._config.config_file_path and os.path.isfile(self._config.config_file_path): + # If the config file exists, assume an initial sign in has taken place and try basic sign in + try: + rc, out, err = self._cli.signin() + except AnsibleLookupError as exc: + test_strings = ( + "missing required parameters", + "unauthorized", + ) + if any(string in exc.message.lower() for string in test_strings): + # A required parameter is missing, or a bad master password was supplied + # so don't bother attempting a full signin + raise + + rc, out, err = self._cli.full_signin() + + self.token = out.strip() + + else: + # Attempt a full signin since there appears to be no existing signin + rc, out, err = self._cli.full_signin() + self.token = out.strip() + + def assert_logged_in(self): + logged_in = self._cli.assert_logged_in() + if logged_in: + self.logged_in = logged_in + pass + else: + self.set_token() + + def get_raw(self, item_id, vault=None): + rc, out, err = self._cli.get_raw(item_id, vault, self.token) + return out + + def get_field(self, item_id, field, section=None, vault=None): + output = self.get_raw(item_id, vault) + if output: + return self._cli._parse_field(output, field, section) + + return "" class LookupModule(LookupBase): def run(self, terms, variables=None, **kwargs): - op = OnePass() + self.set_options(var_options=variables, direct=kwargs) - field = kwargs.get('field', 'password') - section = kwargs.get('section') - vault = kwargs.get('vault') - op.subdomain = kwargs.get('subdomain') - op.domain = kwargs.get('domain', '1password.com') - op.username = kwargs.get('username') - op.secret_key = kwargs.get('secret_key') - op.master_password = kwargs.get('master_password', kwargs.get('vault_password')) + field = self.get_option("field") + section = self.get_option("section") + vault = self.get_option("vault") + subdomain = self.get_option("subdomain") + domain = self.get_option("domain") + username = self.get_option("username") + secret_key = self.get_option("secret_key") + master_password = self.get_option("master_password") + op = OnePass(subdomain, domain, username, secret_key, master_password) op.assert_logged_in() values = [] diff --git a/plugins/lookup/onepassword_raw.py b/plugins/lookup/onepassword_raw.py index 9a1e0741a0..c7b9332953 100644 --- a/plugins/lookup/onepassword_raw.py +++ b/plugins/lookup/onepassword_raw.py @@ -47,7 +47,7 @@ DOCUMENTATION = ''' - This lookup stores potentially sensitive data from 1Password as Ansible facts. Facts are subject to caching if enabled, which means this data could be stored in clear text on disk or in a database. - - Tested with C(op) version 0.5.3 + - Tested with C(op) version 2.7.0 ''' EXAMPLES = """ @@ -76,18 +76,21 @@ from ansible.plugins.lookup import LookupBase class LookupModule(LookupBase): def run(self, terms, variables=None, **kwargs): - op = OnePass() + self.set_options(var_options=variables, direct=kwargs) - vault = kwargs.get('vault') - op.subdomain = kwargs.get('subdomain') - op.username = kwargs.get('username') - op.secret_key = kwargs.get('secret_key') - op.master_password = kwargs.get('master_password', kwargs.get('vault_password')) + vault = self.get_option("vault") + subdomain = self.get_option("subdomain") + domain = self.get_option("domain", "1password.com") + username = self.get_option("username") + secret_key = self.get_option("secret_key") + master_password = self.get_option("master_password") + op = OnePass(subdomain, domain, username, secret_key, master_password) op.assert_logged_in() values = [] for term in terms: data = json.loads(op.get_raw(term, vault)) values.append(data) + return values diff --git a/tests/unit/plugins/lookup/onepassword/__init__.py b/tests/unit/plugins/lookup/onepassword/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/unit/plugins/lookup/onepassword/common.py b/tests/unit/plugins/lookup/onepassword/common.py new file mode 100644 index 0000000000..141aea91a3 --- /dev/null +++ b/tests/unit/plugins/lookup/onepassword/common.py @@ -0,0 +1,85 @@ +# Copyright (c) 2022 Ansible Project +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os +import json + +from ansible_collections.community.general.plugins.lookup.onepassword import ( + OnePassCLIv1, + OnePassCLIv2, +) + + +def load_file(file): + with open((os.path.join(os.path.dirname(__file__), "fixtures", file)), "r") as f: + return json.loads(f.read()) + + +# Intentionally excludes metadata leaf nodes that would exist in real output if not relevant. +MOCK_ENTRIES = { + OnePassCLIv1: [ + { + 'vault_name': 'Acme "Quot\'d" Servers', + 'queries': [ + '0123456789', + 'Mock "Quot\'d" Server' + ], + 'expected': ['t0pS3cret', 't0pS3cret'], + 'output': load_file("v1_out_01.json"), + }, + { + 'vault_name': 'Acme Logins', + 'queries': [ + '9876543210', + 'Mock Website', + 'acme.com' + ], + 'expected': ['t0pS3cret', 't0pS3cret', 't0pS3cret'], + 'output': load_file("v1_out_02.json"), + }, + { + 'vault_name': 'Acme Logins', + 'queries': [ + '864201357' + ], + 'expected': ['vauxhall'], + 'output': load_file("v1_out_03.json"), + }, + ], + OnePassCLIv2: [ + { + "vault_name": "Test Vault", + "queries": [ + "ywvdbojsguzgrgnokmcxtydgdv", + "Authy Backup", + ], + "expected": ["OctoberPoppyNuttyDraperySabbath", "OctoberPoppyNuttyDraperySabbath"], + "output": load_file("v2_out_01.json"), + }, + { + # Request a custom field where ID and label are different + "vault_name": "Test Vault", + "queries": ["Dummy Login"], + "kwargs": { + "field": "password1", + }, + "expected": ["data in custom field"], + "output": load_file("v2_out_02.json") + }, + { + # Request data from a custom section + "vault_name": "Test Vault", + "queries": ["Duplicate Sections"], + "kwargs": { + "field": "s2 text", + "section": "Section 2", + }, + "expected": ["first value"], + "output": load_file("v2_out_03.json") + }, + ], +} diff --git a/tests/unit/plugins/lookup/onepassword/conftest.py b/tests/unit/plugins/lookup/onepassword/conftest.py new file mode 100644 index 0000000000..18afae1a33 --- /dev/null +++ b/tests/unit/plugins/lookup/onepassword/conftest.py @@ -0,0 +1,39 @@ +# Copyright (c) 2020 Ansible Project +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import pytest + +from ansible_collections.community.general.plugins.lookup.onepassword import OnePass + + +OP_VERSION_FIXTURES = [ + "opv1", + "opv2" +] + + +@pytest.fixture +def fake_op(mocker): + def _fake_op(version): + mocker.patch("ansible_collections.community.general.plugins.lookup.onepassword.OnePassCLIBase.get_current_version", return_value=version) + op = OnePass(None, None, None, None, None) + op._config._config_file_path = "/home/jin/.op/config" + mocker.patch.object(op._cli, "_run") + + return op + + return _fake_op + + +@pytest.fixture +def opv1(fake_op): + return fake_op("1.17.2") + + +@pytest.fixture +def opv2(fake_op): + return fake_op("2.27.2") diff --git a/tests/unit/plugins/lookup/onepassword/fixtures/v1_out_01.json b/tests/unit/plugins/lookup/onepassword/fixtures/v1_out_01.json new file mode 100644 index 0000000000..57eab09c54 --- /dev/null +++ b/tests/unit/plugins/lookup/onepassword/fixtures/v1_out_01.json @@ -0,0 +1,18 @@ +{ + "uuid": "0123456789", + "vaultUuid": "2468", + "overview": { + "title": "Mock \"Quot'd\" Server" + }, + "details": { + "sections": [{ + "title": "", + "fields": [ + {"t": "username", "v": "jamesbond"}, + {"t": "password", "v": "t0pS3cret"}, + {"t": "notes", "v": "Test note with\nmultiple lines and trailing space.\n\n"}, + {"t": "tricksy \"quot'd\" field\\", "v": "\"quot'd\" value"} + ] + }] + } +} diff --git a/tests/unit/plugins/lookup/onepassword/fixtures/v1_out_01.json.license b/tests/unit/plugins/lookup/onepassword/fixtures/v1_out_01.json.license new file mode 100644 index 0000000000..969b956c2e --- /dev/null +++ b/tests/unit/plugins/lookup/onepassword/fixtures/v1_out_01.json.license @@ -0,0 +1,3 @@ +GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +SPDX-License-Identifier: GPL-3.0-or-later +SPDX-FileCopyrightText: 2022, Ansible Project diff --git a/tests/unit/plugins/lookup/onepassword/fixtures/v1_out_02.json b/tests/unit/plugins/lookup/onepassword/fixtures/v1_out_02.json new file mode 100644 index 0000000000..da133fe59e --- /dev/null +++ b/tests/unit/plugins/lookup/onepassword/fixtures/v1_out_02.json @@ -0,0 +1,18 @@ +{ + "uuid": "9876543210", + "vaultUuid": "1357", + "overview": { + "title": "Mock Website", + "URLs": [ + {"l": "website", "u": "https://acme.com/login"} + ] + }, + "details": { + "sections": [{ + "title": "", + "fields": [ + {"t": "password", "v": "t0pS3cret"} + ] + }] + } +} diff --git a/tests/unit/plugins/lookup/onepassword/fixtures/v1_out_02.json.license b/tests/unit/plugins/lookup/onepassword/fixtures/v1_out_02.json.license new file mode 100644 index 0000000000..969b956c2e --- /dev/null +++ b/tests/unit/plugins/lookup/onepassword/fixtures/v1_out_02.json.license @@ -0,0 +1,3 @@ +GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +SPDX-License-Identifier: GPL-3.0-or-later +SPDX-FileCopyrightText: 2022, Ansible Project diff --git a/tests/unit/plugins/lookup/onepassword/fixtures/v1_out_03.json b/tests/unit/plugins/lookup/onepassword/fixtures/v1_out_03.json new file mode 100644 index 0000000000..57c7d0f3d6 --- /dev/null +++ b/tests/unit/plugins/lookup/onepassword/fixtures/v1_out_03.json @@ -0,0 +1,20 @@ +{ + "uuid": "864201357", + "vaultUuid": "1357", + "overview": { + "title": "Mock Something" + }, + "details": { + "fields": [ + { + "value": "jbond@mi6.gov.uk", + "name": "emailAddress" + }, + { + "name": "password", + "value": "vauxhall" + }, + {} + ] + } +} diff --git a/tests/unit/plugins/lookup/onepassword/fixtures/v1_out_03.json.license b/tests/unit/plugins/lookup/onepassword/fixtures/v1_out_03.json.license new file mode 100644 index 0000000000..969b956c2e --- /dev/null +++ b/tests/unit/plugins/lookup/onepassword/fixtures/v1_out_03.json.license @@ -0,0 +1,3 @@ +GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +SPDX-License-Identifier: GPL-3.0-or-later +SPDX-FileCopyrightText: 2022, Ansible Project diff --git a/tests/unit/plugins/lookup/onepassword/fixtures/v2_out_01.json b/tests/unit/plugins/lookup/onepassword/fixtures/v2_out_01.json new file mode 100644 index 0000000000..7ef0bb0c23 --- /dev/null +++ b/tests/unit/plugins/lookup/onepassword/fixtures/v2_out_01.json @@ -0,0 +1,35 @@ +{ + "id": "ywvdbojsguzgrgnokmcxtydgdv", + "title": "Authy Backup", + "version": 1, + "vault": { + "id": "bcqxysvcnejjrwzoqrwzcqjqxc", + "name": "test vault" + }, + "category": "PASSWORD", + "last_edited_by": "7FUPZ8ZNE02KSHMAIMKHIVUE17", + "created_at": "2015-01-18T13:13:38Z", + "updated_at": "2016-02-20T16:23:54Z", + "additional_information": "Jan 18, 2015, 08:13:38", + "fields": [ + { + "id": "password", + "type": "CONCEALED", + "purpose": "PASSWORD", + "label": "password", + "value": "OctoberPoppyNuttyDraperySabbath", + "reference": "op://Test Vault/Authy Backup/password", + "password_details": { + "strength": "FANTASTIC" + } + }, + { + "id": "notesPlain", + "type": "STRING", + "purpose": "NOTES", + "label": "notesPlain", + "value": "Backup password to restore Authy", + "reference": "op://Test Vault/Authy Backup/notesPlain" + } + ] +} diff --git a/tests/unit/plugins/lookup/onepassword/fixtures/v2_out_01.json.license b/tests/unit/plugins/lookup/onepassword/fixtures/v2_out_01.json.license new file mode 100644 index 0000000000..969b956c2e --- /dev/null +++ b/tests/unit/plugins/lookup/onepassword/fixtures/v2_out_01.json.license @@ -0,0 +1,3 @@ +GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +SPDX-License-Identifier: GPL-3.0-or-later +SPDX-FileCopyrightText: 2022, Ansible Project diff --git a/tests/unit/plugins/lookup/onepassword/fixtures/v2_out_02.json b/tests/unit/plugins/lookup/onepassword/fixtures/v2_out_02.json new file mode 100644 index 0000000000..5da2a16d12 --- /dev/null +++ b/tests/unit/plugins/lookup/onepassword/fixtures/v2_out_02.json @@ -0,0 +1,85 @@ +{ + "id": "awk4s2u44fhnrgppszcsvc663i", + "title": "Dummy Login", + "version": 4, + "vault": { + "id": "stpebbaccrq72xulgouxsk4p7y", + "name": "Personal" + }, + "category": "LOGIN", + "last_edited_by": "LSGPJERUYBH7BFPHMZ2KKGL6AU", + "created_at": "2018-04-25T21:55:19Z", + "updated_at": "2022-09-02T17:51:21Z", + "additional_information": "agent.smith", + "urls": [ + { + "primary": true, + "href": "https://acme.com" + } + ], + "sections": [ + { + "id": "add more" + }, + { + "id": "gafaeg7vnqmgrklw5r6yrufyxy", + "label": "COMMANDS" + }, + { + "id": "linked items", + "label": "Related Items" + } + ], + "fields": [ + { + "id": "username", + "type": "STRING", + "purpose": "USERNAME", + "label": "username", + "value": "agent.smith", + "reference": "op://Personal/Dummy Login/username" + }, + { + "id": "password", + "type": "CONCEALED", + "purpose": "PASSWORD", + "label": "password", + "value": "FootworkDegreeReverence", + "entropy": 159.60836791992188, + "reference": "op://Personal/Dummy Login/password", + "password_details": { + "entropy": 159, + "generated": true, + "strength": "FANTASTIC" + } + }, + { + "id": "notesPlain", + "type": "STRING", + "purpose": "NOTES", + "label": "notesPlain", + "reference": "op://Personal/Dummy Login/notesPlain" + }, + { + "id": "7gyjekelk24ghgd4rvafspjbli", + "section": { + "id": "add more" + }, + "type": "STRING", + "label": "title", + "value": "value of the field", + "reference": "op://Personal/Dummy Login/add more/title" + }, + { + "id": "fx4wpzokrxn7tlb3uwpdjfptgm", + "section": { + "id": "gafaeg7vnqmgrklw5r6yrufyxy", + "label": "COMMANDS" + }, + "type": "CONCEALED", + "label": "password1", + "value": "data in custom field", + "reference": "op://Personal/Dummy Login/COMMANDS/password1" + } + ] +} diff --git a/tests/unit/plugins/lookup/onepassword/fixtures/v2_out_02.json.license b/tests/unit/plugins/lookup/onepassword/fixtures/v2_out_02.json.license new file mode 100644 index 0000000000..969b956c2e --- /dev/null +++ b/tests/unit/plugins/lookup/onepassword/fixtures/v2_out_02.json.license @@ -0,0 +1,3 @@ +GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +SPDX-License-Identifier: GPL-3.0-or-later +SPDX-FileCopyrightText: 2022, Ansible Project diff --git a/tests/unit/plugins/lookup/onepassword/fixtures/v2_out_03.json b/tests/unit/plugins/lookup/onepassword/fixtures/v2_out_03.json new file mode 100644 index 0000000000..22fbc3f293 --- /dev/null +++ b/tests/unit/plugins/lookup/onepassword/fixtures/v2_out_03.json @@ -0,0 +1,103 @@ +{ + "id": "7t7qu2r35qyvqj3crujd4dqxmy", + "title": "Duplicate Sections", + "version": 3, + "vault": { + "id": "stpebbaccrq72xulgouxsk4p7y", + "name": "Personal" + }, + "category": "LOGIN", + "last_edited_by": "LSGPJERUYBH7BFPHMZ2KKGL6AU", + "created_at": "2022-11-04T17:09:18Z", + "updated_at": "2022-11-04T17:22:19Z", + "additional_information": "flora", + "urls": [ + { + "label": "website", + "primary": true, + "href": "https://acme.com/login" + } + ], + "sections": [ + { + "id": "add more" + }, + { + "id": "7osqcvd43i75teocdzbb6d7mie", + "label": "Section 2" + } + ], + "fields": [ + { + "id": "username", + "type": "STRING", + "purpose": "USERNAME", + "label": "username", + "value": "flora", + "reference": "op://Personal/Duplicate Sections/username" + }, + { + "id": "password", + "type": "CONCEALED", + "purpose": "PASSWORD", + "label": "password", + "value": "PtZGFLAibx-erTo7ywywEvh-n4syas97n-tuF2D.b8DdqA2vCjrvRGkNQxj!Gi9R", + "entropy": 379.564697265625, + "reference": "op://Personal/Duplicate Sections/password", + "password_details": { + "entropy": 379, + "generated": true, + "strength": "FANTASTIC" + } + }, + { + "id": "notesPlain", + "type": "STRING", + "purpose": "NOTES", + "label": "notesPlain", + "reference": "op://Personal/Duplicate Sections/notesPlain" + }, + { + "id": "4saaazkb7arwisj6ysctb4jmm4", + "section": { + "id": "add more" + }, + "type": "STRING", + "label": "text", + "value": "text field the first", + "reference": "op://Personal/Duplicate Sections/add more/text" + }, + { + "id": "4vtfkj4bwcmg7d5uf62wnpkp3a", + "section": { + "id": "add more" + }, + "type": "STRING", + "label": "text", + "value": "text field the second", + "reference": "op://Personal/Duplicate Sections/add more/text" + }, + { + "id": "wbrjnowkrgavpooomtht36gjqu", + "section": { + "id": "7osqcvd43i75teocdzbb6d7mie", + "label": "Section 2" + }, + "type": "STRING", + "label": "s2 text", + "value": "first value", + "reference": "op://Personal/Duplicate Sections/Section 2/s2 text" + }, + { + "id": "bddlz2fj2pebmtfhksbmcexy7m", + "section": { + "id": "7osqcvd43i75teocdzbb6d7mie", + "label": "Section 2" + }, + "type": "STRING", + "label": "s2 text", + "value": "second value", + "reference": "op://Personal/Duplicate Sections/Section 2/s2 text" + } + ] +} diff --git a/tests/unit/plugins/lookup/onepassword/fixtures/v2_out_03.json.license b/tests/unit/plugins/lookup/onepassword/fixtures/v2_out_03.json.license new file mode 100644 index 0000000000..969b956c2e --- /dev/null +++ b/tests/unit/plugins/lookup/onepassword/fixtures/v2_out_03.json.license @@ -0,0 +1,3 @@ +GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +SPDX-License-Identifier: GPL-3.0-or-later +SPDX-FileCopyrightText: 2022, Ansible Project diff --git a/tests/unit/plugins/lookup/onepassword/test_onepassword.py b/tests/unit/plugins/lookup/onepassword/test_onepassword.py new file mode 100644 index 0000000000..9e943dbfa0 --- /dev/null +++ b/tests/unit/plugins/lookup/onepassword/test_onepassword.py @@ -0,0 +1,182 @@ +# Copyright (c) 2020 Ansible Project +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import itertools +import json +import pytest + +from .conftest import OP_VERSION_FIXTURES +from .common import MOCK_ENTRIES + +from ansible.errors import AnsibleLookupError +from ansible.plugins.loader import lookup_loader +from ansible_collections.community.general.plugins.lookup.onepassword import ( + OnePassCLIv1, + OnePassCLIv2, +) + + +@pytest.mark.parametrize( + ("version", "version_class"), + ( + ("1.17.2", OnePassCLIv1), + ("2.27.4", OnePassCLIv2), + ) +) +def test_op_correct_cli_class(fake_op, version, version_class): + op = fake_op(version) + assert op._cli.version == version + assert isinstance(op._cli, version_class) + + +def test_op_unsupported_cli_version(fake_op): + with pytest.raises(AnsibleLookupError, match="is unsupported"): + fake_op("99.77.77") + + +@pytest.mark.parametrize("op_fixture", OP_VERSION_FIXTURES) +def test_op_set_token_with_config(op_fixture, mocker, request): + op = request.getfixturevalue(op_fixture) + token = "F5417F77529B41B595D7F9D6F76EC057" + mocker.patch("os.path.isfile", return_value=True) + mocker.patch.object(op._cli, "signin", return_value=(0, token + "\n", "")) + + op.set_token() + + assert op.token == token + + +@pytest.mark.parametrize( + ("op_fixture", "message"), + [ + (op, value) + for op in OP_VERSION_FIXTURES + for value in + ( + "Missing required parameters", + "The operation is unauthorized", + ) + ] +) +def test_op_set_token_with_config_missing_args(op_fixture, message, request, mocker): + op = request.getfixturevalue(op_fixture) + mocker.patch("os.path.isfile", return_value=True) + mocker.patch.object(op._cli, "signin", return_value=(99, "", ""), side_effect=AnsibleLookupError(message)) + mocker.patch.object(op._cli, "full_signin", return_value=(0, "", "")) + + with pytest.raises(AnsibleLookupError, match=message): + op.set_token() + + op._cli.full_signin.assert_not_called() + + +@pytest.mark.parametrize("op_fixture", OP_VERSION_FIXTURES) +def test_op_set_token_with_config_full_signin(op_fixture, request, mocker): + op = request.getfixturevalue(op_fixture) + mocker.patch("os.path.isfile", return_value=True) + mocker.patch.object(op._cli, "signin", return_value=(99, "", ""), side_effect=AnsibleLookupError("Raised intentionally")) + mocker.patch.object(op._cli, "full_signin", return_value=(0, "", "")) + + op.set_token() + + op._cli.full_signin.assert_called() + + +@pytest.mark.parametrize("op_fixture", OP_VERSION_FIXTURES) +def test_op_set_token_without_config(op_fixture, request, mocker): + op = request.getfixturevalue(op_fixture) + token = "B988E8A2680A4A348962751A96861FA1" + mocker.patch("os.path.isfile", return_value=False) + mocker.patch.object(op._cli, "signin", return_value=(99, "", "")) + mocker.patch.object(op._cli, "full_signin", return_value=(0, token + "\n", "")) + + op.set_token() + + op._cli.signin.assert_not_called() + assert op.token == token + + +@pytest.mark.parametrize( + ("op_fixture", "login_status"), + [(op, value) for op in OP_VERSION_FIXTURES for value in [False, True]] +) +def test_op_assert_logged_in(mocker, login_status, op_fixture, request): + op = request.getfixturevalue(op_fixture) + mocker.patch.object(op._cli, "assert_logged_in", return_value=login_status) + mocker.patch.object(op, "set_token") + + op.assert_logged_in() + + op._cli.assert_logged_in.assert_called_once() + assert op.logged_in == login_status + + if not login_status: + op.set_token.assert_called_once() + + +@pytest.mark.parametrize("op_fixture", OP_VERSION_FIXTURES) +def test_op_get_raw_v1(mocker, op_fixture, request): + op = request.getfixturevalue(op_fixture) + mocker.patch.object(op._cli, "get_raw", return_value=[99, "RAW OUTPUT", ""]) + + result = op.get_raw("some item") + + assert result == "RAW OUTPUT" + op._cli.get_raw.assert_called_once() + + +@pytest.mark.parametrize( + ("op_fixture", "output", "expected"), + ( + list(itertools.chain([op], d)) + for op in OP_VERSION_FIXTURES + for d in [ + ("RAW OUTPUT", "RAW OUTPUT"), + (None, ""), + ("", ""), + ] + ) +) +def test_op_get_field(mocker, op_fixture, output, expected, request): + op = request.getfixturevalue(op_fixture) + mocker.patch.object(op, "get_raw", return_value=output) + mocker.patch.object(op._cli, "_parse_field", return_value=output) + + result = op.get_field("some item", "some field") + + assert result == expected + + +# This test sometimes fails on older Python versions because the gathered tests mismatch. +# Sort the fixture data to make this reliable +# https://github.com/pytest-dev/pytest-xdist/issues/432 +@pytest.mark.parametrize( + ("cli_class", "vault", "queries", "kwargs", "output", "expected"), + ( + (_cli_class, item["vault_name"], item["queries"], item.get("kwargs", {}), item["output"], item["expected"]) + for _cli_class in MOCK_ENTRIES + for item in MOCK_ENTRIES[_cli_class] + ) +) +def test_op_lookup(mocker, cli_class, vault, queries, kwargs, output, expected): + mocker.patch("ansible_collections.community.general.plugins.lookup.onepassword.OnePass._get_cli_class", cli_class) + mocker.patch("ansible_collections.community.general.plugins.lookup.onepassword.OnePass.assert_logged_in", return_value=True) + mocker.patch("ansible_collections.community.general.plugins.lookup.onepassword.OnePassCLIBase._run", return_value=(0, json.dumps(output), "")) + + op_lookup = lookup_loader.get("community.general.onepassword") + result = op_lookup.run(queries, vault=vault, **kwargs) + + assert result == expected + + +@pytest.mark.parametrize("op_fixture", OP_VERSION_FIXTURES) +def test_signin(op_fixture, request): + op = request.getfixturevalue(op_fixture) + op._cli.master_password = "master_pass" + op._cli.signin() + print(op._cli.version) + op._cli._run.assert_called_once_with(['signin', '--raw'], command_input=b"master_pass") diff --git a/tests/unit/plugins/lookup/onepassword/test_onepassword_cli_v1.py b/tests/unit/plugins/lookup/onepassword/test_onepassword_cli_v1.py new file mode 100644 index 0000000000..dc9b44af66 --- /dev/null +++ b/tests/unit/plugins/lookup/onepassword/test_onepassword_cli_v1.py @@ -0,0 +1,50 @@ +# Copyright (c) 2022 Ansible Project +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import pytest + + +from ansible_collections.community.general.plugins.lookup.onepassword import OnePassCLIv1 + + +@pytest.mark.parametrize( + ("args", "rc", "expected_call_args", "expected_call_kwargs", "expected"), + ( + ([], 0, ["get", "account"], {"ignore_errors": True}, True,), + ([], 1, ["get", "account"], {"ignore_errors": True}, False,), + (["acme"], 1, ["get", "account", "--account", "acme.1password.com"], {"ignore_errors": True}, False,), + ) +) +def test_assert_logged_in(mocker, args, rc, expected_call_args, expected_call_kwargs, expected): + mocker.patch.object(OnePassCLIv1, "_run", return_value=[rc, "", ""]) + + op_cli = OnePassCLIv1(*args) + result = op_cli.assert_logged_in() + + op_cli._run.assert_called_with(expected_call_args, **expected_call_kwargs) + assert result == expected + + +def test_full_signin(mocker): + mocker.patch.object(OnePassCLIv1, "_run", return_value=[0, "", ""]) + + op_cli = OnePassCLIv1( + subdomain="acme", + username="bob@acme.com", + secret_key="SECRET", + master_password="ONEKEYTORULETHEMALL", + ) + result = op_cli.full_signin() + + op_cli._run.assert_called_with([ + "signin", + "acme.1password.com", + b"bob@acme.com", + b"SECRET", + "--raw", + ], command_input=b"ONEKEYTORULETHEMALL") + assert result == [0, "", ""] diff --git a/tests/unit/plugins/lookup/onepassword/test_onepassword_cli_v2.py b/tests/unit/plugins/lookup/onepassword/test_onepassword_cli_v2.py new file mode 100644 index 0000000000..d1a5eac5d3 --- /dev/null +++ b/tests/unit/plugins/lookup/onepassword/test_onepassword_cli_v2.py @@ -0,0 +1,52 @@ +# Copyright (c) 2022 Ansible Project +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import pytest + + +from ansible_collections.community.general.plugins.lookup.onepassword import OnePassCLIv2 + + +@pytest.mark.parametrize( + ("args", "out", "expected_call_args", "expected"), + ( + ([], "list of accounts", ["account", "get"], True,), + (["acme"], "list of accounts", ["account", "get", "--account", "acme.1password.com"], True,), + ([], "", ["account", "list"], False,), + ) +) +def test_assert_logged_in(mocker, args, out, expected_call_args, expected): + mocker.patch.object(OnePassCLIv2, "_run", return_value=[0, out, ""]) + op_cli = OnePassCLIv2(*args) + result = op_cli.assert_logged_in() + + op_cli._run.assert_called_with(expected_call_args) + assert result == expected + + +def test_full_signin(mocker): + mocker.patch.object(OnePassCLIv2, "_run", return_value=[0, "", ""]) + + op_cli = OnePassCLIv2( + subdomain="acme", + username="bob@acme.com", + secret_key="SECRET", + master_password="ONEKEYTORULETHEMALL", + ) + result = op_cli.full_signin() + + op_cli._run.assert_called_with( + [ + "account", "add", "--raw", + "--address", "acme.1password.com", + "--email", b"bob@acme.com", + "--signin", + ], + command_input=b"ONEKEYTORULETHEMALL", + environment_update={'OP_SECRET_KEY': 'SECRET'}, + ) + assert result == [0, "", ""] diff --git a/tests/unit/plugins/lookup/test_onepassword.py b/tests/unit/plugins/lookup/test_onepassword.py deleted file mode 100644 index e639dcddbe..0000000000 --- a/tests/unit/plugins/lookup/test_onepassword.py +++ /dev/null @@ -1,322 +0,0 @@ -# Copyright (c) 2018, Scott Buchanan -# Copyright (c) 2016, Andrew Zenk (test_lastpass.py used as starting point) -# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) -# SPDX-License-Identifier: GPL-3.0-or-later -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -import json -import datetime - -try: - from urllib.parse import urlparse -except ImportError: - from urlparse import urlparse - -from argparse import ArgumentParser - - -from ansible_collections.community.general.tests.unit.compat import unittest -from ansible_collections.community.general.tests.unit.compat.mock import patch -from ansible.errors import AnsibleError -from ansible_collections.community.general.plugins.lookup.onepassword import OnePass, LookupModule -from ansible_collections.community.general.plugins.lookup.onepassword_raw import LookupModule as OnePasswordRawLookup - - -# Intentionally excludes metadata leaf nodes that would exist in real output if not relevant. -MOCK_ENTRIES = [ - { - 'vault_name': 'Acme "Quot\'d" Servers', - 'queries': [ - '0123456789', - 'Mock "Quot\'d" Server' - ], - 'output': { - 'uuid': '0123456789', - 'vaultUuid': '2468', - 'overview': { - 'title': 'Mock "Quot\'d" Server' - }, - 'details': { - 'sections': [{ - 'title': '', - 'fields': [ - {'t': 'username', 'v': 'jamesbond'}, - {'t': 'password', 'v': 't0pS3cret'}, - {'t': 'notes', 'v': 'Test note with\nmultiple lines and trailing space.\n\n'}, - {'t': 'tricksy "quot\'d" field\\', 'v': '"quot\'d" value'} - ] - }] - } - } - }, - { - 'vault_name': 'Acme Logins', - 'queries': [ - '9876543210', - 'Mock Website', - 'acme.com' - ], - 'output': { - 'uuid': '9876543210', - 'vaultUuid': '1357', - 'overview': { - 'title': 'Mock Website', - 'URLs': [ - {'l': 'website', 'u': 'https://acme.com/login'} - ] - }, - 'details': { - 'sections': [{ - 'title': '', - 'fields': [ - {'t': 'password', 'v': 't0pS3cret'} - ] - }] - } - } - }, - { - 'vault_name': 'Acme Logins', - 'queries': [ - '864201357' - ], - 'output': { - 'uuid': '864201357', - 'vaultUuid': '1357', - 'overview': { - 'title': 'Mock Something' - }, - 'details': { - 'fields': [ - { - 'value': 'jbond@mi6.gov.uk', - 'name': 'emailAddress' - }, - { - 'name': 'password', - 'value': 'vauxhall' - }, - {}, - ] - } - } - }, -] - - -def get_mock_query_generator(require_field=None): - def _process_field(field, section_title=None): - field_name = field.get('name', field.get('t', '')) - field_value = field.get('value', field.get('v', '')) - - if require_field is None or field_name == require_field: - return entry, query, section_title, field_name, field_value - - for entry in MOCK_ENTRIES: - for query in entry['queries']: - for field in entry['output']['details'].get('fields', []): - fixture = _process_field(field) - if fixture: - yield fixture - for section in entry['output']['details'].get('sections', []): - for field in section['fields']: - fixture = _process_field(field, section['title']) - if fixture: - yield fixture - - -def get_one_mock_query(require_field=None): - generator = get_mock_query_generator(require_field) - return next(generator) - - -class MockOnePass(OnePass): - - _mock_logged_out = False - _mock_timed_out = False - - def _lookup_mock_entry(self, key, vault=None): - for entry in MOCK_ENTRIES: - if vault is not None and vault.lower() != entry['vault_name'].lower() and vault.lower() != entry['output']['vaultUuid'].lower(): - continue - - match_fields = [ - entry['output']['uuid'], - entry['output']['overview']['title'] - ] - - # Note that exactly how 1Password matches on domains in non-trivial cases is neither documented - # nor obvious, so this may not precisely match the real behavior. - urls = entry['output']['overview'].get('URLs') - if urls is not None: - match_fields += [urlparse(url['u']).netloc for url in urls] - - if key in match_fields: - return entry['output'] - - def _run(self, args, expected_rc=0, command_input=None, ignore_errors=False): - parser = ArgumentParser() - - command_parser = parser.add_subparsers(dest='command') - - get_parser = command_parser.add_parser('get') - get_options = ArgumentParser(add_help=False) - get_options.add_argument('--vault') - get_type_parser = get_parser.add_subparsers(dest='object_type') - get_type_parser.add_parser('account', parents=[get_options]) - get_item_parser = get_type_parser.add_parser('item', parents=[get_options]) - get_item_parser.add_argument('item_id') - - args = parser.parse_args(args) - - def mock_exit(output='', error='', rc=0): - if rc != expected_rc: - raise AnsibleError(error) - if error != '': - now = datetime.date.today() - error = '[LOG] {0} (ERROR) {1}'.format(now.strftime('%Y/%m/%d %H:$M:$S'), error) - return rc, output, error - - if args.command == 'get': - if self._mock_logged_out: - return mock_exit(error='You are not currently signed in. Please run `op signin --help` for instructions', rc=1) - - if self._mock_timed_out: - return mock_exit(error='401: Authentication required.', rc=1) - - if args.object_type == 'item': - mock_entry = self._lookup_mock_entry(args.item_id, args.vault) - - if mock_entry is None: - return mock_exit(error='Item {0} not found'.format(args.item_id)) - - return mock_exit(output=json.dumps(mock_entry)) - - if args.object_type == 'account': - # Since we don't actually ever use this output, don't bother mocking output. - return mock_exit() - - raise AnsibleError('Unsupported command string passed to OnePass mock: {0}'.format(args)) - - -class LoggedOutMockOnePass(MockOnePass): - - _mock_logged_out = True - - -class TimedOutMockOnePass(MockOnePass): - - _mock_timed_out = True - - -class TestOnePass(unittest.TestCase): - - def test_onepassword_cli_path(self): - op = MockOnePass(path='/dev/null') - self.assertEqual('/dev/null', op.cli_path) - - def test_onepassword_logged_in(self): - op = MockOnePass() - try: - op.assert_logged_in() - except Exception: - self.fail() - - def test_onepassword_logged_out(self): - op = LoggedOutMockOnePass() - with self.assertRaises(AnsibleError): - op.assert_logged_in() - - def test_onepassword_timed_out(self): - op = TimedOutMockOnePass() - with self.assertRaises(AnsibleError): - op.assert_logged_in() - - def test_onepassword_get(self): - op = MockOnePass() - op.logged_in = True - query_generator = get_mock_query_generator() - for dummy, query, dummy, field_name, field_value in query_generator: - self.assertEqual(field_value, op.get_field(query, field_name)) - - def test_onepassword_get_raw(self): - op = MockOnePass() - op.logged_in = True - for entry in MOCK_ENTRIES: - for query in entry['queries']: - self.assertEqual(json.dumps(entry['output']), op.get_raw(query)) - - def test_onepassword_get_not_found(self): - op = MockOnePass() - op.logged_in = True - self.assertEqual('', op.get_field('a fake query', 'a fake field')) - - def test_onepassword_get_with_section(self): - op = MockOnePass() - op.logged_in = True - dummy, query, section_title, field_name, field_value = get_one_mock_query() - self.assertEqual(field_value, op.get_field(query, field_name, section=section_title)) - - def test_onepassword_get_with_vault(self): - op = MockOnePass() - op.logged_in = True - entry, query, dummy, field_name, field_value = get_one_mock_query() - for vault_query in [entry['vault_name'], entry['output']['vaultUuid']]: - self.assertEqual(field_value, op.get_field(query, field_name, vault=vault_query)) - - def test_onepassword_get_with_wrong_vault(self): - op = MockOnePass() - op.logged_in = True - dummy, query, dummy, field_name, dummy = get_one_mock_query() - self.assertEqual('', op.get_field(query, field_name, vault='a fake vault')) - - def test_onepassword_get_diff_case(self): - op = MockOnePass() - op.logged_in = True - entry, query, section_title, field_name, field_value = get_one_mock_query() - self.assertEqual( - field_value, - op.get_field( - query, - field_name.upper(), - vault=entry['vault_name'].upper(), - section=section_title.upper() - ) - ) - - -@patch('ansible_collections.community.general.plugins.lookup.onepassword.OnePass', MockOnePass) -class TestLookupModule(unittest.TestCase): - - def test_onepassword_plugin_multiple(self): - lookup_plugin = LookupModule() - - entry = MOCK_ENTRIES[0] - field = entry['output']['details']['sections'][0]['fields'][0] - - self.assertEqual( - [field['v']] * len(entry['queries']), - lookup_plugin.run(entry['queries'], field=field['t']) - ) - - def test_onepassword_plugin_default_field(self): - lookup_plugin = LookupModule() - - dummy, query, dummy, dummy, field_value = get_one_mock_query('password') - self.assertEqual([field_value], lookup_plugin.run([query])) - - -@patch('ansible_collections.community.general.plugins.lookup.onepassword_raw.OnePass', MockOnePass) -class TestOnePasswordRawLookup(unittest.TestCase): - - def test_onepassword_raw_plugin_multiple(self): - raw_lookup_plugin = OnePasswordRawLookup() - - entry = MOCK_ENTRIES[0] - raw_value = entry['output'] - - self.assertEqual( - [raw_value] * len(entry['queries']), - raw_lookup_plugin.run(entry['queries']) - ) diff --git a/tests/unit/plugins/module_utils/test_onepassword.py b/tests/unit/plugins/module_utils/test_onepassword.py new file mode 100644 index 0000000000..dbe3918358 --- /dev/null +++ b/tests/unit/plugins/module_utils/test_onepassword.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2022 Ansible Project +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os + +import pytest + +from ansible_collections.community.general.plugins.module_utils.onepassword import OnePasswordConfig + + +@pytest.fixture +def os_expanduser(mocker): + def _os_expanduser(path): + return path.replace("~", "/home/testuser") + + mocker.patch("os.path.expanduser", side_effect=_os_expanduser) + + +@pytest.fixture +def exists(mocker): + def _exists(path): + if "op/" in path: + return True + + return os.path.exists(path) + + +def test_op_config(mocker, os_expanduser): + mocker.patch("os.path.exists", side_effect=[False, True]) + op_config = OnePasswordConfig() + + assert "/home/testuser/.config/op/config" == op_config.config_file_path + + +def test_op_no_config(mocker, os_expanduser): + mocker.patch("os.path.exists", return_value=False) + op_config = OnePasswordConfig() + + assert op_config.config_file_path is None From fc817601bc177386fe84a557d881b20a24c9dd7f Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Sun, 6 Nov 2022 23:38:38 +1300 Subject: [PATCH 0010/1810] django_manage: add extra tests (#5476) --- .../base_test/simple_project/p1/p1/settings.py | 5 +++++ .../targets/django_manage/tasks/main.yaml | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/tests/integration/targets/django_manage/files/base_test/simple_project/p1/p1/settings.py b/tests/integration/targets/django_manage/files/base_test/simple_project/p1/p1/settings.py index 1b98a0dbff..86b3ae64c6 100644 --- a/tests/integration/targets/django_manage/files/base_test/simple_project/p1/p1/settings.py +++ b/tests/integration/targets/django_manage/files/base_test/simple_project/p1/p1/settings.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # Copyright (c) Ansible Project # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) # SPDX-License-Identifier: GPL-3.0-or-later @@ -17,6 +18,7 @@ For the full list of settings and their values, see https://docs.djangoproject.com/en/3.1/ref/settings/ """ +import os from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. @@ -126,3 +128,6 @@ USE_TZ = True STATIC_URL = '/static/' STATIC_ROOT = '/tmp/django-static' + +if "DJANGO_ANSIBLE_RAISE" in os.environ: + raise ValueError("DJANGO_ANSIBLE_RAISE={0}".format(os.environ["DJANGO_ANSIBLE_RAISE"])) diff --git a/tests/integration/targets/django_manage/tasks/main.yaml b/tests/integration/targets/django_manage/tasks/main.yaml index 0d8c8acbef..c07b538938 100644 --- a/tests/integration/targets/django_manage/tasks/main.yaml +++ b/tests/integration/targets/django_manage/tasks/main.yaml @@ -67,3 +67,18 @@ project_path: "{{ tmp_django_root.path }}/simple_project/p1" command: collectstatic --noinput virtualenv: "{{ tmp_django_root.path }}/venv" + +- name: Trigger exception with environment variable + community.general.django_manage: + project_path: "{{ tmp_django_root.path }}/simple_project/p1" + command: collectstatic --noinput + virtualenv: "{{ tmp_django_root.path }}/venv" + environment: + DJANGO_ANSIBLE_RAISE: blah + ignore_errors: true + register: env_raise + +- name: Check env variable reached manage.py + ansible.builtin.assert: + that: + - "'ValueError: DJANGO_ANSIBLE_RAISE=blah' in env_raise.msg" From fb90b5cbe8a2a11d7df81613feb2630eb4754441 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Sun, 6 Nov 2022 23:40:30 +1300 Subject: [PATCH 0011/1810] ansible_galaxy_install: using CmdRunner (#5477) * ansible_galaxy_install: using CmdRunner * fix sanity checks * add changelog fragment --- ...5477-ansible-galaxy-install-cmd-runner.yml | 2 + plugins/modules/ansible_galaxy_install.py | 89 ++++++++++--------- 2 files changed, 47 insertions(+), 44 deletions(-) create mode 100644 changelogs/fragments/5477-ansible-galaxy-install-cmd-runner.yml diff --git a/changelogs/fragments/5477-ansible-galaxy-install-cmd-runner.yml b/changelogs/fragments/5477-ansible-galaxy-install-cmd-runner.yml new file mode 100644 index 0000000000..f480456953 --- /dev/null +++ b/changelogs/fragments/5477-ansible-galaxy-install-cmd-runner.yml @@ -0,0 +1,2 @@ +minor_changes: + - ansible_galaxy_install - refactored module to use ``CmdRunner`` to execute ``ansible-galaxy`` (https://github.com/ansible-collections/community.general/pull/5477). diff --git a/plugins/modules/ansible_galaxy_install.py b/plugins/modules/ansible_galaxy_install.py index 3964cdab9f..5e5ec54eb0 100644 --- a/plugins/modules/ansible_galaxy_install.py +++ b/plugins/modules/ansible_galaxy_install.py @@ -184,10 +184,11 @@ RETURN = """ import re -from ansible_collections.community.general.plugins.module_utils.module_helper import CmdModuleHelper, ArgFormat +from ansible_collections.community.general.plugins.module_utils.cmd_runner import CmdRunner, cmd_runner_fmt as fmt +from ansible_collections.community.general.plugins.module_utils.module_helper import ModuleHelper -class AnsibleGalaxyInstall(CmdModuleHelper): +class AnsibleGalaxyInstall(ModuleHelper): _RE_GALAXY_VERSION = re.compile(r'^ansible-galaxy(?: \[core)? (?P\d+\.\d+\.\d+)(?:\.\w+)?(?:\])?') _RE_LIST_PATH = re.compile(r'^# (?P.*)$') _RE_LIST_COLL = re.compile(r'^(?P\w+\.\w+)\s+(?P[\d\.]+)\s*$') @@ -216,28 +217,33 @@ class AnsibleGalaxyInstall(CmdModuleHelper): command = 'ansible-galaxy' command_args_formats = dict( - type=dict(fmt=lambda v: [] if v == 'both' else [v]), - galaxy_cmd=dict(), - requirements_file=dict(fmt=('-r', '{0}'),), - dest=dict(fmt=('-p', '{0}'),), - force=dict(fmt="--force", style=ArgFormat.BOOLEAN), - no_deps=dict(fmt="--no-deps", style=ArgFormat.BOOLEAN), + type=fmt.as_func(lambda v: [] if v == 'both' else [v]), + galaxy_cmd=fmt.as_list(), + requirements_file=fmt.as_opt_val('-r'), + dest=fmt.as_opt_val('-p'), + force=fmt.as_bool("--force"), + no_deps=fmt.as_bool("--no-deps"), + version=fmt.as_bool("--version"), + name=fmt.as_list(), ) force_lang = "en_US.UTF-8" check_rc = True def _get_ansible_galaxy_version(self): - ansible_galaxy = self.get_bin_path("ansible-galaxy", required=True) - dummy, out, dummy = self.module.run_command([ansible_galaxy, "--version"], check_rc=True) - line = out.splitlines()[0] - match = self._RE_GALAXY_VERSION.match(line) - if not match: - raise RuntimeError("Unable to determine ansible-galaxy version from: {0}".format(line)) - version = match.group("version") - version = tuple(int(x) for x in version.split('.')[:3]) - return version + def process(rc, out, err): + line = out.splitlines()[0] + match = self._RE_GALAXY_VERSION.match(line) + if not match: + self.do_raise("Unable to determine ansible-galaxy version from: {0}".format(line)) + version = match.group("version") + version = tuple(int(x) for x in version.split('.')[:3]) + return version + + with self.runner("version", check_rc=True, output_process=process) as ctx: + return ctx.run(version=True) def __init_module__(self): + self.runner = CmdRunner(self.module, command=self.command, arg_formats=self.command_args_formats, force_lang=self.force_lang) self.ansible_version = self._get_ansible_galaxy_version() if self.ansible_version < (2, 11) and not self.vars.ack_min_ansiblecore211: self.module.deprecate( @@ -260,18 +266,13 @@ class AnsibleGalaxyInstall(CmdModuleHelper): r'|- (?P\w+\.\w+) \((?P[\d\.]+)\))' r' was installed successfully$') - @staticmethod - def _process_output_list(*args): - if "None of the provided paths were usable" in args[1]: - return [] - return args[1].splitlines() - def _list_element(self, _type, path_re, elem_re): - params = ({'type': _type}, {'galaxy_cmd': 'list'}, 'dest') - elems = self.run_command(params=params, - publish_rc=False, publish_out=False, publish_err=False, publish_cmd=False, - process_output=self._process_output_list, - check_rc=False) + def process(rc, out, err): + return [] if "None of the provided paths were usable" in out else out.splitlines() + + with self.runner('type galaxy_cmd dest', output_process=process, check_rc=False) as ctx: + elems = ctx.run(type=_type, galaxy_cmd='list') + elems_dict = {} current_path = None for line in elems: @@ -316,28 +317,28 @@ class AnsibleGalaxyInstall(CmdModuleHelper): self.vars.installed_collections = self._list_collections() def __run__(self): + def process(rc, out, err): + for line in out.splitlines(): + match = self._RE_INSTALL_OUTPUT.match(line) + if not match: + continue + if match.group("collection"): + self.vars.new_collections[match.group("collection")] = match.group("cversion") + if self.is_ansible29: + self.vars.ansible29_change = True + elif match.group("role"): + self.vars.new_roles[match.group("role")] = match.group("rversion") + if self.is_ansible29: + self.vars.ansible29_change = True + if self.is_ansible29: if self.vars.type == 'both': raise ValueError("Type 'both' not supported in Ansible 2.9") self._setup29() else: self._setup210plus() - params = ('type', {'galaxy_cmd': 'install'}, 'force', 'no_deps', 'dest', 'requirements_file', 'name') - self.run_command(params=params) - - def process_command_output(self, rc, out, err): - for line in out.splitlines(): - match = self._RE_INSTALL_OUTPUT.match(line) - if not match: - continue - if match.group("collection"): - self.vars.new_collections[match.group("collection")] = match.group("cversion") - if self.is_ansible29: - self.vars.ansible29_change = True - elif match.group("role"): - self.vars.new_roles[match.group("role")] = match.group("rversion") - if self.is_ansible29: - self.vars.ansible29_change = True + with self.runner("type galaxy_cmd force no_deps dest requirements_file name", output_process=process) as ctx: + ctx.run(galaxy_cmd="install") def main(): From 8fb2228125113782b6d87da03a016a9e01079f06 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Sun, 6 Nov 2022 23:41:11 +1300 Subject: [PATCH 0012/1810] snap: fix regex to support option values with whitespaces (#5475) * snap: fix regex to support option values with whitespaces * add changelog fragment --- changelogs/fragments/5475-snap-option-value-whitespace.yml | 2 ++ plugins/modules/snap.py | 4 ++-- tests/integration/targets/snap/tasks/main.yml | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/5475-snap-option-value-whitespace.yml diff --git a/changelogs/fragments/5475-snap-option-value-whitespace.yml b/changelogs/fragments/5475-snap-option-value-whitespace.yml new file mode 100644 index 0000000000..c41c70da38 --- /dev/null +++ b/changelogs/fragments/5475-snap-option-value-whitespace.yml @@ -0,0 +1,2 @@ +bugfixes: + - snap - allow values in the ``options`` parameter to contain whitespaces (https://github.com/ansible-collections/community.general/pull/5475). diff --git a/plugins/modules/snap.py b/plugins/modules/snap.py index c50e789c85..a432504472 100644 --- a/plugins/modules/snap.py +++ b/plugins/modules/snap.py @@ -170,7 +170,7 @@ def _state_map(value): class Snap(CmdStateModuleHelper): __disable_re = re.compile(r'(?:\S+\s+){5}(?P\S+)') - __set_param_re = re.compile(r'(?P\S+:)?(?P\S+)=(?P\S+)') + __set_param_re = re.compile(r'(?P\S+:)?(?P\S+)\s*=\s*(?P.+)') module = dict( argument_spec={ 'name': dict(type='list', elements='str', required=True), @@ -342,7 +342,7 @@ class Snap(CmdStateModuleHelper): if selected_snap_name is None or (snap_name is not None and snap_name == selected_snap_name): key = match.group("key") - value = match.group("value") + value = match.group("value").strip() if key not in option_map or key in option_map and option_map[key] != value: option_without_prefix = key + "=" + value diff --git a/tests/integration/targets/snap/tasks/main.yml b/tests/integration/targets/snap/tasks/main.yml index 367376202a..906d741127 100644 --- a/tests/integration/targets/snap/tasks/main.yml +++ b/tests/integration/targets/snap/tasks/main.yml @@ -8,7 +8,9 @@ # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) # SPDX-License-Identifier: GPL-3.0-or-later -- block: +- name: Has-snap block + when: has_snap + block: - name: Make sure package is not installed (hello-world) community.general.snap: name: hello-world @@ -189,5 +191,3 @@ - "'uhttpd:document-root-dir=/tmp' in install_with_option_changed.options_changed" - "'uhttpd:listening-port=8080' not in install_with_option_changed.options_changed" - remove is changed - - when: has_snap From f4bad50bbb9222a057368ba1708ea8bfeb81740f Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sun, 6 Nov 2022 11:48:14 +0100 Subject: [PATCH 0013/1810] Prepare 6.0.0 release. --- changelogs/fragments/6.0.0.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelogs/fragments/6.0.0.yml diff --git a/changelogs/fragments/6.0.0.yml b/changelogs/fragments/6.0.0.yml new file mode 100644 index 0000000000..347d16861c --- /dev/null +++ b/changelogs/fragments/6.0.0.yml @@ -0,0 +1,3 @@ +release_summary: >- + New major release of community.general with lots of bugfixes, new features, some removed deprecated features, and some other breaking changes. + Please check the coresponding sections of the changelog for more details. From 90ac53d150aabb4301f5e6dde29188d80a70e0be Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sun, 6 Nov 2022 12:52:45 +0100 Subject: [PATCH 0014/1810] Drop stable-3 from weekly CI; migrate stable-4 from nightly to weekly. --- .azure-pipelines/azure-pipelines.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.azure-pipelines/azure-pipelines.yml b/.azure-pipelines/azure-pipelines.yml index e590812264..52eaf65069 100644 --- a/.azure-pipelines/azure-pipelines.yml +++ b/.azure-pipelines/azure-pipelines.yml @@ -30,13 +30,12 @@ schedules: branches: include: - stable-5 - - stable-4 - cron: 0 11 * * 0 displayName: Weekly (old stable branches) always: true branches: include: - - stable-3 + - stable-4 variables: - name: checkoutPath From 8de0221ae63bb7cf78f3c696fabef3e1c71ce6f5 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sun, 6 Nov 2022 20:28:56 +0100 Subject: [PATCH 0015/1810] Convert copyright docstings to proper copyright comments (#5480) * Drop stable-3 from weekly CI; migrate stable-4 from nightly to weekly. * Convert copyright docstings to proper copyright comments. --- plugins/modules/one_image.py | 21 +-------------------- plugins/modules/one_image_info.py | 21 +-------------------- plugins/modules/one_service.py | 21 +-------------------- plugins/modules/one_vm.py | 23 ++--------------------- 4 files changed, 5 insertions(+), 81 deletions(-) diff --git a/plugins/modules/one_image.py b/plugins/modules/one_image.py index 04a6b57083..fb255dc590 100644 --- a/plugins/modules/one_image.py +++ b/plugins/modules/one_image.py @@ -1,6 +1,6 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright (c) Ansible Project +# Copyright (c) 2018, Milan Ilic # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) # SPDX-License-Identifier: GPL-3.0-or-later @@ -8,25 +8,6 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -""" -(c) 2018, Milan Ilic - -This file is part of Ansible - -Ansible is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -Ansible is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a clone of the GNU General Public License -along with Ansible. If not, see . -""" - DOCUMENTATION = ''' --- module: one_image diff --git a/plugins/modules/one_image_info.py b/plugins/modules/one_image_info.py index 08521a7acd..a908b46776 100644 --- a/plugins/modules/one_image_info.py +++ b/plugins/modules/one_image_info.py @@ -1,6 +1,6 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright (c) Ansible Project +# Copyright (c) 2018, Milan Ilic # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) # SPDX-License-Identifier: GPL-3.0-or-later @@ -8,25 +8,6 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -""" -(c) 2018, Milan Ilic - -This file is part of Ansible - -Ansible is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -Ansible is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a clone of the GNU General Public License -along with Ansible. If not, see . -""" - DOCUMENTATION = ''' --- module: one_image_info diff --git a/plugins/modules/one_service.py b/plugins/modules/one_service.py index 96f200a39e..6bc3137cc3 100644 --- a/plugins/modules/one_service.py +++ b/plugins/modules/one_service.py @@ -1,6 +1,6 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright (c) Ansible Project +# Copyright (c) 2017, Milan Ilic # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) # SPDX-License-Identifier: GPL-3.0-or-later @@ -8,25 +8,6 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -""" -(c) 2017, Milan Ilic - -This file is part of Ansible - -Ansible is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -Ansible is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Ansible. If not, see . -""" - DOCUMENTATION = ''' --- module: one_service diff --git a/plugins/modules/one_vm.py b/plugins/modules/one_vm.py index dca65d6db3..6bfc793603 100644 --- a/plugins/modules/one_vm.py +++ b/plugins/modules/one_vm.py @@ -1,6 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright (c) Ansible Project +# Copyright (c) 2017, Milan Ilic +# Copyright (c) 2019, Jan Meerkamp # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) # SPDX-License-Identifier: GPL-3.0-or-later @@ -8,26 +9,6 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -""" -(c) 2017, Milan Ilic -(c) 2019, Jan Meerkamp - -This file is part of Ansible - -Ansible is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -Ansible is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Ansible. If not, see . -""" - DOCUMENTATION = ''' --- module: one_vm From ac6ac732764d16ed9a96f7b92c6ad68c15bbe655 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sun, 6 Nov 2022 21:16:43 +0100 Subject: [PATCH 0016/1810] Document attributes (_info and _facts modules for now) (#5481) * Add attributes docs fragment. * Use attributes for _info and _facts modules. --- plugins/doc_fragments/attributes.py | 89 +++++++++++++++++++ plugins/modules/ali_instance_info.py | 2 + plugins/modules/cloud_init_data_facts.py | 4 + plugins/modules/dnsimple_info.py | 4 + plugins/modules/gconftool2_info.py | 3 + plugins/modules/github_webhook_info.py | 3 + plugins/modules/hpilo_info.py | 3 + plugins/modules/idrac_redfish_info.py | 3 + plugins/modules/ilo_redfish_info.py | 3 + plugins/modules/ipify_facts.py | 4 + plugins/modules/ipinfoio_facts.py | 4 + plugins/modules/jenkins_job_info.py | 3 + plugins/modules/keycloak_realm_info.py | 4 + plugins/modules/keyring_info.py | 3 + plugins/modules/listen_ports_facts.py | 4 + plugins/modules/manageiq_policies_info.py | 2 + plugins/modules/manageiq_tags_info.py | 4 +- plugins/modules/memset_memstore_info.py | 3 + plugins/modules/memset_server_info.py | 3 + plugins/modules/nginx_status_info.py | 3 + plugins/modules/nomad_job_info.py | 2 + plugins/modules/one_image_info.py | 3 + plugins/modules/onepassword_info.py | 3 + plugins/modules/oneview_datacenter_info.py | 6 +- plugins/modules/oneview_enclosure_info.py | 6 +- .../modules/oneview_ethernet_network_info.py | 6 +- plugins/modules/oneview_fc_network_info.py | 6 +- plugins/modules/oneview_fcoe_network_info.py | 6 +- ...oneview_logical_interconnect_group_info.py | 6 +- plugins/modules/oneview_network_set_info.py | 6 +- plugins/modules/oneview_san_manager_info.py | 4 +- plugins/modules/online_server_info.py | 4 +- plugins/modules/online_user_info.py | 4 +- plugins/modules/pip_package_info.py | 5 +- plugins/modules/pipx_info.py | 3 + plugins/modules/pritunl_org_info.py | 2 + plugins/modules/pritunl_user_info.py | 2 + plugins/modules/proxmox_domain_info.py | 5 +- plugins/modules/proxmox_group_info.py | 5 +- plugins/modules/proxmox_storage_info.py | 5 +- plugins/modules/proxmox_tasks_info.py | 2 + plugins/modules/proxmox_user_info.py | 5 +- plugins/modules/python_requirements_info.py | 3 + plugins/modules/rax_facts.py | 7 +- plugins/modules/redfish_info.py | 3 + plugins/modules/redis_data_info.py | 2 + plugins/modules/redis_info.py | 3 + .../modules/rundeck_job_executions_info.py | 2 + .../scaleway_container_namespace_info.py | 3 +- .../scaleway_container_registry_info.py | 3 +- plugins/modules/scaleway_function_info.py | 3 +- .../scaleway_function_namespace_info.py | 3 +- plugins/modules/scaleway_image_info.py | 4 +- plugins/modules/scaleway_ip_info.py | 4 +- plugins/modules/scaleway_organization_info.py | 4 +- .../modules/scaleway_security_group_info.py | 4 +- plugins/modules/scaleway_server_info.py | 4 +- plugins/modules/scaleway_snapshot_info.py | 4 +- plugins/modules/scaleway_volume_info.py | 4 +- plugins/modules/smartos_image_info.py | 3 + plugins/modules/snmp_facts.py | 4 + plugins/modules/utm_aaa_group_info.py | 4 +- plugins/modules/utm_ca_host_key_cert_info.py | 5 +- .../utm_network_interface_address_info.py | 5 +- plugins/modules/utm_proxy_frontend_info.py | 5 +- plugins/modules/utm_proxy_location_info.py | 5 +- plugins/modules/vertica_info.py | 3 + plugins/modules/wdc_redfish_info.py | 3 + plugins/modules/xenserver_facts.py | 10 ++- plugins/modules/xenserver_guest_info.py | 3 +- plugins/modules/xfconf_info.py | 3 + plugins/modules/zfs_facts.py | 4 + plugins/modules/zpool_facts.py | 4 + 73 files changed, 319 insertions(+), 49 deletions(-) create mode 100644 plugins/doc_fragments/attributes.py diff --git a/plugins/doc_fragments/attributes.py b/plugins/doc_fragments/attributes.py new file mode 100644 index 0000000000..da089dff21 --- /dev/null +++ b/plugins/doc_fragments/attributes.py @@ -0,0 +1,89 @@ +# -*- coding: utf-8 -*- + +# Copyright (c) Ansible Project +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + + +class ModuleDocFragment(object): + + # Standard documentation fragment + DOCUMENTATION = r''' +options: {} +attributes: + check_mode: + description: Can run in C(check_mode) and return changed status prediction without modifying target. + diff_mode: + description: Will return details on what has changed (or possibly needs changing in C(check_mode)), when in diff mode. +''' + +# platform: +# description: Target OS/families that can be operated against. +# support: N/A + + # Should be used together with the standard fragment + INFO_MODULE = r''' +options: {} +attributes: + check_mode: + support: full + details: + - This action does not modify state. + diff_mode: + support: N/A + details: + - This action does not modify state. +''' + + CONN = r''' +options: {} +attributes: + become: + description: Is usable alongside C(become) keywords. + connection: + description: Uses the target's configured connection information to execute code on it. + delegation: + description: Can be used in conjunction with C(delegate_to) and related keywords. +''' + + FACTS = r''' +options: {} +attributes: + facts: + description: Action returns an C(ansible_facts) dictionary that will update existing host facts. +''' + + # Should be used together with the standard fragment and the FACTS fragment + FACTS_MODULE = r''' +options: {} +attributes: + check_mode: + support: full + details: + - This action does not modify state. + diff_mode: + support: N/A + details: + - This action does not modify state. + facts: + support: full +''' + + FILES = r''' +options: {} +attributes: + safe_file_operations: + description: Uses Ansible's strict file operation functions to ensure proper permissions and avoid data corruption. +''' + + FLOW = r''' +options: {} +attributes: + action: + description: Indicates this has a corresponding action plugin so some parts of the options can be executed on the controller. + async: + description: Supports being used with the C(async) keyword. +''' diff --git a/plugins/modules/ali_instance_info.py b/plugins/modules/ali_instance_info.py index 4b758477a3..ea7bcc8d4a 100644 --- a/plugins/modules/ali_instance_info.py +++ b/plugins/modules/ali_instance_info.py @@ -60,6 +60,8 @@ requirements: - "footmark >= 1.13.0" extends_documentation_fragment: - community.general.alicloud + - community.general.attributes + - community.general.attributes.info_module ''' EXAMPLES = ''' diff --git a/plugins/modules/cloud_init_data_facts.py b/plugins/modules/cloud_init_data_facts.py index d02fd2301d..df2f77148e 100644 --- a/plugins/modules/cloud_init_data_facts.py +++ b/plugins/modules/cloud_init_data_facts.py @@ -15,6 +15,10 @@ short_description: Retrieve facts of cloud-init. description: - Gathers facts by reading the status.json and result.json of cloud-init. author: René Moser (@resmo) +extends_documentation_fragment: + - community.general.attributes + - community.general.attributes.facts + - community.general.attributes.facts_module options: filter: description: diff --git a/plugins/modules/dnsimple_info.py b/plugins/modules/dnsimple_info.py index f4a68f509d..959bacbbe8 100644 --- a/plugins/modules/dnsimple_info.py +++ b/plugins/modules/dnsimple_info.py @@ -19,6 +19,10 @@ version_added: "4.2.0" description: Retrieve existing records and domains from DNSimple API. +extends_documentation_fragment: + - community.general.attributes + - community.general.attributes.info_module + options: name: description: diff --git a/plugins/modules/gconftool2_info.py b/plugins/modules/gconftool2_info.py index acebb44013..f9231104d4 100644 --- a/plugins/modules/gconftool2_info.py +++ b/plugins/modules/gconftool2_info.py @@ -15,6 +15,9 @@ short_description: Retrieve GConf configurations version_added: 5.1.0 description: - This module allows retrieving application preferences from the GConf database, with the help of C(gconftool-2). +extends_documentation_fragment: + - community.general.attributes + - community.general.attributes.info_module options: key: description: diff --git a/plugins/modules/github_webhook_info.py b/plugins/modules/github_webhook_info.py index bc3d3c90fa..a6f7c3e52c 100644 --- a/plugins/modules/github_webhook_info.py +++ b/plugins/modules/github_webhook_info.py @@ -17,6 +17,9 @@ description: - This module was called C(github_webhook_facts) before Ansible 2.9. The usage did not change. requirements: - "PyGithub >= 1.3.5" +extends_documentation_fragment: + - community.general.attributes + - community.general.attributes.info_module options: repository: description: diff --git a/plugins/modules/hpilo_info.py b/plugins/modules/hpilo_info.py index 219885cf41..cef6597e48 100644 --- a/plugins/modules/hpilo_info.py +++ b/plugins/modules/hpilo_info.py @@ -21,6 +21,9 @@ description: - This module requires the C(hpilo) python module. - This module was called C(hpilo_facts) before Ansible 2.9, returning C(ansible_facts). Note that the M(community.general.hpilo_info) module no longer returns C(ansible_facts)! +extends_documentation_fragment: +- community.general.attributes +- community.general.attributes.info_module options: host: description: diff --git a/plugins/modules/idrac_redfish_info.py b/plugins/modules/idrac_redfish_info.py index 91e57de14d..cb44a75961 100644 --- a/plugins/modules/idrac_redfish_info.py +++ b/plugins/modules/idrac_redfish_info.py @@ -18,6 +18,9 @@ description: - For use with Dell EMC iDRAC operations that require Redfish OEM extensions. - This module was called C(idrac_redfish_facts) before Ansible 2.9, returning C(ansible_facts). Note that the M(community.general.idrac_redfish_info) module no longer returns C(ansible_facts)! +extends_documentation_fragment: + - community.general.attributes + - community.general.attributes.info_module options: category: required: true diff --git a/plugins/modules/ilo_redfish_info.py b/plugins/modules/ilo_redfish_info.py index 4611e620d5..90cafb8ec6 100644 --- a/plugins/modules/ilo_redfish_info.py +++ b/plugins/modules/ilo_redfish_info.py @@ -15,6 +15,9 @@ description: - Builds Redfish URIs locally and sends them to iLO to get information back. - For use with HPE iLO operations that require Redfish OEM extensions. +extends_documentation_fragment: + - community.general.attributes + - community.general.attributes.info_module options: category: required: true diff --git a/plugins/modules/ipify_facts.py b/plugins/modules/ipify_facts.py index 8953c02940..ab96d7e949 100644 --- a/plugins/modules/ipify_facts.py +++ b/plugins/modules/ipify_facts.py @@ -17,6 +17,10 @@ description: - If behind NAT and need to know the public IP of your internet gateway. author: - René Moser (@resmo) +extends_documentation_fragment: + - community.general.attributes + - community.general.attributes.facts + - community.general.attributes.facts_module options: api_url: description: diff --git a/plugins/modules/ipinfoio_facts.py b/plugins/modules/ipinfoio_facts.py index a10b54ecce..676e88d84d 100644 --- a/plugins/modules/ipinfoio_facts.py +++ b/plugins/modules/ipinfoio_facts.py @@ -16,6 +16,10 @@ short_description: "Retrieve IP geolocation facts of a host's IP address" description: - "Gather IP geolocation facts of a host's IP address using ipinfo.io API" author: "Aleksei Kostiuk (@akostyuk)" +extends_documentation_fragment: + - community.general.attributes + - community.general.attributes.facts + - community.general.attributes.facts_module options: timeout: description: diff --git a/plugins/modules/jenkins_job_info.py b/plugins/modules/jenkins_job_info.py index 1195a3e03d..ba6a531179 100644 --- a/plugins/modules/jenkins_job_info.py +++ b/plugins/modules/jenkins_job_info.py @@ -18,6 +18,9 @@ description: - This module was called C(jenkins_job_info) before Ansible 2.9. The usage did not change. requirements: - "python-jenkins >= 0.4.12" +extends_documentation_fragment: + - community.general.attributes + - community.general.attributes.info_module options: name: type: str diff --git a/plugins/modules/keycloak_realm_info.py b/plugins/modules/keycloak_realm_info.py index 0956f1b525..5c2ebb4c9e 100644 --- a/plugins/modules/keycloak_realm_info.py +++ b/plugins/modules/keycloak_realm_info.py @@ -26,6 +26,10 @@ description: be returned that way by this module. You may pass single values for attributes when calling the module, and this will be translated into a list suitable for the API. +extends_documentation_fragment: + - community.general.attributes + - community.general.attributes.info_module + options: auth_keycloak_url: description: diff --git a/plugins/modules/keyring_info.py b/plugins/modules/keyring_info.py index e0c33ce724..5c41ecc4d0 100644 --- a/plugins/modules/keyring_info.py +++ b/plugins/modules/keyring_info.py @@ -26,6 +26,9 @@ requirements: - keyring (Python library) - gnome-keyring (application - required for headless Linux keyring access) - dbus-run-session (application - required for headless Linux keyring access) +extends_documentation_fragment: + - community.general.attributes + - community.general.attributes.info_module options: service: description: The name of the service. diff --git a/plugins/modules/listen_ports_facts.py b/plugins/modules/listen_ports_facts.py index fc4afa6d7b..eb1ba09237 100644 --- a/plugins/modules/listen_ports_facts.py +++ b/plugins/modules/listen_ports_facts.py @@ -23,6 +23,10 @@ notes: - | C(ss) returns all processes for each listen address and port. This plugin will return each of them, so multiple entries for the same listen address and port are likely in results. +extends_documentation_fragment: + - community.general.attributes + - community.general.attributes.facts + - community.general.attributes.facts_module options: command: description: diff --git a/plugins/modules/manageiq_policies_info.py b/plugins/modules/manageiq_policies_info.py index cdf4cafdaf..c10ee95327 100644 --- a/plugins/modules/manageiq_policies_info.py +++ b/plugins/modules/manageiq_policies_info.py @@ -18,6 +18,8 @@ version_added: 5.8.0 short_description: Listing of resource policy_profiles in ManageIQ extends_documentation_fragment: - community.general.manageiq + - community.general.attributes + - community.general.attributes.info_module author: Alexei Znamensky (@russoz) description: diff --git a/plugins/modules/manageiq_tags_info.py b/plugins/modules/manageiq_tags_info.py index 0cdcd5184d..af71e150cb 100644 --- a/plugins/modules/manageiq_tags_info.py +++ b/plugins/modules/manageiq_tags_info.py @@ -15,7 +15,9 @@ module: manageiq_tags_info version_added: 5.8.0 short_description: Retrieve resource tags in ManageIQ extends_documentation_fragment: -- community.general.manageiq + - community.general.manageiq + - community.general.attributes + - community.general.attributes.info_module author: Alexei Znamensky (@russoz) description: diff --git a/plugins/modules/memset_memstore_info.py b/plugins/modules/memset_memstore_info.py index 1247085ab9..4de803f991 100644 --- a/plugins/modules/memset_memstore_info.py +++ b/plugins/modules/memset_memstore_info.py @@ -19,6 +19,9 @@ notes: description: - Retrieve Memstore product usage information. - This module was called C(memset_memstore_facts) before Ansible 2.9. The usage did not change. +extends_documentation_fragment: + - community.general.attributes + - community.general.attributes.info_module options: api_key: required: true diff --git a/plugins/modules/memset_server_info.py b/plugins/modules/memset_server_info.py index b756a8338e..44aa0d8442 100644 --- a/plugins/modules/memset_server_info.py +++ b/plugins/modules/memset_server_info.py @@ -19,6 +19,9 @@ notes: description: - Retrieve server information. - This module was called C(memset_server_facts) before Ansible 2.9. The usage did not change. +extends_documentation_fragment: + - community.general.attributes + - community.general.attributes.info_module options: api_key: required: true diff --git a/plugins/modules/nginx_status_info.py b/plugins/modules/nginx_status_info.py index 1c99fb2370..1e1bb10495 100644 --- a/plugins/modules/nginx_status_info.py +++ b/plugins/modules/nginx_status_info.py @@ -16,6 +16,9 @@ short_description: Retrieve information on nginx status. description: - Gathers information from nginx from an URL having C(stub_status) enabled. author: "René Moser (@resmo)" +extends_documentation_fragment: + - community.general.attributes + - community.general.attributes.info_module options: url: type: str diff --git a/plugins/modules/nomad_job_info.py b/plugins/modules/nomad_job_info.py index 5130fd1b60..5ee25a57a4 100644 --- a/plugins/modules/nomad_job_info.py +++ b/plugins/modules/nomad_job_info.py @@ -21,6 +21,8 @@ requirements: - python-nomad extends_documentation_fragment: - community.general.nomad + - community.general.attributes + - community.general.attributes.info_module options: name: description: diff --git a/plugins/modules/one_image_info.py b/plugins/modules/one_image_info.py index a908b46776..938f0ef2a4 100644 --- a/plugins/modules/one_image_info.py +++ b/plugins/modules/one_image_info.py @@ -17,6 +17,9 @@ description: - This module was called C(one_image_facts) before Ansible 2.9. The usage did not change. requirements: - pyone +extends_documentation_fragment: + - community.general.attributes + - community.general.attributes.info_module options: api_url: description: diff --git a/plugins/modules/onepassword_info.py b/plugins/modules/onepassword_info.py index ddf8579cb1..bb814c4439 100644 --- a/plugins/modules/onepassword_info.py +++ b/plugins/modules/onepassword_info.py @@ -29,6 +29,9 @@ description: - This module was called C(onepassword_facts) before Ansible 2.9, returning C(ansible_facts). Note that the M(community.general.onepassword_info) module no longer returns C(ansible_facts)! You must now use the C(register) option to use the facts in other tasks. +extends_documentation_fragment: + - community.general.attributes + - community.general.attributes.info_module options: search_terms: type: list diff --git a/plugins/modules/oneview_datacenter_info.py b/plugins/modules/oneview_datacenter_info.py index 0d78c2483a..76e752f399 100644 --- a/plugins/modules/oneview_datacenter_info.py +++ b/plugins/modules/oneview_datacenter_info.py @@ -34,8 +34,10 @@ options: elements: str extends_documentation_fragment: -- community.general.oneview -- community.general.oneview.factsparams + - community.general.oneview + - community.general.oneview.factsparams + - community.general.attributes + - community.general.attributes.info_module ''' diff --git a/plugins/modules/oneview_enclosure_info.py b/plugins/modules/oneview_enclosure_info.py index 1c19d36860..dfef893542 100644 --- a/plugins/modules/oneview_enclosure_info.py +++ b/plugins/modules/oneview_enclosure_info.py @@ -36,8 +36,10 @@ options: elements: raw extends_documentation_fragment: -- community.general.oneview -- community.general.oneview.factsparams + - community.general.oneview + - community.general.oneview.factsparams + - community.general.attributes + - community.general.attributes.info_module ''' diff --git a/plugins/modules/oneview_ethernet_network_info.py b/plugins/modules/oneview_ethernet_network_info.py index 94b87ff24b..cb58575a3b 100644 --- a/plugins/modules/oneview_ethernet_network_info.py +++ b/plugins/modules/oneview_ethernet_network_info.py @@ -33,8 +33,10 @@ options: type: list elements: str extends_documentation_fragment: -- community.general.oneview -- community.general.oneview.factsparams + - community.general.oneview + - community.general.oneview.factsparams + - community.general.attributes + - community.general.attributes.info_module ''' diff --git a/plugins/modules/oneview_fc_network_info.py b/plugins/modules/oneview_fc_network_info.py index 2b6377fb35..6927ba438c 100644 --- a/plugins/modules/oneview_fc_network_info.py +++ b/plugins/modules/oneview_fc_network_info.py @@ -28,8 +28,10 @@ options: type: str extends_documentation_fragment: -- community.general.oneview -- community.general.oneview.factsparams + - community.general.oneview + - community.general.oneview.factsparams + - community.general.attributes + - community.general.attributes.info_module ''' diff --git a/plugins/modules/oneview_fcoe_network_info.py b/plugins/modules/oneview_fcoe_network_info.py index db5c5a59b0..52bcb12c89 100644 --- a/plugins/modules/oneview_fcoe_network_info.py +++ b/plugins/modules/oneview_fcoe_network_info.py @@ -27,8 +27,10 @@ options: - FCoE Network name. type: str extends_documentation_fragment: -- community.general.oneview -- community.general.oneview.factsparams + - community.general.oneview + - community.general.oneview.factsparams + - community.general.attributes + - community.general.attributes.info_module ''' diff --git a/plugins/modules/oneview_logical_interconnect_group_info.py b/plugins/modules/oneview_logical_interconnect_group_info.py index f0962a996a..8d355cdaa0 100644 --- a/plugins/modules/oneview_logical_interconnect_group_info.py +++ b/plugins/modules/oneview_logical_interconnect_group_info.py @@ -28,8 +28,10 @@ options: - Logical Interconnect Group name. type: str extends_documentation_fragment: -- community.general.oneview -- community.general.oneview.factsparams + - community.general.oneview + - community.general.oneview.factsparams + - community.general.attributes + - community.general.attributes.info_module ''' diff --git a/plugins/modules/oneview_network_set_info.py b/plugins/modules/oneview_network_set_info.py index caff260220..1c793dbfb5 100644 --- a/plugins/modules/oneview_network_set_info.py +++ b/plugins/modules/oneview_network_set_info.py @@ -36,8 +36,10 @@ options: elements: str extends_documentation_fragment: -- community.general.oneview -- community.general.oneview.factsparams + - community.general.oneview + - community.general.oneview.factsparams + - community.general.attributes + - community.general.attributes.info_module ''' diff --git a/plugins/modules/oneview_san_manager_info.py b/plugins/modules/oneview_san_manager_info.py index 95497ed8aa..87b3c0534f 100644 --- a/plugins/modules/oneview_san_manager_info.py +++ b/plugins/modules/oneview_san_manager_info.py @@ -36,7 +36,9 @@ options: - C(sort): The sort order of the returned data set." type: dict extends_documentation_fragment: -- community.general.oneview + - community.general.oneview + - community.general.attributes + - community.general.attributes.info_module ''' diff --git a/plugins/modules/online_server_info.py b/plugins/modules/online_server_info.py index 6ba3e4aa4f..533e0453f9 100644 --- a/plugins/modules/online_server_info.py +++ b/plugins/modules/online_server_info.py @@ -18,7 +18,9 @@ description: author: - "Remy Leone (@remyleone)" extends_documentation_fragment: -- community.general.online + - community.general.online + - community.general.attributes + - community.general.attributes.info_module ''' diff --git a/plugins/modules/online_user_info.py b/plugins/modules/online_user_info.py index 1086502040..17cbc7d662 100644 --- a/plugins/modules/online_user_info.py +++ b/plugins/modules/online_user_info.py @@ -15,7 +15,9 @@ description: author: - "Remy Leone (@remyleone)" extends_documentation_fragment: -- community.general.online + - community.general.online + - community.general.attributes + - community.general.attributes.info_module ''' EXAMPLES = r''' diff --git a/plugins/modules/pip_package_info.py b/plugins/modules/pip_package_info.py index 6931366c87..c89e47014e 100644 --- a/plugins/modules/pip_package_info.py +++ b/plugins/modules/pip_package_info.py @@ -14,6 +14,9 @@ module: pip_package_info short_description: pip package information description: - Return information about installed pip packages +extends_documentation_fragment: + - community.general.attributes + - community.general.attributes.info_module options: clients: description: @@ -24,7 +27,7 @@ options: type: list elements: path requirements: - - The requested pip executables must be installed on the target. + - The requested pip executables must be installed on the target. author: - Matthew Jones (@matburt) - Brian Coca (@bcoca) diff --git a/plugins/modules/pipx_info.py b/plugins/modules/pipx_info.py index 05b9db1b2d..ff9698e31d 100644 --- a/plugins/modules/pipx_info.py +++ b/plugins/modules/pipx_info.py @@ -16,6 +16,9 @@ short_description: Rretrieves information about applications installed with pipx version_added: 5.6.0 description: - Retrieve details about Python applications installed in isolated virtualenvs using pipx. +extends_documentation_fragment: + - community.general.attributes + - community.general.attributes.info_module options: name: description: diff --git a/plugins/modules/pritunl_org_info.py b/plugins/modules/pritunl_org_info.py index 1529239ad9..7f3974e0e5 100644 --- a/plugins/modules/pritunl_org_info.py +++ b/plugins/modules/pritunl_org_info.py @@ -18,6 +18,8 @@ description: - A module to list Pritunl organizations using the Pritunl API. extends_documentation_fragment: - community.general.pritunl + - community.general.attributes + - community.general.attributes.info_module options: organization: type: str diff --git a/plugins/modules/pritunl_user_info.py b/plugins/modules/pritunl_user_info.py index 3a5343f6b6..d4c68ca6e0 100644 --- a/plugins/modules/pritunl_user_info.py +++ b/plugins/modules/pritunl_user_info.py @@ -18,6 +18,8 @@ description: - A module to list Pritunl users using the Pritunl API. extends_documentation_fragment: - community.general.pritunl + - community.general.attributes + - community.general.attributes.info_module options: organization: type: str diff --git a/plugins/modules/proxmox_domain_info.py b/plugins/modules/proxmox_domain_info.py index 2cabf5b3c7..7435695a91 100644 --- a/plugins/modules/proxmox_domain_info.py +++ b/plugins/modules/proxmox_domain_info.py @@ -23,7 +23,10 @@ options: aliases: ['realm', 'name'] type: str author: Tristan Le Guern (@tleguern) -extends_documentation_fragment: community.general.proxmox.documentation +extends_documentation_fragment: + - community.general.proxmox.documentation + - community.general.attributes + - community.general.attributes.info_module ''' diff --git a/plugins/modules/proxmox_group_info.py b/plugins/modules/proxmox_group_info.py index d2d4491ce2..531a9dae7a 100644 --- a/plugins/modules/proxmox_group_info.py +++ b/plugins/modules/proxmox_group_info.py @@ -23,7 +23,10 @@ options: aliases: ['groupid', 'name'] type: str author: Tristan Le Guern (@tleguern) -extends_documentation_fragment: community.general.proxmox.documentation +extends_documentation_fragment: + - community.general.proxmox.documentation + - community.general.attributes + - community.general.attributes.info_module ''' diff --git a/plugins/modules/proxmox_storage_info.py b/plugins/modules/proxmox_storage_info.py index a98d3794a9..fd3759364b 100644 --- a/plugins/modules/proxmox_storage_info.py +++ b/plugins/modules/proxmox_storage_info.py @@ -27,7 +27,10 @@ options: - Filter on a specifc storage type. type: str author: Tristan Le Guern (@tleguern) -extends_documentation_fragment: community.general.proxmox.documentation +extends_documentation_fragment: + - community.general.proxmox.documentation + - community.general.attributes + - community.general.attributes.info_module notes: - Storage specific options can be returned by this module, please look at the documentation at U(https://pve.proxmox.com/wiki/Storage). ''' diff --git a/plugins/modules/proxmox_tasks_info.py b/plugins/modules/proxmox_tasks_info.py index c0a3dc6886..183fb3bf0f 100644 --- a/plugins/modules/proxmox_tasks_info.py +++ b/plugins/modules/proxmox_tasks_info.py @@ -30,6 +30,8 @@ options: type: str extends_documentation_fragment: - community.general.proxmox.documentation + - community.general.attributes + - community.general.attributes.info_module ''' diff --git a/plugins/modules/proxmox_user_info.py b/plugins/modules/proxmox_user_info.py index f1b3b881c9..a515f2b453 100644 --- a/plugins/modules/proxmox_user_info.py +++ b/plugins/modules/proxmox_user_info.py @@ -32,7 +32,10 @@ options: - Restrict results to a specific user ID, which is a concatenation of a user and domain parts. type: str author: Tristan Le Guern (@tleguern) -extends_documentation_fragment: community.general.proxmox.documentation +extends_documentation_fragment: + - community.general.proxmox.documentation + - community.general.attributes + - community.general.attributes.info_module ''' EXAMPLES = ''' diff --git a/plugins/modules/python_requirements_info.py b/plugins/modules/python_requirements_info.py index d96787c7d0..231114a1db 100644 --- a/plugins/modules/python_requirements_info.py +++ b/plugins/modules/python_requirements_info.py @@ -13,6 +13,9 @@ short_description: Show python path and assert dependency versions description: - Get info about available Python requirements on the target host, including listing required libraries and gathering versions. - This module was called C(python_requirements_facts) before Ansible 2.9. The usage did not change. +extends_documentation_fragment: + - community.general.attributes + - community.general.attributes.info_module options: dependencies: type: list diff --git a/plugins/modules/rax_facts.py b/plugins/modules/rax_facts.py index 560f05e56a..53657f3c9a 100644 --- a/plugins/modules/rax_facts.py +++ b/plugins/modules/rax_facts.py @@ -13,7 +13,7 @@ DOCUMENTATION = ''' module: rax_facts short_description: Gather facts for Rackspace Cloud Servers description: - - Gather facts for Rackspace Cloud Servers. + - Gather facts for Rackspace Cloud Servers. options: address: type: str @@ -30,7 +30,10 @@ options: - Server name to retrieve facts for author: "Matt Martz (@sivel)" extends_documentation_fragment: -- community.general.rackspace.openstack + - community.general.rackspace.openstack + - community.general.attributes + - community.general.attributes.facts + - community.general.attributes.facts_module ''' diff --git a/plugins/modules/redfish_info.py b/plugins/modules/redfish_info.py index 4cb42711ad..fd81695368 100644 --- a/plugins/modules/redfish_info.py +++ b/plugins/modules/redfish_info.py @@ -18,6 +18,9 @@ description: - Information retrieved is placed in a location specified by the user. - This module was called C(redfish_facts) before Ansible 2.9, returning C(ansible_facts). Note that the M(community.general.redfish_info) module no longer returns C(ansible_facts)! +extends_documentation_fragment: + - community.general.attributes + - community.general.attributes.info_module options: category: required: false diff --git a/plugins/modules/redis_data_info.py b/plugins/modules/redis_data_info.py index c4186ff358..c0af619057 100644 --- a/plugins/modules/redis_data_info.py +++ b/plugins/modules/redis_data_info.py @@ -25,6 +25,8 @@ options: extends_documentation_fragment: - community.general.redis + - community.general.attributes + - community.general.attributes.info_module seealso: - module: community.general.redis_data diff --git a/plugins/modules/redis_info.py b/plugins/modules/redis_info.py index 25b1d80035..b9900a7caf 100644 --- a/plugins/modules/redis_info.py +++ b/plugins/modules/redis_info.py @@ -16,6 +16,9 @@ short_description: Gather information about Redis servers version_added: '0.2.0' description: - Gathers information and statistics about Redis servers. +extends_documentation_fragment: +- community.general.attributes +- community.general.attributes.info_module options: login_host: description: diff --git a/plugins/modules/rundeck_job_executions_info.py b/plugins/modules/rundeck_job_executions_info.py index 2af6eb1d5f..818bde83c0 100644 --- a/plugins/modules/rundeck_job_executions_info.py +++ b/plugins/modules/rundeck_job_executions_info.py @@ -41,6 +41,8 @@ options: extends_documentation_fragment: - community.general.rundeck - url + - community.general.attributes + - community.general.attributes.info_module ''' EXAMPLES = ''' diff --git a/plugins/modules/scaleway_container_namespace_info.py b/plugins/modules/scaleway_container_namespace_info.py index daf5d7b1d6..20ec25d96a 100644 --- a/plugins/modules/scaleway_container_namespace_info.py +++ b/plugins/modules/scaleway_container_namespace_info.py @@ -21,7 +21,8 @@ description: - This module return information about a container namespace on Scaleway account. extends_documentation_fragment: - community.general.scaleway - + - community.general.attributes + - community.general.attributes.info_module options: project_id: diff --git a/plugins/modules/scaleway_container_registry_info.py b/plugins/modules/scaleway_container_registry_info.py index c53e405780..d2a5e61e93 100644 --- a/plugins/modules/scaleway_container_registry_info.py +++ b/plugins/modules/scaleway_container_registry_info.py @@ -21,7 +21,8 @@ description: - This module return information about a container registry on Scaleway account. extends_documentation_fragment: - community.general.scaleway - + - community.general.attributes + - community.general.attributes.info_module options: project_id: diff --git a/plugins/modules/scaleway_function_info.py b/plugins/modules/scaleway_function_info.py index b6f2eefa71..47eca48614 100644 --- a/plugins/modules/scaleway_function_info.py +++ b/plugins/modules/scaleway_function_info.py @@ -21,7 +21,8 @@ description: - This module return information about a function on Scaleway account. extends_documentation_fragment: - community.general.scaleway - + - community.general.attributes + - community.general.attributes.info_module options: namespace_id: diff --git a/plugins/modules/scaleway_function_namespace_info.py b/plugins/modules/scaleway_function_namespace_info.py index 7e02e8e42d..bb0b7fa9df 100644 --- a/plugins/modules/scaleway_function_namespace_info.py +++ b/plugins/modules/scaleway_function_namespace_info.py @@ -21,7 +21,8 @@ description: - This module return information about a function namespace on Scaleway account. extends_documentation_fragment: - community.general.scaleway - + - community.general.attributes + - community.general.attributes.info_module options: project_id: diff --git a/plugins/modules/scaleway_image_info.py b/plugins/modules/scaleway_image_info.py index c68cc99684..ee0134a52a 100644 --- a/plugins/modules/scaleway_image_info.py +++ b/plugins/modules/scaleway_image_info.py @@ -18,7 +18,9 @@ author: - "Yanis Guenane (@Spredzy)" - "Remy Leone (@remyleone)" extends_documentation_fragment: -- community.general.scaleway + - community.general.scaleway + - community.general.attributes + - community.general.attributes.info_module options: region: diff --git a/plugins/modules/scaleway_ip_info.py b/plugins/modules/scaleway_ip_info.py index c65c7e6ab9..d8725894e6 100644 --- a/plugins/modules/scaleway_ip_info.py +++ b/plugins/modules/scaleway_ip_info.py @@ -18,7 +18,9 @@ author: - "Yanis Guenane (@Spredzy)" - "Remy Leone (@remyleone)" extends_documentation_fragment: -- community.general.scaleway + - community.general.scaleway + - community.general.attributes + - community.general.attributes.info_module options: region: diff --git a/plugins/modules/scaleway_organization_info.py b/plugins/modules/scaleway_organization_info.py index 542b8d4603..aca8a0c43f 100644 --- a/plugins/modules/scaleway_organization_info.py +++ b/plugins/modules/scaleway_organization_info.py @@ -24,7 +24,9 @@ options: default: 'https://account.scaleway.com' aliases: ['base_url'] extends_documentation_fragment: -- community.general.scaleway + - community.general.scaleway + - community.general.attributes + - community.general.attributes.info_module ''' diff --git a/plugins/modules/scaleway_security_group_info.py b/plugins/modules/scaleway_security_group_info.py index 5e2cc95a1c..7fd96fd067 100644 --- a/plugins/modules/scaleway_security_group_info.py +++ b/plugins/modules/scaleway_security_group_info.py @@ -33,7 +33,9 @@ options: - waw1 - EMEA-PL-WAW1 extends_documentation_fragment: -- community.general.scaleway + - community.general.scaleway + - community.general.attributes + - community.general.attributes.info_module ''' diff --git a/plugins/modules/scaleway_server_info.py b/plugins/modules/scaleway_server_info.py index 087be54d24..7a31882ef7 100644 --- a/plugins/modules/scaleway_server_info.py +++ b/plugins/modules/scaleway_server_info.py @@ -18,7 +18,9 @@ author: - "Yanis Guenane (@Spredzy)" - "Remy Leone (@remyleone)" extends_documentation_fragment: -- community.general.scaleway + - community.general.scaleway + - community.general.attributes + - community.general.attributes.info_module options: region: diff --git a/plugins/modules/scaleway_snapshot_info.py b/plugins/modules/scaleway_snapshot_info.py index bebf27395c..47cd14cee8 100644 --- a/plugins/modules/scaleway_snapshot_info.py +++ b/plugins/modules/scaleway_snapshot_info.py @@ -18,7 +18,9 @@ author: - "Yanis Guenane (@Spredzy)" - "Remy Leone (@remyleone)" extends_documentation_fragment: -- community.general.scaleway + - community.general.scaleway + - community.general.attributes + - community.general.attributes.info_module options: region: diff --git a/plugins/modules/scaleway_volume_info.py b/plugins/modules/scaleway_volume_info.py index 14a8c96884..369fadbe64 100644 --- a/plugins/modules/scaleway_volume_info.py +++ b/plugins/modules/scaleway_volume_info.py @@ -18,7 +18,9 @@ author: - "Yanis Guenane (@Spredzy)" - "Remy Leone (@remyleone)" extends_documentation_fragment: -- community.general.scaleway + - community.general.scaleway + - community.general.attributes + - community.general.attributes.info_module options: region: diff --git a/plugins/modules/smartos_image_info.py b/plugins/modules/smartos_image_info.py index fb8c782317..0b5117fc45 100644 --- a/plugins/modules/smartos_image_info.py +++ b/plugins/modules/smartos_image_info.py @@ -18,6 +18,9 @@ description: - This module was called C(smartos_image_facts) before Ansible 2.9, returning C(ansible_facts). Note that the M(community.general.smartos_image_info) module no longer returns C(ansible_facts)! author: Adam Števko (@xen0l) +extends_documentation_fragment: + - community.general.attributes + - community.general.attributes.info_module options: filters: description: diff --git a/plugins/modules/snmp_facts.py b/plugins/modules/snmp_facts.py index 7683d7308b..71821faaa8 100644 --- a/plugins/modules/snmp_facts.py +++ b/plugins/modules/snmp_facts.py @@ -20,6 +20,10 @@ description: inserted to the ansible_facts key. requirements: - pysnmp +extends_documentation_fragment: + - community.general.attributes + - community.general.attributes.facts + - community.general.attributes.facts_module options: host: description: diff --git a/plugins/modules/utm_aaa_group_info.py b/plugins/modules/utm_aaa_group_info.py index 26d06cebfe..a01dad92ac 100644 --- a/plugins/modules/utm_aaa_group_info.py +++ b/plugins/modules/utm_aaa_group_info.py @@ -31,7 +31,9 @@ options: required: true extends_documentation_fragment: -- community.general.utm + - community.general.utm + - community.general.attributes + - community.general.attributes.info_module ''' diff --git a/plugins/modules/utm_ca_host_key_cert_info.py b/plugins/modules/utm_ca_host_key_cert_info.py index f67960eeef..e5de74cd4c 100644 --- a/plugins/modules/utm_ca_host_key_cert_info.py +++ b/plugins/modules/utm_ca_host_key_cert_info.py @@ -30,8 +30,9 @@ options: required: true extends_documentation_fragment: -- community.general.utm - + - community.general.utm + - community.general.attributes + - community.general.attributes.info_module ''' EXAMPLES = """ diff --git a/plugins/modules/utm_network_interface_address_info.py b/plugins/modules/utm_network_interface_address_info.py index d7910e73e4..736ea501ef 100644 --- a/plugins/modules/utm_network_interface_address_info.py +++ b/plugins/modules/utm_network_interface_address_info.py @@ -29,8 +29,9 @@ options: required: true extends_documentation_fragment: -- community.general.utm - + - community.general.utm + - community.general.attributes + - community.general.attributes.info_module ''' EXAMPLES = """ diff --git a/plugins/modules/utm_proxy_frontend_info.py b/plugins/modules/utm_proxy_frontend_info.py index 27a71a013e..0b8e124379 100644 --- a/plugins/modules/utm_proxy_frontend_info.py +++ b/plugins/modules/utm_proxy_frontend_info.py @@ -31,8 +31,9 @@ options: required: true extends_documentation_fragment: -- community.general.utm - + - community.general.utm + - community.general.attributes + - community.general.attributes.info_module ''' EXAMPLES = """ diff --git a/plugins/modules/utm_proxy_location_info.py b/plugins/modules/utm_proxy_location_info.py index b46603f8f1..0e7b165903 100644 --- a/plugins/modules/utm_proxy_location_info.py +++ b/plugins/modules/utm_proxy_location_info.py @@ -31,8 +31,9 @@ options: required: true extends_documentation_fragment: -- community.general.utm - + - community.general.utm + - community.general.attributes + - community.general.attributes.info_module ''' EXAMPLES = """ diff --git a/plugins/modules/vertica_info.py b/plugins/modules/vertica_info.py index 825006ad71..a51187de1d 100644 --- a/plugins/modules/vertica_info.py +++ b/plugins/modules/vertica_info.py @@ -17,6 +17,9 @@ description: - Gathers Vertica database information. - This module was called C(vertica_facts) before Ansible 2.9, returning C(ansible_facts). Note that the M(community.general.vertica_info) module no longer returns C(ansible_facts)! +extends_documentation_fragment: + - community.general.attributes + - community.general.attributes.info_module options: cluster: description: diff --git a/plugins/modules/wdc_redfish_info.py b/plugins/modules/wdc_redfish_info.py index 7ba9263b55..038e1a72db 100644 --- a/plugins/modules/wdc_redfish_info.py +++ b/plugins/modules/wdc_redfish_info.py @@ -16,6 +16,9 @@ version_added: 5.4.0 description: - Builds Redfish URIs locally and sends them to remote OOB controllers to get information back. +extends_documentation_fragment: + - community.general.attributes + - community.general.attributes.info_module options: category: required: true diff --git a/plugins/modules/xenserver_facts.py b/plugins/modules/xenserver_facts.py index 567aa07adb..10ec3cd50f 100644 --- a/plugins/modules/xenserver_facts.py +++ b/plugins/modules/xenserver_facts.py @@ -16,9 +16,13 @@ short_description: get facts reported on xenserver description: - Reads data out of XenAPI, can be used instead of multiple xe commands. author: - - Andy Hill (@andyhky) - - Tim Rupp (@caphrim007) - - Robin Lee (@cheese) + - Andy Hill (@andyhky) + - Tim Rupp (@caphrim007) + - Robin Lee (@cheese) +extends_documentation_fragment: + - community.general.attributes + - community.general.attributes.facts + - community.general.attributes.facts_module options: {} ''' diff --git a/plugins/modules/xenserver_guest_info.py b/plugins/modules/xenserver_guest_info.py index 750cc3a84f..5cdd52fc56 100644 --- a/plugins/modules/xenserver_guest_info.py +++ b/plugins/modules/xenserver_guest_info.py @@ -47,7 +47,8 @@ options: type: str extends_documentation_fragment: - community.general.xenserver.documentation - +- community.general.attributes +- community.general.attributes.info_module ''' EXAMPLES = r''' diff --git a/plugins/modules/xfconf_info.py b/plugins/modules/xfconf_info.py index 2bdb745393..149325ebac 100644 --- a/plugins/modules/xfconf_info.py +++ b/plugins/modules/xfconf_info.py @@ -15,6 +15,9 @@ short_description: Retrieve XFCE4 configurations version_added: 3.5.0 description: - This module allows retrieving Xfce 4 configurations with the help of C(xfconf-query). +extends_documentation_fragment: + - community.general.attributes + - community.general.attributes.info_module options: channel: description: diff --git a/plugins/modules/zfs_facts.py b/plugins/modules/zfs_facts.py index 15eef706e5..734659a7ea 100644 --- a/plugins/modules/zfs_facts.py +++ b/plugins/modules/zfs_facts.py @@ -16,6 +16,10 @@ short_description: Gather facts about ZFS datasets. description: - Gather facts from ZFS dataset properties. author: Adam Števko (@xen0l) +extends_documentation_fragment: + - community.general.attributes + - community.general.attributes.facts + - community.general.attributes.facts_module options: name: description: diff --git a/plugins/modules/zpool_facts.py b/plugins/modules/zpool_facts.py index a749438659..ec5fdc4442 100644 --- a/plugins/modules/zpool_facts.py +++ b/plugins/modules/zpool_facts.py @@ -16,6 +16,10 @@ short_description: Gather facts about ZFS pools. description: - Gather facts from ZFS pool properties. author: Adam Števko (@xen0l) +extends_documentation_fragment: + - community.general.attributes + - community.general.attributes.facts + - community.general.attributes.facts_module options: name: description: From 7a9af2b601075d546ecb7ccd3860495a0421c6ba Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Mon, 7 Nov 2022 18:43:21 +1300 Subject: [PATCH 0017/1810] hponcfg: using CmdRunner (#5483) * hponcfg: using CmdRunner * add changelog fragment --- .../fragments/5483-hponcfg-cmd-runner.yml | 2 ++ plugins/modules/hponcfg.py | 30 ++++++++++--------- 2 files changed, 18 insertions(+), 14 deletions(-) create mode 100644 changelogs/fragments/5483-hponcfg-cmd-runner.yml diff --git a/changelogs/fragments/5483-hponcfg-cmd-runner.yml b/changelogs/fragments/5483-hponcfg-cmd-runner.yml new file mode 100644 index 0000000000..9d6c0eb8a9 --- /dev/null +++ b/changelogs/fragments/5483-hponcfg-cmd-runner.yml @@ -0,0 +1,2 @@ +minor_changes: + - hponcfg - refactored module to use ``CmdRunner`` to execute ``hponcfg`` (https://github.com/ansible-collections/community.general/pull/5483). diff --git a/plugins/modules/hponcfg.py b/plugins/modules/hponcfg.py index 9d2afc0ab1..65e40c46ed 100644 --- a/plugins/modules/hponcfg.py +++ b/plugins/modules/hponcfg.py @@ -73,12 +73,11 @@ EXAMPLES = r''' executable: /opt/hp/tools/hponcfg ''' -from ansible_collections.community.general.plugins.module_utils.module_helper import ( - CmdModuleHelper, ArgFormat -) +from ansible_collections.community.general.plugins.module_utils.cmd_runner import CmdRunner, cmd_runner_fmt +from ansible_collections.community.general.plugins.module_utils.module_helper import ModuleHelper -class HPOnCfg(CmdModuleHelper): +class HPOnCfg(ModuleHelper): module = dict( argument_spec=dict( src=dict(type='path', required=True, aliases=['path']), @@ -88,19 +87,22 @@ class HPOnCfg(CmdModuleHelper): ) ) command_args_formats = dict( - src=dict(fmt=["-f", "{0}"]), - verbose=dict(fmt="-v", style=ArgFormat.BOOLEAN), - minfw=dict(fmt=["-m", "{0}"]), + src=cmd_runner_fmt.as_opt_val("-f"), + verbose=cmd_runner_fmt.as_bool("-v"), + minfw=cmd_runner_fmt.as_opt_val("-m"), ) - check_rc = True - - def __init_module__(self): - self.command = self.vars.executable - # Consider every action a change (not idempotent yet!) - self.changed = True def __run__(self): - self.run_command(params=['src', 'verbose', 'minfw']) + runner = CmdRunner( + self.module, + self.vars.executable, + self.command_args_formats, + check_rc=True, + ) + runner(['src', 'verbose', 'minfw']).run() + + # Consider every action a change (not idempotent yet!) + self.changed = True def main(): From c757e20d108963c65de789c501d53a4f74dffd1f Mon Sep 17 00:00:00 2001 From: Yuhua Zou <41054978+ZouYuhua@users.noreply.github.com> Date: Mon, 7 Nov 2022 14:00:55 +0800 Subject: [PATCH 0018/1810] fix the issue#5275: iso_create doesn't add folders (#5468) * fix the issue * add changelog * add changelog file * Update changelogs/fragments/5468-iso-create-not-add-folders.yml Co-authored-by: Felix Fontein --- changelogs/fragments/5468-iso-create-not-add-folders.yml | 2 ++ plugins/modules/iso_create.py | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/5468-iso-create-not-add-folders.yml diff --git a/changelogs/fragments/5468-iso-create-not-add-folders.yml b/changelogs/fragments/5468-iso-create-not-add-folders.yml new file mode 100644 index 0000000000..5bbe48f579 --- /dev/null +++ b/changelogs/fragments/5468-iso-create-not-add-folders.yml @@ -0,0 +1,2 @@ +bugfixes: + - iso_create - the module somtimes failed to add folders for Joliet and UDF formats (https://github.com/ansible-collections/community.general/issues/5275). diff --git a/plugins/modules/iso_create.py b/plugins/modules/iso_create.py index d729f222a2..c457f5a412 100644 --- a/plugins/modules/iso_create.py +++ b/plugins/modules/iso_create.py @@ -188,9 +188,9 @@ def add_directory(module, iso_file=None, dir_path=None, rock_ridge=None, use_jol if rock_ridge: rr_name = os.path.basename(dir_path) if use_joliet: - joliet_path = iso_dir_path + joliet_path = dir_path if use_udf: - udf_path = iso_dir_path + udf_path = dir_path try: iso_file.add_directory(iso_path=iso_dir_path, rr_name=rr_name, joliet_path=joliet_path, udf_path=udf_path) except Exception as err: @@ -254,7 +254,7 @@ def main(): udf=use_udf ) if not module.check_mode: - iso_file = pycdlib.PyCdlib() + iso_file = pycdlib.PyCdlib(always_consistent=True) iso_file.new(interchange_level=inter_level, vol_ident=volume_id, rock_ridge=rock_ridge, joliet=use_joliet, udf=use_udf) for src_file in src_file_list: From 8758f6a43f1bcd9ae227dd41237bc07df3f10731 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Tue, 8 Nov 2022 08:02:10 +1300 Subject: [PATCH 0019/1810] mksysb: using CmdRunner (#5484) * mksysb: using CmdRunner * add changelog fragment * adjust code when check_mode true * Update plugins/modules/mksysb.py Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein --- .../fragments/5484-mksysb-cmd-runner.yml | 2 + plugins/modules/mksysb.py | 54 ++++++++++--------- 2 files changed, 32 insertions(+), 24 deletions(-) create mode 100644 changelogs/fragments/5484-mksysb-cmd-runner.yml diff --git a/changelogs/fragments/5484-mksysb-cmd-runner.yml b/changelogs/fragments/5484-mksysb-cmd-runner.yml new file mode 100644 index 0000000000..89f4d0dac8 --- /dev/null +++ b/changelogs/fragments/5484-mksysb-cmd-runner.yml @@ -0,0 +1,2 @@ +minor_changes: + - mksysb - refactored module to use ``CmdRunner`` to execute ``mksysb`` (https://github.com/ansible-collections/community.general/pull/5484). diff --git a/plugins/modules/mksysb.py b/plugins/modules/mksysb.py index a2e3f4e6c8..a466bd9df6 100644 --- a/plugins/modules/mksysb.py +++ b/plugins/modules/mksysb.py @@ -98,12 +98,15 @@ msg: import os +from ansible_collections.community.general.plugins.module_utils.cmd_runner import CmdRunner, cmd_runner_fmt +from ansible_collections.community.general.plugins.module_utils.module_helper import ModuleHelper + from ansible_collections.community.general.plugins.module_utils.module_helper import ( - CmdModuleHelper, ArgFormat + ArgFormat ) -class MkSysB(CmdModuleHelper): +class MkSysB(ModuleHelper): module = dict( argument_spec=dict( backup_crypt_files=dict(type='bool', default=True), @@ -120,18 +123,17 @@ class MkSysB(CmdModuleHelper): ), supports_check_mode=True, ) - command = ['mksysb', '-X'] command_args_formats = dict( - create_map_files=dict(fmt="-m", style=ArgFormat.BOOLEAN), - use_snapshot=dict(fmt="-T", style=ArgFormat.BOOLEAN), - exclude_files=dict(fmt="-e", style=ArgFormat.BOOLEAN), - exclude_wpar_files=dict(fmt="-G", style=ArgFormat.BOOLEAN), - new_image_data=dict(fmt="-i", style=ArgFormat.BOOLEAN), - software_packing=dict(fmt="-p", style=ArgFormat.BOOLEAN_NOT), - extended_attrs=dict(fmt="-a", style=ArgFormat.BOOLEAN), - backup_crypt_files=dict(fmt="-Z", style=ArgFormat.BOOLEAN_NOT), - backup_dmapi_fs=dict(fmt="-A", style=ArgFormat.BOOLEAN), - combined_path=dict(fmt=lambda p, n: ["%s/%s" % (p, n)], stars=1) + create_map_files=cmd_runner_fmt.as_bool("-m"), + use_snapshot=cmd_runner_fmt.as_bool("-T"), + exclude_files=cmd_runner_fmt.as_bool("-e"), + exclude_wpar_files=cmd_runner_fmt.as_bool("-G"), + new_image_data=cmd_runner_fmt.as_bool("-i"), + software_packing=cmd_runner_fmt.as_bool_not("-p"), + extended_attrs=cmd_runner_fmt.as_bool("-a"), + backup_crypt_files=cmd_runner_fmt.as_bool_not("-Z"), + backup_dmapi_fs=cmd_runner_fmt.as_bool("-A"), + combined_path=cmd_runner_fmt.as_func(cmd_runner_fmt.unpack_args(lambda p, n: ["%s/%s" % (p, n)])), ) def __init_module__(self): @@ -139,18 +141,22 @@ class MkSysB(CmdModuleHelper): self.do_raise("Storage path %s is not valid." % self.vars.storage_path) def __run__(self): - if not self.module.check_mode: - self.run_command(params=[ - 'create_map_files', 'use_snapshot', 'exclude_files', 'exclude_wpar_files', 'software_packing', - 'extended_attrs', 'backup_crypt_files', 'backup_dmapi_fs', 'new_image_data', - {'combined_path': [self.vars.storage_path, self.vars.name]}, - ]) - self._changed = True + def process(rc, out, err): + if rc != 0: + self.do_raise("mksysb failed.") + self.vars.msg = out - def process_command_output(self, rc, out, err): - if rc != 0: - self.do_raise("mksysb failed.") - self.vars.msg = out + runner = CmdRunner( + self.module, + ['mksysb', '-X'], + self.command_args_formats, + ) + with runner(['create_map_files', 'use_snapshot', 'exclude_files', 'exclude_wpar_files', 'software_packing', + 'extended_attrs', 'backup_crypt_files', 'backup_dmapi_fs', 'new_image_data', 'combined_path'], + output_process=process, check_mode_skip=True) as ctx: + ctx.run(combined_path=[self.vars.storage_path, self.vars.name]) + + self.changed = True def main(): From b696aa72b2cdbebb81223150d98cceb0640e7ffb Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Tue, 8 Nov 2022 08:15:00 +1300 Subject: [PATCH 0020/1810] cpanm: using CmdRunner (#5485) * cpanm: using CmdRunner * add changelog fragment --- .../fragments/5485-cpanm-cmd-runner.yml | 2 + plugins/modules/cpanm.py | 48 +++++++++---------- tests/unit/plugins/modules/test_cpanm.py | 11 +++-- 3 files changed, 32 insertions(+), 29 deletions(-) create mode 100644 changelogs/fragments/5485-cpanm-cmd-runner.yml diff --git a/changelogs/fragments/5485-cpanm-cmd-runner.yml b/changelogs/fragments/5485-cpanm-cmd-runner.yml new file mode 100644 index 0000000000..508f261762 --- /dev/null +++ b/changelogs/fragments/5485-cpanm-cmd-runner.yml @@ -0,0 +1,2 @@ +minor_changes: + - cpanm - refactored module to use ``CmdRunner`` to execute ``cpanm`` (https://github.com/ansible-collections/community.general/pull/5485). diff --git a/plugins/modules/cpanm.py b/plugins/modules/cpanm.py index aba4e9d56e..7ac8429bda 100644 --- a/plugins/modules/cpanm.py +++ b/plugins/modules/cpanm.py @@ -134,12 +134,11 @@ EXAMPLES = ''' import os -from ansible_collections.community.general.plugins.module_utils.module_helper import ( - ModuleHelper, CmdMixin, ArgFormat -) +from ansible_collections.community.general.plugins.module_utils.cmd_runner import CmdRunner, cmd_runner_fmt +from ansible_collections.community.general.plugins.module_utils.module_helper import ModuleHelper -class CPANMinus(CmdMixin, ModuleHelper): +class CPANMinus(ModuleHelper): output_params = ['name', 'version'] module = dict( argument_spec=dict( @@ -160,13 +159,13 @@ class CPANMinus(CmdMixin, ModuleHelper): ) command = 'cpanm' command_args_formats = dict( - notest=dict(fmt="--notest", style=ArgFormat.BOOLEAN), - locallib=dict(fmt=('--local-lib', '{0}'),), - mirror=dict(fmt=('--mirror', '{0}'),), - mirror_only=dict(fmt="--mirror-only", style=ArgFormat.BOOLEAN), - installdeps=dict(fmt="--installdeps", style=ArgFormat.BOOLEAN), + notest=cmd_runner_fmt.as_bool("--notest"), + locallib=cmd_runner_fmt.as_opt_val('--local-lib'), + mirror=cmd_runner_fmt.as_opt_val('--mirror'), + mirror_only=cmd_runner_fmt.as_bool("--mirror-only"), + installdeps=cmd_runner_fmt.as_bool("--installdeps"), + pkg_spec=cmd_runner_fmt.as_list(), ) - check_rc = True def __init_module__(self): v = self.vars @@ -181,15 +180,17 @@ class CPANMinus(CmdMixin, ModuleHelper): self.vars.set("binary", self.command) def _is_package_installed(self, name, locallib, version): + def process(rc, out, err): + return rc == 0 + if name is None or name.endswith('.tar.gz'): return False version = "" if version is None else " " + version env = {"PERL5LIB": "%s/lib/perl5" % locallib} if locallib else {} - cmd = ['perl', '-le', 'use %s%s;' % (name, version)] - rc, out, err = self.module.run_command(cmd, check_rc=False, environ_update=env) - - return rc == 0 + runner = CmdRunner(self.module, ["perl", "-le"], {"mod": cmd_runner_fmt.as_list()}, check_rc=False, environ_update=env) + with runner("mod", output_process=process) as ctx: + return ctx.run(mod='use %s%s;' % (name, version)) def sanitize_pkg_spec_version(self, pkg_spec, version): if version is None: @@ -207,6 +208,13 @@ class CPANMinus(CmdMixin, ModuleHelper): return pkg_spec + version def __run__(self): + def process(rc, out, err): + if self.vars.mode == "compatibility" and rc != 0: + self.do_raise(msg=err, cmd=self.vars.cmd_args) + return 'is up to date' not in err and 'is up to date' not in out + + runner = CmdRunner(self.module, self.command, self.command_args_formats, check_rc=True) + v = self.vars pkg_param = 'from_path' if v.from_path else 'name' @@ -214,22 +222,14 @@ class CPANMinus(CmdMixin, ModuleHelper): if self._is_package_installed(v.name, v.locallib, v.version): return pkg_spec = v[pkg_param] - self.changed = self.run_command( - params=['notest', 'locallib', 'mirror', 'mirror_only', 'installdeps', {'name': pkg_spec}], - ) else: installed = self._is_package_installed(v.name_check, v.locallib, v.version) if v.name_check else False if installed: return pkg_spec = self.sanitize_pkg_spec_version(v[pkg_param], v.version) - self.changed = self.run_command( - params=['notest', 'locallib', 'mirror', 'mirror_only', 'installdeps', {'name': pkg_spec}], - ) - def process_command_output(self, rc, out, err): - if self.vars.mode == "compatibility" and rc != 0: - self.do_raise(msg=err, cmd=self.vars.cmd_args) - return 'is up to date' not in err and 'is up to date' not in out + with runner(['notest', 'locallib', 'mirror', 'mirror_only', 'installdeps', 'pkg_spec'], output_process=process) as ctx: + self.changed = ctx.run(pkg_spec=pkg_spec) def main(): diff --git a/tests/unit/plugins/modules/test_cpanm.py b/tests/unit/plugins/modules/test_cpanm.py index 4d6ecdbd6e..5367a1fab8 100644 --- a/tests/unit/plugins/modules/test_cpanm.py +++ b/tests/unit/plugins/modules/test_cpanm.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # Author: Alexei Znamensky (russoz@gmail.com) # Largely adapted from test_redhat_subscription by # Jiri Hnidek (jhnidek@redhat.com) @@ -25,7 +26,7 @@ def patch_cpanm(mocker): """ Function used for mocking some parts of redhat_subscription module """ - mocker.patch('ansible_collections.community.general.plugins.module_utils.module_helper.AnsibleModule.get_bin_path', + mocker.patch('ansible.module_utils.basic.AnsibleModule.get_bin_path', return_value='/testbin/cpanm') @@ -36,8 +37,8 @@ TEST_CASES = [ 'id': 'install_dancer_compatibility', 'run_command.calls': [ ( - ['perl', '-le', 'use Dancer;'], - {'environ_update': {}, 'check_rc': False}, + ['/testbin/cpanm', '-le', 'use Dancer;'], + {'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': False}, (2, '', 'error, not installed',), # output rc, out, err ), ( @@ -55,8 +56,8 @@ TEST_CASES = [ 'id': 'install_dancer_already_installed_compatibility', 'run_command.calls': [ ( - ['perl', '-le', 'use Dancer;'], - {'environ_update': {}, 'check_rc': False}, + ['/testbin/cpanm', '-le', 'use Dancer;'], + {'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': False}, (0, '', '',), # output rc, out, err ), ], From bc7e7f8fcb9ded6ec30eda029b5de8bf7062dc70 Mon Sep 17 00:00:00 2001 From: Guillaume MARTINEZ Date: Mon, 7 Nov 2022 20:57:33 +0100 Subject: [PATCH 0021/1810] [Scaleway] Remove unused sensitive values filtering (#5497) * [Scaleway] Remove unused sensitive values filtering Signed-off-by: Lunik * Try adding function back. Maybe that works aound the bug in pylint. (Also it won't be a breaking change anymore.) Signed-off-by: Lunik Co-authored-by: Felix Fontein --- .../modules/scaleway_container_namespace_info.py | 13 +++++-------- plugins/modules/scaleway_container_registry_info.py | 9 ++------- plugins/modules/scaleway_function_info.py | 13 +++++-------- 3 files changed, 12 insertions(+), 23 deletions(-) diff --git a/plugins/modules/scaleway_container_namespace_info.py b/plugins/modules/scaleway_container_namespace_info.py index 20ec25d96a..fea2d8474b 100644 --- a/plugins/modules/scaleway_container_namespace_info.py +++ b/plugins/modules/scaleway_container_namespace_info.py @@ -74,20 +74,17 @@ container_namespace: region: fr-par registry_endpoint: "" registry_namespace_id: "" - secret_environment_variables: SENSITIVE_VALUE + secret_environment_variables: + - key: MY_SECRET_VAR + value: $argon2id$v=19$m=65536,t=1,p=2$tb6UwSPWx/rH5Vyxt9Ujfw$5ZlvaIjWwNDPxD9Rdght3NarJz4IETKjpvAU3mMSmFg status: pending ''' from ansible_collections.community.general.plugins.module_utils.scaleway import ( - SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, - filter_sensitive_attributes + SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway ) from ansible.module_utils.basic import AnsibleModule -SENSITIVE_ATTRIBUTES = ( - "secret_environment_variables", -) - def info_strategy(api, wished_cn): cn_list = api.fetch_all_resources("namespaces") @@ -124,7 +121,7 @@ def core(module): summary = info_strategy(api=api, wished_cn=wished_container_namespace) - module.exit_json(changed=False, container_namespace=filter_sensitive_attributes(summary, SENSITIVE_ATTRIBUTES)) + module.exit_json(changed=False, container_namespace=summary) def main(): diff --git a/plugins/modules/scaleway_container_registry_info.py b/plugins/modules/scaleway_container_registry_info.py index d2a5e61e93..c0682cefbe 100644 --- a/plugins/modules/scaleway_container_registry_info.py +++ b/plugins/modules/scaleway_container_registry_info.py @@ -80,15 +80,10 @@ container_registry: ''' from ansible_collections.community.general.plugins.module_utils.scaleway import ( - SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, - filter_sensitive_attributes + SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway ) from ansible.module_utils.basic import AnsibleModule -SENSITIVE_ATTRIBUTES = ( - "secret_environment_variables", -) - def info_strategy(api, wished_cn): cn_list = api.fetch_all_resources("namespaces") @@ -125,7 +120,7 @@ def core(module): summary = info_strategy(api=api, wished_cn=wished_container_namespace) - module.exit_json(changed=False, container_registry=filter_sensitive_attributes(summary, SENSITIVE_ATTRIBUTES)) + module.exit_json(changed=False, container_registry=summary) def main(): diff --git a/plugins/modules/scaleway_function_info.py b/plugins/modules/scaleway_function_info.py index 47eca48614..14a4cd6289 100644 --- a/plugins/modules/scaleway_function_info.py +++ b/plugins/modules/scaleway_function_info.py @@ -81,21 +81,18 @@ function: region: fr-par runtime: python310 runtime_message: "" - secret_environment_variables: SENSITIVE_VALUE + secret_environment_variables: + - key: MY_SECRET_VAR + value: $argon2id$v=19$m=65536,t=1,p=2$tb6UwSPWx/rH5Vyxt9Ujfw$5ZlvaIjWwNDPxD9Rdght3NarJz4IETKjpvAU3mMSmFg status: created timeout: 300s ''' from ansible_collections.community.general.plugins.module_utils.scaleway import ( - SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, - filter_sensitive_attributes + SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway ) from ansible.module_utils.basic import AnsibleModule -SENSITIVE_ATTRIBUTES = ( - "secret_environment_variables", -) - def info_strategy(api, wished_fn): fn_list = api.fetch_all_resources("functions") @@ -132,7 +129,7 @@ def core(module): summary = info_strategy(api=api, wished_fn=wished_function) - module.exit_json(changed=False, function=filter_sensitive_attributes(summary, SENSITIVE_ATTRIBUTES)) + module.exit_json(changed=False, function=summary) def main(): From 4fed0e13db5e30e5762faade9f8c38cd1d8abcd0 Mon Sep 17 00:00:00 2001 From: Guillaume MARTINEZ Date: Mon, 7 Nov 2022 21:04:55 +0100 Subject: [PATCH 0022/1810] [Scaleway] Add module to manage containers (#5496) Signed-off-by: Lunik Signed-off-by: Lunik --- .github/BOTMETA.yml | 4 + plugins/modules/scaleway_container.py | 406 ++++++++++++++++++ plugins/modules/scaleway_container_info.py | 151 +++++++ .../targets/scaleway_container/aliases | 6 + .../scaleway_container/defaults/main.yml | 18 + .../targets/scaleway_container/tasks/main.yml | 290 +++++++++++++ .../targets/scaleway_container_info/aliases | 6 + .../scaleway_container_info/defaults/main.yml | 16 + .../scaleway_container_info/tasks/main.yml | 63 +++ 9 files changed, 960 insertions(+) create mode 100644 plugins/modules/scaleway_container.py create mode 100644 plugins/modules/scaleway_container_info.py create mode 100644 tests/integration/targets/scaleway_container/aliases create mode 100644 tests/integration/targets/scaleway_container/defaults/main.yml create mode 100644 tests/integration/targets/scaleway_container/tasks/main.yml create mode 100644 tests/integration/targets/scaleway_container_info/aliases create mode 100644 tests/integration/targets/scaleway_container_info/defaults/main.yml create mode 100644 tests/integration/targets/scaleway_container_info/tasks/main.yml diff --git a/.github/BOTMETA.yml b/.github/BOTMETA.yml index 4975f30c0e..dfacfbecfb 100644 --- a/.github/BOTMETA.yml +++ b/.github/BOTMETA.yml @@ -1077,6 +1077,10 @@ files: maintainers: $team_scaleway $modules/scaleway_compute_private_network.py: maintainers: pastral + $modules/scaleway_container.py: + maintainers: Lunik + $modules/scaleway_container_info.py: + maintainers: Lunik $modules/scaleway_container_namespace.py: maintainers: Lunik $modules/scaleway_container_namespace_info.py: diff --git a/plugins/modules/scaleway_container.py b/plugins/modules/scaleway_container.py new file mode 100644 index 0000000000..6bc237ee39 --- /dev/null +++ b/plugins/modules/scaleway_container.py @@ -0,0 +1,406 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# Scaleway Serverless container management module +# +# Copyright (c) 2022, Guillaume MARTINEZ +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +DOCUMENTATION = ''' +--- +module: scaleway_container +short_description: Scaleway Container management +version_added: 6.0.0 +author: Guillaume MARTINEZ (@Lunik) +description: + - This module manages container on Scaleway account. +extends_documentation_fragment: + - community.general.scaleway + - community.general.scaleway_waitable_resource +requirements: + - passlib[argon2] >= 1.7.4 + + +options: + state: + type: str + description: + - Indicate desired state of the container. + default: present + choices: + - present + - absent + + namespace_id: + type: str + description: + - Container namespace identifier. + required: true + + region: + type: str + description: + - Scaleway region to use (for example C(fr-par)). + required: true + choices: + - fr-par + - nl-ams + - pl-waw + + name: + type: str + description: + - Name of the container namespace. + required: true + + description: + description: + - Description of the container namespace. + type: str + default: '' + + min_scale: + description: + - Minimum number of replicas for the container. + type: int + + max_scale: + description: + - Maximum number of replicas for the container. + type: int + + environment_variables: + description: + - Environment variables of the container namespace. + - Injected in container at runtime. + type: dict + default: {} + + secret_environment_variables: + description: + - Secret environment variables of the container namespace. + - Updating thoses values will not output a C(changed) state in Ansible. + - Injected in container at runtime. + type: dict + default: {} + + memory_limit: + description: + - Resources define performance characteristics of your container. + - They are allocated to your container at runtime. + type: int + + container_timeout: + description: + - The length of time your handler can spend processing a request before being stopped. + type: str + + privacy: + description: + - Privacy policies define whether a container can be executed anonymously. + - Choose C(public) to enable anonymous execution, or C(private) to protect your container with an authentication mechanism provided by the Scaleway API. + type: str + default: public + choices: + - public + - private + + registry_image: + description: + - The name of image used for the container. + type: str + required: true + + max_concurrency: + description: + - Maximum number of connections per container. + - This parameter will be used to trigger autoscaling. + type: int + + protocol: + description: + - Communication protocol of the container. + type: str + default: http1 + choices: + - http1 + - h2c + + port: + description: + - Listen port used to expose the container. + type: int + + redeploy: + description: + - Redeploy the container if update is required. + type: bool + default: false +''' + +EXAMPLES = ''' +- name: Create a container + community.general.scaleway_container: + namespace_id: '{{ scw_container_namespace }}' + state: present + region: fr-par + name: my-awesome-container + registry_image: rg.fr-par.scw.cloud/funcscwtestrgy2f9zw/nginx:latest + environment_variables: + MY_VAR: my_value + secret_environment_variables: + MY_SECRET_VAR: my_secret_value + register: container_creation_task + +- name: Make sure container is deleted + community.general.scaleway_container: + namespace_id: '{{ scw_container_namespace }}' + state: absent + region: fr-par + name: my-awesome-container +''' + +RETURN = ''' +container: + description: The container information. + returned: when I(state=present) + type: dict + sample: + cpu_limit: 140 + description: Container used for testing scaleway_container ansible module + domain_name: cnansibletestgfogtjod-cn-ansible-test.functions.fnc.fr-par.scw.cloud + environment_variables: + MY_VAR: my_value + error_message: null + http_option: "" + id: c9070eb0-d7a4-48dd-9af3-4fb139890721 + max_concurrency: 50 + max_scale: 5 + memory_limit: 256 + min_scale: 0 + name: cn-ansible-test + namespace_id: 75e299f1-d1e5-4e6b-bc6e-4fb51cfe1e69 + port: 80 + privacy: public + protocol: http1 + region: fr-par + registry_image: rg.fr-par.scw.cloud/namespace-ansible-ci/nginx:latest + secret_environment_variables: + - key: MY_SECRET_VAR + value: $argon2id$v=19$m=65536,t=1,p=2$tb6UwSPWx/rH5Vyxt9Ujfw$5ZlvaIjWwNDPxD9Rdght3NarJz4IETKjpvAU3mMSmFg + status: created + timeout: 300s +''' + +from copy import deepcopy + +from ansible_collections.community.general.plugins.module_utils.scaleway import ( + SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, + scaleway_waitable_resource_argument_spec, resource_attributes_should_be_changed, + SecretVariables +) +from ansible.module_utils.basic import AnsibleModule + +STABLE_STATES = ( + "ready", + "created", + "absent" +) + +MUTABLE_ATTRIBUTES = ( + "description", + "min_scale", + "max_scale", + "environment_variables", + "memory_limit", + "timeout", + "privacy", + "registry_image", + "max_concurrency", + "protocol", + "port", + "secret_environment_variables" +) + + +def payload_from_wished_cn(wished_cn): + payload = { + "namespace_id": wished_cn["namespace_id"], + "name": wished_cn["name"], + "description": wished_cn["description"], + "min_scale": wished_cn["min_scale"], + "max_scale": wished_cn["max_scale"], + "environment_variables": wished_cn["environment_variables"], + "secret_environment_variables": SecretVariables.dict_to_list(wished_cn["secret_environment_variables"]), + "memory_limit": wished_cn["memory_limit"], + "timeout": wished_cn["timeout"], + "privacy": wished_cn["privacy"], + "registry_image": wished_cn["registry_image"], + "max_concurrency": wished_cn["max_concurrency"], + "protocol": wished_cn["protocol"], + "port": wished_cn["port"], + "redeploy": wished_cn["redeploy"] + } + + return payload + + +def absent_strategy(api, wished_cn): + changed = False + + cn_list = api.fetch_all_resources("containers") + cn_lookup = dict((cn["name"], cn) + for cn in cn_list) + + if wished_cn["name"] not in cn_lookup: + return changed, {} + + target_cn = cn_lookup[wished_cn["name"]] + changed = True + if api.module.check_mode: + return changed, {"status": "Container would be destroyed"} + + api.wait_to_complete_state_transition(resource=target_cn, stable_states=STABLE_STATES, force_wait=True) + response = api.delete(path=api.api_path + "/%s" % target_cn["id"]) + if not response.ok: + api.module.fail_json(msg='Error deleting container [{0}: {1}]'.format( + response.status_code, response.json)) + + api.wait_to_complete_state_transition(resource=target_cn, stable_states=STABLE_STATES) + return changed, response.json + + +def present_strategy(api, wished_cn): + changed = False + + cn_list = api.fetch_all_resources("containers") + cn_lookup = dict((cn["name"], cn) + for cn in cn_list) + + payload_cn = payload_from_wished_cn(wished_cn) + + if wished_cn["name"] not in cn_lookup: + changed = True + if api.module.check_mode: + return changed, {"status": "A container would be created."} + + # Creation doesn't support `redeploy` parameter + del payload_cn["redeploy"] + + # Create container + api.warn(payload_cn) + creation_response = api.post(path=api.api_path, + data=payload_cn) + + if not creation_response.ok: + msg = "Error during container creation: %s: '%s' (%s)" % (creation_response.info['msg'], + creation_response.json['message'], + creation_response.json) + api.module.fail_json(msg=msg) + + api.wait_to_complete_state_transition(resource=creation_response.json, stable_states=STABLE_STATES) + response = api.get(path=api.api_path + "/%s" % creation_response.json["id"]) + return changed, response.json + + target_cn = cn_lookup[wished_cn["name"]] + decoded_target_cn = deepcopy(target_cn) + decoded_target_cn["secret_environment_variables"] = SecretVariables.decode(decoded_target_cn["secret_environment_variables"], + payload_cn["secret_environment_variables"]) + patch_payload = resource_attributes_should_be_changed(target=decoded_target_cn, + wished=payload_cn, + verifiable_mutable_attributes=MUTABLE_ATTRIBUTES, + mutable_attributes=MUTABLE_ATTRIBUTES) + + if not patch_payload: + return changed, target_cn + + changed = True + if api.module.check_mode: + return changed, {"status": "Container attributes would be changed."} + + cn_patch_response = api.patch(path=api.api_path + "/%s" % target_cn["id"], + data=patch_payload) + + if not cn_patch_response.ok: + api.module.fail_json(msg='Error during container attributes update: [{0}: {1}]'.format( + cn_patch_response.status_code, cn_patch_response.json['message'])) + + api.wait_to_complete_state_transition(resource=target_cn, stable_states=STABLE_STATES) + response = api.get(path=api.api_path + "/%s" % target_cn["id"]) + return changed, response.json + + +state_strategy = { + "present": present_strategy, + "absent": absent_strategy +} + + +def core(module): + SecretVariables.ensure_scaleway_secret_package(module) + + region = module.params["region"] + wished_container = { + "state": module.params["state"], + "namespace_id": module.params["namespace_id"], + "name": module.params["name"], + "description": module.params['description'], + "min_scale": module.params["min_scale"], + "max_scale": module.params["max_scale"], + "environment_variables": module.params['environment_variables'], + "secret_environment_variables": module.params['secret_environment_variables'], + "memory_limit": module.params["memory_limit"], + "timeout": module.params["container_timeout"], + "privacy": module.params["privacy"], + "registry_image": module.params["registry_image"], + "max_concurrency": module.params["max_concurrency"], + "protocol": module.params["protocol"], + "port": module.params["port"], + "redeploy": module.params["redeploy"] + } + + api = Scaleway(module=module) + api.api_path = "containers/v1beta1/regions/%s/containers" % region + + changed, summary = state_strategy[wished_container["state"]](api=api, wished_cn=wished_container) + + module.exit_json(changed=changed, container=summary) + + +def main(): + argument_spec = scaleway_argument_spec() + argument_spec.update(scaleway_waitable_resource_argument_spec()) + argument_spec.update(dict( + state=dict(type='str', default='present', choices=['absent', 'present']), + namespace_id=dict(type='str', required=True), + region=dict(type='str', required=True, choices=SCALEWAY_REGIONS), + name=dict(type='str', required=True), + description=dict(type='str', default=''), + min_scale=dict(type='int'), + max_scale=dict(type='int'), + memory_limit=dict(type='int'), + container_timeout=dict(type='str'), + privacy=dict(type='str', default='public', choices=['public', 'private']), + registry_image=dict(type='str', required=True), + max_concurrency=dict(type='int'), + protocol=dict(type='str', default='http1', choices=['http1', 'h2c']), + port=dict(type='int'), + redeploy=dict(type='bool', default=False), + environment_variables=dict(type='dict', default={}), + secret_environment_variables=dict(type='dict', default={}, no_log=True) + )) + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + ) + + core(module) + + +if __name__ == '__main__': + main() diff --git a/plugins/modules/scaleway_container_info.py b/plugins/modules/scaleway_container_info.py new file mode 100644 index 0000000000..993919c7ee --- /dev/null +++ b/plugins/modules/scaleway_container_info.py @@ -0,0 +1,151 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# Scaleway Serverless container info module +# +# Copyright (c) 2022, Guillaume MARTINEZ +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +DOCUMENTATION = ''' +--- +module: scaleway_container_info +short_description: Retrieve information on Scaleway Container +version_added: 6.0.0 +author: Guillaume MARTINEZ (@Lunik) +description: + - This module return information about a container on Scaleway account. +extends_documentation_fragment: + - community.general.scaleway + + +options: + namespace_id: + type: str + description: + - Container namespace identifier. + required: true + + region: + type: str + description: + - Scaleway region to use (for example C(fr-par)). + required: true + choices: + - fr-par + - nl-ams + - pl-waw + + name: + type: str + description: + - Name of the container. + required: true +''' + +EXAMPLES = ''' +- name: Get a container info + community.general.scaleway_container_info: + namespace_id: '{{ scw_container_namespace }}' + region: fr-par + name: my-awesome-container + register: container_info_task +''' + +RETURN = ''' +container: + description: The container information. + returned: always + type: dict + sample: + cpu_limit: 140 + description: Container used for testing scaleway_container ansible module + domain_name: cnansibletestgfogtjod-cn-ansible-test.functions.fnc.fr-par.scw.cloud + environment_variables: + MY_VAR: my_value + error_message: null + http_option: "" + id: c9070eb0-d7a4-48dd-9af3-4fb139890721 + max_concurrency: 50 + max_scale: 5 + memory_limit: 256 + min_scale: 0 + name: cn-ansible-test + namespace_id: 75e299f1-d1e5-4e6b-bc6e-4fb51cfe1e69 + port: 80 + privacy: public + protocol: http1 + region: fr-par + registry_image: rg.fr-par.scw.cloud/namespace-ansible-ci/nginx:latest + secret_environment_variables: + - key: MY_SECRET_VAR + value: $argon2id$v=19$m=65536,t=1,p=2$tb6UwSPWx/rH5Vyxt9Ujfw$5ZlvaIjWwNDPxD9Rdght3NarJz4IETKjpvAU3mMSmFg + status: created + timeout: 300s +''' + +from ansible_collections.community.general.plugins.module_utils.scaleway import ( + SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway +) +from ansible.module_utils.basic import AnsibleModule + + +def info_strategy(api, wished_cn): + cn_list = api.fetch_all_resources("containers") + cn_lookup = dict((fn["name"], fn) + for fn in cn_list) + + if wished_cn["name"] not in cn_lookup: + msg = "Error during container lookup: Unable to find container named '%s' in namespace '%s'" % (wished_cn["name"], + wished_cn["namespace_id"]) + + api.module.fail_json(msg=msg) + + target_cn = cn_lookup[wished_cn["name"]] + + response = api.get(path=api.api_path + "/%s" % target_cn["id"]) + if not response.ok: + msg = "Error during container lookup: %s: '%s' (%s)" % (response.info['msg'], + response.json['message'], + response.json) + api.module.fail_json(msg=msg) + + return response.json + + +def core(module): + region = module.params["region"] + wished_container = { + "namespace_id": module.params["namespace_id"], + "name": module.params["name"] + } + + api = Scaleway(module=module) + api.api_path = "containers/v1beta1/regions/%s/containers" % region + + summary = info_strategy(api=api, wished_cn=wished_container) + + module.exit_json(changed=False, container=summary) + + +def main(): + argument_spec = scaleway_argument_spec() + argument_spec.update(dict( + namespace_id=dict(type='str', required=True), + region=dict(type='str', required=True, choices=SCALEWAY_REGIONS), + name=dict(type='str', required=True) + )) + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + ) + + core(module) + + +if __name__ == '__main__': + main() diff --git a/tests/integration/targets/scaleway_container/aliases b/tests/integration/targets/scaleway_container/aliases new file mode 100644 index 0000000000..a5ac5181f0 --- /dev/null +++ b/tests/integration/targets/scaleway_container/aliases @@ -0,0 +1,6 @@ +# Copyright (c) 2022, Guillaume MARTINEZ +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +cloud/scaleway +unsupported diff --git a/tests/integration/targets/scaleway_container/defaults/main.yml b/tests/integration/targets/scaleway_container/defaults/main.yml new file mode 100644 index 0000000000..01b8719fc5 --- /dev/null +++ b/tests/integration/targets/scaleway_container/defaults/main.yml @@ -0,0 +1,18 @@ +--- +# Copyright (c) 2022, Guillaume MARTINEZ +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +scaleway_region: fr-par +container_namespace_name: cn-ansible-test +name: cn-ansible-test +description: Container used for testing scaleway_container ansible module +updated_description: Container used for testing scaleway_container ansible module (Updated description) +environment_variables: + MY_VAR: my_value +secret_environment_variables: + MY_SECRET_VAR: my_secret_value +updated_secret_environment_variables: + MY_SECRET_VAR: my_other_secret_value +image: rg.fr-par.scw.cloud/namespace-ansible-ci/nginx:latest +port: 80 diff --git a/tests/integration/targets/scaleway_container/tasks/main.yml b/tests/integration/targets/scaleway_container/tasks/main.yml new file mode 100644 index 0000000000..1ac5bf1768 --- /dev/null +++ b/tests/integration/targets/scaleway_container/tasks/main.yml @@ -0,0 +1,290 @@ +--- +#################################################################### +# WARNING: These are designed specifically for Ansible tests # +# and should not be used as examples of how to write Ansible roles # +#################################################################### + +# Copyright (c) 2022, Guillaume MARTINEZ +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +- name: Create container_namespace + community.general.scaleway_container_namespace: + state: present + name: '{{ container_namespace_name }}' + region: '{{ scaleway_region }}' + project_id: '{{ scw_project }}' + description: '{{ description }}' + register: integration_container_namespace + +- name: Create a container (Check) + check_mode: yes + community.general.scaleway_container: + state: present + name: '{{ name }}' + region: '{{ scaleway_region }}' + namespace_id: '{{ integration_container_namespace.container_namespace.id }}' + registry_image: '{{ image }}' + description: '{{ description }}' + environment_variables: '{{ environment_variables }}' + secret_environment_variables: '{{ secret_environment_variables }}' + port: '{{ port }}' + register: cn_creation_check_task + +- ansible.builtin.debug: + var: cn_creation_check_task + +- name: Check module call result + ansible.builtin.assert: + that: + - cn_creation_check_task is success + - cn_creation_check_task is changed + +- name: Create container + community.general.scaleway_container: + state: present + name: '{{ name }}' + region: '{{ scaleway_region }}' + namespace_id: '{{ integration_container_namespace.container_namespace.id }}' + registry_image: '{{ image }}' + description: '{{ description }}' + environment_variables: '{{ environment_variables }}' + secret_environment_variables: '{{ secret_environment_variables }}' + port: '{{ port }}' + register: cn_creation_task + +- ansible.builtin.debug: + var: cn_creation_task + +- name: Check module call result + ansible.builtin.assert: + that: + - cn_creation_task is success + - cn_creation_task is changed + - cn_creation_task.container.status in ["created", "ready"] + +- name: Create container (Confirmation) + community.general.scaleway_container: + state: present + name: '{{ name }}' + region: '{{ scaleway_region }}' + namespace_id: '{{ integration_container_namespace.container_namespace.id }}' + registry_image: '{{ image }}' + description: '{{ description }}' + environment_variables: '{{ environment_variables }}' + secret_environment_variables: '{{ secret_environment_variables }}' + port: '{{ port }}' + register: cn_creation_confirmation_task + +- ansible.builtin.debug: + var: cn_creation_confirmation_task + +- name: Check module call result + ansible.builtin.assert: + that: + - cn_creation_confirmation_task is success + - cn_creation_confirmation_task is not changed + - cn_creation_confirmation_task.container.status in ["created", "ready"] + +- name: Update container (Check) + check_mode: yes + community.general.scaleway_container: + state: present + name: '{{ name }}' + region: '{{ scaleway_region }}' + namespace_id: '{{ integration_container_namespace.container_namespace.id }}' + registry_image: '{{ image }}' + description: '{{ updated_description }}' + environment_variables: '{{ environment_variables }}' + secret_environment_variables: '{{ secret_environment_variables }}' + port: '{{ port }}' + register: cn_update_check_task + +- ansible.builtin.debug: + var: cn_update_check_task + +- name: Check module call result + ansible.builtin.assert: + that: + - cn_update_check_task is success + - cn_update_check_task is changed + +- name: Update container + community.general.scaleway_container: + state: present + name: '{{ name }}' + region: '{{ scaleway_region }}' + namespace_id: '{{ integration_container_namespace.container_namespace.id }}' + registry_image: '{{ image }}' + description: '{{ updated_description }}' + environment_variables: '{{ environment_variables }}' + secret_environment_variables: '{{ secret_environment_variables }}' + port: '{{ port }}' + register: cn_update_task + +- ansible.builtin.debug: + var: cn_update_task + +- name: Check module call result + ansible.builtin.assert: + that: + - cn_update_task is success + - cn_update_task is changed + - cn_update_task.container.status in ["created", "ready"] + +- name: Update container (Confirmation) + community.general.scaleway_container: + state: present + name: '{{ name }}' + region: '{{ scaleway_region }}' + namespace_id: '{{ integration_container_namespace.container_namespace.id }}' + registry_image: '{{ image }}' + description: '{{ updated_description }}' + environment_variables: '{{ environment_variables }}' + secret_environment_variables: '{{ secret_environment_variables }}' + port: '{{ port }}' + register: cn_update_confirmation_task + +- ansible.builtin.debug: + var: cn_update_confirmation_task + +- name: Check module call result + ansible.builtin.assert: + that: + - cn_update_confirmation_task is success + - cn_update_confirmation_task is not changed + - cn_update_confirmation_task.container.status in ["created", "ready"] + +- name: Update container secret variables (Check) + check_mode: yes + community.general.scaleway_container: + state: present + name: '{{ name }}' + region: '{{ scaleway_region }}' + namespace_id: '{{ integration_container_namespace.container_namespace.id }}' + registry_image: '{{ image }}' + description: '{{ updated_description }}' + environment_variables: '{{ environment_variables }}' + secret_environment_variables: '{{ updated_secret_environment_variables }}' + port: '{{ port }}' + register: cn_update_secret_check_task + +- ansible.builtin.debug: + var: cn_update_secret_check_task + +- name: Check module call result + ansible.builtin.assert: + that: + - cn_update_secret_check_task is success + - cn_update_secret_check_task is changed + +- name: Update container secret variables + community.general.scaleway_container: + state: present + name: '{{ name }}' + region: '{{ scaleway_region }}' + namespace_id: '{{ integration_container_namespace.container_namespace.id }}' + registry_image: '{{ image }}' + description: '{{ updated_description }}' + environment_variables: '{{ environment_variables }}' + secret_environment_variables: '{{ updated_secret_environment_variables }}' + port: '{{ port }}' + register: cn_update_secret_task + +- ansible.builtin.debug: + var: cn_update_secret_task + +- name: Check module call result + ansible.builtin.assert: + that: + - cn_update_secret_task is success + - cn_update_secret_task is changed + - cn_update_secret_task.container.status in ["created", "ready"] + - "'hashed_value' in cn_update_secret_task.container.secret_environment_variables[0]" + +- name: Update container secret variables (Confirmation) + community.general.scaleway_container: + state: present + name: '{{ name }}' + region: '{{ scaleway_region }}' + namespace_id: '{{ integration_container_namespace.container_namespace.id }}' + registry_image: '{{ image }}' + description: '{{ updated_description }}' + environment_variables: '{{ environment_variables }}' + secret_environment_variables: '{{ updated_secret_environment_variables }}' + port: '{{ port }}' + register: cn_update_secret_confirmation_task + +- ansible.builtin.debug: + var: cn_update_secret_confirmation_task + +- name: Check module call result + ansible.builtin.assert: + that: + - cn_update_secret_confirmation_task is success + - cn_update_secret_confirmation_task is not changed + - cn_update_secret_confirmation_task.container.status == "ready" + - "'hashed_value' in cn_update_secret_confirmation_task.container.secret_environment_variables[0]" + +- name: Delete container (Check) + check_mode: yes + community.general.scaleway_container: + state: absent + name: '{{ name }}' + region: '{{ scaleway_region }}' + description: '{{ description }}' + namespace_id: '{{ integration_container_namespace.container_namespace.id }}' + registry_image: '{{ image }}' + register: cn_deletion_check_task + +- ansible.builtin.debug: + var: cn_deletion_check_task + +- name: Check module call result + ansible.builtin.assert: + that: + - cn_deletion_check_task is success + - cn_deletion_check_task is changed + +- name: Delete container + community.general.scaleway_container: + state: absent + name: '{{ name }}' + region: '{{ scaleway_region }}' + description: '{{ description }}' + namespace_id: '{{ integration_container_namespace.container_namespace.id }}' + registry_image: '{{ image }}' + register: cn_deletion_task + +- name: Check module call result + ansible.builtin.assert: + that: + - cn_deletion_task is success + - cn_deletion_task is changed + +- name: Delete container (Confirmation) + community.general.scaleway_container: + state: absent + name: '{{ name }}' + region: '{{ scaleway_region }}' + description: '{{ description }}' + namespace_id: '{{ integration_container_namespace.container_namespace.id }}' + registry_image: '{{ image }}' + register: cn_deletion_confirmation_task + +- ansible.builtin.debug: + var: cn_deletion_confirmation_task + +- name: Check module call result + ansible.builtin.assert: + that: + - cn_deletion_confirmation_task is success + - cn_deletion_confirmation_task is not changed + +- name: Delete container namespace + community.general.scaleway_container_namespace: + state: absent + name: '{{ container_namespace_name }}' + region: '{{ scaleway_region }}' + description: '{{ description }}' + project_id: '{{ scw_project }}' diff --git a/tests/integration/targets/scaleway_container_info/aliases b/tests/integration/targets/scaleway_container_info/aliases new file mode 100644 index 0000000000..a5ac5181f0 --- /dev/null +++ b/tests/integration/targets/scaleway_container_info/aliases @@ -0,0 +1,6 @@ +# Copyright (c) 2022, Guillaume MARTINEZ +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +cloud/scaleway +unsupported diff --git a/tests/integration/targets/scaleway_container_info/defaults/main.yml b/tests/integration/targets/scaleway_container_info/defaults/main.yml new file mode 100644 index 0000000000..f3dadf71a8 --- /dev/null +++ b/tests/integration/targets/scaleway_container_info/defaults/main.yml @@ -0,0 +1,16 @@ +--- +# Copyright (c) 2022, Guillaume MARTINEZ +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +scaleway_region: fr-par +container_namespace_name: cn-ansible-test +name: cn-ansible-test +description: Container used for testing scaleway_container_info ansible module +updated_description: Container used for testing scaleway_container_info ansible module (Updated description) +environment_variables: + MY_VAR: my_value +secret_environment_variables: + MY_SECRET_VAR: my_secret_value +image: rg.fr-par.scw.cloud/namespace-ansible-ci/nginx:latest +port: 80 diff --git a/tests/integration/targets/scaleway_container_info/tasks/main.yml b/tests/integration/targets/scaleway_container_info/tasks/main.yml new file mode 100644 index 0000000000..9f9fe401ca --- /dev/null +++ b/tests/integration/targets/scaleway_container_info/tasks/main.yml @@ -0,0 +1,63 @@ +--- +#################################################################### +# WARNING: These are designed specifically for Ansible tests # +# and should not be used as examples of how to write Ansible roles # +#################################################################### + +# Copyright (c) 2022, Guillaume MARTINEZ +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +- name: Create container_namespace + community.general.scaleway_container_namespace: + state: present + name: '{{ container_namespace_name }}' + region: '{{ scaleway_region }}' + project_id: '{{ scw_project }}' + description: '{{ description }}' + register: integration_container_namespace + +- name: Create container + community.general.scaleway_container: + state: present + name: '{{ name }}' + region: '{{ scaleway_region }}' + namespace_id: '{{ integration_container_namespace.container_namespace.id }}' + registry_image: '{{ image }}' + description: '{{ description }}' + environment_variables: '{{ environment_variables }}' + secret_environment_variables: '{{ secret_environment_variables }}' + port: '{{ port }}' + +- name: Get container info + community.general.scaleway_container_info: + name: '{{ name }}' + region: '{{ scaleway_region }}' + namespace_id: '{{ integration_container_namespace.container_namespace.id }}' + register: cn_info_task + +- ansible.builtin.debug: + var: cn_info_task + +- name: Check module call result + ansible.builtin.assert: + that: + - cn_info_task is success + - cn_info_task is not changed + +- name: Delete container + community.general.scaleway_container: + state: absent + name: '{{ name }}' + region: '{{ scaleway_region }}' + description: '{{ description }}' + namespace_id: '{{ integration_container_namespace.container_namespace.id }}' + registry_image: '{{ image }}' + +- name: Delete container namespace + community.general.scaleway_container_namespace: + state: absent + name: '{{ container_namespace_name }}' + region: '{{ scaleway_region }}' + description: '{{ description }}' + project_id: '{{ scw_project }}' From 16cd2ae76eed3786e4f3346093e10f62671350e5 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Mon, 7 Nov 2022 21:33:42 +0100 Subject: [PATCH 0023/1810] Next expected release will be 6.1.0. --- changelogs/changelog.yaml | 519 +----------------- changelogs/fragments/4728-onepassword-v2.yml | 2 - .../fragments/5435-escape-ldap-param.yml | 2 - .../5450-allow-for-xordered-dns.yaml | 2 - .../5468-iso-create-not-add-folders.yml | 2 - .../5475-snap-option-value-whitespace.yml | 2 - ...5477-ansible-galaxy-install-cmd-runner.yml | 2 - .../fragments/5483-hponcfg-cmd-runner.yml | 2 - .../fragments/5484-mksysb-cmd-runner.yml | 2 - .../fragments/5485-cpanm-cmd-runner.yml | 2 - changelogs/fragments/6.0.0.yml | 3 - galaxy.yml | 2 +- 12 files changed, 3 insertions(+), 539 deletions(-) delete mode 100644 changelogs/fragments/4728-onepassword-v2.yml delete mode 100644 changelogs/fragments/5435-escape-ldap-param.yml delete mode 100644 changelogs/fragments/5450-allow-for-xordered-dns.yaml delete mode 100644 changelogs/fragments/5468-iso-create-not-add-folders.yml delete mode 100644 changelogs/fragments/5475-snap-option-value-whitespace.yml delete mode 100644 changelogs/fragments/5477-ansible-galaxy-install-cmd-runner.yml delete mode 100644 changelogs/fragments/5483-hponcfg-cmd-runner.yml delete mode 100644 changelogs/fragments/5484-mksysb-cmd-runner.yml delete mode 100644 changelogs/fragments/5485-cpanm-cmd-runner.yml delete mode 100644 changelogs/fragments/6.0.0.yml diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index b5612b7ccc..28411f7413 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -1,517 +1,2 @@ -ancestor: 5.0.0 -releases: - 6.0.0-a1: - changes: - breaking_changes: - - newrelic_deployment - ``revision`` is required for v2 API (https://github.com/ansible-collections/community.general/pull/5341). - bugfixes: - - Include ``PSF-license.txt`` file for ``plugins/module_utils/_mount.py``. - - Include ``simplified_bsd.txt`` license file for various module utils, the - ``lxca_common`` docs fragment, and the ``utm_utils`` unit tests. - - alternatives - do not set the priority if the priority was not set by the - user (https://github.com/ansible-collections/community.general/pull/4810). - - alternatives - only pass subcommands when they are specified as module arguments - (https://github.com/ansible-collections/community.general/issues/4803, https://github.com/ansible-collections/community.general/issues/4804, - https://github.com/ansible-collections/community.general/pull/4836). - - alternatives - when ``subcommands`` is specified, ``link`` must be given for - every subcommand. This was already mentioned in the documentation, but not - enforced by the code (https://github.com/ansible-collections/community.general/pull/4836). - - apache2_mod_proxy - avoid crash when reporting inability to parse balancer_member_page - HTML caused by using an undefined variable in the error message (https://github.com/ansible-collections/community.general/pull/5111). - - archive - avoid crash when ``lzma`` is not present and ``format`` is not ``xz`` - (https://github.com/ansible-collections/community.general/pull/5393). - - cmd_runner module utils - fix bug caused by using the ``command`` variable - instead of ``self.command`` when looking for binary path (https://github.com/ansible-collections/community.general/pull/4903). - - consul - fixed bug introduced in PR 4590 (https://github.com/ansible-collections/community.general/issues/4680). - - credstash lookup plugin - pass plugin options to credstash for all terms, - not just for the first (https://github.com/ansible-collections/community.general/pull/5440). - - dig lookup plugin - add option to return empty result without empty strings, - and return empty list instead of ``NXDOMAIN`` (https://github.com/ansible-collections/community.general/pull/5439, - https://github.com/ansible-collections/community.general/issues/5428). - - dig lookup plugin - fix evaluation of falsy values for boolean parameters - ``fail_on_error`` and ``retry_servfail`` (https://github.com/ansible-collections/community.general/pull/5129). - - dnsimple_info - correctly report missing library as ``requests`` and not ``another_library`` - (https://github.com/ansible-collections/community.general/pull/5111). - - dnstxt lookup plugin - add option to return empty result without empty strings, - and return empty list instead of ``NXDOMAIN`` (https://github.com/ansible-collections/community.general/pull/5457, - https://github.com/ansible-collections/community.general/issues/5428). - - dsv lookup plugin - do not ignore the ``tld`` parameter (https://github.com/ansible-collections/community.general/pull/4911). - - filesystem - handle ``fatresize --info`` output lines without ``:`` (https://github.com/ansible-collections/community.general/pull/4700). - - filesystem - improve error messages when output cannot be parsed by including - newlines in escaped form (https://github.com/ansible-collections/community.general/pull/4700). - - funcd connection plugin - fix signature of ``exec_command`` (https://github.com/ansible-collections/community.general/pull/5111). - - ini_file - minor refactor fixing a python lint error (https://github.com/ansible-collections/community.general/pull/5307). - - keycloak_realm - fix default groups and roles (https://github.com/ansible-collections/community.general/issues/4241). - - keyring_info - fix the result from the keyring library never getting returned - (https://github.com/ansible-collections/community.general/pull/4964). - - ldap_attrs - fix ordering issue by ignoring the ``{x}`` prefix on attribute - values (https://github.com/ansible-collections/community.general/issues/977, - https://github.com/ansible-collections/community.general/pull/5385). - - listen_ports_facts - removed leftover ``EnvironmentError`` . The ``else`` - clause had a wrong indentation. The check is now handled in the ``split_pid_name`` - function (https://github.com/ansible-collections/community.general/pull/5202). - - locale_gen - fix support for Ubuntu (https://github.com/ansible-collections/community.general/issues/5281). - - lxc_container - the module has been updated to support Python 3 (https://github.com/ansible-collections/community.general/pull/5304). - - lxd connection plugin - fix incorrect ``inventory_hostname`` in ``remote_addr``. - This is needed for compatibility with ansible-core 2.13 (https://github.com/ansible-collections/community.general/issues/4886). - - manageiq_alert_profiles - avoid crash when reporting unknown profile caused - by trying to return an undefined variable (https://github.com/ansible-collections/community.general/pull/5111). - - nmcli - avoid changed status for most cases with VPN connections (https://github.com/ansible-collections/community.general/pull/5126). - - nmcli - fix error caused by adding undefined module arguments for list options - (https://github.com/ansible-collections/community.general/issues/4373, https://github.com/ansible-collections/community.general/pull/4813). - - 'nmcli - fix error when setting previously unset MAC address, ``gsm.apn`` - or ``vpn.data``: current values were being normalized without checking if - they might be ``None`` (https://github.com/ansible-collections/community.general/pull/5291).' - - nmcli - fix int options idempotence (https://github.com/ansible-collections/community.general/issues/4998). - - nsupdate - compatibility with NS records (https://github.com/ansible-collections/community.general/pull/5112). - - nsupdate - fix silent failures when updating ``NS`` entries from Bind9 managed - DNS zones (https://github.com/ansible-collections/community.general/issues/4657). - - opentelemetry callback plugin - support opentelemetry-api 1.13.0 that removed - support for ``_time_ns`` (https://github.com/ansible-collections/community.general/pull/5342). - - osx_defaults - no longer expand ``~`` in ``value`` to the user's home directory, - or expand environment variables (https://github.com/ansible-collections/community.general/issues/5234, - https://github.com/ansible-collections/community.general/pull/5243). - - packet_ip_subnet - fix error reporting in case of invalid CIDR prefix lengths - (https://github.com/ansible-collections/community.general/pull/5111). - - pacman - fixed name resolution of URL packages (https://github.com/ansible-collections/community.general/pull/4959). - - passwordstore lookup plugin - fix ``returnall`` for gopass (https://github.com/ansible-collections/community.general/pull/5027). - - passwordstore lookup plugin - fix password store path detection for gopass - (https://github.com/ansible-collections/community.general/pull/4955). - - pfexec become plugin - remove superflous quotes preventing exe wrap from working - as expected (https://github.com/ansible-collections/community.general/issues/3671, - https://github.com/ansible-collections/community.general/pull/3889). - - pip_package_info - remove usage of global variable (https://github.com/ansible-collections/community.general/pull/5111). - - pkgng - fix case when ``pkg`` fails when trying to upgrade all packages (https://github.com/ansible-collections/community.general/issues/5363). - - proxmox - fix error handling when getting VM by name when ``state=absent`` - (https://github.com/ansible-collections/community.general/pull/4945). - - proxmox inventory plugin - fix crash when ``enabled=1`` is used in agent config - string (https://github.com/ansible-collections/community.general/pull/4910). - - proxmox inventory plugin - fixed extended status detection for qemu (https://github.com/ansible-collections/community.general/pull/4816). - - proxmox_kvm - fix ``agent`` parameter when boolean value is specified (https://github.com/ansible-collections/community.general/pull/5198). - - proxmox_kvm - fix error handling when getting VM by name when ``state=absent`` - (https://github.com/ansible-collections/community.general/pull/4945). - - proxmox_kvm - fix exception when no ``agent`` argument is specified (https://github.com/ansible-collections/community.general/pull/5194). - - proxmox_kvm - fix wrong condition (https://github.com/ansible-collections/community.general/pull/5108). - - proxmox_kvm - replace new condition with proper condition to allow for using - ``vmid`` on update (https://github.com/ansible-collections/community.general/pull/5206). - - rax_clb_nodes - fix code to be compatible with Python 3 (https://github.com/ansible-collections/community.general/pull/4933). - - redfish_command - fix the check if a virtual media is unmounted to just check - for ``instered= false`` caused by Supermicro hardware that does not clear - the ``ImageName`` (https://github.com/ansible-collections/community.general/pull/4839). - - redfish_command - the Supermicro Redfish implementation only supports the - ``image_url`` parameter in the underlying API calls to ``VirtualMediaInsert`` - and ``VirtualMediaEject``. Any values set (or the defaults) for ``write_protected`` - or ``inserted`` will be ignored (https://github.com/ansible-collections/community.general/pull/4839). - - redfish_info - fix to ``GetChassisPower`` to correctly report power information - when multiple chassis exist, but not all chassis report power information - (https://github.com/ansible-collections/community.general/issues/4901). - - redfish_utils module utils - centralize payload checking when performing modification - requests to a Redfish service (https://github.com/ansible-collections/community.general/issues/5210/). - - redhat_subscription - fix unsubscribing on RHEL 9 (https://github.com/ansible-collections/community.general/issues/4741). - - redhat_subscription - make module idempotent when ``pool_ids`` are used (https://github.com/ansible-collections/community.general/issues/5313). - - redis* modules - fix call to ``module.fail_json`` when failing because of - missing Python libraries (https://github.com/ansible-collections/community.general/pull/4733). - - slack - fix incorrect channel prefix ``#`` caused by incomplete pattern detection - by adding ``G0`` and ``GF`` as channel ID patterns (https://github.com/ansible-collections/community.general/pull/5019). - - slack - fix message update for channels which start with ``CP``. When ``message-id`` - was passed it failed for channels which started with ``CP`` because the ``#`` - symbol was added before the ``channel_id`` (https://github.com/ansible-collections/community.general/pull/5249). - - sudoers - ensure sudoers config files are created with the permissions requested - by sudoers (0440) (https://github.com/ansible-collections/community.general/pull/4814). - - 'sudoers - fix incorrect handling of ``state: absent`` (https://github.com/ansible-collections/community.general/issues/4852).' - - tss lookup plugin - adding support for updated Delinea library (https://github.com/DelineaXPM/python-tss-sdk/issues/9, - https://github.com/ansible-collections/community.general/pull/5151). - - virtualbox inventory plugin - skip parsing values with keys that have both - a value and nested data. Skip parsing values that are nested more than two - keys deep (https://github.com/ansible-collections/community.general/issues/5332, - https://github.com/ansible-collections/community.general/pull/5348). - - xcc_redfish_command - for compatibility due to Redfish spec changes the virtualMedia - resource location changed from Manager to System (https://github.com/ansible-collections/community.general/pull/4682). - - xenserver_facts - fix broken ``AnsibleModule`` call that prevented the module - from working at all (https://github.com/ansible-collections/community.general/pull/5383). - - xfconf - fix setting of boolean values (https://github.com/ansible-collections/community.general/issues/4999, - https://github.com/ansible-collections/community.general/pull/5007). - - zfs - fix wrong quoting of properties (https://github.com/ansible-collections/community.general/issues/4707, - https://github.com/ansible-collections/community.general/pull/4726). - deprecated_features: - - ArgFormat module utils - deprecated along ``CmdMixin``, in favor of the ``cmd_runner_fmt`` - module util (https://github.com/ansible-collections/community.general/pull/5370). - - CmdMixin module utils - deprecated in favor of the ``CmdRunner`` module util - (https://github.com/ansible-collections/community.general/pull/5370). - - CmdModuleHelper module utils - deprecated in favor of the ``CmdRunner`` module - util (https://github.com/ansible-collections/community.general/pull/5370). - - CmdStateModuleHelper module utils - deprecated in favor of the ``CmdRunner`` - module util (https://github.com/ansible-collections/community.general/pull/5370). - - cmd_runner module utils - deprecated ``fmt`` in favour of ``cmd_runner_fmt`` - as the parameter format object (https://github.com/ansible-collections/community.general/pull/4777). - - django_manage - support for Django releases older than 4.1 has been deprecated - and will be removed in community.general 9.0.0 (https://github.com/ansible-collections/community.general/pull/5400). - - django_manage - support for the commands ``cleanup``, ``syncdb`` and ``validate`` - that have been deprecated in Django long time ago will be removed in community.general - 9.0.0 (https://github.com/ansible-collections/community.general/pull/5400). - - django_manage - the behavior of "creating the virtual environment when missing" - is being deprecated and will be removed in community.general version 9.0.0 - (https://github.com/ansible-collections/community.general/pull/5405). - - gconftool2 - deprecates ``state=get`` in favor of using the module ``gconftool2_info`` - (https://github.com/ansible-collections/community.general/pull/4778). - - lxc_container - the module will no longer make any effort to support Python - 2 (https://github.com/ansible-collections/community.general/pull/5304). - - newrelic_deployment - ``appname`` and ``environment`` are no longer valid - options in the v2 API. They will be removed in community.general 7.0.0 (https://github.com/ansible-collections/community.general/pull/5341). - - proxmox - deprecated the current ``unprivileged`` default value, will be changed - to ``true`` in community.general 7.0.0 (https://github.com/pull/5224). - - xfconf - deprecated parameter ``disable_facts``, as since version 4.0.0 it - only allows value ``true`` (https://github.com/ansible-collections/community.general/pull/4520). - major_changes: - - The internal structure of the collection was changed for modules and action - plugins. These no longer live in a directory hierarchy ordered by topic, but - instead are now all in a single (flat) directory. This has no impact on users - *assuming they did not use internal FQCNs*. These will still work, but result - in deprecation warnings. They were never officially supported and thus the - redirects are kept as a courtsey, and this is not labelled as a breaking change. - Note that for example the Ansible VScode plugin started recommending these - internal names. If you followed its recommendation, you will now have to change - back to the short names to avoid deprecation warnings, and potential errors - in the future as these redirects will be removed in community.general 9.0.0 - (https://github.com/ansible-collections/community.general/pull/5461). - - newrelic_deployment - removed New Relic v1 API, added support for v2 API (https://github.com/ansible-collections/community.general/pull/5341). - minor_changes: - - Added MIT license as ``LICENSES/MIT.txt`` for tests/unit/plugins/modules/packaging/language/test_gem.py - (https://github.com/ansible-collections/community.general/pull/5065). - - All software licenses are now in the ``LICENSES/`` directory of the collection - root (https://github.com/ansible-collections/community.general/pull/5065, - https://github.com/ansible-collections/community.general/pull/5079, https://github.com/ansible-collections/community.general/pull/5080, - https://github.com/ansible-collections/community.general/pull/5083, https://github.com/ansible-collections/community.general/pull/5087, - https://github.com/ansible-collections/community.general/pull/5095, https://github.com/ansible-collections/community.general/pull/5098, - https://github.com/ansible-collections/community.general/pull/5106). - - ModuleHelper module utils - added property ``verbosity`` to base class (https://github.com/ansible-collections/community.general/pull/5035). - - ModuleHelper module utils - improved ``ModuleHelperException``, using ``to_native()`` - for the exception message (https://github.com/ansible-collections/community.general/pull/4755). - - The collection repository conforms to the `REUSE specification `__ - except for the changelog fragments (https://github.com/ansible-collections/community.general/pull/5138). - - ali_instance - minor refactor when checking for installed dependency (https://github.com/ansible-collections/community.general/pull/5240). - - ali_instance_info - minor refactor when checking for installed dependency - (https://github.com/ansible-collections/community.general/pull/5240). - - alternatives - add ``state=absent`` to be able to remove an alternative (https://github.com/ansible-collections/community.general/pull/4654). - - alternatives - add ``subcommands`` parameter (https://github.com/ansible-collections/community.general/pull/4654). - - ansible_galaxy_install - minor refactoring using latest ``ModuleHelper`` updates - (https://github.com/ansible-collections/community.general/pull/4752). - - apk - add ``world`` parameter for supporting a custom world file (https://github.com/ansible-collections/community.general/pull/4976). - - bitwarden lookup plugin - add option ``search`` to search for other attributes - than name (https://github.com/ansible-collections/community.general/pull/5297). - - cartesian lookup plugin - start using Ansible's configuration manager to parse - options (https://github.com/ansible-collections/community.general/pull/5440). - - cmd_runner module util - added parameters ``check_mode_skip`` and ``check_mode_return`` - to ``CmdRunner.context()``, so that the command is not executed when ``check_mode=True`` - (https://github.com/ansible-collections/community.general/pull/4736). - - cmd_runner module utils - add ``__call__`` method to invoke context (https://github.com/ansible-collections/community.general/pull/4791). - - consul - adds ``ttl`` parameter for session (https://github.com/ansible-collections/community.general/pull/4996). - - consul - minor refactoring (https://github.com/ansible-collections/community.general/pull/5367). - - consul_session - adds ``token`` parameter for session (https://github.com/ansible-collections/community.general/pull/5193). - - cpanm - using ``do_raise()`` to raise exceptions in ``ModuleHelper`` derived - modules (https://github.com/ansible-collections/community.general/pull/4674). - - credstash lookup plugin - start using Ansible's configuration manager to parse - options (https://github.com/ansible-collections/community.general/pull/5440). - - dependent lookup plugin - start using Ansible's configuration manager to parse - options (https://github.com/ansible-collections/community.general/pull/5440). - - dig lookup plugin - add option ``fail_on_error`` to allow stopping execution - on lookup failures (https://github.com/ansible-collections/community.general/pull/4973). - - dig lookup plugin - start using Ansible's configuration manager to parse options. - All documented options can now also be passed as lookup parameters (https://github.com/ansible-collections/community.general/pull/5440). - - dnstxt lookup plugin - start using Ansible's configuration manager to parse - options (https://github.com/ansible-collections/community.general/pull/5440). - - filetree lookup plugin - start using Ansible's configuration manager to parse - options (https://github.com/ansible-collections/community.general/pull/5440). - - flattened lookup plugin - start using Ansible's configuration manager to parse - options (https://github.com/ansible-collections/community.general/pull/5440). - - gitlab module util - minor refactor when checking for installed dependency - (https://github.com/ansible-collections/community.general/pull/5259). - - gitlab_branch - minor refactor when checking for installed dependency (https://github.com/ansible-collections/community.general/pull/5259). - - gitlab_deploy_key - minor refactor when checking for installed dependency - (https://github.com/ansible-collections/community.general/pull/5259). - - gitlab_group - minor refactor when checking for installed dependency (https://github.com/ansible-collections/community.general/pull/5259). - - gitlab_group_members - minor refactor when checking for installed dependency - (https://github.com/ansible-collections/community.general/pull/5259). - - gitlab_group_variable - minor refactor when checking for installed dependency - (https://github.com/ansible-collections/community.general/pull/5259). - - gitlab_hook - minor refactor when checking for installed dependency (https://github.com/ansible-collections/community.general/pull/5259). - - gitlab_hook - minor refactoring (https://github.com/ansible-collections/community.general/pull/5271). - - gitlab_project - minor refactor when checking for installed dependency (https://github.com/ansible-collections/community.general/pull/5259). - - gitlab_project_members - minor refactor when checking for installed dependency - (https://github.com/ansible-collections/community.general/pull/5259). - - gitlab_project_variable - minor refactor when checking for installed dependency - (https://github.com/ansible-collections/community.general/pull/5259). - - gitlab_protected_branch - minor refactor when checking for installed dependency - (https://github.com/ansible-collections/community.general/pull/5259). - - gitlab_runner - minor refactor when checking for installed dependency (https://github.com/ansible-collections/community.general/pull/5259). - - gitlab_user - minor refactor when checking for installed dependency (https://github.com/ansible-collections/community.general/pull/5259). - - hiera lookup plugin - start using Ansible's configuration manager to parse - options. The Hiera executable and config file can now also be passed as lookup - parameters (https://github.com/ansible-collections/community.general/pull/5440). - - homebrew, homebrew_tap - added Homebrew on Linux path to defaults (https://github.com/ansible-collections/community.general/pull/5241). - - keycloak_* modules - add ``http_agent`` parameter with default value ``Ansible`` - (https://github.com/ansible-collections/community.general/issues/5023). - - keyring lookup plugin - start using Ansible's configuration manager to parse - options (https://github.com/ansible-collections/community.general/pull/5440). - - lastpass - use config manager for handling plugin options (https://github.com/ansible-collections/community.general/pull/5022). - - linode inventory plugin - simplify option handling (https://github.com/ansible-collections/community.general/pull/5438). - - listen_ports_facts - add new ``include_non_listening`` option which adds ``-a`` - option to ``netstat`` and ``ss``. This shows both listening and non-listening - (for TCP this means established connections) sockets, and returns ``state`` - and ``foreign_address`` (https://github.com/ansible-collections/community.general/issues/4762, - https://github.com/ansible-collections/community.general/pull/4953). - - lmdb_kv lookup plugin - start using Ansible's configuration manager to parse - options (https://github.com/ansible-collections/community.general/pull/5440). - - lxc_container - minor refactoring (https://github.com/ansible-collections/community.general/pull/5358). - - machinectl become plugin - can now be used with a password from another user - than root, if a polkit rule is present (https://github.com/ansible-collections/community.general/pull/4849). - - machinectl become plugin - combine the success command when building the become - command to be consistent with other become plugins (https://github.com/ansible-collections/community.general/pull/5287). - - manifold lookup plugin - start using Ansible's configuration manager to parse - options (https://github.com/ansible-collections/community.general/pull/5440). - - maven_artifact - add a new ``unredirected_headers`` option that can be used - with ansible-core 2.12 and above. The default value is to not use ``Authorization`` - and ``Cookie`` headers on redirects for security reasons. With ansible-core - 2.11, all headers are still passed on for redirects (https://github.com/ansible-collections/community.general/pull/4812). - - mksysb - using ``do_raise()`` to raise exceptions in ``ModuleHelper`` derived - modules (https://github.com/ansible-collections/community.general/pull/4674). - - nagios - minor refactoring on parameter validation for different actions (https://github.com/ansible-collections/community.general/pull/5239). - - netcup_dnsapi - add ``timeout`` parameter (https://github.com/ansible-collections/community.general/pull/5301). - - nmcli - add ``transport_mode`` configuration for Infiniband devices (https://github.com/ansible-collections/community.general/pull/5361). - - nmcli - add bond option ``xmit_hash_policy`` to bond options (https://github.com/ansible-collections/community.general/issues/5148). - - nmcli - adds ``vpn`` type and parameter for supporting VPN with service type - L2TP and PPTP (https://github.com/ansible-collections/community.general/pull/4746). - - nmcli - honor IP options for VPNs (https://github.com/ansible-collections/community.general/pull/5228). - - opentelemetry callback plugin - allow configuring opentelementry callback - via config file (https://github.com/ansible-collections/community.general/pull/4916). - - opentelemetry callback plugin - send logs. This can be disabled by setting - ``disable_logs=false`` (https://github.com/ansible-collections/community.general/pull/4175). - - pacman - added parameters ``reason`` and ``reason_for`` to set/change the - install reason of packages (https://github.com/ansible-collections/community.general/pull/4956). - - passwordstore lookup plugin - allow options to be passed lookup options instead - of being part of the term strings (https://github.com/ansible-collections/community.general/pull/5444). - - passwordstore lookup plugin - allow using alternative password managers by - detecting wrapper scripts, allow explicit configuration of pass and gopass - backends (https://github.com/ansible-collections/community.general/issues/4766). - - passwordstore lookup plugin - improve error messages to include stderr (https://github.com/ansible-collections/community.general/pull/5436) - - pipx - added state ``latest`` to the module (https://github.com/ansible-collections/community.general/pull/5105). - - pipx - changed implementation to use ``cmd_runner`` (https://github.com/ansible-collections/community.general/pull/5085). - - pipx - module fails faster when ``name`` is missing for states ``upgrade`` - and ``reinstall`` (https://github.com/ansible-collections/community.general/pull/5100). - - pipx - using ``do_raise()`` to raise exceptions in ``ModuleHelper`` derived - modules (https://github.com/ansible-collections/community.general/pull/4674). - - pipx module utils - created new module util ``pipx`` providing a ``cmd_runner`` - specific for the ``pipx`` module (https://github.com/ansible-collections/community.general/pull/5085). - - portage - add knobs for Portage's ``--backtrack`` and ``--with-bdeps`` options - (https://github.com/ansible-collections/community.general/pull/5349). - - portage - use Portage's python module instead of calling gentoolkit-provided - program in shell (https://github.com/ansible-collections/community.general/pull/5349). - - proxmox inventory plugin - added new flag ``qemu_extended_statuses`` and new - groups ``prelaunch``, ``paused``. They will be - populated only when ``want_facts=true``, ``qemu_extended_statuses=true`` and - only for ``QEMU`` machines (https://github.com/ansible-collections/community.general/pull/4723). - - proxmox inventory plugin - simplify option handling code (https://github.com/ansible-collections/community.general/pull/5437). - - proxmox module utils, the proxmox* modules - add ``api_task_ok`` helper to - standardize API task status checks across all proxmox modules (https://github.com/ansible-collections/community.general/pull/5274). - - proxmox_kvm - allow ``agent`` argument to be a string (https://github.com/ansible-collections/community.general/pull/5107). - - proxmox_snap - add ``unbind`` param to support snapshotting containers with - configured mountpoints (https://github.com/ansible-collections/community.general/pull/5274). - - puppet - adds ``confdir`` parameter to configure a custom confir location - (https://github.com/ansible-collections/community.general/pull/4740). - - redfish - added new command GetVirtualMedia, VirtualMediaInsert and VirtualMediaEject - to Systems category due to Redfish spec changes the virtualMedia resource - location from Manager to System (https://github.com/ansible-collections/community.general/pull/5124). - - redfish_config - add ``SetSessionService`` to set default session timeout - policy (https://github.com/ansible-collections/community.general/issues/5008). - - redfish_info - add ``GetManagerInventory`` to report list of Manager inventory - information (https://github.com/ansible-collections/community.general/issues/4899). - - seport - added new argument ``local`` (https://github.com/ansible-collections/community.general/pull/5203) - - snap - using ``do_raise()`` to raise exceptions in ``ModuleHelper`` derived - modules (https://github.com/ansible-collections/community.general/pull/4674). - - sudoers - will attempt to validate the proposed sudoers rule using visudo - if available, optionally skipped, or required (https://github.com/ansible-collections/community.general/pull/4794, - https://github.com/ansible-collections/community.general/issues/4745). - - terraform - adds capability to handle complex variable structures for ``variables`` - parameter in the module. This must be enabled with the new ``complex_vars`` - parameter (https://github.com/ansible-collections/community.general/pull/4797). - - terraform - run ``terraform init`` with ``-no-color`` not to mess up the stdout - of the task (https://github.com/ansible-collections/community.general/pull/5147). - - wdc_redfish_command - add ``IndicatorLedOn`` and ``IndicatorLedOff`` commands - for ``Chassis`` category (https://github.com/ansible-collections/community.general/pull/5059). - - wdc_redfish_command - add ``PowerModeLow`` and ``PowerModeNormal`` commands - for ``Chassis`` category (https://github.com/ansible-collections/community.general/pull/5145). - - xfconf - add ``stdout``, ``stderr`` and ``cmd`` to the module results (https://github.com/ansible-collections/community.general/pull/5037). - - xfconf - changed implementation to use ``cmd_runner`` (https://github.com/ansible-collections/community.general/pull/4776). - - xfconf - use ``do_raise()`` instead of defining custom exception class (https://github.com/ansible-collections/community.general/pull/4975). - - xfconf - using ``do_raise()`` to raise exceptions in ``ModuleHelper`` derived - modules (https://github.com/ansible-collections/community.general/pull/4674). - - xfconf module utils - created new module util ``xfconf`` providing a ``cmd_runner`` - specific for ``xfconf`` modules (https://github.com/ansible-collections/community.general/pull/4776). - - xfconf_info - changed implementation to use ``cmd_runner`` (https://github.com/ansible-collections/community.general/pull/4776). - - xfconf_info - use ``do_raise()`` instead of defining custom exception class - (https://github.com/ansible-collections/community.general/pull/4975). - - znode - possibility to use ZooKeeper ACL authentication (https://github.com/ansible-collections/community.general/pull/5306). - release_summary: This is a pre-release for the upcoming 6.0.0 major release. - The main objective of this pre-release is to make it possible to test the - large stuctural changes by flattening the directory structure. See the corresponding - entry in the changelog for details. - removed_features: - - bitbucket* modules - ``username`` is no longer an alias of ``workspace``, - but of ``user`` (https://github.com/ansible-collections/community.general/pull/5326). - - gem - the default of the ``norc`` option changed from ``false`` to ``true`` - (https://github.com/ansible-collections/community.general/pull/5326). - - gitlab_group_members - ``gitlab_group`` must now always contain the full path, - and no longer just the name or path (https://github.com/ansible-collections/community.general/pull/5326). - - keycloak_authentication - the return value ``flow`` has been removed. Use - ``end_state`` instead (https://github.com/ansible-collections/community.general/pull/5326). - - keycloak_group - the return value ``group`` has been removed. Use ``end_state`` - instead (https://github.com/ansible-collections/community.general/pull/5326). - - lxd_container - the default of the ``ignore_volatile_options`` option changed - from ``true`` to ``false`` (https://github.com/ansible-collections/community.general/pull/5326). - - mail callback plugin - the ``sender`` option is now required (https://github.com/ansible-collections/community.general/pull/5326). - - module_helper module utils - remove the ``VarDict`` attribute from ``ModuleHelper``. - Import ``VarDict`` from ``ansible_collections.community.general.plugins.module_utils.mh.mixins.vars`` - instead (https://github.com/ansible-collections/community.general/pull/5326). - - proxmox inventory plugin - the default of the ``want_proxmox_nodes_ansible_host`` - option changed from ``true`` to ``false`` (https://github.com/ansible-collections/community.general/pull/5326). - - vmadm - the ``debug`` option has been removed. It was not used anyway (https://github.com/ansible-collections/community.general/pull/5326). - fragments: - - 3671-illumos-pfexec.yml - - 4175-opentelemetry_logs.yml - - 4520-xfconf-deprecate-disable-facts.yml - - 4654-alternatives-add-subcommands.yml - - 4674-use-mh-raise.yaml - - 4682-compatibility-virtualmedia-resource-location.yaml - - 4700-code-changes.yml - - 4712-consul-bugfix.yaml - - 4719-fix-keycloak-realm.yaml - - 4724-proxmox-qemu-extend.yaml - - 4726-zfs.yml - - 4733-redis-fail.yml - - 4736-cmd-runner-skip-if-check.yml - - 4740-puppet-feature.yaml - - 4746-add-vpn-support-nmcli.yaml - - 4752-ansible-galaxy-install-mh-updates.yml - - 4755-mhexception-improvement.yml - - 4776-xfconf-cmd-runner.yaml - - 4777-cmd-runner-deprecate-fmt.yaml - - 4778-gconftool2-deprecate-state-get.yaml - - 4780-passwordstore-wrapper-compat.yml - - 4791-cmd-runner-callable.yaml - - 4794-sudoers-validation.yml - - 4797-terraform-complex-variables.yml - - 4809-redhat_subscription-unsubscribe.yaml - - 4810-alternatives-bug.yml - - 4812-expose-unredirected-headers.yml - - 4813-fix-nmcli-convert-list.yaml - - 4814-sudoers-file-permissions.yml - - 4816-proxmox-fix-extended-status.yaml - - 4836-alternatives.yml - - 4839-fix-VirtualMediaInsert-Supermicro.yml - - 4849-add-password-prompt-support-for-machinectl.yml - - 4852-sudoers-state-absent.yml - - 4886-fix-lxd-inventory-hostname.yml - - 4899-add-GetManagerInventory-for-redfish_info.yml - - 4901-fix-redfish-chassispower.yml - - 4903-cmdrunner-bugfix.yaml - - 4910-fix-for-agent-enabled.yml - - 4911-dsv-honor-tld-option.yml - - 4916-opentelemetry-ini-options.yaml - - 4933-fix-rax-clb-nodes.yaml - - 4945-fix-get_vm-int-parse-handling.yaml - - 4953-listen-ports-facts-extend-output.yaml - - 4955-fix-path-detection-for-gopass.yaml - - 4956-pacman-install-reason.yaml - - 4959-pacman-fix-url-packages-name.yaml - - 4964-fix-keyring-info.yml - - 4973-introduce-dig-lookup-argument.yaml - - 4975-xfconf-use-do-raise.yaml - - 4976-apk-add-support-for-a-custom-world-file.yaml - - 4996-consul-session-ttl.yml - - 4998-nmcli-fix-int-options-idempotence.yml - - 4999-xfconf-bool.yml - - 5008-addSetSessionService.yml - - 5019-slack-support-more-groups.yml - - 5022-lastpass-lookup-cleanup.yml - - 5023-http-agent-param-keycloak.yml - - 5027-fix-returnall-for-gopass.yaml - - 5035-mh-base-verbosity.yaml - - 5037-xfconf-add-cmd-output.yaml - - 5059-wdc_redfish_command-indicator-leds.yml - - 5085-pipx-use-cmd-runner.yaml - - 5100-pipx-req-if.yaml - - 5105-pipx-state-latest.yaml - - 5107-proxmox-agent-argument.yaml - - 5108-proxmox-node-name-condition.yml - - 5111-fixes.yml - - 5112-fix-nsupdate-ns-entry.yaml - - 5124-compatibility-virtualmedia-resource-location.yaml - - 5126-nmcli-remove-diffs.yml - - 5129-dig-boolean-params-fix.yml - - 5145-wdc-redfish-enclosure-power-state.yml - - 5147-terraform-init-no-color.yml - - 5149-nmcli-bond-option.yml - - 5151-add-delinea-support-tss-lookup.yml - - 5193-consul-session-token.yaml - - 5194-fix-proxmox-agent-exception.yaml - - 5198-proxmox.yml - - 5202-bugfix-environmentError-wrong-indentation.yaml - - 5203-seport-add-local-argument.yaml - - 5206-proxmox-conditional-vmid.yml - - 5210-redfish_utils-cleanup-of-configuration-logic-and-oem-checks.yaml - - 5224-proxmox-unprivileged-default.yaml - - 5228-nmcli-ip-options.yaml - - 5239-nagios-refactor.yaml - - 5240-unused-imports.yaml - - 5241-homebrew-add-linux-path.yaml - - 5243-osx-defaults-expand-user-flags.yml - - 5249-add-new-channel-prefix.yml - - 5259-gitlab-imports.yaml - - 5271-gitlab_hook-refactor.yaml - - 5274-proxmox-snap-container-with-mountpoints.yml - - 5280-lxc_container-py3.yaml - - 5282-locale_gen.yaml - - 5287-machinectl-become-success.yml - - 5291-fix-nmcli-error-when-setting-unset-mac-address.yaml - - 5297-bitwarden-add-search-field.yml - - 5301-netcup_dnsapi-timeout.yml - - 5306-add-options-for-authentication.yml - - 5307-ini_file-lint.yaml - - 5313-fix-redhat_subscription-idempotency-pool_ids.yml - - 5341-newrelic-v2-api-changes.yml - - 5342-opentelemetry_bug_fix_opentelemetry-api-1.13.yml - - 5348-fix-vbox-deeply-nested-hostvars.yml - - 5349-drop-gentoolkit-more-knobs.yml - - 5358-lxc-container-refactor.yml - - 5361-nmcli-add-infiniband-transport-mode.yaml - - 5367-consul-refactor.yaml - - 5369-pkgng-fix-update-all.yaml - - 5370-mh-cmdmixin-deprecation.yaml - - 5377-nsupdate-ns-records-with-bind.yml - - 5383-xenserver_facts.yml - - 5385-search_s-based-_is_value_present.yaml - - 5393-archive.yml - - 5400-django-manage-deprecations.yml - - 5404-django-manage-venv-deprecation.yml - - 5436-passwordstore-errors.yml - - 5437-proxmox.yml - - 5438-linode.yml - - 5439-dig-return-empty-result.yml - - 5444-passwordstore-options.yml - - 5457-dnstxt-empty.yml - - 6.0.0-a1.yml - - deprecation-removals.yml - - licenses-2.yml - - licenses.yml - - lookup-options.yml - - psf-license.yml - - simplified-bsd-license.yml - - unflatmap.yml - modules: - - description: Scaleway Function namespace management - name: scaleway_function_namespace - namespace: '' - - description: Retrieve information on Scaleway Function namespace - name: scaleway_function_namespace_info - namespace: '' - release_date: '2022-11-02' +ancestor: 6.0.0 +releases: {} diff --git a/changelogs/fragments/4728-onepassword-v2.yml b/changelogs/fragments/4728-onepassword-v2.yml deleted file mode 100644 index fbec3aa60d..0000000000 --- a/changelogs/fragments/4728-onepassword-v2.yml +++ /dev/null @@ -1,2 +0,0 @@ -minor_changes: - - onepassword - support version 2 of the OnePassword CLI (https://github.com/ansible-collections/community.general/pull/4728) diff --git a/changelogs/fragments/5435-escape-ldap-param.yml b/changelogs/fragments/5435-escape-ldap-param.yml deleted file mode 100644 index 3f22f61759..0000000000 --- a/changelogs/fragments/5435-escape-ldap-param.yml +++ /dev/null @@ -1,2 +0,0 @@ -bugfixes: - - ldap_attrs - fix bug which caused a ``Bad search filter`` error. The error was occuring when the ldap attribute value contained special characters such as ``(`` or ``*`` (https://github.com/ansible-collections/community.general/issues/5434, https://github.com/ansible-collections/community.general/pull/5435). diff --git a/changelogs/fragments/5450-allow-for-xordered-dns.yaml b/changelogs/fragments/5450-allow-for-xordered-dns.yaml deleted file mode 100644 index 1bb1d9c761..0000000000 --- a/changelogs/fragments/5450-allow-for-xordered-dns.yaml +++ /dev/null @@ -1,2 +0,0 @@ -minor_changes: - - ldap_attrs - allow for DNs to have ``{x}`` prefix on first RDN (https://github.com/ansible-collections/community.general/issues/977, https://github.com/ansible-collections/community.general/pull/5450). diff --git a/changelogs/fragments/5468-iso-create-not-add-folders.yml b/changelogs/fragments/5468-iso-create-not-add-folders.yml deleted file mode 100644 index 5bbe48f579..0000000000 --- a/changelogs/fragments/5468-iso-create-not-add-folders.yml +++ /dev/null @@ -1,2 +0,0 @@ -bugfixes: - - iso_create - the module somtimes failed to add folders for Joliet and UDF formats (https://github.com/ansible-collections/community.general/issues/5275). diff --git a/changelogs/fragments/5475-snap-option-value-whitespace.yml b/changelogs/fragments/5475-snap-option-value-whitespace.yml deleted file mode 100644 index c41c70da38..0000000000 --- a/changelogs/fragments/5475-snap-option-value-whitespace.yml +++ /dev/null @@ -1,2 +0,0 @@ -bugfixes: - - snap - allow values in the ``options`` parameter to contain whitespaces (https://github.com/ansible-collections/community.general/pull/5475). diff --git a/changelogs/fragments/5477-ansible-galaxy-install-cmd-runner.yml b/changelogs/fragments/5477-ansible-galaxy-install-cmd-runner.yml deleted file mode 100644 index f480456953..0000000000 --- a/changelogs/fragments/5477-ansible-galaxy-install-cmd-runner.yml +++ /dev/null @@ -1,2 +0,0 @@ -minor_changes: - - ansible_galaxy_install - refactored module to use ``CmdRunner`` to execute ``ansible-galaxy`` (https://github.com/ansible-collections/community.general/pull/5477). diff --git a/changelogs/fragments/5483-hponcfg-cmd-runner.yml b/changelogs/fragments/5483-hponcfg-cmd-runner.yml deleted file mode 100644 index 9d6c0eb8a9..0000000000 --- a/changelogs/fragments/5483-hponcfg-cmd-runner.yml +++ /dev/null @@ -1,2 +0,0 @@ -minor_changes: - - hponcfg - refactored module to use ``CmdRunner`` to execute ``hponcfg`` (https://github.com/ansible-collections/community.general/pull/5483). diff --git a/changelogs/fragments/5484-mksysb-cmd-runner.yml b/changelogs/fragments/5484-mksysb-cmd-runner.yml deleted file mode 100644 index 89f4d0dac8..0000000000 --- a/changelogs/fragments/5484-mksysb-cmd-runner.yml +++ /dev/null @@ -1,2 +0,0 @@ -minor_changes: - - mksysb - refactored module to use ``CmdRunner`` to execute ``mksysb`` (https://github.com/ansible-collections/community.general/pull/5484). diff --git a/changelogs/fragments/5485-cpanm-cmd-runner.yml b/changelogs/fragments/5485-cpanm-cmd-runner.yml deleted file mode 100644 index 508f261762..0000000000 --- a/changelogs/fragments/5485-cpanm-cmd-runner.yml +++ /dev/null @@ -1,2 +0,0 @@ -minor_changes: - - cpanm - refactored module to use ``CmdRunner`` to execute ``cpanm`` (https://github.com/ansible-collections/community.general/pull/5485). diff --git a/changelogs/fragments/6.0.0.yml b/changelogs/fragments/6.0.0.yml deleted file mode 100644 index 347d16861c..0000000000 --- a/changelogs/fragments/6.0.0.yml +++ /dev/null @@ -1,3 +0,0 @@ -release_summary: >- - New major release of community.general with lots of bugfixes, new features, some removed deprecated features, and some other breaking changes. - Please check the coresponding sections of the changelog for more details. diff --git a/galaxy.yml b/galaxy.yml index 0a3fe09b6e..1c300da904 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -5,7 +5,7 @@ namespace: community name: general -version: 6.0.0 +version: 6.1.0 readme: README.md authors: - Ansible (https://github.com/ansible) From df9c5d1d356da2612650cbf0adf65f9871c3b4fe Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Mon, 7 Nov 2022 21:51:24 +0100 Subject: [PATCH 0024/1810] Add stable-6 to nightlies. --- .azure-pipelines/azure-pipelines.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.azure-pipelines/azure-pipelines.yml b/.azure-pipelines/azure-pipelines.yml index 52eaf65069..c39a855dd0 100644 --- a/.azure-pipelines/azure-pipelines.yml +++ b/.azure-pipelines/azure-pipelines.yml @@ -29,6 +29,7 @@ schedules: always: true branches: include: + - stable-6 - stable-5 - cron: 0 11 * * 0 displayName: Weekly (old stable branches) From 858eaac50089490e782b9a25754d21524eb7638c Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Wed, 9 Nov 2022 02:03:07 +1300 Subject: [PATCH 0025/1810] minor docs update (#5501) --- plugins/modules/xfconf.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/modules/xfconf.py b/plugins/modules/xfconf.py index aaf80d4db2..c231a47484 100644 --- a/plugins/modules/xfconf.py +++ b/plugins/modules/xfconf.py @@ -16,9 +16,9 @@ author: short_description: Edit XFCE4 Configurations description: - This module allows for the manipulation of Xfce 4 Configuration with the help of - xfconf-query. Please see the xfconf-query(1) man pages for more details. + xfconf-query. Please see the xfconf-query(1) man page for more details. seealso: - - name: C(xfconf-query) man page + - name: xfconf-query(1) man page description: Manual page of the C(xfconf-query) tool at the XFCE documentation site. link: 'https://docs.xfce.org/xfce/xfconf/xfconf-query' @@ -70,7 +70,7 @@ options: default: "present" force_array: description: - - Force array even if only one element + - Force array even if only one element. type: bool default: false aliases: ['array'] From 27827cbea4e752cd73afa85ac09ce91ea7ab8af9 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Tue, 8 Nov 2022 19:06:59 +0000 Subject: [PATCH 0026/1810] Clarification to use underscores instead of dashes in parser name (#5500) * Clarification to use underscores instead of dashes in parser name * Update plugins/filter/jc.py Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein --- plugins/filter/jc.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/filter/jc.py b/plugins/filter/jc.py index 879647a04d..6708f573d3 100644 --- a/plugins/filter/jc.py +++ b/plugins/filter/jc.py @@ -26,6 +26,7 @@ DOCUMENTATION = ''' description: - The correct parser for the input data. - For example C(ifconfig). + - "Note: use underscores instead of dashes (if any) in the parser module name." - See U(https://github.com/kellyjonbrazil/jc#parsers) for the latest list of parsers. type: string required: true From 621fb6a619fce1d45a72dc2b46bdbc3fb64d86d5 Mon Sep 17 00:00:00 2001 From: wh1t3 r4bb1t <16529603+d34d5p4rr0w@users.noreply.github.com> Date: Wed, 9 Nov 2022 00:00:05 +0200 Subject: [PATCH 0027/1810] one_vm: fix for 'NoneType' object has no attribute 'split' in get_vm_labels_and_attributes_dict (#5489) * Fix for 'NoneType' object has no attribute 'split' * Added changelog to fix * Update changelogs/fragments/5489-nonetype-in-get-vm-by-label.yml Co-authored-by: Felix Fontein * Fix line ending in changelog Co-authored-by: Felix Fontein --- changelogs/fragments/5489-nonetype-in-get-vm-by-label.yml | 2 ++ plugins/modules/one_vm.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/5489-nonetype-in-get-vm-by-label.yml diff --git a/changelogs/fragments/5489-nonetype-in-get-vm-by-label.yml b/changelogs/fragments/5489-nonetype-in-get-vm-by-label.yml new file mode 100644 index 0000000000..8b0d92ec40 --- /dev/null +++ b/changelogs/fragments/5489-nonetype-in-get-vm-by-label.yml @@ -0,0 +1,2 @@ +bugfixes: + - one_vm - avoid splitting labels that are ``None`` (https://github.com/ansible-collections/community.general/pull/5489). \ No newline at end of file diff --git a/plugins/modules/one_vm.py b/plugins/modules/one_vm.py index 6bfc793603..7122907d38 100644 --- a/plugins/modules/one_vm.py +++ b/plugins/modules/one_vm.py @@ -970,7 +970,7 @@ def get_vm_labels_and_attributes_dict(client, vm_id): if key != 'LABELS': attrs_dict[key] = value else: - if key is not None: + if key is not None and value is not None: labels_list = value.split(',') return labels_list, attrs_dict From 97b584e2617bcd7437ffc184acccb2e12be45206 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Wed, 9 Nov 2022 19:18:40 +1300 Subject: [PATCH 0028/1810] Short descriptions (batch1) - massive fix on Capitalization and trailing period (#5503) * short_description fix batch 1 * Update plugins/modules/ali_instance.py Co-authored-by: Felix Fontein * Update plugins/modules/apt_rpm.py Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein --- plugins/modules/ali_instance.py | 2 +- plugins/modules/ali_instance_info.py | 2 +- plugins/modules/apache2_module.py | 2 +- plugins/modules/apt_rpm.py | 2 +- plugins/modules/beadm.py | 2 +- plugins/modules/circonus_annotation.py | 2 +- plugins/modules/clc_aa_policy.py | 2 +- plugins/modules/clc_alert_policy.py | 2 +- plugins/modules/clc_blueprint_package.py | 2 +- plugins/modules/clc_loadbalancer.py | 2 +- plugins/modules/clc_modify_server.py | 2 +- plugins/modules/clc_publicip.py | 2 +- plugins/modules/clc_server.py | 2 +- plugins/modules/clc_server_snapshot.py | 2 +- plugins/modules/cloud_init_data_facts.py | 2 +- plugins/modules/consul.py | 2 +- plugins/modules/cpanm.py | 2 +- plugins/modules/deploy_helper.py | 2 +- plugins/modules/dimensiondata_vlan.py | 2 +- plugins/modules/dnsmadeeasy.py | 2 +- plugins/modules/github_deploy_key.py | 2 +- plugins/modules/github_issue.py | 2 +- plugins/modules/github_key.py | 2 +- plugins/modules/gitlab_deploy_key.py | 2 +- plugins/modules/gitlab_hook.py | 2 +- plugins/modules/gitlab_runner.py | 2 +- plugins/modules/gunicorn.py | 2 +- plugins/modules/hipchat.py | 2 +- plugins/modules/homebrew_tap.py | 2 +- plugins/modules/htpasswd.py | 2 +- plugins/modules/ibm_sa_host.py | 2 +- plugins/modules/ibm_sa_host_ports.py | 2 +- plugins/modules/ibm_sa_pool.py | 2 +- plugins/modules/ibm_sa_vol.py | 2 +- plugins/modules/ibm_sa_vol_map.py | 2 +- plugins/modules/ipa_subca.py | 2 +- plugins/modules/jira.py | 2 +- plugins/modules/ldap_entry.py | 2 +- plugins/modules/ldap_passwd.py | 2 +- plugins/modules/librato_annotation.py | 2 +- plugins/modules/linode_v4.py | 2 +- plugins/modules/listen_ports_facts.py | 2 +- plugins/modules/lldp.py | 2 +- plugins/modules/logentries_msg.py | 2 +- plugins/modules/manageiq_group.py | 2 +- plugins/modules/manageiq_policies.py | 2 +- plugins/modules/manageiq_provider.py | 2 +- plugins/modules/manageiq_tags.py | 2 +- plugins/modules/manageiq_tenant.py | 2 +- plugins/modules/manageiq_user.py | 2 +- 50 files changed, 50 insertions(+), 50 deletions(-) diff --git a/plugins/modules/ali_instance.py b/plugins/modules/ali_instance.py index 4acec0a109..96a042f5ca 100644 --- a/plugins/modules/ali_instance.py +++ b/plugins/modules/ali_instance.py @@ -27,7 +27,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: ali_instance -short_description: Create, Start, Stop, Restart or Terminate an Instance in ECS. Add or Remove Instance to/from a Security Group. +short_description: Create, Start, Stop, Restart or Terminate an Instance in ECS; Add or Remove Instance to/from a Security Group description: - Create, start, stop, restart, modify or terminate ecs instances. - Add or remove ecs instances to/from security group. diff --git a/plugins/modules/ali_instance_info.py b/plugins/modules/ali_instance_info.py index ea7bcc8d4a..f489f96372 100644 --- a/plugins/modules/ali_instance_info.py +++ b/plugins/modules/ali_instance_info.py @@ -27,7 +27,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: ali_instance_info -short_description: Gather information on instances of Alibaba Cloud ECS. +short_description: Gather information on instances of Alibaba Cloud ECS description: - This module fetches data from the Open API in Alicloud. The module must be called from within the ECS instance itself. diff --git a/plugins/modules/apache2_module.py b/plugins/modules/apache2_module.py index 65d2f689bf..a58c0f0c54 100644 --- a/plugins/modules/apache2_module.py +++ b/plugins/modules/apache2_module.py @@ -16,7 +16,7 @@ author: - Christian Berendt (@berendt) - Ralf Hertel (@n0trax) - Robin Roth (@robinro) -short_description: Enables/disables a module of the Apache2 webserver. +short_description: Enables/disables a module of the Apache2 webserver description: - Enables or disables a specified module of the Apache2 webserver. options: diff --git a/plugins/modules/apt_rpm.py b/plugins/modules/apt_rpm.py index 2b6bf3e8a2..d949a61e68 100644 --- a/plugins/modules/apt_rpm.py +++ b/plugins/modules/apt_rpm.py @@ -14,7 +14,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: apt_rpm -short_description: apt_rpm package manager +short_description: APT-RPM package manager description: - Manages packages with I(apt-rpm). Both low-level (I(rpm)) and high-level (I(apt-get)) package manager binaries required. options: diff --git a/plugins/modules/beadm.py b/plugins/modules/beadm.py index 8cb43c6cbb..7a84997089 100644 --- a/plugins/modules/beadm.py +++ b/plugins/modules/beadm.py @@ -12,7 +12,7 @@ __metaclass__ = type DOCUMENTATION = r''' --- module: beadm -short_description: Manage ZFS boot environments on FreeBSD/Solaris/illumos systems. +short_description: Manage ZFS boot environments on FreeBSD/Solaris/illumos systems description: - Create, delete or activate ZFS boot environments. - Mount and unmount ZFS boot environments. diff --git a/plugins/modules/circonus_annotation.py b/plugins/modules/circonus_annotation.py index 6248fd2f55..661c854e6d 100644 --- a/plugins/modules/circonus_annotation.py +++ b/plugins/modules/circonus_annotation.py @@ -12,7 +12,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: circonus_annotation -short_description: create an annotation in circonus +short_description: Create an annotation in circonus description: - Create an annotation event with a given category, title and description. Optionally start, end or durations can be provided author: "Nick Harring (@NickatEpic)" diff --git a/plugins/modules/clc_aa_policy.py b/plugins/modules/clc_aa_policy.py index d5d56b2a65..d1fba2429a 100644 --- a/plugins/modules/clc_aa_policy.py +++ b/plugins/modules/clc_aa_policy.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' module: clc_aa_policy -short_description: Create or Delete Anti Affinity Policies at CenturyLink Cloud. +short_description: Create or Delete Anti Affinity Policies at CenturyLink Cloud description: - An Ansible module to Create or Delete Anti Affinity Policies at CenturyLink Cloud. options: diff --git a/plugins/modules/clc_alert_policy.py b/plugins/modules/clc_alert_policy.py index c7f02c2ffa..1d733013d2 100644 --- a/plugins/modules/clc_alert_policy.py +++ b/plugins/modules/clc_alert_policy.py @@ -12,7 +12,7 @@ __metaclass__ = type DOCUMENTATION = ''' module: clc_alert_policy -short_description: Create or Delete Alert Policies at CenturyLink Cloud. +short_description: Create or Delete Alert Policies at CenturyLink Cloud description: - An Ansible module to Create or Delete Alert Policies at CenturyLink Cloud. options: diff --git a/plugins/modules/clc_blueprint_package.py b/plugins/modules/clc_blueprint_package.py index 0dc29b0ce0..cb23df852b 100644 --- a/plugins/modules/clc_blueprint_package.py +++ b/plugins/modules/clc_blueprint_package.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' module: clc_blueprint_package -short_description: deploys a blue print package on a set of servers in CenturyLink Cloud. +short_description: Deploys a blue print package on a set of servers in CenturyLink Cloud description: - An Ansible module to deploy blue print package on a set of servers in CenturyLink Cloud. options: diff --git a/plugins/modules/clc_loadbalancer.py b/plugins/modules/clc_loadbalancer.py index d13c2d76ce..ab6d866fb6 100644 --- a/plugins/modules/clc_loadbalancer.py +++ b/plugins/modules/clc_loadbalancer.py @@ -12,7 +12,7 @@ __metaclass__ = type DOCUMENTATION = ''' module: clc_loadbalancer -short_description: Create, Delete shared loadbalancers in CenturyLink Cloud. +short_description: Create, Delete shared loadbalancers in CenturyLink Cloud description: - An Ansible module to Create, Delete shared loadbalancers in CenturyLink Cloud. options: diff --git a/plugins/modules/clc_modify_server.py b/plugins/modules/clc_modify_server.py index ff0611e3f8..786cdf2ae4 100644 --- a/plugins/modules/clc_modify_server.py +++ b/plugins/modules/clc_modify_server.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' module: clc_modify_server -short_description: modify servers in CenturyLink Cloud. +short_description: Modify servers in CenturyLink Cloud description: - An Ansible module to modify servers in CenturyLink Cloud. options: diff --git a/plugins/modules/clc_publicip.py b/plugins/modules/clc_publicip.py index 98d392adf9..5111b3cf19 100644 --- a/plugins/modules/clc_publicip.py +++ b/plugins/modules/clc_publicip.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' module: clc_publicip -short_description: Add and Delete public ips on servers in CenturyLink Cloud. +short_description: Add and Delete public ips on servers in CenturyLink Cloud description: - An Ansible module to add or delete public ip addresses on an existing server or servers in CenturyLink Cloud. options: diff --git a/plugins/modules/clc_server.py b/plugins/modules/clc_server.py index 062c5ea411..d8e4f16217 100644 --- a/plugins/modules/clc_server.py +++ b/plugins/modules/clc_server.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' module: clc_server -short_description: Create, Delete, Start and Stop servers in CenturyLink Cloud. +short_description: Create, Delete, Start and Stop servers in CenturyLink Cloud description: - An Ansible module to Create, Delete, Start and Stop servers in CenturyLink Cloud. options: diff --git a/plugins/modules/clc_server_snapshot.py b/plugins/modules/clc_server_snapshot.py index 44f52ece64..096abfe29b 100644 --- a/plugins/modules/clc_server_snapshot.py +++ b/plugins/modules/clc_server_snapshot.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' module: clc_server_snapshot -short_description: Create, Delete and Restore server snapshots in CenturyLink Cloud. +short_description: Create, Delete and Restore server snapshots in CenturyLink Cloud description: - An Ansible module to Create, Delete and Restore server snapshots in CenturyLink Cloud. options: diff --git a/plugins/modules/cloud_init_data_facts.py b/plugins/modules/cloud_init_data_facts.py index df2f77148e..d8209cc61a 100644 --- a/plugins/modules/cloud_init_data_facts.py +++ b/plugins/modules/cloud_init_data_facts.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: cloud_init_data_facts -short_description: Retrieve facts of cloud-init. +short_description: Retrieve facts of cloud-init description: - Gathers facts by reading the status.json and result.json of cloud-init. author: René Moser (@resmo) diff --git a/plugins/modules/consul.py b/plugins/modules/consul.py index 0d75bde2eb..a7cefc9865 100644 --- a/plugins/modules/consul.py +++ b/plugins/modules/consul.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' module: consul -short_description: "Add, modify & delete services within a consul cluster." +short_description: "Add, modify & delete services within a consul cluster" description: - Registers services and checks for an agent with a consul cluster. A service is some process running on the agent node that should be advertised by diff --git a/plugins/modules/cpanm.py b/plugins/modules/cpanm.py index 7ac8429bda..98f37d573e 100644 --- a/plugins/modules/cpanm.py +++ b/plugins/modules/cpanm.py @@ -13,7 +13,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: cpanm -short_description: Manages Perl library dependencies. +short_description: Manages Perl library dependencies description: - Manage Perl library dependencies using cpanminus. options: diff --git a/plugins/modules/deploy_helper.py b/plugins/modules/deploy_helper.py index 3d3fe08f28..afa63cba19 100644 --- a/plugins/modules/deploy_helper.py +++ b/plugins/modules/deploy_helper.py @@ -15,7 +15,7 @@ DOCUMENTATION = ''' --- module: deploy_helper author: "Ramon de la Fuente (@ramondelafuente)" -short_description: Manages some of the steps common in deploying projects. +short_description: Manages some of the steps common in deploying projects description: - The Deploy Helper manages some of the steps common in deploying software. It creates a folder structure, manages a symlink for the current release diff --git a/plugins/modules/dimensiondata_vlan.py b/plugins/modules/dimensiondata_vlan.py index ca25374dcb..86db5e5057 100644 --- a/plugins/modules/dimensiondata_vlan.py +++ b/plugins/modules/dimensiondata_vlan.py @@ -13,7 +13,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: dimensiondata_vlan -short_description: Manage a VLAN in a Cloud Control network domain. +short_description: Manage a VLAN in a Cloud Control network domain extends_documentation_fragment: - community.general.dimensiondata - community.general.dimensiondata_wait diff --git a/plugins/modules/dnsmadeeasy.py b/plugins/modules/dnsmadeeasy.py index cb27a5a68a..b775f24ab0 100644 --- a/plugins/modules/dnsmadeeasy.py +++ b/plugins/modules/dnsmadeeasy.py @@ -12,7 +12,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: dnsmadeeasy -short_description: Interface with dnsmadeeasy.com (a DNS hosting service). +short_description: Interface with dnsmadeeasy.com (a DNS hosting service) description: - > Manages DNS records via the v2 REST API of the DNS Made Easy service. It handles records only; there is no manipulation of domains or diff --git a/plugins/modules/github_deploy_key.py b/plugins/modules/github_deploy_key.py index 97e7a1ac7f..bd32438b0a 100644 --- a/plugins/modules/github_deploy_key.py +++ b/plugins/modules/github_deploy_key.py @@ -13,7 +13,7 @@ DOCUMENTATION = ''' --- module: github_deploy_key author: "Ali (@bincyber)" -short_description: Manages deploy keys for GitHub repositories. +short_description: Manages deploy keys for GitHub repositories description: - "Adds or removes deploy keys for GitHub repositories. Supports authentication using username and password, username and password and 2-factor authentication code (OTP), OAuth2 token, or personal access token. Admin diff --git a/plugins/modules/github_issue.py b/plugins/modules/github_issue.py index 4f8f2363cc..d49837499a 100644 --- a/plugins/modules/github_issue.py +++ b/plugins/modules/github_issue.py @@ -12,7 +12,7 @@ __metaclass__ = type DOCUMENTATION = ''' module: github_issue -short_description: View GitHub issue. +short_description: View GitHub issue description: - View GitHub issue for a given repository and organization. options: diff --git a/plugins/modules/github_key.py b/plugins/modules/github_key.py index 5dfd694275..3c7ee7bd7b 100644 --- a/plugins/modules/github_key.py +++ b/plugins/modules/github_key.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' module: github_key -short_description: Manage GitHub access keys. +short_description: Manage GitHub access keys description: - Creates, removes, or updates GitHub access keys. options: diff --git a/plugins/modules/gitlab_deploy_key.py b/plugins/modules/gitlab_deploy_key.py index 1b77801ec4..3ed2b2d7a5 100644 --- a/plugins/modules/gitlab_deploy_key.py +++ b/plugins/modules/gitlab_deploy_key.py @@ -13,7 +13,7 @@ __metaclass__ = type DOCUMENTATION = ''' module: gitlab_deploy_key -short_description: Manages GitLab project deploy keys. +short_description: Manages GitLab project deploy keys description: - Adds, updates and removes project deploy keys author: diff --git a/plugins/modules/gitlab_hook.py b/plugins/modules/gitlab_hook.py index c10cb45324..70864207ed 100644 --- a/plugins/modules/gitlab_hook.py +++ b/plugins/modules/gitlab_hook.py @@ -14,7 +14,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: gitlab_hook -short_description: Manages GitLab project hooks. +short_description: Manages GitLab project hooks description: - Adds, updates and removes project hook author: diff --git a/plugins/modules/gitlab_runner.py b/plugins/modules/gitlab_runner.py index 67d998f12f..1094df9424 100644 --- a/plugins/modules/gitlab_runner.py +++ b/plugins/modules/gitlab_runner.py @@ -13,7 +13,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: gitlab_runner -short_description: Create, modify and delete GitLab Runners. +short_description: Create, modify and delete GitLab Runners description: - Register, update and delete runners with the GitLab API. - All operations are performed using the GitLab API v4. diff --git a/plugins/modules/gunicorn.py b/plugins/modules/gunicorn.py index 9ed903dfd5..ff88cead7c 100644 --- a/plugins/modules/gunicorn.py +++ b/plugins/modules/gunicorn.py @@ -12,7 +12,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: gunicorn -short_description: Run gunicorn with various settings. +short_description: Run gunicorn with various settings description: - Starts gunicorn with the parameters specified. Common settings for gunicorn configuration are supported. For additional configuration use a config file diff --git a/plugins/modules/hipchat.py b/plugins/modules/hipchat.py index 1871bd23ae..a5aa150f32 100644 --- a/plugins/modules/hipchat.py +++ b/plugins/modules/hipchat.py @@ -12,7 +12,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: hipchat -short_description: Send a message to Hipchat. +short_description: Send a message to Hipchat description: - Send a message to a Hipchat room, with options to control the formatting. options: diff --git a/plugins/modules/homebrew_tap.py b/plugins/modules/homebrew_tap.py index 0cc5b23ce8..7099773b21 100644 --- a/plugins/modules/homebrew_tap.py +++ b/plugins/modules/homebrew_tap.py @@ -19,7 +19,7 @@ module: homebrew_tap author: - "Indrajit Raychaudhuri (@indrajitr)" - "Daniel Jaouen (@danieljaouen)" -short_description: Tap a Homebrew repository. +short_description: Tap a Homebrew repository description: - Tap external Homebrew repositories. options: diff --git a/plugins/modules/htpasswd.py b/plugins/modules/htpasswd.py index 4f05d21b0d..f24eaa0087 100644 --- a/plugins/modules/htpasswd.py +++ b/plugins/modules/htpasswd.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' module: htpasswd -short_description: manage user files for basic authentication +short_description: Manage user files for basic authentication description: - Add and remove username/password entries in a password file using htpasswd. - This is used by web servers such as Apache and Nginx for basic authentication. diff --git a/plugins/modules/ibm_sa_host.py b/plugins/modules/ibm_sa_host.py index 2902a02028..961e1bba19 100644 --- a/plugins/modules/ibm_sa_host.py +++ b/plugins/modules/ibm_sa_host.py @@ -13,7 +13,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: ibm_sa_host -short_description: Adds hosts to or removes them from IBM Spectrum Accelerate Family storage systems. +short_description: Adds hosts to or removes them from IBM Spectrum Accelerate Family storage systems description: - "This module adds hosts to or removes them from IBM Spectrum Accelerate Family storage systems." diff --git a/plugins/modules/ibm_sa_host_ports.py b/plugins/modules/ibm_sa_host_ports.py index 147c434344..fc543053a7 100644 --- a/plugins/modules/ibm_sa_host_ports.py +++ b/plugins/modules/ibm_sa_host_ports.py @@ -13,7 +13,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: ibm_sa_host_ports -short_description: Add host ports on IBM Spectrum Accelerate Family storage systems. +short_description: Add host ports on IBM Spectrum Accelerate Family storage systems description: - "This module adds ports to or removes them from the hosts diff --git a/plugins/modules/ibm_sa_pool.py b/plugins/modules/ibm_sa_pool.py index 6393a70686..998f3f74be 100644 --- a/plugins/modules/ibm_sa_pool.py +++ b/plugins/modules/ibm_sa_pool.py @@ -13,7 +13,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: ibm_sa_pool -short_description: Handles pools on IBM Spectrum Accelerate Family storage systems. +short_description: Handles pools on IBM Spectrum Accelerate Family storage systems description: - "This module creates or deletes pools to be used on IBM Spectrum Accelerate Family storage systems" diff --git a/plugins/modules/ibm_sa_vol.py b/plugins/modules/ibm_sa_vol.py index 6e28fcfd05..115ac9169f 100644 --- a/plugins/modules/ibm_sa_vol.py +++ b/plugins/modules/ibm_sa_vol.py @@ -13,7 +13,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: ibm_sa_vol -short_description: Handle volumes on IBM Spectrum Accelerate Family storage systems. +short_description: Handle volumes on IBM Spectrum Accelerate Family storage systems description: - "This module creates or deletes volumes to be used on IBM Spectrum Accelerate Family storage systems." diff --git a/plugins/modules/ibm_sa_vol_map.py b/plugins/modules/ibm_sa_vol_map.py index 72de7d8c07..f493a2d979 100644 --- a/plugins/modules/ibm_sa_vol_map.py +++ b/plugins/modules/ibm_sa_vol_map.py @@ -13,7 +13,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: ibm_sa_vol_map -short_description: Handles volume mapping on IBM Spectrum Accelerate Family storage systems. +short_description: Handles volume mapping on IBM Spectrum Accelerate Family storage systems description: - "This module maps volumes to or unmaps them from the hosts on diff --git a/plugins/modules/ipa_subca.py b/plugins/modules/ipa_subca.py index ef9f74ed87..b470be6aef 100644 --- a/plugins/modules/ipa_subca.py +++ b/plugins/modules/ipa_subca.py @@ -11,7 +11,7 @@ DOCUMENTATION = r''' --- module: ipa_subca author: Abhijeet Kasurde (@Akasurde) -short_description: Manage FreeIPA Lightweight Sub Certificate Authorities. +short_description: Manage FreeIPA Lightweight Sub Certificate Authorities description: - Add, modify, enable, disable and delete an IPA Lightweight Sub Certificate Authorities using IPA API. options: diff --git a/plugins/modules/jira.py b/plugins/modules/jira.py index 3b006a55bb..5e0a55119c 100644 --- a/plugins/modules/jira.py +++ b/plugins/modules/jira.py @@ -16,7 +16,7 @@ __metaclass__ = type DOCUMENTATION = r""" module: jira -short_description: create and modify issues in a JIRA instance +short_description: Create and modify issues in a JIRA instance description: - Create and modify issues in a JIRA instance. diff --git a/plugins/modules/ldap_entry.py b/plugins/modules/ldap_entry.py index d15b31f6d3..8cacbc42c1 100644 --- a/plugins/modules/ldap_entry.py +++ b/plugins/modules/ldap_entry.py @@ -14,7 +14,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: ldap_entry -short_description: Add or remove LDAP entries. +short_description: Add or remove LDAP entries description: - Add or remove LDAP entries. This module only asserts the existence or non-existence of an LDAP entry, not its attributes. To assert the diff --git a/plugins/modules/ldap_passwd.py b/plugins/modules/ldap_passwd.py index 5ffd5e12ca..029b5df252 100644 --- a/plugins/modules/ldap_passwd.py +++ b/plugins/modules/ldap_passwd.py @@ -12,7 +12,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: ldap_passwd -short_description: Set passwords in LDAP. +short_description: Set passwords in LDAP description: - Set a password for an LDAP entry. This module only asserts that a given password is valid for a given entry. To assert the diff --git a/plugins/modules/librato_annotation.py b/plugins/modules/librato_annotation.py index 4ca2e7204a..70e17cfef4 100644 --- a/plugins/modules/librato_annotation.py +++ b/plugins/modules/librato_annotation.py @@ -12,7 +12,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: librato_annotation -short_description: create an annotation in librato +short_description: Create an annotation in librato description: - Create an annotation event on the given annotation stream :name. If the annotation stream does not exist, it will be created automatically author: "Seth Edwards (@Sedward)" diff --git a/plugins/modules/linode_v4.py b/plugins/modules/linode_v4.py index 6ef8786af8..3613fc7b50 100644 --- a/plugins/modules/linode_v4.py +++ b/plugins/modules/linode_v4.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: linode_v4 -short_description: Manage instances on the Linode cloud. +short_description: Manage instances on the Linode cloud description: Manage instances on the Linode cloud. requirements: - python >= 2.7 diff --git a/plugins/modules/listen_ports_facts.py b/plugins/modules/listen_ports_facts.py index eb1ba09237..bc630e1d2e 100644 --- a/plugins/modules/listen_ports_facts.py +++ b/plugins/modules/listen_ports_facts.py @@ -18,7 +18,7 @@ description: - This module currently supports Linux only. requirements: - netstat or ss -short_description: Gather facts on processes listening on TCP and UDP ports. +short_description: Gather facts on processes listening on TCP and UDP ports notes: - | C(ss) returns all processes for each listen address and port. diff --git a/plugins/modules/lldp.py b/plugins/modules/lldp.py index 9a74f37f37..3a050ae29e 100644 --- a/plugins/modules/lldp.py +++ b/plugins/modules/lldp.py @@ -13,7 +13,7 @@ DOCUMENTATION = ''' --- module: lldp requirements: [ lldpctl ] -short_description: get details reported by lldp +short_description: Get details reported by lldp description: - Reads data out of lldpctl options: {} diff --git a/plugins/modules/logentries_msg.py b/plugins/modules/logentries_msg.py index b1b77e1d62..723273165f 100644 --- a/plugins/modules/logentries_msg.py +++ b/plugins/modules/logentries_msg.py @@ -12,7 +12,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: logentries_msg -short_description: Send a message to logentries. +short_description: Send a message to logentries description: - Send a message to logentries requirements: diff --git a/plugins/modules/manageiq_group.py b/plugins/modules/manageiq_group.py index 509de77e21..5772c19a7e 100644 --- a/plugins/modules/manageiq_group.py +++ b/plugins/modules/manageiq_group.py @@ -12,7 +12,7 @@ DOCUMENTATION = ''' module: manageiq_group -short_description: Management of groups in ManageIQ. +short_description: Management of groups in ManageIQ extends_documentation_fragment: - community.general.manageiq diff --git a/plugins/modules/manageiq_policies.py b/plugins/modules/manageiq_policies.py index ae36094768..c5b2d88287 100644 --- a/plugins/modules/manageiq_policies.py +++ b/plugins/modules/manageiq_policies.py @@ -13,7 +13,7 @@ DOCUMENTATION = ''' module: manageiq_policies -short_description: Management of resource policy_profiles in ManageIQ. +short_description: Management of resource policy_profiles in ManageIQ extends_documentation_fragment: - community.general.manageiq diff --git a/plugins/modules/manageiq_provider.py b/plugins/modules/manageiq_provider.py index 951e9bb07c..5eb6d779ac 100644 --- a/plugins/modules/manageiq_provider.py +++ b/plugins/modules/manageiq_provider.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' module: manageiq_provider -short_description: Management of provider in ManageIQ. +short_description: Management of provider in ManageIQ extends_documentation_fragment: - community.general.manageiq diff --git a/plugins/modules/manageiq_tags.py b/plugins/modules/manageiq_tags.py index 209fb5ea9d..9d051a5aa1 100644 --- a/plugins/modules/manageiq_tags.py +++ b/plugins/modules/manageiq_tags.py @@ -13,7 +13,7 @@ DOCUMENTATION = ''' module: manageiq_tags -short_description: Management of resource tags in ManageIQ. +short_description: Management of resource tags in ManageIQ extends_documentation_fragment: - community.general.manageiq diff --git a/plugins/modules/manageiq_tenant.py b/plugins/modules/manageiq_tenant.py index 0f4473092b..f3700d2492 100644 --- a/plugins/modules/manageiq_tenant.py +++ b/plugins/modules/manageiq_tenant.py @@ -12,7 +12,7 @@ DOCUMENTATION = ''' module: manageiq_tenant -short_description: Management of tenants in ManageIQ. +short_description: Management of tenants in ManageIQ extends_documentation_fragment: - community.general.manageiq diff --git a/plugins/modules/manageiq_user.py b/plugins/modules/manageiq_user.py index b9b69182cb..9910e092e0 100644 --- a/plugins/modules/manageiq_user.py +++ b/plugins/modules/manageiq_user.py @@ -12,7 +12,7 @@ DOCUMENTATION = ''' module: manageiq_user -short_description: Management of users in ManageIQ. +short_description: Management of users in ManageIQ extends_documentation_fragment: - community.general.manageiq From eae33c20f6eb8e7616064b8ffee17165c5656b56 Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Wed, 9 Nov 2022 01:28:14 -0500 Subject: [PATCH 0029/1810] Actually sort the fixtures (#5510) * Actually sort the fixtures I removed my more complicated fix but failed to actually put the sorted() call back in. * Sort by class name --- tests/unit/plugins/lookup/onepassword/test_onepassword.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/unit/plugins/lookup/onepassword/test_onepassword.py b/tests/unit/plugins/lookup/onepassword/test_onepassword.py index 9e943dbfa0..e9f8f42c96 100644 --- a/tests/unit/plugins/lookup/onepassword/test_onepassword.py +++ b/tests/unit/plugins/lookup/onepassword/test_onepassword.py @@ -5,6 +5,7 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type +import operator import itertools import json import pytest @@ -158,7 +159,7 @@ def test_op_get_field(mocker, op_fixture, output, expected, request): ("cli_class", "vault", "queries", "kwargs", "output", "expected"), ( (_cli_class, item["vault_name"], item["queries"], item.get("kwargs", {}), item["output"], item["expected"]) - for _cli_class in MOCK_ENTRIES + for _cli_class in sorted(MOCK_ENTRIES, key=operator.attrgetter("__name__")) for item in MOCK_ENTRIES[_cli_class] ) ) From c604cc5ba901574697b99bd31236d99e0e6cd1a3 Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Wed, 9 Nov 2022 01:28:49 -0500 Subject: [PATCH 0030/1810] onepassword_raw - Add missing parameter to doc string (#5511) * onepassword_raw - Add missing parameter to doc string * Remove redundant mention of default value * Update changelogs/fragments/5506-onepassword_raw-missing-param.yml Co-authored-by: Felix Fontein --- changelogs/fragments/5506-onepassword_raw-missing-param.yml | 2 ++ plugins/lookup/onepassword.py | 2 +- plugins/lookup/onepassword_raw.py | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/5506-onepassword_raw-missing-param.yml diff --git a/changelogs/fragments/5506-onepassword_raw-missing-param.yml b/changelogs/fragments/5506-onepassword_raw-missing-param.yml new file mode 100644 index 0000000000..f10ff28d28 --- /dev/null +++ b/changelogs/fragments/5506-onepassword_raw-missing-param.yml @@ -0,0 +1,2 @@ +bugfixes: + - onepassword_raw - add missing parameter to plugin documentation (https://github.com/ansible-collections/community.general/issues/5506). diff --git a/plugins/lookup/onepassword.py b/plugins/lookup/onepassword.py index bbd11d6645..5e9549c2b7 100644 --- a/plugins/lookup/onepassword.py +++ b/plugins/lookup/onepassword.py @@ -32,7 +32,7 @@ DOCUMENTATION = ''' section: description: Item section containing the field to retrieve (case-insensitive). If absent will return first match from any section. domain: - description: Domain of 1Password. Default is U(1password.com). + description: Domain of 1Password. version_added: 3.2.0 default: '1password.com' type: str diff --git a/plugins/lookup/onepassword_raw.py b/plugins/lookup/onepassword_raw.py index c7b9332953..9b87a3f619 100644 --- a/plugins/lookup/onepassword_raw.py +++ b/plugins/lookup/onepassword_raw.py @@ -30,6 +30,11 @@ DOCUMENTATION = ''' description: Item section containing the field to retrieve (case-insensitive). If absent will return first match from any section. subdomain: description: The 1Password subdomain to authenticate against. + domain: + description: Domain of 1Password. + version_added: 6.0.0 + default: '1password.com' + type: str username: description: The username used to sign in. secret_key: From f683d6a05dd57deb4347755cf26064fd65bf8efc Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Thu, 10 Nov 2022 01:57:41 +1300 Subject: [PATCH 0031/1810] short_description fix batch 2 (#5520) --- plugins/modules/consul.py | 2 +- plugins/modules/etcd3.py | 2 +- plugins/modules/gitlab_protected_branch.py | 4 ++-- plugins/modules/heroku_collaborator.py | 2 +- plugins/modules/ipinfoio_facts.py | 2 +- plugins/modules/launchd.py | 2 +- plugins/modules/memset_memstore_info.py | 2 +- plugins/modules/memset_server_info.py | 2 +- plugins/modules/memset_zone.py | 2 +- plugins/modules/memset_zone_domain.py | 2 +- plugins/modules/memset_zone_record.py | 2 +- plugins/modules/mksysb.py | 2 +- plugins/modules/mssql_db.py | 2 +- plugins/modules/nagios.py | 2 +- plugins/modules/netcup_dns.py | 2 +- plugins/modules/nginx_status_info.py | 2 +- plugins/modules/nosh.py | 2 +- plugins/modules/nsupdate.py | 2 +- plugins/modules/omapi_host.py | 2 +- plugins/modules/oneandone_firewall_policy.py | 2 +- plugins/modules/oneandone_load_balancer.py | 2 +- plugins/modules/oneandone_monitoring_policy.py | 2 +- plugins/modules/oneandone_private_network.py | 2 +- plugins/modules/oneandone_public_ip.py | 2 +- plugins/modules/oneandone_server.py | 2 +- plugins/modules/oneview_fc_network.py | 2 +- plugins/modules/online_server_info.py | 2 +- plugins/modules/online_user_info.py | 2 +- plugins/modules/opendj_backendprop.py | 2 +- plugins/modules/openwrt_init.py | 2 +- plugins/modules/packet_device.py | 2 +- plugins/modules/packet_ip_subnet.py | 2 +- plugins/modules/packet_project.py | 2 +- plugins/modules/packet_sshkey.py | 2 +- plugins/modules/packet_volume.py | 2 +- plugins/modules/packet_volume_attachment.py | 2 +- plugins/modules/pids.py | 2 +- plugins/modules/pip_package_info.py | 2 +- plugins/modules/pkgin.py | 2 +- plugins/modules/profitbricks.py | 2 +- plugins/modules/profitbricks_datacenter.py | 2 +- plugins/modules/profitbricks_nic.py | 2 +- plugins/modules/profitbricks_volume.py | 2 +- plugins/modules/profitbricks_volume_attachments.py | 2 +- plugins/modules/proxmox.py | 2 +- plugins/modules/proxmox_disk.py | 2 +- plugins/modules/proxmox_kvm.py | 2 +- plugins/modules/proxmox_nic.py | 2 +- plugins/modules/proxmox_template.py | 2 +- plugins/modules/pubnub_blocks.py | 2 +- 50 files changed, 51 insertions(+), 51 deletions(-) diff --git a/plugins/modules/consul.py b/plugins/modules/consul.py index a7cefc9865..aabc1bd4b7 100644 --- a/plugins/modules/consul.py +++ b/plugins/modules/consul.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' module: consul -short_description: "Add, modify & delete services within a consul cluster" +short_description: Add, modify & delete services within a consul cluster description: - Registers services and checks for an agent with a consul cluster. A service is some process running on the agent node that should be advertised by diff --git a/plugins/modules/etcd3.py b/plugins/modules/etcd3.py index e67227cc19..2a89c71968 100644 --- a/plugins/modules/etcd3.py +++ b/plugins/modules/etcd3.py @@ -12,7 +12,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: etcd3 -short_description: "Set or delete key value pairs from an etcd3 cluster" +short_description: Set or delete key value pairs from an etcd3 cluster requirements: - etcd3 description: diff --git a/plugins/modules/gitlab_protected_branch.py b/plugins/modules/gitlab_protected_branch.py index bddf175f0f..335e1445a2 100644 --- a/plugins/modules/gitlab_protected_branch.py +++ b/plugins/modules/gitlab_protected_branch.py @@ -9,7 +9,7 @@ __metaclass__ = type DOCUMENTATION = ''' module: gitlab_protected_branch -short_description: (un)Marking existing branches for protection +short_description: Manage protection of existing branches version_added: 3.4.0 description: - (un)Marking existing branches for protection. @@ -25,7 +25,7 @@ extends_documentation_fragment: options: state: description: - - Create or delete proteced branch. + - Create or delete protected branch. default: present type: str choices: ["present", "absent"] diff --git a/plugins/modules/heroku_collaborator.py b/plugins/modules/heroku_collaborator.py index e29439ca2f..d76b2b6507 100644 --- a/plugins/modules/heroku_collaborator.py +++ b/plugins/modules/heroku_collaborator.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: heroku_collaborator -short_description: "Add or delete app collaborators on Heroku" +short_description: Add or delete app collaborators on Heroku description: - Manages collaborators for Heroku apps. - If set to C(present) and heroku user is already collaborator, then do nothing. diff --git a/plugins/modules/ipinfoio_facts.py b/plugins/modules/ipinfoio_facts.py index 676e88d84d..f29b3cbf4c 100644 --- a/plugins/modules/ipinfoio_facts.py +++ b/plugins/modules/ipinfoio_facts.py @@ -12,7 +12,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: ipinfoio_facts -short_description: "Retrieve IP geolocation facts of a host's IP address" +short_description: Retrieve IP geolocation facts of a host's IP address description: - "Gather IP geolocation facts of a host's IP address using ipinfo.io API" author: "Aleksei Kostiuk (@akostyuk)" diff --git a/plugins/modules/launchd.py b/plugins/modules/launchd.py index 6e14e4c10c..250bbffb9e 100644 --- a/plugins/modules/launchd.py +++ b/plugins/modules/launchd.py @@ -13,7 +13,7 @@ DOCUMENTATION = r''' module: launchd author: - Martin Migasiewicz (@martinm82) -short_description: Manage macOS services +short_description: Manage macOS services version_added: 1.0.0 description: - Manage launchd services on target macOS hosts. diff --git a/plugins/modules/memset_memstore_info.py b/plugins/modules/memset_memstore_info.py index 4de803f991..8ce3d5b05a 100644 --- a/plugins/modules/memset_memstore_info.py +++ b/plugins/modules/memset_memstore_info.py @@ -12,7 +12,7 @@ DOCUMENTATION = ''' --- module: memset_memstore_info author: "Simon Weald (@glitchcrab)" -short_description: Retrieve Memstore product usage information. +short_description: Retrieve Memstore product usage information notes: - An API key generated via the Memset customer control panel is needed with the following minimum scope - I(memstore.usage). diff --git a/plugins/modules/memset_server_info.py b/plugins/modules/memset_server_info.py index 44aa0d8442..0c78f2bd1d 100644 --- a/plugins/modules/memset_server_info.py +++ b/plugins/modules/memset_server_info.py @@ -12,7 +12,7 @@ DOCUMENTATION = ''' --- module: memset_server_info author: "Simon Weald (@glitchcrab)" -short_description: Retrieve server information. +short_description: Retrieve server information notes: - An API key generated via the Memset customer control panel is needed with the following minimum scope - I(server.info). diff --git a/plugins/modules/memset_zone.py b/plugins/modules/memset_zone.py index 9731e3a943..02b5fd28f0 100644 --- a/plugins/modules/memset_zone.py +++ b/plugins/modules/memset_zone.py @@ -12,7 +12,7 @@ DOCUMENTATION = ''' --- module: memset_zone author: "Simon Weald (@glitchcrab)" -short_description: Creates and deletes Memset DNS zones. +short_description: Creates and deletes Memset DNS zones notes: - Zones can be thought of as a logical group of domains, all of which share the same DNS records (i.e. they point to the same IP). An API key generated via the diff --git a/plugins/modules/memset_zone_domain.py b/plugins/modules/memset_zone_domain.py index 995c7bc8d3..1e18a984b6 100644 --- a/plugins/modules/memset_zone_domain.py +++ b/plugins/modules/memset_zone_domain.py @@ -12,7 +12,7 @@ DOCUMENTATION = ''' --- module: memset_zone_domain author: "Simon Weald (@glitchcrab)" -short_description: Create and delete domains in Memset DNS zones. +short_description: Create and delete domains in Memset DNS zones notes: - Zone domains can be thought of as a collection of domains, all of which share the same DNS records (i.e. they point to the same IP). An API key generated via the diff --git a/plugins/modules/memset_zone_record.py b/plugins/modules/memset_zone_record.py index c114532f90..925a034c56 100644 --- a/plugins/modules/memset_zone_record.py +++ b/plugins/modules/memset_zone_record.py @@ -12,7 +12,7 @@ DOCUMENTATION = ''' --- module: memset_zone_record author: "Simon Weald (@glitchcrab)" -short_description: Create and delete records in Memset DNS zones. +short_description: Create and delete records in Memset DNS zones notes: - Zones can be thought of as a logical group of domains, all of which share the same DNS records (i.e. they point to the same IP). An API key generated via the diff --git a/plugins/modules/mksysb.py b/plugins/modules/mksysb.py index a466bd9df6..15b6ad9442 100644 --- a/plugins/modules/mksysb.py +++ b/plugins/modules/mksysb.py @@ -14,7 +14,7 @@ DOCUMENTATION = ''' --- author: Kairo Araujo (@kairoaraujo) module: mksysb -short_description: Generates AIX mksysb rootvg backups. +short_description: Generates AIX mksysb rootvg backups description: - This module manages a basic AIX mksysb (image) of rootvg. options: diff --git a/plugins/modules/mssql_db.py b/plugins/modules/mssql_db.py index a7d16b2710..58a8c4dea9 100644 --- a/plugins/modules/mssql_db.py +++ b/plugins/modules/mssql_db.py @@ -13,7 +13,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: mssql_db -short_description: Add or remove MSSQL databases from a remote host. +short_description: Add or remove MSSQL databases from a remote host description: - Add or remove MSSQL databases from a remote host. options: diff --git a/plugins/modules/nagios.py b/plugins/modules/nagios.py index 4fb2a9ff45..ec526a3959 100644 --- a/plugins/modules/nagios.py +++ b/plugins/modules/nagios.py @@ -17,7 +17,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: nagios -short_description: Perform common tasks in Nagios related to downtime and notifications. +short_description: Perform common tasks in Nagios related to downtime and notifications description: - "The C(nagios) module has two basic functions: scheduling downtime and toggling alerts for services or hosts." - The C(nagios) module is not idempotent. diff --git a/plugins/modules/netcup_dns.py b/plugins/modules/netcup_dns.py index 5d082c2980..4c3c015ebd 100644 --- a/plugins/modules/netcup_dns.py +++ b/plugins/modules/netcup_dns.py @@ -13,7 +13,7 @@ DOCUMENTATION = ''' --- module: netcup_dns notes: [] -short_description: manage Netcup DNS records +short_description: Manage Netcup DNS records description: - "Manages DNS records via the Netcup API, see the docs U(https://ccp.netcup.net/run/webservice/servers/endpoint.php)." options: diff --git a/plugins/modules/nginx_status_info.py b/plugins/modules/nginx_status_info.py index 1e1bb10495..6bbea078b0 100644 --- a/plugins/modules/nginx_status_info.py +++ b/plugins/modules/nginx_status_info.py @@ -12,7 +12,7 @@ __metaclass__ = type DOCUMENTATION = r''' --- module: nginx_status_info -short_description: Retrieve information on nginx status. +short_description: Retrieve information on nginx status description: - Gathers information from nginx from an URL having C(stub_status) enabled. author: "René Moser (@resmo)" diff --git a/plugins/modules/nosh.py b/plugins/modules/nosh.py index 756f5fed42..432990a4d2 100644 --- a/plugins/modules/nosh.py +++ b/plugins/modules/nosh.py @@ -14,7 +14,7 @@ DOCUMENTATION = ''' module: nosh author: - "Thomas Caravia (@tacatac)" -short_description: Manage services with nosh +short_description: Manage services with nosh description: - Control running and enabled state for system-wide or user services. - BSD and Linux systems are supported. diff --git a/plugins/modules/nsupdate.py b/plugins/modules/nsupdate.py index 43b951fe61..2be4863b68 100644 --- a/plugins/modules/nsupdate.py +++ b/plugins/modules/nsupdate.py @@ -18,7 +18,7 @@ DOCUMENTATION = ''' --- module: nsupdate -short_description: Manage DNS records. +short_description: Manage DNS records description: - Create, update and remove DNS records using DDNS updates requirements: diff --git a/plugins/modules/omapi_host.py b/plugins/modules/omapi_host.py index 7d1897ca55..4e3a6247d6 100644 --- a/plugins/modules/omapi_host.py +++ b/plugins/modules/omapi_host.py @@ -13,7 +13,7 @@ __metaclass__ = type DOCUMENTATION = r''' --- module: omapi_host -short_description: Setup OMAPI hosts. +short_description: Setup OMAPI hosts description: Manage OMAPI hosts into compatible DHCPd servers requirements: - pypureomapi diff --git a/plugins/modules/oneandone_firewall_policy.py b/plugins/modules/oneandone_firewall_policy.py index 23203e8d05..5cceffa812 100644 --- a/plugins/modules/oneandone_firewall_policy.py +++ b/plugins/modules/oneandone_firewall_policy.py @@ -10,7 +10,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: oneandone_firewall_policy -short_description: Configure 1&1 firewall policy. +short_description: Configure 1&1 firewall policy description: - Create, remove, reconfigure, update firewall policies. This module has a dependency on 1and1 >= 1.0 diff --git a/plugins/modules/oneandone_load_balancer.py b/plugins/modules/oneandone_load_balancer.py index 04aefde63a..432fc456b1 100644 --- a/plugins/modules/oneandone_load_balancer.py +++ b/plugins/modules/oneandone_load_balancer.py @@ -10,7 +10,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: oneandone_load_balancer -short_description: Configure 1&1 load balancer. +short_description: Configure 1&1 load balancer description: - Create, remove, update load balancers. This module has a dependency on 1and1 >= 1.0 diff --git a/plugins/modules/oneandone_monitoring_policy.py b/plugins/modules/oneandone_monitoring_policy.py index 46c68e86e0..04e9c67570 100644 --- a/plugins/modules/oneandone_monitoring_policy.py +++ b/plugins/modules/oneandone_monitoring_policy.py @@ -10,7 +10,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: oneandone_monitoring_policy -short_description: Configure 1&1 monitoring policy. +short_description: Configure 1&1 monitoring policy description: - Create, remove, update monitoring policies (and add/remove ports, processes, and servers). diff --git a/plugins/modules/oneandone_private_network.py b/plugins/modules/oneandone_private_network.py index a6db23310a..4a912a0f35 100644 --- a/plugins/modules/oneandone_private_network.py +++ b/plugins/modules/oneandone_private_network.py @@ -10,7 +10,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: oneandone_private_network -short_description: Configure 1&1 private networking. +short_description: Configure 1&1 private networking description: - Create, remove, reconfigure, update a private network. This module has a dependency on 1and1 >= 1.0 diff --git a/plugins/modules/oneandone_public_ip.py b/plugins/modules/oneandone_public_ip.py index a5970735ce..31ed082c74 100644 --- a/plugins/modules/oneandone_public_ip.py +++ b/plugins/modules/oneandone_public_ip.py @@ -10,7 +10,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: oneandone_public_ip -short_description: Configure 1&1 public IPs. +short_description: Configure 1&1 public IPs description: - Create, update, and remove public IPs. This module has a dependency on 1and1 >= 1.0 diff --git a/plugins/modules/oneandone_server.py b/plugins/modules/oneandone_server.py index 22b4b9dd69..e0f1b0eb03 100644 --- a/plugins/modules/oneandone_server.py +++ b/plugins/modules/oneandone_server.py @@ -10,7 +10,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: oneandone_server -short_description: Create, destroy, start, stop, and reboot a 1&1 Host server. +short_description: Create, destroy, start, stop, and reboot a 1&1 Host server description: - Create, destroy, update, start, stop, and reboot a 1&1 Host server. When the server is created it can optionally wait for it to be 'running' before returning. diff --git a/plugins/modules/oneview_fc_network.py b/plugins/modules/oneview_fc_network.py index e4b1a17339..2898447c0b 100644 --- a/plugins/modules/oneview_fc_network.py +++ b/plugins/modules/oneview_fc_network.py @@ -10,7 +10,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: oneview_fc_network -short_description: Manage OneView Fibre Channel Network resources. +short_description: Manage OneView Fibre Channel Network resources description: - Provides an interface to manage Fibre Channel Network resources. Can create, update, and delete. requirements: diff --git a/plugins/modules/online_server_info.py b/plugins/modules/online_server_info.py index 533e0453f9..f6d03cb275 100644 --- a/plugins/modules/online_server_info.py +++ b/plugins/modules/online_server_info.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = r''' --- module: online_server_info -short_description: Gather information about Online servers. +short_description: Gather information about Online servers description: - Gather information about the servers. - U(https://www.online.net/en/dedicated-server) diff --git a/plugins/modules/online_user_info.py b/plugins/modules/online_user_info.py index 17cbc7d662..1d91418caf 100644 --- a/plugins/modules/online_user_info.py +++ b/plugins/modules/online_user_info.py @@ -9,7 +9,7 @@ __metaclass__ = type DOCUMENTATION = r''' module: online_user_info -short_description: Gather information about Online user. +short_description: Gather information about Online user description: - Gather information about the user. author: diff --git a/plugins/modules/opendj_backendprop.py b/plugins/modules/opendj_backendprop.py index dfdf6a903a..7e620c4305 100644 --- a/plugins/modules/opendj_backendprop.py +++ b/plugins/modules/opendj_backendprop.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: opendj_backendprop -short_description: Will update the backend configuration of OpenDJ via the dsconfig set-backend-prop command. +short_description: Will update the backend configuration of OpenDJ via the dsconfig set-backend-prop command description: - This module will update settings for OpenDJ with the command set-backend-prop. - It will check first via de get-backend-prop if configuration needs to be applied. diff --git a/plugins/modules/openwrt_init.py b/plugins/modules/openwrt_init.py index be7031791e..978a6bec35 100644 --- a/plugins/modules/openwrt_init.py +++ b/plugins/modules/openwrt_init.py @@ -12,7 +12,7 @@ DOCUMENTATION = ''' module: openwrt_init author: - "Andrew Gaffney (@agaffney)" -short_description: Manage services on OpenWrt. +short_description: Manage services on OpenWrt description: - Controls OpenWrt services on remote hosts. options: diff --git a/plugins/modules/packet_device.py b/plugins/modules/packet_device.py index 6b78406a6e..500a400273 100644 --- a/plugins/modules/packet_device.py +++ b/plugins/modules/packet_device.py @@ -14,7 +14,7 @@ DOCUMENTATION = ''' --- module: packet_device -short_description: Manage a bare metal server in the Packet Host. +short_description: Manage a bare metal server in the Packet Host description: - Manage a bare metal server in the Packet Host (a "device" in the API terms). diff --git a/plugins/modules/packet_ip_subnet.py b/plugins/modules/packet_ip_subnet.py index 79f93a6413..63790e1c6a 100644 --- a/plugins/modules/packet_ip_subnet.py +++ b/plugins/modules/packet_ip_subnet.py @@ -14,7 +14,7 @@ DOCUMENTATION = ''' --- module: packet_ip_subnet -short_description: Assign IP subnet to a bare metal server. +short_description: Assign IP subnet to a bare metal server description: - Assign or unassign IPv4 or IPv6 subnets to or from a device in the Packet host. diff --git a/plugins/modules/packet_project.py b/plugins/modules/packet_project.py index 18b6f73f99..9a82c2ec72 100644 --- a/plugins/modules/packet_project.py +++ b/plugins/modules/packet_project.py @@ -14,7 +14,7 @@ DOCUMENTATION = ''' --- module: packet_project -short_description: Create/delete a project in Packet host. +short_description: Create/delete a project in Packet host description: - Create/delete a project in Packet host. diff --git a/plugins/modules/packet_sshkey.py b/plugins/modules/packet_sshkey.py index d39e419747..87beb01aa8 100644 --- a/plugins/modules/packet_sshkey.py +++ b/plugins/modules/packet_sshkey.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: packet_sshkey -short_description: Create/delete an SSH key in Packet host. +short_description: Create/delete an SSH key in Packet host description: - Create/delete an SSH key in Packet host. - API is documented at U(https://www.packet.net/help/api/#page:ssh-keys,header:ssh-keys-ssh-keys-post). diff --git a/plugins/modules/packet_volume.py b/plugins/modules/packet_volume.py index f0508c5891..b06e57b56c 100644 --- a/plugins/modules/packet_volume.py +++ b/plugins/modules/packet_volume.py @@ -13,7 +13,7 @@ DOCUMENTATION = ''' --- module: packet_volume -short_description: Create/delete a volume in Packet host. +short_description: Create/delete a volume in Packet host description: - Create/delete a volume in Packet host. diff --git a/plugins/modules/packet_volume_attachment.py b/plugins/modules/packet_volume_attachment.py index 4f55d60cfa..74b42ab479 100644 --- a/plugins/modules/packet_volume_attachment.py +++ b/plugins/modules/packet_volume_attachment.py @@ -14,7 +14,7 @@ DOCUMENTATION = ''' --- module: packet_volume_attachment -short_description: Attach/detach a volume to a device in the Packet host. +short_description: Attach/detach a volume to a device in the Packet host description: - Attach/detach a volume to a device in the Packet host. diff --git a/plugins/modules/pids.py b/plugins/modules/pids.py index 072a2bb7a4..eaaf7f9437 100644 --- a/plugins/modules/pids.py +++ b/plugins/modules/pids.py @@ -10,7 +10,7 @@ __metaclass__ = type DOCUMENTATION = ''' module: pids description: "Retrieves a list of PIDs of given process name in Ansible controller/controlled machines.Returns an empty list if no process in that name exists." -short_description: "Retrieves process IDs list if the process is running otherwise return empty list" +short_description: Retrieves process IDs list if the process is running otherwise return empty list author: - Saranya Sridharan (@saranyasridharan) requirements: diff --git a/plugins/modules/pip_package_info.py b/plugins/modules/pip_package_info.py index c89e47014e..2cde7218d4 100644 --- a/plugins/modules/pip_package_info.py +++ b/plugins/modules/pip_package_info.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' module: pip_package_info -short_description: pip package information +short_description: Pip package information description: - Return information about installed pip packages extends_documentation_fragment: diff --git a/plugins/modules/pkgin.py b/plugins/modules/pkgin.py index 477460e0e3..0da06e0502 100644 --- a/plugins/modules/pkgin.py +++ b/plugins/modules/pkgin.py @@ -19,7 +19,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: pkgin -short_description: Package manager for SmartOS, NetBSD, et al. +short_description: Package manager for SmartOS, NetBSD, et al description: - "The standard package manager for SmartOS, but also usable on NetBSD or any OS that uses C(pkgsrc). (Home: U(http://pkgin.net/))" diff --git a/plugins/modules/profitbricks.py b/plugins/modules/profitbricks.py index cb41491464..6b0134cb99 100644 --- a/plugins/modules/profitbricks.py +++ b/plugins/modules/profitbricks.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: profitbricks -short_description: Create, destroy, start, stop, and reboot a ProfitBricks virtual machine. +short_description: Create, destroy, start, stop, and reboot a ProfitBricks virtual machine description: - Create, destroy, update, start, stop, and reboot a ProfitBricks virtual machine. When the virtual machine is created it can optionally wait for it to be 'running' before returning. This module has a dependency on profitbricks >= 1.0.0 diff --git a/plugins/modules/profitbricks_datacenter.py b/plugins/modules/profitbricks_datacenter.py index cc3184320d..a11d12bfd9 100644 --- a/plugins/modules/profitbricks_datacenter.py +++ b/plugins/modules/profitbricks_datacenter.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: profitbricks_datacenter -short_description: Create or destroy a ProfitBricks Virtual Datacenter. +short_description: Create or destroy a ProfitBricks Virtual Datacenter description: - This is a simple module that supports creating or removing vDCs. A vDC is required before you can create servers. This module has a dependency on profitbricks >= 1.0.0 diff --git a/plugins/modules/profitbricks_nic.py b/plugins/modules/profitbricks_nic.py index facb146b60..c6239f5ef5 100644 --- a/plugins/modules/profitbricks_nic.py +++ b/plugins/modules/profitbricks_nic.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: profitbricks_nic -short_description: Create or Remove a NIC. +short_description: Create or Remove a NIC description: - This module allows you to create or restore a volume snapshot. This module has a dependency on profitbricks >= 1.0.0 options: diff --git a/plugins/modules/profitbricks_volume.py b/plugins/modules/profitbricks_volume.py index 2d449fd92a..1d21897715 100644 --- a/plugins/modules/profitbricks_volume.py +++ b/plugins/modules/profitbricks_volume.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: profitbricks_volume -short_description: Create or destroy a volume. +short_description: Create or destroy a volume description: - Allows you to create or remove a volume from a ProfitBricks datacenter. This module has a dependency on profitbricks >= 1.0.0 options: diff --git a/plugins/modules/profitbricks_volume_attachments.py b/plugins/modules/profitbricks_volume_attachments.py index 5637aca67f..49b418362b 100644 --- a/plugins/modules/profitbricks_volume_attachments.py +++ b/plugins/modules/profitbricks_volume_attachments.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: profitbricks_volume_attachments -short_description: Attach or detach a volume. +short_description: Attach or detach a volume description: - Allows you to attach or detach a volume from a ProfitBricks server. This module has a dependency on profitbricks >= 1.0.0 options: diff --git a/plugins/modules/proxmox.py b/plugins/modules/proxmox.py index 5a89ee7796..89706655f2 100644 --- a/plugins/modules/proxmox.py +++ b/plugins/modules/proxmox.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: proxmox -short_description: management of instances in Proxmox VE cluster +short_description: Management of instances in Proxmox VE cluster description: - allows you to create/delete/stop instances in Proxmox VE cluster - Starting in Ansible 2.1, it automatically detects containerization type (lxc for PVE 4, openvz for older) diff --git a/plugins/modules/proxmox_disk.py b/plugins/modules/proxmox_disk.py index 182a0d25f2..7a39d38d05 100644 --- a/plugins/modules/proxmox_disk.py +++ b/plugins/modules/proxmox_disk.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = r''' --- module: proxmox_disk -short_description: Management of a disk of a Qemu(KVM) VM in a Proxmox VE cluster. +short_description: Management of a disk of a Qemu(KVM) VM in a Proxmox VE cluster version_added: 5.7.0 description: - Allows you to perform some supported operations on a disk in Qemu(KVM) Virtual Machines in a Proxmox VE cluster. diff --git a/plugins/modules/proxmox_kvm.py b/plugins/modules/proxmox_kvm.py index 92aaf6a904..25e252bee9 100644 --- a/plugins/modules/proxmox_kvm.py +++ b/plugins/modules/proxmox_kvm.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = r''' --- module: proxmox_kvm -short_description: Management of Qemu(KVM) Virtual Machines in Proxmox VE cluster. +short_description: Management of Qemu(KVM) Virtual Machines in Proxmox VE cluster description: - Allows you to create/delete/stop Qemu(KVM) Virtual Machines in Proxmox VE cluster. - Since community.general 4.0.0 on, there are no more default values, see I(proxmox_default_behavior). diff --git a/plugins/modules/proxmox_nic.py b/plugins/modules/proxmox_nic.py index 49f7f91bcd..bcc56de57e 100644 --- a/plugins/modules/proxmox_nic.py +++ b/plugins/modules/proxmox_nic.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = r''' --- module: proxmox_nic -short_description: Management of a NIC of a Qemu(KVM) VM in a Proxmox VE cluster. +short_description: Management of a NIC of a Qemu(KVM) VM in a Proxmox VE cluster version_added: 3.1.0 description: - Allows you to create/update/delete a NIC on Qemu(KVM) Virtual Machines in a Proxmox VE cluster. diff --git a/plugins/modules/proxmox_template.py b/plugins/modules/proxmox_template.py index 24a6c87d31..a09af2f2a3 100644 --- a/plugins/modules/proxmox_template.py +++ b/plugins/modules/proxmox_template.py @@ -12,7 +12,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: proxmox_template -short_description: management of OS templates in Proxmox VE cluster +short_description: Management of OS templates in Proxmox VE cluster description: - allows you to upload/delete templates in Proxmox VE cluster options: diff --git a/plugins/modules/pubnub_blocks.py b/plugins/modules/pubnub_blocks.py index 9942c57134..28b17b5431 100644 --- a/plugins/modules/pubnub_blocks.py +++ b/plugins/modules/pubnub_blocks.py @@ -17,7 +17,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: pubnub_blocks -short_description: PubNub blocks management module. +short_description: PubNub blocks management module description: - "This module allows Ansible to interface with the PubNub BLOCKS infrastructure by providing the following operations: create / remove, From 0e9cd5e6b6ae33b0d0781c0d81413b0bb52d2dbb Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Wed, 9 Nov 2022 18:37:43 +0100 Subject: [PATCH 0032/1810] Ignore mpdehaan in BOTMETA. (#5524) --- .github/BOTMETA.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/BOTMETA.yml b/.github/BOTMETA.yml index dfacfbecfb..c56720cb0d 100644 --- a/.github/BOTMETA.yml +++ b/.github/BOTMETA.yml @@ -822,7 +822,8 @@ files: maintainers: marc-sensenich $modules/ohai.py: labels: ohai - maintainers: $team_ansible_core mpdehaan + maintainers: $team_ansible_core + ignore: mpdehaan $modules/omapi_host.py: maintainers: amasolov nerzhul $modules/one_: @@ -1072,7 +1073,8 @@ files: $modules/sapcar_extract.py: maintainers: RainerLeber $modules/say.py: - maintainers: $team_ansible_core mpdehaan + maintainers: $team_ansible_core + ignore: mpdehaan $modules/scaleway_: maintainers: $team_scaleway $modules/scaleway_compute_private_network.py: From 6b20572ea17da272be87d74e3abf52153a3b33f1 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Thu, 10 Nov 2022 09:09:09 +1300 Subject: [PATCH 0033/1810] Short descriptions (batch3) - massive fix on Capitalization and trailing period (#5521) * short_description fix batch 3 * Update plugins/modules/telegram.py Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein --- plugins/modules/pulp_repo.py | 2 +- plugins/modules/rax.py | 2 +- plugins/modules/rax_cdb.py | 2 +- plugins/modules/rax_cdb_database.py | 2 +- plugins/modules/rax_cdb_user.py | 2 +- plugins/modules/rax_clb.py | 2 +- plugins/modules/rax_clb_nodes.py | 2 +- plugins/modules/rax_clb_ssl.py | 2 +- plugins/modules/rax_mon_alarm.py | 2 +- plugins/modules/rax_mon_notification.py | 2 +- plugins/modules/rax_network.py | 2 +- plugins/modules/rax_queue.py | 2 +- plugins/modules/rundeck_acl_policy.py | 2 +- plugins/modules/rundeck_project.py | 2 +- plugins/modules/say.py | 2 +- plugins/modules/scaleway_image_info.py | 2 +- plugins/modules/scaleway_ip_info.py | 2 +- plugins/modules/scaleway_organization_info.py | 2 +- plugins/modules/scaleway_security_group_info.py | 2 +- plugins/modules/scaleway_server_info.py | 2 +- plugins/modules/scaleway_snapshot_info.py | 2 +- plugins/modules/scaleway_volume_info.py | 2 +- plugins/modules/sl_vm.py | 2 +- plugins/modules/smartos_image_info.py | 2 +- plugins/modules/spectrum_device.py | 2 +- plugins/modules/spectrum_model_attrs.py | 2 +- plugins/modules/svc.py | 2 +- plugins/modules/swupd.py | 2 +- plugins/modules/telegram.py | 2 +- plugins/modules/twilio.py | 2 +- plugins/modules/utm_aaa_group.py | 2 +- plugins/modules/utm_aaa_group_info.py | 2 +- plugins/modules/utm_ca_host_key_cert.py | 2 +- plugins/modules/utm_dns_host.py | 2 +- plugins/modules/utm_proxy_auth_profile.py | 2 +- plugins/modules/utm_proxy_frontend.py | 2 +- plugins/modules/utm_proxy_frontend_info.py | 2 +- plugins/modules/utm_proxy_location.py | 2 +- plugins/modules/utm_proxy_location_info.py | 2 +- plugins/modules/vertica_configuration.py | 2 +- plugins/modules/vertica_info.py | 2 +- plugins/modules/vertica_role.py | 2 +- plugins/modules/vertica_schema.py | 2 +- plugins/modules/vertica_user.py | 2 +- plugins/modules/vmadm.py | 2 +- plugins/modules/xenserver_facts.py | 2 +- plugins/modules/zfs_facts.py | 2 +- plugins/modules/zpool_facts.py | 2 +- 48 files changed, 48 insertions(+), 48 deletions(-) diff --git a/plugins/modules/pulp_repo.py b/plugins/modules/pulp_repo.py index 030d2fd9af..9e100ba93e 100644 --- a/plugins/modules/pulp_repo.py +++ b/plugins/modules/pulp_repo.py @@ -14,7 +14,7 @@ DOCUMENTATION = ''' --- module: pulp_repo author: "Joe Adams (@sysadmind)" -short_description: Add or remove Pulp repos from a remote host. +short_description: Add or remove Pulp repos from a remote host description: - Add or remove Pulp repos from a remote host. - Note, this is for Pulp 2 only. diff --git a/plugins/modules/rax.py b/plugins/modules/rax.py index b35384173a..fa929f7971 100644 --- a/plugins/modules/rax.py +++ b/plugins/modules/rax.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: rax -short_description: create / delete an instance in Rackspace Public Cloud +short_description: Create / delete an instance in Rackspace Public Cloud description: - creates / deletes a Rackspace Public Cloud instance and optionally waits for it to be 'running'. diff --git a/plugins/modules/rax_cdb.py b/plugins/modules/rax_cdb.py index 6703a8dd4b..3fb6194d9d 100644 --- a/plugins/modules/rax_cdb.py +++ b/plugins/modules/rax_cdb.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: rax_cdb -short_description: create/delete or resize a Rackspace Cloud Databases instance +short_description: Create/delete or resize a Rackspace Cloud Databases instance description: - creates / deletes or resize a Rackspace Cloud Databases instance and optionally waits for it to be 'running'. The name option needs to be diff --git a/plugins/modules/rax_cdb_database.py b/plugins/modules/rax_cdb_database.py index 5b5ebc6e29..6e0e8411c2 100644 --- a/plugins/modules/rax_cdb_database.py +++ b/plugins/modules/rax_cdb_database.py @@ -10,7 +10,7 @@ __metaclass__ = type DOCUMENTATION = ''' module: rax_cdb_database -short_description: 'create / delete a database in the Cloud Databases' +short_description: Create / delete a database in the Cloud Databases description: - create / delete a database in the Cloud Databases. options: diff --git a/plugins/modules/rax_cdb_user.py b/plugins/modules/rax_cdb_user.py index ccc3e677a5..63cb00b608 100644 --- a/plugins/modules/rax_cdb_user.py +++ b/plugins/modules/rax_cdb_user.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: rax_cdb_user -short_description: create / delete a Rackspace Cloud Database +short_description: Create / delete a Rackspace Cloud Database description: - create / delete a database in the Cloud Databases. options: diff --git a/plugins/modules/rax_clb.py b/plugins/modules/rax_clb.py index 7d45c865f0..8355a42921 100644 --- a/plugins/modules/rax_clb.py +++ b/plugins/modules/rax_clb.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: rax_clb -short_description: create / delete a load balancer in Rackspace Public Cloud +short_description: Create / delete a load balancer in Rackspace Public Cloud description: - creates / deletes a Rackspace Public Cloud load balancer. options: diff --git a/plugins/modules/rax_clb_nodes.py b/plugins/modules/rax_clb_nodes.py index 04341f7ceb..e6d050de46 100644 --- a/plugins/modules/rax_clb_nodes.py +++ b/plugins/modules/rax_clb_nodes.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: rax_clb_nodes -short_description: add, modify and remove nodes from a Rackspace Cloud Load Balancer +short_description: Add, modify and remove nodes from a Rackspace Cloud Load Balancer description: - Adds, modifies and removes nodes from a Rackspace Cloud Load Balancer options: diff --git a/plugins/modules/rax_clb_ssl.py b/plugins/modules/rax_clb_ssl.py index db192368b4..85110d3390 100644 --- a/plugins/modules/rax_clb_ssl.py +++ b/plugins/modules/rax_clb_ssl.py @@ -10,7 +10,7 @@ __metaclass__ = type DOCUMENTATION = ''' module: rax_clb_ssl -short_description: Manage SSL termination for a Rackspace Cloud Load Balancer. +short_description: Manage SSL termination for a Rackspace Cloud Load Balancer description: - Set up, reconfigure, or remove SSL termination for an existing load balancer. options: diff --git a/plugins/modules/rax_mon_alarm.py b/plugins/modules/rax_mon_alarm.py index dd971f7243..d167420341 100644 --- a/plugins/modules/rax_mon_alarm.py +++ b/plugins/modules/rax_mon_alarm.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: rax_mon_alarm -short_description: Create or delete a Rackspace Cloud Monitoring alarm. +short_description: Create or delete a Rackspace Cloud Monitoring alarm description: - Create or delete a Rackspace Cloud Monitoring alarm that associates an existing rax_mon_entity, rax_mon_check, and rax_mon_notification_plan with diff --git a/plugins/modules/rax_mon_notification.py b/plugins/modules/rax_mon_notification.py index c26b0315db..73bfd1a78f 100644 --- a/plugins/modules/rax_mon_notification.py +++ b/plugins/modules/rax_mon_notification.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: rax_mon_notification -short_description: Create or delete a Rackspace Cloud Monitoring notification. +short_description: Create or delete a Rackspace Cloud Monitoring notification description: - Create or delete a Rackspace Cloud Monitoring notification that specifies a channel that can be used to communicate alarms, such as email, webhooks, or diff --git a/plugins/modules/rax_network.py b/plugins/modules/rax_network.py index 02de3ce011..edb7773b72 100644 --- a/plugins/modules/rax_network.py +++ b/plugins/modules/rax_network.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: rax_network -short_description: create / delete an isolated network in Rackspace Public Cloud +short_description: Create / delete an isolated network in Rackspace Public Cloud description: - creates / deletes a Rackspace Public Cloud isolated network. options: diff --git a/plugins/modules/rax_queue.py b/plugins/modules/rax_queue.py index 366c1c77e3..e053f3266d 100644 --- a/plugins/modules/rax_queue.py +++ b/plugins/modules/rax_queue.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: rax_queue -short_description: create / delete a queue in Rackspace Public Cloud +short_description: Create / delete a queue in Rackspace Public Cloud description: - creates / deletes a Rackspace Public Cloud queue. options: diff --git a/plugins/modules/rundeck_acl_policy.py b/plugins/modules/rundeck_acl_policy.py index 6168cb5b64..4830c44784 100644 --- a/plugins/modules/rundeck_acl_policy.py +++ b/plugins/modules/rundeck_acl_policy.py @@ -15,7 +15,7 @@ DOCUMENTATION = ''' --- module: rundeck_acl_policy -short_description: Manage Rundeck ACL policies. +short_description: Manage Rundeck ACL policies description: - Create, update and remove Rundeck ACL policies through HTTP API. author: "Loic Blot (@nerzhul)" diff --git a/plugins/modules/rundeck_project.py b/plugins/modules/rundeck_project.py index 88f4a78100..2039a00a02 100644 --- a/plugins/modules/rundeck_project.py +++ b/plugins/modules/rundeck_project.py @@ -17,7 +17,7 @@ DOCUMENTATION = ''' --- module: rundeck_project -short_description: Manage Rundeck projects. +short_description: Manage Rundeck projects description: - Create and remove Rundeck projects through HTTP API. author: "Loic Blot (@nerzhul)" diff --git a/plugins/modules/say.py b/plugins/modules/say.py index fe36b02d15..04b5027cae 100644 --- a/plugins/modules/say.py +++ b/plugins/modules/say.py @@ -12,7 +12,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: say -short_description: Makes a computer to speak. +short_description: Makes a computer to speak description: - makes a computer speak! Amuse your friends, annoy your coworkers! notes: diff --git a/plugins/modules/scaleway_image_info.py b/plugins/modules/scaleway_image_info.py index ee0134a52a..56ca689c38 100644 --- a/plugins/modules/scaleway_image_info.py +++ b/plugins/modules/scaleway_image_info.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = r''' --- module: scaleway_image_info -short_description: Gather information about the Scaleway images available. +short_description: Gather information about the Scaleway images available description: - Gather information about the Scaleway images available. author: diff --git a/plugins/modules/scaleway_ip_info.py b/plugins/modules/scaleway_ip_info.py index d8725894e6..1fd4be5898 100644 --- a/plugins/modules/scaleway_ip_info.py +++ b/plugins/modules/scaleway_ip_info.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = r''' --- module: scaleway_ip_info -short_description: Gather information about the Scaleway ips available. +short_description: Gather information about the Scaleway ips available description: - Gather information about the Scaleway ips available. author: diff --git a/plugins/modules/scaleway_organization_info.py b/plugins/modules/scaleway_organization_info.py index aca8a0c43f..6e1f8df388 100644 --- a/plugins/modules/scaleway_organization_info.py +++ b/plugins/modules/scaleway_organization_info.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = r''' --- module: scaleway_organization_info -short_description: Gather information about the Scaleway organizations available. +short_description: Gather information about the Scaleway organizations available description: - Gather information about the Scaleway organizations available. author: diff --git a/plugins/modules/scaleway_security_group_info.py b/plugins/modules/scaleway_security_group_info.py index 7fd96fd067..fb28e87740 100644 --- a/plugins/modules/scaleway_security_group_info.py +++ b/plugins/modules/scaleway_security_group_info.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = r''' --- module: scaleway_security_group_info -short_description: Gather information about the Scaleway security groups available. +short_description: Gather information about the Scaleway security groups available description: - Gather information about the Scaleway security groups available. author: diff --git a/plugins/modules/scaleway_server_info.py b/plugins/modules/scaleway_server_info.py index 7a31882ef7..01e9410da8 100644 --- a/plugins/modules/scaleway_server_info.py +++ b/plugins/modules/scaleway_server_info.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = r''' --- module: scaleway_server_info -short_description: Gather information about the Scaleway servers available. +short_description: Gather information about the Scaleway servers available description: - Gather information about the Scaleway servers available. author: diff --git a/plugins/modules/scaleway_snapshot_info.py b/plugins/modules/scaleway_snapshot_info.py index 47cd14cee8..687f43c85b 100644 --- a/plugins/modules/scaleway_snapshot_info.py +++ b/plugins/modules/scaleway_snapshot_info.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = r''' --- module: scaleway_snapshot_info -short_description: Gather information about the Scaleway snapshots available. +short_description: Gather information about the Scaleway snapshots available description: - Gather information about the Scaleway snapshot available. author: diff --git a/plugins/modules/scaleway_volume_info.py b/plugins/modules/scaleway_volume_info.py index 369fadbe64..471845c43e 100644 --- a/plugins/modules/scaleway_volume_info.py +++ b/plugins/modules/scaleway_volume_info.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = r''' --- module: scaleway_volume_info -short_description: Gather information about the Scaleway volumes available. +short_description: Gather information about the Scaleway volumes available description: - Gather information about the Scaleway volumes available. author: diff --git a/plugins/modules/sl_vm.py b/plugins/modules/sl_vm.py index 56b3ccdd39..ca925c345f 100644 --- a/plugins/modules/sl_vm.py +++ b/plugins/modules/sl_vm.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: sl_vm -short_description: create or cancel a virtual instance in SoftLayer +short_description: Create or cancel a virtual instance in SoftLayer description: - Creates or cancels SoftLayer instances. - When created, optionally waits for it to be 'running'. diff --git a/plugins/modules/smartos_image_info.py b/plugins/modules/smartos_image_info.py index 0b5117fc45..37267d115a 100644 --- a/plugins/modules/smartos_image_info.py +++ b/plugins/modules/smartos_image_info.py @@ -12,7 +12,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: smartos_image_info -short_description: Get SmartOS image details. +short_description: Get SmartOS image details description: - Retrieve information about all installed images on SmartOS. - This module was called C(smartos_image_facts) before Ansible 2.9, returning C(ansible_facts). diff --git a/plugins/modules/spectrum_device.py b/plugins/modules/spectrum_device.py index c2bab55016..40093aa3a9 100644 --- a/plugins/modules/spectrum_device.py +++ b/plugins/modules/spectrum_device.py @@ -12,7 +12,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: spectrum_device -short_description: Creates/deletes devices in CA Spectrum. +short_description: Creates/deletes devices in CA Spectrum description: - This module allows you to create and delete devices in CA Spectrum U(https://www.ca.com/us/products/ca-spectrum.html). - Tested on CA Spectrum 9.4.2, 10.1.1 and 10.2.1 diff --git a/plugins/modules/spectrum_model_attrs.py b/plugins/modules/spectrum_model_attrs.py index 5a92802f5f..de771b0ad3 100644 --- a/plugins/modules/spectrum_model_attrs.py +++ b/plugins/modules/spectrum_model_attrs.py @@ -12,7 +12,7 @@ __metaclass__ = type DOCUMENTATION = r''' --- module: spectrum_model_attrs -short_description: Enforce a model's attributes in CA Spectrum. +short_description: Enforce a model's attributes in CA Spectrum description: - This module can be used to enforce a model's attributes in CA Spectrum. version_added: 2.5.0 diff --git a/plugins/modules/svc.py b/plugins/modules/svc.py index 2800c9d2bf..4d92892ce3 100644 --- a/plugins/modules/svc.py +++ b/plugins/modules/svc.py @@ -13,7 +13,7 @@ DOCUMENTATION = ''' module: svc author: - Brian Coca (@bcoca) -short_description: Manage daemontools services +short_description: Manage daemontools services description: - Controls daemontools services on remote hosts using the svc utility. options: diff --git a/plugins/modules/swupd.py b/plugins/modules/swupd.py index 4567709f48..a47dd667ae 100644 --- a/plugins/modules/swupd.py +++ b/plugins/modules/swupd.py @@ -13,7 +13,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: swupd -short_description: Manages updates and bundles in ClearLinux systems. +short_description: Manages updates and bundles in ClearLinux systems description: - Manages updates and bundles with the swupd bundle manager, which is used by the Clear Linux Project for Intel Architecture. diff --git a/plugins/modules/telegram.py b/plugins/modules/telegram.py index 499af4ef1a..4e89825120 100644 --- a/plugins/modules/telegram.py +++ b/plugins/modules/telegram.py @@ -16,7 +16,7 @@ author: - "Artem Feofanov (@tyouxa)" - "Nikolai Lomov (@lomserman)" -short_description: module for sending notifications via telegram +short_description: Send notifications via telegram description: - Send notifications via telegram bot, to a verified group or user. diff --git a/plugins/modules/twilio.py b/plugins/modules/twilio.py index 1934820fe3..6d22563d1c 100644 --- a/plugins/modules/twilio.py +++ b/plugins/modules/twilio.py @@ -12,7 +12,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: twilio -short_description: Sends a text message to a mobile phone through Twilio. +short_description: Sends a text message to a mobile phone through Twilio description: - Sends a text message to a phone number through the Twilio messaging API. notes: diff --git a/plugins/modules/utm_aaa_group.py b/plugins/modules/utm_aaa_group.py index cff1834c93..3d5cbc2007 100644 --- a/plugins/modules/utm_aaa_group.py +++ b/plugins/modules/utm_aaa_group.py @@ -15,7 +15,7 @@ module: utm_aaa_group author: - Johannes Brunswicker (@MatrixCrawler) -short_description: Create, update or destroy an aaa group object in Sophos UTM. +short_description: Create, update or destroy an aaa group object in Sophos UTM description: - Create, update or destroy an aaa group object in Sophos UTM. diff --git a/plugins/modules/utm_aaa_group_info.py b/plugins/modules/utm_aaa_group_info.py index a01dad92ac..8798fda7f3 100644 --- a/plugins/modules/utm_aaa_group_info.py +++ b/plugins/modules/utm_aaa_group_info.py @@ -17,7 +17,7 @@ module: utm_aaa_group_info author: - Johannes Brunswicker (@MatrixCrawler) -short_description: get info for reverse_proxy frontend entry in Sophos UTM +short_description: Get info for reverse_proxy frontend entry in Sophos UTM description: - get info for a reverse_proxy frontend entry in SOPHOS UTM. diff --git a/plugins/modules/utm_ca_host_key_cert.py b/plugins/modules/utm_ca_host_key_cert.py index 693f25964a..318bc1fd31 100644 --- a/plugins/modules/utm_ca_host_key_cert.py +++ b/plugins/modules/utm_ca_host_key_cert.py @@ -16,7 +16,7 @@ module: utm_ca_host_key_cert author: - Stephan Schwarz (@stearz) -short_description: create, update or destroy ca host_key_cert entry in Sophos UTM +short_description: Create, update or destroy ca host_key_cert entry in Sophos UTM description: - Create, update or destroy a ca host_key_cert entry in SOPHOS UTM. diff --git a/plugins/modules/utm_dns_host.py b/plugins/modules/utm_dns_host.py index af91e2433b..3a1744651a 100644 --- a/plugins/modules/utm_dns_host.py +++ b/plugins/modules/utm_dns_host.py @@ -15,7 +15,7 @@ module: utm_dns_host author: - Johannes Brunswicker (@MatrixCrawler) -short_description: create, update or destroy dns entry in Sophos UTM +short_description: Create, update or destroy dns entry in Sophos UTM description: - Create, update or destroy a dns entry in SOPHOS UTM. diff --git a/plugins/modules/utm_proxy_auth_profile.py b/plugins/modules/utm_proxy_auth_profile.py index aab426cc03..0c53a92380 100644 --- a/plugins/modules/utm_proxy_auth_profile.py +++ b/plugins/modules/utm_proxy_auth_profile.py @@ -16,7 +16,7 @@ module: utm_proxy_auth_profile author: - Stephan Schwarz (@stearz) -short_description: create, update or destroy reverse_proxy auth_profile entry in Sophos UTM +short_description: Create, update or destroy reverse_proxy auth_profile entry in Sophos UTM description: - Create, update or destroy a reverse_proxy auth_profile entry in SOPHOS UTM. diff --git a/plugins/modules/utm_proxy_frontend.py b/plugins/modules/utm_proxy_frontend.py index 8f5a1e8686..127c7d4d43 100644 --- a/plugins/modules/utm_proxy_frontend.py +++ b/plugins/modules/utm_proxy_frontend.py @@ -16,7 +16,7 @@ module: utm_proxy_frontend author: - Johannes Brunswicker (@MatrixCrawler) -short_description: create, update or destroy reverse_proxy frontend entry in Sophos UTM +short_description: Create, update or destroy reverse_proxy frontend entry in Sophos UTM description: - Create, update or destroy a reverse_proxy frontend entry in Sophos UTM. diff --git a/plugins/modules/utm_proxy_frontend_info.py b/plugins/modules/utm_proxy_frontend_info.py index 0b8e124379..65faecfbc8 100644 --- a/plugins/modules/utm_proxy_frontend_info.py +++ b/plugins/modules/utm_proxy_frontend_info.py @@ -16,7 +16,7 @@ module: utm_proxy_frontend_info author: - Johannes Brunswicker (@MatrixCrawler) -short_description: create, update or destroy reverse_proxy frontend entry in Sophos UTM +short_description: Create, update or destroy reverse_proxy frontend entry in Sophos UTM description: - Create, update or destroy a reverse_proxy frontend entry in SOPHOS UTM. diff --git a/plugins/modules/utm_proxy_location.py b/plugins/modules/utm_proxy_location.py index c6ff1bd26b..0efeea5a27 100644 --- a/plugins/modules/utm_proxy_location.py +++ b/plugins/modules/utm_proxy_location.py @@ -16,7 +16,7 @@ module: utm_proxy_location author: - Johannes Brunswicker (@MatrixCrawler) -short_description: create, update or destroy reverse_proxy location entry in Sophos UTM +short_description: Create, update or destroy reverse_proxy location entry in Sophos UTM description: - Create, update or destroy a reverse_proxy location entry in SOPHOS UTM. diff --git a/plugins/modules/utm_proxy_location_info.py b/plugins/modules/utm_proxy_location_info.py index 0e7b165903..4b502df296 100644 --- a/plugins/modules/utm_proxy_location_info.py +++ b/plugins/modules/utm_proxy_location_info.py @@ -16,7 +16,7 @@ module: utm_proxy_location_info author: - Johannes Brunswicker (@MatrixCrawler) -short_description: create, update or destroy reverse_proxy location entry in Sophos UTM +short_description: Create, update or destroy reverse_proxy location entry in Sophos UTM description: - Create, update or destroy a reverse_proxy location entry in SOPHOS UTM. diff --git a/plugins/modules/vertica_configuration.py b/plugins/modules/vertica_configuration.py index f3ac067d0f..553630da39 100644 --- a/plugins/modules/vertica_configuration.py +++ b/plugins/modules/vertica_configuration.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: vertica_configuration -short_description: Updates Vertica configuration parameters. +short_description: Updates Vertica configuration parameters description: - Updates Vertica configuration parameters. options: diff --git a/plugins/modules/vertica_info.py b/plugins/modules/vertica_info.py index a51187de1d..3106be3b38 100644 --- a/plugins/modules/vertica_info.py +++ b/plugins/modules/vertica_info.py @@ -12,7 +12,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: vertica_info -short_description: Gathers Vertica database facts. +short_description: Gathers Vertica database facts description: - Gathers Vertica database information. - This module was called C(vertica_facts) before Ansible 2.9, returning C(ansible_facts). diff --git a/plugins/modules/vertica_role.py b/plugins/modules/vertica_role.py index e9f2ef34df..dde9919511 100644 --- a/plugins/modules/vertica_role.py +++ b/plugins/modules/vertica_role.py @@ -12,7 +12,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: vertica_role -short_description: Adds or removes Vertica database roles and assigns roles to them. +short_description: Adds or removes Vertica database roles and assigns roles to them description: - Adds or removes Vertica database role and, optionally, assign other roles. options: diff --git a/plugins/modules/vertica_schema.py b/plugins/modules/vertica_schema.py index b1bdf944b9..3c4071473a 100644 --- a/plugins/modules/vertica_schema.py +++ b/plugins/modules/vertica_schema.py @@ -12,7 +12,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: vertica_schema -short_description: Adds or removes Vertica database schema and roles. +short_description: Adds or removes Vertica database schema and roles description: - Adds or removes Vertica database schema and, optionally, roles with schema access privileges. diff --git a/plugins/modules/vertica_user.py b/plugins/modules/vertica_user.py index ff2f02d0cc..89f1cb92a3 100644 --- a/plugins/modules/vertica_user.py +++ b/plugins/modules/vertica_user.py @@ -11,7 +11,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: vertica_user -short_description: Adds or removes Vertica database users and assigns roles. +short_description: Adds or removes Vertica database users and assigns roles description: - Adds or removes Vertica database user and, optionally, assigns roles. - A user will not be removed until all the dependencies have been dropped. diff --git a/plugins/modules/vmadm.py b/plugins/modules/vmadm.py index 3bc016d679..6b4490ca57 100644 --- a/plugins/modules/vmadm.py +++ b/plugins/modules/vmadm.py @@ -12,7 +12,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: vmadm -short_description: Manage SmartOS virtual machines and zones. +short_description: Manage SmartOS virtual machines and zones description: - Manage SmartOS virtual machines through vmadm(1M). author: Jasper Lievisse Adriaanse (@jasperla) diff --git a/plugins/modules/xenserver_facts.py b/plugins/modules/xenserver_facts.py index 10ec3cd50f..59c457c7f7 100644 --- a/plugins/modules/xenserver_facts.py +++ b/plugins/modules/xenserver_facts.py @@ -12,7 +12,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: xenserver_facts -short_description: get facts reported on xenserver +short_description: Get facts reported on xenserver description: - Reads data out of XenAPI, can be used instead of multiple xe commands. author: diff --git a/plugins/modules/zfs_facts.py b/plugins/modules/zfs_facts.py index 734659a7ea..bb4530c473 100644 --- a/plugins/modules/zfs_facts.py +++ b/plugins/modules/zfs_facts.py @@ -12,7 +12,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: zfs_facts -short_description: Gather facts about ZFS datasets. +short_description: Gather facts about ZFS datasets description: - Gather facts from ZFS dataset properties. author: Adam Števko (@xen0l) diff --git a/plugins/modules/zpool_facts.py b/plugins/modules/zpool_facts.py index ec5fdc4442..2477a920b0 100644 --- a/plugins/modules/zpool_facts.py +++ b/plugins/modules/zpool_facts.py @@ -12,7 +12,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- module: zpool_facts -short_description: Gather facts about ZFS pools. +short_description: Gather facts about ZFS pools description: - Gather facts from ZFS pool properties. author: Adam Števko (@xen0l) From 7610501c66a704214091aa0ba89065a53719f9cd Mon Sep 17 00:00:00 2001 From: Tong He <68936428+unnecessary-username@users.noreply.github.com> Date: Fri, 11 Nov 2022 04:18:01 +0800 Subject: [PATCH 0034/1810] Fix a logical flaw when deleting a build in the jenkins_build module (#5514) * Fix the logical flaw when deleting a build in the jenkins_build module. * Fix the logical flaw when deleting a Jenkins build in the jenkins_build module. * Adding changelogs. * Update tests/unit/plugins/modules/test_jenkins_build.py Co-authored-by: Felix Fontein * Attempt to mock the exception classes. * Remedy the CI issues when mocking the exception classes. * Assuming a way to mock the get_build_status function. * Near to the feasible approach. * Calls the correct class when unit testing. * Fix sending wrong arguments when unit testing. * Directly assign the argument value in the unit testing. * Fix errors calling different classes. Co-authored-by: Felix Fontein --- ...gical-flaw-when-deleting-jenkins-build.yml | 2 + plugins/modules/jenkins_build.py | 10 +++- .../plugins/modules/test_jenkins_build.py | 48 +++++++++++++++++-- 3 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/5514-fix-logical-flaw-when-deleting-jenkins-build.yml diff --git a/changelogs/fragments/5514-fix-logical-flaw-when-deleting-jenkins-build.yml b/changelogs/fragments/5514-fix-logical-flaw-when-deleting-jenkins-build.yml new file mode 100644 index 0000000000..818ee95146 --- /dev/null +++ b/changelogs/fragments/5514-fix-logical-flaw-when-deleting-jenkins-build.yml @@ -0,0 +1,2 @@ +bugfixes: + - jenkins_build - fix the logical flaw when deleting a Jenkins build (https://github.com/ansible-collections/community.general/pull/5514). \ No newline at end of file diff --git a/plugins/modules/jenkins_build.py b/plugins/modules/jenkins_build.py index 09304ccfbc..b02027f229 100644 --- a/plugins/modules/jenkins_build.py +++ b/plugins/modules/jenkins_build.py @@ -183,7 +183,10 @@ class JenkinsBuild: try: response = self.server.get_build_info(self.name, self.build_number) return response - + except jenkins.JenkinsException as e: + response = {} + response["result"] = "ABSENT" + return response except Exception as e: self.module.fail_json(msg='Unable to fetch build information, %s' % to_native(e), exception=traceback.format_exc()) @@ -231,7 +234,10 @@ class JenkinsBuild: if self.state == "stopped" and build_status['result'] == "ABORTED": result['changed'] = True result['build_info'] = build_status - elif build_status['result'] == "SUCCESS": + elif self.state == "absent" and build_status['result'] == "ABSENT": + result['changed'] = True + result['build_info'] = build_status + elif self.state != "absent" and build_status['result'] == "SUCCESS": result['changed'] = True result['build_info'] = build_status else: diff --git a/tests/unit/plugins/modules/test_jenkins_build.py b/tests/unit/plugins/modules/test_jenkins_build.py index adee2fce99..44c6307ac9 100644 --- a/tests/unit/plugins/modules/test_jenkins_build.py +++ b/tests/unit/plugins/modules/test_jenkins_build.py @@ -43,6 +43,28 @@ def fail_json(*args, **kwargs): raise AnsibleFailJson(kwargs) +class jenkins: + class JenkinsException(Exception): + pass + + class NotFoundException(JenkinsException): + pass + + +class JenkinsBuildMock(): + def get_build_status(self): + try: + instance = JenkinsMock() + response = JenkinsMock.get_build_info(instance, 'host-delete', 1234) + return response + except jenkins.JenkinsException as e: + response = {} + response["result"] = "ABSENT" + return response + except Exception as e: + fail_json(msg='Unable to fetch build information, {0}'.format(e)) + + class JenkinsMock(): def get_job_info(self, name): @@ -51,6 +73,8 @@ class JenkinsMock(): } def get_build_info(self, name, build_number): + if name == "host-delete": + raise jenkins.JenkinsException("job {0} number {1} does not exist".format(name, build_number)) return { "building": True, "result": "SUCCESS" @@ -83,7 +107,7 @@ class JenkinsMockIdempotent(): return None def delete_build(self, name, build_number): - return None + raise jenkins.NotFoundException("job {0} number {1} does not exist".format(name, build_number)) def stop_build(self, name, build_number): return None @@ -167,13 +191,31 @@ class TestJenkinsBuild(unittest.TestCase): @patch('ansible_collections.community.general.plugins.modules.jenkins_build.test_dependencies') @patch('ansible_collections.community.general.plugins.modules.jenkins_build.JenkinsBuild.get_jenkins_connection') - def test_module_delete_build(self, jenkins_connection, test_deps): + @patch('ansible_collections.community.general.plugins.modules.jenkins_build.JenkinsBuild.get_build_status') + def test_module_delete_build(self, build_status, jenkins_connection, test_deps): test_deps.return_value = None jenkins_connection.return_value = JenkinsMock() + build_status.return_value = JenkinsBuildMock().get_build_status() with self.assertRaises(AnsibleExitJson): set_module_args({ - "name": "host-check", + "name": "host-delete", + "build_number": "1234", + "state": "absent", + "user": "abc", + "token": "xyz" + }) + jenkins_build.main() + + @patch('ansible_collections.community.general.plugins.modules.jenkins_build.test_dependencies') + @patch('ansible_collections.community.general.plugins.modules.jenkins_build.JenkinsBuild.get_jenkins_connection') + def test_module_delete_build_again(self, jenkins_connection, test_deps): + test_deps.return_value = None + jenkins_connection.return_value = JenkinsMockIdempotent() + + with self.assertRaises(AnsibleFailJson): + set_module_args({ + "name": "host-delete", "build_number": "1234", "state": "absent", "user": "abc", From bc0f99386b509ca2a6bb5ddae5ef79bf0e4b3e8d Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Fri, 11 Nov 2022 09:18:52 +1300 Subject: [PATCH 0035/1810] xfconf: prune deprecated facts-generation code (#5502) * xfconf: prune deprecated facts-generatin code * add changelog fragment * adjust changelog fragment * Update changelogs/fragments/5502-xfconf-facts-deprecation.yml Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein --- changelogs/fragments/5502-xfconf-facts-deprecation.yml | 6 ++++++ plugins/modules/xfconf.py | 7 ++----- 2 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/5502-xfconf-facts-deprecation.yml diff --git a/changelogs/fragments/5502-xfconf-facts-deprecation.yml b/changelogs/fragments/5502-xfconf-facts-deprecation.yml new file mode 100644 index 0000000000..776d852700 --- /dev/null +++ b/changelogs/fragments/5502-xfconf-facts-deprecation.yml @@ -0,0 +1,6 @@ +removed_features: + - > + xfconf - generating facts was deprecated in community.general 3.0.0, + however two factoids, ``previous_value`` and ``type`` continued to be generated by mistake. This behaviour + has been removed and ``xfconf`` generate no facts whatsoever + (https://github.com/ansible-collections/community.general/pull/5502). diff --git a/plugins/modules/xfconf.py b/plugins/modules/xfconf.py index c231a47484..6776ef888e 100644 --- a/plugins/modules/xfconf.py +++ b/plugins/modules/xfconf.py @@ -195,15 +195,12 @@ class XFConfProperty(StateModuleHelper): default_state = 'present' - def update_xfconf_output(self, **kwargs): - self.update_vars(meta={"output": True, "fact": True}, **kwargs) - def __init_module__(self): self.runner = xfconf_runner(self.module) self.does_not = 'Property "{0}" does not exist on channel "{1}".'.format(self.vars.property, self.vars.channel) - self.vars.set('previous_value', self._get(), fact=True) - self.vars.set('type', self.vars.value_type, fact=True) + self.vars.set('previous_value', self._get()) + self.vars.set('type', self.vars.value_type) self.vars.meta('value').set(initial_value=self.vars.previous_value) if self.vars.disable_facts is False: From 27a4ffc2931e5ccdd3a2d4d09260351d1050c4f9 Mon Sep 17 00:00:00 2001 From: Doc_Tiebeau Date: Sun, 13 Nov 2022 21:03:30 +0100 Subject: [PATCH 0036/1810] Fix: Duplicate vmid in proxmox_disk module #5492 (#5493) https://github.com/ansible-collections/community.general/issues/5492 --- plugins/modules/proxmox_disk.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/proxmox_disk.py b/plugins/modules/proxmox_disk.py index 7a39d38d05..8f55e2d130 100644 --- a/plugins/modules/proxmox_disk.py +++ b/plugins/modules/proxmox_disk.py @@ -725,7 +725,7 @@ def main(): actual_size = disk_config['size'] if size == actual_size: module.exit_json(changed=False, vmid=vmid, msg="Disk %s is already %s size" % (disk, size)) - proxmox.proxmox_api.nodes(vm['node']).qemu(vmid).resize.set(vmid=vmid, disk=disk, size=size) + proxmox.proxmox_api.nodes(vm['node']).qemu(vmid).resize.set(disk=disk, size=size) module.exit_json(changed=True, vmid=vmid, msg="Disk %s resized in VM %s" % (disk, vmid)) except Exception as e: module.fail_json(msg="Failed to resize disk %s in VM %s with exception: %s" % (disk, vmid, str(e))) From 672385309ce68912201ed1bd34bf74bc0cd25112 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sun, 13 Nov 2022 21:06:11 +0100 Subject: [PATCH 0037/1810] Add changelog fragment. --- changelogs/fragments/5493-proxmox.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelogs/fragments/5493-proxmox.yml diff --git a/changelogs/fragments/5493-proxmox.yml b/changelogs/fragments/5493-proxmox.yml new file mode 100644 index 0000000000..a14b7767e6 --- /dev/null +++ b/changelogs/fragments/5493-proxmox.yml @@ -0,0 +1,2 @@ +bugfixes: + - "proxmox_disk - avoid duplicate ``vmid`` reference (https://github.com/ansible-collections/community.general/issues/5492, https://github.com/ansible-collections/community.general/pull/5493)." From 60c8b9a67fe0788c770db69641ca6552beb2f522 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Tue, 15 Nov 2022 08:12:09 +0100 Subject: [PATCH 0038/1810] dependent lookup: prevent deprecation warning with ansible-core 2.14 (#5543) * Prevent deprecation warning. * Improve naming and add comment. --- changelogs/fragments/5543-dependent-template.yml | 2 ++ plugins/lookup/dependent.py | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/5543-dependent-template.yml diff --git a/changelogs/fragments/5543-dependent-template.yml b/changelogs/fragments/5543-dependent-template.yml new file mode 100644 index 0000000000..63e8f67d63 --- /dev/null +++ b/changelogs/fragments/5543-dependent-template.yml @@ -0,0 +1,2 @@ +bugfixes: + - "dependent lookup plugin - avoid warning on deprecated parameter for ``Templar.template()`` (https://github.com/ansible-collections/community.general/pull/5543)." diff --git a/plugins/lookup/dependent.py b/plugins/lookup/dependent.py index b44a9208af..54714344eb 100644 --- a/plugins/lookup/dependent.py +++ b/plugins/lookup/dependent.py @@ -125,8 +125,16 @@ from ansible.errors import AnsibleLookupError from ansible.module_utils.common._collections_compat import Mapping, Sequence from ansible.module_utils.six import string_types from ansible.plugins.lookup import LookupBase +from ansible.release import __version__ as ansible_version from ansible.template import Templar +from ansible_collections.community.general.plugins.module_utils.version import LooseVersion + + +# Whether Templar has a cache, which can be controlled by Templar.template()'s cache option. +# The cache was removed for ansible-core 2.14 (https://github.com/ansible/ansible/pull/78419) +_TEMPLAR_HAS_TEMPLATE_CACHE = LooseVersion(ansible_version) < LooseVersion('2.14.0') + class LookupModule(LookupBase): def __evaluate(self, expression, templar, variables): @@ -136,7 +144,10 @@ class LookupModule(LookupBase): ``variables`` are the variables to use. """ templar.available_variables = variables or {} - return templar.template("{0}{1}{2}".format("{{", expression, "}}"), cache=False) + expression = "{0}{1}{2}".format("{{", expression, "}}") + if _TEMPLAR_HAS_TEMPLATE_CACHE: + return templar.template(expression, cache=False) + return templar.template(expression) def __process(self, result, terms, index, current, templar, variables): """Fills ``result`` list with evaluated items. From 6a6bbb65770571d17ceab304c44b41eb6ef98052 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Tue, 15 Nov 2022 08:13:00 +0100 Subject: [PATCH 0039/1810] Clean up code-scanning workflow. (#5546) --- .github/workflows/codeql-analysis.yml | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index f7ab9450cc..2d93f5efef 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -24,15 +24,6 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v3 - with: - # We must fetch at least the immediate parents so that if this is - # a pull request then we can checkout the head. - fetch-depth: 2 - - # If this run was triggered by a pull request event, then checkout - # the head of the pull request instead of the merge commit. - - run: git checkout HEAD^2 - if: ${{ github.event_name == 'pull_request' }} # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL @@ -41,21 +32,5 @@ jobs: # with: # languages: go, javascript, csharp, python, cpp, java - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - # ℹ️ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v2 From 6c7e9116e1abba6c125e7f05cf7fd0e8042a1f43 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Wed, 16 Nov 2022 09:02:45 +1300 Subject: [PATCH 0040/1810] gconftool2: refactored to use ModuleHelper + CmdRunner (#5545) * gconftool2: refactored to use ModuleHelper + CmdRunner * add changelog fragment * removed old code commented out --- .../fragments/5545-gconftool-cmd-runner.yml | 2 + plugins/module_utils/gconftool2.py | 23 ++- plugins/modules/gconftool2.py | 173 +++++------------- plugins/modules/gconftool2_info.py | 4 +- tests/sanity/ignore-2.11.txt | 2 +- tests/sanity/ignore-2.12.txt | 2 +- tests/sanity/ignore-2.13.txt | 2 +- tests/sanity/ignore-2.14.txt | 2 +- tests/sanity/ignore-2.15.txt | 2 +- tests/unit/plugins/modules/test_gconftool2.py | 116 ++++++++++++ 10 files changed, 186 insertions(+), 142 deletions(-) create mode 100644 changelogs/fragments/5545-gconftool-cmd-runner.yml create mode 100644 tests/unit/plugins/modules/test_gconftool2.py diff --git a/changelogs/fragments/5545-gconftool-cmd-runner.yml b/changelogs/fragments/5545-gconftool-cmd-runner.yml new file mode 100644 index 0000000000..a41d5c3657 --- /dev/null +++ b/changelogs/fragments/5545-gconftool-cmd-runner.yml @@ -0,0 +1,2 @@ +minor_changes: + - gconftool2 - refactor using ``ModuleHelper`` and ``CmdRunner`` (https://github.com/ansible-collections/community.general/pull/5545). diff --git a/plugins/module_utils/gconftool2.py b/plugins/module_utils/gconftool2.py index cd9de57695..e90c3fb2cb 100644 --- a/plugins/module_utils/gconftool2.py +++ b/plugins/module_utils/gconftool2.py @@ -6,7 +6,14 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type -from ansible_collections.community.general.plugins.module_utils.cmd_runner import CmdRunner, cmd_runner_fmt as fmt +from ansible_collections.community.general.plugins.module_utils.cmd_runner import CmdRunner, cmd_runner_fmt + + +_state_map = { + "present": "--set", + "absent": "--unset", + "get": "--get", +} def gconftool2_runner(module, **kwargs): @@ -14,14 +21,12 @@ def gconftool2_runner(module, **kwargs): module, command='gconftool-2', arg_formats=dict( - key=fmt.as_list(), - value_type=fmt.as_opt_val("--type"), - value=fmt.as_list(), - direct=fmt.as_bool("--direct"), - config_source=fmt.as_opt_val("--config-source"), - get=fmt.as_bool("--get"), - set_arg=fmt.as_bool("--set"), - unset=fmt.as_bool("--unset"), + state=cmd_runner_fmt.as_map(_state_map), + key=cmd_runner_fmt.as_list(), + value_type=cmd_runner_fmt.as_opt_val("--type"), + value=cmd_runner_fmt.as_list(), + direct=cmd_runner_fmt.as_bool("--direct"), + config_source=cmd_runner_fmt.as_opt_val("--config-source"), ), **kwargs ) diff --git a/plugins/modules/gconftool2.py b/plugins/modules/gconftool2.py index 931b43d76c..a3ac8bb8f1 100644 --- a/plugins/modules/gconftool2.py +++ b/plugins/modules/gconftool2.py @@ -83,75 +83,17 @@ RETURN = ''' ... ''' -from ansible.module_utils.basic import AnsibleModule +from ansible_collections.community.general.plugins.module_utils.module_helper import StateModuleHelper +from ansible_collections.community.general.plugins.module_utils.gconftool2 import gconftool2_runner -class GConf2Preference(object): - def __init__(self, ansible, key, value_type, value, - direct=False, config_source=""): - self.ansible = ansible - self.key = key - self.value_type = value_type - self.value = value - self.config_source = config_source - self.direct = direct - - def value_already_set(self): - return False - - def call(self, call_type, fail_onerr=True): - """ Helper function to perform gconftool-2 operations """ - config_source = [] - direct = [] - changed = False - out = '' - - # If the configuration source is different from the default, create - # the argument - if self.config_source is not None and len(self.config_source) > 0: - config_source = ["--config-source", self.config_source] - - # If direct is true, create the argument - if self.direct: - direct = ["--direct"] - - # Execute the call - cmd = ["gconftool-2"] - try: - # If the call is "get", then we don't need as many parameters and - # we can ignore some - if call_type == 'get': - self.ansible.deprecate( - msg="State 'get' is deprecated. Please use the module community.general.gconftool2_info instead", - version="8.0.0", collection_name="community.general" - ) - cmd.extend(["--get", self.key]) - # Otherwise, we will use all relevant parameters - elif call_type == 'set': - cmd.extend(direct) - cmd.extend(config_source) - cmd.extend(["--type", self.value_type, "--{3}".format(call_type), self.key, self.value]) - elif call_type == 'unset': - cmd.extend(["--unset", self.key]) - - # Start external command - rc, out, err = self.ansible.run_command(cmd) - - if err and fail_onerr: - self.ansible.fail_json(msg='gconftool-2 failed with ' - 'error: %s' % (str(err))) - else: - changed = True - - except OSError as exception: - self.ansible.fail_json(msg='gconftool-2 failed with exception: ' - '%s' % exception) - return changed, out.rstrip() - - -def main(): - # Setup the Ansible module - module = AnsibleModule( +class GConftool(StateModuleHelper): + change_params = 'value', + diff_params = 'value', + output_params = ('key', 'value_type') + facts_params = ('key', 'value_type') + facts_name = 'gconftool2' + module = dict( argument_spec=dict( key=dict(type='str', required=True, no_log=False), value_type=dict(type='str', choices=['bool', 'float', 'int', 'string']), @@ -160,75 +102,54 @@ def main(): direct=dict(type='bool', default=False), config_source=dict(type='str'), ), - supports_check_mode=True + required_if=[ + ('state', 'present', ['value', 'value_type']), + ('state', 'absent', ['value']), + ('direct', True, ['config_source']), + ], + supports_check_mode=True, ) - state_values = {"present": "set", "absent": "unset", "get": "get"} + def __init_module__(self): + self.runner = gconftool2_runner(self.module, check_rc=True) + if self.vars.state != "get": + if not self.vars.direct and self.vars.config_source is not None: + self.module.fail_json(msg='If the "config_source" is specified then "direct" must be "true"') - # Assign module values to dictionary values - key = module.params['key'] - value_type = module.params['value_type'] - if module.params['value'].lower() == "true": - value = "true" - elif module.params['value'] == "false": - value = "false" - else: - value = module.params['value'] + self.vars.set('previous_value', self._get(), fact=True) + self.vars.set('value_type', self.vars.value_type) + self.vars.set_meta('value', initial_value=self.vars.previous_value) + self.vars.set('playbook_value', self.vars.value, fact=True) - state = state_values[module.params['state']] - direct = module.params['direct'] - config_source = module.params['config_source'] + def _make_process(self, fail_on_err): + def process(rc, out, err): + if err and fail_on_err: + self.ansible.fail_json(msg='gconftool-2 failed with error: %s' % (str(err))) + self.vars.value = out.rstrip() + return self.vars.value + return process - # Initialize some variables for later - change = False - new_value = '' + def _get(self): + return self.runner("state key", output_process=self._make_process(False)).run(state="get") - if state != "get": - if value is None or value == "": - module.fail_json(msg='State %s requires "value" to be set' - % str(state)) - elif value_type is None or value_type == "": - module.fail_json(msg='State %s requires "value_type" to be set' - % str(state)) + def state_get(self): + self.deprecate( + msg="State 'get' is deprecated. Please use the module community.general.gconftool2_info instead", + version="8.0.0", collection_name="community.general" + ) - if direct and config_source is None: - module.fail_json(msg='If "direct" is "true" then the ' + - '"config_source" must be specified') - elif not direct and config_source is not None: - module.fail_json(msg='If the "config_source" is specified ' + - 'then "direct" must be "true"') + def state_absent(self): + with self.runner("state key", output_process=self._make_process(False)) as ctx: + ctx.run() + self.vars.set('new_value', None, fact=True) - # Create a gconf2 preference - gconf_pref = GConf2Preference(module, key, value_type, - value, direct, config_source) - # Now we get the current value, if not found don't fail - dummy, current_value = gconf_pref.call("get", fail_onerr=False) + def state_present(self): + with self.runner("direct config_source value_type state key value", output_process=self._make_process(True)) as ctx: + self.vars.set('new_value', ctx.run(), fact=True) - # Check if the current value equals the value we want to set. If not, make - # a change - if current_value != value: - # If check mode, we know a change would have occurred. - if module.check_mode: - # So we will set the change to True - change = True - # And set the new_value to the value that would have been set - new_value = value - # If not check mode make the change. - else: - change, new_value = gconf_pref.call(state) - # If the value we want to set is the same as the current_value, we will - # set the new_value to the current_value for reporting - else: - new_value = current_value - facts = dict(gconftool2={'changed': change, - 'key': key, - 'value_type': value_type, - 'new_value': new_value, - 'previous_value': current_value, - 'playbook_value': module.params['value']}) - - module.exit_json(changed=change, ansible_facts=facts) +def main(): + GConftool.execute() if __name__ == '__main__': diff --git a/plugins/modules/gconftool2_info.py b/plugins/modules/gconftool2_info.py index f9231104d4..282065b95e 100644 --- a/plugins/modules/gconftool2_info.py +++ b/plugins/modules/gconftool2_info.py @@ -65,8 +65,8 @@ class GConftoolInfo(ModuleHelper): self.runner = gconftool2_runner(self.module, check_rc=True) def __run__(self): - with self.runner.context(args_order=["get", "key"]) as ctx: - rc, out, err = ctx.run(get=True) + with self.runner.context(args_order=["state", "key"]) as ctx: + rc, out, err = ctx.run(state="get") self.vars.value = None if err and not out else out.rstrip() diff --git a/tests/sanity/ignore-2.11.txt b/tests/sanity/ignore-2.11.txt index 603981df04..f8efbcfbee 100644 --- a/tests/sanity/ignore-2.11.txt +++ b/tests/sanity/ignore-2.11.txt @@ -7,7 +7,7 @@ plugins/modules/consul.py validate-modules:doc-missing-type plugins/modules/consul.py validate-modules:undocumented-parameter plugins/modules/consul_session.py validate-modules:parameter-state-invalid-choice -plugins/modules/gconftool2.py validate-modules:parameter-state-invalid-choice +plugins/modules/gconftool2.py validate-modules:parameter-state-invalid-choice # state=get - removed in 8.0.0 plugins/modules/iptables_state.py validate-modules:undocumented-parameter plugins/modules/jenkins_plugin.py use-argspec-type-path plugins/modules/lxc_container.py validate-modules:use-run-command-not-popen diff --git a/tests/sanity/ignore-2.12.txt b/tests/sanity/ignore-2.12.txt index 778f25ae53..adb6d868a9 100644 --- a/tests/sanity/ignore-2.12.txt +++ b/tests/sanity/ignore-2.12.txt @@ -2,7 +2,7 @@ plugins/modules/consul.py validate-modules:doc-missing-type plugins/modules/consul.py validate-modules:undocumented-parameter plugins/modules/consul_session.py validate-modules:parameter-state-invalid-choice -plugins/modules/gconftool2.py validate-modules:parameter-state-invalid-choice +plugins/modules/gconftool2.py validate-modules:parameter-state-invalid-choice # state=get - removed in 8.0.0 plugins/modules/iptables_state.py validate-modules:undocumented-parameter plugins/modules/jenkins_plugin.py use-argspec-type-path plugins/modules/lxc_container.py validate-modules:use-run-command-not-popen diff --git a/tests/sanity/ignore-2.13.txt b/tests/sanity/ignore-2.13.txt index 778f25ae53..adb6d868a9 100644 --- a/tests/sanity/ignore-2.13.txt +++ b/tests/sanity/ignore-2.13.txt @@ -2,7 +2,7 @@ plugins/modules/consul.py validate-modules:doc-missing-type plugins/modules/consul.py validate-modules:undocumented-parameter plugins/modules/consul_session.py validate-modules:parameter-state-invalid-choice -plugins/modules/gconftool2.py validate-modules:parameter-state-invalid-choice +plugins/modules/gconftool2.py validate-modules:parameter-state-invalid-choice # state=get - removed in 8.0.0 plugins/modules/iptables_state.py validate-modules:undocumented-parameter plugins/modules/jenkins_plugin.py use-argspec-type-path plugins/modules/lxc_container.py validate-modules:use-run-command-not-popen diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt index 20f87d1af2..d670fe2282 100644 --- a/tests/sanity/ignore-2.14.txt +++ b/tests/sanity/ignore-2.14.txt @@ -2,7 +2,7 @@ plugins/modules/consul.py validate-modules:doc-missing-type plugins/modules/consul.py validate-modules:undocumented-parameter plugins/modules/consul_session.py validate-modules:parameter-state-invalid-choice -plugins/modules/gconftool2.py validate-modules:parameter-state-invalid-choice +plugins/modules/gconftool2.py validate-modules:parameter-state-invalid-choice # state=get - removed in 8.0.0 plugins/modules/homectl.py import-3.11 # Uses deprecated stdlib library 'crypt' plugins/modules/iptables_state.py validate-modules:undocumented-parameter plugins/modules/jenkins_plugin.py use-argspec-type-path diff --git a/tests/sanity/ignore-2.15.txt b/tests/sanity/ignore-2.15.txt index 20f87d1af2..d670fe2282 100644 --- a/tests/sanity/ignore-2.15.txt +++ b/tests/sanity/ignore-2.15.txt @@ -2,7 +2,7 @@ plugins/modules/consul.py validate-modules:doc-missing-type plugins/modules/consul.py validate-modules:undocumented-parameter plugins/modules/consul_session.py validate-modules:parameter-state-invalid-choice -plugins/modules/gconftool2.py validate-modules:parameter-state-invalid-choice +plugins/modules/gconftool2.py validate-modules:parameter-state-invalid-choice # state=get - removed in 8.0.0 plugins/modules/homectl.py import-3.11 # Uses deprecated stdlib library 'crypt' plugins/modules/iptables_state.py validate-modules:undocumented-parameter plugins/modules/jenkins_plugin.py use-argspec-type-path diff --git a/tests/unit/plugins/modules/test_gconftool2.py b/tests/unit/plugins/modules/test_gconftool2.py new file mode 100644 index 0000000000..f01f15ef82 --- /dev/null +++ b/tests/unit/plugins/modules/test_gconftool2.py @@ -0,0 +1,116 @@ +# -*- coding: utf-8 -*- +# Copyright (c) Alexei Znamensky (russoz@gmail.com) +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import json + +from ansible_collections.community.general.plugins.modules import gconftool2 + +import pytest + +TESTED_MODULE = gconftool2.__name__ + + +@pytest.fixture +def patch_gconftool2(mocker): + """ + Function used for mocking some parts of redhat_subscription module + """ + mocker.patch('ansible_collections.community.general.plugins.module_utils.mh.module_helper.AnsibleModule.get_bin_path', + return_value='/testbin/gconftool-2') + + +TEST_CASES = [ + [ + {'state': 'get', 'key': '/desktop/gnome/background/picture_filename'}, + { + 'id': 'test_simple_element_get', + 'run_command.calls': [ + ( + ['/testbin/gconftool-2', '--get', '/desktop/gnome/background/picture_filename'], + {'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': True}, + (0, '100\n', '',), + ), + ], + 'new_value': '100', + } + ], + [ + {'state': 'get', 'key': '/desktop/gnome/background/picture_filename'}, + { + 'id': 'test_simple_element_get_not_found', + 'run_command.calls': [ + ( + ['/testbin/gconftool-2', '--get', '/desktop/gnome/background/picture_filename'], + {'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': True}, + (0, '', "No value set for `/desktop/gnome/background/picture_filename'\n",), + ), + ], + 'new_value': None, + } + ], + [ + {'state': 'present', 'key': '/desktop/gnome/background/picture_filename', 'value': '200', 'value_type': 'int'}, + { + 'id': 'test_simple_element_set', + 'run_command.calls': [ + ( + ['/testbin/gconftool-2', '--get', '/desktop/gnome/background/picture_filename'], + {'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': True}, + (0, '100\n', '',), + ), + ( + ['/testbin/gconftool-2', '--type', 'int', '--set', '/desktop/gnome/background/picture_filename', '200'], + {'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': True}, + (0, '200\n', '',), + ), + ], + 'new_value': '200', + } + ], +] +TEST_CASES_IDS = [item[1]['id'] for item in TEST_CASES] + + +@pytest.mark.parametrize('patch_ansible_module, testcase', + TEST_CASES, + ids=TEST_CASES_IDS, + indirect=['patch_ansible_module']) +@pytest.mark.usefixtures('patch_ansible_module') +def test_gconftool2(mocker, capfd, patch_gconftool2, testcase): + """ + Run unit tests for test cases listen in TEST_CASES + """ + + # Mock function used for running commands first + call_results = [item[2] for item in testcase['run_command.calls']] + mock_run_command = mocker.patch( + 'ansible_collections.community.general.plugins.module_utils.mh.module_helper.AnsibleModule.run_command', + side_effect=call_results) + + # Try to run test case + with pytest.raises(SystemExit): + gconftool2.main() + + out, err = capfd.readouterr() + results = json.loads(out) + print("testcase =\n%s" % testcase) + print("results =\n%s" % results) + + for conditional_test_result in ('value',): + if conditional_test_result in testcase: + assert conditional_test_result in results, "'{0}' not found in {1}".format(conditional_test_result, results) + assert results[conditional_test_result] == testcase[conditional_test_result], \ + "'{0}': '{1}' != '{2}'".format(conditional_test_result, results[conditional_test_result], testcase[conditional_test_result]) + + assert mock_run_command.call_count == len(testcase['run_command.calls']) + if mock_run_command.call_count: + call_args_list = [(item[0][0], item[1]) for item in mock_run_command.call_args_list] + expected_call_args_list = [(item[0], item[1]) for item in testcase['run_command.calls']] + print("call args list =\n%s" % call_args_list) + print("expected args list =\n%s" % expected_call_args_list) + assert call_args_list == expected_call_args_list From 9874462abb10a079cc45b88e778e33160a737253 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Wed, 16 Nov 2022 09:04:29 +1300 Subject: [PATCH 0041/1810] lxd_project: refactored os.path.expanduser() to module utils (#5549) * lxd_project: refactored os.path.expanduser() to module utils * add changelog fragment --- changelogs/fragments/5549-lxd-project-sanity.yml | 2 ++ plugins/module_utils/lxd.py | 12 ++++++++++-- plugins/modules/lxd_project.py | 8 +++++--- tests/sanity/ignore-2.11.txt | 1 - tests/sanity/ignore-2.12.txt | 1 - tests/sanity/ignore-2.13.txt | 1 - tests/sanity/ignore-2.14.txt | 1 - tests/sanity/ignore-2.15.txt | 1 - 8 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 changelogs/fragments/5549-lxd-project-sanity.yml diff --git a/changelogs/fragments/5549-lxd-project-sanity.yml b/changelogs/fragments/5549-lxd-project-sanity.yml new file mode 100644 index 0000000000..0a5e328e1c --- /dev/null +++ b/changelogs/fragments/5549-lxd-project-sanity.yml @@ -0,0 +1,2 @@ +minor_changes: + - lxd_project - refactored code out to module utils to clear sanity check (https://github.com/ansible-collections/community.general/pull/5549). diff --git a/plugins/module_utils/lxd.py b/plugins/module_utils/lxd.py index bdf026313a..007de4d8db 100644 --- a/plugins/module_utils/lxd.py +++ b/plugins/module_utils/lxd.py @@ -8,8 +8,10 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type +import os import socket import ssl +import json from ansible.module_utils.urls import generic_urlparse from ansible.module_utils.six.moves.urllib.parse import urlparse @@ -20,8 +22,6 @@ from ansible.module_utils.common.text.converters import to_text HTTPConnection = http_client.HTTPConnection HTTPSConnection = http_client.HTTPSConnection -import json - class UnixHTTPConnection(HTTPConnection): def __init__(self, path): @@ -124,3 +124,11 @@ class LXDClient(object): if err is None: err = resp_json.get('error', None) return err + + +def default_key_file(): + return os.path.expanduser('~/.config/lxc/client.key') + + +def default_cert_file(): + return os.path.expanduser('~/.config/lxc/client.crt') diff --git a/plugins/modules/lxd_project.py b/plugins/modules/lxd_project.py index f0aa4058e7..ad6019c2ec 100644 --- a/plugins/modules/lxd_project.py +++ b/plugins/modules/lxd_project.py @@ -178,7 +178,9 @@ actions: sample: ["create"] ''' -from ansible_collections.community.general.plugins.module_utils.lxd import LXDClient, LXDClientException +from ansible_collections.community.general.plugins.module_utils.lxd import ( + LXDClient, LXDClientException, default_key_file, default_cert_file +) from ansible.module_utils.basic import AnsibleModule import os @@ -211,10 +213,10 @@ class LXDProjectManagement(object): self.key_file = self.module.params.get('client_key') if self.key_file is None: - self.key_file = os.path.expanduser('~/.config/lxc/client.key') + self.key_file = default_key_file() self.cert_file = self.module.params.get('client_cert') if self.cert_file is None: - self.cert_file = os.path.expanduser('~/.config/lxc/client.crt') + self.cert_file = default_cert_file() self.debug = self.module._verbosity >= 4 try: diff --git a/tests/sanity/ignore-2.11.txt b/tests/sanity/ignore-2.11.txt index f8efbcfbee..5b8f3a4393 100644 --- a/tests/sanity/ignore-2.11.txt +++ b/tests/sanity/ignore-2.11.txt @@ -11,7 +11,6 @@ plugins/modules/gconftool2.py validate-modules:parameter-state-invalid-choice plugins/modules/iptables_state.py validate-modules:undocumented-parameter plugins/modules/jenkins_plugin.py use-argspec-type-path plugins/modules/lxc_container.py validate-modules:use-run-command-not-popen -plugins/modules/lxd_project.py use-argspec-type-path # expanduser() applied to constants plugins/modules/manageiq_policies.py validate-modules:parameter-state-invalid-choice plugins/modules/manageiq_provider.py validate-modules:doc-choices-do-not-match-spec # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:doc-missing-type # missing docs on suboptions diff --git a/tests/sanity/ignore-2.12.txt b/tests/sanity/ignore-2.12.txt index adb6d868a9..2ff7c01e0a 100644 --- a/tests/sanity/ignore-2.12.txt +++ b/tests/sanity/ignore-2.12.txt @@ -6,7 +6,6 @@ plugins/modules/gconftool2.py validate-modules:parameter-state-invalid-choice plugins/modules/iptables_state.py validate-modules:undocumented-parameter plugins/modules/jenkins_plugin.py use-argspec-type-path plugins/modules/lxc_container.py validate-modules:use-run-command-not-popen -plugins/modules/lxd_project.py use-argspec-type-path # expanduser() applied to constants plugins/modules/manageiq_policies.py validate-modules:parameter-state-invalid-choice plugins/modules/manageiq_provider.py validate-modules:doc-choices-do-not-match-spec # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:doc-missing-type # missing docs on suboptions diff --git a/tests/sanity/ignore-2.13.txt b/tests/sanity/ignore-2.13.txt index adb6d868a9..2ff7c01e0a 100644 --- a/tests/sanity/ignore-2.13.txt +++ b/tests/sanity/ignore-2.13.txt @@ -6,7 +6,6 @@ plugins/modules/gconftool2.py validate-modules:parameter-state-invalid-choice plugins/modules/iptables_state.py validate-modules:undocumented-parameter plugins/modules/jenkins_plugin.py use-argspec-type-path plugins/modules/lxc_container.py validate-modules:use-run-command-not-popen -plugins/modules/lxd_project.py use-argspec-type-path # expanduser() applied to constants plugins/modules/manageiq_policies.py validate-modules:parameter-state-invalid-choice plugins/modules/manageiq_provider.py validate-modules:doc-choices-do-not-match-spec # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:doc-missing-type # missing docs on suboptions diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt index d670fe2282..5cd667f8d7 100644 --- a/tests/sanity/ignore-2.14.txt +++ b/tests/sanity/ignore-2.14.txt @@ -7,7 +7,6 @@ plugins/modules/homectl.py import-3.11 # Uses deprecated stdlib library 'crypt' plugins/modules/iptables_state.py validate-modules:undocumented-parameter plugins/modules/jenkins_plugin.py use-argspec-type-path plugins/modules/lxc_container.py validate-modules:use-run-command-not-popen -plugins/modules/lxd_project.py use-argspec-type-path # expanduser() applied to constants plugins/modules/manageiq_policies.py validate-modules:parameter-state-invalid-choice plugins/modules/manageiq_provider.py validate-modules:doc-choices-do-not-match-spec # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:doc-missing-type # missing docs on suboptions diff --git a/tests/sanity/ignore-2.15.txt b/tests/sanity/ignore-2.15.txt index d670fe2282..5cd667f8d7 100644 --- a/tests/sanity/ignore-2.15.txt +++ b/tests/sanity/ignore-2.15.txt @@ -7,7 +7,6 @@ plugins/modules/homectl.py import-3.11 # Uses deprecated stdlib library 'crypt' plugins/modules/iptables_state.py validate-modules:undocumented-parameter plugins/modules/jenkins_plugin.py use-argspec-type-path plugins/modules/lxc_container.py validate-modules:use-run-command-not-popen -plugins/modules/lxd_project.py use-argspec-type-path # expanduser() applied to constants plugins/modules/manageiq_policies.py validate-modules:parameter-state-invalid-choice plugins/modules/manageiq_provider.py validate-modules:doc-choices-do-not-match-spec # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:doc-missing-type # missing docs on suboptions From 270dc133b3f4b030886d343f65694aa6bcd33457 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Wed, 16 Nov 2022 10:37:48 +1300 Subject: [PATCH 0042/1810] spotinst_aws_elasticgroup: sanity checks (#5553) * spotinst_aws_elastigroup: add elements to parameter do_not_update * spotinst_aws_elastigroup: add docs for parameter token * add missing docs * add changelog fragment * Update plugins/modules/spotinst_aws_elastigroup.py Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein --- .../5553-spotinst-aws-elasticgroup-sanity.yml | 2 ++ plugins/modules/spotinst_aws_elastigroup.py | 28 +++++++++++++++++-- tests/sanity/ignore-2.11.txt | 3 -- tests/sanity/ignore-2.12.txt | 3 -- tests/sanity/ignore-2.13.txt | 3 -- tests/sanity/ignore-2.14.txt | 3 -- tests/sanity/ignore-2.15.txt | 3 -- 7 files changed, 28 insertions(+), 17 deletions(-) create mode 100644 changelogs/fragments/5553-spotinst-aws-elasticgroup-sanity.yml diff --git a/changelogs/fragments/5553-spotinst-aws-elasticgroup-sanity.yml b/changelogs/fragments/5553-spotinst-aws-elasticgroup-sanity.yml new file mode 100644 index 0000000000..1213f5412a --- /dev/null +++ b/changelogs/fragments/5553-spotinst-aws-elasticgroup-sanity.yml @@ -0,0 +1,2 @@ +minor_changes: + - spotinst_aws_elastigroup - add ``elements`` attribute when missing in ``list`` parameters (https://github.com/ansible-collections/community.general/pull/5553). diff --git a/plugins/modules/spotinst_aws_elastigroup.py b/plugins/modules/spotinst_aws_elastigroup.py index df2b8d84db..481ba70cb9 100644 --- a/plugins/modules/spotinst_aws_elastigroup.py +++ b/plugins/modules/spotinst_aws_elastigroup.py @@ -35,6 +35,13 @@ options: By default this is retrieved from the credentials path. type: str + token: + description: + - A Personal API Access Token issued by Spotinst. + - >- + When not specified, the module will try to obtain it, in that order, from: environment variable C(SPOTINST_TOKEN), or from the credentials path. + type: str + availability_vs_cost: description: - The strategy orientation. @@ -507,8 +514,25 @@ options: description: - TODO document. type: list + elements: str default: [] + multai_token: + description: + - Token used for Multai configuration. + type: str + + multai_load_balancers: + description: + - Configuration parameters for Multai load balancers. + type: list + elements: dict + + elastic_beanstalk: + description: + - Placeholder parameter for future implementation of Elastic Beanstalk configurations. + type: dict + ''' EXAMPLES = ''' # Basic configuration YAML example @@ -1455,7 +1479,7 @@ def main(): block_device_mappings=dict(type='list', elements='dict'), chef=dict(type='dict'), credentials_path=dict(type='path', default="~/.spotinst/credentials"), - do_not_update=dict(default=[], type='list'), + do_not_update=dict(default=[], type='list', elements='str'), down_scaling_policies=dict(type='list', elements='dict'), draining_timeout=dict(type='int'), ebs_optimized=dict(type='bool'), @@ -1479,7 +1503,7 @@ def main(): mesosphere=dict(type='dict'), min_size=dict(type='int', required=True), monitoring=dict(type='str'), - multai_load_balancers=dict(type='list'), + multai_load_balancers=dict(type='list', elements='dict'), multai_token=dict(type='str', no_log=True), name=dict(type='str', required=True), network_interfaces=dict(type='list', elements='dict'), diff --git a/tests/sanity/ignore-2.11.txt b/tests/sanity/ignore-2.11.txt index 5b8f3a4393..ddb02bb888 100644 --- a/tests/sanity/ignore-2.11.txt +++ b/tests/sanity/ignore-2.11.txt @@ -28,9 +28,6 @@ plugins/modules/rax_scaling_group.py use-argspec-type-path # fix needed, expand plugins/modules/redhat_subscription.py validate-modules:return-syntax-error plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/scaleway_organization_info.py validate-modules:return-syntax-error -plugins/modules/spotinst_aws_elastigroup.py validate-modules:parameter-list-no-elements -plugins/modules/spotinst_aws_elastigroup.py validate-modules:parameter-type-not-in-doc -plugins/modules/spotinst_aws_elastigroup.py validate-modules:undocumented-parameter plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path plugins/modules/udm_share.py validate-modules:parameter-list-no-elements plugins/modules/udm_user.py validate-modules:parameter-list-no-elements diff --git a/tests/sanity/ignore-2.12.txt b/tests/sanity/ignore-2.12.txt index 2ff7c01e0a..3949640c51 100644 --- a/tests/sanity/ignore-2.12.txt +++ b/tests/sanity/ignore-2.12.txt @@ -23,9 +23,6 @@ plugins/modules/rax_scaling_group.py use-argspec-type-path # fix needed, expand plugins/modules/redhat_subscription.py validate-modules:return-syntax-error plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/scaleway_organization_info.py validate-modules:return-syntax-error -plugins/modules/spotinst_aws_elastigroup.py validate-modules:parameter-list-no-elements -plugins/modules/spotinst_aws_elastigroup.py validate-modules:parameter-type-not-in-doc -plugins/modules/spotinst_aws_elastigroup.py validate-modules:undocumented-parameter plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path plugins/modules/udm_share.py validate-modules:parameter-list-no-elements plugins/modules/udm_user.py validate-modules:parameter-list-no-elements diff --git a/tests/sanity/ignore-2.13.txt b/tests/sanity/ignore-2.13.txt index 2ff7c01e0a..3949640c51 100644 --- a/tests/sanity/ignore-2.13.txt +++ b/tests/sanity/ignore-2.13.txt @@ -23,9 +23,6 @@ plugins/modules/rax_scaling_group.py use-argspec-type-path # fix needed, expand plugins/modules/redhat_subscription.py validate-modules:return-syntax-error plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/scaleway_organization_info.py validate-modules:return-syntax-error -plugins/modules/spotinst_aws_elastigroup.py validate-modules:parameter-list-no-elements -plugins/modules/spotinst_aws_elastigroup.py validate-modules:parameter-type-not-in-doc -plugins/modules/spotinst_aws_elastigroup.py validate-modules:undocumented-parameter plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path plugins/modules/udm_share.py validate-modules:parameter-list-no-elements plugins/modules/udm_user.py validate-modules:parameter-list-no-elements diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt index 5cd667f8d7..3bae2ac329 100644 --- a/tests/sanity/ignore-2.14.txt +++ b/tests/sanity/ignore-2.14.txt @@ -24,9 +24,6 @@ plugins/modules/rax_scaling_group.py use-argspec-type-path # fix needed, expand plugins/modules/redhat_subscription.py validate-modules:return-syntax-error plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/scaleway_organization_info.py validate-modules:return-syntax-error -plugins/modules/spotinst_aws_elastigroup.py validate-modules:parameter-list-no-elements -plugins/modules/spotinst_aws_elastigroup.py validate-modules:parameter-type-not-in-doc -plugins/modules/spotinst_aws_elastigroup.py validate-modules:undocumented-parameter plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path plugins/modules/udm_share.py validate-modules:parameter-list-no-elements plugins/modules/udm_user.py import-3.11 # Uses deprecated stdlib library 'crypt' diff --git a/tests/sanity/ignore-2.15.txt b/tests/sanity/ignore-2.15.txt index 5cd667f8d7..3bae2ac329 100644 --- a/tests/sanity/ignore-2.15.txt +++ b/tests/sanity/ignore-2.15.txt @@ -24,9 +24,6 @@ plugins/modules/rax_scaling_group.py use-argspec-type-path # fix needed, expand plugins/modules/redhat_subscription.py validate-modules:return-syntax-error plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/scaleway_organization_info.py validate-modules:return-syntax-error -plugins/modules/spotinst_aws_elastigroup.py validate-modules:parameter-list-no-elements -plugins/modules/spotinst_aws_elastigroup.py validate-modules:parameter-type-not-in-doc -plugins/modules/spotinst_aws_elastigroup.py validate-modules:undocumented-parameter plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path plugins/modules/udm_share.py validate-modules:parameter-list-no-elements plugins/modules/udm_user.py import-3.11 # Uses deprecated stdlib library 'crypt' From 801e3d86ef4f71bd99a6ffc1696b3b8fe7b89223 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Wed, 16 Nov 2022 18:44:18 +1300 Subject: [PATCH 0043/1810] redhat_subscription: fix sanity check (#5555) * redhat_subscription: fix sanity check * removed ignore lines --- plugins/modules/redhat_subscription.py | 2 +- tests/sanity/ignore-2.11.txt | 1 - tests/sanity/ignore-2.12.txt | 1 - tests/sanity/ignore-2.13.txt | 1 - tests/sanity/ignore-2.14.txt | 1 - tests/sanity/ignore-2.15.txt | 1 - 6 files changed, 1 insertion(+), 6 deletions(-) diff --git a/plugins/modules/redhat_subscription.py b/plugins/modules/redhat_subscription.py index 69aa550c5d..997d1e5153 100644 --- a/plugins/modules/redhat_subscription.py +++ b/plugins/modules/redhat_subscription.py @@ -264,7 +264,7 @@ RETURN = ''' subscribed_pool_ids: description: List of pool IDs to which system is now subscribed returned: success - type: complex + type: dict sample: { "8a85f9815ab905d3015ab928c7005de4": "1" } diff --git a/tests/sanity/ignore-2.11.txt b/tests/sanity/ignore-2.11.txt index ddb02bb888..2f6bf480c0 100644 --- a/tests/sanity/ignore-2.11.txt +++ b/tests/sanity/ignore-2.11.txt @@ -25,7 +25,6 @@ plugins/modules/rax_files_objects.py use-argspec-type-path plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice plugins/modules/rax.py use-argspec-type-path # fix needed plugins/modules/rax_scaling_group.py use-argspec-type-path # fix needed, expanduser() applied to dict values -plugins/modules/redhat_subscription.py validate-modules:return-syntax-error plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/scaleway_organization_info.py validate-modules:return-syntax-error plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path diff --git a/tests/sanity/ignore-2.12.txt b/tests/sanity/ignore-2.12.txt index 3949640c51..6499478916 100644 --- a/tests/sanity/ignore-2.12.txt +++ b/tests/sanity/ignore-2.12.txt @@ -20,7 +20,6 @@ plugins/modules/rax_files_objects.py use-argspec-type-path plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice plugins/modules/rax.py use-argspec-type-path # fix needed plugins/modules/rax_scaling_group.py use-argspec-type-path # fix needed, expanduser() applied to dict values -plugins/modules/redhat_subscription.py validate-modules:return-syntax-error plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/scaleway_organization_info.py validate-modules:return-syntax-error plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path diff --git a/tests/sanity/ignore-2.13.txt b/tests/sanity/ignore-2.13.txt index 3949640c51..6499478916 100644 --- a/tests/sanity/ignore-2.13.txt +++ b/tests/sanity/ignore-2.13.txt @@ -20,7 +20,6 @@ plugins/modules/rax_files_objects.py use-argspec-type-path plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice plugins/modules/rax.py use-argspec-type-path # fix needed plugins/modules/rax_scaling_group.py use-argspec-type-path # fix needed, expanduser() applied to dict values -plugins/modules/redhat_subscription.py validate-modules:return-syntax-error plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/scaleway_organization_info.py validate-modules:return-syntax-error plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt index 3bae2ac329..ce92542bd1 100644 --- a/tests/sanity/ignore-2.14.txt +++ b/tests/sanity/ignore-2.14.txt @@ -21,7 +21,6 @@ plugins/modules/rax_files_objects.py use-argspec-type-path plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice plugins/modules/rax.py use-argspec-type-path # fix needed plugins/modules/rax_scaling_group.py use-argspec-type-path # fix needed, expanduser() applied to dict values -plugins/modules/redhat_subscription.py validate-modules:return-syntax-error plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/scaleway_organization_info.py validate-modules:return-syntax-error plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path diff --git a/tests/sanity/ignore-2.15.txt b/tests/sanity/ignore-2.15.txt index 3bae2ac329..ce92542bd1 100644 --- a/tests/sanity/ignore-2.15.txt +++ b/tests/sanity/ignore-2.15.txt @@ -21,7 +21,6 @@ plugins/modules/rax_files_objects.py use-argspec-type-path plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice plugins/modules/rax.py use-argspec-type-path # fix needed plugins/modules/rax_scaling_group.py use-argspec-type-path # fix needed, expanduser() applied to dict values -plugins/modules/redhat_subscription.py validate-modules:return-syntax-error plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/scaleway_organization_info.py validate-modules:return-syntax-error plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path From e87ca10b61275a4c679f7e945116b8c11090504e Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Wed, 16 Nov 2022 18:44:40 +1300 Subject: [PATCH 0044/1810] cmd_runner module utils: fix case for as_fixed() format (#5538) * cmd_runner module utils: fix case for as_fixed() format * add changelog fragment * simplified test_cmd_runner * fix handling empty default for `as_map()` * add changelog fragment * MissingArgumentValue is reraised in run() --- .../fragments/5538-cmd-runner-as-fixed.yml | 3 + plugins/module_utils/cmd_runner.py | 19 ++- .../plugins/module_utils/test_cmd_runner.py | 124 +++++++++--------- 3 files changed, 77 insertions(+), 69 deletions(-) create mode 100644 changelogs/fragments/5538-cmd-runner-as-fixed.yml diff --git a/changelogs/fragments/5538-cmd-runner-as-fixed.yml b/changelogs/fragments/5538-cmd-runner-as-fixed.yml new file mode 100644 index 0000000000..714564b09f --- /dev/null +++ b/changelogs/fragments/5538-cmd-runner-as-fixed.yml @@ -0,0 +1,3 @@ +bugfixes: + - cmd_runner module utils - formatting arguments ``cmd_runner_fmt.as_fixed()`` was expecting an non-existing argument (https://github.com/ansible-collections/community.general/pull/5538). + - cmd_runner module utils - fixed bug when handling default cases in ``cmd_runner_fmt.as_map()`` (https://github.com/ansible-collections/community.general/pull/5538). diff --git a/plugins/module_utils/cmd_runner.py b/plugins/module_utils/cmd_runner.py index 141a6be9b2..38daac6716 100644 --- a/plugins/module_utils/cmd_runner.py +++ b/plugins/module_utils/cmd_runner.py @@ -88,9 +88,10 @@ class FormatError(CmdRunnerException): class _ArgFormat(object): - def __init__(self, func, ignore_none=None): + def __init__(self, func, ignore_none=None, ignore_missing_value=False): self.func = func self.ignore_none = ignore_none + self.ignore_missing_value = ignore_missing_value def __call__(self, value, ctx_ignore_none): ignore_none = self.ignore_none if self.ignore_none is not None else ctx_ignore_none @@ -127,7 +128,7 @@ class _Format(object): @staticmethod def as_fixed(args): - return _ArgFormat(lambda value: _ensure_list(args), ignore_none=False) + return _ArgFormat(lambda value: _ensure_list(args), ignore_none=False, ignore_missing_value=True) @staticmethod def as_func(func, ignore_none=None): @@ -135,14 +136,15 @@ class _Format(object): @staticmethod def as_map(_map, default=None, ignore_none=None): + if default is None: + default = [] return _ArgFormat(lambda value: _ensure_list(_map.get(value, default)), ignore_none=ignore_none) @staticmethod def as_default_type(_type, arg="", ignore_none=None): fmt = _Format if _type == "dict": - return fmt.as_func(lambda d: ["--{0}={1}".format(*a) for a in iteritems(d)], - ignore_none=ignore_none) + return fmt.as_func(lambda d: ["--{0}={1}".format(*a) for a in iteritems(d)], ignore_none=ignore_none) if _type == "list": return fmt.as_func(lambda value: ["--{0}".format(x) for x in value], ignore_none=ignore_none) if _type == "bool": @@ -261,10 +263,13 @@ class _CmdRunnerContext(object): for arg_name in self.args_order: value = None try: - value = named_args[arg_name] + if arg_name in named_args: + value = named_args[arg_name] + elif not runner.arg_formats[arg_name].ignore_missing_value: + raise MissingArgumentValue(self.args_order, arg_name) self.cmd.extend(runner.arg_formats[arg_name](value, ctx_ignore_none=self.ignore_value_none)) - except KeyError: - raise MissingArgumentValue(self.args_order, arg_name) + except MissingArgumentValue: + raise except Exception as e: raise FormatError(arg_name, value, runner.arg_formats[arg_name], e) diff --git a/tests/unit/plugins/module_utils/test_cmd_runner.py b/tests/unit/plugins/module_utils/test_cmd_runner.py index 5fdc5fb5fc..f1c3e25a9b 100644 --- a/tests/unit/plugins/module_utils/test_cmd_runner.py +++ b/tests/unit/plugins/module_utils/test_cmd_runner.py @@ -240,6 +240,60 @@ TC_RUNNER = dict( ), ), ), + aa_bb_fixed=( + dict( + args_bundle=dict( + aa=dict(type="int", value=11, fmt_func=fmt.as_opt_eq_val, fmt_arg="--answer"), + bb=dict(fmt_func=fmt.as_fixed, fmt_arg=["fixed", "args"]), + ), + runner_init_args=dict(), + runner_ctx_args=dict(args_order=['aa', 'bb']), + ), + dict(runner_ctx_run_args=dict(), rc=0, out="", err=""), + dict( + run_info=dict( + cmd=['/mock/bin/testing', '--answer=11', 'fixed', 'args'], + environ_update={'LANGUAGE': 'C', 'LC_ALL': 'C'}, + args_order=('aa', 'bb'), + ), + ), + ), + aa_bb_map=( + dict( + args_bundle=dict( + aa=dict(type="int", value=11, fmt_func=fmt.as_opt_eq_val, fmt_arg="--answer"), + bb=dict(fmt_func=fmt.as_map, fmt_arg={"v1": 111, "v2": 222}), + ), + runner_init_args=dict(), + runner_ctx_args=dict(args_order=['aa', 'bb']), + ), + dict(runner_ctx_run_args=dict(bb="v2"), rc=0, out="", err=""), + dict( + run_info=dict( + cmd=['/mock/bin/testing', '--answer=11', '222'], + environ_update={'LANGUAGE': 'C', 'LC_ALL': 'C'}, + args_order=('aa', 'bb'), + ), + ), + ), + aa_bb_map_default=( + dict( + args_bundle=dict( + aa=dict(type="int", value=11, fmt_func=fmt.as_opt_eq_val, fmt_arg="--answer"), + bb=dict(fmt_func=fmt.as_map, fmt_arg={"v1": 111, "v2": 222}), + ), + runner_init_args=dict(), + runner_ctx_args=dict(args_order=['aa', 'bb']), + ), + dict(runner_ctx_run_args=dict(bb="v123456789"), rc=0, out="", err=""), + dict( + run_info=dict( + cmd=['/mock/bin/testing', '--answer=11'], + environ_update={'LANGUAGE': 'C', 'LC_ALL': 'C'}, + args_order=('aa', 'bb'), + ), + ), + ), ) TC_RUNNER_IDS = sorted(TC_RUNNER.keys()) @@ -301,70 +355,16 @@ def test_runner_context(runner_input, cmd_execution, expected): results = ctx.run(**cmd_execution['runner_ctx_run_args']) _assert_run(runner_input, cmd_execution, expected, ctx, results) + with pytest.raises(exc): + with runner(**runner_input['runner_ctx_args']) as ctx2: + results2 = ctx2.run(**cmd_execution['runner_ctx_run_args']) + _assert_run(runner_input, cmd_execution, expected, ctx2, results2) + else: with runner.context(**runner_input['runner_ctx_args']) as ctx: results = ctx.run(**cmd_execution['runner_ctx_run_args']) _assert_run(runner_input, cmd_execution, expected, ctx, results) - -@pytest.mark.parametrize('runner_input, cmd_execution, expected', - (TC_RUNNER[tc] for tc in TC_RUNNER_IDS), - ids=TC_RUNNER_IDS) -def test_runner_callable(runner_input, cmd_execution, expected): - arg_spec = {} - params = {} - arg_formats = {} - for k, v in runner_input['args_bundle'].items(): - try: - arg_spec[k] = {'type': v['type']} - except KeyError: - pass - try: - params[k] = v['value'] - except KeyError: - pass - try: - arg_formats[k] = v['fmt_func'](v['fmt_arg']) - except KeyError: - pass - - orig_results = tuple(cmd_execution[x] for x in ('rc', 'out', 'err')) - - print("arg_spec={0}\nparams={1}\narg_formats={2}\n".format( - arg_spec, - params, - arg_formats, - )) - - module = MagicMock() - type(module).argument_spec = PropertyMock(return_value=arg_spec) - type(module).params = PropertyMock(return_value=params) - module.get_bin_path.return_value = '/mock/bin/testing' - module.run_command.return_value = orig_results - - runner = CmdRunner( - module=module, - command="testing", - arg_formats=arg_formats, - **runner_input['runner_init_args'] - ) - - def _assert_run_info(actual, expected): - reduced = dict((k, actual[k]) for k in expected.keys()) - assert reduced == expected, "{0}".format(reduced) - - def _assert_run(runner_input, cmd_execution, expected, ctx, results): - _assert_run_info(ctx.run_info, expected['run_info']) - assert results == expected.get('results', orig_results) - - exc = expected.get("exc") - if exc: - with pytest.raises(exc): - with runner(**runner_input['runner_ctx_args']) as ctx: - results = ctx.run(**cmd_execution['runner_ctx_run_args']) - _assert_run(runner_input, cmd_execution, expected, ctx, results) - - else: - with runner(**runner_input['runner_ctx_args']) as ctx: - results = ctx.run(**cmd_execution['runner_ctx_run_args']) - _assert_run(runner_input, cmd_execution, expected, ctx, results) + with runner(**runner_input['runner_ctx_args']) as ctx2: + results2 = ctx2.run(**cmd_execution['runner_ctx_run_args']) + _assert_run(runner_input, cmd_execution, expected, ctx2, results2) From 6a03108609cba48b88b57d2bf43eb238fc13f229 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Thu, 17 Nov 2022 09:58:55 +1300 Subject: [PATCH 0045/1810] rax_scaling_group: fix sanity check (#5563) * rax_scaling_group: fix sanity check * add changelog fragment * added missing call to expanduser() --- .../5563-rax-scaling-group-sanity.yml | 2 ++ plugins/module_utils/rax.py | 18 ++++++++++++++++ plugins/modules/rax_scaling_group.py | 21 ++++++------------- tests/sanity/ignore-2.11.txt | 1 - tests/sanity/ignore-2.12.txt | 1 - tests/sanity/ignore-2.13.txt | 1 - tests/sanity/ignore-2.14.txt | 1 - tests/sanity/ignore-2.15.txt | 1 - 8 files changed, 26 insertions(+), 20 deletions(-) create mode 100644 changelogs/fragments/5563-rax-scaling-group-sanity.yml diff --git a/changelogs/fragments/5563-rax-scaling-group-sanity.yml b/changelogs/fragments/5563-rax-scaling-group-sanity.yml new file mode 100644 index 0000000000..310257f293 --- /dev/null +++ b/changelogs/fragments/5563-rax-scaling-group-sanity.yml @@ -0,0 +1,2 @@ +minor_changes: + - rax_scaling_group - refactored out code to the ``rax`` module utils to clear the sanity check (https://github.com/ansible-collections/community.general/pull/5563). diff --git a/plugins/module_utils/rax.py b/plugins/module_utils/rax.py index 2372088033..6331c0d1be 100644 --- a/plugins/module_utils/rax.py +++ b/plugins/module_utils/rax.py @@ -314,3 +314,21 @@ def setup_rax_module(module, rax_module, region_required=True): (region, ','.join(rax_module.regions))) return rax_module + + +def rax_scaling_group_personality_file(module, files): + if not files: + return [] + + results = [] + for rpath, lpath in files.items(): + lpath = os.path.expanduser(lpath) + try: + with open(lpath, 'r') as f: + results.append({ + 'path': rpath, + 'contents': f.read(), + }) + except Exception as e: + module.fail_json(msg='Failed to load %s: %s' % (lpath, str(e))) + return results diff --git a/plugins/modules/rax_scaling_group.py b/plugins/modules/rax_scaling_group.py index ef31cbb031..ed974ef0f9 100644 --- a/plugins/modules/rax_scaling_group.py +++ b/plugins/modules/rax_scaling_group.py @@ -161,8 +161,11 @@ except ImportError: HAS_PYRAX = False from ansible.module_utils.basic import AnsibleModule -from ansible_collections.community.general.plugins.module_utils.rax import (rax_argument_spec, rax_find_image, rax_find_network, - rax_required_together, rax_to_dict, setup_rax_module) +from ansible_collections.community.general.plugins.module_utils.rax import ( + rax_argument_spec, rax_find_image, rax_find_network, + rax_required_together, rax_to_dict, setup_rax_module, + rax_scaling_group_personality_file, +) from ansible.module_utils.six import string_types @@ -223,19 +226,7 @@ def rax_asg(module, cooldown=300, disk_config=None, files=None, flavor=None, del nic['net-id'] # Handle the file contents - personality = [] - if files: - for rpath in files.keys(): - lpath = os.path.expanduser(files[rpath]) - try: - f = open(lpath, 'r') - personality.append({ - 'path': rpath, - 'contents': f.read() - }) - f.close() - except Exception as e: - module.fail_json(msg='Failed to load %s' % lpath) + personality = rax_scaling_group_personality_file(module, files) lbs = [] if loadbalancers: diff --git a/tests/sanity/ignore-2.11.txt b/tests/sanity/ignore-2.11.txt index 2f6bf480c0..8ca3e163da 100644 --- a/tests/sanity/ignore-2.11.txt +++ b/tests/sanity/ignore-2.11.txt @@ -24,7 +24,6 @@ plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias - plugins/modules/rax_files_objects.py use-argspec-type-path plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice plugins/modules/rax.py use-argspec-type-path # fix needed -plugins/modules/rax_scaling_group.py use-argspec-type-path # fix needed, expanduser() applied to dict values plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/scaleway_organization_info.py validate-modules:return-syntax-error plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path diff --git a/tests/sanity/ignore-2.12.txt b/tests/sanity/ignore-2.12.txt index 6499478916..9c1ccbf433 100644 --- a/tests/sanity/ignore-2.12.txt +++ b/tests/sanity/ignore-2.12.txt @@ -19,7 +19,6 @@ plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias - plugins/modules/rax_files_objects.py use-argspec-type-path plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice plugins/modules/rax.py use-argspec-type-path # fix needed -plugins/modules/rax_scaling_group.py use-argspec-type-path # fix needed, expanduser() applied to dict values plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/scaleway_organization_info.py validate-modules:return-syntax-error plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path diff --git a/tests/sanity/ignore-2.13.txt b/tests/sanity/ignore-2.13.txt index 6499478916..9c1ccbf433 100644 --- a/tests/sanity/ignore-2.13.txt +++ b/tests/sanity/ignore-2.13.txt @@ -19,7 +19,6 @@ plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias - plugins/modules/rax_files_objects.py use-argspec-type-path plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice plugins/modules/rax.py use-argspec-type-path # fix needed -plugins/modules/rax_scaling_group.py use-argspec-type-path # fix needed, expanduser() applied to dict values plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/scaleway_organization_info.py validate-modules:return-syntax-error plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt index ce92542bd1..edf15c5cfc 100644 --- a/tests/sanity/ignore-2.14.txt +++ b/tests/sanity/ignore-2.14.txt @@ -20,7 +20,6 @@ plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias - plugins/modules/rax_files_objects.py use-argspec-type-path plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice plugins/modules/rax.py use-argspec-type-path # fix needed -plugins/modules/rax_scaling_group.py use-argspec-type-path # fix needed, expanduser() applied to dict values plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/scaleway_organization_info.py validate-modules:return-syntax-error plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path diff --git a/tests/sanity/ignore-2.15.txt b/tests/sanity/ignore-2.15.txt index ce92542bd1..edf15c5cfc 100644 --- a/tests/sanity/ignore-2.15.txt +++ b/tests/sanity/ignore-2.15.txt @@ -20,7 +20,6 @@ plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias - plugins/modules/rax_files_objects.py use-argspec-type-path plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice plugins/modules/rax.py use-argspec-type-path # fix needed -plugins/modules/rax_scaling_group.py use-argspec-type-path # fix needed, expanduser() applied to dict values plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/scaleway_organization_info.py validate-modules:return-syntax-error plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path From 5e5af458fb431d742a22b1ba8642e30a75765667 Mon Sep 17 00:00:00 2001 From: Evan Jarrett Date: Wed, 16 Nov 2022 23:53:46 -0600 Subject: [PATCH 0046/1810] chroot plugin fix inventory_hostname var for remote_addr (#5570) * Add inventory_hostname under remote_addr.vars in chroot connection plugin required by ansible 2.13 * fix changelog fragment --- .../5570-chroot-plugin-fix-default-inventory_hostname.yml | 2 ++ plugins/connection/chroot.py | 1 + 2 files changed, 3 insertions(+) create mode 100644 changelogs/fragments/5570-chroot-plugin-fix-default-inventory_hostname.yml diff --git a/changelogs/fragments/5570-chroot-plugin-fix-default-inventory_hostname.yml b/changelogs/fragments/5570-chroot-plugin-fix-default-inventory_hostname.yml new file mode 100644 index 0000000000..fc0c074f84 --- /dev/null +++ b/changelogs/fragments/5570-chroot-plugin-fix-default-inventory_hostname.yml @@ -0,0 +1,2 @@ +bugfixes: + - "chroot connection plugin - add ``inventory_hostname`` to vars under ``remote_addr``. This is needed for compatibility with ansible-core 2.13 (https://github.com/ansible-collections/community.general/pull/5570)." \ No newline at end of file diff --git a/plugins/connection/chroot.py b/plugins/connection/chroot.py index cbbf9612e9..ef6d5566d3 100644 --- a/plugins/connection/chroot.py +++ b/plugins/connection/chroot.py @@ -22,6 +22,7 @@ DOCUMENTATION = ''' - The path of the chroot you want to access. default: inventory_hostname vars: + - name: inventory_hostname - name: ansible_host executable: description: From 0624951e177466912f4bda642b72dd2d9c54c1cd Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Thu, 17 Nov 2022 18:55:00 +1300 Subject: [PATCH 0047/1810] add dependency manager (#5535) * add dependency manager * add plugins/module_utils/deps.py to BOTMETA * ditch usng OrderedDict to keep compatibility with Python 2.6 * Update plugins/module_utils/deps.py Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein --- .github/BOTMETA.yml | 2 + plugins/module_utils/deps.py | 90 +++++++++++++++++++++++++++++++ plugins/modules/dnsimple_info.py | 16 ++---- plugins/modules/iso_customize.py | 19 +++---- plugins/modules/pagerduty_user.py | 27 ++-------- plugins/modules/pids.py | 15 +++--- plugins/modules/snmp_facts.py | 17 ++---- 7 files changed, 117 insertions(+), 69 deletions(-) create mode 100644 plugins/module_utils/deps.py diff --git a/.github/BOTMETA.yml b/.github/BOTMETA.yml index c56720cb0d..2fbbf64f65 100644 --- a/.github/BOTMETA.yml +++ b/.github/BOTMETA.yml @@ -265,6 +265,8 @@ files: maintainers: delineaKrehl tylerezimmerman $module_utils/: labels: module_utils + $module_utils/deps.py: + maintainers: russoz $module_utils/gconftool2.py: labels: gconftool2 maintainers: russoz diff --git a/plugins/module_utils/deps.py b/plugins/module_utils/deps.py new file mode 100644 index 0000000000..bfb94cbc09 --- /dev/null +++ b/plugins/module_utils/deps.py @@ -0,0 +1,90 @@ +# -*- coding: utf-8 -*- +# (c) 2022, Alexei Znamensky +# Copyright (c) 2022, Ansible Project +# Simplified BSD License (see LICENSES/BSD-2-Clause.txt or https://opensource.org/licenses/BSD-2-Clause) +# SPDX-License-Identifier: BSD-2-Clause + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +import traceback +from contextlib import contextmanager + +from ansible.module_utils.common.text.converters import to_native +from ansible.module_utils.basic import missing_required_lib + + +_deps = dict() + + +class _Dependency(object): + _states = ["pending", "failure", "success"] + + def __init__(self, name, reason=None, url=None, msg=None): + self.name = name + self.reason = reason + self.url = url + self.msg = msg + + self.state = 0 + self.trace = None + self.exc = None + + def succeed(self): + self.state = 2 + + def fail(self, exc, trace): + self.state = 1 + self.exc = exc + self.trace = trace + + @property + def message(self): + if self.msg: + return to_native(self.msg) + else: + return missing_required_lib(self.name, reason=self.reason, url=self.url) + + @property + def failed(self): + return self.state == 1 + + def verify(self, module): + if self.failed: + module.fail_json(msg=self.message, exception=self.trace) + + def __str__(self): + return "".format(self.name, self._states[self.state]) + + +@contextmanager +def declare(name, *args, **kwargs): + dep = _Dependency(name, *args, **kwargs) + try: + yield dep + except Exception as e: + dep.fail(e, traceback.format_exc()) + else: + dep.succeed() + finally: + _deps[name] = dep + + +def validate(module, spec=None): + dep_names = sorted(_deps) + + if spec is not None: + if spec.startswith("-"): + spec_split = spec[1:].split(":") + for d in spec_split: + dep_names.remove(d) + else: + spec_split = spec[1:].split(":") + dep_names = [] + for d in spec_split: + _deps[d] # ensure it exists + dep_names.append(d) + + for dep in dep_names: + _deps[dep].verify(module) diff --git a/plugins/modules/dnsimple_info.py b/plugins/modules/dnsimple_info.py index 959bacbbe8..52fd53303f 100644 --- a/plugins/modules/dnsimple_info.py +++ b/plugins/modules/dnsimple_info.py @@ -230,18 +230,11 @@ dnsimple_record_info: type: str ''' -import traceback from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.basic import missing_required_lib +from ansible_collections.community.general.plugins.module_utils import deps -try: +with deps.declare("requests"): from requests import Request, Session -except ImportError: - HAS_REQUESTS = False - REQUESTS_IMPORT_ERROR = traceback.format_exc() -else: - HAS_REQUESTS = True - REQUESTS_IMPORT_ERROR = None def build_url(account, key, is_sandbox): @@ -310,10 +303,7 @@ def main(): params['api_key'], params['sandbox']) - if not HAS_REQUESTS: - module.exit_json( - msg=missing_required_lib('requests'), - exception=REQUESTS_IMPORT_ERROR) + deps.validate(module) # At minimum we need account and key if params['account_id'] and params['api_key']: diff --git a/plugins/modules/iso_customize.py b/plugins/modules/iso_customize.py index c3a2ae2651..4f902f47e4 100644 --- a/plugins/modules/iso_customize.py +++ b/plugins/modules/iso_customize.py @@ -97,19 +97,14 @@ dest_iso: ''' import os -import traceback -PYCDLIB_IMP_ERR = None -try: - import pycdlib - HAS_PYCDLIB = True -except ImportError: - PYCDLIB_IMP_ERR = traceback.format_exc() - HAS_PYCDLIB = False - -from ansible.module_utils.basic import AnsibleModule, missing_required_lib +from ansible_collections.community.general.plugins.module_utils import deps +from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.common.text.converters import to_native +with deps.declare("pycdlib"): + import pycdlib + # The upper dir exist, we only add subdirectoy def iso_add_dir(module, opened_iso, iso_type, dir_path): @@ -306,9 +301,7 @@ def main(): required_one_of=[('delete_files', 'add_files'), ], supports_check_mode=True, ) - if not HAS_PYCDLIB: - module.fail_json( - missing_required_lib('pycdlib'), exception=PYCDLIB_IMP_ERR) + deps.validate(module) src_iso = module.params['src_iso'] if not os.path.exists(src_iso): diff --git a/plugins/modules/pagerduty_user.py b/plugins/modules/pagerduty_user.py index 4d8e32248f..e16fe59e76 100644 --- a/plugins/modules/pagerduty_user.py +++ b/plugins/modules/pagerduty_user.py @@ -80,25 +80,12 @@ EXAMPLES = r''' RETURN = r''' # ''' -from ansible.module_utils.basic import AnsibleModule, missing_required_lib -import traceback from os import path +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.community.general.plugins.module_utils import deps -try: - from pdpyras import APISession - HAS_PD_PY = True - PD_IMPORT_ERR = None -except ImportError: - HAS_PD_PY = False - PD_IMPORT_ERR = traceback.format_exc() - -try: - from pdpyras import PDClientError - HAS_PD_CLIENT_ERR = True - PD_CLIENT_ERR_IMPORT_ERR = None -except ImportError: - HAS_PD_CLIENT_ERR = False - PD_CLIENT_ERR_IMPORT_ERR = traceback.format_exc() +with deps.declare("pdpyras", url="https://github.com/PagerDuty/pdpyras"): + from pdpyras import APISession, PDClientError class PagerDutyUser(object): @@ -202,11 +189,7 @@ def main(): supports_check_mode=True, ) - if not HAS_PD_PY: - module.fail_json(msg=missing_required_lib('pdpyras', url='https://github.com/PagerDuty/pdpyras'), exception=PD_IMPORT_ERR) - - if not HAS_PD_CLIENT_ERR: - module.fail_json(msg=missing_required_lib('PDClientError', url='https://github.com/PagerDuty/pdpyras'), exception=PD_CLIENT_ERR_IMPORT_ERR) + deps.validate(module) access_token = module.params['access_token'] pd_user = module.params['pd_user'] diff --git a/plugins/modules/pids.py b/plugins/modules/pids.py index eaaf7f9437..2fe2a6b8ac 100644 --- a/plugins/modules/pids.py +++ b/plugins/modules/pids.py @@ -3,8 +3,8 @@ # Copyright (c) 2019, Saranya Sridharan # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) # SPDX-License-Identifier: GPL-3.0-or-later -from __future__ import (absolute_import, division, print_function) +from __future__ import (absolute_import, division, print_function) __metaclass__ = type DOCUMENTATION = ''' @@ -60,18 +60,15 @@ import re from os.path import basename from ansible.module_utils import six -from ansible.module_utils.basic import AnsibleModule, missing_required_lib +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.community.general.plugins.module_utils import deps from ansible.module_utils.common.text.converters import to_native from ansible_collections.community.general.plugins.module_utils.version import LooseVersion -try: +with deps.declare("psutil"): import psutil - HAS_PSUTIL = True -except ImportError: - HAS_PSUTIL = False - class PSAdapterError(Exception): pass @@ -177,8 +174,8 @@ def compare_lower(a, b): class Pids(object): def __init__(self, module): - if not HAS_PSUTIL: - module.fail_json(msg=missing_required_lib('psutil')) + + deps.validate(module) self._ps = PSAdapter.from_package(psutil) diff --git a/plugins/modules/snmp_facts.py b/plugins/modules/snmp_facts.py index 71821faaa8..0242bc6dde 100644 --- a/plugins/modules/snmp_facts.py +++ b/plugins/modules/snmp_facts.py @@ -183,20 +183,14 @@ ansible_interfaces: ''' import binascii -import traceback from collections import defaultdict +from ansible_collections.community.general.plugins.module_utils import deps +from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils.common.text.converters import to_text -PYSNMP_IMP_ERR = None -try: +with deps.declare("pysnmp"): from pysnmp.entity.rfc3413.oneliner import cmdgen from pysnmp.proto.rfc1905 import EndOfMibView - HAS_PYSNMP = True -except Exception: - PYSNMP_IMP_ERR = traceback.format_exc() - HAS_PYSNMP = False - -from ansible.module_utils.basic import AnsibleModule, missing_required_lib -from ansible.module_utils.common.text.converters import to_text class DefineOid(object): @@ -299,8 +293,7 @@ def main(): m_args = module.params - if not HAS_PYSNMP: - module.fail_json(msg=missing_required_lib('pysnmp'), exception=PYSNMP_IMP_ERR) + deps.validate(module) cmdGen = cmdgen.CommandGenerator() transport_opts = dict((k, m_args[k]) for k in ('timeout', 'retries') if m_args[k] is not None) From 8ad43fd77484f85bedc114dbedaee04168d6c8ee Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Thu, 17 Nov 2022 18:55:46 +1300 Subject: [PATCH 0048/1810] jenkins_plugin: fix sanity checks (#5565) * jenkins_plugin: fix sanity checks * update BOTMETA * add changelog fragment * fix copyright * Update plugins/module_utils/jenkins.py Co-authored-by: Felix Fontein * Update plugins/module_utils/jenkins.py Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein --- .github/BOTMETA.yml | 3 + .../fragments/5565-jenkins-plugin-sanity.yml | 2 + plugins/module_utils/jenkins.py | 35 ++++++++ plugins/modules/jenkins_plugin.py | 85 +++++++------------ tests/sanity/ignore-2.11.txt | 1 - tests/sanity/ignore-2.12.txt | 1 - tests/sanity/ignore-2.13.txt | 1 - tests/sanity/ignore-2.14.txt | 1 - tests/sanity/ignore-2.15.txt | 1 - 9 files changed, 71 insertions(+), 59 deletions(-) create mode 100644 changelogs/fragments/5565-jenkins-plugin-sanity.yml create mode 100644 plugins/module_utils/jenkins.py diff --git a/.github/BOTMETA.yml b/.github/BOTMETA.yml index 2fbbf64f65..6aacdc9cad 100644 --- a/.github/BOTMETA.yml +++ b/.github/BOTMETA.yml @@ -284,6 +284,9 @@ files: $module_utils/ipa.py: labels: ipa maintainers: $team_ipa + $module_utils/jenkins.py: + labels: jenkins + maintainers: russoz $module_utils/manageiq.py: labels: manageiq maintainers: $team_manageiq diff --git a/changelogs/fragments/5565-jenkins-plugin-sanity.yml b/changelogs/fragments/5565-jenkins-plugin-sanity.yml new file mode 100644 index 0000000000..ea72d90615 --- /dev/null +++ b/changelogs/fragments/5565-jenkins-plugin-sanity.yml @@ -0,0 +1,2 @@ +minor_changes: + - jenkins_plugin - refactor code to module util to fix sanity check (https://github.com/ansible-collections/community.general/pull/5565). diff --git a/plugins/module_utils/jenkins.py b/plugins/module_utils/jenkins.py new file mode 100644 index 0000000000..c742b364b7 --- /dev/null +++ b/plugins/module_utils/jenkins.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- + +# Copyright (c) 2022, Alexei Znamensky +# +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +import os +import time + + +def download_updates_file(updates_expiration): + updates_filename = 'jenkins-plugin-cache.json' + updates_dir = os.path.expanduser('~/.ansible/tmp') + updates_file = os.path.join(updates_dir, updates_filename) + download_updates = True + + # Make sure the destination directory exists + if not os.path.isdir(updates_dir): + os.makedirs(updates_dir, 0o700) + + # Check if we need to download new updates file + if os.path.isfile(updates_file): + # Get timestamp when the file was changed last time + ts_file = os.stat(updates_file).st_mtime + ts_now = time.time() + + if ts_now - ts_file < updates_expiration: + download_updates = False + + return updates_file, download_updates diff --git a/plugins/modules/jenkins_plugin.py b/plugins/modules/jenkins_plugin.py index 27261bf815..c4e1b7fb66 100644 --- a/plugins/modules/jenkins_plugin.py +++ b/plugins/modules/jenkins_plugin.py @@ -290,12 +290,6 @@ state: sample: "present" ''' -from ansible.module_utils.basic import AnsibleModule, to_bytes -from ansible.module_utils.six.moves import http_cookiejar as cookiejar -from ansible.module_utils.six.moves.urllib.parse import urlencode -from ansible.module_utils.urls import fetch_url, url_argument_spec -from ansible.module_utils.six import text_type, binary_type -from ansible.module_utils.common.text.converters import to_native import hashlib import io import json @@ -303,6 +297,15 @@ import os import tempfile import time +from ansible.module_utils.basic import AnsibleModule, to_bytes +from ansible.module_utils.six.moves import http_cookiejar as cookiejar +from ansible.module_utils.six.moves.urllib.parse import urlencode +from ansible.module_utils.urls import fetch_url, url_argument_spec +from ansible.module_utils.six import text_type, binary_type +from ansible.module_utils.common.text.converters import to_native + +from ansible_collections.community.general.plugins.module_utils.jenkins import download_updates_file + class FailedInstallingWithPluginManager(Exception): pass @@ -605,21 +608,12 @@ class JenkinsPlugin(object): return urls def _download_updates(self): - updates_filename = 'jenkins-plugin-cache.json' - updates_dir = os.path.expanduser('~/.ansible/tmp') - updates_file = "%s/%s" % (updates_dir, updates_filename) - download_updates = True - - # Check if we need to download new updates file - if os.path.isfile(updates_file): - # Get timestamp when the file was changed last time - ts_file = os.stat(updates_file).st_mtime - ts_now = time.time() - - if ts_now - ts_file < self.params['updates_expiration']: - download_updates = False - - updates_file_orig = updates_file + try: + updates_file, download_updates = download_updates_file(self.params['updates_expiration']) + except OSError as e: + self.module.fail_json( + msg="Cannot create temporal directory.", + details=to_native(e)) # Download the updates file if needed if download_updates: @@ -632,56 +626,39 @@ class JenkinsPlugin(object): msg_exception="Updates download failed.") # Write the updates file - update_fd, updates_file = tempfile.mkstemp() - os.write(update_fd, r.read()) + tmp_update_fd, tmp_updates_file = tempfile.mkstemp() + os.write(tmp_update_fd, r.read()) try: - os.close(update_fd) + os.close(tmp_update_fd) except IOError as e: self.module.fail_json( - msg="Cannot close the tmp updates file %s." % updates_file, + msg="Cannot close the tmp updates file %s." % tmp_updates_file, details=to_native(e)) # Open the updates file try: - f = io.open(updates_file, encoding='utf-8') + f = io.open(tmp_updates_file, encoding='utf-8') + + # Read only the second line + dummy = f.readline() + data = json.loads(f.readline()) except IOError as e: self.module.fail_json( msg="Cannot open temporal updates file.", details=to_native(e)) - - i = 0 - for line in f: - # Read only the second line - if i == 1: - try: - data = json.loads(line) - except Exception as e: - self.module.fail_json( - msg="Cannot load JSON data from the tmp updates file.", - details=to_native(e)) - - break - - i += 1 + except Exception as e: + self.module.fail_json( + msg="Cannot load JSON data from the tmp updates file.", + details=to_native(e)) # Move the updates file to the right place if we could read it if download_updates: - # Make sure the destination directory exists - if not os.path.isdir(updates_dir): - try: - os.makedirs(updates_dir, int('0700', 8)) - except OSError as e: - self.module.fail_json( - msg="Cannot create temporal directory.", - details=to_native(e)) - - self.module.atomic_move(updates_file, updates_file_orig) + self.module.atomic_move(tmp_updates_file, updates_file) # Check if we have the plugin data available - if 'plugins' not in data or self.params['name'] not in data['plugins']: - self.module.fail_json( - msg="Cannot find plugin data in the updates file.") + if not data.get('plugins', {}).get(self.params['name']): + self.module.fail_json(msg="Cannot find plugin data in the updates file.") return data['plugins'][self.params['name']] diff --git a/tests/sanity/ignore-2.11.txt b/tests/sanity/ignore-2.11.txt index 8ca3e163da..8dd9768f91 100644 --- a/tests/sanity/ignore-2.11.txt +++ b/tests/sanity/ignore-2.11.txt @@ -9,7 +9,6 @@ plugins/modules/consul.py validate-modules:undocumented-parameter plugins/modules/consul_session.py validate-modules:parameter-state-invalid-choice plugins/modules/gconftool2.py validate-modules:parameter-state-invalid-choice # state=get - removed in 8.0.0 plugins/modules/iptables_state.py validate-modules:undocumented-parameter -plugins/modules/jenkins_plugin.py use-argspec-type-path plugins/modules/lxc_container.py validate-modules:use-run-command-not-popen plugins/modules/manageiq_policies.py validate-modules:parameter-state-invalid-choice plugins/modules/manageiq_provider.py validate-modules:doc-choices-do-not-match-spec # missing docs on suboptions diff --git a/tests/sanity/ignore-2.12.txt b/tests/sanity/ignore-2.12.txt index 9c1ccbf433..22b506c3ce 100644 --- a/tests/sanity/ignore-2.12.txt +++ b/tests/sanity/ignore-2.12.txt @@ -4,7 +4,6 @@ plugins/modules/consul.py validate-modules:undocumented-parameter plugins/modules/consul_session.py validate-modules:parameter-state-invalid-choice plugins/modules/gconftool2.py validate-modules:parameter-state-invalid-choice # state=get - removed in 8.0.0 plugins/modules/iptables_state.py validate-modules:undocumented-parameter -plugins/modules/jenkins_plugin.py use-argspec-type-path plugins/modules/lxc_container.py validate-modules:use-run-command-not-popen plugins/modules/manageiq_policies.py validate-modules:parameter-state-invalid-choice plugins/modules/manageiq_provider.py validate-modules:doc-choices-do-not-match-spec # missing docs on suboptions diff --git a/tests/sanity/ignore-2.13.txt b/tests/sanity/ignore-2.13.txt index 9c1ccbf433..22b506c3ce 100644 --- a/tests/sanity/ignore-2.13.txt +++ b/tests/sanity/ignore-2.13.txt @@ -4,7 +4,6 @@ plugins/modules/consul.py validate-modules:undocumented-parameter plugins/modules/consul_session.py validate-modules:parameter-state-invalid-choice plugins/modules/gconftool2.py validate-modules:parameter-state-invalid-choice # state=get - removed in 8.0.0 plugins/modules/iptables_state.py validate-modules:undocumented-parameter -plugins/modules/jenkins_plugin.py use-argspec-type-path plugins/modules/lxc_container.py validate-modules:use-run-command-not-popen plugins/modules/manageiq_policies.py validate-modules:parameter-state-invalid-choice plugins/modules/manageiq_provider.py validate-modules:doc-choices-do-not-match-spec # missing docs on suboptions diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt index edf15c5cfc..5b788a517c 100644 --- a/tests/sanity/ignore-2.14.txt +++ b/tests/sanity/ignore-2.14.txt @@ -5,7 +5,6 @@ plugins/modules/consul_session.py validate-modules:parameter-state-invalid-choic plugins/modules/gconftool2.py validate-modules:parameter-state-invalid-choice # state=get - removed in 8.0.0 plugins/modules/homectl.py import-3.11 # Uses deprecated stdlib library 'crypt' plugins/modules/iptables_state.py validate-modules:undocumented-parameter -plugins/modules/jenkins_plugin.py use-argspec-type-path plugins/modules/lxc_container.py validate-modules:use-run-command-not-popen plugins/modules/manageiq_policies.py validate-modules:parameter-state-invalid-choice plugins/modules/manageiq_provider.py validate-modules:doc-choices-do-not-match-spec # missing docs on suboptions diff --git a/tests/sanity/ignore-2.15.txt b/tests/sanity/ignore-2.15.txt index edf15c5cfc..5b788a517c 100644 --- a/tests/sanity/ignore-2.15.txt +++ b/tests/sanity/ignore-2.15.txt @@ -5,7 +5,6 @@ plugins/modules/consul_session.py validate-modules:parameter-state-invalid-choic plugins/modules/gconftool2.py validate-modules:parameter-state-invalid-choice # state=get - removed in 8.0.0 plugins/modules/homectl.py import-3.11 # Uses deprecated stdlib library 'crypt' plugins/modules/iptables_state.py validate-modules:undocumented-parameter -plugins/modules/jenkins_plugin.py use-argspec-type-path plugins/modules/lxc_container.py validate-modules:use-run-command-not-popen plugins/modules/manageiq_policies.py validate-modules:parameter-state-invalid-choice plugins/modules/manageiq_provider.py validate-modules:doc-choices-do-not-match-spec # missing docs on suboptions From 52c28494ca903642aa4278afb580321302d119c9 Mon Sep 17 00:00:00 2001 From: David Stuart Date: Thu, 17 Nov 2022 05:56:21 +0000 Subject: [PATCH 0049/1810] Add additional flags to nmap.py (#5566) * Adding extra flag options for NMAP scaning udp_scan, icmp_timestamp and dns_resolve * Update nmap.py * Update plugins/inventory/nmap.py Co-authored-by: Felix Fontein * Updates as per felixfontein suggestions * Updates as per felixfontein suggestions * Update plugins/inventory/nmap.py Co-authored-by: Felix Fontein * Update plugins/inventory/nmap.py Co-authored-by: Felix Fontein * Update nmap.py * Update changelogs/fragments/5566-additional-flags-nmap.yml Co-authored-by: Felix Fontein * Update changelogs/fragments/5566-additional-flags-nmap.yml Co-authored-by: Felix Fontein * Update 5566-additional-flags-nmap.yml * Update nmap.py Co-authored-by: Axis12 <3225945+axistwelve@users.noreply.github.com> Co-authored-by: Felix Fontein --- .../fragments/5566-additional-flags-nmap.yml | 3 ++ plugins/inventory/nmap.py | 28 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 changelogs/fragments/5566-additional-flags-nmap.yml diff --git a/changelogs/fragments/5566-additional-flags-nmap.yml b/changelogs/fragments/5566-additional-flags-nmap.yml new file mode 100644 index 0000000000..d42f3a4695 --- /dev/null +++ b/changelogs/fragments/5566-additional-flags-nmap.yml @@ -0,0 +1,3 @@ +minor_changes: + - nmap inventory plugin - add new options ``udp_scan``, ``icmp_timestamp``, and ``dns_resolve`` for different types of scans (https://github.com/ansible-collections/community.general/pull/5566). + diff --git a/plugins/inventory/nmap.py b/plugins/inventory/nmap.py index 01a5fa04ba..f0fa50e3b3 100644 --- a/plugins/inventory/nmap.py +++ b/plugins/inventory/nmap.py @@ -46,6 +46,25 @@ DOCUMENTATION = ''' description: use IPv6 type addresses type: boolean default: true + udp_scan: + description: + - Scan via UDP. + - Depending on your system you might need I(sudo=true) for this to work. + type: boolean + default: false + version_added: 6.1.0 + icmp_timestamp: + description: + - Scan via ICMP Timestamp (C(-PP)). + - Depending on your system you might need I(sudo=true) for this to work. + type: boolean + default: false + version_added: 6.1.0 + dns_resolve: + description: Whether to always (C(true)) or never (C(false)) do DNS resolution. + type: boolean + default: false + version_added: 6.1.0 notes: - At least one of ipv4 or ipv6 is required to be True, both can be True, but they cannot both be False. - 'TODO: add OS fingerprinting' @@ -166,6 +185,15 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable): cmd.append('--exclude') cmd.append(','.join(self._options['exclude'])) + if self._options['dns_resolve']: + cmd.append('-n') + + if self._options['udp_scan']: + cmd.append('-sU') + + if self._options['icmp_timestamp']: + cmd.append('-PP') + cmd.append(self._options['address']) try: # execute From 83ff4429e887c89edfb7f6c494d2a755fd75a3fd Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Thu, 17 Nov 2022 19:19:30 +1300 Subject: [PATCH 0050/1810] scaleway_organization_info: sanity checks (#5571) * scaleway_organization_info: fix sanity checks * remove lines from ignore files * Update plugins/modules/scaleway_organization_info.py Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein --- plugins/modules/scaleway_organization_info.py | 3 ++- tests/sanity/ignore-2.11.txt | 1 - tests/sanity/ignore-2.12.txt | 1 - tests/sanity/ignore-2.13.txt | 1 - tests/sanity/ignore-2.14.txt | 1 - tests/sanity/ignore-2.15.txt | 1 - 6 files changed, 2 insertions(+), 6 deletions(-) diff --git a/plugins/modules/scaleway_organization_info.py b/plugins/modules/scaleway_organization_info.py index 6e1f8df388..717c47db19 100644 --- a/plugins/modules/scaleway_organization_info.py +++ b/plugins/modules/scaleway_organization_info.py @@ -44,7 +44,8 @@ RETURN = r''' scaleway_organization_info: description: Response from Scaleway API returned: success - type: complex + type: list + elements: dict sample: "scaleway_organization_info": [ { diff --git a/tests/sanity/ignore-2.11.txt b/tests/sanity/ignore-2.11.txt index 8dd9768f91..86d7f6a9e2 100644 --- a/tests/sanity/ignore-2.11.txt +++ b/tests/sanity/ignore-2.11.txt @@ -24,7 +24,6 @@ plugins/modules/rax_files_objects.py use-argspec-type-path plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice plugins/modules/rax.py use-argspec-type-path # fix needed plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice -plugins/modules/scaleway_organization_info.py validate-modules:return-syntax-error plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path plugins/modules/udm_share.py validate-modules:parameter-list-no-elements plugins/modules/udm_user.py validate-modules:parameter-list-no-elements diff --git a/tests/sanity/ignore-2.12.txt b/tests/sanity/ignore-2.12.txt index 22b506c3ce..45772005a3 100644 --- a/tests/sanity/ignore-2.12.txt +++ b/tests/sanity/ignore-2.12.txt @@ -19,7 +19,6 @@ plugins/modules/rax_files_objects.py use-argspec-type-path plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice plugins/modules/rax.py use-argspec-type-path # fix needed plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice -plugins/modules/scaleway_organization_info.py validate-modules:return-syntax-error plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path plugins/modules/udm_share.py validate-modules:parameter-list-no-elements plugins/modules/udm_user.py validate-modules:parameter-list-no-elements diff --git a/tests/sanity/ignore-2.13.txt b/tests/sanity/ignore-2.13.txt index 22b506c3ce..45772005a3 100644 --- a/tests/sanity/ignore-2.13.txt +++ b/tests/sanity/ignore-2.13.txt @@ -19,7 +19,6 @@ plugins/modules/rax_files_objects.py use-argspec-type-path plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice plugins/modules/rax.py use-argspec-type-path # fix needed plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice -plugins/modules/scaleway_organization_info.py validate-modules:return-syntax-error plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path plugins/modules/udm_share.py validate-modules:parameter-list-no-elements plugins/modules/udm_user.py validate-modules:parameter-list-no-elements diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt index 5b788a517c..49c2eb1bb2 100644 --- a/tests/sanity/ignore-2.14.txt +++ b/tests/sanity/ignore-2.14.txt @@ -20,7 +20,6 @@ plugins/modules/rax_files_objects.py use-argspec-type-path plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice plugins/modules/rax.py use-argspec-type-path # fix needed plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice -plugins/modules/scaleway_organization_info.py validate-modules:return-syntax-error plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path plugins/modules/udm_share.py validate-modules:parameter-list-no-elements plugins/modules/udm_user.py import-3.11 # Uses deprecated stdlib library 'crypt' diff --git a/tests/sanity/ignore-2.15.txt b/tests/sanity/ignore-2.15.txt index 5b788a517c..49c2eb1bb2 100644 --- a/tests/sanity/ignore-2.15.txt +++ b/tests/sanity/ignore-2.15.txt @@ -20,7 +20,6 @@ plugins/modules/rax_files_objects.py use-argspec-type-path plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice plugins/modules/rax.py use-argspec-type-path # fix needed plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice -plugins/modules/scaleway_organization_info.py validate-modules:return-syntax-error plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path plugins/modules/udm_share.py validate-modules:parameter-list-no-elements plugins/modules/udm_user.py import-3.11 # Uses deprecated stdlib library 'crypt' From c7481c5c96536a6bb8a0c32639706bada10346bb Mon Sep 17 00:00:00 2001 From: Guillaume MARTINEZ Date: Fri, 18 Nov 2022 23:49:25 +0100 Subject: [PATCH 0051/1810] [GitLab] Add modules to manager project badges (#5534) * [GitLab] Add modules to manager project badges Signed-off-by: Lunik * first review Signed-off-by: Lunik * Update plugins/modules/gitlab_project_badge.py Co-authored-by: Felix Fontein Signed-off-by: Lunik Co-authored-by: Felix Fontein --- plugins/modules/gitlab_project_badge.py | 216 ++++++++++++++++++ .../targets/gitlab_project_badge/aliases | 6 + .../gitlab_project_badge/defaults/main.yml | 11 + .../gitlab_project_badge/tasks/main.yml | 214 +++++++++++++++++ 4 files changed, 447 insertions(+) create mode 100644 plugins/modules/gitlab_project_badge.py create mode 100644 tests/integration/targets/gitlab_project_badge/aliases create mode 100644 tests/integration/targets/gitlab_project_badge/defaults/main.yml create mode 100644 tests/integration/targets/gitlab_project_badge/tasks/main.yml diff --git a/plugins/modules/gitlab_project_badge.py b/plugins/modules/gitlab_project_badge.py new file mode 100644 index 0000000000..5b1a8d3f1c --- /dev/null +++ b/plugins/modules/gitlab_project_badge.py @@ -0,0 +1,216 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2022, Guillaume MARTINEZ (lunik@tiwabbit.fr) +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = r''' +--- +module: gitlab_project_badge +short_description: Manage project badges on GitLab Server +version_added: 6.1.0 +description: + - This module allows to add and remove badges to/from a project. +author: Guillaume MARTINEZ (@Lunik) +requirements: + - C(owner) or C(maintainer) rights to project on the GitLab server +extends_documentation_fragment: + - community.general.auth_basic + - community.general.gitlab + - community.general.attributes + +attributes: + check_mode: + support: full + diff_mode: + support: none + +options: + project: + description: + - The name (or full path) of the GitLab project the badge is added to/removed from. + required: true + type: str + + state: + description: + - State of the badge in the project. + - On C(present), it adds a badge to a GitLab project. + - On C(absent), it removes a badge from a GitLab project. + choices: ['present', 'absent'] + default: 'present' + type: str + + link_url: + description: + - The URL associated with the badge. + required: true + type: str + + image_url: + description: + - The image URL of the badge. + - A badge is identified by this URL. + required: true + type: str +''' + +EXAMPLES = r''' +- name: Add a badge to a GitLab Project + community.general.gitlab_project_badge: + api_url: 'https://example.gitlab.com' + api_token: 'Your-Private-Token' + project: projectname + state: present + link_url: 'https://example.gitlab.com/%{project_path}' + image_url: 'https://example.gitlab.com/%{project_path}/badges/%{default_branch}/pipeline.svg' + +- name: Remove a badge from a GitLab Project + community.general.gitlab_project_badge: + api_url: 'https://example.gitlab.com' + api_token: 'Your-Private-Token' + project: projectname + state: absent + link_url: 'https://example.gitlab.com/%{project_path}' + image_url: 'https://example.gitlab.com/%{project_path}/badges/%{default_branch}/pipeline.svg' +''' + +RETURN = ''' +badge: + description: The badge information. + returned: when I(state=present) + type: dict + sample: + id: 1 + link_url: 'http://example.com/ci_status.svg?project=%{project_path}&ref=%{default_branch}' + image_url: 'https://shields.io/my/badge' + rendered_link_url: 'http://example.com/ci_status.svg?project=example-org/example-project&ref=master' + rendered_image_url: 'https://shields.io/my/badge' + kind: project +''' + +from ansible.module_utils.api import basic_auth_argument_spec +from ansible.module_utils.basic import AnsibleModule + +from ansible_collections.community.general.plugins.module_utils.gitlab import ( + auth_argument_spec, gitlab_authentication, find_project, ensure_gitlab_package +) + + +def present_strategy(module, gl, project, wished_badge): + changed = False + + existing_badge = None + for badge in project.badges.list(iterator=True): + if badge.image_url == wished_badge["image_url"]: + existing_badge = badge + break + + if not existing_badge: + changed = True + if module.check_mode: + return changed, {"status": "A project badge would be created."} + + badge = project.badges.create(wished_badge) + return changed, badge.attributes + + if existing_badge.link_url != wished_badge["link_url"]: + changed = True + existing_badge.link_url = wished_badge["link_url"] + + if changed: + if module.check_mode: + return changed, {"status": "Project badge attributes would be changed."} + + existing_badge.save() + + return changed, existing_badge.attributes + + +def absent_strategy(module, gl, project, wished_badge): + changed = False + + existing_badge = None + for badge in project.badges.list(iterator=True): + if badge.image_url == wished_badge["image_url"]: + existing_badge = badge + break + + if not existing_badge: + return changed, None + + changed = True + if module.check_mode: + return changed, {"status": "Project badge would be destroyed."} + + existing_badge.delete() + + return changed, None + + +state_strategy = { + "present": present_strategy, + "absent": absent_strategy +} + + +def core(module): + ensure_gitlab_package(module) + + gitlab_project = module.params['project'] + state = module.params['state'] + + gl = gitlab_authentication(module) + + project = find_project(gl, gitlab_project) + # project doesn't exist + if not project: + module.fail_json(msg="project '%s' not found." % gitlab_project) + + wished_badge = { + "link_url": module.params["link_url"], + "image_url": module.params["image_url"], + } + + changed, summary = state_strategy[state](module=module, gl=gl, project=project, wished_badge=wished_badge) + + module.exit_json(changed=changed, badge=summary) + + +def main(): + argument_spec = basic_auth_argument_spec() + argument_spec.update(auth_argument_spec()) + argument_spec.update(dict( + project=dict(type='str', required=True), + state=dict(type='str', default='present', choices=['present', 'absent']), + link_url=dict(type='str', required=True), + image_url=dict(type='str', required=True), + )) + + module = AnsibleModule( + argument_spec=argument_spec, + mutually_exclusive=[ + ['api_username', 'api_token'], + ['api_username', 'api_oauth_token'], + ['api_username', 'api_job_token'], + ['api_token', 'api_oauth_token'], + ['api_token', 'api_job_token'], + ], + required_together=[ + ['api_username', 'api_password'], + ], + required_one_of=[ + ['api_username', 'api_token', 'api_oauth_token', 'api_job_token'], + ], + supports_check_mode=True, + ) + + core(module) + + +if __name__ == '__main__': + main() diff --git a/tests/integration/targets/gitlab_project_badge/aliases b/tests/integration/targets/gitlab_project_badge/aliases new file mode 100644 index 0000000000..9f72f37111 --- /dev/null +++ b/tests/integration/targets/gitlab_project_badge/aliases @@ -0,0 +1,6 @@ +# Copyright (c) 2022, Guillaume MARTINEZ (lunik@tiwabbit.fr) +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +gitlab/ci +disabled diff --git a/tests/integration/targets/gitlab_project_badge/defaults/main.yml b/tests/integration/targets/gitlab_project_badge/defaults/main.yml new file mode 100644 index 0000000000..bf84a4751a --- /dev/null +++ b/tests/integration/targets/gitlab_project_badge/defaults/main.yml @@ -0,0 +1,11 @@ +--- +# Copyright (c) 2022, Guillaume MARTINEZ +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +gitlab_api_token: glpat-XXXXXXXXXXXXXXXXXXXX +gitlab_api_url: https://gitlab.com +gitlab_project_name: ansible_test_project +gitlab_badge_link_url: 'https://example.gitlab.com/%{project_path}' +updated_gitlab_badge_link_url: 'https://test.gitlab.com/%{project_path}' +gitlab_badge_image_url: 'https://example.gitlab.com/%{project_path}/badges/%{default_branch}/pipeline.svg' \ No newline at end of file diff --git a/tests/integration/targets/gitlab_project_badge/tasks/main.yml b/tests/integration/targets/gitlab_project_badge/tasks/main.yml new file mode 100644 index 0000000000..fa8a806efe --- /dev/null +++ b/tests/integration/targets/gitlab_project_badge/tasks/main.yml @@ -0,0 +1,214 @@ +--- +#################################################################### +# WARNING: These are designed specifically for Ansible tests # +# and should not be used as examples of how to write Ansible roles # +#################################################################### + +# Copyright (c) 2022, Guillaume MARTINEZ +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +- name: Install required libs + pip: + name: python-gitlab + state: present + +- name: Create {{ gitlab_project_name }} + gitlab_project: + api_url: "{{ gitlab_api_url }}" + validate_certs: False + api_token: "{{ gitlab_api_token }}" + name: "{{ gitlab_project_name }}" + initialize_with_readme: True + state: present + +- name: Create Badge (check) + check_mode: yes + gitlab_project_badge: + api_url: "{{ gitlab_api_url }}" + validate_certs: False + api_token: "{{ gitlab_api_token }}" + project: "{{ gitlab_project_name }}" + state: present + link_url: "{{ gitlab_badge_link_url }}" + image_url: "{{ gitlab_badge_image_url }}" + register: gitlab_badge_create_check_task + +- ansible.builtin.debug: + var: gitlab_badge_create_check_task + +- name: Check module call result + assert: + that: + - gitlab_badge_create_check_task.changed + - not gitlab_badge_create_check_task.failed + +- name: Create Badge + gitlab_project_badge: + api_url: "{{ gitlab_api_url }}" + validate_certs: False + api_token: "{{ gitlab_api_token }}" + project: "{{ gitlab_project_name }}" + state: present + link_url: "{{ gitlab_badge_link_url }}" + image_url: "{{ gitlab_badge_image_url }}" + register: gitlab_badge_create_task + +- ansible.builtin.debug: + var: gitlab_badge_create_task + +- name: Check module call result + assert: + that: + - gitlab_badge_create_task.changed + - not gitlab_badge_create_task.failed + +- name: Create Badge (confirmation) + gitlab_project_badge: + api_url: "{{ gitlab_api_url }}" + validate_certs: False + api_token: "{{ gitlab_api_token }}" + project: "{{ gitlab_project_name }}" + state: present + link_url: "{{ gitlab_badge_link_url }}" + image_url: "{{ gitlab_badge_image_url }}" + register: gitlab_badge_create_confirmation_task + +- ansible.builtin.debug: + var: gitlab_badge_create_confirmation_task + +- name: Check module call result + assert: + that: + - not gitlab_badge_create_confirmation_task.changed + - not gitlab_badge_create_confirmation_task.failed + +- name: Update Badge (check) + check_mode: yes + gitlab_project_badge: + api_url: "{{ gitlab_api_url }}" + validate_certs: False + api_token: "{{ gitlab_api_token }}" + project: "{{ gitlab_project_name }}" + state: present + link_url: "{{ updated_gitlab_badge_link_url }}" + image_url: "{{ gitlab_badge_image_url }}" + register: gitlab_badge_update_check_task + +- ansible.builtin.debug: + var: gitlab_badge_update_check_task + +- name: Check module call result + assert: + that: + - gitlab_badge_update_check_task.changed + - not gitlab_badge_update_check_task.failed + +- name: Update Badge + gitlab_project_badge: + api_url: "{{ gitlab_api_url }}" + validate_certs: False + api_token: "{{ gitlab_api_token }}" + project: "{{ gitlab_project_name }}" + state: present + link_url: "{{ updated_gitlab_badge_link_url }}" + image_url: "{{ gitlab_badge_image_url }}" + register: gitlab_badge_update_task + +- ansible.builtin.debug: + var: gitlab_badge_update_task + +- name: Check module call result + assert: + that: + - gitlab_badge_update_task.changed + - not gitlab_badge_update_task.failed + +- name: Update Badge (confirmation) + gitlab_project_badge: + api_url: "{{ gitlab_api_url }}" + validate_certs: False + api_token: "{{ gitlab_api_token }}" + project: "{{ gitlab_project_name }}" + state: present + link_url: "{{ updated_gitlab_badge_link_url }}" + image_url: "{{ gitlab_badge_image_url }}" + register: gitlab_badge_update_confirmation_task + +- ansible.builtin.debug: + var: gitlab_badge_update_confirmation_task + +- name: Check module call result + assert: + that: + - not gitlab_badge_update_confirmation_task.changed + - not gitlab_badge_update_confirmation_task.failed + +- name: Delete Badge (check) + check_mode: yes + gitlab_project_badge: + api_url: "{{ gitlab_api_url }}" + validate_certs: False + api_token: "{{ gitlab_api_token }}" + project: "{{ gitlab_project_name }}" + state: absent + link_url: "{{ updated_gitlab_badge_link_url }}" + image_url: "{{ gitlab_badge_image_url }}" + register: gitlab_badge_delete_check_task + +- ansible.builtin.debug: + var: gitlab_badge_delete_check_task + +- name: Check module call result + assert: + that: + - gitlab_badge_delete_check_task.changed + - not gitlab_badge_delete_check_task.failed + +- name: Delete Badge + gitlab_project_badge: + api_url: "{{ gitlab_api_url }}" + validate_certs: False + api_token: "{{ gitlab_api_token }}" + project: "{{ gitlab_project_name }}" + state: absent + link_url: "{{ updated_gitlab_badge_link_url }}" + image_url: "{{ gitlab_badge_image_url }}" + register: gitlab_badge_delete_task + +- ansible.builtin.debug: + var: gitlab_badge_delete_task + +- name: Check module call result + assert: + that: + - gitlab_badge_delete_task.changed + - not gitlab_badge_delete_task.failed + +- name: Delete Badge (confirmation) + gitlab_project_badge: + api_url: "{{ gitlab_api_url }}" + validate_certs: False + api_token: "{{ gitlab_api_token }}" + project: "{{ gitlab_project_name }}" + state: absent + link_url: "{{ updated_gitlab_badge_link_url }}" + image_url: "{{ gitlab_badge_image_url }}" + register: gitlab_badge_delete_confirmation_task + +- ansible.builtin.debug: + var: gitlab_badge_delete_confirmation_task + +- name: Check module call result + assert: + that: + - not gitlab_badge_delete_confirmation_task.changed + - not gitlab_badge_delete_confirmation_task.failed + +- name: Clean up {{ gitlab_project_name }} + gitlab_project: + api_url: "{{ gitlab_api_url }}" + validate_certs: False + api_token: "{{ gitlab_api_token }}" + name: "{{ gitlab_project_name }}" + state: absent From f2a420ead5d14055b500215689b4b517c031f67e Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Tue, 22 Nov 2022 12:50:21 +0100 Subject: [PATCH 0052/1810] Another try: fix languages to check. (#5587) --- .github/workflows/codeql-analysis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 2d93f5efef..4b11b4fd9e 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -28,9 +28,8 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v2 - # Override language selection by uncommenting this and choosing your languages - # with: - # languages: go, javascript, csharp, python, cpp, java + with: + languages: python - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v2 From 3bf3d6bff44934a5dcd654180cc95a74552f3ae4 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Tue, 22 Nov 2022 12:51:25 +0100 Subject: [PATCH 0053/1810] Allow to trigger manual code scanning run. --- .github/workflows/codeql-analysis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 4b11b4fd9e..620de35af5 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -8,6 +8,7 @@ name: "Code scanning - action" on: schedule: - cron: '26 19 * * 1' + workflow_dispatch: permissions: contents: read From 5c1c8152ec1c392e11fe1242dbbb24fe8ea3fdb8 Mon Sep 17 00:00:00 2001 From: Mike Raineri Date: Wed, 23 Nov 2022 01:46:39 -0500 Subject: [PATCH 0054/1810] Redfish: Expanded SimpleUpdate command to allow for users to monitor the progress of an update and perform follow-up operations (#5580) * Redfish: Expanded SimpleUpdate command to allow for users to monitor the progress of an update and perform follow-up operations * Update changelogs/fragments/3910-redfish-add-operation-apply-time-to-simple-update.yml Co-authored-by: Felix Fontein * Update plugins/modules/redfish_command.py Co-authored-by: Felix Fontein * Update changelogs/fragments/4276-redfish-command-updates-for-full-simple-update-workflow.yml Co-authored-by: Felix Fontein * Updated based on feedback and CI results * Update plugins/modules/redfish_command.py Co-authored-by: Felix Fontein * Update plugins/modules/redfish_command.py Co-authored-by: Felix Fontein * Update plugins/modules/redfish_info.py Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein --- ...-operation-apply-time-to-simple-update.yml | 2 + ...pdates-for-full-simple-update-workflow.yml | 4 + plugins/module_utils/redfish_utils.py | 136 +++++++++++++++++- plugins/modules/redfish_command.py | 58 +++++++- plugins/modules/redfish_info.py | 26 +++- 5 files changed, 218 insertions(+), 8 deletions(-) create mode 100644 changelogs/fragments/3910-redfish-add-operation-apply-time-to-simple-update.yml create mode 100644 changelogs/fragments/4276-redfish-command-updates-for-full-simple-update-workflow.yml diff --git a/changelogs/fragments/3910-redfish-add-operation-apply-time-to-simple-update.yml b/changelogs/fragments/3910-redfish-add-operation-apply-time-to-simple-update.yml new file mode 100644 index 0000000000..d52438ca45 --- /dev/null +++ b/changelogs/fragments/3910-redfish-add-operation-apply-time-to-simple-update.yml @@ -0,0 +1,2 @@ +minor_changes: + - redfish_command - add ``update_apply_time`` to ``SimpleUpdate`` command (https://github.com/ansible-collections/community.general/issues/3910). diff --git a/changelogs/fragments/4276-redfish-command-updates-for-full-simple-update-workflow.yml b/changelogs/fragments/4276-redfish-command-updates-for-full-simple-update-workflow.yml new file mode 100644 index 0000000000..2f5da1467b --- /dev/null +++ b/changelogs/fragments/4276-redfish-command-updates-for-full-simple-update-workflow.yml @@ -0,0 +1,4 @@ +minor_changes: + - redfish_command - add ``update_status`` to output of ``SimpleUpdate`` command to allow a user monitor the update in progress (https://github.com/ansible-collections/community.general/issues/4276). + - redfish_info - add ``GetUpdateStatus`` command to check the progress of a previous update request (https://github.com/ansible-collections/community.general/issues/4276). + - redfish_command - add ``PerformRequestedOperations`` command to perform any operations necessary to continue the update flow (https://github.com/ansible-collections/community.general/issues/4276). diff --git a/plugins/module_utils/redfish_utils.py b/plugins/module_utils/redfish_utils.py index 3bd3d73676..a86baa1066 100644 --- a/plugins/module_utils/redfish_utils.py +++ b/plugins/module_utils/redfish_utils.py @@ -143,7 +143,7 @@ class RedfishUtils(object): except Exception as e: return {'ret': False, 'msg': "Failed GET request to '%s': '%s'" % (uri, to_text(e))} - return {'ret': True, 'data': data, 'headers': headers} + return {'ret': True, 'data': data, 'headers': headers, 'resp': resp} def post_request(self, uri, pyld): req_headers = dict(POST_HEADERS) @@ -155,6 +155,11 @@ class RedfishUtils(object): force_basic_auth=basic_auth, validate_certs=False, follow_redirects='all', use_proxy=True, timeout=self.timeout) + try: + data = json.loads(to_native(resp.read())) + except Exception as e: + # No response data; this is okay in many cases + data = None headers = dict((k.lower(), v) for (k, v) in resp.info().items()) except HTTPError as e: msg = self._get_extended_message(e) @@ -169,7 +174,7 @@ class RedfishUtils(object): except Exception as e: return {'ret': False, 'msg': "Failed POST request to '%s': '%s'" % (uri, to_text(e))} - return {'ret': True, 'headers': headers, 'resp': resp} + return {'ret': True, 'data': data, 'headers': headers, 'resp': resp} def patch_request(self, uri, pyld, check_pyld=False): req_headers = dict(PATCH_HEADERS) @@ -1384,11 +1389,82 @@ class RedfishUtils(object): else: return self._software_inventory(self.software_uri) + def _operation_results(self, response, data, handle=None): + """ + Builds the results for an operation from task, job, or action response. + + :param response: HTTP response object + :param data: HTTP response data + :param handle: The task or job handle that was last used + :return: dict containing operation results + """ + + operation_results = {'status': None, 'messages': [], 'handle': None, 'ret': True, + 'resets_requested': []} + + if response.status == 204: + # No content; successful, but nothing to return + # Use the Redfish "Completed" enum from TaskState for the operation status + operation_results['status'] = 'Completed' + else: + # Parse the response body for details + + # Determine the next handle, if any + operation_results['handle'] = handle + if response.status == 202: + # Task generated; get the task monitor URI + operation_results['handle'] = response.getheader('Location', handle) + + # Pull out the status and messages based on the body format + if data is not None: + response_type = data.get('@odata.type', '') + if response_type.startswith('#Task.') or response_type.startswith('#Job.'): + # Task and Job have similar enough structures to treat the same + operation_results['status'] = data.get('TaskState', data.get('JobState')) + operation_results['messages'] = data.get('Messages', []) + else: + # Error response body, which is a bit of a misnomer since it's used in successful action responses + operation_results['status'] = 'Completed' + if response.status >= 400: + operation_results['status'] = 'Exception' + operation_results['messages'] = data.get('error', {}).get('@Message.ExtendedInfo', []) + else: + # No response body (or malformed); build based on status code + operation_results['status'] = 'Completed' + if response.status == 202: + operation_results['status'] = 'New' + elif response.status >= 400: + operation_results['status'] = 'Exception' + + # Clear out the handle if the operation is complete + if operation_results['status'] in ['Completed', 'Cancelled', 'Exception', 'Killed']: + operation_results['handle'] = None + + # Scan the messages to see if next steps are needed + for message in operation_results['messages']: + message_id = message['MessageId'] + + if message_id.startswith('Update.1.') and message_id.endswith('.OperationTransitionedToJob'): + # Operation rerouted to a job; update the status and handle + operation_results['status'] = 'New' + operation_results['handle'] = message['MessageArgs'][0] + operation_results['resets_requested'] = [] + # No need to process other messages in this case + break + + if message_id.startswith('Base.1.') and message_id.endswith('.ResetRequired'): + # A reset to some device is needed to continue the update + reset = {'uri': message['MessageArgs'][0], 'type': message['MessageArgs'][1]} + operation_results['resets_requested'].append(reset) + + return operation_results + def simple_update(self, update_opts): image_uri = update_opts.get('update_image_uri') protocol = update_opts.get('update_protocol') targets = update_opts.get('update_targets') creds = update_opts.get('update_creds') + apply_time = update_opts.get('update_apply_time') if not image_uri: return {'ret': False, 'msg': @@ -1439,11 +1515,65 @@ class RedfishUtils(object): payload["Username"] = creds.get('username') if creds.get('password'): payload["Password"] = creds.get('password') + if apply_time: + payload["@Redfish.OperationApplyTime"] = apply_time response = self.post_request(self.root_uri + update_uri, payload) if response['ret'] is False: return response return {'ret': True, 'changed': True, - 'msg': "SimpleUpdate requested"} + 'msg': "SimpleUpdate requested", + 'update_status': self._operation_results(response['resp'], response['data'])} + + def get_update_status(self, update_handle): + """ + Gets the status of an update operation. + + :param handle: The task or job handle tracking the update + :return: dict containing the response of the update status + """ + + if not update_handle: + return {'ret': False, 'msg': 'Must provide a handle tracking the update.'} + + # Get the task or job tracking the update + response = self.get_request(self.root_uri + update_handle) + if response['ret'] is False: + return response + + # Inspect the response to build the update status + return self._operation_results(response['resp'], response['data'], update_handle) + + def perform_requested_update_operations(self, update_handle): + """ + Performs requested operations to allow the update to continue. + + :param handle: The task or job handle tracking the update + :return: dict containing the result of the operations + """ + + # Get the current update status + update_status = self.get_update_status(update_handle) + if update_status['ret'] is False: + return update_status + + changed = False + + # Perform any requested updates + for reset in update_status['resets_requested']: + resp = self.post_request(self.root_uri + reset['uri'], {'ResetType': reset['type']}) + if resp['ret'] is False: + # Override the 'changed' indicator since other resets may have + # been successful + resp['changed'] = changed + return resp + changed = True + + msg = 'No operations required for the update' + if changed: + # Will need to consider finetuning this message if the scope of the + # requested operations grow over time + msg = 'One or more components reset to continue the update' + return {'ret': True, 'changed': changed, 'msg': msg} def get_bios_attributes(self, systems_uri): result = {} diff --git a/plugins/modules/redfish_command.py b/plugins/modules/redfish_command.py index 43443cf38e..9d5640996a 100644 --- a/plugins/modules/redfish_command.py +++ b/plugins/modules/redfish_command.py @@ -161,6 +161,24 @@ options: description: - Password for retrieving the update image. type: str + update_apply_time: + required: false + description: + - Time when to apply the update. + type: str + choices: + - Immediate + - OnReset + - AtMaintenanceWindowStart + - InMaintenanceWindowOnReset + - OnStartUpdateRequest + version_added: '6.1.0' + update_handle: + required: false + description: + - Handle to check the status of an update in progress. + type: str + version_added: '6.1.0' virtual_media: required: false description: @@ -508,6 +526,15 @@ EXAMPLES = ''' username: operator password: supersecretpwd + - name: Perform requested operations to continue the update + community.general.redfish_command: + category: Update + command: PerformRequestedOperations + baseuri: "{{ baseuri }}" + username: "{{ username }}" + password: "{{ password }}" + update_handle: /redfish/v1/TaskService/TaskMonitors/735 + - name: Insert Virtual Media community.general.redfish_command: category: Systems @@ -610,6 +637,20 @@ msg: returned: always type: str sample: "Action was successful" +return_values: + description: Dictionary containing command-specific response data from the action. + returned: on success + type: dict + version_added: 6.1.0 + sample: { + "update_status": { + "handle": "/redfish/v1/TaskService/TaskMonitors/735", + "messages": [], + "resets_requested": [], + "ret": true, + "status": "New" + } + } ''' from ansible.module_utils.basic import AnsibleModule @@ -630,12 +671,13 @@ CATEGORY_COMMANDS_ALL = { "Manager": ["GracefulRestart", "ClearLogs", "VirtualMediaInsert", "VirtualMediaEject", "PowerOn", "PowerForceOff", "PowerForceRestart", "PowerGracefulRestart", "PowerGracefulShutdown", "PowerReboot"], - "Update": ["SimpleUpdate"] + "Update": ["SimpleUpdate", "PerformRequestedOperations"], } def main(): result = {} + return_values = {} module = AnsibleModule( argument_spec=dict( category=dict(required=True), @@ -667,6 +709,9 @@ def main(): password=dict(no_log=True) ) ), + update_apply_time=dict(choices=['Immediate', 'OnReset', 'AtMaintenanceWindowStart', + 'InMaintenanceWindowOnReset', 'OnStartUpdateRequest']), + update_handle=dict(), virtual_media=dict( type='dict', options=dict( @@ -721,7 +766,9 @@ def main(): 'update_image_uri': module.params['update_image_uri'], 'update_protocol': module.params['update_protocol'], 'update_targets': module.params['update_targets'], - 'update_creds': module.params['update_creds'] + 'update_creds': module.params['update_creds'], + 'update_apply_time': module.params['update_apply_time'], + 'update_handle': module.params['update_handle'], } # Boot override options @@ -859,6 +906,10 @@ def main(): for command in command_list: if command == "SimpleUpdate": result = rf_utils.simple_update(update_opts) + if 'update_status' in result: + return_values['update_status'] = result['update_status'] + elif command == "PerformRequestedOperations": + result = rf_utils.perform_requested_update_operations(update_opts['update_handle']) # Return data back or fail with proper message if result['ret'] is True: @@ -866,7 +917,8 @@ def main(): changed = result.get('changed', True) session = result.get('session', dict()) module.exit_json(changed=changed, session=session, - msg='Action was successful') + msg='Action was successful', + return_values=return_values) else: module.fail_json(msg=to_native(result['msg'])) diff --git a/plugins/modules/redfish_info.py b/plugins/modules/redfish_info.py index fd81695368..e6df4813ad 100644 --- a/plugins/modules/redfish_info.py +++ b/plugins/modules/redfish_info.py @@ -58,6 +58,12 @@ options: - Timeout in seconds for HTTP requests to OOB controller. default: 10 type: int + update_handle: + required: false + description: + - Handle to check the status of an update in progress. + type: str + version_added: '6.1.0' author: "Jose Delarosa (@jose-delarosa)" ''' @@ -247,6 +253,15 @@ EXAMPLES = ''' username: "{{ username }}" password: "{{ password }}" + - name: Get the status of an update operation + community.general.redfish_info: + category: Update + command: GetUpdateStatus + baseuri: "{{ baseuri }}" + username: "{{ username }}" + password: "{{ password }}" + update_handle: /redfish/v1/TaskService/TaskMonitors/735 + - name: Get Manager Services community.general.redfish_info: category: Manager @@ -324,7 +339,8 @@ CATEGORY_COMMANDS_ALL = { "GetChassisThermals", "GetChassisInventory", "GetHealthReport"], "Accounts": ["ListUsers"], "Sessions": ["GetSessions"], - "Update": ["GetFirmwareInventory", "GetFirmwareUpdateCapabilities", "GetSoftwareInventory"], + "Update": ["GetFirmwareInventory", "GetFirmwareUpdateCapabilities", "GetSoftwareInventory", + "GetUpdateStatus"], "Manager": ["GetManagerNicInventory", "GetVirtualMedia", "GetLogs", "GetNetworkProtocols", "GetHealthReport", "GetHostInterfaces", "GetManagerInventory"], } @@ -350,7 +366,8 @@ def main(): username=dict(), password=dict(no_log=True), auth_token=dict(no_log=True), - timeout=dict(type='int', default=10) + timeout=dict(type='int', default=10), + update_handle=dict(), ), required_together=[ ('username', 'password'), @@ -372,6 +389,9 @@ def main(): # timeout timeout = module.params['timeout'] + # update handle + update_handle = module.params['update_handle'] + # Build root URI root_uri = "https://" + module.params['baseuri'] rf_utils = RedfishUtils(creds, root_uri, timeout, module) @@ -482,6 +502,8 @@ def main(): result["software"] = rf_utils.get_software_inventory() elif command == "GetFirmwareUpdateCapabilities": result["firmware_update_capabilities"] = rf_utils.get_firmware_update_capabilities() + elif command == "GetUpdateStatus": + result["update_status"] = rf_utils.get_update_status(update_handle) elif category == "Sessions": # execute only if we find SessionService resources From 79929830c401b5f127d95be71e4b81edf0f61986 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Thu, 24 Nov 2022 06:43:58 +1300 Subject: [PATCH 0055/1810] udm_user: sanity (#5559) * fix parameter email * fix parameter groups * fix parameters home_telephone_number, mail_alternative_address, mobile_telephone_number, pager_telephonenumber * fix parameter phone * fix parameter samba_privileges * fix parameter samba_user_workstations * fix parameter secretary * fix parameter serviceprovider * remove lines from ignore files * add changelog fragment --- changelogs/fragments/5559-udm-user-sanity.yml | 2 ++ plugins/modules/udm_user.py | 32 ++++++++++++++++--- tests/sanity/ignore-2.11.txt | 1 - tests/sanity/ignore-2.12.txt | 1 - tests/sanity/ignore-2.13.txt | 1 - tests/sanity/ignore-2.14.txt | 1 - tests/sanity/ignore-2.15.txt | 1 - 7 files changed, 29 insertions(+), 10 deletions(-) create mode 100644 changelogs/fragments/5559-udm-user-sanity.yml diff --git a/changelogs/fragments/5559-udm-user-sanity.yml b/changelogs/fragments/5559-udm-user-sanity.yml new file mode 100644 index 0000000000..1501591f81 --- /dev/null +++ b/changelogs/fragments/5559-udm-user-sanity.yml @@ -0,0 +1,2 @@ +minor_changes: + - udm_user - add ``elements`` attribute when missing in ``list`` parameters (https://github.com/ansible-collections/community.general/pull/5559). diff --git a/plugins/modules/udm_user.py b/plugins/modules/udm_user.py index d5b26fbb28..96bbdfbc10 100644 --- a/plugins/modules/udm_user.py +++ b/plugins/modules/udm_user.py @@ -78,6 +78,7 @@ options: description: - A list of e-mail addresses. type: list + elements: str employee_number: description: - Employee number @@ -99,6 +100,7 @@ options: LDAP filter for each group as $GROUP: C((&(objectClass=posixGroup)(cn=$GROUP)))." type: list + elements: str home_share: description: - "Home NFS share. Must be a LDAP DN, e.g. @@ -116,6 +118,7 @@ options: - List of private telephone numbers. aliases: [ homeTelephoneNumber ] type: list + elements: str homedrive: description: - Windows home drive, e.g. C("H:"). @@ -126,6 +129,7 @@ options: - List of alternative e-mail addresses. aliases: [ mailAlternativeAddress ] type: list + elements: str mail_home_server: description: - FQDN of mail server @@ -142,6 +146,7 @@ options: - Mobile phone number aliases: [ mobileTelephoneNumber ] type: list + elements: str organisation: description: - Organisation @@ -165,10 +170,12 @@ options: - List of pager telephone numbers. aliases: [ pagerTelephonenumber ] type: list + elements: str phone: description: - List of telephone numbers. type: list + elements: str default: [] postcode: description: @@ -201,12 +208,14 @@ options: join." aliases: [ sambaPrivileges ] type: list + elements: str default: [] samba_user_workstations: description: - Allow the authentication only on this Microsoft Windows host. aliases: [ sambaUserWorkstations ] type: list + elements: str default: [] sambahome: description: @@ -221,11 +230,13 @@ options: description: - A list of superiors as LDAP DNs. type: list + elements: str serviceprovider: default: [''] description: - Enable user for the following service providers. type: list + elements: str shell: default: '/bin/bash' description: @@ -333,7 +344,8 @@ def main(): display_name=dict(type='str', aliases=['displayName']), email=dict(default=[''], - type='list'), + type='list', + elements='str'), employee_number=dict(type='str', aliases=['employeeNumber']), employee_type=dict(type='str', @@ -341,18 +353,21 @@ def main(): firstname=dict(type='str'), gecos=dict(type='str'), groups=dict(default=[], - type='list'), + type='list', + elements='str'), home_share=dict(type='str', aliases=['homeShare']), home_share_path=dict(type='str', aliases=['homeSharePath']), home_telephone_number=dict(default=[], type='list', + elements='str', aliases=['homeTelephoneNumber']), homedrive=dict(type='str'), lastname=dict(type='str'), mail_alternative_address=dict(default=[], type='list', + elements='str', aliases=['mailAlternativeAddress']), mail_home_server=dict(type='str', aliases=['mailHomeServer']), @@ -360,6 +375,7 @@ def main(): aliases=['mailPrimaryAddress']), mobile_telephone_number=dict(default=[], type='list', + elements='str', aliases=['mobileTelephoneNumber']), organisation=dict(type='str', aliases=['organization']), @@ -371,11 +387,13 @@ def main(): aliases=['override_pw_length']), pager_telephonenumber=dict(default=[], type='list', + elements='str', aliases=['pagerTelephonenumber']), password=dict(type='str', no_log=True), phone=dict(default=[], - type='list'), + type='list', + elements='str'), postcode=dict(type='str'), primary_group=dict(type='str', aliases=['primaryGroup']), @@ -387,16 +405,20 @@ def main(): aliases=['roomNumber']), samba_privileges=dict(default=[], type='list', + elements='str', aliases=['sambaPrivileges']), samba_user_workstations=dict(default=[], type='list', + elements='str', aliases=['sambaUserWorkstations']), sambahome=dict(type='str'), scriptpath=dict(type='str'), secretary=dict(default=[], - type='list'), + type='list', + elements='str'), serviceprovider=dict(default=[''], - type='list'), + type='list', + elements='str'), shell=dict(default='/bin/bash', type='str'), street=dict(type='str'), diff --git a/tests/sanity/ignore-2.11.txt b/tests/sanity/ignore-2.11.txt index 86d7f6a9e2..1b89dae547 100644 --- a/tests/sanity/ignore-2.11.txt +++ b/tests/sanity/ignore-2.11.txt @@ -26,7 +26,6 @@ plugins/modules/rax.py use-argspec-type-path # fix needed plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path plugins/modules/udm_share.py validate-modules:parameter-list-no-elements -plugins/modules/udm_user.py validate-modules:parameter-list-no-elements plugins/modules/xfconf.py validate-modules:return-syntax-error plugins/modules/yarn.py use-argspec-type-path tests/integration/targets/django_manage/files/base_test/simple_project/p1/manage.py compile-2.6 # django generated code diff --git a/tests/sanity/ignore-2.12.txt b/tests/sanity/ignore-2.12.txt index 45772005a3..29e8927103 100644 --- a/tests/sanity/ignore-2.12.txt +++ b/tests/sanity/ignore-2.12.txt @@ -21,6 +21,5 @@ plugins/modules/rax.py use-argspec-type-path # fix needed plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path plugins/modules/udm_share.py validate-modules:parameter-list-no-elements -plugins/modules/udm_user.py validate-modules:parameter-list-no-elements plugins/modules/xfconf.py validate-modules:return-syntax-error plugins/modules/yarn.py use-argspec-type-path diff --git a/tests/sanity/ignore-2.13.txt b/tests/sanity/ignore-2.13.txt index 45772005a3..29e8927103 100644 --- a/tests/sanity/ignore-2.13.txt +++ b/tests/sanity/ignore-2.13.txt @@ -21,6 +21,5 @@ plugins/modules/rax.py use-argspec-type-path # fix needed plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path plugins/modules/udm_share.py validate-modules:parameter-list-no-elements -plugins/modules/udm_user.py validate-modules:parameter-list-no-elements plugins/modules/xfconf.py validate-modules:return-syntax-error plugins/modules/yarn.py use-argspec-type-path diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt index 49c2eb1bb2..9c667f3d7b 100644 --- a/tests/sanity/ignore-2.14.txt +++ b/tests/sanity/ignore-2.14.txt @@ -23,6 +23,5 @@ plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path plugins/modules/udm_share.py validate-modules:parameter-list-no-elements plugins/modules/udm_user.py import-3.11 # Uses deprecated stdlib library 'crypt' -plugins/modules/udm_user.py validate-modules:parameter-list-no-elements plugins/modules/xfconf.py validate-modules:return-syntax-error plugins/modules/yarn.py use-argspec-type-path diff --git a/tests/sanity/ignore-2.15.txt b/tests/sanity/ignore-2.15.txt index 49c2eb1bb2..9c667f3d7b 100644 --- a/tests/sanity/ignore-2.15.txt +++ b/tests/sanity/ignore-2.15.txt @@ -23,6 +23,5 @@ plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path plugins/modules/udm_share.py validate-modules:parameter-list-no-elements plugins/modules/udm_user.py import-3.11 # Uses deprecated stdlib library 'crypt' -plugins/modules/udm_user.py validate-modules:parameter-list-no-elements plugins/modules/xfconf.py validate-modules:return-syntax-error plugins/modules/yarn.py use-argspec-type-path From 11e1423f60e6cdad13de0da1707e57688ebe82e8 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Wed, 23 Nov 2022 19:34:48 +0100 Subject: [PATCH 0056/1810] Temporarily disable copr tests. (#5594) --- tests/integration/targets/copr/aliases | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/integration/targets/copr/aliases b/tests/integration/targets/copr/aliases index ed3c1af00d..c9fc0e0a2f 100644 --- a/tests/integration/targets/copr/aliases +++ b/tests/integration/targets/copr/aliases @@ -7,3 +7,5 @@ needs/root skip/macos skip/osx skip/freebsd + +disabled # FIXME tests are currently failing From 911769d2f3478e67daad411a1b87f1803bbbe143 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Sat, 26 Nov 2022 18:37:58 +0100 Subject: [PATCH 0057/1810] redhat_subscription: improve wording wrt Satellite (#5581) Do not mention an explicit version of Satellite for an environment to use; future versions of Satellite will support that, and older versions are long EOL. Also mention Katello next to Red Hat Satellite. --- plugins/modules/redhat_subscription.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/plugins/modules/redhat_subscription.py b/plugins/modules/redhat_subscription.py index 997d1e5153..aaf39d6d3f 100644 --- a/plugins/modules/redhat_subscription.py +++ b/plugins/modules/redhat_subscription.py @@ -34,15 +34,15 @@ options: type: str username: description: - - access.redhat.com or Sat6 username + - access.redhat.com or Red Hat Satellite or Katello username type: str password: description: - - access.redhat.com or Sat6 password + - access.redhat.com or Red Hat Satellite or Katello password type: str server_hostname: description: - - Specify an alternative Red Hat Subscription Management or Sat6 server + - Specify an alternative Red Hat Subscription Management or Red Hat Satellite or Katello server type: str server_insecure: description: @@ -50,12 +50,12 @@ options: type: str server_prefix: description: - - Specify the prefix when registering to the Red Hat Subscription Management or Sat6 server. + - Specify the prefix when registering to the Red Hat Subscription Management or Red Hat Satellite or Katello server. type: str version_added: 3.3.0 server_port: description: - - Specify the port when registering to the Red Hat Subscription Management or Sat6 server. + - Specify the port when registering to the Red Hat Subscription Management or Red Hat Satellite or Katello server. type: str version_added: 3.3.0 rhsm_baseurl: @@ -98,7 +98,7 @@ options: type: str environment: description: - - Register with a specific environment in the destination org. Used with Red Hat Satellite 6.x or Katello + - Register with a specific environment in the destination org. Used with Red Hat Satellite or Katello type: str pool: description: @@ -229,7 +229,7 @@ EXAMPLES = ''' org_id: 222333444 pool: '^Red Hat Enterprise Server$' -- name: Register as user credentials into given environment (against Red Hat Satellite 6.x), and auto-subscribe. +- name: Register as user credentials into given environment (against Red Hat Satellite or Katello), and auto-subscribe. community.general.redhat_subscription: state: present username: joe_user @@ -397,7 +397,9 @@ class Rhsm(RegistrationBase): rhsm_baseurl, server_insecure, server_hostname, server_proxy_hostname, server_proxy_port, server_proxy_user, server_proxy_password, release): ''' - Register the current system to the provided RHSM or Sat6 server + Register the current system to the provided RHSM or Red Hat Satellite + or Katello server + Raises: * Exception - if error occurs while running command ''' From a3b748a15ed9250d67d812c8929fd1ec3cf7ae3b Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Sun, 27 Nov 2022 06:41:45 +1300 Subject: [PATCH 0058/1810] udm_share: fix sanity checks (#5557) * udm_share: fix sanity checks * add changelog fragment --- changelogs/fragments/5557-udm-share-sanity.yml | 2 ++ plugins/modules/udm_share.py | 10 ++++++++++ tests/sanity/ignore-2.11.txt | 1 - tests/sanity/ignore-2.12.txt | 1 - tests/sanity/ignore-2.13.txt | 1 - tests/sanity/ignore-2.14.txt | 1 - tests/sanity/ignore-2.15.txt | 1 - 7 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/5557-udm-share-sanity.yml diff --git a/changelogs/fragments/5557-udm-share-sanity.yml b/changelogs/fragments/5557-udm-share-sanity.yml new file mode 100644 index 0000000000..12bd3d026e --- /dev/null +++ b/changelogs/fragments/5557-udm-share-sanity.yml @@ -0,0 +1,2 @@ +minor_changes: + - udm_share - added ``elements`` attribute to ``list`` type parameters (https://github.com/ansible-collections/community.general/pull/5557). diff --git a/plugins/modules/udm_share.py b/plugins/modules/udm_share.py index b1d7e13287..8120df1b00 100644 --- a/plugins/modules/udm_share.py +++ b/plugins/modules/udm_share.py @@ -125,6 +125,7 @@ options: description: - Option name in smb.conf and its value. type: list + elements: dict aliases: [ samba_custom_settings ] sambaDirectoryMode: default: '0755' @@ -200,12 +201,14 @@ options: description: - Allowed host/network. type: list + elements: str aliases: [ samba_hosts_allow ] sambaHostsDeny: default: [] description: - Denied host/network. type: list + elements: str aliases: [ samba_hosts_deny ] sambaInheritAcls: default: true @@ -314,11 +317,13 @@ options: description: - Only allow access for this host, IP address or network. type: list + elements: str nfsCustomSettings: default: [] description: - Option name in exports file. type: list + elements: str aliases: [ nfs_custom_settings ] ''' @@ -382,6 +387,7 @@ def main(): aliases=['samba_csc_policy'], default='manual'), sambaCustomSettings=dict(type='list', + elements='dict', aliases=['samba_custom_settings'], default=[]), sambaDirectoryMode=dict(type='str', @@ -418,9 +424,11 @@ def main(): aliases=['samba_hide_unreadable'], default=False), sambaHostsAllow=dict(type='list', + elements='str', aliases=['samba_hosts_allow'], default=[]), sambaHostsDeny=dict(type='list', + elements='str', aliases=['samba_hosts_deny'], default=[]), sambaInheritAcls=dict(type='bool', @@ -474,8 +482,10 @@ def main(): aliases=['samba_writeable'], default=True), nfs_hosts=dict(type='list', + elements='str', default=[]), nfsCustomSettings=dict(type='list', + elements='str', aliases=['nfs_custom_settings'], default=[]), state=dict(default='present', diff --git a/tests/sanity/ignore-2.11.txt b/tests/sanity/ignore-2.11.txt index 1b89dae547..d12199993a 100644 --- a/tests/sanity/ignore-2.11.txt +++ b/tests/sanity/ignore-2.11.txt @@ -25,7 +25,6 @@ plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice plugins/modules/rax.py use-argspec-type-path # fix needed plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path -plugins/modules/udm_share.py validate-modules:parameter-list-no-elements plugins/modules/xfconf.py validate-modules:return-syntax-error plugins/modules/yarn.py use-argspec-type-path tests/integration/targets/django_manage/files/base_test/simple_project/p1/manage.py compile-2.6 # django generated code diff --git a/tests/sanity/ignore-2.12.txt b/tests/sanity/ignore-2.12.txt index 29e8927103..d5dd72b549 100644 --- a/tests/sanity/ignore-2.12.txt +++ b/tests/sanity/ignore-2.12.txt @@ -20,6 +20,5 @@ plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice plugins/modules/rax.py use-argspec-type-path # fix needed plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path -plugins/modules/udm_share.py validate-modules:parameter-list-no-elements plugins/modules/xfconf.py validate-modules:return-syntax-error plugins/modules/yarn.py use-argspec-type-path diff --git a/tests/sanity/ignore-2.13.txt b/tests/sanity/ignore-2.13.txt index 29e8927103..d5dd72b549 100644 --- a/tests/sanity/ignore-2.13.txt +++ b/tests/sanity/ignore-2.13.txt @@ -20,6 +20,5 @@ plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice plugins/modules/rax.py use-argspec-type-path # fix needed plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path -plugins/modules/udm_share.py validate-modules:parameter-list-no-elements plugins/modules/xfconf.py validate-modules:return-syntax-error plugins/modules/yarn.py use-argspec-type-path diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt index 9c667f3d7b..b54479472b 100644 --- a/tests/sanity/ignore-2.14.txt +++ b/tests/sanity/ignore-2.14.txt @@ -21,7 +21,6 @@ plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice plugins/modules/rax.py use-argspec-type-path # fix needed plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path -plugins/modules/udm_share.py validate-modules:parameter-list-no-elements plugins/modules/udm_user.py import-3.11 # Uses deprecated stdlib library 'crypt' plugins/modules/xfconf.py validate-modules:return-syntax-error plugins/modules/yarn.py use-argspec-type-path diff --git a/tests/sanity/ignore-2.15.txt b/tests/sanity/ignore-2.15.txt index 9c667f3d7b..b54479472b 100644 --- a/tests/sanity/ignore-2.15.txt +++ b/tests/sanity/ignore-2.15.txt @@ -21,7 +21,6 @@ plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice plugins/modules/rax.py use-argspec-type-path # fix needed plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path -plugins/modules/udm_share.py validate-modules:parameter-list-no-elements plugins/modules/udm_user.py import-3.11 # Uses deprecated stdlib library 'crypt' plugins/modules/xfconf.py validate-modules:return-syntax-error plugins/modules/yarn.py use-argspec-type-path From b1094d840ffc2b20a77904fd1bd5e2537047ce5a Mon Sep 17 00:00:00 2001 From: Rainer Leber <39616583+rainerleber@users.noreply.github.com> Date: Sun, 27 Nov 2022 13:59:29 +0100 Subject: [PATCH 0059/1810] Redirect and Remove sap modules (#5592) * redirect and remove sap modules * remove botmeta redirect * add changelog fragment * revert runtime.yml changes and add new entries * Update meta/runtime.yml Co-authored-by: Felix Fontein * Update changelogs/fragments/5592-redirect-remove-sap-modules.yml Co-authored-by: Felix Fontein * Update changelogs/fragments/5592-redirect-remove-sap-modules.yml Co-authored-by: Felix Fontein * Update 5592-redirect-remove-sap-modules.yml Fix indentation * Fix RST syntax. * Update meta/runtime.yml Co-authored-by: Felix Fontein * Update meta/runtime.yml Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein --- .github/BOTMETA.yml | 6 - .../5592-redirect-remove-sap-modules.yml | 13 + meta/runtime.yml | 6 + plugins/modules/hana_query.py | 214 ----------- plugins/modules/sap_task_list_execute.py | 343 ------------------ plugins/modules/sapcar_extract.py | 221 ----------- tests/unit/plugins/modules/test_hana_query.py | 103 ------ .../modules/test_sap_task_list_execute.py | 91 ----- .../plugins/modules/test_sapcar_extract.py | 54 --- 9 files changed, 19 insertions(+), 1032 deletions(-) create mode 100644 changelogs/fragments/5592-redirect-remove-sap-modules.yml delete mode 100644 plugins/modules/hana_query.py delete mode 100644 plugins/modules/sap_task_list_execute.py delete mode 100644 plugins/modules/sapcar_extract.py delete mode 100644 tests/unit/plugins/modules/test_hana_query.py delete mode 100644 tests/unit/plugins/modules/test_sap_task_list_execute.py delete mode 100644 tests/unit/plugins/modules/test_sapcar_extract.py diff --git a/.github/BOTMETA.yml b/.github/BOTMETA.yml index 6aacdc9cad..c8e19d0b13 100644 --- a/.github/BOTMETA.yml +++ b/.github/BOTMETA.yml @@ -527,8 +527,6 @@ files: maintainers: zimbatm $modules/gunicorn.py: maintainers: agmezr - $modules/hana_query.py: - maintainers: rainerleber $modules/haproxy.py: maintainers: ravibhure Normo $modules/heroku_collaborator.py: @@ -1073,10 +1071,6 @@ files: maintainers: nerzhul $modules/runit.py: maintainers: jsumners - $modules/sap_task_list_execute: - maintainers: rainerleber - $modules/sapcar_extract.py: - maintainers: RainerLeber $modules/say.py: maintainers: $team_ansible_core ignore: mpdehaan diff --git a/changelogs/fragments/5592-redirect-remove-sap-modules.yml b/changelogs/fragments/5592-redirect-remove-sap-modules.yml new file mode 100644 index 0000000000..0d6cc2bf39 --- /dev/null +++ b/changelogs/fragments/5592-redirect-remove-sap-modules.yml @@ -0,0 +1,13 @@ +removed_features: + - | + All ``sap`` modules have been removed from this collection. + They have been migrated to the `community.sap_libs `_ collection. + Redirections have been provided. + Following modules are affected: + - sapcar_extract + - sap_task_list_execute + - hana_query +breaking_changes: + - | + If you are not using this collection as part of Ansible, but installed (and/or upgraded) community.general manually, you need to make sure to also install ``community.sap_libs`` if you are using any of the ``sapcar_extract``, ``sap_task_list_execute``, and ``hana_query`` modules. + Without that collection installed, the redirects for these modules do not work. diff --git a/meta/runtime.yml b/meta/runtime.yml index 98a46f62dc..9d15860ac4 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -972,6 +972,8 @@ plugin_routing: warning_text: You are using an internal name to access the community.general.heroku_collaborator modules. This has never been supported or documented, and will stop working in community.general 9.0.0. + hana_query: + redirect: community.sap_libs.sap_hdbsql hetzner_failover_ip: redirect: community.hrobot.failover_ip hetzner_failover_ip_info: @@ -3389,6 +3391,10 @@ plugin_routing: warning_text: You are using an internal name to access the community.general.redfish_info modules. This has never been supported or documented, and will stop working in community.general 9.0.0. + sapcar_extract: + redirect: community.sap_libs.sapcar_extract + sap_task_list_execute: + redirect: community.sap_libs.sap_task_list_execute packaging.os.redhat_subscription: redirect: community.general.redhat_subscription deprecation: diff --git a/plugins/modules/hana_query.py b/plugins/modules/hana_query.py deleted file mode 100644 index 746b2a3f44..0000000000 --- a/plugins/modules/hana_query.py +++ /dev/null @@ -1,214 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# Copyright (c) 2021, Rainer Leber -# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) -# SPDX-License-Identifier: GPL-3.0-or-later -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -DOCUMENTATION = r''' ---- -module: hana_query -short_description: Execute SQL on HANA -version_added: 3.2.0 -description: This module executes SQL statements on HANA with hdbsql. -options: - sid: - description: The system ID. - type: str - required: true - instance: - description: The instance number. - type: str - required: true - user: - description: A dedicated username. The user could be also in hdbuserstore. Defaults to C(SYSTEM). - type: str - default: SYSTEM - userstore: - description: If C(true) the user must be in hdbuserstore. - type: bool - default: false - version_added: 3.5.0 - password: - description: - - The password to connect to the database. - - "B(Note:) Since the passwords have to be passed as command line arguments, I(userstore=true) should - be used whenever possible, as command line arguments can be seen by other users - on the same machine." - type: str - autocommit: - description: Autocommit the statement. - type: bool - default: true - host: - description: The Host IP address. The port can be defined as well. - type: str - database: - description: Define the database on which to connect. - type: str - encrypted: - description: Use encrypted connection. Defaults to C(false). - type: bool - default: false - filepath: - description: - - One or more files each containing one SQL query to run. - - Must be a string or list containing strings. - type: list - elements: path - query: - description: - - SQL query to run. - - Must be a string or list containing strings. Please note that if you supply a string, it will be split by commas (C(,)) to a list. - It is better to supply a one-element list instead to avoid mangled input. - type: list - elements: str -notes: - - Does not support C(check_mode). -author: - - Rainer Leber (@rainerleber) -''' - -EXAMPLES = r''' -- name: Simple select query - community.general.hana_query: - sid: "hdb" - instance: "01" - password: "Test123" - query: "select user_name from users" - -- name: Run several queries - community.general.hana_query: - sid: "hdb" - instance: "01" - password: "Test123" - query: - - "select user_name from users;" - - select * from SYSTEM; - host: "localhost" - autocommit: false - -- name: Run several queries from file - community.general.hana_query: - sid: "hdb" - instance: "01" - password: "Test123" - filepath: - - /tmp/HANA_CPU_UtilizationPerCore_2.00.020+.txt - - /tmp/HANA.txt - host: "localhost" - -- name: Run several queries from user store - community.general.hana_query: - sid: "hdb" - instance: "01" - user: hdbstoreuser - userstore: true - query: - - "select user_name from users;" - - select * from users; - autocommit: false -''' - -RETURN = r''' -query_result: - description: List containing results of all queries executed (one sublist for every query). - returned: on success - type: list - elements: list - sample: [[{"Column": "Value1"}, {"Column": "Value2"}], [{"Column": "Value1"}, {"Column": "Value2"}]] -''' - -import csv -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.six import StringIO -from ansible.module_utils.common.text.converters import to_native - - -def csv_to_list(rawcsv): - reader_raw = csv.DictReader(StringIO(rawcsv)) - reader = [dict((k, v.strip()) for k, v in row.items()) for row in reader_raw] - return list(reader) - - -def main(): - module = AnsibleModule( - argument_spec=dict( - sid=dict(type='str', required=True), - instance=dict(type='str', required=True), - encrypted=dict(type='bool', default=False), - host=dict(type='str', required=False), - user=dict(type='str', default="SYSTEM"), - userstore=dict(type='bool', default=False), - password=dict(type='str', no_log=True), - database=dict(type='str', required=False), - query=dict(type='list', elements='str', required=False), - filepath=dict(type='list', elements='path', required=False), - autocommit=dict(type='bool', default=True), - ), - required_one_of=[('query', 'filepath')], - required_if=[('userstore', False, ['password'])], - supports_check_mode=False, - ) - rc, out, err, out_raw = [0, [], "", ""] - - params = module.params - - sid = (params['sid']).upper() - instance = params['instance'] - user = params['user'] - userstore = params['userstore'] - password = params['password'] - autocommit = params['autocommit'] - host = params['host'] - database = params['database'] - encrypted = params['encrypted'] - - filepath = params['filepath'] - query = params['query'] - - bin_path = "/usr/sap/{sid}/HDB{instance}/exe/hdbsql".format(sid=sid, instance=instance) - - try: - command = [module.get_bin_path(bin_path, required=True)] - except Exception as e: - module.fail_json(msg='Failed to find hdbsql at the expected path "{0}". Please check SID and instance number: "{1}"'.format(bin_path, to_native(e))) - - if encrypted is True: - command.extend(['-attemptencrypt']) - if autocommit is False: - command.extend(['-z']) - if host is not None: - command.extend(['-n', host]) - if database is not None: - command.extend(['-d', database]) - # -x Suppresses additional output, such as the number of selected rows in a result set. - if userstore: - command.extend(['-x', '-U', user]) - else: - command.extend(['-x', '-i', instance, '-u', user, '-p', password]) - - if filepath is not None: - command.extend(['-I']) - for p in filepath: - # makes a command like hdbsql -i 01 -u SYSTEM -p secret123# -I /tmp/HANA_CPU_UtilizationPerCore_2.00.020+.txt, - # iterates through files and append the output to var out. - query_command = command + [p] - (rc, out_raw, err) = module.run_command(query_command) - out.append(csv_to_list(out_raw)) - if query is not None: - for q in query: - # makes a command like hdbsql -i 01 -u SYSTEM -p secret123# "select user_name from users", - # iterates through multiple commands and append the output to var out. - query_command = command + [q] - (rc, out_raw, err) = module.run_command(query_command) - out.append(csv_to_list(out_raw)) - changed = True - - module.exit_json(changed=changed, rc=rc, query_result=out, stderr=err) - - -if __name__ == '__main__': - main() diff --git a/plugins/modules/sap_task_list_execute.py b/plugins/modules/sap_task_list_execute.py deleted file mode 100644 index 29936b8483..0000000000 --- a/plugins/modules/sap_task_list_execute.py +++ /dev/null @@ -1,343 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# Copyright (c) 2021, Rainer Leber -# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) -# SPDX-License-Identifier: GPL-3.0-or-later -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -DOCUMENTATION = r''' ---- -module: sap_task_list_execute -short_description: Perform SAP Task list execution -version_added: "3.5.0" -description: - - The C(sap_task_list_execute) module depends on C(pyrfc) Python library (version 2.4.0 and upwards). - Depending on distribution you are using, you may need to install additional packages to - have these available. - - Tasks in the task list which requires manual activities will be confirmed automatically. - - This module will use the RFC package C(STC_TM_API). - -requirements: - - pyrfc >= 2.4.0 - - xmltodict - -options: - conn_username: - description: The required username for the SAP system. - required: true - type: str - conn_password: - description: The required password for the SAP system. - required: true - type: str - host: - description: The required host for the SAP system. Can be either an FQDN or IP Address. - required: true - type: str - sysnr: - description: - - The system number of the SAP system. - - You must quote the value to ensure retaining the leading zeros. - default: '00' - type: str - client: - description: - - The client number to connect to. - - You must quote the value to ensure retaining the leading zeros. - default: '000' - type: str - task_to_execute: - description: The task list which will be executed. - required: true - type: str - task_parameters: - description: - - The tasks and the parameters for execution. - - If the task list do not need any parameters. This could be empty. - - If only specific tasks from the task list should be executed. - The tasks even when no parameter is needed must be provided. - Alongside with the module parameter I(task_skip=true). - type: list - elements: dict - suboptions: - TASKNAME: - description: The name of the task in the task list. - type: str - required: true - FIELDNAME: - description: The name of the field of the task. - type: str - VALUE: - description: The value which have to be set. - type: raw - task_settings: - description: - - Setting for the execution of the task list. This can be the following as in TCODE SE80 described. - Check Mode C(CHECKRUN), Background Processing Active C(BATCH) (this is the default value), - Asynchronous Execution C(ASYNC), Trace Mode C(TRACE), Server Name C(BATCH_TARGET). - default: ['BATCH'] - type: list - elements: str - task_skip: - description: - - If this parameter is C(true) not defined tasks in I(task_parameters) are skipped. - - This could be the case when only certain tasks should run from the task list. - default: false - type: bool - -notes: - - Does not support C(check_mode). -author: - - Rainer Leber (@rainerleber) -''' - -EXAMPLES = r''' -# Pass in a message -- name: Test task execution - community.general.sap_task_list_execute: - conn_username: DDIC - conn_password: Passwd1234 - host: 10.1.8.10 - sysnr: '01' - client: '000' - task_to_execute: SAP_BASIS_SSL_CHECK - task_settings: batch - -- name: Pass in input parameters - community.general.sap_task_list_execute: - conn_username: DDIC - conn_password: Passwd1234 - host: 10.1.8.10 - sysnr: '00' - client: '000' - task_to_execute: SAP_BASIS_SSL_CHECK - task_parameters : - - { 'TASKNAME': 'CL_STCT_CHECK_SEC_CRYPTO', 'FIELDNAME': 'P_OPT2', 'VALUE': 'X' } - - TASKNAME: CL_STCT_CHECK_SEC_CRYPTO - FIELDNAME: P_OPT3 - VALUE: X - task_settings: batch - -# Exported environement variables. -- name: Hint if module will fail with error message like ImportError libsapnwrfc.so... - community.general.sap_task_list_execute: - conn_username: DDIC - conn_password: Passwd1234 - host: 10.1.8.10 - sysnr: '00' - client: '000' - task_to_execute: SAP_BASIS_SSL_CHECK - task_settings: batch - environment: - SAPNWRFC_HOME: /usr/local/sap/nwrfcsdk - LD_LIBRARY_PATH: /usr/local/sap/nwrfcsdk/lib -''' - -RETURN = r''' -msg: - description: A small execution description. - type: str - returned: always - sample: 'Successful' -out: - description: A complete description of the executed tasks. If this is available. - type: list - elements: dict - returned: on success - sample: [...,{ - "LOG": { - "STCTM_S_LOG": [ - { - "ACTIVITY": "U_CONFIG", - "ACTIVITY_DESCR": "Configuration changed", - "DETAILS": null, - "EXEC_ID": "20210728184903.815739", - "FIELD": null, - "ID": "STC_TASK", - "LOG_MSG_NO": "000000", - "LOG_NO": null, - "MESSAGE": "For radiobutton group ICM too many options are set; choose only one option", - "MESSAGE_V1": "ICM", - "MESSAGE_V2": null, - "MESSAGE_V3": null, - "MESSAGE_V4": null, - "NUMBER": "048", - "PARAMETER": null, - "PERIOD": "M", - "PERIOD_DESCR": "Maintenance", - "ROW": "0", - "SRC_LINE": "170", - "SRC_OBJECT": "CL_STCTM_REPORT_UI IF_STCTM_UI_TASK~SET_PARAMETERS", - "SYSTEM": null, - "TIMESTMP": "20210728184903", - "TSTPNM": "DDIC", - "TYPE": "E" - },... - ]}}] -''' - -from ansible.module_utils.basic import AnsibleModule, missing_required_lib -import traceback -try: - from pyrfc import Connection -except ImportError: - HAS_PYRFC_LIBRARY = False - PYRFC_LIBRARY_IMPORT_ERROR = traceback.format_exc() -else: - HAS_PYRFC_LIBRARY = True - PYRFC_LIBRARY_IMPORT_ERROR = None -try: - import xmltodict -except ImportError: - HAS_XMLTODICT_LIBRARY = False - XMLTODICT_LIBRARY_IMPORT_ERROR = traceback.format_exc() -else: - HAS_XMLTODICT_LIBRARY = True - XMLTODICT_LIBRARY_IMPORT_ERROR = None - - -def call_rfc_method(connection, method_name, kwargs): - # PyRFC call function - return connection.call(method_name, **kwargs) - - -def process_exec_settings(task_settings): - # processes task settings to objects - exec_settings = {} - for settings in task_settings: - temp_dict = {settings.upper(): 'X'} - for key, value in temp_dict.items(): - exec_settings[key] = value - return exec_settings - - -def xml_to_dict(xml_raw): - try: - xml_parsed = xmltodict.parse(xml_raw, dict_constructor=dict) - xml_dict = xml_parsed['asx:abap']['asx:values']['SESSION']['TASKLIST'] - except KeyError: - xml_dict = "No logs available." - return xml_dict - - -def run_module(): - - params_spec = dict( - TASKNAME=dict(type='str', required=True), - FIELDNAME=dict(type='str'), - VALUE=dict(type='raw'), - ) - - # define available arguments/parameters a user can pass to the module - module = AnsibleModule( - argument_spec=dict( - # values for connection - conn_username=dict(type='str', required=True), - conn_password=dict(type='str', required=True, no_log=True), - host=dict(type='str', required=True), - sysnr=dict(type='str', default="00"), - client=dict(type='str', default="000"), - # values for execution tasks - task_to_execute=dict(type='str', required=True), - task_parameters=dict(type='list', elements='dict', options=params_spec), - task_settings=dict(type='list', elements='str', default=['BATCH']), - task_skip=dict(type='bool', default=False), - ), - supports_check_mode=False, - ) - result = dict(changed=False, msg='', out={}) - - params = module.params - - username = params['conn_username'].upper() - password = params['conn_password'] - host = params['host'] - sysnr = params['sysnr'] - client = params['client'] - - task_parameters = params['task_parameters'] - task_to_execute = params['task_to_execute'] - task_settings = params['task_settings'] - task_skip = params['task_skip'] - - if not HAS_PYRFC_LIBRARY: - module.fail_json( - msg=missing_required_lib('pyrfc'), - exception=PYRFC_LIBRARY_IMPORT_ERROR) - - if not HAS_XMLTODICT_LIBRARY: - module.fail_json( - msg=missing_required_lib('xmltodict'), - exception=XMLTODICT_LIBRARY_IMPORT_ERROR) - - # basic RFC connection with pyrfc - try: - conn = Connection(user=username, passwd=password, ashost=host, sysnr=sysnr, client=client) - except Exception as err: - result['error'] = str(err) - result['msg'] = 'Something went wrong connecting to the SAP system.' - module.fail_json(**result) - - try: - raw_params = call_rfc_method(conn, 'STC_TM_SCENARIO_GET_PARAMETERS', - {'I_SCENARIO_ID': task_to_execute}) - except Exception as err: - result['error'] = str(err) - result['msg'] = 'The task list does not exsist.' - module.fail_json(**result) - exec_settings = process_exec_settings(task_settings) - # initialize session task - session_init = call_rfc_method(conn, 'STC_TM_SESSION_BEGIN', - {'I_SCENARIO_ID': task_to_execute, - 'I_INIT_ONLY': 'X'}) - # Confirm Tasks which requires manual activities from Task List Run - for task in raw_params['ET_PARAMETER']: - call_rfc_method(conn, 'STC_TM_TASK_CONFIRM', - {'I_SESSION_ID': session_init['E_SESSION_ID'], - 'I_TASKNAME': task['TASKNAME']}) - if task_skip: - for task in raw_params['ET_PARAMETER']: - call_rfc_method(conn, 'STC_TM_TASK_SKIP', - {'I_SESSION_ID': session_init['E_SESSION_ID'], - 'I_TASKNAME': task['TASKNAME'], 'I_SKIP_DEP_TASKS': 'X'}) - # unskip defined tasks and set parameters - if task_parameters is not None: - for task in task_parameters: - call_rfc_method(conn, 'STC_TM_TASK_UNSKIP', - {'I_SESSION_ID': session_init['E_SESSION_ID'], - 'I_TASKNAME': task['TASKNAME'], 'I_UNSKIP_DEP_TASKS': 'X'}) - - call_rfc_method(conn, 'STC_TM_SESSION_SET_PARAMETERS', - {'I_SESSION_ID': session_init['E_SESSION_ID'], - 'IT_PARAMETER': task_parameters}) - # start the task - try: - session_start = call_rfc_method(conn, 'STC_TM_SESSION_RESUME', - {'I_SESSION_ID': session_init['E_SESSION_ID'], - 'IS_EXEC_SETTINGS': exec_settings}) - except Exception as err: - result['error'] = str(err) - result['msg'] = 'Something went wrong. See error.' - module.fail_json(**result) - # get task logs because the execution may successfully but the tasks shows errors or warnings - # returned value is ABAPXML https://help.sap.com/doc/abapdocu_755_index_htm/7.55/en-US/abenabap_xslt_asxml_general.htm - session_log = call_rfc_method(conn, 'STC_TM_SESSION_GET_LOG', - {'I_SESSION_ID': session_init['E_SESSION_ID']}) - - task_list = xml_to_dict(session_log['E_LOG']) - - result['changed'] = True - result['msg'] = session_start['E_STATUS_DESCR'] - result['out'] = task_list - - module.exit_json(**result) - - -def main(): - run_module() - - -if __name__ == '__main__': - main() diff --git a/plugins/modules/sapcar_extract.py b/plugins/modules/sapcar_extract.py deleted file mode 100644 index 57ede47616..0000000000 --- a/plugins/modules/sapcar_extract.py +++ /dev/null @@ -1,221 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# Copyright (c) 2021, Rainer Leber -# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) -# SPDX-License-Identifier: GPL-3.0-or-later -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -DOCUMENTATION = ''' ---- -module: sapcar_extract -short_description: Manages SAP SAPCAR archives -version_added: "3.2.0" -description: - - Provides support for unpacking C(sar)/C(car) files with the SAPCAR binary from SAP and pulling - information back into Ansible. -options: - path: - description: The path to the SAR/CAR file. - type: path - required: true - dest: - description: - - The destination where SAPCAR extracts the SAR file. Missing folders will be created. - If this parameter is not provided it will unpack in the same folder as the SAR file. - type: path - binary_path: - description: - - The path to the SAPCAR binary, for example, C(/home/dummy/sapcar) or C(https://myserver/SAPCAR). - If this parameter is not provided the module will look in C(PATH). - type: path - signature: - description: - - If C(true) the signature will be extracted. - default: false - type: bool - security_library: - description: - - The path to the security library, for example, C(/usr/sap/hostctrl/exe/libsapcrytp.so), for signature operations. - type: path - manifest: - description: - - The name of the manifest. - default: "SIGNATURE.SMF" - type: str - remove: - description: - - If C(true) the SAR/CAR file will be removed. B(This should be used with caution!) - default: false - type: bool -author: - - Rainer Leber (@RainerLeber) -notes: - - Always returns C(changed=true) in C(check_mode). -''' - -EXAMPLES = """ -- name: Extract SAR file - community.general.sapcar_extract: - path: "~/source/hana.sar" - -- name: Extract SAR file with destination - community.general.sapcar_extract: - path: "~/source/hana.sar" - dest: "~/test/" - -- name: Extract SAR file with destination and download from webserver can be a fileshare as well - community.general.sapcar_extract: - path: "~/source/hana.sar" - dest: "~/dest/" - binary_path: "https://myserver/SAPCAR" - -- name: Extract SAR file and delete SAR after extract - community.general.sapcar_extract: - path: "~/source/hana.sar" - remove: true - -- name: Extract SAR file with manifest - community.general.sapcar_extract: - path: "~/source/hana.sar" - signature: true - -- name: Extract SAR file with manifest and rename it - community.general.sapcar_extract: - path: "~/source/hana.sar" - manifest: "MyNewSignature.SMF" - signature: true -""" - -import os -from tempfile import NamedTemporaryFile -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.urls import open_url -from ansible.module_utils.common.text.converters import to_native - - -def get_list_of_files(dir_name): - # create a list of file and directories - # names in the given directory - list_of_file = os.listdir(dir_name) - allFiles = list() - # Iterate over all the entries - for entry in list_of_file: - # Create full path - fullPath = os.path.join(dir_name, entry) - # If entry is a directory then get the list of files in this directory - if os.path.isdir(fullPath): - allFiles = allFiles + [fullPath] - allFiles = allFiles + get_list_of_files(fullPath) - else: - allFiles.append(fullPath) - return allFiles - - -def download_SAPCAR(binary_path, module): - bin_path = None - # download sapcar binary if url is provided otherwise path is returned - if binary_path is not None: - if binary_path.startswith('https://') or binary_path.startswith('http://'): - random_file = NamedTemporaryFile(delete=False) - with open_url(binary_path) as response: - with random_file as out_file: - data = response.read() - out_file.write(data) - os.chmod(out_file.name, 0o700) - bin_path = out_file.name - module.add_cleanup_file(bin_path) - else: - bin_path = binary_path - return bin_path - - -def check_if_present(command, path, dest, signature, manifest, module): - # manipuliating output from SAR file for compare with already extracted files - iter_command = [command, '-tvf', path] - sar_out = module.run_command(iter_command)[1] - sar_raw = sar_out.split("\n")[1:] - if dest[-1] != "/": - dest = dest + "/" - sar_files = [dest + x.split(" ")[-1] for x in sar_raw if x] - # remove any SIGNATURE.SMF from list because it will not unpacked if signature is false - if not signature: - sar_files = [item for item in sar_files if '.SMF' not in item] - # if signature is renamed manipulate files in list of sar file for compare. - if manifest != "SIGNATURE.SMF": - sar_files = [item for item in sar_files if '.SMF' not in item] - sar_files = sar_files + [manifest] - # get extracted files if present - files_extracted = get_list_of_files(dest) - # compare extracted files with files in sar file - present = all(elem in files_extracted for elem in sar_files) - return present - - -def main(): - module = AnsibleModule( - argument_spec=dict( - path=dict(type='path', required=True), - dest=dict(type='path'), - binary_path=dict(type='path'), - signature=dict(type='bool', default=False), - security_library=dict(type='path'), - manifest=dict(type='str', default="SIGNATURE.SMF"), - remove=dict(type='bool', default=False), - ), - supports_check_mode=True, - ) - rc, out, err = [0, "", ""] - params = module.params - check_mode = module.check_mode - - path = params['path'] - dest = params['dest'] - signature = params['signature'] - security_library = params['security_library'] - manifest = params['manifest'] - remove = params['remove'] - - bin_path = download_SAPCAR(params['binary_path'], module) - - if dest is None: - dest_head_tail = os.path.split(path) - dest = dest_head_tail[0] + '/' - else: - if not os.path.exists(dest): - os.makedirs(dest, 0o755) - - if bin_path is not None: - command = [module.get_bin_path(bin_path, required=True)] - else: - try: - command = [module.get_bin_path('sapcar', required=True)] - except Exception as e: - module.fail_json(msg='Failed to find SAPCAR at the expected path or URL "{0}". Please check whether it is available: {1}' - .format(bin_path, to_native(e))) - - present = check_if_present(command[0], path, dest, signature, manifest, module) - - if not present: - command.extend(['-xvf', path, '-R', dest]) - if security_library: - command.extend(['-L', security_library]) - if signature: - command.extend(['-manifest', manifest]) - if not check_mode: - (rc, out, err) = module.run_command(command, check_rc=True) - changed = True - else: - changed = False - out = "already unpacked" - - if remove: - os.remove(path) - - module.exit_json(changed=changed, message=rc, stdout=out, - stderr=err, command=' '.join(command)) - - -if __name__ == '__main__': - main() diff --git a/tests/unit/plugins/modules/test_hana_query.py b/tests/unit/plugins/modules/test_hana_query.py deleted file mode 100644 index db06e4cef7..0000000000 --- a/tests/unit/plugins/modules/test_hana_query.py +++ /dev/null @@ -1,103 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2021, Rainer Leber (@rainerleber) -# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) -# SPDX-License-Identifier: GPL-3.0-or-later - -from __future__ import absolute_import, division, print_function -__metaclass__ = type - -from ansible_collections.community.general.plugins.modules import hana_query -from ansible_collections.community.general.tests.unit.plugins.modules.utils import ( - AnsibleExitJson, - AnsibleFailJson, - ModuleTestCase, - set_module_args, -) -from ansible_collections.community.general.tests.unit.compat.mock import patch -from ansible.module_utils import basic - - -def get_bin_path(*args, **kwargs): - """Function to return path of hdbsql""" - return "/usr/sap/HDB/HDB01/exe/hdbsql" - - -class Testhana_query(ModuleTestCase): - """Main class for testing hana_query module.""" - - def setUp(self): - """Setup.""" - super(Testhana_query, self).setUp() - self.module = hana_query - self.mock_get_bin_path = patch.object(basic.AnsibleModule, 'get_bin_path', get_bin_path) - self.mock_get_bin_path.start() - self.addCleanup(self.mock_get_bin_path.stop) # ensure that the patching is 'undone' - - def tearDown(self): - """Teardown.""" - super(Testhana_query, self).tearDown() - - def test_without_required_parameters(self): - """Failure must occurs when all parameters are missing.""" - with self.assertRaises(AnsibleFailJson): - set_module_args({}) - self.module.main() - - def test_hana_query(self): - """Check that result is processed.""" - set_module_args({ - 'sid': "HDB", - 'instance': "01", - 'encrypted': False, - 'host': "localhost", - 'user': "SYSTEM", - 'password': "1234Qwer", - 'database': "HDB", - 'query': "SELECT * FROM users;" - }) - with patch.object(basic.AnsibleModule, 'run_command') as run_command: - run_command.return_value = 0, 'username,name\n testuser,test user \n myuser, my user \n', '' - with self.assertRaises(AnsibleExitJson) as result: - hana_query.main() - self.assertEqual(result.exception.args[0]['query_result'], [[ - {'username': 'testuser', 'name': 'test user'}, - {'username': 'myuser', 'name': 'my user'}, - ]]) - self.assertEqual(run_command.call_count, 1) - - def test_hana_userstore_query(self): - """Check that result is processed with userstore.""" - set_module_args({ - 'sid': "HDB", - 'instance': "01", - 'encrypted': False, - 'host': "localhost", - 'user': "SYSTEM", - 'userstore': True, - 'database': "HDB", - 'query': "SELECT * FROM users;" - }) - with patch.object(basic.AnsibleModule, 'run_command') as run_command: - run_command.return_value = 0, 'username,name\n testuser,test user \n myuser, my user \n', '' - with self.assertRaises(AnsibleExitJson) as result: - hana_query.main() - self.assertEqual(result.exception.args[0]['query_result'], [[ - {'username': 'testuser', 'name': 'test user'}, - {'username': 'myuser', 'name': 'my user'}, - ]]) - self.assertEqual(run_command.call_count, 1) - - def test_hana_failed_no_passwd(self): - """Check that result is failed with no password.""" - with self.assertRaises(AnsibleFailJson): - set_module_args({ - 'sid': "HDB", - 'instance': "01", - 'encrypted': False, - 'host': "localhost", - 'user': "SYSTEM", - 'database': "HDB", - 'query': "SELECT * FROM users;" - }) - self.module.main() diff --git a/tests/unit/plugins/modules/test_sap_task_list_execute.py b/tests/unit/plugins/modules/test_sap_task_list_execute.py deleted file mode 100644 index 34c97c4a80..0000000000 --- a/tests/unit/plugins/modules/test_sap_task_list_execute.py +++ /dev/null @@ -1,91 +0,0 @@ -# Copyright (c) Ansible project -# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) -# SPDX-License-Identifier: GPL-3.0-or-later - -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -import sys -from ansible_collections.community.general.tests.unit.compat.mock import patch, MagicMock -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args - -sys.modules['pyrfc'] = MagicMock() -sys.modules['pyrfc.Connection'] = MagicMock() -sys.modules['xmltodict'] = MagicMock() -sys.modules['xmltodict.parse'] = MagicMock() - -from ansible_collections.community.general.plugins.modules import sap_task_list_execute - - -class TestSAPRfcModule(ModuleTestCase): - - def setUp(self): - super(TestSAPRfcModule, self).setUp() - self.module = sap_task_list_execute - - def tearDown(self): - super(TestSAPRfcModule, self).tearDown() - - def define_rfc_connect(self, mocker): - return mocker.patch(self.module.call_rfc_method) - - def test_without_required_parameters(self): - """Failure must occurs when all parameters are missing""" - with self.assertRaises(AnsibleFailJson): - set_module_args({}) - self.module.main() - - def test_error_no_task_list(self): - """tests fail to exec task list""" - - set_module_args({ - "conn_username": "DDIC", - "conn_password": "Test1234", - "host": "10.1.8.9", - "task_to_execute": "SAP_BASIS_SSL_CHECK" - }) - - with patch.object(self.module, 'Connection') as conn: - conn.return_value = '' - with self.assertRaises(AnsibleFailJson) as result: - self.module.main() - self.assertEqual(result.exception.args[0]['msg'], 'The task list does not exsist.') - - def test_success(self): - """test execute task list success""" - - set_module_args({ - "conn_username": "DDIC", - "conn_password": "Test1234", - "host": "10.1.8.9", - "task_to_execute": "SAP_BASIS_SSL_CHECK" - }) - with patch.object(self.module, 'xml_to_dict') as XML: - XML.return_value = {'item': [{'TASK': {'CHECK_STATUS_DESCR': 'Check successfully', - 'STATUS_DESCR': 'Executed successfully', 'TASKNAME': 'CL_STCT_CHECK_SEC_CRYPTO', - 'LNR': '1', 'DESCRIPTION': 'Check SAP Cryptographic Library', 'DOCU_EXIST': 'X', - 'LOG_EXIST': 'X', 'ACTION_SKIP': None, 'ACTION_UNSKIP': None, 'ACTION_CONFIRM': None, - 'ACTION_MAINTAIN': None}}]} - - with self.assertRaises(AnsibleExitJson) as result: - sap_task_list_execute.main() - self.assertEqual(result.exception.args[0]['out'], {'item': [{'TASK': {'CHECK_STATUS_DESCR': 'Check successfully', - 'STATUS_DESCR': 'Executed successfully', 'TASKNAME': 'CL_STCT_CHECK_SEC_CRYPTO', - 'LNR': '1', 'DESCRIPTION': 'Check SAP Cryptographic Library', 'DOCU_EXIST': 'X', - 'LOG_EXIST': 'X', 'ACTION_SKIP': None, 'ACTION_UNSKIP': None, - 'ACTION_CONFIRM': None, 'ACTION_MAINTAIN': None}}]}) - - def test_success_no_log(self): - """test execute task list success without logs""" - - set_module_args({ - "conn_username": "DDIC", - "conn_password": "Test1234", - "host": "10.1.8.9", - "task_to_execute": "SAP_BASIS_SSL_CHECK" - }) - with patch.object(self.module, 'xml_to_dict') as XML: - XML.return_value = "No logs available." - with self.assertRaises(AnsibleExitJson) as result: - sap_task_list_execute.main() - self.assertEqual(result.exception.args[0]['out'], 'No logs available.') diff --git a/tests/unit/plugins/modules/test_sapcar_extract.py b/tests/unit/plugins/modules/test_sapcar_extract.py deleted file mode 100644 index bec9cf8862..0000000000 --- a/tests/unit/plugins/modules/test_sapcar_extract.py +++ /dev/null @@ -1,54 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2021, Rainer Leber (@rainerleber) -# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) -# SPDX-License-Identifier: GPL-3.0-or-later - -from __future__ import absolute_import, division, print_function -__metaclass__ = type - -from ansible_collections.community.general.plugins.modules import sapcar_extract -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args -from ansible_collections.community.general.tests.unit.compat.mock import patch -from ansible.module_utils import basic - - -def get_bin_path(*args, **kwargs): - """Function to return path of SAPCAR""" - return "/tmp/sapcar" - - -class Testsapcar_extract(ModuleTestCase): - """Main class for testing sapcar_extract module.""" - - def setUp(self): - """Setup.""" - super(Testsapcar_extract, self).setUp() - self.module = sapcar_extract - self.mock_get_bin_path = patch.object(basic.AnsibleModule, 'get_bin_path', get_bin_path) - self.mock_get_bin_path.start() - self.addCleanup(self.mock_get_bin_path.stop) # ensure that the patching is 'undone' - - def tearDown(self): - """Teardown.""" - super(Testsapcar_extract, self).tearDown() - - def test_without_required_parameters(self): - """Failure must occurs when all parameters are missing.""" - with self.assertRaises(AnsibleFailJson): - set_module_args({}) - self.module.main() - - def test_sapcar_extract(self): - """Check that result is changed.""" - set_module_args({ - 'path': "/tmp/HANA_CLIENT_REV2_00_053_00_LINUX_X86_64.SAR", - 'dest': "/tmp/test2", - 'binary_path': "/tmp/sapcar" - }) - with patch.object(basic.AnsibleModule, 'run_command') as run_command: - run_command.return_value = 0, '', '' # successful execution, no output - with self.assertRaises(AnsibleExitJson) as result: - sapcar_extract.main() - self.assertTrue(result.exception.args[0]['changed']) - self.assertEqual(run_command.call_count, 1) From 3f80aa3c636f0ccd0f84dfca1954048699737f52 Mon Sep 17 00:00:00 2001 From: "Fabian P. Schmidt" Date: Mon, 28 Nov 2022 20:52:06 +0100 Subject: [PATCH 0060/1810] contributing: Modify link anchor to changelog fragments docs (#5618) The hmtl anchor linked now points to the parent section ("Creating changelog fragments"). Previously new contributors were linked to the subsection "Creating a changelog fragment", just to be immediately be guided by the second paragraph to jump to the previous section. Signed-off-by: Fabian P. Schmidt Signed-off-by: Fabian P. Schmidt --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4236778dc6..358daa5e91 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -31,7 +31,7 @@ Also, consider taking up a valuable, reviewed, but abandoned pull request which * Try committing your changes with an informative but short commit message. * Do not squash your commits and force-push to your branch if not needed. Reviews of your pull request are much easier with individual commits to comprehend the pull request history. All commits of your pull request branch will be squashed into one commit by GitHub upon merge. * Do not add merge commits to your PR. The bot will complain and you will have to rebase ([instructions for rebasing](https://docs.ansible.com/ansible/latest/dev_guide/developing_rebasing.html)) to remove them before your PR can be merged. To avoid that git automatically does merges during pulls, you can configure it to do rebases instead by running `git config pull.rebase true` inside the repository checkout. -* Make sure your PR includes a [changelog fragment](https://docs.ansible.com/ansible/devel/community/development_process.html#changelogs-how-to). (You must not include a fragment for new modules or new plugins, except for test and filter plugins. Also you shouldn't include one for docs-only changes. If you're not sure, simply don't include one, we'll tell you whether one is needed or not :) ) +* Make sure your PR includes a [changelog fragment](https://docs.ansible.com/ansible/devel/community/development_process.html#creating-changelog-fragments). (You must not include a fragment for new modules or new plugins, except for test and filter plugins. Also you shouldn't include one for docs-only changes. If you're not sure, simply don't include one, we'll tell you whether one is needed or not :) ) * Avoid reformatting unrelated parts of the codebase in your PR. These types of changes will likely be requested for reversion, create additional work for reviewers, and may cause approval to be delayed. You can also read [our Quick-start development guide](https://github.com/ansible/community-docs/blob/main/create_pr_quick_start_guide.rst). From 1ca775248f6e8df679ec57e710582f2b7131cc66 Mon Sep 17 00:00:00 2001 From: Naewis Date: Mon, 28 Nov 2022 22:44:24 +0100 Subject: [PATCH 0061/1810] java_certs : Not enough info on error (#5550) * java_certs : Not enough info on error Just bumped into an issue when the message was "Internal module failure, cannot extract public certificate from pkcs12, error: " Seems that the issue #2560 doesn't cover all cases. To make debugging easier, I propose to add error output on json return instead of only expose standard output. * java_certs - add missing fragment message * Word-smithing. Co-authored-by: Felix Fontein --- .../fragments/5550-java_certs-not-enough-info-on-error.yml | 2 ++ plugins/modules/java_cert.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/5550-java_certs-not-enough-info-on-error.yml diff --git a/changelogs/fragments/5550-java_certs-not-enough-info-on-error.yml b/changelogs/fragments/5550-java_certs-not-enough-info-on-error.yml new file mode 100644 index 0000000000..c2b2be0418 --- /dev/null +++ b/changelogs/fragments/5550-java_certs-not-enough-info-on-error.yml @@ -0,0 +1,2 @@ +minor_changes: + - java_certs - add more detailed error output when extracting certificate from PKCS12 fails (https://github.com/ansible-collections/community.general/pull/5550). diff --git a/plugins/modules/java_cert.py b/plugins/modules/java_cert.py index 1d1327ed71..461f365a72 100644 --- a/plugins/modules/java_cert.py +++ b/plugins/modules/java_cert.py @@ -281,7 +281,8 @@ def _export_public_cert_from_pkcs12(module, executable, pkcs_file, alias, passwo (export_rc, export_stdout, export_err) = module.run_command(export_cmd, data=password, check_rc=False) if export_rc != 0: - module.fail_json(msg="Internal module failure, cannot extract public certificate from pkcs12, error: %s" % export_stdout, + module.fail_json(msg="Internal module failure, cannot extract public certificate from PKCS12, message: %s" % export_stdout, + stderr=export_err, rc=export_rc) with open(dest, 'w') as f: From 53da86c1a5efc8c8e397c73776fae8bd993854d7 Mon Sep 17 00:00:00 2001 From: "Fabian P. Schmidt" Date: Mon, 28 Nov 2022 22:51:23 +0100 Subject: [PATCH 0062/1810] unixy Callback: Use Ansible's config manager (#5601) * unixy Callback: Use Ansible's config manager In ansible-core 2.14 deprecated support was removed[1] for accessing options of the DefaultCallback via class attributes. Use the "new" config system instead. [1]: https://github.com/ansible/ansible/commit/dbdbfe845adac977a78c6484da1c5923754d83a2 Fixes #5600. Signed-off-by: Fabian P. Schmidt * Update changelog fragment. Signed-off-by: Fabian P. Schmidt Co-authored-by: Felix Fontein --- .../5601-unixy-callback-use-config-manager.yml | 2 ++ plugins/callback/unixy.py | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 changelogs/fragments/5601-unixy-callback-use-config-manager.yml diff --git a/changelogs/fragments/5601-unixy-callback-use-config-manager.yml b/changelogs/fragments/5601-unixy-callback-use-config-manager.yml new file mode 100644 index 0000000000..f3d0362f8f --- /dev/null +++ b/changelogs/fragments/5601-unixy-callback-use-config-manager.yml @@ -0,0 +1,2 @@ +bugfixes: + - unixy callback plugin - fix plugin to work with ansible-core 2.14 by using Ansible's configuration manager for handling options (https://github.com/ansible-collections/community.general/issues/5600). diff --git a/plugins/callback/unixy.py b/plugins/callback/unixy.py index fa26be8238..55f46afd32 100644 --- a/plugins/callback/unixy.py +++ b/plugins/callback/unixy.py @@ -63,7 +63,7 @@ class CallbackModule(CallbackModule_default): def _preprocess_result(self, result): self.delegated_vars = result._result.get('_ansible_delegated_vars', None) - self._handle_exception(result._result, use_stderr=self.display_failed_stderr) + self._handle_exception(result._result, use_stderr=self.get_option('display_failed_stderr')) self._handle_warnings(result._result) def _process_result_output(self, result, msg): @@ -109,7 +109,7 @@ class CallbackModule(CallbackModule_default): self._display.display(msg) def v2_runner_on_skipped(self, result, ignore_errors=False): - if self.display_skipped_hosts: + if self.get_option('display_skipped_hosts'): self._preprocess_result(result) display_color = C.COLOR_SKIP msg = "skipped" @@ -128,7 +128,7 @@ class CallbackModule(CallbackModule_default): msg += " | item: %s" % (item_value,) task_result = self._process_result_output(result, msg) - self._display.display(" " + task_result, display_color, stderr=self.display_failed_stderr) + self._display.display(" " + task_result, display_color, stderr=self.get_option('display_failed_stderr')) def v2_runner_on_ok(self, result, msg="ok", display_color=C.COLOR_OK): self._preprocess_result(result) @@ -142,7 +142,7 @@ class CallbackModule(CallbackModule_default): display_color = C.COLOR_CHANGED task_result = self._process_result_output(result, msg) self._display.display(" " + task_result, display_color) - elif self.display_ok_hosts: + elif self.get('display_ok_hosts'): task_result = self._process_result_output(result, msg) self._display.display(" " + task_result, display_color) @@ -162,7 +162,7 @@ class CallbackModule(CallbackModule_default): display_color = C.COLOR_UNREACHABLE task_result = self._process_result_output(result, msg) - self._display.display(" " + task_result, display_color, stderr=self.display_failed_stderr) + self._display.display(" " + task_result, display_color, stderr=self.get_option('display_failed_stderr')) def v2_on_file_diff(self, result): if result._task.loop and 'results' in result._result: @@ -205,7 +205,7 @@ class CallbackModule(CallbackModule_default): colorize(u'ignored', t['ignored'], None)), log_only=True ) - if stats.custom and self.show_custom_stats: + if stats.custom and self.get_option('show_custom_stats'): self._display.banner("CUSTOM STATS: ") # per host # TODO: come up with 'pretty format' From 101c957631445dc3902eb71f74b0f52708cc8050 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Tue, 29 Nov 2022 13:07:08 +0100 Subject: [PATCH 0063/1810] redhat_subscription: drop unneeded args to Rhsm.register() (#5583) Stop passing all the "rhsm_", and "server_" module arguments to "Rhsm.register()", and thus as arguments for "subscription-manager register": - right before calling "Rhsm.register()", "Rhsm.configure()" is called to configure subscription-manager with all the "rhsm_", and "server_" arguments; hence, they are already configured - the passed argument to "--serverurl" is partially wrong: "Rhsm.register()" passes only the hostname, whereas the other bits (port and prefix) are supported too; this "works" because port and prefix were already configured previously, and the lax parsing that subscription-manager does allows for missing bits - the parsing done by subscription-manager for "--baseurl" strips out the URL scheme and always uses https: this means that specifying "rhsm_baseurl: http://server" as module parameter will be taken as "https://server" by subscription-manager; since "rhsm_baseurl" is already configured by "Rhsm.configure()", this issue is gone --- ...hat_subscription-subscribe-parameters.yaml | 3 +++ plugins/modules/redhat_subscription.py | 24 ++----------------- .../modules/test_redhat_subscription.py | 5 ---- 3 files changed, 5 insertions(+), 27 deletions(-) create mode 100644 changelogs/fragments/5583-redhat_subscription-subscribe-parameters.yaml diff --git a/changelogs/fragments/5583-redhat_subscription-subscribe-parameters.yaml b/changelogs/fragments/5583-redhat_subscription-subscribe-parameters.yaml new file mode 100644 index 0000000000..bef3676c3b --- /dev/null +++ b/changelogs/fragments/5583-redhat_subscription-subscribe-parameters.yaml @@ -0,0 +1,3 @@ +bugfixes: + - redhat_subscription - do not pass arguments to ``subscription-manager register`` for things already configured; now a specified ``rhsm_baseurl`` is properly set for subscription-manager + (https://github.com/ansible-collections/community.general/pull/5583). diff --git a/plugins/modules/redhat_subscription.py b/plugins/modules/redhat_subscription.py index aaf39d6d3f..bb21578fa5 100644 --- a/plugins/modules/redhat_subscription.py +++ b/plugins/modules/redhat_subscription.py @@ -394,8 +394,7 @@ class Rhsm(RegistrationBase): def register(self, username, password, auto_attach, activationkey, org_id, consumer_type, consumer_name, consumer_id, force_register, environment, - rhsm_baseurl, server_insecure, server_hostname, server_proxy_hostname, - server_proxy_port, server_proxy_user, server_proxy_password, release): + release): ''' Register the current system to the provided RHSM or Red Hat Satellite or Katello server @@ -409,27 +408,9 @@ class Rhsm(RegistrationBase): if force_register: args.extend(['--force']) - if rhsm_baseurl: - args.extend(['--baseurl', rhsm_baseurl]) - - if server_insecure: - args.extend(['--insecure']) - - if server_hostname: - args.extend(['--serverurl', server_hostname]) - if org_id: args.extend(['--org', org_id]) - if server_proxy_hostname and server_proxy_port: - args.extend(['--proxy', server_proxy_hostname + ':' + server_proxy_port]) - - if server_proxy_user: - args.extend(['--proxyuser', server_proxy_user]) - - if server_proxy_password: - args.extend(['--proxypassword', server_proxy_password]) - if activationkey: args.extend(['--activationkey', activationkey]) else: @@ -924,8 +905,7 @@ def main(): rhsm.configure(**module.params) rhsm.register(username, password, auto_attach, activationkey, org_id, consumer_type, consumer_name, consumer_id, force_register, - environment, rhsm_baseurl, server_insecure, server_hostname, - server_proxy_hostname, server_proxy_port, server_proxy_user, server_proxy_password, release) + environment, release) if syspurpose and 'sync' in syspurpose and syspurpose['sync'] is True: rhsm.sync_syspurpose() if pool_ids: diff --git a/tests/unit/plugins/modules/test_redhat_subscription.py b/tests/unit/plugins/modules/test_redhat_subscription.py index bf65671419..f38f1ffe0d 100644 --- a/tests/unit/plugins/modules/test_redhat_subscription.py +++ b/tests/unit/plugins/modules/test_redhat_subscription.py @@ -92,7 +92,6 @@ TEST_CASES = [ ), ( ['/testbin/subscription-manager', 'register', - '--serverurl', 'satellite.company.com', '--username', 'admin', '--password', 'admin'], {'check_rc': True, 'expand_user_and_vars': False}, @@ -180,7 +179,6 @@ TEST_CASES = [ [ '/testbin/subscription-manager', 'register', - '--serverurl', 'satellite.company.com', '--org', 'admin', '--activationkey', 'some-activation-key' ], @@ -340,9 +338,6 @@ TEST_CASES = [ 'register', '--force', '--org', 'admin', - '--proxy', 'proxy.company.com:12345', - '--proxyuser', 'proxy_user', - '--proxypassword', 'secret_proxy_password', '--username', 'admin', '--password', 'admin' ], From f7fa54eed9f82ea2d0287541d9bef31a8e3631d3 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Wed, 30 Nov 2022 22:15:55 +0100 Subject: [PATCH 0064/1810] redhat_subscription: don't discard vars with key (#5627) Fixes #3486. From the man-pages of subscription-manager, none of the parameters used are tied to the activationkey except the two that remain in its else-clause. Note that type is not mentioned in the man-pages on 7.6 (at least), but is still present and available. Co-authored-by: Thor K. H --- ...t_subscription-subscribe-parameters-2.yaml | 3 +++ plugins/modules/redhat_subscription.py | 25 +++++++++++-------- 2 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 changelogs/fragments/5627-redhat_subscription-subscribe-parameters-2.yaml diff --git a/changelogs/fragments/5627-redhat_subscription-subscribe-parameters-2.yaml b/changelogs/fragments/5627-redhat_subscription-subscribe-parameters-2.yaml new file mode 100644 index 0000000000..c76f6871d8 --- /dev/null +++ b/changelogs/fragments/5627-redhat_subscription-subscribe-parameters-2.yaml @@ -0,0 +1,3 @@ +bugfixes: + - redhat_subscription - do not ignore ``consumer_name`` and other variables if ``activationkey`` is specified + (https://github.com/ansible-collections/community.general/issues/3486, https://github.com/ansible-collections/community.general/pull/5627). diff --git a/plugins/modules/redhat_subscription.py b/plugins/modules/redhat_subscription.py index bb21578fa5..041c1a0097 100644 --- a/plugins/modules/redhat_subscription.py +++ b/plugins/modules/redhat_subscription.py @@ -411,23 +411,28 @@ class Rhsm(RegistrationBase): if org_id: args.extend(['--org', org_id]) + if auto_attach: + args.append('--auto-attach') + + if consumer_type: + args.extend(['--type', consumer_type]) + + if consumer_name: + args.extend(['--name', consumer_name]) + + if consumer_id: + args.extend(['--consumerid', consumer_id]) + + if environment: + args.extend(['--environment', environment]) + if activationkey: args.extend(['--activationkey', activationkey]) else: - if auto_attach: - args.append('--auto-attach') if username: args.extend(['--username', username]) if password: args.extend(['--password', password]) - if consumer_type: - args.extend(['--type', consumer_type]) - if consumer_name: - args.extend(['--name', consumer_name]) - if consumer_id: - args.extend(['--consumerid', consumer_id]) - if environment: - args.extend(['--environment', environment]) if release: args.extend(['--release', release]) From b8545d10e6dc0655995fe354b285871ce1f263b2 Mon Sep 17 00:00:00 2001 From: Carlos Neira Date: Wed, 30 Nov 2022 18:41:35 -0300 Subject: [PATCH 0065/1810] Fix for vmadm get_vm_uuid out of range (#5628) * Fix for vmadm get_vm_uuid out of range * Fix for vmadm get_vm_uuid out of range * Update changelogs/fragments/5628-fix-vmadm-off-by-one.yml Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein --- changelogs/fragments/5628-fix-vmadm-off-by-one.yml | 2 ++ plugins/modules/vmadm.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/5628-fix-vmadm-off-by-one.yml diff --git a/changelogs/fragments/5628-fix-vmadm-off-by-one.yml b/changelogs/fragments/5628-fix-vmadm-off-by-one.yml new file mode 100644 index 0000000000..bcb7bf63e6 --- /dev/null +++ b/changelogs/fragments/5628-fix-vmadm-off-by-one.yml @@ -0,0 +1,2 @@ +bugfixes: + - vmadm - fix for index out of range error in ``get_vm_uuid`` (https://github.com/ansible-collections/community.general/pull/5628). diff --git a/plugins/modules/vmadm.py b/plugins/modules/vmadm.py index 6b4490ca57..d6110726f4 100644 --- a/plugins/modules/vmadm.py +++ b/plugins/modules/vmadm.py @@ -438,7 +438,7 @@ def get_vm_prop(module, uuid, prop): def get_vm_uuid(module, alias): # Lookup the uuid that goes with the given alias. # Returns the uuid or '' if not found. - cmd = [module.vmadm, 'lookup', '-j', '-o', 'uuid', 'alias={1}'.format(alias)] + cmd = [module.vmadm, 'lookup', '-j', '-o', 'uuid', 'alias={0}'.format(alias)] (rc, stdout, stderr) = module.run_command(cmd) From 428e181440dc92378c7326d9d2bfadda052ce372 Mon Sep 17 00:00:00 2001 From: Lee Garrett Date: Wed, 30 Nov 2022 22:48:32 +0100 Subject: [PATCH 0066/1810] vdo: Use yaml.safe_load() instead of yaml.load() (#5632) * vdo: Use yaml.safe_load() instead of yaml.load() yaml.load() without specifying a Loader= is deprecated and unsafe. For details, see https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Deprecation * Update changelogs/fragments/5632-vdo-Use-yaml-safe-load-instead-of-yaml-load.yml Co-authored-by: Felix Fontein Co-authored-by: Lee Garrett Co-authored-by: Felix Fontein --- .../5632-vdo-Use-yaml-safe-load-instead-of-yaml-load.yml | 2 ++ plugins/modules/vdo.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/5632-vdo-Use-yaml-safe-load-instead-of-yaml-load.yml diff --git a/changelogs/fragments/5632-vdo-Use-yaml-safe-load-instead-of-yaml-load.yml b/changelogs/fragments/5632-vdo-Use-yaml-safe-load-instead-of-yaml-load.yml new file mode 100644 index 0000000000..c2b0756eca --- /dev/null +++ b/changelogs/fragments/5632-vdo-Use-yaml-safe-load-instead-of-yaml-load.yml @@ -0,0 +1,2 @@ +bugfixes: + - vdo - now uses ``yaml.safe_load()`` to parse command output instead of the deprecated ``yaml.load()`` which is potentially unsafe. Using ``yaml.load()`` without explicitely setting a ``Loader=`` is also an error in pyYAML 6.0 (https://github.com/ansible-collections/community.general/pull/5632). diff --git a/plugins/modules/vdo.py b/plugins/modules/vdo.py index 21e8a96100..d2d4afe944 100644 --- a/plugins/modules/vdo.py +++ b/plugins/modules/vdo.py @@ -332,7 +332,7 @@ def inventory_vdos(module, vdocmd): if rc != 0: module.fail_json(msg="Inventorying VDOs failed: %s" % vdostatusout, rc=rc, err=err) - vdostatusyaml = yaml.load(vdostatusout) + vdostatusyaml = yaml.safe_load(vdostatusout) if vdostatusyaml is None: return vdolist @@ -548,7 +548,7 @@ def run_module(): # Modify the current parameters of a VDO that exists. if desiredvdo in vdolist and state == 'present': rc, vdostatusoutput, err = module.run_command([vdocmd, "status"]) - vdostatusyaml = yaml.load(vdostatusoutput) + vdostatusyaml = yaml.safe_load(vdostatusoutput) # An empty dictionary to contain dictionaries of VDO statistics processedvdos = {} From 03039a56c0a409b574f79f456df72950d95362c6 Mon Sep 17 00:00:00 2001 From: William McBroom Date: Thu, 1 Dec 2022 15:17:09 -0600 Subject: [PATCH 0067/1810] Remove automatically adding # symbol to channel names (#5629) * Add regex to match all channel ids * Add changelog fragment * Allow matching of channel ids with 9-11 characters * Fix file name * Update changelogs/fragments/5629-add-channel-prefix-regex.yml Co-authored-by: Felix Fontein * Remove channel auto prepend # * Update changelog fragment * Add prepend_hash option * Add version_added to prepend_hash doc string Co-authored-by: Felix Fontein * Add description of possible values for the prepend_hash option Co-authored-by: Felix Fontein * Remove old channel assign statement * Update changelogs/fragments/5629-add-prepend-hash-option-for-channel-id.yml Co-authored-by: Felix Fontein * Update changelog fragment tag Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein --- ...add-prepend-hash-option-for-channel-id.yml | 2 ++ plugins/modules/slack.py | 32 ++++++++++++++++--- 2 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/5629-add-prepend-hash-option-for-channel-id.yml diff --git a/changelogs/fragments/5629-add-prepend-hash-option-for-channel-id.yml b/changelogs/fragments/5629-add-prepend-hash-option-for-channel-id.yml new file mode 100644 index 0000000000..f38a6b4e13 --- /dev/null +++ b/changelogs/fragments/5629-add-prepend-hash-option-for-channel-id.yml @@ -0,0 +1,2 @@ +minor_changes: + - "slack - add option ``prepend_hash`` which allows to control whether a ``#`` is prepended to ``channel_id``. The current behavior (value ``auto``) is to prepend ``#`` unless some specific prefixes are found. That list of prefixes is incomplete, and there does not seem to exist a documented condition on when exactly ``#`` must not be prepended. We recommend to explicitly set ``prepend_hash=always`` or ``prepend_hash=never`` to avoid any ambiguity (https://github.com/ansible-collections/community.general/pull/5629)." \ No newline at end of file diff --git a/plugins/modules/slack.py b/plugins/modules/slack.py index 46602a5d16..2854277f60 100644 --- a/plugins/modules/slack.py +++ b/plugins/modules/slack.py @@ -129,6 +129,21 @@ options: type: list elements: dict version_added: 1.0.0 + prepend_hash: + type: str + description: + - Setting for automatically prepending a C(#) symbol on the passed in I(channel_id). + - The C(auto) method prepends a C(#) unless I(channel_id) starts with one of C(#), C(@), C(C0), C(GF), C(G0), C(CP). + These prefixes only cover a small set of the prefixes that should not have a C(#) prepended. + Since an exact condition which I(channel_id) values must not have the C(#) prefix is not known, + the value C(auto) for this option will be deprecated in the future. It is best to explicitly set + I(prepend_hash=always) or I(prepend_hash=never) to obtain the needed behavior. + choices: + - 'always' + - 'never' + - 'auto' + default: 'auto' + version_added: 6.1.0 """ EXAMPLES = """ @@ -289,7 +304,7 @@ def recursive_escape_quotes(obj, keys): def build_payload_for_slack(text, channel, thread_id, username, icon_url, icon_emoji, link_names, - parse, color, attachments, blocks, message_id): + parse, color, attachments, blocks, message_id, prepend_hash): payload = {} if color == "normal" and text is not None: payload = dict(text=escape_quotes(text)) @@ -297,10 +312,15 @@ def build_payload_for_slack(text, channel, thread_id, username, icon_url, icon_e # With a custom color we have to set the message as attachment, and explicitly turn markdown parsing on for it. payload = dict(attachments=[dict(text=escape_quotes(text), color=color, mrkdwn_in=["text"])]) if channel is not None: - if channel.startswith(('#', '@', 'C0', 'GF', 'G0', 'CP')): - payload['channel'] = channel - else: + if prepend_hash == 'auto': + if channel.startswith(('#', '@', 'C0', 'GF', 'G0', 'CP')): + payload['channel'] = channel + else: + payload['channel'] = '#' + channel + elif prepend_hash == 'always': payload['channel'] = '#' + channel + elif prepend_hash == 'never': + payload['channel'] = channel if thread_id is not None: payload['thread_ts'] = thread_id if username is not None: @@ -428,6 +448,7 @@ def main(): attachments=dict(type='list', elements='dict'), blocks=dict(type='list', elements='dict'), message_id=dict(type='str'), + prepend_hash=dict(type='str', default='auto', choices=['always', 'never', 'auto']), ), supports_check_mode=True, ) @@ -446,6 +467,7 @@ def main(): attachments = module.params['attachments'] blocks = module.params['blocks'] message_id = module.params['message_id'] + prepend_hash = module.params['prepend_hash'] color_choices = ['normal', 'good', 'warning', 'danger'] if color not in color_choices and not is_valid_hex_color(color): @@ -470,7 +492,7 @@ def main(): module.exit_json(changed=changed) payload = build_payload_for_slack(text, channel, thread_id, username, icon_url, icon_emoji, link_names, - parse, color, attachments, blocks, message_id) + parse, color, attachments, blocks, message_id, prepend_hash) slack_response = do_notify_slack(module, domain, token, payload) if 'ok' in slack_response: From da7cba4c12dcdf04a41949f05ccf9d9d952da57d Mon Sep 17 00:00:00 2001 From: Dorian Monnier Date: Thu, 1 Dec 2022 22:20:11 +0100 Subject: [PATCH 0068/1810] Fix example in keycloak_realm documentation (#5639) --- plugins/modules/keycloak_realm.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/modules/keycloak_realm.py b/plugins/modules/keycloak_realm.py index f457d20cd3..73a17cf10b 100644 --- a/plugins/modules/keycloak_realm.py +++ b/plugins/modules/keycloak_realm.py @@ -519,6 +519,7 @@ EXAMPLES = ''' auth_username: USERNAME auth_password: PASSWORD id: realm + realm: realm state: present - name: Delete a Keycloak realm From fd436bdbc2917365580851a9a0cf940875633ea1 Mon Sep 17 00:00:00 2001 From: Torgny Bjers Date: Fri, 2 Dec 2022 00:43:22 -0500 Subject: [PATCH 0069/1810] fix typo disable_looups in inventory/proxmox (#5640) * fix typo disable_looups in inventory/proxmox - resolve issue with lookups in proxmox inventory config * add changelog fragment * Update changelogs/fragments/5640-fix-typo-proxmox-inventory.yml Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein --- changelogs/fragments/5640-fix-typo-proxmox-inventory.yml | 2 ++ plugins/inventory/proxmox.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/5640-fix-typo-proxmox-inventory.yml diff --git a/changelogs/fragments/5640-fix-typo-proxmox-inventory.yml b/changelogs/fragments/5640-fix-typo-proxmox-inventory.yml new file mode 100644 index 0000000000..d5b8de5aea --- /dev/null +++ b/changelogs/fragments/5640-fix-typo-proxmox-inventory.yml @@ -0,0 +1,2 @@ +bugfixes: + - "proxmox inventory plugin - fix bug while templating when using templates for the ``url``, ``user``, ``password``, ``token_id``, or ``token_secret`` options (https://github.com/ansible-collections/community.general/pull/5640)." diff --git a/plugins/inventory/proxmox.py b/plugins/inventory/proxmox.py index b24bcacf25..904579a494 100644 --- a/plugins/inventory/proxmox.py +++ b/plugins/inventory/proxmox.py @@ -615,7 +615,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable): for o in ('url', 'user', 'password', 'token_id', 'token_secret'): v = self.get_option(o) if self.templar.is_template(v): - v = self.templar.template(v, disable_looups=False) + v = self.templar.template(v, disable_lookups=False) setattr(self, 'proxmox_%s' % o, v) # some more cleanup and validation From 23aacc78e1dd4eb6a05fea4a243075fd6ed0e2ef Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Sat, 3 Dec 2022 15:16:55 -0600 Subject: [PATCH 0070/1810] Reenable and enhance `copr` integration tests (#5638) * Enhance `copr` integration tests - Switch to a new test Copr repository. @copr/integration_tests was removed which caused the tests to fail. I created a new one under my account that I'll ensure stays around. - Add basic testing to ensure that repo files are created in the correct location and contain the correct baseurl and enabled status. - Also run tests on Enterprise Linux. - Test that packages from the Copr install. This has to be disabled on EOL Fedoras that Copr does not allow building new packages for. Resolves: https://github.com/ansible-collections/community.general/issues/5595 * copr tests: Fix ansible_python_interpreter on c8s * copr: Don't test on alt Pythons on cs8 * Revert "copr tests: Fix ansible_python_interpreter on c8s" This reverts commit 58e15a7ebf3a8b270a7ada1a3834ab8322ca006c. --- tests/integration/targets/copr/aliases | 2 - tests/integration/targets/copr/tasks/main.yml | 112 ++++++++++++++++-- tests/integration/targets/copr/vars/main.yml | 15 +++ 3 files changed, 117 insertions(+), 12 deletions(-) create mode 100644 tests/integration/targets/copr/vars/main.yml diff --git a/tests/integration/targets/copr/aliases b/tests/integration/targets/copr/aliases index c9fc0e0a2f..ed3c1af00d 100644 --- a/tests/integration/targets/copr/aliases +++ b/tests/integration/targets/copr/aliases @@ -7,5 +7,3 @@ needs/root skip/macos skip/osx skip/freebsd - -disabled # FIXME tests are currently failing diff --git a/tests/integration/targets/copr/tasks/main.yml b/tests/integration/targets/copr/tasks/main.yml index ac78255d48..917e44b7ec 100644 --- a/tests/integration/targets/copr/tasks/main.yml +++ b/tests/integration/targets/copr/tasks/main.yml @@ -3,14 +3,27 @@ # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) # SPDX-License-Identifier: GPL-3.0-or-later -- when: ansible_distribution == 'Fedora' +- when: + # Fedora or RHEL >= 8 + # This module requires the dnf module which is not available on RHEL 7. + - > + ansible_distribution == 'Fedora' + or (ansible_os_family == 'RedHat' and ansible_distribution != 'Fedora' + and ansible_distribution_major_version | int >= 8) + # The copr module imports dnf which is only available for the system Python + # interpreter. + - > + not (ansible_distribution == 'CentOS' and + ansible_distribution_major_version | int == 8 and not + ansible_python_version.startswith('3.6')) block: + - debug: var=copr_chroot - name: enable copr project copr: host: copr.fedorainfracloud.org state: enabled - name: '@copr/integration_tests' - chroot: fedora-rawhide-x86_64 + name: '{{ copr_fullname }}' + chroot: "{{ copr_chroot }}" register: result - name: assert that the copr project was enabled @@ -24,8 +37,8 @@ check_mode: yes copr: state: enabled - name: '@copr/integration_tests' - chroot: fedora-rawhide-x86_64 + name: '{{ copr_fullname }}' + chroot: '{{ copr_chroot }}' register: result - name: assert that the copr project was enabled @@ -34,10 +47,53 @@ - result is not changed - result.msg == 'enabled' + - name: Ensure the repo is installed and enabled | slurp + register: result + ansible.builtin.slurp: + src: "{{ copr_repofile }}" + + - name: Ensure the repo is installed and enabled + vars: + content: "{{ result.content | b64decode }}" + _baseurl: "{{ 'https://download.copr.fedorainfracloud.org/results/gotmax23/community.general.copr_integration_tests' | regex_escape }}" + baseurl: "{{ content | regex_search('baseurl=' ~ _baseurl) }}" + block: + - ansible.builtin.debug: + var: content + - ansible.builtin.debug: + var: baseurl + - name: Ensure the repo is installed and enabled + ansible.builtin.assert: + that: + - "'enabled=1' in content" + - baseurl | length > 0 + + - name: Install test package from Copr + when: + # Copr does not build new packages for EOL Fedoras. + - > + not (ansible_distribution == 'Fedora' and + ansible_distribution_major_version | int < 35) + block: + - name: install test package from the copr + ansible.builtin.package: + update_cache: true + name: copr-module-integration-dummy-package + + - name: uninstall test package + register: result + ansible.builtin.package: + name: copr-module-integration-dummy-package + state: absent + + - name: check uninstall test package + ansible.builtin.assert: + that: result.changed | bool + - name: remove copr project copr: state: absent - name: '@copr/integration_tests' + name: '{{ copr_fullname }}' register: result - name: assert that the copr project was removed @@ -46,11 +102,20 @@ - 'result is changed' - result.msg == 'absent' + - name: Ensure the repo file was removed | stat + register: result + ansible.builtin.stat: + dest: "{{ copr_repofile }}" + + - name: Ensure the repo file was removed + ansible.builtin.assert: + that: not result.stat.exists | bool + - name: disable copr project copr: state: disabled - name: '@copr/integration_tests' - chroot: fedora-rawhide-x86_64 + name: '{{ copr_fullname }}' + chroot: '{{ copr_chroot }}' register: result - name: assert that the copr project was disabled @@ -59,10 +124,37 @@ - 'result is changed' - result.msg == 'disabled' + - name: Ensure the repo is installed but disabled | slurp + register: result + ansible.builtin.slurp: + src: "{{ copr_repofile }}" + + - name: Ensure the repo is installed but disabled + vars: + content: "{{ result.content | b64decode }}" + _baseurl: "{{ 'https://download.copr.fedorainfracloud.org/results/gotmax23/community.general.copr_integration_tests' | regex_escape }}" + baseurl: "{{ content | regex_search('baseurl=' ~ _baseurl) }}" + block: + - ansible.builtin.debug: + var: content + - ansible.builtin.debug: + var: baseurl + - name: Ensure the repo is installed but disabled + ansible.builtin.assert: + that: + - "'enabled=0' in content" + - baseurl | length > 0 + always: - name: clean up + ignore_errors: true copr: host: copr.fedorainfracloud.org state: absent - name: '@copr/integration_tests' - chroot: fedora-rawhide-x86_64 + name: '{{ copr_fullname }}' + chroot: '{{ copr_chroot }}' + + - name: cleanup test package + ansible.builtin.package: + name: copr-module-integration-dummy-package + state: absent diff --git a/tests/integration/targets/copr/vars/main.yml b/tests/integration/targets/copr/vars/main.yml new file mode 100644 index 0000000000..a37a44d478 --- /dev/null +++ b/tests/integration/targets/copr/vars/main.yml @@ -0,0 +1,15 @@ +# Copyright (c) 2022 Maxwell G +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or +# https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later +--- +copr_host: copr.fedorainfracloud.org +copr_namespace: gotmax23 +copr_name: community.general.copr_integration_tests +copr_fullname: '{{ copr_namespace }}/{{ copr_name }}' +copr_repofile: '/etc/yum.repos.d/_copr:{{ copr_host }}:{{ copr_namespace }}:{{ copr_name }}.repo' + +# TODO: Fix chroot autodetection so this isn't necessary +_copr_chroot_fedora: "fedora-rawhide-x86_64" +_copr_chroot_rhelish: "epel-{{ ansible_distribution_major_version }}-x86_64" +copr_chroot: "{{ _copr_chroot_fedora if ansible_distribution == 'Fedora' else _copr_chroot_rhelish }}" From be22ca063354507fbafb6d55032be39636bbf036 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Mon, 5 Dec 2022 00:18:33 +1300 Subject: [PATCH 0071/1810] cmd_runner: allow bool format to pass alternate (false) value (#5647) * allow bool format to pass alternate (false) value * add changelog fragment --- changelogs/fragments/5647-cmd-runner-as-bool-false.yml | 2 ++ plugins/module_utils/cmd_runner.py | 9 +++++++-- tests/unit/plugins/module_utils/test_cmd_runner.py | 4 ++++ 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/5647-cmd-runner-as-bool-false.yml diff --git a/changelogs/fragments/5647-cmd-runner-as-bool-false.yml b/changelogs/fragments/5647-cmd-runner-as-bool-false.yml new file mode 100644 index 0000000000..5dc447d235 --- /dev/null +++ b/changelogs/fragments/5647-cmd-runner-as-bool-false.yml @@ -0,0 +1,2 @@ +minor_changes: + - cmd_runner module utils - ``cmd_runner_fmt.as_bool()`` can now take an extra parameter to format when value is false (https://github.com/ansible-collections/community.general/pull/5647). diff --git a/plugins/module_utils/cmd_runner.py b/plugins/module_utils/cmd_runner.py index 38daac6716..21d61a6a5c 100644 --- a/plugins/module_utils/cmd_runner.py +++ b/plugins/module_utils/cmd_runner.py @@ -103,8 +103,13 @@ class _ArgFormat(object): class _Format(object): @staticmethod - def as_bool(args): - return _ArgFormat(lambda value: _ensure_list(args) if value else []) + def as_bool(args_true, args_false=None, ignore_none=None): + if args_false is not None: + if ignore_none is None: + ignore_none = False + else: + args_false = [] + return _ArgFormat(lambda value: _ensure_list(args_true) if value else _ensure_list(args_false), ignore_none=ignore_none) @staticmethod def as_bool_not(args): diff --git a/tests/unit/plugins/module_utils/test_cmd_runner.py b/tests/unit/plugins/module_utils/test_cmd_runner.py index f1c3e25a9b..7cec215a76 100644 --- a/tests/unit/plugins/module_utils/test_cmd_runner.py +++ b/tests/unit/plugins/module_utils/test_cmd_runner.py @@ -18,6 +18,10 @@ TC_FORMATS = dict( simple_boolean__true=(fmt.as_bool, ("--superflag",), True, ["--superflag"]), simple_boolean__false=(fmt.as_bool, ("--superflag",), False, []), simple_boolean__none=(fmt.as_bool, ("--superflag",), None, []), + simple_boolean_both__true=(fmt.as_bool, ("--superflag", "--falseflag"), True, ["--superflag"]), + simple_boolean_both__false=(fmt.as_bool, ("--superflag", "--falseflag"), False, ["--falseflag"]), + simple_boolean_both__none=(fmt.as_bool, ("--superflag", "--falseflag"), None, ["--falseflag"]), + simple_boolean_both__none_ig=(fmt.as_bool, ("--superflag", "--falseflag", True), None, []), simple_boolean_not__true=(fmt.as_bool_not, ("--superflag",), True, []), simple_boolean_not__false=(fmt.as_bool_not, ("--superflag",), False, ["--superflag"]), simple_boolean_not__none=(fmt.as_bool_not, ("--superflag",), None, ["--superflag"]), From 632fc07e65778cf236a8da35bf4204bddcd052b0 Mon Sep 17 00:00:00 2001 From: domelek <40233039+domelek@users.noreply.github.com> Date: Sun, 4 Dec 2022 12:42:46 +0100 Subject: [PATCH 0072/1810] Updated tags delimiter (#5602) * Updated tags delimiter Starting from Proxmox 7.3 tags are delimited by semicolon. For backward compatibility it needs to be splitted by both commas and semicolons. * Added missing space * Add changelog fragment. Co-authored-by: Felix Fontein --- changelogs/fragments/5602-proxmox-tags.yml | 2 ++ plugins/inventory/proxmox.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/5602-proxmox-tags.yml diff --git a/changelogs/fragments/5602-proxmox-tags.yml b/changelogs/fragments/5602-proxmox-tags.yml new file mode 100644 index 0000000000..32498f0366 --- /dev/null +++ b/changelogs/fragments/5602-proxmox-tags.yml @@ -0,0 +1,2 @@ +bugfixes: + - "proxmox inventory plugin - handle tags delimited by semicolon instead of comma, which happens from Proxmox 7.3 on (https://github.com/ansible-collections/community.general/pull/5602)." diff --git a/plugins/inventory/proxmox.py b/plugins/inventory/proxmox.py index 904579a494..e33f7ed77d 100644 --- a/plugins/inventory/proxmox.py +++ b/plugins/inventory/proxmox.py @@ -408,7 +408,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable): stripped_value = value.strip() if stripped_value: parsed_key = key + "_parsed" - properties[parsed_key] = [tag.strip() for tag in stripped_value.split(",")] + properties[parsed_key] = [tag.strip() for tag in stripped_value.replace(',', ';').split(";")] # The first field in the agent string tells you whether the agent is enabled # the rest of the comma separated string is extra config for the agent. From fb2833d34d5e8b389ed017084d87ea6b079d4d9b Mon Sep 17 00:00:00 2001 From: Arek Kalandyk <36413794+koralowiec@users.noreply.github.com> Date: Sun, 4 Dec 2022 12:57:54 +0100 Subject: [PATCH 0073/1810] feat(ssh_config): host_key_algorithms option (#5605) * feat(ssh_config): host_key_algorithms option * chore: add changelog fragment * chore(ssh_config): add version info to option and update fragment --- .../5605-ssh-config-add-host-key-algorithms.yaml | 2 ++ plugins/modules/ssh_config.py | 7 +++++++ .../targets/ssh_config/tasks/options.yml | 13 +++++++++++++ 3 files changed, 22 insertions(+) create mode 100644 changelogs/fragments/5605-ssh-config-add-host-key-algorithms.yaml diff --git a/changelogs/fragments/5605-ssh-config-add-host-key-algorithms.yaml b/changelogs/fragments/5605-ssh-config-add-host-key-algorithms.yaml new file mode 100644 index 0000000000..1535d9b13d --- /dev/null +++ b/changelogs/fragments/5605-ssh-config-add-host-key-algorithms.yaml @@ -0,0 +1,2 @@ +minor_changes: + - ssh_config - add ``host_key_algorithms`` option (https://github.com/ansible-collections/community.general/pull/5605). diff --git a/plugins/modules/ssh_config.py b/plugins/modules/ssh_config.py index 00a0525d6c..cb028ac8e5 100644 --- a/plugins/modules/ssh_config.py +++ b/plugins/modules/ssh_config.py @@ -88,6 +88,11 @@ options: - If I(user) and this option are not specified, C(/etc/ssh/ssh_config) is used. - Mutually exclusive with I(user). type: path + host_key_algorithms: + description: + - Sets the C(HostKeyAlgorithms) option. + type: str + version_added: 6.1.0 requirements: - StormSSH notes: @@ -207,6 +212,7 @@ class SSHConfig(): strict_host_key_checking=self.params.get('strict_host_key_checking'), user_known_hosts_file=self.params.get('user_known_hosts_file'), proxycommand=self.params.get('proxycommand'), + host_key_algorithms=self.params.get('host_key_algorithms'), ) # Convert True / False to 'yes' / 'no' for usage in ssh_config @@ -297,6 +303,7 @@ def main(): group=dict(default=None, type='str'), host=dict(type='str', required=True), hostname=dict(type='str'), + host_key_algorithms=dict(type='str', no_log=False), identity_file=dict(type='path'), port=dict(type='str'), proxycommand=dict(type='str', default=None), diff --git a/tests/integration/targets/ssh_config/tasks/options.yml b/tests/integration/targets/ssh_config/tasks/options.yml index 04586873ad..65ce691cf8 100644 --- a/tests/integration/targets/ssh_config/tasks/options.yml +++ b/tests/integration/targets/ssh_config/tasks/options.yml @@ -15,6 +15,7 @@ host: "options.example.com" proxycommand: "ssh jumphost.example.com -W %h:%p" forward_agent: true + host_key_algorithms: "+ssh-rsa" state: present register: options_add check_mode: yes @@ -43,6 +44,7 @@ host: "options.example.com" proxycommand: "ssh jumphost.example.com -W %h:%p" forward_agent: true + host_key_algorithms: "+ssh-rsa" state: present register: options_add @@ -60,6 +62,7 @@ host: "options.example.com" proxycommand: "ssh jumphost.example.com -W %h:%p" forward_agent: true + host_key_algorithms: "+ssh-rsa" state: present register: options_add_again @@ -81,6 +84,7 @@ that: - "'proxycommand ssh jumphost.example.com -W %h:%p' in slurp_ssh_config['content'] | b64decode" - "'forwardagent yes' in slurp_ssh_config['content'] | b64decode" + - "'hostkeyalgorithms +ssh-rsa' in slurp_ssh_config['content'] | b64decode" - name: Options - Update host community.general.ssh_config: @@ -88,6 +92,7 @@ host: "options.example.com" proxycommand: "ssh new-jumphost.example.com -W %h:%p" forward_agent: no + host_key_algorithms: "+ssh-ed25519" state: present register: options_update @@ -107,6 +112,7 @@ host: "options.example.com" proxycommand: "ssh new-jumphost.example.com -W %h:%p" forward_agent: no + host_key_algorithms: "+ssh-ed25519" state: present register: options_update @@ -129,6 +135,7 @@ that: - "'proxycommand ssh new-jumphost.example.com -W %h:%p' in slurp_ssh_config['content'] | b64decode" - "'forwardagent no' in slurp_ssh_config['content'] | b64decode" + - "'hostkeyalgorithms +ssh-ed25519' in slurp_ssh_config['content'] | b64decode" - name: Options - Ensure no update in case option exist in ssh_config file but wasn't defined in playbook community.general.ssh_config: @@ -156,6 +163,11 @@ that: - "'proxycommand ssh new-jumphost.example.com -W %h:%p' in slurp_ssh_config['content'] | b64decode" - "'forwardagent no' in slurp_ssh_config['content'] | b64decode" + - "'hostkeyalgorithms +ssh-ed25519' in slurp_ssh_config['content'] | b64decode" + +- name: Debug + debug: + msg: "{{ slurp_ssh_config['content'] | b64decode }}" - name: Options - Delete a host community.general.ssh_config: @@ -197,3 +209,4 @@ that: - "'proxycommand ssh new-jumphost.example.com -W %h:%p' not in slurp_ssh_config['content'] | b64decode" - "'forwardagent no' not in slurp_ssh_config['content'] | b64decode" + - "'hostkeyalgorithms +ssh-ed25519' not in slurp_ssh_config['content'] | b64decode" From 7ea544a6244c7324e45c6972cdf0b6674797e0e9 Mon Sep 17 00:00:00 2001 From: John Cant Date: Mon, 5 Dec 2022 05:22:14 +0000 Subject: [PATCH 0074/1810] New Module: Keycloak ClientSecret with PR changes (#5606) * feat(plugins/keycloak): add get and create util function for client secret * feat(plugins/keycloak): add client secret module * chore: add maintainer in BOTMETA * Update plugins/modules/identity/keycloak/keycloak_clientsecret.py Co-authored-by: Felix Fontein * Make changes to keycloak_clientsecret from PR * Add SPDX identifier for keycloak_clientsecret * Add copyright in keycloak_clientsecret for REUSE * Add integration test for keycloak_clientsecret * rm clientsecret from keycloak_clientsecret result - end_state used instead * keycloak_clientsecret: Undo meta/runtime.yml change * Fix sanity tests for keycloak_clientsecret * New keycloak_clientsecret_info module - Replaces keycloak_clientsecret - Module definition and some common logic moved into module_utils - Update documentation, tests, etc. - Add myself as author * Misc fixes to keycloak_clientsecret_info * Add keycloak_clientsecret_regenerate module * keycloak_clientsecret* Update .github/BOTMETA.yml * keycloak_clientsecret_regenerate: Fix sanity tests * Fix README for keycloak_clientsecret integration test * Separate out keycloak_clientsecret module_utils * Keycloak_clientsecret module_utils: boilerplate * Update plugins/modules/keycloak_clientsecret_info.py Co-authored-by: Felix Fontein * Update plugins/modules/keycloak_clientsecret_info.py Co-authored-by: Felix Fontein * Update plugins/modules/keycloak_clientsecret_info.py Co-authored-by: Felix Fontein * Update plugins/modules/keycloak_clientsecret_info.py Co-authored-by: Felix Fontein * Update plugins/modules/keycloak_clientsecret_info.py Co-authored-by: Felix Fontein * Update plugins/modules/keycloak_clientsecret_info.py Co-authored-by: Felix Fontein * keycloak_clientsecret: Add no_log to examples and docs * keycloak_clientsecret: Update BOTMETA * Update .github/BOTMETA.yml Co-authored-by: Felix Fontein Co-authored-by: fynncfchen Co-authored-by: Fynnnnn Co-authored-by: Felix Fontein --- .github/BOTMETA.yml | 6 + .../identity/keycloak/keycloak.py | 48 +++++ .../keycloak/keycloak_clientsecret.py | 77 ++++++++ plugins/modules/keycloak_clientsecret_info.py | 161 +++++++++++++++++ .../keycloak_clientsecret_regenerate.py | 167 ++++++++++++++++++ .../keycloak_clientsecret_info/README.md | 17 ++ .../docker-compose.yml | 31 ++++ .../keycloak_clientsecret_info/tasks/main.yml | 48 +++++ .../keycloak_clientsecret_info/vars/main.yml | 20 +++ .../README.md | 17 ++ .../docker-compose.yml | 31 ++++ .../tasks/main.yml | 49 +++++ .../vars/main.yml | 20 +++ 13 files changed, 692 insertions(+) create mode 100644 plugins/module_utils/identity/keycloak/keycloak_clientsecret.py create mode 100644 plugins/modules/keycloak_clientsecret_info.py create mode 100644 plugins/modules/keycloak_clientsecret_regenerate.py create mode 100644 tests/integration/targets/keycloak_clientsecret_info/README.md create mode 100644 tests/integration/targets/keycloak_clientsecret_info/docker-compose.yml create mode 100644 tests/integration/targets/keycloak_clientsecret_info/tasks/main.yml create mode 100644 tests/integration/targets/keycloak_clientsecret_info/vars/main.yml create mode 100644 tests/integration/targets/keycloak_clientsecret_regenerate/README.md create mode 100644 tests/integration/targets/keycloak_clientsecret_regenerate/docker-compose.yml create mode 100644 tests/integration/targets/keycloak_clientsecret_regenerate/tasks/main.yml create mode 100644 tests/integration/targets/keycloak_clientsecret_regenerate/vars/main.yml diff --git a/.github/BOTMETA.yml b/.github/BOTMETA.yml index c8e19d0b13..18f4f66e1f 100644 --- a/.github/BOTMETA.yml +++ b/.github/BOTMETA.yml @@ -281,6 +281,8 @@ files: maintainers: $team_huawei $module_utils/identity/keycloak/keycloak.py: maintainers: $team_keycloak + $module_utils/identity/keycloak/keycloak_clientsecret.py: + maintainers: $team_keycloak fynncfchen johncant $module_utils/ipa.py: labels: ipa maintainers: $team_ipa @@ -668,6 +670,10 @@ files: maintainers: Gaetan2907 $modules/keycloak_clientscope.py: maintainers: Gaetan2907 + $modules/keycloak_clientsecret_info.py: + maintainers: fynncfchen johncant + $modules/keycloak_clientsecret_regenerate.py: + maintainers: fynncfchen johncant $modules/keycloak_group.py: maintainers: adamgoossens $modules/keycloak_identity_provider.py: diff --git a/plugins/module_utils/identity/keycloak/keycloak.py b/plugins/module_utils/identity/keycloak/keycloak.py index 078925ef71..87b2120318 100644 --- a/plugins/module_utils/identity/keycloak/keycloak.py +++ b/plugins/module_utils/identity/keycloak/keycloak.py @@ -58,6 +58,8 @@ URL_CLIENT_USER_ROLEMAPPINGS = "{url}/admin/realms/{realm}/users/{id}/role-mappi URL_CLIENT_USER_ROLEMAPPINGS_AVAILABLE = "{url}/admin/realms/{realm}/users/{id}/role-mappings/clients/{client}/available" URL_CLIENT_USER_ROLEMAPPINGS_COMPOSITE = "{url}/admin/realms/{realm}/users/{id}/role-mappings/clients/{client}/composite" +URL_CLIENTSECRET = "{url}/admin/realms/{realm}/clients/{id}/client-secret" + URL_AUTHENTICATION_FLOWS = "{url}/admin/realms/{realm}/authentication/flows" URL_AUTHENTICATION_FLOW = "{url}/admin/realms/{realm}/authentication/flows/{id}" URL_AUTHENTICATION_FLOW_COPY = "{url}/admin/realms/{realm}/authentication/flows/{copyfrom}/copy" @@ -1160,6 +1162,52 @@ class KeycloakAPI(object): self.module.fail_json(msg='Could not update protocolmappers for clientscope %s in realm %s: %s' % (mapper_rep, realm, str(e))) + def create_clientsecret(self, id, realm="master"): + """ Generate a new client secret by id + + :param id: id (not clientId) of client to be queried + :param realm: client from this realm + :return: dict of credential representation + """ + clientsecret_url = URL_CLIENTSECRET.format(url=self.baseurl, realm=realm, id=id) + + try: + return json.loads(to_native(open_url(clientsecret_url, method='POST', headers=self.restheaders, timeout=self.connection_timeout, + validate_certs=self.validate_certs).read())) + + except HTTPError as e: + if e.code == 404: + return None + else: + self.module.fail_json(msg='Could not obtain clientsecret of client %s for realm %s: %s' + % (id, realm, str(e))) + except Exception as e: + self.module.fail_json(msg='Could not obtain clientsecret of client %s for realm %s: %s' + % (id, realm, str(e))) + + def get_clientsecret(self, id, realm="master"): + """ Obtain client secret by id + + :param id: id (not clientId) of client to be queried + :param realm: client from this realm + :return: dict of credential representation + """ + clientsecret_url = URL_CLIENTSECRET.format(url=self.baseurl, realm=realm, id=id) + + try: + return json.loads(to_native(open_url(clientsecret_url, method='GET', headers=self.restheaders, timeout=self.connection_timeout, + validate_certs=self.validate_certs).read())) + + except HTTPError as e: + if e.code == 404: + return None + else: + self.module.fail_json(msg='Could not obtain clientsecret of client %s for realm %s: %s' + % (id, realm, str(e))) + except Exception as e: + self.module.fail_json(msg='Could not obtain clientsecret of client %s for realm %s: %s' + % (id, realm, str(e))) + def get_groups(self, realm="master"): """ Fetch the name and ID of all groups on the Keycloak server. diff --git a/plugins/module_utils/identity/keycloak/keycloak_clientsecret.py b/plugins/module_utils/identity/keycloak/keycloak_clientsecret.py new file mode 100644 index 0000000000..85caa8e16b --- /dev/null +++ b/plugins/module_utils/identity/keycloak/keycloak_clientsecret.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2022, John Cant +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible.module_utils.basic import AnsibleModule + +from ansible_collections.community.general.plugins.module_utils.identity.keycloak.keycloak import \ + keycloak_argument_spec + + +def keycloak_clientsecret_module(): + """ + Returns an AnsibleModule definition for modules that interact with a client + secret. + + :return: argument_spec dict + """ + argument_spec = keycloak_argument_spec() + + meta_args = dict( + realm=dict(default='master'), + id=dict(type='str'), + client_id=dict(type='str', aliases=['clientId']), + ) + + argument_spec.update(meta_args) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_one_of=([['id', 'client_id'], + ['token', 'auth_realm', 'auth_username', 'auth_password']]), + required_together=([['auth_realm', 'auth_username', 'auth_password']]), + mutually_exclusive=[ + ['token', 'auth_realm'], + ['token', 'auth_username'], + ['token', 'auth_password'] + ]) + + return module + + +def keycloak_clientsecret_module_resolve_params(module, kc): + """ + Given an AnsibleModule definition for keycloak_clientsecret_*, and a + KeycloakAPI client, resolve the params needed to interact with the Keycloak + client secret, looking up the client by clientId if necessary via an API + call. + + :return: tuple of id, realm + """ + + realm = module.params.get('realm') + id = module.params.get('id') + client_id = module.params.get('client_id') + + # only lookup the client_id if id isn't provided. + # in the case that both are provided, prefer the ID, since it's one + # less lookup. + if id is None: + # Due to the required_one_of spec, client_id is guaranteed to not be None + client = kc.get_client_by_clientid(client_id, realm=realm) + + if client is None: + module.fail_json( + msg='Client does not exist {client_id}'.format(client_id=client_id) + ) + + id = client['id'] + + return id, realm diff --git a/plugins/modules/keycloak_clientsecret_info.py b/plugins/modules/keycloak_clientsecret_info.py new file mode 100644 index 0000000000..98a41ad20a --- /dev/null +++ b/plugins/modules/keycloak_clientsecret_info.py @@ -0,0 +1,161 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2022, Fynn Chen +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +DOCUMENTATION = ''' +--- +module: keycloak_clientsecret_info + +short_description: Retrieve client secret via Keycloak API + +version_added: 6.1.0 + +description: + - This module allows you to get a Keycloak client secret via the Keycloak + REST API. It requires access to the REST API via OpenID Connect; the user + connecting and the client being used must have the requisite access rights. + In a default Keycloak installation, admin-cli and an admin user would work, + as would a separate client definition with the scope tailored to your needs + and a user having the expected roles. + + - When retrieving a new client secret, where possible provide the client's + I(id) (not I(client_id)) to the module. This removes a lookup to the API to + translate the I(client_id) into the client ID. + + - "Note that this module returns the client secret. To avoid this showing up in the logs, + please add C(no_log: true) to the task." + +options: + realm: + type: str + description: + - They Keycloak realm under which this client resides. + default: 'master' + + id: + description: + - The unique identifier for this client. + - This parameter is not required for getting or generating a client secret but + providing it will reduce the number of API calls required. + type: str + + client_id: + description: + - The I(client_id) of the client. Passing this instead of I(id) results in an + extra API call. + aliases: + - clientId + type: str + + +extends_documentation_fragment: + - community.general.keycloak + - community.general.attributes + - community.general.attributes.info_module + +author: + - Fynn Chen (@fynncfchen) + - John Cant (@johncant) +''' + +EXAMPLES = ''' +- name: Get a Keycloak client secret, authentication with credentials + community.general.keycloak_clientsecret_info: + id: '9d59aa76-2755-48c6-b1af-beb70a82c3cd' + realm: MyCustomRealm + auth_client_id: admin-cli + auth_keycloak_url: https://auth.example.com/auth + auth_realm: master + auth_username: USERNAME + auth_password: PASSWORD + delegate_to: localhost + no_log: true + +- name: Get a new Keycloak client secret, authentication with token + community.general.keycloak_clientsecret_info: + id: '9d59aa76-2755-48c6-b1af-beb70a82c3cd' + realm: MyCustomRealm + auth_client_id: admin-cli + auth_keycloak_url: https://auth.example.com/auth + token: TOKEN + delegate_to: localhost + no_log: true + +- name: Get a new Keycloak client secret, passing client_id instead of id + community.general.keycloak_clientsecret_info: + client_id: 'myClientId' + realm: MyCustomRealm + auth_client_id: admin-cli + auth_keycloak_url: https://auth.example.com/auth + token: TOKEN + delegate_to: localhost + no_log: true +''' + +RETURN = ''' +msg: + description: Textual description of whether we succeeded or failed + returned: always + type: str + +clientsecret_info: + description: Representation of the client secret + returned: on success + type: complex + contains: + type: + description: Credential type. + type: str + returned: always + sample: secret + value: + description: Client secret. + type: str + returned: always + sample: cUGnX1EIeTtPPAkcyGMv0ncyqDPu68P1 +''' + +from ansible_collections.community.general.plugins.module_utils.identity.keycloak.keycloak import ( + KeycloakAPI, KeycloakError, get_token) +from ansible_collections.community.general.plugins.module_utils.identity.keycloak.keycloak_clientsecret import ( + keycloak_clientsecret_module, keycloak_clientsecret_module_resolve_params) + + +def main(): + """ + Module keycloak_clientsecret_info + + :return: + """ + + module = keycloak_clientsecret_module() + + # Obtain access token, initialize API + try: + connection_header = get_token(module.params) + except KeycloakError as e: + module.fail_json(msg=str(e)) + + kc = KeycloakAPI(module, connection_header) + + id, realm = keycloak_clientsecret_module_resolve_params(module, kc) + + clientsecret = kc.get_clientsecret(id=id, realm=realm) + + result = { + 'clientsecret_info': clientsecret, + 'msg': 'Get client secret successful for ID {id}'.format(id=id) + } + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/plugins/modules/keycloak_clientsecret_regenerate.py b/plugins/modules/keycloak_clientsecret_regenerate.py new file mode 100644 index 0000000000..7a48a25d25 --- /dev/null +++ b/plugins/modules/keycloak_clientsecret_regenerate.py @@ -0,0 +1,167 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2022, Fynn Chen +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +DOCUMENTATION = ''' +--- +module: keycloak_clientsecret_regenerate + +short_description: Regenerate Keycloak client secret via Keycloak API + +version_added: 6.1.0 + +description: + - This module allows you to regenerate a Keycloak client secret via the + Keycloak REST API. It requires access to the REST API via OpenID Connect; + the user connecting and the client being used must have the requisite access + rights. In a default Keycloak installation, admin-cli and an admin user + would work, as would a separate client definition with the scope tailored to + your needs and a user having the expected roles. + + - When regenerating a client secret, where possible provide the client's id + (not client_id) to the module. This removes a lookup to the API to + translate the client_id into the client ID. + + - "Note that this module returns the client secret. To avoid this showing up in the logs, + please add C(no_log: true) to the task." + +options: + realm: + type: str + description: + - They Keycloak realm under which this client resides. + default: 'master' + + id: + description: + - The unique identifier for this client. + - This parameter is not required for getting or generating a client secret but + providing it will reduce the number of API calls required. + type: str + + client_id: + description: + - The client_id of the client. Passing this instead of id results in an + extra API call. + aliases: + - clientId + type: str + + +extends_documentation_fragment: + - community.general.keycloak + +author: + - Fynn Chen (@fynncfchen) + - John Cant (@johncant) +''' + +EXAMPLES = ''' +- name: Regenerate a Keycloak client secret, authentication with credentials + community.general.keycloak_clientsecret_regenerate: + id: '9d59aa76-2755-48c6-b1af-beb70a82c3cd' + realm: MyCustomRealm + auth_client_id: admin-cli + auth_keycloak_url: https://auth.example.com/auth + auth_realm: master + auth_username: USERNAME + auth_password: PASSWORD + delegate_to: localhost + no_log: true + +- name: Regenerate a Keycloak client secret, authentication with token + community.general.keycloak_clientsecret_regenerate: + id: '9d59aa76-2755-48c6-b1af-beb70a82c3cd' + realm: MyCustomRealm + auth_client_id: admin-cli + auth_keycloak_url: https://auth.example.com/auth + token: TOKEN + delegate_to: localhost + no_log: true + +- name: Regenerate a Keycloak client secret, passing client_id instead of id + community.general.keycloak_clientsecret_info: + client_id: 'myClientId' + realm: MyCustomRealm + auth_client_id: admin-cli + auth_keycloak_url: https://auth.example.com/auth + token: TOKEN + delegate_to: localhost + no_log: true +''' + +RETURN = ''' +msg: + description: Message as to what action was taken. + returned: always + type: str + +end_state: + description: Representation of the client credential after module execution + returned: on success + type: complex + contains: + type: + description: Credential type. + type: str + returned: always + sample: secret + value: + description: Client secret. + type: str + returned: always + sample: cUGnX1EIeTtPPAkcyGMv0ncyqDPu68P1 + +''' + +from ansible_collections.community.general.plugins.module_utils.identity.keycloak.keycloak import ( + KeycloakAPI, KeycloakError, get_token) +from ansible_collections.community.general.plugins.module_utils.identity.keycloak.keycloak_clientsecret import ( + keycloak_clientsecret_module, keycloak_clientsecret_module_resolve_params) + + +def main(): + """ + Module keycloak_clientsecret_regenerate + + :return: + """ + + module = keycloak_clientsecret_module() + + # Obtain access token, initialize API + try: + connection_header = get_token(module.params) + except KeycloakError as e: + module.fail_json(msg=str(e)) + + kc = KeycloakAPI(module, connection_header) + + id, realm = keycloak_clientsecret_module_resolve_params(module, kc) + + if module.check_mode: + dummy_result = { + "msg": 'No action taken while in check mode', + "end_state": {'type': 'secret', 'value': 'X' * 32} + } + module.exit_json(**dummy_result) + + # Create new secret + clientsecret = kc.create_clientsecret(id=id, realm=realm) + + result = { + "msg": 'New client secret has been generated for ID {id}'.format(id=id), + "end_state": clientsecret + } + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/tests/integration/targets/keycloak_clientsecret_info/README.md b/tests/integration/targets/keycloak_clientsecret_info/README.md new file mode 100644 index 0000000000..fb721801da --- /dev/null +++ b/tests/integration/targets/keycloak_clientsecret_info/README.md @@ -0,0 +1,17 @@ + + +The integration test can be performed as follows: + +``` +# 1. Start docker-compose: +docker-compose -f tests/integration/targets/keycloak_clientsecret_info/docker-compose.yml stop +docker-compose -f tests/integration/targets/keycloak_clientsecret_info/docker-compose.yml rm -f -v +docker-compose -f tests/integration/targets/keycloak_clientsecret_info/docker-compose.yml up -d + +# 2. Run the integration tests: +ansible-test integration keycloak_clientsecret_info --allow-unsupported -v +``` diff --git a/tests/integration/targets/keycloak_clientsecret_info/docker-compose.yml b/tests/integration/targets/keycloak_clientsecret_info/docker-compose.yml new file mode 100644 index 0000000000..5e14e9aac1 --- /dev/null +++ b/tests/integration/targets/keycloak_clientsecret_info/docker-compose.yml @@ -0,0 +1,31 @@ +--- +# Copyright (c) Ansible Project +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +version: '3.4' + +services: + postgres: + image: postgres:9.6 + restart: always + environment: + POSTGRES_USER: postgres + POSTGRES_DB: postgres + POSTGRES_PASSWORD: postgres + + keycloak: + image: jboss/keycloak:12.0.4 + ports: + - 8080:8080 + + environment: + DB_VENDOR: postgres + DB_ADDR: postgres + DB_DATABASE: postgres + DB_USER: postgres + DB_SCHEMA: public + DB_PASSWORD: postgres + + KEYCLOAK_USER: admin + KEYCLOAK_PASSWORD: password diff --git a/tests/integration/targets/keycloak_clientsecret_info/tasks/main.yml b/tests/integration/targets/keycloak_clientsecret_info/tasks/main.yml new file mode 100644 index 0000000000..a0cacf1889 --- /dev/null +++ b/tests/integration/targets/keycloak_clientsecret_info/tasks/main.yml @@ -0,0 +1,48 @@ +--- +# Copyright (c) Ansible Project +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +- name: Create realm + community.general.keycloak_realm: "{{ auth_args | combine(call_args) }}" + vars: + call_args: + id: "{{ realm }}" + realm: "{{ realm }}" + state: present + +- name: Keycloak Client + community.general.keycloak_client: "{{ auth_args | combine(call_args) }}" + vars: + call_args: + realm: "{{ realm }}" + client_id: "{{ client_id }}" + state: present + register: client + +- name: Keycloak Client fetch clientsecret by client_id + community.general.keycloak_clientsecret_info: "{{ auth_args | combine(call_args) }}" + vars: + call_args: + realm: "{{ realm }}" + client_id: "{{ client_id }}" + register: fetch_by_client_id_result + +- name: Assert that the client secret was retrieved + assert: + that: + - fetch_by_client_id_result.clientsecret_info.type == "secret" + - "{{ fetch_by_client_id_result.clientsecret_info.value | length }} >= 32" + +- name: Keycloak Client fetch clientsecret by id + community.general.keycloak_clientsecret_info: "{{ auth_args | combine(call_args) }}" + vars: + call_args: + realm: "{{ realm }}" + id: "{{ client.end_state.id }}" + register: fetch_by_id_result + +- name: Assert that the same client secret was retrieved both times + assert: + that: + - fetch_by_id_result.clientsecret_info.value == fetch_by_client_id_result.clientsecret_info.value diff --git a/tests/integration/targets/keycloak_clientsecret_info/vars/main.yml b/tests/integration/targets/keycloak_clientsecret_info/vars/main.yml new file mode 100644 index 0000000000..8c913705f7 --- /dev/null +++ b/tests/integration/targets/keycloak_clientsecret_info/vars/main.yml @@ -0,0 +1,20 @@ +--- +# Copyright (c) Ansible Project +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +url: http://localhost:8080/auth +admin_realm: master +admin_user: admin +admin_password: password +realm: myrealm +client_id: myclient +role: myrole +description_1: desc 1 +description_2: desc 2 + +auth_args: + auth_keycloak_url: "{{ url }}" + auth_realm: "{{ admin_realm }}" + auth_username: "{{ admin_user }}" + auth_password: "{{ admin_password }}" diff --git a/tests/integration/targets/keycloak_clientsecret_regenerate/README.md b/tests/integration/targets/keycloak_clientsecret_regenerate/README.md new file mode 100644 index 0000000000..08251b4c52 --- /dev/null +++ b/tests/integration/targets/keycloak_clientsecret_regenerate/README.md @@ -0,0 +1,17 @@ + + +The integration test can be performed as follows: + +``` +# 1. Start docker-compose: +docker-compose -f tests/integration/targets/keycloak_clientsecret_regenerate/docker-compose.yml stop +docker-compose -f tests/integration/targets/keycloak_clientsecret_regenerate/docker-compose.yml rm -f -v +docker-compose -f tests/integration/targets/keycloak_clientsecret_regenerate/docker-compose.yml up -d + +# 2. Run the integration tests: +ansible-test integration keycloak_clientsecret_regenerate --allow-unsupported -v +``` diff --git a/tests/integration/targets/keycloak_clientsecret_regenerate/docker-compose.yml b/tests/integration/targets/keycloak_clientsecret_regenerate/docker-compose.yml new file mode 100644 index 0000000000..5e14e9aac1 --- /dev/null +++ b/tests/integration/targets/keycloak_clientsecret_regenerate/docker-compose.yml @@ -0,0 +1,31 @@ +--- +# Copyright (c) Ansible Project +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +version: '3.4' + +services: + postgres: + image: postgres:9.6 + restart: always + environment: + POSTGRES_USER: postgres + POSTGRES_DB: postgres + POSTGRES_PASSWORD: postgres + + keycloak: + image: jboss/keycloak:12.0.4 + ports: + - 8080:8080 + + environment: + DB_VENDOR: postgres + DB_ADDR: postgres + DB_DATABASE: postgres + DB_USER: postgres + DB_SCHEMA: public + DB_PASSWORD: postgres + + KEYCLOAK_USER: admin + KEYCLOAK_PASSWORD: password diff --git a/tests/integration/targets/keycloak_clientsecret_regenerate/tasks/main.yml b/tests/integration/targets/keycloak_clientsecret_regenerate/tasks/main.yml new file mode 100644 index 0000000000..9bd52698a2 --- /dev/null +++ b/tests/integration/targets/keycloak_clientsecret_regenerate/tasks/main.yml @@ -0,0 +1,49 @@ +--- +# Copyright (c) Ansible Project +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +- name: Create realm + community.general.keycloak_realm: "{{ auth_args | combine(call_args) }}" + vars: + call_args: + id: "{{ realm }}" + realm: "{{ realm }}" + state: present + +- name: Keycloak Client + community.general.keycloak_client: "{{ auth_args | combine(call_args) }}" + vars: + call_args: + realm: "{{ realm }}" + client_id: "{{ client_id }}" + state: present + register: client + +- name: Keycloak Client regenerate clientsecret by client_id + community.general.keycloak_clientsecret_regenerate: "{{ auth_args | combine(call_args) }}" + vars: + call_args: + realm: "{{ realm }}" + client_id: "{{ client_id }}" + register: regenerate_by_client_id + +- name: Assert that the client secret was retrieved + assert: + that: + - regenerate_by_client_id.end_state.type == "secret" + - "{{ regenerate_by_client_id.end_state.value | length }} >= 32" + +- name: Keycloak Client regenerate clientsecret by id + community.general.keycloak_clientsecret_regenerate: "{{ auth_args | combine(call_args) }}" + vars: + call_args: + realm: "{{ realm }}" + id: "{{ client.end_state.id }}" + register: regenerate_by_id + +- name: Assert that client secret was regenerated + assert: + that: + - "{{ regenerate_by_id.end_state.value | length }} >= 32" + - regenerate_by_id.end_state.value != regenerate_by_client_id.end_state.value diff --git a/tests/integration/targets/keycloak_clientsecret_regenerate/vars/main.yml b/tests/integration/targets/keycloak_clientsecret_regenerate/vars/main.yml new file mode 100644 index 0000000000..8c913705f7 --- /dev/null +++ b/tests/integration/targets/keycloak_clientsecret_regenerate/vars/main.yml @@ -0,0 +1,20 @@ +--- +# Copyright (c) Ansible Project +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +url: http://localhost:8080/auth +admin_realm: master +admin_user: admin +admin_password: password +realm: myrealm +client_id: myclient +role: myrole +description_1: desc 1 +description_2: desc 2 + +auth_args: + auth_keycloak_url: "{{ url }}" + auth_realm: "{{ admin_realm }}" + auth_username: "{{ admin_user }}" + auth_password: "{{ admin_password }}" From f0b3bba030055183b864678208e187c24d2ca581 Mon Sep 17 00:00:00 2001 From: fachleitner Date: Mon, 5 Dec 2022 06:23:00 +0100 Subject: [PATCH 0075/1810] Fix keycloak_client_rolemapping role removal and diff (#5619) * Keycloak: Fix client rolemapping removal Keycloak's delete_group_rolemapping API wrapper didn't pass data about the roles to remove to keycloak, resulting in removal of all roles. Follow the intended behaviour and delete only the roles listed in the module invocation. Signed-off-by: Florian Achleitner * Keycloak: Fix client_rolemapping diff The module's diff output wrongly showed the changed roles list as 'after' state. This is obviously wrong for role removal and also wrong for role addition, if there are other roles assigned. Use the result of the API query for 'end_state' for 'diff' as well. Signed-off-by: Florian Achleitner * Keycloak: Calculate client_rolemapping proposed state properly Signed-off-by: Florian Achleitner * Add changelog fragment Signed-off-by: Florian Achleitner Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein * Fix for python2 unit test Signed-off-by: Florian Achleitner Co-authored-by: Felix Fontein --- changelogs/fragments/5619-keycloak-improvements.yml | 3 +++ plugins/module_utils/identity/keycloak/keycloak.py | 2 +- plugins/modules/keycloak_client_rolemapping.py | 11 +++++++---- 3 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/5619-keycloak-improvements.yml diff --git a/changelogs/fragments/5619-keycloak-improvements.yml b/changelogs/fragments/5619-keycloak-improvements.yml new file mode 100644 index 0000000000..2e5a739dad --- /dev/null +++ b/changelogs/fragments/5619-keycloak-improvements.yml @@ -0,0 +1,3 @@ +bugfixes: + - "keycloak_client_rolemapping - remove only listed mappings with ``state=absent`` (https://github.com/ansible-collections/community.general/pull/5619)." + - "keycloak_client_rolemapping - calculate ``proposed`` and ``after`` return values properly (https://github.com/ansible-collections/community.general/pull/5619)." diff --git a/plugins/module_utils/identity/keycloak/keycloak.py b/plugins/module_utils/identity/keycloak/keycloak.py index 87b2120318..09b22b7561 100644 --- a/plugins/module_utils/identity/keycloak/keycloak.py +++ b/plugins/module_utils/identity/keycloak/keycloak.py @@ -608,7 +608,7 @@ class KeycloakAPI(object): """ available_rolemappings_url = URL_CLIENT_GROUP_ROLEMAPPINGS.format(url=self.baseurl, realm=realm, id=gid, client=cid) try: - open_url(available_rolemappings_url, method="DELETE", http_agent=self.http_agent, headers=self.restheaders, + open_url(available_rolemappings_url, method="DELETE", http_agent=self.http_agent, headers=self.restheaders, data=json.dumps(role_rep), validate_certs=self.validate_certs, timeout=self.connection_timeout) except Exception as e: self.module.fail_json(msg="Could not delete available rolemappings for client %s in group %s, realm %s: %s" diff --git a/plugins/modules/keycloak_client_rolemapping.py b/plugins/modules/keycloak_client_rolemapping.py index 4f1f9b0d0f..f0da97ef59 100644 --- a/plugins/modules/keycloak_client_rolemapping.py +++ b/plugins/modules/keycloak_client_rolemapping.py @@ -295,7 +295,7 @@ def main(): assigned_roles_before = kc.get_client_group_composite_rolemappings(gid, cid, realm=realm) result['existing'] = assigned_roles_before - result['proposed'] = roles + result['proposed'] = list(assigned_roles_before) if assigned_roles_before else [] update_roles = [] for role_index, role in enumerate(roles, start=0): @@ -307,6 +307,7 @@ def main(): 'id': role['id'], 'name': role['name'], }) + result['proposed'].append(available_role) # Fetch roles to remove if state absent else: for assigned_role in assigned_roles_before: @@ -315,13 +316,15 @@ def main(): 'id': role['id'], 'name': role['name'], }) + if assigned_role in result['proposed']: # Handle double removal + result['proposed'].remove(assigned_role) if len(update_roles): if state == 'present': # Assign roles result['changed'] = True if module._diff: - result['diff'] = dict(before=assigned_roles_before, after=update_roles) + result['diff'] = dict(before=assigned_roles_before, after=result['proposed']) if module.check_mode: module.exit_json(**result) kc.add_group_rolemapping(gid, cid, update_roles, realm=realm) @@ -333,7 +336,7 @@ def main(): # Remove mapping of role result['changed'] = True if module._diff: - result['diff'] = dict(before=assigned_roles_before, after=update_roles) + result['diff'] = dict(before=assigned_roles_before, after=result['proposed']) if module.check_mode: module.exit_json(**result) kc.delete_group_rolemapping(gid, cid, update_roles, realm=realm) @@ -344,7 +347,7 @@ def main(): # Do nothing else: result['changed'] = False - result['msg'] = 'Nothing to do, roles %s are correctly mapped with group %s.' % (roles, group_name) + result['msg'] = 'Nothing to do, roles %s are %s with group %s.' % (roles, 'mapped' if state == 'present' else 'not mapped', group_name) module.exit_json(**result) From b22638ba0cea86994006aa399b94fa45a1c2ff0e Mon Sep 17 00:00:00 2001 From: TSKushal <44438079+TSKushal@users.noreply.github.com> Date: Mon, 5 Dec 2022 23:01:50 +0530 Subject: [PATCH 0076/1810] Adding PUT functionality to redfish_utils (Updated) (#5507) * adding changelog fragment * adding PUT functionality * sanity fix Co-authored-by: Kushal --- .../5490-adding-put-functionality.yml | 2 + plugins/module_utils/redfish_utils.py | 37 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 changelogs/fragments/5490-adding-put-functionality.yml diff --git a/changelogs/fragments/5490-adding-put-functionality.yml b/changelogs/fragments/5490-adding-put-functionality.yml new file mode 100644 index 0000000000..09141d2822 --- /dev/null +++ b/changelogs/fragments/5490-adding-put-functionality.yml @@ -0,0 +1,2 @@ +minor_changes: + - redfish_utils module utils - added PUT (``put_request()``) functionality (https://github.com/ansible-collections/community.general/pull/5490). diff --git a/plugins/module_utils/redfish_utils.py b/plugins/module_utils/redfish_utils.py index a86baa1066..4a56346c3f 100644 --- a/plugins/module_utils/redfish_utils.py +++ b/plugins/module_utils/redfish_utils.py @@ -19,6 +19,8 @@ POST_HEADERS = {'content-type': 'application/json', 'accept': 'application/json' 'OData-Version': '4.0'} PATCH_HEADERS = {'content-type': 'application/json', 'accept': 'application/json', 'OData-Version': '4.0'} +PUT_HEADERS = {'content-type': 'application/json', 'accept': 'application/json', + 'OData-Version': '4.0'} DELETE_HEADERS = {'accept': 'application/json', 'OData-Version': '4.0'} FAIL_MSG = 'Issuing a data modification command without specifying the '\ @@ -224,6 +226,41 @@ class RedfishUtils(object): 'msg': "Failed PATCH request to '%s': '%s'" % (uri, to_text(e))} return {'ret': True, 'changed': True, 'resp': resp, 'msg': 'Modified %s' % uri} + def put_request(self, uri, pyld): + req_headers = dict(PUT_HEADERS) + r = self.get_request(uri) + if r['ret']: + # Get etag from etag header or @odata.etag property + etag = r['headers'].get('etag') + if not etag: + etag = r['data'].get('@odata.etag') + if etag: + if self.strip_etag_quotes: + etag = etag.strip('"') + req_headers['If-Match'] = etag + username, password, basic_auth = self._auth_params(req_headers) + try: + resp = open_url(uri, data=json.dumps(pyld), + headers=req_headers, method="PUT", + url_username=username, url_password=password, + force_basic_auth=basic_auth, validate_certs=False, + follow_redirects='all', + use_proxy=True, timeout=self.timeout) + except HTTPError as e: + msg = self._get_extended_message(e) + return {'ret': False, + 'msg': "HTTP Error %s on PUT request to '%s', extended message: '%s'" + % (e.code, uri, msg), + 'status': e.code} + except URLError as e: + return {'ret': False, 'msg': "URL Error on PUT request to '%s': '%s'" + % (uri, e.reason)} + # Almost all errors should be caught above, but just in case + except Exception as e: + return {'ret': False, + 'msg': "Failed PUT request to '%s': '%s'" % (uri, to_text(e))} + return {'ret': True, 'resp': resp} + def delete_request(self, uri, pyld=None): req_headers = dict(DELETE_HEADERS) username, password, basic_auth = self._auth_params(req_headers) From b52a7a6b0edcf5f73904259f6a21777cd94a2d49 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Tue, 6 Dec 2022 07:30:54 +0100 Subject: [PATCH 0077/1810] Next expected release is 6.2.0. --- galaxy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/galaxy.yml b/galaxy.yml index 1c300da904..f55ebce545 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -5,7 +5,7 @@ namespace: community name: general -version: 6.1.0 +version: 6.2.0 readme: README.md authors: - Ansible (https://github.com/ansible) From 50021d6bfb58b1551cb9ca0bf09a865bd49f895e Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Thu, 8 Dec 2022 22:13:41 +0100 Subject: [PATCH 0078/1810] Fix pipx_info tests (#5668) Update dependencies. --- tests/integration/targets/pipx_info/tasks/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/integration/targets/pipx_info/tasks/main.yml b/tests/integration/targets/pipx_info/tasks/main.yml index 61163afd08..0a01f0af9c 100644 --- a/tests/integration/targets/pipx_info/tasks/main.yml +++ b/tests/integration/targets/pipx_info/tasks/main.yml @@ -56,7 +56,8 @@ - info_all_deps.application|length == 1 - info_all_deps.application[0].name == "tox" - "'version' in info_all_deps.application[0]" - - info_all_deps.application[0].dependencies == ["virtualenv"] + - info_all_deps.application[0].dependencies == ["chardet", "virtualenv"] + or info_all_deps.application[0].dependencies == ["virtualenv"] - "'injected' not in info_all.application[0]" - info_tox.application == info_all_deps.application From 471f523f53220bfbb3e6585b767c7483790c025d Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Thu, 8 Dec 2022 22:40:37 +0100 Subject: [PATCH 0079/1810] redhat_subscription: add `server_proxy_scheme` parameter (#5662) Add the `server_proxy_scheme` parameter to configure the scheme used for the proxy server. This completes the configuration parameters for the proxy server. --- .../5662-redhat_subscription-server_proxy_scheme.yaml | 3 +++ plugins/modules/redhat_subscription.py | 6 ++++++ tests/unit/plugins/modules/test_redhat_subscription.py | 2 ++ 3 files changed, 11 insertions(+) create mode 100644 changelogs/fragments/5662-redhat_subscription-server_proxy_scheme.yaml diff --git a/changelogs/fragments/5662-redhat_subscription-server_proxy_scheme.yaml b/changelogs/fragments/5662-redhat_subscription-server_proxy_scheme.yaml new file mode 100644 index 0000000000..293e18311a --- /dev/null +++ b/changelogs/fragments/5662-redhat_subscription-server_proxy_scheme.yaml @@ -0,0 +1,3 @@ +minor_changes: + - redhat_subscription - add a ``server_proxy_scheme`` parameter to configure the scheme for the proxy server + (https://github.com/ansible-collections/community.general/pull/5662). diff --git a/plugins/modules/redhat_subscription.py b/plugins/modules/redhat_subscription.py index 041c1a0097..8836b78564 100644 --- a/plugins/modules/redhat_subscription.py +++ b/plugins/modules/redhat_subscription.py @@ -70,6 +70,11 @@ options: description: - Specify an HTTP proxy hostname. type: str + server_proxy_scheme: + description: + - Specify an HTTP proxy scheme, for example C(http) or C(https). + type: str + version_added: 6.2.0 server_proxy_port: description: - Specify an HTTP proxy port. @@ -806,6 +811,7 @@ def main(): 'consumer_id': {}, 'force_register': {'default': False, 'type': 'bool'}, 'server_proxy_hostname': {}, + 'server_proxy_scheme': {}, 'server_proxy_port': {}, 'server_proxy_user': {}, 'server_proxy_password': {'no_log': True}, diff --git a/tests/unit/plugins/modules/test_redhat_subscription.py b/tests/unit/plugins/modules/test_redhat_subscription.py index f38f1ffe0d..865f041141 100644 --- a/tests/unit/plugins/modules/test_redhat_subscription.py +++ b/tests/unit/plugins/modules/test_redhat_subscription.py @@ -308,6 +308,7 @@ TEST_CASES = [ 'org_id': 'admin', 'force_register': 'true', 'server_proxy_hostname': 'proxy.company.com', + 'server_proxy_scheme': 'https', 'server_proxy_port': '12345', 'server_proxy_user': 'proxy_user', 'server_proxy_password': 'secret_proxy_password' @@ -327,6 +328,7 @@ TEST_CASES = [ '--server.proxy_hostname=proxy.company.com', '--server.proxy_password=secret_proxy_password', '--server.proxy_port=12345', + '--server.proxy_scheme=https', '--server.proxy_user=proxy_user' ], {'check_rc': True}, From b5e58a3bccd38791e1c8871bf471941c1d1c762f Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Fri, 9 Dec 2022 15:10:48 +0100 Subject: [PATCH 0080/1810] CI: Bump CentOS Stream 8 Python from 3.8 to 3.9 (#5674) Bump CentOS Stream 8 Python from 3.8 to 3.9. --- .azure-pipelines/azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/azure-pipelines.yml b/.azure-pipelines/azure-pipelines.yml index c39a855dd0..a5dcafa422 100644 --- a/.azure-pipelines/azure-pipelines.yml +++ b/.azure-pipelines/azure-pipelines.yml @@ -386,7 +386,7 @@ stages: - name: ArchLinux test: archlinux/3.10 - name: CentOS Stream 8 - test: centos-stream8/3.8 + test: centos-stream8/3.9 groups: - 1 - 2 From c3bc172bf6fccdca9c16155da058ce95a57e6076 Mon Sep 17 00:00:00 2001 From: Markus Bergholz Date: Sat, 10 Dec 2022 21:40:36 +0100 Subject: [PATCH 0081/1810] respect new variable property in gitlab_group_variable and gitlab_project_variable (#5667) * draft * add changelog fragment * rework * rework group variables * add new line at end of file * Update plugins/module_utils/gitlab.py Co-authored-by: Nejc Habjan * rename * revert * return a copy * Update plugins/modules/gitlab_project_variable.py Co-authored-by: Felix Fontein Co-authored-by: Nejc Habjan Co-authored-by: Felix Fontein --- .../fragments/5666-gitlab-variables.yml | 3 +++ plugins/module_utils/gitlab.py | 11 +++++++++ plugins/modules/gitlab_group_variable.py | 12 +++------- plugins/modules/gitlab_project_variable.py | 23 ++++++++----------- 4 files changed, 27 insertions(+), 22 deletions(-) create mode 100644 changelogs/fragments/5666-gitlab-variables.yml diff --git a/changelogs/fragments/5666-gitlab-variables.yml b/changelogs/fragments/5666-gitlab-variables.yml new file mode 100644 index 0000000000..2070fa8e4a --- /dev/null +++ b/changelogs/fragments/5666-gitlab-variables.yml @@ -0,0 +1,3 @@ +bugfixes: + - gitlab_group_variables - fix dropping variables accidentally when GitLab introduced new properties (https://github.com/ansible-collections/community.general/pull/5667). + - gitlab_project_variables - fix dropping variables accidentally when GitLab introduced new properties (https://github.com/ansible-collections/community.general/pull/5667). \ No newline at end of file diff --git a/plugins/module_utils/gitlab.py b/plugins/module_utils/gitlab.py index 3ed338b401..7cb59e4c2c 100644 --- a/plugins/module_utils/gitlab.py +++ b/plugins/module_utils/gitlab.py @@ -110,3 +110,14 @@ def gitlab_authentication(module): GitLab remove Session API now that private tokens are removed from user API endpoints since version 10.2." % to_native(e)) return gitlab_instance + + +def filter_returned_variables(gitlab_variables): + # pop properties we don't know + existing_variables = [dict(x.attributes) for x in gitlab_variables] + KNOWN = ['key', 'value', 'masked', 'protected', 'variable_type', 'environment_scope'] + for item in existing_variables: + for key in list(item.keys()): + if key not in KNOWN: + item.pop(key) + return existing_variables diff --git a/plugins/modules/gitlab_group_variable.py b/plugins/modules/gitlab_group_variable.py index c273777ca3..4a185b2394 100644 --- a/plugins/modules/gitlab_group_variable.py +++ b/plugins/modules/gitlab_group_variable.py @@ -165,7 +165,7 @@ from ansible.module_utils.six import string_types from ansible.module_utils.six import integer_types from ansible_collections.community.general.plugins.module_utils.gitlab import ( - auth_argument_spec, gitlab_authentication, ensure_gitlab_package + auth_argument_spec, gitlab_authentication, ensure_gitlab_package, filter_returned_variables ) @@ -296,11 +296,7 @@ def native_python_main(this_gitlab, purge, requested_variables, state, module): before = [x.attributes for x in gitlab_keys] gitlab_keys = this_gitlab.list_all_group_variables() - existing_variables = [x.attributes for x in gitlab_keys] - - # preprocessing:filter out and enrich before compare - for item in existing_variables: - item.pop('group_id') + existing_variables = filter_returned_variables(gitlab_keys) for item in requested_variables: item['key'] = item.pop('name') @@ -331,9 +327,7 @@ def native_python_main(this_gitlab, purge, requested_variables, state, module): if purge: # refetch and filter gitlab_keys = this_gitlab.list_all_group_variables() - existing_variables = [x.attributes for x in gitlab_keys] - for item in existing_variables: - item.pop('group_id') + existing_variables = filter_returned_variables(gitlab_keys) remove = [x for x in existing_variables if x not in requested_variables] for item in remove: diff --git a/plugins/modules/gitlab_project_variable.py b/plugins/modules/gitlab_project_variable.py index cdd6402ae8..986847c07b 100644 --- a/plugins/modules/gitlab_project_variable.py +++ b/plugins/modules/gitlab_project_variable.py @@ -189,7 +189,7 @@ except Exception: HAS_GITLAB_PACKAGE = False from ansible_collections.community.general.plugins.module_utils.gitlab import ( - auth_argument_spec, gitlab_authentication, ensure_gitlab_package + auth_argument_spec, gitlab_authentication, ensure_gitlab_package, filter_returned_variables ) @@ -255,9 +255,11 @@ class GitlabProjectVariables(object): return True var = { - "key": var_obj.get('key'), "value": var_obj.get('value'), - "masked": var_obj.get('masked'), "protected": var_obj.get('protected'), - "variable_type": var_obj.get('variable_type') + "key": var_obj.get('key'), + "value": var_obj.get('value'), + "masked": var_obj.get('masked'), + "protected": var_obj.get('protected'), + "variable_type": var_obj.get('variable_type'), } if var_obj.get('environment_scope') is not None: @@ -319,12 +321,9 @@ def native_python_main(this_gitlab, purge, requested_variables, state, module): before = [x.attributes for x in gitlab_keys] gitlab_keys = this_gitlab.list_all_project_variables() - existing_variables = [x.attributes for x in gitlab_keys] - - # preprocessing:filter out and enrich before compare - for item in existing_variables: - item.pop('project_id') + existing_variables = filter_returned_variables(gitlab_keys) + # filter out and enrich before compare for item in requested_variables: item['key'] = item.pop('name') item['value'] = str(item.get('value')) @@ -354,9 +353,7 @@ def native_python_main(this_gitlab, purge, requested_variables, state, module): if purge: # refetch and filter gitlab_keys = this_gitlab.list_all_project_variables() - existing_variables = [x.attributes for x in gitlab_keys] - for item in existing_variables: - item.pop('project_id') + existing_variables = filter_returned_variables(gitlab_keys) remove = [x for x in existing_variables if x not in requested_variables] for item in remove: @@ -409,7 +406,7 @@ def main(): masked=dict(type='bool', default=False), protected=dict(type='bool', default=False), environment_scope=dict(type='str', default='*'), - variable_type=dict(type='str', default='env_var', choices=["env_var", "file"]) + variable_type=dict(type='str', default='env_var', choices=["env_var", "file"]), )), state=dict(type='str', default="present", choices=["absent", "present"]), ) From f95e0d775d301ab36d22526d5f2c25b7598084a4 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Thu, 15 Dec 2022 09:30:03 +1300 Subject: [PATCH 0082/1810] puppet: refactored to use CmdRunner (#5612) * puppet: refactored to use CmdRunner * add changelog fragment * add more tests --- .github/BOTMETA.yml | 3 + .../fragments/5612-puppet-cmd-runner.yml | 2 + plugins/module_utils/puppet.py | 114 ++++++++++++++ plugins/modules/puppet.py | 108 ++----------- tests/sanity/ignore-2.11.txt | 3 +- tests/sanity/ignore-2.12.txt | 3 +- tests/sanity/ignore-2.13.txt | 3 +- tests/sanity/ignore-2.14.txt | 3 +- tests/sanity/ignore-2.15.txt | 3 +- tests/unit/plugins/modules/test_puppet.py | 145 ++++++++++++++++++ 10 files changed, 282 insertions(+), 105 deletions(-) create mode 100644 changelogs/fragments/5612-puppet-cmd-runner.yml create mode 100644 plugins/module_utils/puppet.py create mode 100644 tests/unit/plugins/modules/test_puppet.py diff --git a/.github/BOTMETA.yml b/.github/BOTMETA.yml index 18f4f66e1f..0a0cded0c1 100644 --- a/.github/BOTMETA.yml +++ b/.github/BOTMETA.yml @@ -309,6 +309,9 @@ files: $module_utils/pipx.py: labels: pipx maintainers: russoz + $module_utils/puppet.py: + labels: puppet + maintainers: russoz $module_utils/pure.py: labels: pure pure_storage maintainers: $team_purestorage diff --git a/changelogs/fragments/5612-puppet-cmd-runner.yml b/changelogs/fragments/5612-puppet-cmd-runner.yml new file mode 100644 index 0000000000..a2d14bf5fc --- /dev/null +++ b/changelogs/fragments/5612-puppet-cmd-runner.yml @@ -0,0 +1,2 @@ +minor_changes: + - puppet - refactored module to use ``CmdRunner`` for executing ``puppet`` (https://github.com/ansible-collections/community.general/pull/5612). diff --git a/plugins/module_utils/puppet.py b/plugins/module_utils/puppet.py new file mode 100644 index 0000000000..06369882fb --- /dev/null +++ b/plugins/module_utils/puppet.py @@ -0,0 +1,114 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2022, Alexei Znamensky +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +import os + +from ansible_collections.community.general.plugins.module_utils.cmd_runner import CmdRunner, cmd_runner_fmt + + +_PUPPET_PATH_PREFIX = ["/opt/puppetlabs/bin"] + + +def get_facter_dir(): + if os.getuid() == 0: + return '/etc/facter/facts.d' + else: + return os.path.expanduser('~/.facter/facts.d') + + +def _puppet_cmd(module): + return module.get_bin_path("puppet", False, _PUPPET_PATH_PREFIX) + + +# If the `timeout` CLI command feature is removed, +# Then we could add this as a fixed param to `puppet_runner` +def ensure_agent_enabled(module): + runner = CmdRunner( + module, + command="puppet", + path_prefix=_PUPPET_PATH_PREFIX, + arg_formats=dict( + _agent_disabled=cmd_runner_fmt.as_fixed(['config', 'print', 'agent_disabled_lockfile']), + ), + check_rc=False, + ) + + rc, stdout, stderr = runner("_agent_disabled").run() + if os.path.exists(stdout.strip()): + module.fail_json( + msg="Puppet agent is administratively disabled.", + disabled=True) + elif rc != 0: + module.fail_json( + msg="Puppet agent state could not be determined.") + + +def puppet_runner(module): + + # Keeping backward compatibility, allow for running with the `timeout` CLI command. + # If this can be replaced with ansible `timeout` parameter in playbook, + # then this function could be removed. + def _prepare_base_cmd(): + _tout_cmd = module.get_bin_path("timeout", False) + if _tout_cmd: + cmd = ["timeout", "-s", "9", module.params["timeout"], _puppet_cmd(module)] + else: + cmd = ["puppet"] + return cmd + + def noop_func(v): + _noop = cmd_runner_fmt.as_map({ + True: "--noop", + False: "--no-noop", + }) + return _noop(module.check_mode or v) + + _logdest_map = { + "syslog": ["--logdest", "syslog"], + "all": ["--logdest", "syslog", "--logdest", "console"], + } + + @cmd_runner_fmt.unpack_args + def execute_func(execute, manifest): + if execute: + return ["--execute", execute] + else: + return [manifest] + + runner = CmdRunner( + module, + command=_prepare_base_cmd(), + path_prefix=_PUPPET_PATH_PREFIX, + arg_formats=dict( + _agent_fixed=cmd_runner_fmt.as_fixed([ + "agent", "--onetime", "--no-daemonize", "--no-usecacheonfailure", + "--no-splay", "--detailed-exitcodes", "--verbose", "--color", "0", + ]), + _apply_fixed=cmd_runner_fmt.as_fixed(["apply", "--detailed-exitcodes"]), + puppetmaster=cmd_runner_fmt.as_opt_val("--server"), + show_diff=cmd_runner_fmt.as_bool("--show-diff"), + confdir=cmd_runner_fmt.as_opt_val("--confdir"), + environment=cmd_runner_fmt.as_opt_val("--environment"), + tags=cmd_runner_fmt.as_func(lambda v: ["--tags", ",".join(v)]), + certname=cmd_runner_fmt.as_opt_eq_val("--certname"), + noop=cmd_runner_fmt.as_func(noop_func), + use_srv_records=cmd_runner_fmt.as_map({ + True: "--usr_srv_records", + False: "--no-usr_srv_records", + }), + logdest=cmd_runner_fmt.as_map(_logdest_map, default=[]), + modulepath=cmd_runner_fmt.as_opt_eq_val("--modulepath"), + _execute=cmd_runner_fmt.as_func(execute_func), + summarize=cmd_runner_fmt.as_bool("--summarize"), + debug=cmd_runner_fmt.as_bool("--debug"), + verbose=cmd_runner_fmt.as_bool("--verbose"), + ), + check_rc=False, + ) + return runner diff --git a/plugins/modules/puppet.py b/plugins/modules/puppet.py index c787a7f00c..8454bb60fd 100644 --- a/plugins/modules/puppet.py +++ b/plugins/modules/puppet.py @@ -152,15 +152,9 @@ import json import os import stat +import ansible_collections.community.general.plugins.module_utils.puppet as puppet_utils + from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.six.moves import shlex_quote - - -def _get_facter_dir(): - if os.getuid() == 0: - return '/etc/facter/facts.d' - else: - return os.path.expanduser('~/.facter/facts.d') def _write_structured_data(basedir, basename, data): @@ -212,16 +206,6 @@ def main(): ) p = module.params - global PUPPET_CMD - PUPPET_CMD = module.get_bin_path("puppet", False, ['/opt/puppetlabs/bin']) - - if not PUPPET_CMD: - module.fail_json( - msg="Could not find puppet. Please ensure it is installed.") - - global TIMEOUT_CMD - TIMEOUT_CMD = module.get_bin_path("timeout", False) - if p['manifest']: if not os.path.exists(p['manifest']): module.fail_json( @@ -230,90 +214,24 @@ def main(): # Check if puppet is disabled here if not p['manifest']: - rc, stdout, stderr = module.run_command( - PUPPET_CMD + " config print agent_disabled_lockfile") - if os.path.exists(stdout.strip()): - module.fail_json( - msg="Puppet agent is administratively disabled.", - disabled=True) - elif rc != 0: - module.fail_json( - msg="Puppet agent state could not be determined.") + puppet_utils.ensure_agent_enabled(module) if module.params['facts'] and not module.check_mode: _write_structured_data( - _get_facter_dir(), + puppet_utils.get_facter_dir(), module.params['facter_basename'], module.params['facts']) - if TIMEOUT_CMD: - base_cmd = "%(timeout_cmd)s -s 9 %(timeout)s %(puppet_cmd)s" % dict( - timeout_cmd=TIMEOUT_CMD, - timeout=shlex_quote(p['timeout']), - puppet_cmd=PUPPET_CMD) - else: - base_cmd = PUPPET_CMD + runner = puppet_utils.puppet_runner(module) if not p['manifest'] and not p['execute']: - cmd = ("%(base_cmd)s agent --onetime" - " --no-daemonize --no-usecacheonfailure --no-splay" - " --detailed-exitcodes --verbose --color 0") % dict(base_cmd=base_cmd) - if p['puppetmaster']: - cmd += " --server %s" % shlex_quote(p['puppetmaster']) - if p['show_diff']: - cmd += " --show_diff" - if p['confdir']: - cmd += " --confdir %s" % shlex_quote(p['confdir']) - if p['environment']: - cmd += " --environment '%s'" % p['environment'] - if p['tags']: - cmd += " --tags '%s'" % ','.join(p['tags']) - if p['certname']: - cmd += " --certname='%s'" % p['certname'] - if module.check_mode: - cmd += " --noop" - elif 'noop' in p: - if p['noop']: - cmd += " --noop" - else: - cmd += " --no-noop" - if p['use_srv_records'] is not None: - if not p['use_srv_records']: - cmd += " --no-use_srv_records" - else: - cmd += " --use_srv_records" + args_order = "_agent_fixed puppetmaster show_diff confdir environment tags certname noop use_srv_records" + with runner(args_order) as ctx: + rc, stdout, stderr = ctx.run() else: - cmd = "%s apply --detailed-exitcodes " % base_cmd - if p['logdest'] == 'syslog': - cmd += "--logdest syslog " - if p['logdest'] == 'all': - cmd += " --logdest syslog --logdest console" - if p['modulepath']: - cmd += "--modulepath='%s'" % p['modulepath'] - if p['environment']: - cmd += "--environment '%s' " % p['environment'] - if p['certname']: - cmd += " --certname='%s'" % p['certname'] - if p['tags']: - cmd += " --tags '%s'" % ','.join(p['tags']) - if module.check_mode: - cmd += "--noop " - elif 'noop' in p: - if p['noop']: - cmd += " --noop" - else: - cmd += " --no-noop" - if p['execute']: - cmd += " --execute '%s'" % p['execute'] - else: - cmd += " %s" % shlex_quote(p['manifest']) - if p['summarize']: - cmd += " --summarize" - if p['debug']: - cmd += " --debug" - if p['verbose']: - cmd += " --verbose" - rc, stdout, stderr = module.run_command(cmd) + args_order = "_apply_fixed logdest modulepath environment certname tags noop _execute summarize debug verbose" + with runner(args_order) as ctx: + rc, stdout, stderr = ctx.run(_execute=[p['execute'], p['manifest']]) if rc == 0: # success @@ -335,11 +253,11 @@ def main(): elif rc == 124: # timeout module.exit_json( - rc=rc, msg="%s timed out" % cmd, stdout=stdout, stderr=stderr) + rc=rc, msg="%s timed out" % ctx.cmd, stdout=stdout, stderr=stderr) else: # failure module.fail_json( - rc=rc, msg="%s failed with return code: %d" % (cmd, rc), + rc=rc, msg="%s failed with return code: %d" % (ctx.cmd, rc), stdout=stdout, stderr=stderr) diff --git a/tests/sanity/ignore-2.11.txt b/tests/sanity/ignore-2.11.txt index d12199993a..c79a17493f 100644 --- a/tests/sanity/ignore-2.11.txt +++ b/tests/sanity/ignore-2.11.txt @@ -18,8 +18,7 @@ plugins/modules/manageiq_provider.py validate-modules:undocumented-parameter plugins/modules/manageiq_tags.py validate-modules:parameter-state-invalid-choice plugins/modules/osx_defaults.py validate-modules:parameter-state-invalid-choice plugins/modules/parted.py validate-modules:parameter-state-invalid-choice -plugins/modules/puppet.py use-argspec-type-path -plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias - removed in 7.0.0 +plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias - removed in 7.0.0 plugins/modules/rax_files_objects.py use-argspec-type-path plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice plugins/modules/rax.py use-argspec-type-path # fix needed diff --git a/tests/sanity/ignore-2.12.txt b/tests/sanity/ignore-2.12.txt index d5dd72b549..d93315938c 100644 --- a/tests/sanity/ignore-2.12.txt +++ b/tests/sanity/ignore-2.12.txt @@ -13,8 +13,7 @@ plugins/modules/manageiq_provider.py validate-modules:undocumented-parameter plugins/modules/manageiq_tags.py validate-modules:parameter-state-invalid-choice plugins/modules/osx_defaults.py validate-modules:parameter-state-invalid-choice plugins/modules/parted.py validate-modules:parameter-state-invalid-choice -plugins/modules/puppet.py use-argspec-type-path -plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias - removed in 7.0.0 +plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias - removed in 7.0.0 plugins/modules/rax_files_objects.py use-argspec-type-path plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice plugins/modules/rax.py use-argspec-type-path # fix needed diff --git a/tests/sanity/ignore-2.13.txt b/tests/sanity/ignore-2.13.txt index d5dd72b549..d93315938c 100644 --- a/tests/sanity/ignore-2.13.txt +++ b/tests/sanity/ignore-2.13.txt @@ -13,8 +13,7 @@ plugins/modules/manageiq_provider.py validate-modules:undocumented-parameter plugins/modules/manageiq_tags.py validate-modules:parameter-state-invalid-choice plugins/modules/osx_defaults.py validate-modules:parameter-state-invalid-choice plugins/modules/parted.py validate-modules:parameter-state-invalid-choice -plugins/modules/puppet.py use-argspec-type-path -plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias - removed in 7.0.0 +plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias - removed in 7.0.0 plugins/modules/rax_files_objects.py use-argspec-type-path plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice plugins/modules/rax.py use-argspec-type-path # fix needed diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt index b54479472b..d4c0d0d948 100644 --- a/tests/sanity/ignore-2.14.txt +++ b/tests/sanity/ignore-2.14.txt @@ -14,8 +14,7 @@ plugins/modules/manageiq_provider.py validate-modules:undocumented-parameter plugins/modules/manageiq_tags.py validate-modules:parameter-state-invalid-choice plugins/modules/osx_defaults.py validate-modules:parameter-state-invalid-choice plugins/modules/parted.py validate-modules:parameter-state-invalid-choice -plugins/modules/puppet.py use-argspec-type-path -plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias - removed in 7.0.0 +plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias - removed in 7.0.0 plugins/modules/rax_files_objects.py use-argspec-type-path plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice plugins/modules/rax.py use-argspec-type-path # fix needed diff --git a/tests/sanity/ignore-2.15.txt b/tests/sanity/ignore-2.15.txt index b54479472b..d4c0d0d948 100644 --- a/tests/sanity/ignore-2.15.txt +++ b/tests/sanity/ignore-2.15.txt @@ -14,8 +14,7 @@ plugins/modules/manageiq_provider.py validate-modules:undocumented-parameter plugins/modules/manageiq_tags.py validate-modules:parameter-state-invalid-choice plugins/modules/osx_defaults.py validate-modules:parameter-state-invalid-choice plugins/modules/parted.py validate-modules:parameter-state-invalid-choice -plugins/modules/puppet.py use-argspec-type-path -plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias - removed in 7.0.0 +plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias - removed in 7.0.0 plugins/modules/rax_files_objects.py use-argspec-type-path plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice plugins/modules/rax.py use-argspec-type-path # fix needed diff --git a/tests/unit/plugins/modules/test_puppet.py b/tests/unit/plugins/modules/test_puppet.py new file mode 100644 index 0000000000..632385957e --- /dev/null +++ b/tests/unit/plugins/modules/test_puppet.py @@ -0,0 +1,145 @@ +# -*- coding: utf-8 -*- +# Author: Alexei Znamensky (russoz@gmail.com) +# Largely adapted from test_redhat_subscription by +# Jiri Hnidek (jhnidek@redhat.com) +# +# Copyright (c) Alexei Znamensky (russoz@gmail.com) +# Copyright (c) Jiri Hnidek (jhnidek@redhat.com) +# +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import json + +from ansible_collections.community.general.plugins.modules import puppet + +import pytest + +TESTED_MODULE = puppet.__name__ + + +@pytest.fixture +def patch_get_bin_path(mocker): + """ + Function used for mocking AnsibleModule.get_bin_path + """ + def mockie(self, path, *args, **kwargs): + return "/testbin/{0}".format(path) + mocker.patch("ansible.module_utils.basic.AnsibleModule.get_bin_path", mockie) + + +TEST_CASES = [ + [ + {}, + { + "id": "puppet_agent_plain", + "run_command.calls": [ + ( + ["/testbin/puppet", "config", "print", "agent_disabled_lockfile"], + {"environ_update": {"LANGUAGE": "C", "LC_ALL": "C"}, "check_rc": False}, + (0, "blah, anything", "",), # output rc, out, err + ), + ( + [ + "/testbin/timeout", "-s", "9", "30m", "/testbin/puppet", "agent", "--onetime", "--no-daemonize", + "--no-usecacheonfailure", "--no-splay", "--detailed-exitcodes", "--verbose", "--color", "0" + ], + {"environ_update": {"LANGUAGE": "C", "LC_ALL": "C"}, "check_rc": False}, + (0, "", "",), # output rc, out, err + ), + ], + "changed": False, + } + ], + [ + { + "certname": "potatobox" + }, + { + "id": "puppet_agent_certname", + "run_command.calls": [ + ( + ["/testbin/puppet", "config", "print", "agent_disabled_lockfile"], + {"environ_update": {"LANGUAGE": "C", "LC_ALL": "C"}, "check_rc": False}, + (0, "blah, anything", "",), # output rc, out, err + ), + ( + [ + "/testbin/timeout", "-s", "9", "30m", "/testbin/puppet", "agent", "--onetime", "--no-daemonize", + "--no-usecacheonfailure", "--no-splay", "--detailed-exitcodes", "--verbose", "--color", "0", "--certname=potatobox" + ], + {"environ_update": {"LANGUAGE": "C", "LC_ALL": "C"}, "check_rc": False}, + (0, "", "",), # output rc, out, err + ), + ], + "changed": False, + } + ], + [ + { + "tags": ["a", "b", "c"] + }, + { + "id": "puppet_agent_tags_abc", + "run_command.calls": [ + ( + ["/testbin/puppet", "config", "print", "agent_disabled_lockfile"], + {"environ_update": {"LANGUAGE": "C", "LC_ALL": "C"}, "check_rc": False}, + (0, "blah, anything", "",), # output rc, out, err + ), + ( + [ + "/testbin/timeout", "-s", "9", "30m", "/testbin/puppet", "agent", "--onetime", "--no-daemonize", + "--no-usecacheonfailure", "--no-splay", "--detailed-exitcodes", "--verbose", "--color", "0", "--tags", "a,b,c" + ], + {"environ_update": {"LANGUAGE": "C", "LC_ALL": "C"}, "check_rc": False}, + (0, "", "",), # output rc, out, err + ), + ], + "changed": False, + } + ], +] +TEST_CASES_IDS = [item[1]["id"] for item in TEST_CASES] + + +@pytest.mark.parametrize("patch_ansible_module, testcase", + TEST_CASES, + ids=TEST_CASES_IDS, + indirect=["patch_ansible_module"]) +@pytest.mark.usefixtures("patch_ansible_module") +def test_puppet(mocker, capfd, patch_get_bin_path, testcase): + """ + Run unit tests for test cases listen in TEST_CASES + """ + + # Mock function used for running commands first + call_results = [item[2] for item in testcase["run_command.calls"]] + mock_run_command = mocker.patch( + "ansible.module_utils.basic.AnsibleModule.run_command", + side_effect=call_results) + + # Try to run test case + with pytest.raises(SystemExit): + puppet.main() + + out, err = capfd.readouterr() + results = json.loads(out) + print("results =\n%s" % results) + + assert mock_run_command.call_count == len(testcase["run_command.calls"]) + if mock_run_command.call_count: + call_args_list = [(item[0][0], item[1]) for item in mock_run_command.call_args_list] + expected_call_args_list = [(item[0], item[1]) for item in testcase["run_command.calls"]] + print("call args list =\n%s" % call_args_list) + print("expected args list =\n%s" % expected_call_args_list) + assert call_args_list == expected_call_args_list + + assert results.get("changed", False) == testcase["changed"] + if "failed" in testcase: + assert results.get("failed", False) == testcase["failed"] + if "msg" in testcase: + assert results.get("msg", "") == testcase["msg"] From af53271c41f14c39696b1ac3f65b3163407ab18b Mon Sep 17 00:00:00 2001 From: Alexander Couzens Date: Sat, 17 Dec 2022 12:10:23 +0100 Subject: [PATCH 0083/1810] lxc_container: fix lxc argument when executing lxc command (#5659) lxc_container fails when executing the lxc command (e.g. when creating a new container) because PR#5358 broke the module argument parsing. The resulting argument dict contained only the module argument name and the argument flag but not the value. E.g. ``` - lxc_container: template: debian ``` would result in lxc command arguments `lxc template --template` instead of `lxc --template debian`. Fixes: 6f88426cf1dc ("lxc_container: minor refactor (#5358)") Fixes #5578 Signed-off-by: Alexander Couzens Signed-off-by: Alexander Couzens --- changelogs/fragments/5659-fix-lxc_container-command.yml | 2 ++ plugins/modules/lxc_container.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/5659-fix-lxc_container-command.yml diff --git a/changelogs/fragments/5659-fix-lxc_container-command.yml b/changelogs/fragments/5659-fix-lxc_container-command.yml new file mode 100644 index 0000000000..450d889808 --- /dev/null +++ b/changelogs/fragments/5659-fix-lxc_container-command.yml @@ -0,0 +1,2 @@ +bugfixes: + - lxc_container - fix the arguments of the lxc command which broke the creation and cloning of containers (https://github.com/ansible-collections/community.general/issues/5578). diff --git a/plugins/modules/lxc_container.py b/plugins/modules/lxc_container.py index 7871f13972..9fe27b8d81 100644 --- a/plugins/modules/lxc_container.py +++ b/plugins/modules/lxc_container.py @@ -677,7 +677,7 @@ class LxcContainerManagement(object): false_values = BOOLEANS_FALSE.union([None, '']) result = dict( - (k, v) + (v, self.module.params[k]) for k, v in variables.items() if self.module.params[k] not in false_values ) From 25be366cc3dfa99bdc9bb914cece4614c2256d08 Mon Sep 17 00:00:00 2001 From: Or Bin Date: Sun, 18 Dec 2022 00:31:06 +0200 Subject: [PATCH 0084/1810] Fixed `github_release` docs: only module-specific returned key is `tag` (#5699) * Fixed github_release docs: only module-specific returned key is "tag" * Update plugins/modules/github_release.py - added a dot Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein --- plugins/modules/github_release.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/plugins/modules/github_release.py b/plugins/modules/github_release.py index 84ce4ce4ec..0b3a5a886c 100644 --- a/plugins/modules/github_release.py +++ b/plugins/modules/github_release.py @@ -108,17 +108,8 @@ EXAMPLES = ''' ''' RETURN = ''' -create_release: - description: - - Version of the created release - - "For Ansible version 2.5 and later, if specified release version already exists, then State is unchanged" - - "For Ansible versions prior to 2.5, if specified release version already exists, then State is skipped" - type: str - returned: success - sample: 1.1.0 - -latest_release: - description: Version of the latest release +tag: + description: Version of the created/latest release. type: str returned: success sample: 1.1.0 From fab73a1d1e168fc04a5723d45bb3251149d9d856 Mon Sep 17 00:00:00 2001 From: castorsky Date: Tue, 20 Dec 2022 03:22:23 +0800 Subject: [PATCH 0085/1810] Bugfix: Remove redundant VMID parameters (#5672) * Remove redundant parameters VMID * Add changelog fragment --- changelogs/fragments/5672-proxmox.yml | 3 +++ plugins/modules/proxmox_disk.py | 4 ++-- plugins/modules/proxmox_nic.py | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/5672-proxmox.yml diff --git a/changelogs/fragments/5672-proxmox.yml b/changelogs/fragments/5672-proxmox.yml new file mode 100644 index 0000000000..4fafe53d14 --- /dev/null +++ b/changelogs/fragments/5672-proxmox.yml @@ -0,0 +1,3 @@ +bugfixes: + - "proxmox_disk - fixed possible issues with redundant ``vmid`` parameter (https://github.com/ansible-collections/community.general/issues/5492, https://github.com/ansible-collections/community.general/pull/5672)." + - "proxmox_nic - fixed possible issues with redundant ``vmid`` parameter (https://github.com/ansible-collections/community.general/issues/5492, https://github.com/ansible-collections/community.general/pull/5672)." diff --git a/plugins/modules/proxmox_disk.py b/plugins/modules/proxmox_disk.py index 8f55e2d130..8a81f18a3f 100644 --- a/plugins/modules/proxmox_disk.py +++ b/plugins/modules/proxmox_disk.py @@ -699,7 +699,7 @@ def main(): module.exit_json(changed=False, vmid=vmid, msg='Disk %s already detached in VM %s' % (disk, vmid)) if disk not in vm_config: module.exit_json(changed=False, vmid=vmid, msg="Disk %s not present in VM %s config" % (disk, vmid)) - proxmox.proxmox_api.nodes(vm['node']).qemu(vmid).unlink.put(vmid=vmid, idlist=disk, force=0) + proxmox.proxmox_api.nodes(vm['node']).qemu(vmid).unlink.put(idlist=disk, force=0) module.exit_json(changed=True, vmid=vmid, msg="Disk %s detached from VM %s" % (disk, vmid)) except Exception as e: module.fail_json(msg="Failed to detach disk %s from VM %s with exception: %s" % (disk, vmid, str(e))) @@ -734,7 +734,7 @@ def main(): try: if disk not in vm_config: module.exit_json(changed=False, vmid=vmid, msg="Disk %s is already absent in VM %s" % (disk, vmid)) - proxmox.proxmox_api.nodes(vm['node']).qemu(vmid).unlink.put(vmid=vmid, idlist=disk, force=1) + proxmox.proxmox_api.nodes(vm['node']).qemu(vmid).unlink.put(idlist=disk, force=1) module.exit_json(changed=True, vmid=vmid, msg="Disk %s removed from VM %s" % (disk, vmid)) except Exception as e: module.fail_json(vmid=vmid, msg='Unable to remove disk %s from VM %s: %s' % (disk, vmid, str(e))) diff --git a/plugins/modules/proxmox_nic.py b/plugins/modules/proxmox_nic.py index bcc56de57e..5c8c3f47df 100644 --- a/plugins/modules/proxmox_nic.py +++ b/plugins/modules/proxmox_nic.py @@ -223,7 +223,7 @@ class ProxmoxNicAnsible(ProxmoxAnsible): if interface in vminfo: if not self.module.check_mode: - self.proxmox_api.nodes(vm['node']).qemu(vmid).config.set(vmid=vmid, delete=interface) + self.proxmox_api.nodes(vm['node']).qemu(vmid).config.set(delete=interface) return True return False From 2b39470a774c28e26780e4e2e4cc9b998471da3c Mon Sep 17 00:00:00 2001 From: joergho <48011876+joergho@users.noreply.github.com> Date: Mon, 19 Dec 2022 20:23:44 +0100 Subject: [PATCH 0086/1810] opkg: fix issue that force=reinstall would not reinstall an existing package (#5705) * opkg: fix issue that force=reinstall would not reinstall an existing package Signed-off-by: Joerg Hofrichter * changelog fragment Signed-off-by: Joerg Hofrichter --- changelogs/fragments/5705-opkg-fix-force-reinstall.yml | 2 ++ plugins/modules/opkg.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/5705-opkg-fix-force-reinstall.yml diff --git a/changelogs/fragments/5705-opkg-fix-force-reinstall.yml b/changelogs/fragments/5705-opkg-fix-force-reinstall.yml new file mode 100644 index 0000000000..27a188ab9e --- /dev/null +++ b/changelogs/fragments/5705-opkg-fix-force-reinstall.yml @@ -0,0 +1,2 @@ +bugfixes: + - opkg - fix issue that ``force=reinstall`` would not reinstall an existing package (https://github.com/ansible-collections/community.general/pull/5705). diff --git a/plugins/modules/opkg.py b/plugins/modules/opkg.py index 60d2adc958..6c5e23093e 100644 --- a/plugins/modules/opkg.py +++ b/plugins/modules/opkg.py @@ -154,7 +154,7 @@ def install_packages(module, opkg_path, packages): install_c = 0 for package in packages: - if query_package(module, opkg_path, package): + if query_package(module, opkg_path, package) and (force != '--force-reinstall'): continue rc, out, err = module.run_command("%s install %s %s" % (opkg_path, force, package)) From 77fde030cdb89c1c5532974fb2d827dc1156a097 Mon Sep 17 00:00:00 2001 From: Laurence Date: Tue, 20 Dec 2022 11:49:11 +0000 Subject: [PATCH 0087/1810] Add support for host restriction in sudoers module (#5703) * Add support to restrict privileges by host * Missing comma * Making linter happy. * Add version 6.2.0 as when sudoers host parameter added Co-authored-by: Felix Fontein * Changelog fragment for PR #5703 * Test for sudoers host-based restriction Co-authored-by: Felix Fontein --- .../fragments/5703-sudoers-host-support.yml | 2 ++ plugins/modules/sudoers.py | 22 +++++++++++++++++-- .../targets/sudoers/tasks/main.yml | 14 ++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/5703-sudoers-host-support.yml diff --git a/changelogs/fragments/5703-sudoers-host-support.yml b/changelogs/fragments/5703-sudoers-host-support.yml new file mode 100644 index 0000000000..1aaa30d8d9 --- /dev/null +++ b/changelogs/fragments/5703-sudoers-host-support.yml @@ -0,0 +1,2 @@ +minor_changes: + - sudoers - adds ``host`` parameter for setting hostname restrictions in sudoers rules (https://github.com/ansible-collections/community.general/issues/5702). diff --git a/plugins/modules/sudoers.py b/plugins/modules/sudoers.py index 2c0aa879bc..f2bcb20b75 100644 --- a/plugins/modules/sudoers.py +++ b/plugins/modules/sudoers.py @@ -43,6 +43,12 @@ options: - Whether a password will be required to run the sudo'd command. default: true type: bool + host: + description: + - Specify the host the rule is for. + default: ALL + type: str + version_added: 6.2.0 runas: description: - Specify the target user the command(s) will run as. @@ -95,10 +101,11 @@ EXAMPLES = ''' - name: >- Allow the monitoring group to run sudo /usr/local/bin/gather-app-metrics - without requiring a password + without requiring a password on the host called webserver community.general.sudoers: name: monitor-app group: monitoring + host: webserver commands: /usr/local/bin/gather-app-metrics - name: >- @@ -136,6 +143,7 @@ class Sudoers(object): self.group = module.params['group'] self.state = module.params['state'] self.nopassword = module.params['nopassword'] + self.host = module.params['host'] self.runas = module.params['runas'] self.sudoers_path = module.params['sudoers_path'] self.file = os.path.join(self.sudoers_path, self.name) @@ -178,7 +186,13 @@ class Sudoers(object): commands_str = ', '.join(self.commands) nopasswd_str = 'NOPASSWD:' if self.nopassword else '' runas_str = '({runas})'.format(runas=self.runas) if self.runas is not None else '' - return "{owner} ALL={runas}{nopasswd} {commands}\n".format(owner=owner, runas=runas_str, nopasswd=nopasswd_str, commands=commands_str) + return "{owner} {host}={runas}{nopasswd} {commands}\n".format( + owner=owner, + host=self.host, + runas=runas_str, + nopasswd=nopasswd_str, + commands=commands_str + ) def validate(self): if self.validation == 'absent': @@ -225,6 +239,10 @@ def main(): 'type': 'bool', 'default': True, }, + 'host': { + 'type': 'str', + 'default': 'ALL', + }, 'runas': { 'type': 'str', 'default': None, diff --git a/tests/integration/targets/sudoers/tasks/main.yml b/tests/integration/targets/sudoers/tasks/main.yml index 682bd7efff..a44307ad9e 100644 --- a/tests/integration/targets/sudoers/tasks/main.yml +++ b/tests/integration/targets/sudoers/tasks/main.yml @@ -131,6 +131,19 @@ src: "{{ sudoers_path }}/my-sudo-rule-6" register: rule_6_contents +- name: Create rule to allow user to sudo just on host-1 + community.general.sudoers: + name: my-sudo-rule-7 + state: present + user: alice + host: host-1 + commands: /usr/local/bin/command + register: rule_7 + +- name: Grab contents of my-sudo-rule-7 + ansible.builtin.slurp: + src: "{{ sudoers_path }}/my-sudo-rule-7" + register: rule_7_contents - name: Revoke rule 1 community.general.sudoers: @@ -229,6 +242,7 @@ - "rule_4_contents['content'] | b64decode == '%students ALL=NOPASSWD: /usr/local/bin/command\n'" - "rule_5_contents['content'] | b64decode == 'alice ALL=NOPASSWD: /usr/local/bin/command\n'" - "rule_6_contents['content'] | b64decode == 'alice ALL=(bob)NOPASSWD: /usr/local/bin/command\n'" + - "rule_7_contents['content'] | b64decode == 'alice host-1=NOPASSWD: /usr/local/bin/command\n'" - name: Check revocation stat ansible.builtin.assert: From 1f492414816f5455de27afe659f22272a0829514 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Wed, 21 Dec 2022 07:31:46 +0100 Subject: [PATCH 0088/1810] CI: add extra VMs for certain tests (#5713) * Remove superfluous VM. * Add extra VM group. * More platforms, add scripts. * [REVERT THIS] Shrink matrix to only the tests we are interested in. * Fix some tests. * Skip snap tests on Ubuntu VMs for now. * Skip xfs_quota tests on Alpine VMs due to ansible.posix.mount failing. * Revert "[REVERT THIS] Shrink matrix to only the tests we are interested in." This reverts commit 2e98e163db643f5b06290d2f1fa99fe14ca4eebd. * Stick to Alpine and Ubuntu 22.04 for now. --- .azure-pipelines/azure-pipelines.yml | 25 ++++++++++++++++--- tests/integration/targets/filesize/aliases | 1 + tests/integration/targets/filesystem/aliases | 1 + .../filesystem/tasks/create_device.yml | 8 ++++-- .../targets/iptables_state/aliases | 1 + .../iptables_state/tasks/tests/01-tables.yml | 11 +------- tests/integration/targets/lvg/aliases | 1 + tests/integration/targets/lvg/tasks/setup.yml | 19 ++++++++++---- .../targets/lvg/tasks/teardown.yml | 13 +++++----- .../targets/lvg/tasks/test_grow_reduce.yml | 16 ++++++------ .../targets/lvg/tasks/test_indempotency.yml | 4 +-- .../targets/lvg/tasks/test_pvresize.yml | 10 ++++---- tests/integration/targets/snap/aliases | 4 +++ tests/integration/targets/snap_alias/aliases | 4 +++ tests/integration/targets/ufw/aliases | 1 + tests/integration/targets/xattr/aliases | 1 + tests/integration/targets/xfs_quota/aliases | 2 ++ tests/utils/shippable/alpine.sh | 1 + tests/utils/shippable/fedora.sh | 1 + tests/utils/shippable/ubuntu.sh | 1 + 20 files changed, 83 insertions(+), 42 deletions(-) create mode 120000 tests/utils/shippable/alpine.sh create mode 120000 tests/utils/shippable/fedora.sh create mode 120000 tests/utils/shippable/ubuntu.sh diff --git a/.azure-pipelines/azure-pipelines.yml b/.azure-pipelines/azure-pipelines.yml index a5dcafa422..c8e03a164b 100644 --- a/.azure-pipelines/azure-pipelines.yml +++ b/.azure-pipelines/azure-pipelines.yml @@ -189,6 +189,24 @@ stages: - test: 3.5 ## Remote + - stage: Remote_devel_extra_vms + displayName: Remote devel extra VMs + dependsOn: [] + jobs: + - template: templates/matrix.yml + parameters: + testFormat: devel/{0} + targets: + - name: Alpine 3.16 + test: alpine/3.16 + # - name: Fedora 36 + # test: fedora/36 + # - name: Ubuntu 20.04 + # test: ubuntu/20.04 + - name: Ubuntu 22.04 + test: ubuntu/22.04 + groups: + - vm - stage: Remote_devel displayName: Remote devel dependsOn: [] @@ -203,8 +221,6 @@ stages: test: rhel/7.9 - name: RHEL 9.0 test: rhel/9.0 - - name: FreeBSD 12.3 - test: freebsd/12.3 - name: FreeBSD 13.1 test: freebsd/13.1 groups: @@ -221,8 +237,8 @@ stages: targets: - name: RHEL 9.0 test: rhel/9.0 - - name: FreeBSD 13.1 - test: freebsd/13.1 + - name: FreeBSD 12.3 + test: freebsd/12.3 groups: - 1 - 2 @@ -459,6 +475,7 @@ stages: - Units_2_12 - Units_2_13 - Units_2_14 + - Remote_devel_extra_vms - Remote_devel - Remote_2_11 - Remote_2_12 diff --git a/tests/integration/targets/filesize/aliases b/tests/integration/targets/filesize/aliases index afda346c4e..7642e70daf 100644 --- a/tests/integration/targets/filesize/aliases +++ b/tests/integration/targets/filesize/aliases @@ -3,3 +3,4 @@ # SPDX-License-Identifier: GPL-3.0-or-later azp/posix/1 +azp/posix/vm diff --git a/tests/integration/targets/filesystem/aliases b/tests/integration/targets/filesystem/aliases index 007bed5386..a666f7a142 100644 --- a/tests/integration/targets/filesystem/aliases +++ b/tests/integration/targets/filesystem/aliases @@ -3,6 +3,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later azp/posix/1 +azp/posix/vm destructive skip/aix skip/osx diff --git a/tests/integration/targets/filesystem/tasks/create_device.yml b/tests/integration/targets/filesystem/tasks/create_device.yml index 5229e19f25..8966ec2e61 100644 --- a/tests/integration/targets/filesystem/tasks/create_device.yml +++ b/tests/integration/targets/filesystem/tasks/create_device.yml @@ -14,10 +14,14 @@ block: - when: fstype == 'lvm' block: + - name: 'Show next free loop device' + ansible.builtin.command: + cmd: 'losetup -f' + register: loop_device_cmd + - name: 'Create a loop device for LVM' ansible.builtin.command: - cmd: 'losetup --show -f {{ dev }}' - register: loop_device_cmd + cmd: 'losetup -f {{ dev }}' - name: 'Switch to loop device target for further tasks' ansible.builtin.set_fact: diff --git a/tests/integration/targets/iptables_state/aliases b/tests/integration/targets/iptables_state/aliases index 80f7c7e32f..5a02a630bc 100644 --- a/tests/integration/targets/iptables_state/aliases +++ b/tests/integration/targets/iptables_state/aliases @@ -3,6 +3,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later azp/posix/1 +azp/posix/vm destructive skip/docker # kernel modules not loadable skip/freebsd # no iptables/netfilter (Linux specific) diff --git a/tests/integration/targets/iptables_state/tasks/tests/01-tables.yml b/tests/integration/targets/iptables_state/tasks/tests/01-tables.yml index 2f00e175b4..929928c8e7 100644 --- a/tests/integration/targets/iptables_state/tasks/tests/01-tables.yml +++ b/tests/integration/targets/iptables_state/tasks/tests/01-tables.yml @@ -167,13 +167,12 @@ -- name: "get security, raw and mangle tables states" +- name: "get raw and mangle tables states" iptables_state: path: "{{ iptables_saved }}" state: saved table: "{{ item }}" loop: - - security - raw - mangle changed_when: false @@ -198,8 +197,6 @@ - "'*nat' in iptables_state.saved" - "'raw' in iptables_state.tables" - "'*raw' in iptables_state.saved" - - "'security' in iptables_state.tables" - - "'*security' in iptables_state.saved" quiet: yes @@ -233,17 +230,14 @@ - "'*mangle' in iptables_state.initial_state" - "'*nat' in iptables_state.initial_state" - "'*raw' in iptables_state.initial_state" - - "'*security' in iptables_state.initial_state" - "'filter' in iptables_state.tables" - "'mangle' not in iptables_state.tables" - "'nat' not in iptables_state.tables" - "'raw' not in iptables_state.tables" - - "'security' not in iptables_state.tables" - "'*filter' in iptables_state.restored" - "'*mangle' not in iptables_state.restored" - "'*nat' not in iptables_state.restored" - "'*raw' not in iptables_state.restored" - - "'*security' not in iptables_state.restored" - iptables_state is not changed quiet: yes @@ -264,17 +258,14 @@ - "'*mangle' in iptables_state.initial_state" - "'*nat' in iptables_state.initial_state" - "'*raw' in iptables_state.initial_state" - - "'*security' in iptables_state.initial_state" - "'filter' in iptables_state.tables" - "'mangle' in iptables_state.tables" - "'nat' in iptables_state.tables" - "'raw' in iptables_state.tables" - - "'security' in iptables_state.tables" - "'*filter' in iptables_state.restored" - "'*mangle' in iptables_state.restored" - "'*nat' in iptables_state.restored" - "'*raw' in iptables_state.restored" - - "'*security' in iptables_state.restored" - iptables_state is not changed quiet: yes diff --git a/tests/integration/targets/lvg/aliases b/tests/integration/targets/lvg/aliases index f4617b3377..3b92ba75c4 100644 --- a/tests/integration/targets/lvg/aliases +++ b/tests/integration/targets/lvg/aliases @@ -3,6 +3,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later azp/posix/1 +azp/posix/vm destructive needs/privileged skip/aix diff --git a/tests/integration/targets/lvg/tasks/setup.yml b/tests/integration/targets/lvg/tasks/setup.yml index 92785e6d3d..3984b9fc3a 100644 --- a/tests/integration/targets/lvg/tasks/setup.yml +++ b/tests/integration/targets/lvg/tasks/setup.yml @@ -7,12 +7,21 @@ command: "dd if=/dev/zero of={{ remote_tmp_dir }}/img{{ item }} bs=1M count=10" with_sequence: 'count=2' +- name: "Show next free loop device" + command: "losetup -f" + register: loop_device1 + - name: "Create loop device for file" - command: "losetup --show -f {{ remote_tmp_dir }}/img{{ item }}" - with_sequence: 'count=2' - register: loop_devices + command: "losetup -f {{ remote_tmp_dir }}/img1" + +- name: "Show next free loop device" + command: "losetup -f" + register: loop_device2 + +- name: "Create loop device for file" + command: "losetup -f {{ remote_tmp_dir }}/img2" - name: "Affect name on disk to work on" set_fact: - loop_device1: "{{ loop_devices.results[0] }}" - loop_device2: "{{ loop_devices.results[1] }}" + loop_device1: "{{ loop_device1.stdout }}" + loop_device2: "{{ loop_device2.stdout }}" diff --git a/tests/integration/targets/lvg/tasks/teardown.yml b/tests/integration/targets/lvg/tasks/teardown.yml index 027c1257fe..de49573214 100644 --- a/tests/integration/targets/lvg/tasks/teardown.yml +++ b/tests/integration/targets/lvg/tasks/teardown.yml @@ -8,15 +8,16 @@ vg: testvg state: absent -- name: Detach loop device - command: "losetup -d {{ item.stdout }}" - loop: "{{ loop_devices.results|default([]) }}" +- name: Detach loop devices + command: "losetup -d {{ item }}" + loop: + - "{{ loop_device1 | default('') }}" + - "{{ loop_device2 | default('') }}" when: - - item.stdout is defined - - item.stdout is match("/dev/.*") + - item != '' - name: Remove device files file: path: "{{ remote_tmp_dir }}/img{{ item }}" state: absent - with_sequence: 'count={{ loop_devices.results|length }}' + with_sequence: 'count=2' diff --git a/tests/integration/targets/lvg/tasks/test_grow_reduce.yml b/tests/integration/targets/lvg/tasks/test_grow_reduce.yml index 5974a88aaf..857df92464 100644 --- a/tests/integration/targets/lvg/tasks/test_grow_reduce.yml +++ b/tests/integration/targets/lvg/tasks/test_grow_reduce.yml @@ -6,7 +6,7 @@ - name: "Create volume group on first disk" lvg: vg: testvg - pvs: "{{ loop_device1.stdout }}" + pvs: "{{ loop_device1 }}" - name: "get lvm facts" setup: @@ -16,14 +16,14 @@ - name: "Assert the testvg span only on first disk" assert: that: - - ansible_lvm.pvs[loop_device1.stdout].vg == "testvg" - - 'loop_device2.stdout not in ansible_lvm.pvs or - ansible_lvm.pvs[loop_device2.stdout].vg == ""' + - ansible_lvm.pvs[loop_device1].vg == "testvg" + - 'loop_device2 not in ansible_lvm.pvs or + ansible_lvm.pvs[loop_device2].vg == ""' - name: "Extend to second disk AND reduce from the first disk" lvg: vg: testvg - pvs: "{{ loop_device2.stdout }}" + pvs: "{{ loop_device2 }}" - name: "get lvm facts" setup: @@ -33,6 +33,6 @@ - name: "Assert the testvg span only on first disk" assert: that: - - 'loop_device1.stdout not in ansible_lvm.pvs or - ansible_lvm.pvs[loop_device1.stdout].vg == ""' - - ansible_lvm.pvs[loop_device2.stdout].vg == "testvg" + - 'loop_device1 not in ansible_lvm.pvs or + ansible_lvm.pvs[loop_device1].vg == ""' + - ansible_lvm.pvs[loop_device2].vg == "testvg" diff --git a/tests/integration/targets/lvg/tasks/test_indempotency.yml b/tests/integration/targets/lvg/tasks/test_indempotency.yml index abaa262881..758912484c 100644 --- a/tests/integration/targets/lvg/tasks/test_indempotency.yml +++ b/tests/integration/targets/lvg/tasks/test_indempotency.yml @@ -6,12 +6,12 @@ - name: Create volume group on disk device lvg: vg: testvg - pvs: "{{ loop_device1.stdout }}" + pvs: "{{ loop_device1 }}" - name: Create the volume group again to verify idempotence lvg: vg: testvg - pvs: "{{ loop_device1.stdout }}" + pvs: "{{ loop_device1 }}" register: repeat_vg_create - name: Do all assertions to verify expected results diff --git a/tests/integration/targets/lvg/tasks/test_pvresize.yml b/tests/integration/targets/lvg/tasks/test_pvresize.yml index c8a2c8edb5..eef9503040 100644 --- a/tests/integration/targets/lvg/tasks/test_pvresize.yml +++ b/tests/integration/targets/lvg/tasks/test_pvresize.yml @@ -6,7 +6,7 @@ - name: "Create volume group on first disk" lvg: vg: testvg - pvs: "{{ loop_device1.stdout }}" + pvs: "{{ loop_device1 }}" - name: Gets current vg size shell: vgs -v testvg -o pv_size --noheading --units b | xargs @@ -21,12 +21,12 @@ command: "dd if=/dev/zero bs=8MiB count=1 of={{ remote_tmp_dir }}/img1 conv=notrunc oflag=append" - name: "Reread size of file associated with loop_device1" - command: "losetup -c {{ loop_device1.stdout }}" + command: "losetup -c {{ loop_device1 }}" - name: "Reruns lvg with pvresize:no" lvg: vg: testvg - pvs: "{{ loop_device1.stdout }}" + pvs: "{{ loop_device1 }}" pvresize: no register: cmd_result @@ -46,7 +46,7 @@ - name: "Reruns lvg with pvresize:yes and check_mode:yes" lvg: vg: testvg - pvs: "{{ loop_device1.stdout }}" + pvs: "{{ loop_device1 }}" pvresize: yes check_mode: yes register: cmd_result @@ -68,7 +68,7 @@ - name: "Reruns lvg with pvresize:yes" lvg: vg: testvg - pvs: "{{ loop_device1.stdout }}" + pvs: "{{ loop_device1 }}" pvresize: yes - name: Gets current vg size diff --git a/tests/integration/targets/snap/aliases b/tests/integration/targets/snap/aliases index dcb4aa199e..a50e25cc5c 100644 --- a/tests/integration/targets/snap/aliases +++ b/tests/integration/targets/snap/aliases @@ -3,8 +3,12 @@ # SPDX-License-Identifier: GPL-3.0-or-later azp/posix/1 +azp/posix/vm skip/aix +skip/alpine +skip/fedora skip/freebsd skip/osx skip/macos skip/docker +skip/ubuntu # FIXME! diff --git a/tests/integration/targets/snap_alias/aliases b/tests/integration/targets/snap_alias/aliases index dcb4aa199e..a50e25cc5c 100644 --- a/tests/integration/targets/snap_alias/aliases +++ b/tests/integration/targets/snap_alias/aliases @@ -3,8 +3,12 @@ # SPDX-License-Identifier: GPL-3.0-or-later azp/posix/1 +azp/posix/vm skip/aix +skip/alpine +skip/fedora skip/freebsd skip/osx skip/macos skip/docker +skip/ubuntu # FIXME! diff --git a/tests/integration/targets/ufw/aliases b/tests/integration/targets/ufw/aliases index fa4f2a6cd3..1f974ecd19 100644 --- a/tests/integration/targets/ufw/aliases +++ b/tests/integration/targets/ufw/aliases @@ -3,6 +3,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later azp/posix/2 +azp/posix/vm skip/aix skip/osx skip/macos diff --git a/tests/integration/targets/xattr/aliases b/tests/integration/targets/xattr/aliases index db3751be49..5cd9c012e1 100644 --- a/tests/integration/targets/xattr/aliases +++ b/tests/integration/targets/xattr/aliases @@ -3,6 +3,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later azp/posix/2 +azp/posix/vm skip/aix skip/docker skip/freebsd diff --git a/tests/integration/targets/xfs_quota/aliases b/tests/integration/targets/xfs_quota/aliases index 56dffecaa4..dd4714509e 100644 --- a/tests/integration/targets/xfs_quota/aliases +++ b/tests/integration/targets/xfs_quota/aliases @@ -3,9 +3,11 @@ # SPDX-License-Identifier: GPL-3.0-or-later azp/posix/1 +azp/posix/vm needs/privileged needs/root skip/aix +skip/alpine # FIXME skip/osx skip/macos skip/freebsd diff --git a/tests/utils/shippable/alpine.sh b/tests/utils/shippable/alpine.sh new file mode 120000 index 0000000000..6ddb776854 --- /dev/null +++ b/tests/utils/shippable/alpine.sh @@ -0,0 +1 @@ +remote.sh \ No newline at end of file diff --git a/tests/utils/shippable/fedora.sh b/tests/utils/shippable/fedora.sh new file mode 120000 index 0000000000..6ddb776854 --- /dev/null +++ b/tests/utils/shippable/fedora.sh @@ -0,0 +1 @@ +remote.sh \ No newline at end of file diff --git a/tests/utils/shippable/ubuntu.sh b/tests/utils/shippable/ubuntu.sh new file mode 120000 index 0000000000..6ddb776854 --- /dev/null +++ b/tests/utils/shippable/ubuntu.sh @@ -0,0 +1 @@ +remote.sh \ No newline at end of file From 488e828f9b7dcf2867edec72ce35f766d7b54ff0 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Thu, 22 Dec 2022 18:45:07 +1300 Subject: [PATCH 0089/1810] ansible_galaxy_install: use locale C tentatively, else en_US (#5680) * ansible_galaxy_install: use locale C tentatively, else en_US * use custom exception to signal unsupported locale * add step to remove artefacts at the end of the test * add step to remove artefacts at the beginning of the test * comment out context controller * trying with temporary dir as destination * remove collection before test with reqs file * ensure collections are installed in temp dir in tests + check_force * simplified the change * added extra condition for failing locale * improved exception handling * add changelog fragment --- ...5680-ansible_galaxy_install-fx-locale.yaml | 3 ++ plugins/modules/ansible_galaxy_install.py | 35 ++++++++++++++----- .../ansible_galaxy_install/tasks/main.yml | 6 ++-- 3 files changed, 32 insertions(+), 12 deletions(-) create mode 100644 changelogs/fragments/5680-ansible_galaxy_install-fx-locale.yaml diff --git a/changelogs/fragments/5680-ansible_galaxy_install-fx-locale.yaml b/changelogs/fragments/5680-ansible_galaxy_install-fx-locale.yaml new file mode 100644 index 0000000000..35fd88bc25 --- /dev/null +++ b/changelogs/fragments/5680-ansible_galaxy_install-fx-locale.yaml @@ -0,0 +1,3 @@ +bugfixes: + - ansible_galaxy_install - try ``C.UTF-8`` and then fall back to ``en_US.UTF-8`` before failing (https://github.com/ansible-collections/community.general/pull/5680). + - ansible_galaxy_install - set default to raise exception if command's return code is different from zero (https://github.com/ansible-collections/community.general/pull/5680). diff --git a/plugins/modules/ansible_galaxy_install.py b/plugins/modules/ansible_galaxy_install.py index 5e5ec54eb0..694591d8cb 100644 --- a/plugins/modules/ansible_galaxy_install.py +++ b/plugins/modules/ansible_galaxy_install.py @@ -20,6 +20,10 @@ notes: - > B(Ansible 2.9/2.10): The C(ansible-galaxy) command changed significantly between Ansible 2.9 and ansible-base 2.10 (later ansible-core 2.11). See comments in the parameters. + - > + The module will try and run using the C(C.UTF-8) locale. + If that fails, it will try C(en_US.UTF-8). + If that one also fails, the module will fail. requirements: - Ansible 2.9, ansible-base 2.10, or ansible-core 2.11 or newer options: @@ -185,7 +189,7 @@ RETURN = """ import re from ansible_collections.community.general.plugins.module_utils.cmd_runner import CmdRunner, cmd_runner_fmt as fmt -from ansible_collections.community.general.plugins.module_utils.module_helper import ModuleHelper +from ansible_collections.community.general.plugins.module_utils.module_helper import ModuleHelper, ModuleHelperException class AnsibleGalaxyInstall(ModuleHelper): @@ -226,11 +230,17 @@ class AnsibleGalaxyInstall(ModuleHelper): version=fmt.as_bool("--version"), name=fmt.as_list(), ) - force_lang = "en_US.UTF-8" - check_rc = True + + def _make_runner(self, lang): + return CmdRunner(self.module, command=self.command, arg_formats=self.command_args_formats, force_lang=lang, check_rc=True) def _get_ansible_galaxy_version(self): + class UnsupportedLocale(ModuleHelperException): + pass + def process(rc, out, err): + if (rc != 0 and "unsupported locale setting" in err) or (rc == 0 and "cannot change locale" in err): + raise UnsupportedLocale(msg=err) line = out.splitlines()[0] match = self._RE_GALAXY_VERSION.match(line) if not match: @@ -239,12 +249,18 @@ class AnsibleGalaxyInstall(ModuleHelper): version = tuple(int(x) for x in version.split('.')[:3]) return version - with self.runner("version", check_rc=True, output_process=process) as ctx: - return ctx.run(version=True) + try: + runner = self._make_runner("C.UTF-8") + with runner("version", check_rc=False, output_process=process) as ctx: + return runner, ctx.run(version=True) + except UnsupportedLocale as e: + runner = self._make_runner("en_US.UTF-8") + with runner("version", check_rc=True, output_process=process) as ctx: + return runner, ctx.run(version=True) def __init_module__(self): - self.runner = CmdRunner(self.module, command=self.command, arg_formats=self.command_args_formats, force_lang=self.force_lang) - self.ansible_version = self._get_ansible_galaxy_version() + # self.runner = CmdRunner(self.module, command=self.command, arg_formats=self.command_args_formats, force_lang=self.force_lang) + self.runner, self.ansible_version = self._get_ansible_galaxy_version() if self.ansible_version < (2, 11) and not self.vars.ack_min_ansiblecore211: self.module.deprecate( "Support for Ansible 2.9 and ansible-base 2.10 is being deprecated. " @@ -339,11 +355,12 @@ class AnsibleGalaxyInstall(ModuleHelper): self._setup210plus() with self.runner("type galaxy_cmd force no_deps dest requirements_file name", output_process=process) as ctx: ctx.run(galaxy_cmd="install") + if self.verbosity > 2: + self.vars.set("run_info", ctx.run_info) def main(): - galaxy = AnsibleGalaxyInstall() - galaxy.run() + AnsibleGalaxyInstall.execute() if __name__ == '__main__': diff --git a/tests/integration/targets/ansible_galaxy_install/tasks/main.yml b/tests/integration/targets/ansible_galaxy_install/tasks/main.yml index 44ad697930..1ecd9980d4 100644 --- a/tests/integration/targets/ansible_galaxy_install/tasks/main.yml +++ b/tests/integration/targets/ansible_galaxy_install/tasks/main.yml @@ -10,7 +10,7 @@ name: netbox.netbox register: install_c0 -- name: Assert collection was installed +- name: Assert collection netbox.netbox was installed assert: that: - install_c0 is changed @@ -34,7 +34,7 @@ name: ansistrano.deploy register: install_r0 -- name: Assert collection was installed +- name: Assert collection ansistrano.deploy was installed assert: that: - install_r0 is changed @@ -52,7 +52,7 @@ - install_r1 is not changed ################################################### -- name: +- name: Set requirements file path set_fact: reqs_file: '{{ remote_tmp_dir }}/reqs.yaml' From 2fc7baecf8620adba9f46e4d4566f1d2bf1a0a9f Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Thu, 22 Dec 2022 18:54:02 +1300 Subject: [PATCH 0090/1810] xfconf: prune deprecated facts-generating code (more of it) (#5719) * xfconf: prune deprecated facts-generatin code (more of it) * add changelog fragment --- changelogs/fragments/5719-xfconf-facts-deprecation.yml | 6 ++++++ plugins/modules/xfconf.py | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/5719-xfconf-facts-deprecation.yml diff --git a/changelogs/fragments/5719-xfconf-facts-deprecation.yml b/changelogs/fragments/5719-xfconf-facts-deprecation.yml new file mode 100644 index 0000000000..353c0f3730 --- /dev/null +++ b/changelogs/fragments/5719-xfconf-facts-deprecation.yml @@ -0,0 +1,6 @@ +removed_features: + - > + xfconf - generating facts was deprecated in community.general 3.0.0, + however three factoids, ``property``, ``channel`` and ``value`` continued to be generated by mistake. + This behaviour has been removed and ``xfconf`` generate no facts whatsoever + (https://github.com/ansible-collections/community.general/pull/5502). diff --git a/plugins/modules/xfconf.py b/plugins/modules/xfconf.py index 6776ef888e..ec00763ee1 100644 --- a/plugins/modules/xfconf.py +++ b/plugins/modules/xfconf.py @@ -172,7 +172,6 @@ class XFConfProperty(StateModuleHelper): change_params = 'value', diff_params = 'value', output_params = ('property', 'channel', 'value') - facts_params = ('property', 'channel', 'value') module = dict( argument_spec=dict( state=dict(type='str', choices=("present", "absent"), default="present"), From 28969c61ad0dadb79061ec313e901b93df6c2bdf Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Thu, 22 Dec 2022 18:57:23 +1300 Subject: [PATCH 0091/1810] manageiq_policies: deprecate list state (#5721) * manageiq_policies: deprecate list state * add changelog fragment --- .../5721-manageiq-policies-deprecate-list-state.yaml | 2 ++ plugins/modules/manageiq_policies.py | 12 +++++++++++- tests/sanity/ignore-2.11.txt | 2 +- tests/sanity/ignore-2.12.txt | 2 +- tests/sanity/ignore-2.13.txt | 2 +- tests/sanity/ignore-2.14.txt | 2 +- tests/sanity/ignore-2.15.txt | 2 +- 7 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 changelogs/fragments/5721-manageiq-policies-deprecate-list-state.yaml diff --git a/changelogs/fragments/5721-manageiq-policies-deprecate-list-state.yaml b/changelogs/fragments/5721-manageiq-policies-deprecate-list-state.yaml new file mode 100644 index 0000000000..109a2103e4 --- /dev/null +++ b/changelogs/fragments/5721-manageiq-policies-deprecate-list-state.yaml @@ -0,0 +1,2 @@ +deprecated_features: + - manageiq_policies - deprecate ``state=list`` in favour of using ``community.general.manageiq_policies_info`` (https://github.com/ansible-collections/community.general/pull/5721). diff --git a/plugins/modules/manageiq_policies.py b/plugins/modules/manageiq_policies.py index c5b2d88287..fc185fcd58 100644 --- a/plugins/modules/manageiq_policies.py +++ b/plugins/modules/manageiq_policies.py @@ -27,7 +27,10 @@ options: description: - C(absent) - policy_profiles should not exist, - C(present) - policy_profiles should exist, - - C(list) - list current policy_profiles and policies. + - > + C(list) - list current policy_profiles and policies. + This state is deprecated and will be removed 8.0.0. + Please use the module M(community.general.manageiq_policies_info) instead. choices: ['absent', 'present', 'list'] default: 'present' policy_profiles: @@ -163,6 +166,13 @@ def main(): resource_name = module.params['resource_name'] state = module.params['state'] + if state == "list": + module.deprecate( + 'The value "list" for "state" is deprecated. Please use community.general.manageiq_policies_info instead.', + version='8.0.0', + collection_name='community.general' + ) + # get the action and resource type action = actions[state] resource_type = manageiq_entities()[resource_type_key] diff --git a/tests/sanity/ignore-2.11.txt b/tests/sanity/ignore-2.11.txt index c79a17493f..e49b216f6e 100644 --- a/tests/sanity/ignore-2.11.txt +++ b/tests/sanity/ignore-2.11.txt @@ -10,7 +10,7 @@ plugins/modules/consul_session.py validate-modules:parameter-state-invalid-choic plugins/modules/gconftool2.py validate-modules:parameter-state-invalid-choice # state=get - removed in 8.0.0 plugins/modules/iptables_state.py validate-modules:undocumented-parameter plugins/modules/lxc_container.py validate-modules:use-run-command-not-popen -plugins/modules/manageiq_policies.py validate-modules:parameter-state-invalid-choice +plugins/modules/manageiq_policies.py validate-modules:parameter-state-invalid-choice # state=list - removed in 8.0.0 plugins/modules/manageiq_provider.py validate-modules:doc-choices-do-not-match-spec # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:doc-missing-type # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:parameter-type-not-in-doc # missing docs on suboptions diff --git a/tests/sanity/ignore-2.12.txt b/tests/sanity/ignore-2.12.txt index d93315938c..0cf9b73046 100644 --- a/tests/sanity/ignore-2.12.txt +++ b/tests/sanity/ignore-2.12.txt @@ -5,7 +5,7 @@ plugins/modules/consul_session.py validate-modules:parameter-state-invalid-choic plugins/modules/gconftool2.py validate-modules:parameter-state-invalid-choice # state=get - removed in 8.0.0 plugins/modules/iptables_state.py validate-modules:undocumented-parameter plugins/modules/lxc_container.py validate-modules:use-run-command-not-popen -plugins/modules/manageiq_policies.py validate-modules:parameter-state-invalid-choice +plugins/modules/manageiq_policies.py validate-modules:parameter-state-invalid-choice # state=list - removed in 8.0.0 plugins/modules/manageiq_provider.py validate-modules:doc-choices-do-not-match-spec # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:doc-missing-type # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:parameter-type-not-in-doc # missing docs on suboptions diff --git a/tests/sanity/ignore-2.13.txt b/tests/sanity/ignore-2.13.txt index d93315938c..0cf9b73046 100644 --- a/tests/sanity/ignore-2.13.txt +++ b/tests/sanity/ignore-2.13.txt @@ -5,7 +5,7 @@ plugins/modules/consul_session.py validate-modules:parameter-state-invalid-choic plugins/modules/gconftool2.py validate-modules:parameter-state-invalid-choice # state=get - removed in 8.0.0 plugins/modules/iptables_state.py validate-modules:undocumented-parameter plugins/modules/lxc_container.py validate-modules:use-run-command-not-popen -plugins/modules/manageiq_policies.py validate-modules:parameter-state-invalid-choice +plugins/modules/manageiq_policies.py validate-modules:parameter-state-invalid-choice # state=list - removed in 8.0.0 plugins/modules/manageiq_provider.py validate-modules:doc-choices-do-not-match-spec # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:doc-missing-type # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:parameter-type-not-in-doc # missing docs on suboptions diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt index d4c0d0d948..efdb15f969 100644 --- a/tests/sanity/ignore-2.14.txt +++ b/tests/sanity/ignore-2.14.txt @@ -6,7 +6,7 @@ plugins/modules/gconftool2.py validate-modules:parameter-state-invalid-choice plugins/modules/homectl.py import-3.11 # Uses deprecated stdlib library 'crypt' plugins/modules/iptables_state.py validate-modules:undocumented-parameter plugins/modules/lxc_container.py validate-modules:use-run-command-not-popen -plugins/modules/manageiq_policies.py validate-modules:parameter-state-invalid-choice +plugins/modules/manageiq_policies.py validate-modules:parameter-state-invalid-choice # state=list - removed in 8.0.0 plugins/modules/manageiq_provider.py validate-modules:doc-choices-do-not-match-spec # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:doc-missing-type # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:parameter-type-not-in-doc # missing docs on suboptions diff --git a/tests/sanity/ignore-2.15.txt b/tests/sanity/ignore-2.15.txt index d4c0d0d948..efdb15f969 100644 --- a/tests/sanity/ignore-2.15.txt +++ b/tests/sanity/ignore-2.15.txt @@ -6,7 +6,7 @@ plugins/modules/gconftool2.py validate-modules:parameter-state-invalid-choice plugins/modules/homectl.py import-3.11 # Uses deprecated stdlib library 'crypt' plugins/modules/iptables_state.py validate-modules:undocumented-parameter plugins/modules/lxc_container.py validate-modules:use-run-command-not-popen -plugins/modules/manageiq_policies.py validate-modules:parameter-state-invalid-choice +plugins/modules/manageiq_policies.py validate-modules:parameter-state-invalid-choice # state=list - removed in 8.0.0 plugins/modules/manageiq_provider.py validate-modules:doc-choices-do-not-match-spec # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:doc-missing-type # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:parameter-type-not-in-doc # missing docs on suboptions From b3485b8fcab59e47d7460c3473329a9d516c3ea0 Mon Sep 17 00:00:00 2001 From: joergho <48011876+joergho@users.noreply.github.com> Date: Thu, 22 Dec 2022 19:31:33 +0100 Subject: [PATCH 0092/1810] opkg module: allow installing a package in a certain version (#5688) * opkg: allow installing a package in a certain version example: - name: Install foo in version 1.2 community.general.opkg: name: foo=1.2 state: present Signed-off-by: Joerg Hofrichter * opkg: use list for passing arguments to run_command Signed-off-by: Joerg Hofrichter Signed-off-by: Joerg Hofrichter --- ...88-opkg-module-install-certain-version.yml | 2 + plugins/modules/opkg.py | 62 +++++++++++++++---- 2 files changed, 53 insertions(+), 11 deletions(-) create mode 100644 changelogs/fragments/5688-opkg-module-install-certain-version.yml diff --git a/changelogs/fragments/5688-opkg-module-install-certain-version.yml b/changelogs/fragments/5688-opkg-module-install-certain-version.yml new file mode 100644 index 0000000000..88168bd202 --- /dev/null +++ b/changelogs/fragments/5688-opkg-module-install-certain-version.yml @@ -0,0 +1,2 @@ +minor_changes: + - opkg - allow installing a package in a certain version (https://github.com/ansible-collections/community.general/pull/5688). diff --git a/plugins/modules/opkg.py b/plugins/modules/opkg.py index 6c5e23093e..7e2b8c4ac2 100644 --- a/plugins/modules/opkg.py +++ b/plugins/modules/opkg.py @@ -22,6 +22,9 @@ options: name: description: - Name of package(s) to install/remove. + - C(NAME=VERSION) syntax is also supported to install a package + in a certain version. See the examples. This is supported since + community.general 6.2.0. aliases: [pkg] required: true type: list @@ -64,6 +67,11 @@ EXAMPLES = ''' name: foo state: present +- name: Install foo in version 1.2 + community.general.opkg: + name: foo=1.2 + state: present + - name: Update cache and install foo community.general.opkg: name: foo @@ -96,22 +104,39 @@ from ansible.module_utils.six.moves import shlex_quote def update_package_db(module, opkg_path): """ Updates packages list. """ - rc, out, err = module.run_command("%s update" % opkg_path) + rc, out, err = module.run_command([opkg_path, "update"]) if rc != 0: module.fail_json(msg="could not update package db") -def query_package(module, opkg_path, name, state="present"): +def query_package(module, opkg_path, name, version=None, state="present"): """ Returns whether a package is installed or not. """ if state == "present": + rc, out, err = module.run_command([opkg_path, "list-installed", name]) + if rc != 0: + return False + # variable out is one line if the package is installed: + # "NAME - VERSION - DESCRIPTION" + if version is not None: + if not out.startswith("%s - %s " % (name, version)): + return False + else: + if not out.startswith(name + " "): + return False + return True + else: + raise NotImplementedError() - rc, out, err = module.run_command("%s list-installed | grep -q \"^%s \"" % (shlex_quote(opkg_path), shlex_quote(name)), use_unsafe_shell=True) - if rc == 0: - return True - return False +def split_name_and_version(module, package): + """ Split the name and the version when using the NAME=VERSION syntax """ + splitted = package.split('=', 1) + if len(splitted) == 1: + return splitted[0], None + else: + return splitted[0], splitted[1] def remove_packages(module, opkg_path, packages): @@ -125,11 +150,16 @@ def remove_packages(module, opkg_path, packages): remove_c = 0 # Using a for loop in case of error, we can report the package that failed for package in packages: + package, version = split_name_and_version(module, package) + # Query the package first, to see if we even need to remove if not query_package(module, opkg_path, package): continue - rc, out, err = module.run_command("%s remove %s %s" % (opkg_path, force, package)) + if force: + rc, out, err = module.run_command([opkg_path, "remove", force, package]) + else: + rc, out, err = module.run_command([opkg_path, "remove", package]) if query_package(module, opkg_path, package): module.fail_json(msg="failed to remove %s: %s" % (package, out)) @@ -154,13 +184,23 @@ def install_packages(module, opkg_path, packages): install_c = 0 for package in packages: - if query_package(module, opkg_path, package) and (force != '--force-reinstall'): + package, version = split_name_and_version(module, package) + + if query_package(module, opkg_path, package, version) and (force != '--force-reinstall'): continue - rc, out, err = module.run_command("%s install %s %s" % (opkg_path, force, package)) + if version is not None: + version_str = "=%s" % version + else: + version_str = "" - if not query_package(module, opkg_path, package): - module.fail_json(msg="failed to install %s: %s" % (package, out)) + if force: + rc, out, err = module.run_command([opkg_path, "install", force, package + version_str]) + else: + rc, out, err = module.run_command([opkg_path, "install", package + version_str]) + + if not query_package(module, opkg_path, package, version): + module.fail_json(msg="failed to install %s%s: %s" % (package, version_str, out)) install_c += 1 From 6383c82328f32a6221fa7dd88fc92910966b5457 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Fri, 23 Dec 2022 09:34:21 +1300 Subject: [PATCH 0093/1810] ssh_config: fixed sanity (#5720) * ssh_config: fix sanity checks * fixed mod utils and removed sanity ignores * update BOTMETA * add changelog fragment * Update plugins/module_utils/ssh.py Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein --- .github/BOTMETA.yml | 2 ++ .../5720-ssh_config-plugin-sanity.yml | 2 ++ plugins/module_utils/ssh.py | 21 +++++++++++++++++++ plugins/modules/ssh_config.py | 6 ++---- tests/sanity/ignore-2.11.txt | 1 - tests/sanity/ignore-2.12.txt | 1 - tests/sanity/ignore-2.13.txt | 1 - tests/sanity/ignore-2.14.txt | 1 - tests/sanity/ignore-2.15.txt | 1 - 9 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 changelogs/fragments/5720-ssh_config-plugin-sanity.yml create mode 100644 plugins/module_utils/ssh.py diff --git a/.github/BOTMETA.yml b/.github/BOTMETA.yml index 0a0cded0c1..047d537895 100644 --- a/.github/BOTMETA.yml +++ b/.github/BOTMETA.yml @@ -323,6 +323,8 @@ files: $module_utils/scaleway.py: labels: cloud scaleway maintainers: $team_scaleway + $module_utils/ssh.py: + maintainers: russoz $module_utils/storage/hpe3par/hpe3par.py: maintainers: farhan7500 gautamphegde $module_utils/utm_utils.py: diff --git a/changelogs/fragments/5720-ssh_config-plugin-sanity.yml b/changelogs/fragments/5720-ssh_config-plugin-sanity.yml new file mode 100644 index 0000000000..19d57ea145 --- /dev/null +++ b/changelogs/fragments/5720-ssh_config-plugin-sanity.yml @@ -0,0 +1,2 @@ +minor_changes: + - ssh_config - refactor code to module util to fix sanity check (https://github.com/ansible-collections/community.general/pull/5720). diff --git a/plugins/module_utils/ssh.py b/plugins/module_utils/ssh.py new file mode 100644 index 0000000000..082839e26d --- /dev/null +++ b/plugins/module_utils/ssh.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2015, Björn Andersson +# Copyright (c) 2021, Ansible Project +# Copyright (c) 2021, Abhijeet Kasurde +# Copyright (c) 2022, Alexei Znamensky +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +import os + + +def determine_config_file(user, config_file): + if user: + config_file = os.path.join(os.path.expanduser('~%s' % user), '.ssh', 'config') + elif config_file is None: + config_file = '/etc/ssh/ssh_config' + return config_file diff --git a/plugins/modules/ssh_config.py b/plugins/modules/ssh_config.py index cb028ac8e5..f2fa8aa457 100644 --- a/plugins/modules/ssh_config.py +++ b/plugins/modules/ssh_config.py @@ -169,6 +169,7 @@ except ImportError: from ansible.module_utils.basic import AnsibleModule, missing_required_lib from ansible.module_utils.common.text.converters import to_native +from ansible_collections.community.general.plugins.module_utils.ssh import determine_config_file class SSHConfig(): @@ -188,10 +189,7 @@ class SSHConfig(): self.config.load() def check_ssh_config_path(self): - if self.user: - self.config_file = os.path.join(os.path.expanduser('~%s' % self.user), '.ssh', 'config') - elif self.config_file is None: - self.config_file = '/etc/ssh/ssh_config' + self.config_file = determine_config_file(self.user, self.config_file) # See if the identity file exists or not, relative to the config file if os.path.exists(self.config_file) and self.identity_file is not None: diff --git a/tests/sanity/ignore-2.11.txt b/tests/sanity/ignore-2.11.txt index e49b216f6e..77738afd40 100644 --- a/tests/sanity/ignore-2.11.txt +++ b/tests/sanity/ignore-2.11.txt @@ -23,7 +23,6 @@ plugins/modules/rax_files_objects.py use-argspec-type-path plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice plugins/modules/rax.py use-argspec-type-path # fix needed plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice -plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path plugins/modules/xfconf.py validate-modules:return-syntax-error plugins/modules/yarn.py use-argspec-type-path tests/integration/targets/django_manage/files/base_test/simple_project/p1/manage.py compile-2.6 # django generated code diff --git a/tests/sanity/ignore-2.12.txt b/tests/sanity/ignore-2.12.txt index 0cf9b73046..61494a1ab1 100644 --- a/tests/sanity/ignore-2.12.txt +++ b/tests/sanity/ignore-2.12.txt @@ -18,6 +18,5 @@ plugins/modules/rax_files_objects.py use-argspec-type-path plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice plugins/modules/rax.py use-argspec-type-path # fix needed plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice -plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path plugins/modules/xfconf.py validate-modules:return-syntax-error plugins/modules/yarn.py use-argspec-type-path diff --git a/tests/sanity/ignore-2.13.txt b/tests/sanity/ignore-2.13.txt index 0cf9b73046..61494a1ab1 100644 --- a/tests/sanity/ignore-2.13.txt +++ b/tests/sanity/ignore-2.13.txt @@ -18,6 +18,5 @@ plugins/modules/rax_files_objects.py use-argspec-type-path plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice plugins/modules/rax.py use-argspec-type-path # fix needed plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice -plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path plugins/modules/xfconf.py validate-modules:return-syntax-error plugins/modules/yarn.py use-argspec-type-path diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt index efdb15f969..6b9026caea 100644 --- a/tests/sanity/ignore-2.14.txt +++ b/tests/sanity/ignore-2.14.txt @@ -19,7 +19,6 @@ plugins/modules/rax_files_objects.py use-argspec-type-path plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice plugins/modules/rax.py use-argspec-type-path # fix needed plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice -plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path plugins/modules/udm_user.py import-3.11 # Uses deprecated stdlib library 'crypt' plugins/modules/xfconf.py validate-modules:return-syntax-error plugins/modules/yarn.py use-argspec-type-path diff --git a/tests/sanity/ignore-2.15.txt b/tests/sanity/ignore-2.15.txt index efdb15f969..6b9026caea 100644 --- a/tests/sanity/ignore-2.15.txt +++ b/tests/sanity/ignore-2.15.txt @@ -19,7 +19,6 @@ plugins/modules/rax_files_objects.py use-argspec-type-path plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice plugins/modules/rax.py use-argspec-type-path # fix needed plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice -plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path plugins/modules/udm_user.py import-3.11 # Uses deprecated stdlib library 'crypt' plugins/modules/xfconf.py validate-modules:return-syntax-error plugins/modules/yarn.py use-argspec-type-path From 2ce3cf91b8bb0e070b01974f6c938029f0bbbd97 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Fri, 23 Dec 2022 19:13:56 +1300 Subject: [PATCH 0094/1810] manageiq_tags: deprecate list state (#5727) * manageiq_tags: deprecate list state * add changelog fragment * add comment to sanity ignore files --- ...27-manageiq-tags-deprecate-list-state.yaml | 2 ++ plugins/modules/manageiq_tags.py | 23 +++++++++---------- tests/sanity/ignore-2.11.txt | 2 +- tests/sanity/ignore-2.12.txt | 2 +- tests/sanity/ignore-2.13.txt | 2 +- tests/sanity/ignore-2.14.txt | 2 +- tests/sanity/ignore-2.15.txt | 2 +- 7 files changed, 18 insertions(+), 17 deletions(-) create mode 100644 changelogs/fragments/5727-manageiq-tags-deprecate-list-state.yaml diff --git a/changelogs/fragments/5727-manageiq-tags-deprecate-list-state.yaml b/changelogs/fragments/5727-manageiq-tags-deprecate-list-state.yaml new file mode 100644 index 0000000000..fe1c49fbf5 --- /dev/null +++ b/changelogs/fragments/5727-manageiq-tags-deprecate-list-state.yaml @@ -0,0 +1,2 @@ +deprecated_features: + - manageiq_tags - deprecate ``state=list`` in favour of using ``community.general.manageiq_tags_info`` (https://github.com/ansible-collections/community.general/pull/5727). diff --git a/plugins/modules/manageiq_tags.py b/plugins/modules/manageiq_tags.py index 9d051a5aa1..5e6b944533 100644 --- a/plugins/modules/manageiq_tags.py +++ b/plugins/modules/manageiq_tags.py @@ -27,7 +27,10 @@ options: description: - C(absent) - tags should not exist. - C(present) - tags should exist. - - C(list) - list current tags. + - > + C(list) - list current tags. + This state is deprecated and will be removed 8.0.0. + Please use the module M(community.general.manageiq_tags_info) instead. choices: ['absent', 'present', 'list'] default: 'present' tags: @@ -103,17 +106,6 @@ EXAMPLES = ''' username: 'admin' password: 'smartvm' validate_certs: false - -- name: List current tags for a provider in ManageIQ. - community.general.manageiq_tags: - state: list - resource_name: 'EngLab' - resource_type: 'provider' - manageiq_connection: - url: 'http://127.0.0.1:3000' - username: 'admin' - password: 'smartvm' - validate_certs: false ''' RETURN = ''' @@ -155,6 +147,13 @@ def main(): resource_name = module.params['resource_name'] state = module.params['state'] + if state == "list": + module.deprecate( + 'The value "list" for "state" is deprecated. Please use community.general.manageiq_tags_info instead.', + version='8.0.0', + collection_name='community.general' + ) + # get the action and resource type action = actions[state] resource_type = manageiq_entities()[resource_type_key] diff --git a/tests/sanity/ignore-2.11.txt b/tests/sanity/ignore-2.11.txt index 77738afd40..39b09d887a 100644 --- a/tests/sanity/ignore-2.11.txt +++ b/tests/sanity/ignore-2.11.txt @@ -15,7 +15,7 @@ plugins/modules/manageiq_provider.py validate-modules:doc-choices-do-not-match-s plugins/modules/manageiq_provider.py validate-modules:doc-missing-type # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:parameter-type-not-in-doc # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:undocumented-parameter # missing docs on suboptions -plugins/modules/manageiq_tags.py validate-modules:parameter-state-invalid-choice +plugins/modules/manageiq_tags.py validate-modules:parameter-state-invalid-choice # state=list - removed in 8.0.0 plugins/modules/osx_defaults.py validate-modules:parameter-state-invalid-choice plugins/modules/parted.py validate-modules:parameter-state-invalid-choice plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias - removed in 7.0.0 diff --git a/tests/sanity/ignore-2.12.txt b/tests/sanity/ignore-2.12.txt index 61494a1ab1..47244bb515 100644 --- a/tests/sanity/ignore-2.12.txt +++ b/tests/sanity/ignore-2.12.txt @@ -10,7 +10,7 @@ plugins/modules/manageiq_provider.py validate-modules:doc-choices-do-not-match-s plugins/modules/manageiq_provider.py validate-modules:doc-missing-type # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:parameter-type-not-in-doc # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:undocumented-parameter # missing docs on suboptions -plugins/modules/manageiq_tags.py validate-modules:parameter-state-invalid-choice +plugins/modules/manageiq_tags.py validate-modules:parameter-state-invalid-choice # state=list - removed in 8.0.0 plugins/modules/osx_defaults.py validate-modules:parameter-state-invalid-choice plugins/modules/parted.py validate-modules:parameter-state-invalid-choice plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias - removed in 7.0.0 diff --git a/tests/sanity/ignore-2.13.txt b/tests/sanity/ignore-2.13.txt index 61494a1ab1..47244bb515 100644 --- a/tests/sanity/ignore-2.13.txt +++ b/tests/sanity/ignore-2.13.txt @@ -10,7 +10,7 @@ plugins/modules/manageiq_provider.py validate-modules:doc-choices-do-not-match-s plugins/modules/manageiq_provider.py validate-modules:doc-missing-type # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:parameter-type-not-in-doc # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:undocumented-parameter # missing docs on suboptions -plugins/modules/manageiq_tags.py validate-modules:parameter-state-invalid-choice +plugins/modules/manageiq_tags.py validate-modules:parameter-state-invalid-choice # state=list - removed in 8.0.0 plugins/modules/osx_defaults.py validate-modules:parameter-state-invalid-choice plugins/modules/parted.py validate-modules:parameter-state-invalid-choice plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias - removed in 7.0.0 diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt index 6b9026caea..a2e9e37325 100644 --- a/tests/sanity/ignore-2.14.txt +++ b/tests/sanity/ignore-2.14.txt @@ -11,7 +11,7 @@ plugins/modules/manageiq_provider.py validate-modules:doc-choices-do-not-match-s plugins/modules/manageiq_provider.py validate-modules:doc-missing-type # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:parameter-type-not-in-doc # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:undocumented-parameter # missing docs on suboptions -plugins/modules/manageiq_tags.py validate-modules:parameter-state-invalid-choice +plugins/modules/manageiq_tags.py validate-modules:parameter-state-invalid-choice # state=list - removed in 8.0.0 plugins/modules/osx_defaults.py validate-modules:parameter-state-invalid-choice plugins/modules/parted.py validate-modules:parameter-state-invalid-choice plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias - removed in 7.0.0 diff --git a/tests/sanity/ignore-2.15.txt b/tests/sanity/ignore-2.15.txt index 6b9026caea..a2e9e37325 100644 --- a/tests/sanity/ignore-2.15.txt +++ b/tests/sanity/ignore-2.15.txt @@ -11,7 +11,7 @@ plugins/modules/manageiq_provider.py validate-modules:doc-choices-do-not-match-s plugins/modules/manageiq_provider.py validate-modules:doc-missing-type # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:parameter-type-not-in-doc # missing docs on suboptions plugins/modules/manageiq_provider.py validate-modules:undocumented-parameter # missing docs on suboptions -plugins/modules/manageiq_tags.py validate-modules:parameter-state-invalid-choice +plugins/modules/manageiq_tags.py validate-modules:parameter-state-invalid-choice # state=list - removed in 8.0.0 plugins/modules/osx_defaults.py validate-modules:parameter-state-invalid-choice plugins/modules/parted.py validate-modules:parameter-state-invalid-choice plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias - removed in 7.0.0 From eb1c1210d657375cdd9374de79608677316deef7 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Fri, 23 Dec 2022 19:15:28 +1300 Subject: [PATCH 0095/1810] manageiq_policies: remove doc example for deprecated case (#5728) --- plugins/modules/manageiq_policies.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/plugins/modules/manageiq_policies.py b/plugins/modules/manageiq_policies.py index fc185fcd58..fa96fc950f 100644 --- a/plugins/modules/manageiq_policies.py +++ b/plugins/modules/manageiq_policies.py @@ -85,17 +85,6 @@ EXAMPLES = ''' username: 'admin' password: 'smartvm' validate_certs: false - -- name: List current policy_profile and policies for a provider in ManageIQ - community.general.manageiq_policies: - state: list - resource_name: 'EngLab' - resource_type: 'provider' - manageiq_connection: - url: 'http://127.0.0.1:3000' - username: 'admin' - password: 'smartvm' - validate_certs: false ''' RETURN = ''' From 669d0925f71cf591b45bf890b33625d182ae4fc8 Mon Sep 17 00:00:00 2001 From: HAH! Sun <3346207+omani@users.noreply.github.com> Date: Fri, 23 Dec 2022 10:00:17 +0300 Subject: [PATCH 0096/1810] Feature: Provide project field for LXD inventory plugin (#5658) * Provide project field for LXD inventory plugin if field `project` exists in `lxd.yml`, the instances are searched in the given LXD project. if project field is not defined the default project named `default` will be used. Signed-off-by: omani <3346207+omani@users.noreply.github.com> * Update plugins/inventory/lxd.py Signed-off-by: omani <3346207+omani@users.noreply.github.com> Co-authored-by: Felix Fontein --- plugins/inventory/lxd.py | 55 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/plugins/inventory/lxd.py b/plugins/inventory/lxd.py index 291d12b037..2e37de70c1 100644 --- a/plugins/inventory/lxd.py +++ b/plugins/inventory/lxd.py @@ -55,6 +55,11 @@ DOCUMENTATION = r''' type: str default: none choices: [ 'STOPPED', 'STARTING', 'RUNNING', 'none' ] + project: + description: Filter the instance according to the given project. + type: str + default: default + version_added: 6.2.0 type_filter: description: - Filter the instances by type C(virtual-machine), C(container) or C(both). @@ -140,6 +145,9 @@ groupby: vlan666: type: vlanid attribute: 666 + projectInternals: + type: project + attribute: internals ''' import binascii @@ -153,6 +161,7 @@ from ansible.module_utils.common.text.converters import to_native, to_text from ansible.module_utils.common.dict_transformations import dict_merge from ansible.module_utils.six import raise_from from ansible.errors import AnsibleError, AnsibleParserError +from ansible.module_utils.six.moves.urllib.parse import urlencode from ansible_collections.community.general.plugins.module_utils.lxd import LXDClient, LXDClientException try: @@ -330,7 +339,15 @@ class InventoryModule(BaseInventoryPlugin): # "status_code": 200, # "type": "sync" # } - instances = self.socket.do('GET', '/1.0/instances') + url = '/1.0/instances' + if self.project: + url = url + '?{0}'.format(urlencode(dict(project=self.project))) + + instances = self.socket.do('GET', url) + + if self.project: + return [m.split('/')[3].split('?')[0] for m in instances['metadata']] + return [m.split('/')[3] for m in instances['metadata']] def _get_config(self, branch, name): @@ -351,9 +368,11 @@ class InventoryModule(BaseInventoryPlugin): dict(config): Config of the instance""" config = {} if isinstance(branch, (tuple, list)): - config[name] = {branch[1]: self.socket.do('GET', '/1.0/{0}/{1}/{2}'.format(to_native(branch[0]), to_native(name), to_native(branch[1])))} + config[name] = {branch[1]: self.socket.do( + 'GET', '/1.0/{0}/{1}/{2}?{3}'.format(to_native(branch[0]), to_native(name), to_native(branch[1]), urlencode(dict(project=self.project))))} else: - config[name] = {branch: self.socket.do('GET', '/1.0/{0}/{1}'.format(to_native(branch), to_native(name)))} + config[name] = {branch: self.socket.do( + 'GET', '/1.0/{0}/{1}?{2}'.format(to_native(branch), to_native(name), urlencode(dict(project=self.project))))} return config def get_instance_data(self, names): @@ -583,6 +602,8 @@ class InventoryModule(BaseInventoryPlugin): self._set_data_entry(instance_name, 'network_interfaces', self.extract_network_information_from_instance_config(instance_name)) self._set_data_entry(instance_name, 'preferred_interface', self.get_prefered_instance_network_interface(instance_name)) self._set_data_entry(instance_name, 'vlan_ids', self.get_instance_vlans(instance_name)) + self._set_data_entry(instance_name, 'project', self._get_data_entry( + 'instances/{0}/instances/metadata/project'.format(instance_name))) def build_inventory_network(self, instance_name): """Add the network interfaces of the instance to the inventory @@ -686,6 +707,8 @@ class InventoryModule(BaseInventoryPlugin): # add VLAN_ID information if self._get_data_entry('inventory/{0}/vlan_ids'.format(instance_name)): self.inventory.set_variable(instance_name, 'ansible_lxd_vlan_ids', self._get_data_entry('inventory/{0}/vlan_ids'.format(instance_name))) + # add project + self.inventory.set_variable(instance_name, 'ansible_lxd_project', self._get_data_entry('inventory/{0}/project'.format(instance_name))) def build_inventory_groups_location(self, group_name): """create group by attribute: location @@ -761,6 +784,28 @@ class InventoryModule(BaseInventoryPlugin): # Ignore invalid IP addresses returned by lxd pass + def build_inventory_groups_project(self, group_name): + """create group by attribute: project + + Args: + str(group_name): Group name + Kwargs: + None + Raises: + None + Returns: + None""" + # maybe we just want to expand one group + if group_name not in self.inventory.groups: + self.inventory.add_group(group_name) + + gen_instances = [ + instance_name for instance_name in self.inventory.hosts + if 'ansible_lxd_project' in self.inventory.get_host(instance_name).get_vars()] + for instance_name in gen_instances: + if self.groupby[group_name].get('attribute').lower() == self.inventory.get_host(instance_name).get_vars().get('ansible_lxd_project'): + self.inventory.add_child(group_name, instance_name) + def build_inventory_groups_os(self, group_name): """create group by attribute: os @@ -899,6 +944,7 @@ class InventoryModule(BaseInventoryPlugin): * 'profile' * 'vlanid' * 'type' + * 'project' Args: str(group_name): Group name @@ -926,6 +972,8 @@ class InventoryModule(BaseInventoryPlugin): self.build_inventory_groups_vlanid(group_name) elif self.groupby[group_name].get('type') == 'type': self.build_inventory_groups_type(group_name) + elif self.groupby[group_name].get('type') == 'project': + self.build_inventory_groups_project(group_name) else: raise AnsibleParserError('Unknown group type: {0}'.format(to_native(group_name))) @@ -1032,6 +1080,7 @@ class InventoryModule(BaseInventoryPlugin): try: self.client_key = self.get_option('client_key') self.client_cert = self.get_option('client_cert') + self.project = self.get_option('project') self.debug = self.DEBUG self.data = {} # store for inventory-data self.groupby = self.get_option('groupby') From 2d4ce9f21970a2d126550135ba35f7c9a0cfb449 Mon Sep 17 00:00:00 2001 From: GuillaumeV-cemea <101114641+GuillaumeV-cemea@users.noreply.github.com> Date: Fri, 30 Dec 2022 22:09:00 +0100 Subject: [PATCH 0097/1810] feat: add tags to proxmox containers (#5714) * feat: add tags to proxmox containers * fix: correct version added * fix: code style * feat: changelog fragment * fix: correct version_added Co-authored-by: Felix Fontein * feat: fail on unsupported params, rather than silently ignoring them * fix: actually check unsupported feature presence before failing Co-authored-by: Felix Fontein --- .../5714-proxmox-lxc-tag-support.yml | 3 ++ plugins/modules/proxmox.py | 35 ++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/5714-proxmox-lxc-tag-support.yml diff --git a/changelogs/fragments/5714-proxmox-lxc-tag-support.yml b/changelogs/fragments/5714-proxmox-lxc-tag-support.yml new file mode 100644 index 0000000000..5e3dcc8fcf --- /dev/null +++ b/changelogs/fragments/5714-proxmox-lxc-tag-support.yml @@ -0,0 +1,3 @@ +--- +minor_changes: +- proxmox - added new module parameter ``tags`` for use with PVE 7+ (https://github.com/ansible-collections/community.general/pull/5714). diff --git a/plugins/modules/proxmox.py b/plugins/modules/proxmox.py index 89706655f2..640f9b4114 100644 --- a/plugins/modules/proxmox.py +++ b/plugins/modules/proxmox.py @@ -106,6 +106,14 @@ options: description: - sets DNS search domain for a container type: str + tags: + description: + - List of tags to apply to the container. + - Tags must start with C([a-z0-9_]) followed by zero or more of the following characters C([a-z0-9_-+.]). + - Tags are only available in Proxmox 7+. + type: list + elements: str + version_added: 6.2.0 timeout: description: - timeout for operations @@ -391,6 +399,7 @@ EXAMPLES = r''' state: absent ''' +import re import time from ansible_collections.community.general.plugins.module_utils.version import LooseVersion @@ -415,11 +424,25 @@ class ProxmoxLxcAnsible(ProxmoxAnsible): return config['template'] def create_instance(self, vmid, node, disk, storage, cpus, memory, swap, timeout, clone, **kwargs): + + # Version limited features + minimum_version = { + 'tags': 7, + } proxmox_node = self.proxmox_api.nodes(node) # Remove all empty kwarg entries kwargs = dict((k, v) for k, v in kwargs.items() if v is not None) + version = self.version() + pve_major_version = 3 if version < LooseVersion('4.0') else version.version[0] + + # Fail on unsupported features + for option, version in minimum_version.items(): + if pve_major_version < version and option in kwargs: + self.module.fail_json(changed=False, msg="Feature {option} is only supported in PVE {version}+, and you're using PVE {pve_major_version}". + format(option=option, version=version, pve_major_version=pve_major_version)) + if VZ_TYPE == 'lxc': kwargs['cpulimit'] = cpus kwargs['rootfs'] = disk @@ -437,6 +460,14 @@ class ProxmoxLxcAnsible(ProxmoxAnsible): kwargs['cpus'] = cpus kwargs['disk'] = disk + # LXC tags are expected to be valid and presented as a comma/semi-colon delimited string + if 'tags' in kwargs: + re_tag = re.compile(r'^[a-z0-9_][a-z0-9_\-\+\.]*$') + for tag in kwargs['tags']: + if not re_tag.match(tag): + self.module.fail_json(msg='%s is not a valid tag' % tag) + kwargs['tags'] = ",".join(kwargs['tags']) + if clone is not None: if VZ_TYPE != 'lxc': self.module.fail_json(changed=False, msg="Clone operator is only supported for LXC enabled proxmox clusters.") @@ -569,6 +600,7 @@ def main(): proxmox_default_behavior=dict(type='str', default='no_defaults', choices=['compatibility', 'no_defaults']), clone=dict(type='int'), clone_type=dict(default='opportunistic', choices=['full', 'linked', 'opportunistic']), + tags=dict(type='list', elements='str') ) module_args.update(proxmox_args) @@ -674,7 +706,8 @@ def main(): features=",".join(module.params['features']) if module.params['features'] is not None else None, unprivileged=ansible_to_proxmox_bool(module.params['unprivileged']), description=module.params['description'], - hookscript=module.params['hookscript']) + hookscript=module.params['hookscript'], + tags=module.params['tags']) module.exit_json(changed=True, msg="Deployed VM %s from template %s" % (vmid, module.params['ostemplate'])) except Exception as e: From 568e18809c7cb0b7057feb77bbc919efe5752d8d Mon Sep 17 00:00:00 2001 From: "Fabian P. Schmidt" Date: Fri, 30 Dec 2022 22:35:03 +0100 Subject: [PATCH 0098/1810] unixy Callback: Fix typo using ansibles config manager (#5744) Fixes typo introduced in 53da86c. Signed-off-by: Fabian P. Schmidt Signed-off-by: Fabian P. Schmidt --- .../fragments/5744-unixy-callback-fix-config-manager-typo.yml | 2 ++ plugins/callback/unixy.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/5744-unixy-callback-fix-config-manager-typo.yml diff --git a/changelogs/fragments/5744-unixy-callback-fix-config-manager-typo.yml b/changelogs/fragments/5744-unixy-callback-fix-config-manager-typo.yml new file mode 100644 index 0000000000..d60b43d3d4 --- /dev/null +++ b/changelogs/fragments/5744-unixy-callback-fix-config-manager-typo.yml @@ -0,0 +1,2 @@ +bugfixes: + - unixy callback plugin - fix typo introduced when updating to use Ansible's configuration manager for handling options (https://github.com/ansible-collections/community.general/issues/5600). diff --git a/plugins/callback/unixy.py b/plugins/callback/unixy.py index 55f46afd32..02a2e46ba6 100644 --- a/plugins/callback/unixy.py +++ b/plugins/callback/unixy.py @@ -142,7 +142,7 @@ class CallbackModule(CallbackModule_default): display_color = C.COLOR_CHANGED task_result = self._process_result_output(result, msg) self._display.display(" " + task_result, display_color) - elif self.get('display_ok_hosts'): + elif self.get_option('display_ok_hosts'): task_result = self._process_result_output(result, msg) self._display.display(" " + task_result, display_color) From 06d72dfed9c19b7995c7d4665365e112d08c4427 Mon Sep 17 00:00:00 2001 From: bluikko <14869000+bluikko@users.noreply.github.com> Date: Sat, 31 Dec 2022 13:53:27 +0700 Subject: [PATCH 0099/1810] htpasswd: improve documentation on crypt_scheme (#5741) * htpasswd: improve documentation on crypt_scheme * htpasswd: formatting in documentation Co-authored-by: Felix Fontein * htpasswd: formatting in documentation Co-authored-by: Felix Fontein * Apply suggestions from code review * Apply suggestions from code review Co-authored-by: Felix Fontein --- plugins/modules/htpasswd.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/modules/htpasswd.py b/plugins/modules/htpasswd.py index f24eaa0087..231506984a 100644 --- a/plugins/modules/htpasswd.py +++ b/plugins/modules/htpasswd.py @@ -41,9 +41,12 @@ options: description: - Encryption scheme to be used. As well as the four choices listed here, you can also use any other hash supported by passlib, such as - md5_crypt and sha256_crypt, which are linux passwd hashes. If you - do so the password file will not be compatible with Apache or Nginx - - 'Some of the available choices might be: C(apr_md5_crypt), C(des_crypt), C(ldap_sha1), C(plaintext)' + C(portable_apache22) and C(host_apache24); or C(md5_crypt) and C(sha256_crypt), + which are Linux passwd hashes. Only some schemes in addition to + the four choices below will be compatible with Apache or Nginx, and + supported schemes depend on passlib version and its dependencies. + - See U(https://passlib.readthedocs.io/en/stable/lib/passlib.apache.html#passlib.apache.HtpasswdFile) parameter C(default_scheme). + - 'Some of the available choices might be: C(apr_md5_crypt), C(des_crypt), C(ldap_sha1), C(plaintext).' state: type: str required: false From 7c99c53c648df93a109f28ff99aee8dff68f52f4 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Wed, 4 Jan 2023 07:30:06 +0100 Subject: [PATCH 0100/1810] The next expected release will be 6.3.0. --- galaxy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/galaxy.yml b/galaxy.yml index f55ebce545..09c85cf2b8 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -5,7 +5,7 @@ namespace: community name: general -version: 6.2.0 +version: 6.3.0 readme: README.md authors: - Ansible (https://github.com/ansible) From b49bf081f8fce789f78cbf996d201c1ac99add01 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Wed, 4 Jan 2023 23:59:06 +1300 Subject: [PATCH 0101/1810] ModuleHelper - fix bug when adjusting conflicting output (#5755) * ModuleHelper - fix bug when adjusting conflicting output * add changelog fragment * remove commented test code --- .../fragments/5755-mh-fix-output-conflict.yml | 2 ++ plugins/module_utils/mh/module_helper.py | 2 +- .../targets/module_helper/library/msimple.py | 6 +++- .../targets/module_helper/tasks/main.yml | 1 + .../tasks/msimple_output_conflict.yml | 31 +++++++++++++++++++ 5 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/5755-mh-fix-output-conflict.yml create mode 100644 tests/integration/targets/module_helper/tasks/msimple_output_conflict.yml diff --git a/changelogs/fragments/5755-mh-fix-output-conflict.yml b/changelogs/fragments/5755-mh-fix-output-conflict.yml new file mode 100644 index 0000000000..f433cc0290 --- /dev/null +++ b/changelogs/fragments/5755-mh-fix-output-conflict.yml @@ -0,0 +1,2 @@ +bugfixes: + - ModuleHelper - fix bug when adjusting the name of reserved output variables (https://github.com/ansible-collections/community.general/pull/5755). diff --git a/plugins/module_utils/mh/module_helper.py b/plugins/module_utils/mh/module_helper.py index c844acba50..51696b6ff6 100644 --- a/plugins/module_utils/mh/module_helper.py +++ b/plugins/module_utils/mh/module_helper.py @@ -60,7 +60,7 @@ class ModuleHelper(DeprecateAttrsMixin, VarsMixin, DependencyMixin, ModuleHelper vars_diff = self.vars.diff() or {} result['diff'] = dict_merge(dict(diff), vars_diff) - for varname in result: + for varname in list(result): if varname in self._output_conflict_list: result["_" + varname] = result[varname] del result[varname] diff --git a/tests/integration/targets/module_helper/library/msimple.py b/tests/integration/targets/module_helper/library/msimple.py index 60a49dccb1..3729b6c702 100644 --- a/tests/integration/targets/module_helper/library/msimple.py +++ b/tests/integration/targets/module_helper/library/msimple.py @@ -35,12 +35,13 @@ from ansible_collections.community.general.plugins.module_utils.mh.deco import c class MSimple(ModuleHelper): - output_params = ('a', 'b', 'c') + output_params = ('a', 'b', 'c', 'm') module = dict( argument_spec=dict( a=dict(type='int', default=0), b=dict(type='str'), c=dict(type='str'), + m=dict(type='str'), ), supports_check_mode=True, ) @@ -65,6 +66,9 @@ class MSimple(ModuleHelper): self.vars['c'] = str(self.vars.c) * 2 self.process_a3_bc() + if self.vars.m: + self.vars.msg = self.vars.m + def main(): msimple = MSimple() diff --git a/tests/integration/targets/module_helper/tasks/main.yml b/tests/integration/targets/module_helper/tasks/main.yml index 90006f701d..2368cfcbb5 100644 --- a/tests/integration/targets/module_helper/tasks/main.yml +++ b/tests/integration/targets/module_helper/tasks/main.yml @@ -3,6 +3,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later - include_tasks: msimple.yml +- include_tasks: msimple_output_conflict.yml - include_tasks: mdepfail.yml - include_tasks: mstate.yml - include_tasks: msimpleda.yml diff --git a/tests/integration/targets/module_helper/tasks/msimple_output_conflict.yml b/tests/integration/targets/module_helper/tasks/msimple_output_conflict.yml new file mode 100644 index 0000000000..21ffd37d35 --- /dev/null +++ b/tests/integration/targets/module_helper/tasks/msimple_output_conflict.yml @@ -0,0 +1,31 @@ +# Copyright (c) 2023, Alexei Znamensky +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +- name: test msimple (set a=80) + msimple: + a: 80 + register: simple1 + +- name: assert simple1 + assert: + that: + - simple1.a == 80 + - simple1.abc == "abc" + - simple1 is not changed + - simple1.value is none + +- name: test msimple 2 + msimple: + a: 80 + m: a message in a bottle + register: simple2 + +- name: assert simple2 + assert: + that: + - simple1.a == 80 + - simple1.abc == "abc" + - simple1 is not changed + - simple1.value is none + - 'simple2._msg == "a message in a bottle"' From 84ebda65f1479b9b338bfca7294e4c28fba79576 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Wed, 4 Jan 2023 22:06:57 +0100 Subject: [PATCH 0102/1810] Fix callback plugin types (#5761) Fix callback types. --- changelogs/fragments/5761-callback-types.yml | 7 +++++++ plugins/callback/loganalytics.py | 4 ++-- plugins/callback/logdna.py | 4 ++-- plugins/callback/logstash.py | 2 +- plugins/callback/splunk.py | 4 ++-- plugins/callback/sumologic.py | 4 ++-- plugins/callback/syslog_json.py | 2 +- 7 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 changelogs/fragments/5761-callback-types.yml diff --git a/changelogs/fragments/5761-callback-types.yml b/changelogs/fragments/5761-callback-types.yml new file mode 100644 index 0000000000..62466f46a5 --- /dev/null +++ b/changelogs/fragments/5761-callback-types.yml @@ -0,0 +1,7 @@ +bugfixes: + - "loganalytics callback plugin - adjust type of callback to ``notification``, it was incorrectly classified as ``aggregate`` before (https://github.com/ansible-collections/community.general/pull/5761)." + - "logdna callback plugin - adjust type of callback to ``notification``, it was incorrectly classified as ``aggregate`` before (https://github.com/ansible-collections/community.general/pull/5761)." + - "logstash callback plugin - adjust type of callback to ``notification``, it was incorrectly classified as ``aggregate`` before (https://github.com/ansible-collections/community.general/pull/5761)." + - "splunk callback plugin - adjust type of callback to ``notification``, it was incorrectly classified as ``aggregate`` before (https://github.com/ansible-collections/community.general/pull/5761)." + - "sumologic callback plugin - adjust type of callback to ``notification``, it was incorrectly classified as ``aggregate`` before (https://github.com/ansible-collections/community.general/pull/5761)." + - "syslog_json callback plugin - adjust type of callback to ``notification``, it was incorrectly classified as ``aggregate`` before (https://github.com/ansible-collections/community.general/pull/5761)." diff --git a/plugins/callback/loganalytics.py b/plugins/callback/loganalytics.py index 54acf846a3..8690aac934 100644 --- a/plugins/callback/loganalytics.py +++ b/plugins/callback/loganalytics.py @@ -8,7 +8,7 @@ __metaclass__ = type DOCUMENTATION = ''' name: loganalytics - type: aggregate + type: notification short_description: Posts task results to Azure Log Analytics author: "Cyrus Li (@zhcli) " description: @@ -155,7 +155,7 @@ class AzureLogAnalyticsSource(object): class CallbackModule(CallbackBase): CALLBACK_VERSION = 2.0 - CALLBACK_TYPE = 'aggregate' + CALLBACK_TYPE = 'notification' CALLBACK_NAME = 'loganalytics' CALLBACK_NEEDS_WHITELIST = True diff --git a/plugins/callback/logdna.py b/plugins/callback/logdna.py index ee0a1eb022..2d0880ce19 100644 --- a/plugins/callback/logdna.py +++ b/plugins/callback/logdna.py @@ -9,7 +9,7 @@ __metaclass__ = type DOCUMENTATION = ''' author: Unknown (!UNKNOWN) name: logdna - type: aggregate + type: notification short_description: Sends playbook logs to LogDNA description: - This callback will report logs from playbook actions, tasks, and events to LogDNA (https://app.logdna.com) @@ -111,7 +111,7 @@ def isJSONable(obj): class CallbackModule(CallbackBase): CALLBACK_VERSION = 0.1 - CALLBACK_TYPE = 'aggregate' + CALLBACK_TYPE = 'notification' CALLBACK_NAME = 'community.general.logdna' CALLBACK_NEEDS_WHITELIST = True diff --git a/plugins/callback/logstash.py b/plugins/callback/logstash.py index 5d3c1e50b8..7666b47876 100644 --- a/plugins/callback/logstash.py +++ b/plugins/callback/logstash.py @@ -113,7 +113,7 @@ from ansible.plugins.callback import CallbackBase class CallbackModule(CallbackBase): CALLBACK_VERSION = 2.0 - CALLBACK_TYPE = 'aggregate' + CALLBACK_TYPE = 'notification' CALLBACK_NAME = 'community.general.logstash' CALLBACK_NEEDS_WHITELIST = True diff --git a/plugins/callback/splunk.py b/plugins/callback/splunk.py index 701cbfdebd..32e77f4eb4 100644 --- a/plugins/callback/splunk.py +++ b/plugins/callback/splunk.py @@ -8,7 +8,7 @@ __metaclass__ = type DOCUMENTATION = ''' name: splunk - type: aggregate + type: notification short_description: Sends task result events to Splunk HTTP Event Collector author: "Stuart Hirst (!UNKNOWN) " description: @@ -165,7 +165,7 @@ class SplunkHTTPCollectorSource(object): class CallbackModule(CallbackBase): CALLBACK_VERSION = 2.0 - CALLBACK_TYPE = 'aggregate' + CALLBACK_TYPE = 'notification' CALLBACK_NAME = 'community.general.splunk' CALLBACK_NEEDS_WHITELIST = True diff --git a/plugins/callback/sumologic.py b/plugins/callback/sumologic.py index 0b6c9b6fee..6fd950d991 100644 --- a/plugins/callback/sumologic.py +++ b/plugins/callback/sumologic.py @@ -8,7 +8,7 @@ __metaclass__ = type DOCUMENTATION = ''' name: sumologic -type: aggregate +type: notification short_description: Sends task result events to Sumologic author: "Ryan Currah (@ryancurrah)" description: @@ -111,7 +111,7 @@ class SumologicHTTPCollectorSource(object): class CallbackModule(CallbackBase): CALLBACK_VERSION = 2.0 - CALLBACK_TYPE = 'aggregate' + CALLBACK_TYPE = 'notification' CALLBACK_NAME = 'community.general.sumologic' CALLBACK_NEEDS_WHITELIST = True diff --git a/plugins/callback/syslog_json.py b/plugins/callback/syslog_json.py index 7ca99a9edd..4b2c7e79b8 100644 --- a/plugins/callback/syslog_json.py +++ b/plugins/callback/syslog_json.py @@ -71,7 +71,7 @@ class CallbackModule(CallbackBase): """ CALLBACK_VERSION = 2.0 - CALLBACK_TYPE = 'aggregate' + CALLBACK_TYPE = 'notification' CALLBACK_NAME = 'community.general.syslog_json' CALLBACK_NEEDS_WHITELIST = True From 4dc897d559cd631554691a2a4d3d82e34325686c Mon Sep 17 00:00:00 2001 From: Eric C Chong Date: Thu, 5 Jan 2023 15:36:07 -0500 Subject: [PATCH 0103/1810] redhat_subscription: Add support for Red Hat API token (#5725) Add support for Red Hat API token fix mixed up fix version --- ...hat_subscription-add-red-hat-api-token.yml | 2 ++ plugins/modules/redhat_subscription.py | 24 ++++++++++---- .../modules/test_redhat_subscription.py | 31 +++++++++++++++++++ 3 files changed, 51 insertions(+), 6 deletions(-) create mode 100644 changelogs/fragments/5725-redhat_subscription-add-red-hat-api-token.yml diff --git a/changelogs/fragments/5725-redhat_subscription-add-red-hat-api-token.yml b/changelogs/fragments/5725-redhat_subscription-add-red-hat-api-token.yml new file mode 100644 index 0000000000..980e91ceb2 --- /dev/null +++ b/changelogs/fragments/5725-redhat_subscription-add-red-hat-api-token.yml @@ -0,0 +1,2 @@ +minor_changes: + - redhat_subscription - adds ``token`` parameter for subscription-manager authentication using Red Hat API token (https://github.com/ansible-collections/community.general/pull/5725). diff --git a/plugins/modules/redhat_subscription.py b/plugins/modules/redhat_subscription.py index 8836b78564..2649092e8a 100644 --- a/plugins/modules/redhat_subscription.py +++ b/plugins/modules/redhat_subscription.py @@ -40,6 +40,11 @@ options: description: - access.redhat.com or Red Hat Satellite or Katello password type: str + token: + description: + - sso.redhat.com API access token. + type: str + version_added: 6.3.0 server_hostname: description: - Specify an alternative Red Hat Subscription Management or Red Hat Satellite or Katello server @@ -294,10 +299,11 @@ class RegistrationBase(object): REDHAT_REPO = "/etc/yum.repos.d/redhat.repo" - def __init__(self, module, username=None, password=None): + def __init__(self, module, username=None, password=None, token=None): self.module = module self.username = username self.password = password + self.token = token def configure(self): raise NotImplementedError("Must be implemented by a sub-class") @@ -340,8 +346,8 @@ class RegistrationBase(object): class Rhsm(RegistrationBase): - def __init__(self, module, username=None, password=None): - RegistrationBase.__init__(self, module, username, password) + def __init__(self, module, username=None, password=None, token=None): + RegistrationBase.__init__(self, module, username, password, token) self.module = module def enable(self): @@ -397,7 +403,7 @@ class Rhsm(RegistrationBase): else: return False - def register(self, username, password, auto_attach, activationkey, org_id, + def register(self, username, password, token, auto_attach, activationkey, org_id, consumer_type, consumer_name, consumer_id, force_register, environment, release): ''' @@ -433,6 +439,8 @@ class Rhsm(RegistrationBase): if activationkey: args.extend(['--activationkey', activationkey]) + elif token: + args.extend(['--token', token]) else: if username: args.extend(['--username', username]) @@ -794,6 +802,7 @@ def main(): 'state': {'default': 'present', 'choices': ['present', 'absent']}, 'username': {}, 'password': {'no_log': True}, + 'token': {'no_log': True}, 'server_hostname': {}, 'server_insecure': {}, 'server_prefix': {}, @@ -831,17 +840,20 @@ def main(): ['server_proxy_hostname', 'server_proxy_port'], ['server_proxy_user', 'server_proxy_password']], mutually_exclusive=[['activationkey', 'username'], + ['activationkey', 'token'], + ['token', 'username'], ['activationkey', 'consumer_id'], ['activationkey', 'environment'], ['activationkey', 'auto_attach'], ['pool', 'pool_ids']], - required_if=[['state', 'present', ['username', 'activationkey'], True]], + required_if=[['state', 'present', ['username', 'activationkey', 'token'], True]], ) rhsm.module = module state = module.params['state'] username = module.params['username'] password = module.params['password'] + token = module.params['token'] server_hostname = module.params['server_hostname'] server_insecure = module.params['server_insecure'] server_prefix = module.params['server_prefix'] @@ -914,7 +926,7 @@ def main(): try: rhsm.enable() rhsm.configure(**module.params) - rhsm.register(username, password, auto_attach, activationkey, org_id, + rhsm.register(username, password, token, auto_attach, activationkey, org_id, consumer_type, consumer_name, consumer_id, force_register, environment, release) if syspurpose and 'sync' in syspurpose and syspurpose['sync'] is True: diff --git a/tests/unit/plugins/modules/test_redhat_subscription.py b/tests/unit/plugins/modules/test_redhat_subscription.py index 865f041141..e3f4cdd812 100644 --- a/tests/unit/plugins/modules/test_redhat_subscription.py +++ b/tests/unit/plugins/modules/test_redhat_subscription.py @@ -102,6 +102,37 @@ TEST_CASES = [ 'msg': "System successfully registered to 'satellite.company.com'." } ], + # Test simple registration using token + [ + { + 'state': 'present', + 'server_hostname': 'satellite.company.com', + 'token': 'fake_token', + }, + { + 'id': 'test_registeration_token', + 'run_command.calls': [ + ( + ['/testbin/subscription-manager', 'identity'], + {'check_rc': False}, + (1, '', '') + ), + ( + ['/testbin/subscription-manager', 'config', '--server.hostname=satellite.company.com'], + {'check_rc': True}, + (0, '', '') + ), + ( + ['/testbin/subscription-manager', 'register', + '--token', 'fake_token'], + {'check_rc': True, 'expand_user_and_vars': False}, + (0, '', '') + ) + ], + 'changed': True, + 'msg': "System successfully registered to 'satellite.company.com'." + } + ], # Test unregistration, when system is unregistered [ { From 217a62aca2aa673708621d1c963def9e068681e0 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Sat, 7 Jan 2023 01:34:39 +1300 Subject: [PATCH 0104/1810] consul: minor fixes in docs (#5767) * consul: minor fixes in docs * additional docs fixes * adjustments from review --- plugins/modules/consul.py | 57 ++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/plugins/modules/consul.py b/plugins/modules/consul.py index aabc1bd4b7..ea329254a1 100644 --- a/plugins/modules/consul.py +++ b/plugins/modules/consul.py @@ -23,7 +23,7 @@ description: by Consul from the Service name and id respectively by appending 'service:' Node level checks require a I(check_name) and optionally a I(check_id)." - Currently, there is no complete way to retrieve the script, interval or ttl - metadata for a registered check. Without this metadata it is not possible to + metadata for a registered check. Without this metadata it is not possible to tell if the data supplied with ansible represents a change to a check. As a result this does not attempt to determine changes and will always report a changed occurred. An API method is planned to supply this metadata so at that @@ -37,7 +37,7 @@ options: state: type: str description: - - register or deregister the consul service, defaults to present + - Register or deregister the consul service, defaults to present. default: present choices: ['present', 'absent'] service_name: @@ -45,30 +45,30 @@ options: description: - Unique name for the service on a node, must be unique per node, required if registering a service. May be omitted if registering - a node level check + a node level check. service_id: type: str description: - - the ID for the service, must be unique per node. If I(state=absent), + - The ID for the service, must be unique per node. If I(state=absent), defaults to the service name if supplied. host: type: str description: - - host of the consul agent defaults to localhost + - Host of the consul agent defaults to localhost. default: localhost port: type: int description: - - the port on which the consul agent is running + - The port on which the consul agent is running. default: 8500 scheme: type: str description: - - the protocol scheme on which the consul agent is running + - The protocol scheme on which the consul agent is running. default: http validate_certs: description: - - whether to verify the TLS certificate of the consul agent + - Whether to verify the TLS certificate of the consul agent. type: bool default: true notes: @@ -78,12 +78,12 @@ options: service_port: type: int description: - - the port on which the service is listening. Can optionally be supplied for - registration of a service, i.e. if I(service_name) or I(service_id) is set + - The port on which the service is listening. Can optionally be supplied for + registration of a service, i.e. if I(service_name) or I(service_id) is set. service_address: type: str description: - - the address to advertise that the service will be listening on. + - The address to advertise that the service will be listening on. This value will be passed as the I(address) parameter to Consul's C(/v1/agent/service/register) API method, so refer to the Consul API documentation for further details. @@ -91,63 +91,64 @@ options: type: list elements: str description: - - tags that will be attached to the service registration. + - Tags that will be attached to the service registration. script: type: str description: - - the script/command that will be run periodically to check the health - of the service. Scripts require I(interval) and vice versa. + - The script/command that will be run periodically to check the health of the service. + - Requires I(interval) to be provided. interval: type: str description: - - the interval at which the service check will be run. This is a number - with a s or m suffix to signify the units of seconds or minutes e.g - C(15s) or C(1m). If no suffix is supplied, m will be used by default e.g. - C(1) will be C(1m). Required if the I(script) parameter is specified. + - The interval at which the service check will be run. + This is a number with a C(s) or C(m) suffix to signify the units of seconds or minutes e.g C(15s) or C(1m). + If no suffix is supplied C(s) will be used by default, e.g. C(10) will be C(10s). + - Required if one of the parameters I(script), I(http), or I(tcp) is specified. check_id: type: str description: - - an ID for the service check. If I(state=absent), defaults to + - An ID for the service check. If I(state=absent), defaults to I(check_name). Ignored if part of a service definition. check_name: type: str description: - - a name for the service check. Required if standalone, ignored if + - Name for the service check. Required if standalone, ignored if part of service definition. ttl: type: str description: - - checks can be registered with a ttl instead of a I(script) and I(interval) + - Checks can be registered with a ttl instead of a I(script) and I(interval) this means that the service will check in with the agent before the ttl expires. If it doesn't the check will be considered failed. Required if registering a check and the script an interval are missing - Similar to the interval this is a number with a s or m suffix to - signify the units of seconds or minutes e.g C(15s) or C(1m). If no suffix - is supplied, C(m) will be used by default e.g. C(1) will be C(1m) + Similar to the interval this is a number with a C(s) or C(m) suffix to + signify the units of seconds or minutes e.g C(15s) or C(1m). + If no suffix is supplied C(s) will be used by default, e.g. C(10) will be C(10s). tcp: type: str description: - Checks can be registered with a TCP port. This means that consul will check if the connection attempt to that port is successful (that is, the port is currently accepting connections). The format is C(host:port), for example C(localhost:80). - I(interval) must also be provided with this option. + - Requires I(interval) to be provided. version_added: '1.3.0' http: type: str description: - - checks can be registered with an HTTP endpoint. This means that consul + - Checks can be registered with an HTTP endpoint. This means that consul will check that the http endpoint returns a successful HTTP status. - I(interval) must also be provided with this option. + - Requires I(interval) to be provided. timeout: type: str description: - A custom HTTP check timeout. The consul default is 10 seconds. Similar to the interval this is a number with a C(s) or C(m) suffix to signify the units of seconds or minutes, e.g. C(15s) or C(1m). + If no suffix is supplied C(s) will be used by default, e.g. C(10) will be C(10s). token: type: str description: - - the token key identifying an ACL rule set. May be required to register services. + - The token key identifying an ACL rule set. May be required to register services. ''' EXAMPLES = ''' From 02431341b7ecf24432f4082a6005721c624ae550 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Sat, 7 Jan 2023 22:20:19 +1300 Subject: [PATCH 0105/1810] snap: use MH execute() static method (#5773) * use MH execute() static method * add changelog fragment --- changelogs/fragments/5773-snap-mh-execute.yml | 2 ++ plugins/modules/snap.py | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/5773-snap-mh-execute.yml diff --git a/changelogs/fragments/5773-snap-mh-execute.yml b/changelogs/fragments/5773-snap-mh-execute.yml new file mode 100644 index 0000000000..43b9b6a1ac --- /dev/null +++ b/changelogs/fragments/5773-snap-mh-execute.yml @@ -0,0 +1,2 @@ +minor_changes: + - snap - minor refactor when executing module (https://github.com/ansible-collections/community.general/pull/5773). diff --git a/plugins/modules/snap.py b/plugins/modules/snap.py index a432504472..1b5e27071a 100644 --- a/plugins/modules/snap.py +++ b/plugins/modules/snap.py @@ -399,8 +399,7 @@ class Snap(CmdStateModuleHelper): def main(): - snap = Snap() - snap.run() + Snap.execute() if __name__ == '__main__': From dc531b183d2f1b48378ddfd3dd976e067bc02eb6 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Sat, 7 Jan 2023 22:21:13 +1300 Subject: [PATCH 0106/1810] ModuleHelper - lax handling of conflicting output (#5765) * ModuleHelper - lax handling of conflicting output * add changelog fragment * only create _var when really needed * adjust changelog * Update changelogs/fragments/5765-mh-lax-output-conflict.yml Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein --- .../fragments/5765-mh-lax-output-conflict.yml | 9 ++++++ plugins/module_utils/mh/deco.py | 17 +++++++++-- plugins/module_utils/mh/module_helper.py | 5 ---- .../targets/module_helper/library/msimple.py | 5 ++-- .../tasks/msimple_output_conflict.yml | 29 +++++++++++++++++-- 5 files changed, 52 insertions(+), 13 deletions(-) create mode 100644 changelogs/fragments/5765-mh-lax-output-conflict.yml diff --git a/changelogs/fragments/5765-mh-lax-output-conflict.yml b/changelogs/fragments/5765-mh-lax-output-conflict.yml new file mode 100644 index 0000000000..2e8cc292bd --- /dev/null +++ b/changelogs/fragments/5765-mh-lax-output-conflict.yml @@ -0,0 +1,9 @@ +breaking_changes: + - > + ModuleHelper module utils - when the module sets output variables named ``msg``, ``exception``, ``output``, ``vars``, or ``changed``, + the actual output will prefix those names with ``_`` (underscore symbol) only when they clash with output variables generated by ModuleHelper + itself, which only occurs when handling exceptions. Please note that this breaking + change does not require a new major release since before this release, it was not possible + to add such variables to the output + `due to a bug `__ + (https://github.com/ansible-collections/community.general/pull/5765). diff --git a/plugins/module_utils/mh/deco.py b/plugins/module_utils/mh/deco.py index 3073e4e9e7..5138b212c7 100644 --- a/plugins/module_utils/mh/deco.py +++ b/plugins/module_utils/mh/deco.py @@ -37,8 +37,17 @@ def cause_changes(on_success=None, on_failure=None): def module_fails_on_exception(func): + conflict_list = ('msg', 'exception', 'output', 'vars', 'changed') + @wraps(func) def wrapper(self, *args, **kwargs): + def fix_var_conflicts(output): + result = dict([ + (k if k not in conflict_list else "_" + k, v) + for k, v in output.items() + ]) + return result + try: func(self, *args, **kwargs) except SystemExit: @@ -46,12 +55,16 @@ def module_fails_on_exception(func): except ModuleHelperException as e: if e.update_output: self.update_output(e.update_output) + # patchy solution to resolve conflict with output variables + output = fix_var_conflicts(self.output) self.module.fail_json(msg=e.msg, exception=traceback.format_exc(), - output=self.output, vars=self.vars.output(), **self.output) + output=self.output, vars=self.vars.output(), **output) except Exception as e: + # patchy solution to resolve conflict with output variables + output = fix_var_conflicts(self.output) msg = "Module failed with exception: {0}".format(str(e).strip()) self.module.fail_json(msg=msg, exception=traceback.format_exc(), - output=self.output, vars=self.vars.output(), **self.output) + output=self.output, vars=self.vars.output(), **output) return wrapper diff --git a/plugins/module_utils/mh/module_helper.py b/plugins/module_utils/mh/module_helper.py index 51696b6ff6..6813b5454b 100644 --- a/plugins/module_utils/mh/module_helper.py +++ b/plugins/module_utils/mh/module_helper.py @@ -18,7 +18,6 @@ from ansible_collections.community.general.plugins.module_utils.mh.mixins.deprec class ModuleHelper(DeprecateAttrsMixin, VarsMixin, DependencyMixin, ModuleHelperBase): - _output_conflict_list = ('msg', 'exception', 'output', 'vars', 'changed') facts_name = None output_params = () diff_params = () @@ -60,10 +59,6 @@ class ModuleHelper(DeprecateAttrsMixin, VarsMixin, DependencyMixin, ModuleHelper vars_diff = self.vars.diff() or {} result['diff'] = dict_merge(dict(diff), vars_diff) - for varname in list(result): - if varname in self._output_conflict_list: - result["_" + varname] = result[varname] - del result[varname] return result diff --git a/tests/integration/targets/module_helper/library/msimple.py b/tests/integration/targets/module_helper/library/msimple.py index 3729b6c702..096e515247 100644 --- a/tests/integration/targets/module_helper/library/msimple.py +++ b/tests/integration/targets/module_helper/library/msimple.py @@ -57,6 +57,8 @@ class MSimple(ModuleHelper): self.vars['c'] = str(self.vars.c) * 3 def __run__(self): + if self.vars.m: + self.vars.msg = self.vars.m if self.vars.a >= 100: raise Exception("a >= 100") if self.vars.c == "abc change": @@ -66,9 +68,6 @@ class MSimple(ModuleHelper): self.vars['c'] = str(self.vars.c) * 2 self.process_a3_bc() - if self.vars.m: - self.vars.msg = self.vars.m - def main(): msimple = MSimple() diff --git a/tests/integration/targets/module_helper/tasks/msimple_output_conflict.yml b/tests/integration/targets/module_helper/tasks/msimple_output_conflict.yml index 21ffd37d35..55e0a06eca 100644 --- a/tests/integration/targets/module_helper/tasks/msimple_output_conflict.yml +++ b/tests/integration/targets/module_helper/tasks/msimple_output_conflict.yml @@ -2,7 +2,7 @@ # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) # SPDX-License-Identifier: GPL-3.0-or-later -- name: test msimple (set a=80) +- name: test msimple conflict output (set a=80) msimple: a: 80 register: simple1 @@ -15,7 +15,7 @@ - simple1 is not changed - simple1.value is none -- name: test msimple 2 +- name: test msimple conflict output 2 msimple: a: 80 m: a message in a bottle @@ -28,4 +28,27 @@ - simple1.abc == "abc" - simple1 is not changed - simple1.value is none - - 'simple2._msg == "a message in a bottle"' + - > + "_msg" not in simple2 + - > + simple2.msg == "a message in a bottle" + +- name: test msimple 3 + msimple: + a: 101 + m: a message in a bottle + ignore_errors: yes + register: simple3 + +- name: assert simple3 + assert: + that: + - simple3.a == 101 + - > + simple3.msg == "Module failed with exception: a >= 100" + - > + simple3._msg == "a message in a bottle" + - simple3.abc == "abc" + - simple3 is failed + - simple3 is not changed + - simple3.value is none From fc2b1aac4aca701f3e87706266ac2e32a905d9fe Mon Sep 17 00:00:00 2001 From: Teodor Janez Podobnik <48418580+dorkamotorka@users.noreply.github.com> Date: Sat, 7 Jan 2023 10:24:32 +0100 Subject: [PATCH 0107/1810] terraform: bugfix: init command when default workspace doesn't exists (#5735) * feat: init when default workspace doesn't exists * doc: add changelogs fragment and docs update * fix: changelog formating fix --- ...init-fix-when-default-workspace-doesnt-exists.yaml | 3 +++ plugins/modules/terraform.py | 11 +++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/5735-terraform-init-fix-when-default-workspace-doesnt-exists.yaml diff --git a/changelogs/fragments/5735-terraform-init-fix-when-default-workspace-doesnt-exists.yaml b/changelogs/fragments/5735-terraform-init-fix-when-default-workspace-doesnt-exists.yaml new file mode 100644 index 0000000000..3ec348aed9 --- /dev/null +++ b/changelogs/fragments/5735-terraform-init-fix-when-default-workspace-doesnt-exists.yaml @@ -0,0 +1,3 @@ +bugfixes: + - terraform - fix ``current`` workspace never getting appended to the ``all`` key in the ``workspace_ctf`` object (https://github.com/ansible-collections/community.general/pull/5735). + - terraform - fix ``terraform init`` failure when there are multiple workspaces on the remote backend and when ``default`` workspace is missing by setting ``TF_WORKSPACE`` environmental variable to the value of ``workspace`` when used (https://github.com/ansible-collections/community.general/pull/5735). diff --git a/plugins/modules/terraform.py b/plugins/modules/terraform.py index 615c125cf3..2a018ea03c 100644 --- a/plugins/modules/terraform.py +++ b/plugins/modules/terraform.py @@ -48,7 +48,9 @@ options: version_added: 3.0.0 workspace: description: - - The terraform workspace to work with. + - The terraform workspace to work with. This sets the C(TF_WORKSPACE) environmental variable + that is used to override workspace selection. For more information about workspaces + have a look at U(https://developer.hashicorp.com/terraform/language/state/workspaces). type: str default: default purge_workspace: @@ -310,7 +312,7 @@ def _state_args(state_file): return [] -def init_plugins(bin_path, project_path, backend_config, backend_config_files, init_reconfigure, provider_upgrade, plugin_paths): +def init_plugins(bin_path, project_path, backend_config, backend_config_files, init_reconfigure, provider_upgrade, plugin_paths, workspace): command = [bin_path, 'init', '-input=false', '-no-color'] if backend_config: for key, val in backend_config.items(): @@ -328,7 +330,7 @@ def init_plugins(bin_path, project_path, backend_config, backend_config_files, i if plugin_paths: for plugin_path in plugin_paths: command.extend(['-plugin-dir', plugin_path]) - rc, out, err = module.run_command(command, check_rc=True, cwd=project_path) + rc, out, err = module.run_command(command, check_rc=True, cwd=project_path, environ_update={"TF_WORKSPACE": workspace}) def get_workspace_context(bin_path, project_path): @@ -343,6 +345,7 @@ def get_workspace_context(bin_path, project_path): continue elif stripped_item.startswith('* '): workspace_ctx["current"] = stripped_item.replace('* ', '') + workspace_ctx["all"].append(stripped_item.replace('* ', '')) else: workspace_ctx["all"].append(stripped_item) return workspace_ctx @@ -485,7 +488,7 @@ def main(): if force_init: if overwrite_init or not os.path.isfile(os.path.join(project_path, ".terraform", "terraform.tfstate")): - init_plugins(command[0], project_path, backend_config, backend_config_files, init_reconfigure, provider_upgrade, plugin_paths) + init_plugins(command[0], project_path, backend_config, backend_config_files, init_reconfigure, provider_upgrade, plugin_paths, workspace) workspace_ctx = get_workspace_context(command[0], project_path) if workspace_ctx["current"] != workspace: From e3f02cb161b7bf351ebab9335b31056a6125348b Mon Sep 17 00:00:00 2001 From: reverendj1 Date: Sat, 7 Jan 2023 04:28:05 -0500 Subject: [PATCH 0108/1810] Add Support to Bitwarden Lookup for Custom Fields (#5694) * Add Support to Bitwarden Lookup for Custom Fields This adds support to the Bitwarden lookup for retrieving values from custom fields, such as api keys. * Need to Return Whole Record if Field is Not Defined * whitespace * Add Changelog Fragment * Need to Make Sure All Login Fields are Represented We need to make sure that all login fields are accounted for, since there will be no other way to retrieve them with this change, and we don't want to break backwards compatibility. Looking at this code from the official client, https://github.com/bitwarden/clients/blob/master/libs/common/spec/models/domain/login.spec.ts, autofillOnPageLoad might be another login field. * Update changelogs/fragments/5694-add-custom-fields-to-bitwarden.yml Clarify changelog fragment Co-authored-by: Felix Fontein * Update plugins/lookup/bitwarden.py Fix logic. Should only error if matches were found, but are missing the custom field. Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein --- .../5694-add-custom-fields-to-bitwarden.yml | 2 ++ plugins/lookup/bitwarden.py | 20 ++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/5694-add-custom-fields-to-bitwarden.yml diff --git a/changelogs/fragments/5694-add-custom-fields-to-bitwarden.yml b/changelogs/fragments/5694-add-custom-fields-to-bitwarden.yml new file mode 100644 index 0000000000..55006f06a9 --- /dev/null +++ b/changelogs/fragments/5694-add-custom-fields-to-bitwarden.yml @@ -0,0 +1,2 @@ +minor_changes: + - bitwarden lookup plugin - can now retrieve secrets from custom fields (https://github.com/ansible-collections/community.general/pull/5694). diff --git a/plugins/lookup/bitwarden.py b/plugins/lookup/bitwarden.py index 1cc2e44c74..dbcb88d456 100644 --- a/plugins/lookup/bitwarden.py +++ b/plugins/lookup/bitwarden.py @@ -47,6 +47,11 @@ EXAMPLES = """ ansible.builtin.debug: msg: >- {{ lookup('community.general.bitwarden', 'a_test') }} + +- name: "Get custom field 'api_key' from Bitwarden record named 'a_test'" + ansible.builtin.debug: + msg: >- + {{ lookup('community.general.bitwarden', 'a_test', field='api_key') }} """ RETURN = """ @@ -109,10 +114,19 @@ class Bitwarden(object): """ matches = self._get_matches(search_value, search_field) - if field: + if field in ['autofillOnPageLoad', 'password', 'passwordRevisionDate', 'totp', 'uris', 'username']: return [match['login'][field] for match in matches] - - return matches + elif not field: + return matches + else: + custom_field_matches = [] + for match in matches: + for custom_field in match['fields']: + if custom_field['name'] == field: + custom_field_matches.append(custom_field['value']) + if matches and not custom_field_matches: + raise AnsibleError("Custom field {field} does not exist in {search_value}".format(field=field, search_value=search_value)) + return custom_field_matches class LookupModule(LookupBase): From 2670215c8ad6b18aac2220e1261818ed7f5f45cb Mon Sep 17 00:00:00 2001 From: rietvelde <99407273+rietvelde@users.noreply.github.com> Date: Sat, 7 Jan 2023 10:31:50 +0100 Subject: [PATCH 0109/1810] Fix gem.py, hang on uninstall specific gem version (#5751) * Update gem.py move 'cmd.append('--executable')' to all uninstalls rather than only all versions * Create 5751-gem-fix-uninstall-hang * Rename 5751-gem-fix-uninstall-hang to 5751-gem-fix-uninstall-hang.yml --- changelogs/fragments/5751-gem-fix-uninstall-hang.yml | 2 ++ plugins/modules/gem.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/5751-gem-fix-uninstall-hang.yml diff --git a/changelogs/fragments/5751-gem-fix-uninstall-hang.yml b/changelogs/fragments/5751-gem-fix-uninstall-hang.yml new file mode 100644 index 0000000000..3fdd0056de --- /dev/null +++ b/changelogs/fragments/5751-gem-fix-uninstall-hang.yml @@ -0,0 +1,2 @@ +bugfixes: + - gem - fix hang due to interactive prompt for confirmation on specific version uninstall (https://github.com/ansible-collections/community.general/pull/5751). diff --git a/plugins/modules/gem.py b/plugins/modules/gem.py index 8d7f7dade0..21e9efea58 100644 --- a/plugins/modules/gem.py +++ b/plugins/modules/gem.py @@ -234,7 +234,7 @@ def uninstall(module): cmd.extend(['--version', module.params['version']]) else: cmd.append('--all') - cmd.append('--executable') + cmd.append('--executable') cmd.append(module.params['name']) module.run_command(cmd, environ_update=environ, check_rc=True) From 9e3a729da9599aa2751a7ed0afb4bf68401ab400 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 7 Jan 2023 11:03:58 +0100 Subject: [PATCH 0110/1810] Improve callback docs (#5760) * Improve callback docs. * Apply suggestions from code review Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> * Update plugins/callback/logentries.py Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> * More improvements. Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> --- plugins/callback/cgroup_memory_recap.py | 12 ++++++------ plugins/callback/context_demo.py | 4 ++-- plugins/callback/counter_enabled.py | 2 +- plugins/callback/dense.py | 2 +- plugins/callback/jabber.py | 4 ++-- plugins/callback/log_plays.py | 4 ++-- plugins/callback/logdna.py | 12 ++++++------ plugins/callback/logentries.py | 18 +++++++++--------- plugins/callback/logstash.py | 12 ++++++------ plugins/callback/null.py | 2 +- plugins/callback/say.py | 6 +++--- plugins/callback/selective.py | 2 +- plugins/callback/slack.py | 6 +++--- plugins/callback/splunk.py | 10 +++++----- plugins/callback/sumologic.py | 6 +++--- plugins/callback/syslog_json.py | 10 +++++----- plugins/callback/yaml.py | 2 +- 17 files changed, 57 insertions(+), 57 deletions(-) diff --git a/plugins/callback/cgroup_memory_recap.py b/plugins/callback/cgroup_memory_recap.py index eedacfeecb..ccdbcc9cf0 100644 --- a/plugins/callback/cgroup_memory_recap.py +++ b/plugins/callback/cgroup_memory_recap.py @@ -16,15 +16,15 @@ DOCUMENTATION = ''' - cgroups short_description: Profiles maximum memory usage of tasks and full execution using cgroups description: - - This is an ansible callback plugin that profiles maximum memory usage of ansible and individual tasks, and displays a recap at the end using cgroups + - This is an ansible callback plugin that profiles maximum memory usage of ansible and individual tasks, and displays a recap at the end using cgroups. notes: - - Requires ansible to be run from within a cgroup, such as with C(cgexec -g memory:ansible_profile ansible-playbook ...) - - This cgroup should only be used by ansible to get accurate results - - To create the cgroup, first use a command such as C(sudo cgcreate -a ec2-user:ec2-user -t ec2-user:ec2-user -g memory:ansible_profile) + - Requires ansible to be run from within a cgroup, such as with C(cgexec -g memory:ansible_profile ansible-playbook ...). + - This cgroup should only be used by ansible to get accurate results. + - To create the cgroup, first use a command such as C(sudo cgcreate -a ec2-user:ec2-user -t ec2-user:ec2-user -g memory:ansible_profile). options: max_mem_file: required: true - description: Path to cgroups C(memory.max_usage_in_bytes) file. Example C(/sys/fs/cgroup/memory/ansible_profile/memory.max_usage_in_bytes) + description: Path to cgroups C(memory.max_usage_in_bytes) file. Example C(/sys/fs/cgroup/memory/ansible_profile/memory.max_usage_in_bytes). env: - name: CGROUP_MAX_MEM_FILE ini: @@ -32,7 +32,7 @@ DOCUMENTATION = ''' key: max_mem_file cur_mem_file: required: true - description: Path to C(memory.usage_in_bytes) file. Example C(/sys/fs/cgroup/memory/ansible_profile/memory.usage_in_bytes) + description: Path to C(memory.usage_in_bytes) file. Example C(/sys/fs/cgroup/memory/ansible_profile/memory.usage_in_bytes). env: - name: CGROUP_CUR_MEM_FILE ini: diff --git a/plugins/callback/context_demo.py b/plugins/callback/context_demo.py index 9c3c9c5afc..b9558fc064 100644 --- a/plugins/callback/context_demo.py +++ b/plugins/callback/context_demo.py @@ -13,8 +13,8 @@ DOCUMENTATION = ''' type: aggregate short_description: demo callback that adds play/task context description: - - Displays some play and task context along with normal output - - This is mostly for demo purposes + - Displays some play and task context along with normal output. + - This is mostly for demo purposes. requirements: - whitelist in configuration ''' diff --git a/plugins/callback/counter_enabled.py b/plugins/callback/counter_enabled.py index e0e040c9d4..555ebd29a6 100644 --- a/plugins/callback/counter_enabled.py +++ b/plugins/callback/counter_enabled.py @@ -21,7 +21,7 @@ DOCUMENTATION = ''' extends_documentation_fragment: - default_callback requirements: - - set as stdout callback in ansible.cfg (stdout_callback = counter_enabled) + - set as stdout callback in C(ansible.cfg) (C(stdout_callback = counter_enabled)) ''' from ansible import constants as C diff --git a/plugins/callback/dense.py b/plugins/callback/dense.py index 18e4f162ff..490705fd27 100644 --- a/plugins/callback/dense.py +++ b/plugins/callback/dense.py @@ -14,7 +14,7 @@ short_description: minimal stdout output extends_documentation_fragment: - default_callback description: -- When in verbose mode it will act the same as the default callback +- When in verbose mode it will act the same as the default callback. author: - Dag Wieers (@dagwieers) requirements: diff --git a/plugins/callback/jabber.py b/plugins/callback/jabber.py index 823ae20144..d2d00496d8 100644 --- a/plugins/callback/jabber.py +++ b/plugins/callback/jabber.py @@ -13,10 +13,10 @@ DOCUMENTATION = ''' type: notification short_description: post task events to a jabber server description: - - The chatty part of ChatOps with a Hipchat server as a target + - The chatty part of ChatOps with a Hipchat server as a target. - This callback plugin sends status updates to a HipChat channel during playbook execution. requirements: - - xmpp (python lib https://github.com/ArchipelProject/xmpppy) + - xmpp (Python library U(https://github.com/ArchipelProject/xmpppy)) options: server: description: connection info to jabber server diff --git a/plugins/callback/log_plays.py b/plugins/callback/log_plays.py index b1dc69364c..e99054e176 100644 --- a/plugins/callback/log_plays.py +++ b/plugins/callback/log_plays.py @@ -13,10 +13,10 @@ DOCUMENTATION = ''' type: notification short_description: write playbook output to log file description: - - This callback writes playbook output to a file per host in the C(/var/log/ansible/hosts) directory + - This callback writes playbook output to a file per host in the C(/var/log/ansible/hosts) directory. requirements: - Whitelist in configuration - - A writeable /var/log/ansible/hosts directory by the user executing Ansible on the controller + - A writeable C(/var/log/ansible/hosts) directory by the user executing Ansible on the controller options: log_folder: default: /var/log/ansible/hosts diff --git a/plugins/callback/logdna.py b/plugins/callback/logdna.py index 2d0880ce19..fc9a81ac8a 100644 --- a/plugins/callback/logdna.py +++ b/plugins/callback/logdna.py @@ -12,14 +12,14 @@ DOCUMENTATION = ''' type: notification short_description: Sends playbook logs to LogDNA description: - - This callback will report logs from playbook actions, tasks, and events to LogDNA (https://app.logdna.com) + - This callback will report logs from playbook actions, tasks, and events to LogDNA (U(https://app.logdna.com)). requirements: - - LogDNA Python Library (https://github.com/logdna/python) + - LogDNA Python Library (U(https://github.com/logdna/python)) - whitelisting in configuration options: conf_key: required: true - description: LogDNA Ingestion Key + description: LogDNA Ingestion Key. type: string env: - name: LOGDNA_INGESTION_KEY @@ -28,7 +28,7 @@ DOCUMENTATION = ''' key: conf_key plugin_ignore_errors: required: false - description: Whether to ignore errors on failing or not + description: Whether to ignore errors on failing or not. type: boolean env: - name: ANSIBLE_IGNORE_ERRORS @@ -38,7 +38,7 @@ DOCUMENTATION = ''' default: false conf_hostname: required: false - description: Alternative Host Name; the current host name by default + description: Alternative Host Name; the current host name by default. type: string env: - name: LOGDNA_HOSTNAME @@ -47,7 +47,7 @@ DOCUMENTATION = ''' key: conf_hostname conf_tags: required: false - description: Tags + description: Tags. type: string env: - name: LOGDNA_TAGS diff --git a/plugins/callback/logentries.py b/plugins/callback/logentries.py index d40939b0ab..22322a4df2 100644 --- a/plugins/callback/logentries.py +++ b/plugins/callback/logentries.py @@ -13,15 +13,15 @@ DOCUMENTATION = ''' short_description: Sends events to Logentries description: - This callback plugin will generate JSON objects and send them to Logentries via TCP for auditing/debugging purposes. - - Before 2.4, if you wanted to use an ini configuration, the file must be placed in the same directory as this plugin and named logentries.ini + - Before 2.4, if you wanted to use an ini configuration, the file must be placed in the same directory as this plugin and named C(logentries.ini). - In 2.4 and above you can just put it in the main Ansible configuration file. requirements: - whitelisting in configuration - - certifi (python library) - - flatdict (python library), if you want to use the 'flatten' option + - certifi (Python library) + - flatdict (Python library), if you want to use the 'flatten' option options: api: - description: URI to the Logentries API + description: URI to the Logentries API. env: - name: LOGENTRIES_API default: data.logentries.com @@ -29,7 +29,7 @@ DOCUMENTATION = ''' - section: callback_logentries key: api port: - description: HTTP port to use when connecting to the API + description: HTTP port to use when connecting to the API. env: - name: LOGENTRIES_PORT default: 80 @@ -37,7 +37,7 @@ DOCUMENTATION = ''' - section: callback_logentries key: port tls_port: - description: Port to use when connecting to the API when TLS is enabled + description: Port to use when connecting to the API when TLS is enabled. env: - name: LOGENTRIES_TLS_PORT default: 443 @@ -45,7 +45,7 @@ DOCUMENTATION = ''' - section: callback_logentries key: tls_port token: - description: The logentries "TCP token" + description: The logentries C(TCP token). env: - name: LOGENTRIES_ANSIBLE_TOKEN required: true @@ -54,7 +54,7 @@ DOCUMENTATION = ''' key: token use_tls: description: - - Toggle to decide whether to use TLS to encrypt the communications with the API server + - Toggle to decide whether to use TLS to encrypt the communications with the API server. env: - name: LOGENTRIES_USE_TLS default: false @@ -63,7 +63,7 @@ DOCUMENTATION = ''' - section: callback_logentries key: use_tls flatten: - description: flatten complex data structures into a single dictionary with complex keys + description: Flatten complex data structures into a single dictionary with complex keys. type: boolean default: false env: diff --git a/plugins/callback/logstash.py b/plugins/callback/logstash.py index 7666b47876..144e1f9915 100644 --- a/plugins/callback/logstash.py +++ b/plugins/callback/logstash.py @@ -13,13 +13,13 @@ DOCUMENTATION = r''' type: notification short_description: Sends events to Logstash description: - - This callback will report facts and task events to Logstash https://www.elastic.co/products/logstash + - This callback will report facts and task events to Logstash U(https://www.elastic.co/products/logstash). requirements: - whitelisting in configuration - - logstash (python library) + - logstash (Python library) options: server: - description: Address of the Logstash server + description: Address of the Logstash server. env: - name: LOGSTASH_SERVER ini: @@ -28,7 +28,7 @@ DOCUMENTATION = r''' version_added: 1.0.0 default: localhost port: - description: Port on which logstash is listening + description: Port on which logstash is listening. env: - name: LOGSTASH_PORT ini: @@ -37,7 +37,7 @@ DOCUMENTATION = r''' version_added: 1.0.0 default: 5000 type: - description: Message type + description: Message type. env: - name: LOGSTASH_TYPE ini: @@ -54,7 +54,7 @@ DOCUMENTATION = r''' env: - name: LOGSTASH_PRE_COMMAND format_version: - description: Logging format + description: Logging format. type: str version_added: 2.0.0 ini: diff --git a/plugins/callback/null.py b/plugins/callback/null.py index 01f5f6ca06..f53a242945 100644 --- a/plugins/callback/null.py +++ b/plugins/callback/null.py @@ -15,7 +15,7 @@ DOCUMENTATION = ''' - set as main display callback short_description: Don't display stuff to screen description: - - This callback prevents outputing events to screen + - This callback prevents outputing events to screen. ''' from ansible.plugins.callback import CallbackBase diff --git a/plugins/callback/say.py b/plugins/callback/say.py index 03d7060352..005725a22b 100644 --- a/plugins/callback/say.py +++ b/plugins/callback/say.py @@ -14,12 +14,12 @@ DOCUMENTATION = ''' type: notification requirements: - whitelisting in configuration - - the '/usr/bin/say' command line program (standard on macOS) or 'espeak' command line program + - the C(/usr/bin/say) command line program (standard on macOS) or C(espeak) command line program short_description: notify using software speech synthesizer description: - - This plugin will use the 'say' or 'espeak' program to "speak" about play events. + - This plugin will use the C(say) or C(espeak) program to "speak" about play events. notes: - - In 2.8, this callback has been renamed from C(osx_say) into M(community.general.say). + - In Ansible 2.8, this callback has been renamed from C(osx_say) into M(community.general.say). ''' import platform diff --git a/plugins/callback/selective.py b/plugins/callback/selective.py index 6476f5ba53..526975bd2c 100644 --- a/plugins/callback/selective.py +++ b/plugins/callback/selective.py @@ -22,7 +22,7 @@ DOCUMENTATION = ''' options: nocolor: default: false - description: This setting allows suppressing colorizing output + description: This setting allows suppressing colorizing output. env: - name: ANSIBLE_NOCOLOR - name: ANSIBLE_SELECTIVE_DONT_COLORIZE diff --git a/plugins/callback/slack.py b/plugins/callback/slack.py index 6ca15b43f5..e9b84bbb38 100644 --- a/plugins/callback/slack.py +++ b/plugins/callback/slack.py @@ -18,11 +18,11 @@ DOCUMENTATION = ''' short_description: Sends play events to a Slack channel description: - This is an ansible callback plugin that sends status updates to a Slack channel during playbook execution. - - Before 2.4 only environment variables were available for configuring this plugin + - Before Ansible 2.4 only environment variables were available for configuring this plugin. options: webhook_url: required: true - description: Slack Webhook URL + description: Slack Webhook URL. env: - name: SLACK_WEBHOOK_URL ini: @@ -45,7 +45,7 @@ DOCUMENTATION = ''' - section: callback_slack key: username validate_certs: - description: validate the SSL certificate of the Slack server. (For HTTPS URLs) + description: Validate the SSL certificate of the Slack server for HTTPS URLs. env: - name: SLACK_VALIDATE_CERTS ini: diff --git a/plugins/callback/splunk.py b/plugins/callback/splunk.py index 32e77f4eb4..67ad944d2e 100644 --- a/plugins/callback/splunk.py +++ b/plugins/callback/splunk.py @@ -13,22 +13,22 @@ DOCUMENTATION = ''' author: "Stuart Hirst (!UNKNOWN) " description: - This callback plugin will send task results as JSON formatted events to a Splunk HTTP collector. - - The companion Splunk Monitoring & Diagnostics App is available here "https://splunkbase.splunk.com/app/4023/" + - The companion Splunk Monitoring & Diagnostics App is available here U(https://splunkbase.splunk.com/app/4023/). - Credit to "Ryan Currah (@ryancurrah)" for original source upon which this is based. requirements: - Whitelisting this callback plugin - 'Create a HTTP Event Collector in Splunk' - - 'Define the url and token in ansible.cfg' + - 'Define the URL and token in C(ansible.cfg)' options: url: - description: URL to the Splunk HTTP collector source + description: URL to the Splunk HTTP collector source. env: - name: SPLUNK_URL ini: - section: callback_splunk key: url authtoken: - description: Token to authenticate the connection to the Splunk HTTP collector + description: Token to authenticate the connection to the Splunk HTTP collector. env: - name: SPLUNK_AUTHTOKEN ini: @@ -48,7 +48,7 @@ DOCUMENTATION = ''' version_added: '1.0.0' include_milliseconds: description: Whether to include milliseconds as part of the generated timestamp field in the event - sent to the Splunk HTTP collector + sent to the Splunk HTTP collector. env: - name: SPLUNK_INCLUDE_MILLISECONDS ini: diff --git a/plugins/callback/sumologic.py b/plugins/callback/sumologic.py index 6fd950d991..998081c35b 100644 --- a/plugins/callback/sumologic.py +++ b/plugins/callback/sumologic.py @@ -12,14 +12,14 @@ type: notification short_description: Sends task result events to Sumologic author: "Ryan Currah (@ryancurrah)" description: - - This callback plugin will send task results as JSON formatted events to a Sumologic HTTP collector source + - This callback plugin will send task results as JSON formatted events to a Sumologic HTTP collector source. requirements: - Whitelisting this callback plugin - 'Create a HTTP collector source in Sumologic and specify a custom timestamp format of C(yyyy-MM-dd HH:mm:ss ZZZZ) and a custom timestamp locator of C("timestamp": "(.*)")' options: url: - description: URL to the Sumologic HTTP collector source + description: URL to the Sumologic HTTP collector source. env: - name: SUMOLOGIC_URL ini: @@ -28,7 +28,7 @@ options: ''' EXAMPLES = ''' -examples: > +examples: | To enable, add this to your ansible.cfg file in the defaults block [defaults] callback_whitelist = community.general.sumologic diff --git a/plugins/callback/syslog_json.py b/plugins/callback/syslog_json.py index 4b2c7e79b8..2bd8f6e604 100644 --- a/plugins/callback/syslog_json.py +++ b/plugins/callback/syslog_json.py @@ -15,11 +15,11 @@ DOCUMENTATION = ''' - whitelist in configuration short_description: sends JSON events to syslog description: - - This plugin logs ansible-playbook and ansible runs to a syslog server in JSON format - - Before Ansible 2.9 only environment variables were available for configuration + - This plugin logs ansible-playbook and ansible runs to a syslog server in JSON format. + - Before Ansible 2.9 only environment variables were available for configuration. options: server: - description: syslog server that will receive the event + description: Syslog server that will receive the event. env: - name: SYSLOG_SERVER default: localhost @@ -27,7 +27,7 @@ DOCUMENTATION = ''' - section: callback_syslog_json key: syslog_server port: - description: port on which the syslog server is listening + description: Port on which the syslog server is listening. env: - name: SYSLOG_PORT default: 514 @@ -35,7 +35,7 @@ DOCUMENTATION = ''' - section: callback_syslog_json key: syslog_port facility: - description: syslog facility to log as + description: Syslog facility to log as. env: - name: SYSLOG_FACILITY default: user diff --git a/plugins/callback/yaml.py b/plugins/callback/yaml.py index 81d59e2e70..73782de151 100644 --- a/plugins/callback/yaml.py +++ b/plugins/callback/yaml.py @@ -11,7 +11,7 @@ DOCUMENTATION = ''' author: Unknown (!UNKNOWN) name: yaml type: stdout - short_description: yaml-ized Ansible screen output + short_description: YAML-ized Ansible screen output description: - Ansible output that can be quite a bit easier to read than the default JSON formatting. From 0ff003d31246ca03a891a28a9ecbca8e0b27bb46 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 7 Jan 2023 14:06:09 +0100 Subject: [PATCH 0111/1810] Fix CI (#5785) Try to fix CI. --- tests/utils/constraints.txt | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/tests/utils/constraints.txt b/tests/utils/constraints.txt index af2b326ddd..87db256f41 100644 --- a/tests/utils/constraints.txt +++ b/tests/utils/constraints.txt @@ -7,7 +7,7 @@ coverage >= 4.2, < 5.0.0, != 4.3.2 ; python_version <= '3.7' # features in 4.2+ coverage >= 4.5.4, < 5.0.0 ; python_version > '3.7' # coverage had a bug in < 4.5.4 that would cause unit tests to hang in Python 3.8, coverage 5.0+ incompatible cryptography < 2.2 ; python_version < '2.7' # cryptography 2.2 drops support for python 2.6 cryptography >= 3.0, < 3.4 ; python_version < '3.6' and python_version >= '2.7' # cryptography 3.4 drops support for python 2.7 -cryptography >= 3.3, < 3.4 ; python_version >= '2.7' # FIXME: the upper limit is needed for RHEL8.2, CentOS 8, Ubuntu 18.04, and OpenSuSE 15 +cryptography >= 3.3, < 3.4 ; python_version >= '2.7' and python_version < '3.9' # FIXME: the upper limit is needed for RHEL8.2, CentOS 8, Ubuntu 18.04, and OpenSuSE 15 deepdiff < 4.0.0 ; python_version < '3' # deepdiff 4.0.0 and later require python 3 jinja2 < 2.11 ; python_version < '2.7' # jinja2 2.11 and later require python 2.7 or later urllib3 < 1.24 ; python_version < '2.7' # urllib3 1.24 and later require python 2.7 or later @@ -56,12 +56,3 @@ redis ; python_version >= '3.6' pycdlib < 1.13.0 ; python_version < '3' # 1.13.0 does not work with Python 2, while not declaring that python-daemon <= 2.3.0 ; python_version < '3' bcrypt < 4.0.0 # TEMP: restrict to < 4.0.0 since installing 4.0.0 fails on RHEL 8 - -# freeze pylint and its requirements for consistent test results -astroid == 2.2.5 -isort == 4.3.15 -lazy-object-proxy == 1.3.1 -mccabe == 0.6.1 -pylint == 2.3.1 -typed-ast == 1.4.0 # 1.4.0 is required to compile on Python 3.8 -wrapt == 1.11.1 From 759ca9a0ab5a6c68dea342e0840b6803ac008a63 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 7 Jan 2023 14:08:34 +0100 Subject: [PATCH 0112/1810] Remove currently unneeded generic tests from CI (#5786) Remove currently unneeded generic tests from CI. --- .azure-pipelines/azure-pipelines.yml | 11 ++++++----- tests/integration/targets/one_host/aliases | 2 +- tests/integration/targets/one_template/aliases | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.azure-pipelines/azure-pipelines.yml b/.azure-pipelines/azure-pipelines.yml index c8e03a164b..77463e2c79 100644 --- a/.azure-pipelines/azure-pipelines.yml +++ b/.azure-pipelines/azure-pipelines.yml @@ -487,10 +487,11 @@ stages: - Docker_2_13 - Docker_2_14 - Docker_community_devel - - Generic_devel - - Generic_2_11 - - Generic_2_12 - - Generic_2_13 - - Generic_2_14 +# Right now all generic tests are disabled. Uncomment when at least one of them is re-enabled. +# - Generic_devel +# - Generic_2_11 +# - Generic_2_12 +# - Generic_2_13 +# - Generic_2_14 jobs: - template: templates/coverage.yml diff --git a/tests/integration/targets/one_host/aliases b/tests/integration/targets/one_host/aliases index 02a31bcd55..100ba0f979 100644 --- a/tests/integration/targets/one_host/aliases +++ b/tests/integration/targets/one_host/aliases @@ -4,4 +4,4 @@ azp/generic/1 cloud/opennebula -disabled # FIXME +disabled # FIXME - when this is fixed, also re-enable the generic tests in CI! diff --git a/tests/integration/targets/one_template/aliases b/tests/integration/targets/one_template/aliases index 02a31bcd55..100ba0f979 100644 --- a/tests/integration/targets/one_template/aliases +++ b/tests/integration/targets/one_template/aliases @@ -4,4 +4,4 @@ azp/generic/1 cloud/opennebula -disabled # FIXME +disabled # FIXME - when this is fixed, also re-enable the generic tests in CI! From 3b73e7ed2a550480892854ffb48314665a9b52c5 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 7 Jan 2023 16:44:27 +0100 Subject: [PATCH 0113/1810] alternatives: make work with Fedora 37 (#5794) * alternatives in Fedora 37 uses follower instead of slave. * Add changelog fragment. --- changelogs/fragments/5794-alternatives-fedora37.yml | 2 ++ plugins/modules/alternatives.py | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/5794-alternatives-fedora37.yml diff --git a/changelogs/fragments/5794-alternatives-fedora37.yml b/changelogs/fragments/5794-alternatives-fedora37.yml new file mode 100644 index 0000000000..bfb77142cc --- /dev/null +++ b/changelogs/fragments/5794-alternatives-fedora37.yml @@ -0,0 +1,2 @@ +bugfixes: + - "alternatives - support subcommands on Fedora 37, which uses ``follower`` instead of ``slave`` (https://github.com/ansible-collections/community.general/pull/5794)." diff --git a/plugins/modules/alternatives.py b/plugins/modules/alternatives.py index 4566144493..48cacb4540 100644 --- a/plugins/modules/alternatives.py +++ b/plugins/modules/alternatives.py @@ -60,6 +60,8 @@ options: description: - A list of subcommands. - Each subcommand needs a name, a link and a path parameter. + - Subcommands are also named 'slaves' or 'followers', depending on the version + of alternatives. type: list elements: dict aliases: ['slaves'] @@ -310,10 +312,10 @@ class AlternativesModule(object): current_mode_regex = re.compile(r'\s-\s(?:status\sis\s)?(\w*)(?:\smode|.)$', re.MULTILINE) current_path_regex = re.compile(r'^\s*link currently points to (.*)$', re.MULTILINE) current_link_regex = re.compile(r'^\s*link \w+ is (.*)$', re.MULTILINE) - subcmd_path_link_regex = re.compile(r'^\s*slave (\S+) is (.*)$', re.MULTILINE) + subcmd_path_link_regex = re.compile(r'^\s*(?:slave|follower) (\S+) is (.*)$', re.MULTILINE) - alternative_regex = re.compile(r'^(\/.*)\s-\s(?:family\s\S+\s)?priority\s(\d+)((?:\s+slave.*)*)', re.MULTILINE) - subcmd_regex = re.compile(r'^\s+slave (.*): (.*)$', re.MULTILINE) + alternative_regex = re.compile(r'^(\/.*)\s-\s(?:family\s\S+\s)?priority\s(\d+)((?:\s+(?:slave|follower).*)*)', re.MULTILINE) + subcmd_regex = re.compile(r'^\s+(?:slave|follower) (.*): (.*)$', re.MULTILINE) match = current_mode_regex.search(display_output) if not match: From 6fb212b1042f730b7a92c6508a6d249b53f12fae Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 7 Jan 2023 17:19:58 +0100 Subject: [PATCH 0114/1810] Update CI matrix (#5782) * Update CI matrix. * Disable RHEL 9.1 for tests where RHEL 9.0 was disabled as well. * Skip iso_extract on FreeBSD 12.4. * Fix cloud_init_data_facts test for Fedora 37. * Do not try to install snap on RHEL 9.1. * Skip pkgng jail tests on FreeBSD 12.4 as well. --- .azure-pipelines/azure-pipelines.yml | 22 ++++++++++--------- .../cloud_init_data_facts/tasks/main.yml | 6 +++++ .../integration/targets/django_manage/aliases | 1 + tests/integration/targets/homectl/aliases | 1 + tests/integration/targets/iso_extract/aliases | 2 ++ tests/integration/targets/odbc/aliases | 1 + .../targets/pkgng/tasks/freebsd.yml | 7 +++++- .../targets/setup_snap/tasks/D-RedHat-9.1.yml | 6 +++++ tests/integration/targets/ufw/aliases | 1 + 9 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 tests/integration/targets/setup_snap/tasks/D-RedHat-9.1.yml diff --git a/.azure-pipelines/azure-pipelines.yml b/.azure-pipelines/azure-pipelines.yml index 77463e2c79..3816369497 100644 --- a/.azure-pipelines/azure-pipelines.yml +++ b/.azure-pipelines/azure-pipelines.yml @@ -197,10 +197,10 @@ stages: parameters: testFormat: devel/{0} targets: - - name: Alpine 3.16 - test: alpine/3.16 - # - name: Fedora 36 - # test: fedora/36 + - name: Alpine 3.17 + test: alpine/3.17 + # - name: Fedora 37 + # test: fedora/37 # - name: Ubuntu 20.04 # test: ubuntu/20.04 - name: Ubuntu 22.04 @@ -219,10 +219,12 @@ stages: test: macos/12.0 - name: RHEL 7.9 test: rhel/7.9 - - name: RHEL 9.0 - test: rhel/9.0 + - name: RHEL 9.1 + test: rhel/9.1 - name: FreeBSD 13.1 test: freebsd/13.1 + - name: FreeBSD 12.4 + test: freebsd/12.4 groups: - 1 - 2 @@ -305,8 +307,8 @@ stages: targets: - name: CentOS 7 test: centos7 - - name: Fedora 36 - test: fedora36 + - name: Fedora 37 + test: fedora37 - name: openSUSE 15 test: opensuse15 - name: Ubuntu 20.04 @@ -327,8 +329,8 @@ stages: parameters: testFormat: 2.14/linux/{0} targets: - - name: Ubuntu 20.04 - test: ubuntu2004 + - name: Fedora 36 + test: fedora36 groups: - 1 - 2 diff --git a/tests/integration/targets/cloud_init_data_facts/tasks/main.yml b/tests/integration/targets/cloud_init_data_facts/tasks/main.yml index fc634a972f..fe38d4ca5b 100644 --- a/tests/integration/targets/cloud_init_data_facts/tasks/main.yml +++ b/tests/integration/targets/cloud_init_data_facts/tasks/main.yml @@ -29,6 +29,12 @@ - cloud-init - udev + - name: Ensure systemd-network user exists + user: + name: systemd-network + state: present + when: ansible_distribution == 'Fedora' and ansible_distribution_major_version|int >= 37 + - name: setup run cloud-init service: name: cloud-init-local diff --git a/tests/integration/targets/django_manage/aliases b/tests/integration/targets/django_manage/aliases index 025fe0ec48..98aed9e9d4 100644 --- a/tests/integration/targets/django_manage/aliases +++ b/tests/integration/targets/django_manage/aliases @@ -12,3 +12,4 @@ skip/rhel8.3 skip/rhel8.4 skip/rhel8.5 skip/rhel9.0 +skip/rhel9.1 diff --git a/tests/integration/targets/homectl/aliases b/tests/integration/targets/homectl/aliases index 8d80bf12c3..b87db2e43c 100644 --- a/tests/integration/targets/homectl/aliases +++ b/tests/integration/targets/homectl/aliases @@ -8,3 +8,4 @@ skip/freebsd skip/osx skip/macos skip/rhel9.0 # See https://www.reddit.com/r/Fedora/comments/si7nzk/homectl/ +skip/rhel9.1 # See https://www.reddit.com/r/Fedora/comments/si7nzk/homectl/ diff --git a/tests/integration/targets/iso_extract/aliases b/tests/integration/targets/iso_extract/aliases index 5b0ab153c8..2815959456 100644 --- a/tests/integration/targets/iso_extract/aliases +++ b/tests/integration/targets/iso_extract/aliases @@ -8,3 +8,5 @@ destructive skip/aix skip/osx # FIXME skip/rhel9.0 # FIXME +skip/rhel9.1 # FIXME +skip/freebsd12.4 # FIXME diff --git a/tests/integration/targets/odbc/aliases b/tests/integration/targets/odbc/aliases index 2dbf0eac3e..e8465c50e8 100644 --- a/tests/integration/targets/odbc/aliases +++ b/tests/integration/targets/odbc/aliases @@ -8,4 +8,5 @@ skip/osx skip/macos skip/rhel8.0 skip/rhel9.0 +skip/rhel9.1 skip/freebsd diff --git a/tests/integration/targets/pkgng/tasks/freebsd.yml b/tests/integration/targets/pkgng/tasks/freebsd.yml index a7cb90b11d..a822b4c7e9 100644 --- a/tests/integration/targets/pkgng/tasks/freebsd.yml +++ b/tests/integration/targets/pkgng/tasks/freebsd.yml @@ -501,14 +501,19 @@ # NOTE: FreeBSD 12.0 test runner receives a "connection reset by peer" after ~20% downloaded so we are # only running this on 12.1 or higher # + # NOTE: FreeBSD 12.4 fails to update repositories because it cannot load certificates from /usr/share/keys/pkg/trusted + # knowledge has to take a look) + # # NOTE: FreeBSD 13.0 fails to update the package catalogue for unknown reasons (someone with FreeBSD # knowledge has to take a look) # # NOTE: FreeBSD 13.1 fails to update the package catalogue for unknown reasons (someone with FreeBSD # knowledge has to take a look) # + # See also + # https://github.com/ansible-collections/community.general/issues/5795 when: >- - (ansible_distribution_version is version('12.01', '>=') and ansible_distribution_version is version('13.0', '<')) + (ansible_distribution_version is version('12.01', '>=') and ansible_distribution_version is version('12.4', '<')) or ansible_distribution_version is version('13.2', '>=') block: - name: Setup testjail diff --git a/tests/integration/targets/setup_snap/tasks/D-RedHat-9.1.yml b/tests/integration/targets/setup_snap/tasks/D-RedHat-9.1.yml new file mode 100644 index 0000000000..5bbfaff128 --- /dev/null +++ b/tests/integration/targets/setup_snap/tasks/D-RedHat-9.1.yml @@ -0,0 +1,6 @@ +--- +# Copyright (c) Ansible Project +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +# Do nothing diff --git a/tests/integration/targets/ufw/aliases b/tests/integration/targets/ufw/aliases index 1f974ecd19..2ef1a41338 100644 --- a/tests/integration/targets/ufw/aliases +++ b/tests/integration/targets/ufw/aliases @@ -10,6 +10,7 @@ skip/macos skip/freebsd skip/rhel8.0 # FIXME skip/rhel9.0 # FIXME +skip/rhel9.1 # FIXME skip/docker needs/root needs/target/setup_epel From 4caa6574de486d6840ac50affe48501f9d895bf4 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Mon, 9 Jan 2023 09:37:29 +1300 Subject: [PATCH 0115/1810] snap_alias: using CmdRunner (#5486) * snap_alias: using CmdRunner * add changelog fragment * fix changelog fragment * invert order of initialization in __init_module__() * comment extra changed=True from code * add extra info when verbose * add extra info when verbose - fix blank line * handle check_mode the old way * fix logical test * fix error when using multiple aliases * fix error when using multiple aliases, part 2 * revert to using check_mode_skip=True again --- .../fragments/5486-snap-alias-cmd-runner.yml | 2 + plugins/modules/snap_alias.py | 53 ++++++++++--------- 2 files changed, 31 insertions(+), 24 deletions(-) create mode 100644 changelogs/fragments/5486-snap-alias-cmd-runner.yml diff --git a/changelogs/fragments/5486-snap-alias-cmd-runner.yml b/changelogs/fragments/5486-snap-alias-cmd-runner.yml new file mode 100644 index 0000000000..59ae0c5abf --- /dev/null +++ b/changelogs/fragments/5486-snap-alias-cmd-runner.yml @@ -0,0 +1,2 @@ +minor_changes: + - snap_alias - refactored module to use ``CmdRunner`` to execute ``snap`` (https://github.com/ansible-collections/community.general/pull/5486). diff --git a/plugins/modules/snap_alias.py b/plugins/modules/snap_alias.py index 818dbbce31..1611c06719 100644 --- a/plugins/modules/snap_alias.py +++ b/plugins/modules/snap_alias.py @@ -79,9 +79,8 @@ snap_aliases: import re -from ansible_collections.community.general.plugins.module_utils.module_helper import ( - CmdStateModuleHelper -) +from ansible_collections.community.general.plugins.module_utils.cmd_runner import CmdRunner, cmd_runner_fmt +from ansible_collections.community.general.plugins.module_utils.module_helper import StateModuleHelper _state_map = dict( @@ -91,7 +90,7 @@ _state_map = dict( ) -class SnapAlias(CmdStateModuleHelper): +class SnapAlias(StateModuleHelper): _RE_ALIAS_LIST = re.compile(r"^(?P[\w-]+)\s+(?P[\w-]+)\s+.*$") module = dict( @@ -106,25 +105,26 @@ class SnapAlias(CmdStateModuleHelper): ], supports_check_mode=True, ) - command = "snap" - command_args_formats = dict( - _alias=dict(fmt=lambda v: [v]), - state=dict(fmt=lambda v: [_state_map[v]]), - ) - check_rc = False + + command_args_formats = { + "state": cmd_runner_fmt.as_map(_state_map), + "name": cmd_runner_fmt.as_list(), + "alias": cmd_runner_fmt.as_list(), + } def _aliases(self): n = self.vars.name return {n: self._get_aliases_for(n)} if n else self._get_aliases() def __init_module__(self): + self.runner = CmdRunner(self.module, "snap", self.command_args_formats, check_rc=False) self.vars.set("snap_aliases", self._aliases(), change=True, diff=True) def __quit_module__(self): self.vars.snap_aliases = self._aliases() def _get_aliases(self): - def process_get_aliases(rc, out, err): + def process(rc, out, err): if err: return {} aliases = [self._RE_ALIAS_LIST.match(a.strip()) for a in out.splitlines()[1:]] @@ -134,9 +134,8 @@ class SnapAlias(CmdStateModuleHelper): results[snap] = results.get(snap, []) + [alias] return results - return self.run_command(params=[{'state': 'info'}, 'name'], check_rc=True, - publish_rc=False, publish_out=False, publish_err=False, publish_cmd=False, - process_output=process_get_aliases) + with self.runner("state name", check_rc=True, output_process=process) as ctx: + return ctx.run(state="info") def _get_aliases_for(self, name): return self._get_aliases().get(name, []) @@ -152,24 +151,30 @@ class SnapAlias(CmdStateModuleHelper): return any(alias in aliases for aliases in self.vars.snap_aliases.values()) def state_present(self): - for alias in self.vars.alias: - if not self._has_alias(self.vars.name, alias): + for _alias in self.vars.alias: + if not self._has_alias(self.vars.name, _alias): self.changed = True - if not self.module.check_mode: - self.run_command(params=['state', 'name', {'_alias': alias}]) + with self.runner("state name alias", check_mode_skip=True) as ctx: + ctx.run(alias=_alias) + if self.verbosity >= 4: + self.vars.run_info = ctx.run_info def state_absent(self): if not self.vars.alias: if self._has_alias(self.vars.name): self.changed = True - if not self.module.check_mode: - self.run_command(params=['state', 'name']) + with self.runner("state name", check_mode_skip=True) as ctx: + ctx.run() + if self.verbosity >= 4: + self.vars.run_info = ctx.run_info else: - for alias in self.vars.alias: - if self._has_alias(self.vars.name, alias): + for _alias in self.vars.alias: + if self._has_alias(self.vars.name, _alias): self.changed = True - if not self.module.check_mode: - self.run_command(params=['state', {'_alias': alias}]) + with self.runner("state alias", check_mode_skip=True) as ctx: + ctx.run(alias=_alias) + if self.verbosity >= 4: + self.vars.run_info = ctx.run_info def main(): From 682bb4b88a00b880756a891f9280083164dc8fb2 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Fri, 13 Jan 2023 08:42:38 +1300 Subject: [PATCH 0116/1810] opkg: refactor module to use StateModuleHelper and CmdRunner (#5718) * opkg: refactor module to use StateModuleHelper and CmdRunner * add changelog fragment * Update plugins/modules/opkg.py Co-authored-by: joergho <48011876+joergho@users.noreply.github.com> * Update plugins/modules/opkg.py Co-authored-by: joergho <48011876+joergho@users.noreply.github.com> * Update plugins/modules/opkg.py Co-authored-by: joergho <48011876+joergho@users.noreply.github.com> * Update plugins/modules/opkg.py Co-authored-by: joergho <48011876+joergho@users.noreply.github.com> * Update plugins/modules/opkg.py Co-authored-by: joergho <48011876+joergho@users.noreply.github.com> * Update plugins/modules/opkg.py Co-authored-by: joergho <48011876+joergho@users.noreply.github.com> * Update plugins/modules/opkg.py Co-authored-by: joergho <48011876+joergho@users.noreply.github.com> * generate message outcome as before * aggregated changes from 5688 * fix package query * add unit tests * fix sanity error * Update plugins/modules/opkg.py Co-authored-by: joergho <48011876+joergho@users.noreply.github.com> * add test for specifying version * refactor parameter name Co-authored-by: joergho <48011876+joergho@users.noreply.github.com> --- changelogs/fragments/5718-opkg-refactor.yaml | 2 + plugins/modules/opkg.py | 208 ++++++++----------- tests/unit/plugins/modules/test_opkg.py | 193 +++++++++++++++++ 3 files changed, 280 insertions(+), 123 deletions(-) create mode 100644 changelogs/fragments/5718-opkg-refactor.yaml create mode 100644 tests/unit/plugins/modules/test_opkg.py diff --git a/changelogs/fragments/5718-opkg-refactor.yaml b/changelogs/fragments/5718-opkg-refactor.yaml new file mode 100644 index 0000000000..fb8b5680da --- /dev/null +++ b/changelogs/fragments/5718-opkg-refactor.yaml @@ -0,0 +1,2 @@ +minor_changes: + - opkg - refactored module to use ``CmdRunner`` for executing ``opkg`` (https://github.com/ansible-collections/community.general/pull/5718). diff --git a/plugins/modules/opkg.py b/plugins/modules/opkg.py index 7e2b8c4ac2..d736c1f3ff 100644 --- a/plugins/modules/opkg.py +++ b/plugins/modules/opkg.py @@ -97,144 +97,106 @@ EXAMPLES = ''' force: overwrite ''' -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.six.moves import shlex_quote +from ansible_collections.community.general.plugins.module_utils.cmd_runner import CmdRunner, cmd_runner_fmt +from ansible_collections.community.general.plugins.module_utils.module_helper import StateModuleHelper -def update_package_db(module, opkg_path): - """ Updates packages list. """ - - rc, out, err = module.run_command([opkg_path, "update"]) - - if rc != 0: - module.fail_json(msg="could not update package db") - - -def query_package(module, opkg_path, name, version=None, state="present"): - """ Returns whether a package is installed or not. """ - - if state == "present": - rc, out, err = module.run_command([opkg_path, "list-installed", name]) - if rc != 0: - return False - # variable out is one line if the package is installed: - # "NAME - VERSION - DESCRIPTION" - if version is not None: - if not out.startswith("%s - %s " % (name, version)): - return False - else: - if not out.startswith(name + " "): - return False - return True - else: - raise NotImplementedError() - - -def split_name_and_version(module, package): - """ Split the name and the version when using the NAME=VERSION syntax """ - splitted = package.split('=', 1) - if len(splitted) == 1: - return splitted[0], None - else: - return splitted[0], splitted[1] - - -def remove_packages(module, opkg_path, packages): - """ Uninstalls one or more packages if installed. """ - - p = module.params - force = p["force"] - if force: - force = "--force-%s" % force - - remove_c = 0 - # Using a for loop in case of error, we can report the package that failed - for package in packages: - package, version = split_name_and_version(module, package) - - # Query the package first, to see if we even need to remove - if not query_package(module, opkg_path, package): - continue - - if force: - rc, out, err = module.run_command([opkg_path, "remove", force, package]) - else: - rc, out, err = module.run_command([opkg_path, "remove", package]) - - if query_package(module, opkg_path, package): - module.fail_json(msg="failed to remove %s: %s" % (package, out)) - - remove_c += 1 - - if remove_c > 0: - - module.exit_json(changed=True, msg="removed %s package(s)" % remove_c) - - module.exit_json(changed=False, msg="package(s) already absent") - - -def install_packages(module, opkg_path, packages): - """ Installs one or more packages if not already installed. """ - - p = module.params - force = p["force"] - if force: - force = "--force-%s" % force - - install_c = 0 - - for package in packages: - package, version = split_name_and_version(module, package) - - if query_package(module, opkg_path, package, version) and (force != '--force-reinstall'): - continue - - if version is not None: - version_str = "=%s" % version - else: - version_str = "" - - if force: - rc, out, err = module.run_command([opkg_path, "install", force, package + version_str]) - else: - rc, out, err = module.run_command([opkg_path, "install", package + version_str]) - - if not query_package(module, opkg_path, package, version): - module.fail_json(msg="failed to install %s%s: %s" % (package, version_str, out)) - - install_c += 1 - - if install_c > 0: - module.exit_json(changed=True, msg="installed %s package(s)" % (install_c)) - - module.exit_json(changed=False, msg="package(s) already present") - - -def main(): - module = AnsibleModule( +class Opkg(StateModuleHelper): + module = dict( argument_spec=dict( name=dict(aliases=["pkg"], required=True, type="list", elements="str"), state=dict(default="present", choices=["present", "installed", "absent", "removed"]), force=dict(default="", choices=["", "depends", "maintainer", "reinstall", "overwrite", "downgrade", "space", "postinstall", "remove", "checksum", "removal-of-dependent-packages"]), update_cache=dict(default=False, type='bool'), - ) + ), ) - opkg_path = module.get_bin_path('opkg', True, ['/bin']) + def __init_module__(self): + self.vars.set("install_c", 0, output=False, change=True) + self.vars.set("remove_c", 0, output=False, change=True) - p = module.params + state_map = dict( + query="list-installed", + present="install", + installed="install", + absent="remove", + removed="remove", + ) - if p["update_cache"]: - update_package_db(module, opkg_path) + def _force(value): + if value == "": + value = None + return cmd_runner_fmt.as_optval("--force-")(value, ctx_ignore_none=True) - pkgs = p["name"] + self.runner = CmdRunner( + self.module, + command="opkg", + arg_formats=dict( + package=cmd_runner_fmt.as_list(), + state=cmd_runner_fmt.as_map(state_map), + force=cmd_runner_fmt.as_func(_force), + update_cache=cmd_runner_fmt.as_bool("update") + ), + ) - if p["state"] in ["present", "installed"]: - install_packages(module, opkg_path, pkgs) + @staticmethod + def split_name_and_version(package): + """ Split the name and the version when using the NAME=VERSION syntax """ + splitted = package.split('=', 1) + if len(splitted) == 1: + return splitted[0], None + else: + return splitted[0], splitted[1] - elif p["state"] in ["absent", "removed"]: - remove_packages(module, opkg_path, pkgs) + def _package_in_desired_state(self, name, want_installed, version=None): + dummy, out, dummy = self.runner("state package").run(state="query", package=name) + + has_package = out.startswith(name + " - %s" % ("" if not version else (version + " "))) + return want_installed == has_package + + def state_present(self): + if self.vars.update_cache: + dummy, rc, dummy = self.runner("update_cache").run() + if rc != 0: + self.do_raise("could not update package db") + with self.runner("state force package") as ctx: + for package in self.vars.name: + pkg_name, pkg_version = self.split_name_and_version(package) + if not self._package_in_desired_state(pkg_name, want_installed=True, version=pkg_version) or self.vars.force == "reinstall": + ctx.run(package=package) + if not self._package_in_desired_state(pkg_name, want_installed=True, version=pkg_version): + self.do_raise("failed to install %s" % package) + self.vars.install_c += 1 + if self.vars.install_c > 0: + self.vars.msg = "installed %s package(s)" % (self.vars.install_c) + else: + self.vars.msg = "package(s) already present" + + def state_absent(self): + if self.vars.update_cache: + dummy, rc, dummy = self.runner("update_cache").run() + if rc != 0: + self.do_raise("could not update package db") + with self.runner("state force package") as ctx: + for package in self.vars.name: + package, dummy = self.split_name_and_version(package) + if not self._package_in_desired_state(package, want_installed=False): + ctx.run(package=package) + if not self._package_in_desired_state(package, want_installed=False): + self.do_raise("failed to remove %s" % package) + self.vars.remove_c += 1 + if self.vars.remove_c > 0: + self.vars.msg = "removed %s package(s)" % (self.vars.remove_c) + else: + self.vars.msg = "package(s) already absent" + + state_installed = state_present + state_removed = state_absent + + +def main(): + Opkg.execute() if __name__ == '__main__': diff --git a/tests/unit/plugins/modules/test_opkg.py b/tests/unit/plugins/modules/test_opkg.py new file mode 100644 index 0000000000..f11347facc --- /dev/null +++ b/tests/unit/plugins/modules/test_opkg.py @@ -0,0 +1,193 @@ +# -*- coding: utf-8 -*- +# Copyright (c) Alexei Znamensky (russoz@gmail.com) +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import json + +from collections import namedtuple +from ansible_collections.community.general.plugins.modules import opkg + +import pytest + +TESTED_MODULE = opkg.__name__ + + +ModuleTestCase = namedtuple("ModuleTestCase", ["id", "input", "output", "run_command_calls"]) +RunCmdCall = namedtuple("RunCmdCall", ["command", "environ", "rc", "out", "err"]) + + +@pytest.fixture +def patch_opkg(mocker): + mocker.patch('ansible.module_utils.basic.AnsibleModule.get_bin_path', return_value='/testbin/opkg') + + +TEST_CASES = [ + ModuleTestCase( + id="install_zlibdev", + input={"name": "zlib-dev", "state": "present"}, + output={ + "msg": "installed 1 package(s)" + }, + run_command_calls=[ + RunCmdCall( + command=["/testbin/opkg", "list-installed", "zlib-dev"], + environ={'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': False}, + rc=0, + out="", + err="", + ), + RunCmdCall( + command=["/testbin/opkg", "install", "zlib-dev"], + environ={'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': False}, + rc=0, + out=( + "Installing zlib-dev (1.2.11-6) to root..." + "Downloading https://downloads.openwrt.org/releases/22.03.0/packages/mips_24kc/base/zlib-dev_1.2.11-6_mips_24kc.ipk" + "Installing zlib (1.2.11-6) to root..." + "Downloading https://downloads.openwrt.org/releases/22.03.0/packages/mips_24kc/base/zlib_1.2.11-6_mips_24kc.ipk" + "Configuring zlib." + "Configuring zlib-dev." + ), + err="", + ), + RunCmdCall( + command=["/testbin/opkg", "list-installed", "zlib-dev"], + environ={'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': False}, + rc=0, + out="zlib-dev - 1.2.11-6\n", + err="", + ), + ], + ), + ModuleTestCase( + id="install_zlibdev_present", + input={"name": "zlib-dev", "state": "present"}, + output={ + "msg": "package(s) already present" + }, + run_command_calls=[ + RunCmdCall( + command=["/testbin/opkg", "list-installed", "zlib-dev"], + environ={'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': False}, + rc=0, + out="zlib-dev - 1.2.11-6\n", + err="", + ), + ], + ), + ModuleTestCase( + id="install_zlibdev_force_reinstall", + input={"name": "zlib-dev", "state": "present", "force": "reinstall"}, + output={ + "msg": "installed 1 package(s)" + }, + run_command_calls=[ + RunCmdCall( + command=["/testbin/opkg", "list-installed", "zlib-dev"], + environ={'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': False}, + rc=0, + out="zlib-dev - 1.2.11-6\n", + err="", + ), + RunCmdCall( + command=["/testbin/opkg", "install", "--force-reinstall", "zlib-dev"], + environ={'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': False}, + rc=0, + out=( + "Installing zlib-dev (1.2.11-6) to root...\n" + "Downloading https://downloads.openwrt.org/releases/22.03.0/packages/mips_24kc/base/zlib-dev_1.2.11-6_mips_24kc.ipk\n" + "Configuring zlib-dev.\n" + ), + err="", + ), + RunCmdCall( + command=["/testbin/opkg", "list-installed", "zlib-dev"], + environ={'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': False}, + rc=0, + out="zlib-dev - 1.2.11-6\n", + err="", + ), + ], + ), + ModuleTestCase( + id="install_zlibdev_with_version", + input={"name": "zlib-dev=1.2.11-6", "state": "present"}, + output={ + "msg": "installed 1 package(s)" + }, + run_command_calls=[ + RunCmdCall( + command=["/testbin/opkg", "list-installed", "zlib-dev"], + environ={'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': False}, + rc=0, + out="", + err="", + ), + RunCmdCall( + command=["/testbin/opkg", "install", "zlib-dev=1.2.11-6"], + environ={'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': False}, + rc=0, + out=( + "Installing zlib-dev (1.2.11-6) to root..." + "Downloading https://downloads.openwrt.org/releases/22.03.0/packages/mips_24kc/base/zlib-dev_1.2.11-6_mips_24kc.ipk" + "Installing zlib (1.2.11-6) to root..." + "Downloading https://downloads.openwrt.org/releases/22.03.0/packages/mips_24kc/base/zlib_1.2.11-6_mips_24kc.ipk" + "Configuring zlib." + "Configuring zlib-dev." + ), + err="", + ), + RunCmdCall( + command=["/testbin/opkg", "list-installed", "zlib-dev"], + environ={'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': False}, + rc=0, + out="zlib-dev - 1.2.11-6 \n", # This output has the extra space at the end, to satisfy the behaviour of Yocto/OpenEmbedded's opkg + err="", + ), + ], + ), +] +TEST_CASES_IDS = [item.id for item in TEST_CASES] + + +@pytest.mark.parametrize('patch_ansible_module, testcase', + [[x.input, x] for x in TEST_CASES], + ids=TEST_CASES_IDS, + indirect=['patch_ansible_module']) +@pytest.mark.usefixtures('patch_ansible_module') +def test_opkg(mocker, capfd, patch_opkg, testcase): + """ + Run unit tests for test cases listen in TEST_CASES + """ + + run_cmd_calls = testcase.run_command_calls + + # Mock function used for running commands first + call_results = [(x.rc, x.out, x.err) for x in run_cmd_calls] + mock_run_command = mocker.patch('ansible.module_utils.basic.AnsibleModule.run_command', side_effect=call_results) + + # Try to run test case + with pytest.raises(SystemExit): + opkg.main() + + out, err = capfd.readouterr() + results = json.loads(out) + print("testcase =\n%s" % str(testcase)) + print("results =\n%s" % results) + + for test_result in testcase.output: + assert results[test_result] == testcase.output[test_result], \ + "'{0}': '{1}' != '{2}'".format(test_result, results[test_result], testcase.output[test_result]) + + call_args_list = [(item[0][0], item[1]) for item in mock_run_command.call_args_list] + expected_call_args_list = [(item.command, item.environ) for item in run_cmd_calls] + print("call args list =\n%s" % call_args_list) + print("expected args list =\n%s" % expected_call_args_list) + + assert mock_run_command.call_count == len(run_cmd_calls) + if mock_run_command.call_count: + assert call_args_list == expected_call_args_list From b9ac2dcda5fe44b8c6c10b2649a9d682a053c069 Mon Sep 17 00:00:00 2001 From: joergho <48011876+joergho@users.noreply.github.com> Date: Thu, 12 Jan 2023 20:43:56 +0100 Subject: [PATCH 0117/1810] opkg: extend docu about compatibilty with OpenWrt vs. Yocto based Linux distribitions (#5810) * opkg: extend documentation: opkg also works on Yocto ... based linux distributions Signed-off-by: Joerg Hofrichter * opkg: extend documentation: PACKAGE=VERSION only works on Yocto ... based linux distributions Signed-off-by: Joerg Hofrichter Signed-off-by: Joerg Hofrichter --- plugins/modules/opkg.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/modules/opkg.py b/plugins/modules/opkg.py index d736c1f3ff..73c2597de2 100644 --- a/plugins/modules/opkg.py +++ b/plugins/modules/opkg.py @@ -15,16 +15,17 @@ DOCUMENTATION = ''' --- module: opkg author: "Patrick Pelletier (@skinp)" -short_description: Package manager for OpenWrt +short_description: Package manager for OpenWrt and Openembedded/Yocto based Linux distributions description: - - Manages OpenWrt packages + - Manages ipk packages for OpenWrt and Openembedded/Yocto based Linux distributions options: name: description: - Name of package(s) to install/remove. - C(NAME=VERSION) syntax is also supported to install a package - in a certain version. See the examples. This is supported since - community.general 6.2.0. + in a certain version. See the examples. This only works on Yocto based + Linux distributions (opkg>=0.3.2) and not for OpenWrt. This is + supported since community.general 6.2.0. aliases: [pkg] required: true type: list @@ -67,7 +68,7 @@ EXAMPLES = ''' name: foo state: present -- name: Install foo in version 1.2 +- name: Install foo in version 1.2 (opkg>=0.3.2 on Yocto based Linux distributions) community.general.opkg: name: foo=1.2 state: present From 317f79ff1f4a590d73455054c3235cdef684b4f8 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Fri, 13 Jan 2023 09:02:25 +1300 Subject: [PATCH 0118/1810] multiple scaleway modules: fixed markups in doc (#5766) * multiple scaleway modules: fixed markups in doc * Update plugins/modules/scaleway_ip.py Co-authored-by: Felix Fontein * Update plugins/modules/scaleway_volume.py Co-authored-by: Felix Fontein * Update plugins/modules/scaleway_private_network.py Co-authored-by: Felix Fontein * Update plugins/modules/scaleway_security_group.py Co-authored-by: Felix Fontein * Update plugins/modules/scaleway_security_group_rule.py Co-authored-by: Felix Fontein * Update plugins/modules/scaleway_sshkey.py Co-authored-by: Felix Fontein * further docs adjustments Co-authored-by: Felix Fontein --- .../scaleway_compute_private_network.py | 2 +- plugins/modules/scaleway_database_backup.py | 12 ++++----- plugins/modules/scaleway_image_info.py | 2 +- plugins/modules/scaleway_ip.py | 4 +-- plugins/modules/scaleway_lb.py | 14 +++++----- plugins/modules/scaleway_organization_info.py | 4 +-- plugins/modules/scaleway_private_network.py | 5 ++-- plugins/modules/scaleway_security_group.py | 7 +++-- .../modules/scaleway_security_group_rule.py | 19 +++++++------ plugins/modules/scaleway_sshkey.py | 9 +++---- plugins/modules/scaleway_user_data.py | 10 +++---- plugins/modules/scaleway_volume.py | 27 +++++++++---------- 12 files changed, 55 insertions(+), 60 deletions(-) diff --git a/plugins/modules/scaleway_compute_private_network.py b/plugins/modules/scaleway_compute_private_network.py index f85b2f2444..201ec257f7 100644 --- a/plugins/modules/scaleway_compute_private_network.py +++ b/plugins/modules/scaleway_compute_private_network.py @@ -92,7 +92,7 @@ EXAMPLES = ''' RETURN = ''' scaleway_compute_private_network: description: Information on the VPC. - returned: success when C(state=present) + returned: success when I(state=present) type: dict sample: { diff --git a/plugins/modules/scaleway_database_backup.py b/plugins/modules/scaleway_database_backup.py index f91ce143a0..9daa7921c0 100644 --- a/plugins/modules/scaleway_database_backup.py +++ b/plugins/modules/scaleway_database_backup.py @@ -19,7 +19,7 @@ short_description: Scaleway database backups management module version_added: 1.2.0 author: Guillaume Rodriguez (@guillaume_ro_fr) description: - - This module manages database backups on Scaleway account U(https://developer.scaleway.com). + - "This module manages database backups on Scaleway account U(https://developer.scaleway.com)." extends_documentation_fragment: - community.general.scaleway options: @@ -58,7 +58,7 @@ options: description: - Name used to identify the database backup. - Required for C(present) state. - - Ignored when C(state=absent), C(state=exported) or C(state=restored). + - Ignored when I(state=absent), I(state=exported) or I(state=restored). type: str required: false @@ -66,7 +66,7 @@ options: description: - Name used to identify the database. - Required for C(present) and C(restored) states. - - Ignored when C(state=absent) or C(state=exported). + - Ignored when I(state=absent) or I(state=exported). type: str required: false @@ -74,14 +74,14 @@ options: description: - UUID of the instance associated to the database backup. - Required for C(present) and C(restored) states. - - Ignored when C(state=absent) or C(state=exported). + - Ignored when I(state=absent) or I(state=exported). type: str required: false expires_at: description: - Expiration datetime of the database backup (ISO 8601 format). - - Ignored when C(state=absent), C(state=exported) or C(state=restored). + - Ignored when I(state=absent), I(state=exported) or I(state=restored). type: str required: false @@ -139,7 +139,7 @@ EXAMPLES = ''' RETURN = ''' metadata: description: Backup metadata. - returned: when C(state=present), C(state=exported) or C(state=restored) + returned: when I(state=present), I(state=exported) or I(state=restored) type: dict sample: { "metadata": { diff --git a/plugins/modules/scaleway_image_info.py b/plugins/modules/scaleway_image_info.py index 56ca689c38..bdae185148 100644 --- a/plugins/modules/scaleway_image_info.py +++ b/plugins/modules/scaleway_image_info.py @@ -26,7 +26,7 @@ options: region: type: str description: - - Scaleway compute zone + - Scaleway compute zone. required: true choices: - ams1 diff --git a/plugins/modules/scaleway_ip.py b/plugins/modules/scaleway_ip.py index eccd64e47b..a49e9c9f31 100644 --- a/plugins/modules/scaleway_ip.py +++ b/plugins/modules/scaleway_ip.py @@ -88,8 +88,8 @@ EXAMPLES = ''' RETURN = ''' data: - description: This is only present when C(state=present) - returned: when C(state=present) + description: This is only present when I(state=present). + returned: when I(state=present) type: dict sample: { "ips": [ diff --git a/plugins/modules/scaleway_lb.py b/plugins/modules/scaleway_lb.py index 124cba5945..578f4ae894 100644 --- a/plugins/modules/scaleway_lb.py +++ b/plugins/modules/scaleway_lb.py @@ -29,19 +29,19 @@ options: name: type: str description: - - Name of the load-balancer + - Name of the load-balancer. required: true description: type: str description: - - Description of the load-balancer + - Description of the load-balancer. required: true organization_id: type: str description: - - Organization identifier + - Organization identifier. required: true state: @@ -56,7 +56,7 @@ options: region: type: str description: - - Scaleway zone + - Scaleway zone. required: true choices: - nl-ams @@ -68,7 +68,7 @@ options: elements: str default: [] description: - - List of tags to apply to the load-balancer + - List of tags to apply to the load-balancer. wait: description: @@ -79,14 +79,14 @@ options: wait_timeout: type: int description: - - Time to wait for the load-balancer to reach the expected state + - Time to wait for the load-balancer to reach the expected state. required: false default: 300 wait_sleep_time: type: int description: - - Time to wait before every attempt to check the state of the load-balancer + - Time to wait before every attempt to check the state of the load-balancer. required: false default: 3 ''' diff --git a/plugins/modules/scaleway_organization_info.py b/plugins/modules/scaleway_organization_info.py index 717c47db19..e9e272c988 100644 --- a/plugins/modules/scaleway_organization_info.py +++ b/plugins/modules/scaleway_organization_info.py @@ -20,7 +20,7 @@ author: options: api_url: description: - - Scaleway API URL + - Scaleway API URL. default: 'https://account.scaleway.com' aliases: ['base_url'] extends_documentation_fragment: @@ -42,7 +42,7 @@ EXAMPLES = r''' RETURN = r''' --- scaleway_organization_info: - description: Response from Scaleway API + description: Response from Scaleway API. returned: success type: list elements: dict diff --git a/plugins/modules/scaleway_private_network.py b/plugins/modules/scaleway_private_network.py index 6a611fa32b..57cf67ec1f 100644 --- a/plugins/modules/scaleway_private_network.py +++ b/plugins/modules/scaleway_private_network.py @@ -18,8 +18,7 @@ short_description: Scaleway private network management version_added: 4.5.0 author: Pascal MANGIN (@pastral) description: - - This module manages private network on Scaleway account - (U(https://developer.scaleway.com)). + - "This module manages private network on Scaleway account (U(https://developer.scaleway.com))." extends_documentation_fragment: - community.general.scaleway @@ -88,7 +87,7 @@ EXAMPLES = ''' RETURN = ''' scaleway_private_network: description: Information on the VPC. - returned: success when C(state=present) + returned: success when I(state=present) type: dict sample: { diff --git a/plugins/modules/scaleway_security_group.py b/plugins/modules/scaleway_security_group.py index 635309947a..d863156fa3 100644 --- a/plugins/modules/scaleway_security_group.py +++ b/plugins/modules/scaleway_security_group.py @@ -18,8 +18,7 @@ module: scaleway_security_group short_description: Scaleway Security Group management module author: Antoine Barbare (@abarbare) description: - - This module manages Security Group on Scaleway account - U(https://developer.scaleway.com). + - "This module manages Security Group on Scaleway account U(https://developer.scaleway.com)." extends_documentation_fragment: - community.general.scaleway @@ -105,8 +104,8 @@ EXAMPLES = ''' RETURN = ''' data: - description: This is only present when C(state=present) - returned: when C(state=present) + description: This is only present when I(state=present). + returned: when I(state=present) type: dict sample: { "scaleway_security_group": { diff --git a/plugins/modules/scaleway_security_group_rule.py b/plugins/modules/scaleway_security_group_rule.py index d0b16aeb50..cd27543a7b 100644 --- a/plugins/modules/scaleway_security_group_rule.py +++ b/plugins/modules/scaleway_security_group_rule.py @@ -18,8 +18,7 @@ module: scaleway_security_group_rule short_description: Scaleway Security Group Rule management module author: Antoine Barbare (@abarbare) description: - - This module manages Security Group Rule on Scaleway account - U(https://developer.scaleway.com) + - "This module manages Security Group Rule on Scaleway account U(https://developer.scaleway.com)." extends_documentation_fragment: - community.general.scaleway requirements: @@ -53,7 +52,7 @@ options: protocol: type: str description: - - Network protocol to use + - Network protocol to use. choices: - TCP - UDP @@ -62,20 +61,20 @@ options: port: description: - - Port related to the rule, null value for all the ports + - Port related to the rule, null value for all the ports. required: true type: int ip_range: type: str description: - - IPV4 CIDR notation to apply to the rule + - IPV4 CIDR notation to apply to the rule. default: 0.0.0.0/0 direction: type: str description: - - Rule direction + - Rule direction. choices: - inbound - outbound @@ -84,7 +83,7 @@ options: action: type: str description: - - Rule action + - Rule action. choices: - accept - drop @@ -93,7 +92,7 @@ options: security_group: type: str description: - - Security Group unique identifier + - Security Group unique identifier. required: true ''' @@ -113,8 +112,8 @@ EXAMPLES = ''' RETURN = ''' data: - description: This is only present when C(state=present) - returned: when C(state=present) + description: This is only present when I(state=present). + returned: when I(state=present) type: dict sample: { "scaleway_security_group_rule": { diff --git a/plugins/modules/scaleway_sshkey.py b/plugins/modules/scaleway_sshkey.py index 13dc211d36..8bb804165a 100644 --- a/plugins/modules/scaleway_sshkey.py +++ b/plugins/modules/scaleway_sshkey.py @@ -19,8 +19,7 @@ module: scaleway_sshkey short_description: Scaleway SSH keys management module author: Remy Leone (@remyleone) description: - - This module manages SSH keys on Scaleway account - U(https://developer.scaleway.com) + - "This module manages SSH keys on Scaleway account U(https://developer.scaleway.com)." extends_documentation_fragment: - community.general.scaleway @@ -42,7 +41,7 @@ options: api_url: type: str description: - - Scaleway API URL + - Scaleway API URL. default: 'https://account.scaleway.com' aliases: ['base_url'] ''' @@ -67,8 +66,8 @@ EXAMPLES = ''' RETURN = ''' data: - description: This is only present when C(state=present) - returned: when C(state=present) + description: This is only present when I(state=present). + returned: when I(state=present) type: dict sample: { "ssh_public_keys": [ diff --git a/plugins/modules/scaleway_user_data.py b/plugins/modules/scaleway_user_data.py index 37d9e94142..509ae44cc0 100644 --- a/plugins/modules/scaleway_user_data.py +++ b/plugins/modules/scaleway_user_data.py @@ -19,8 +19,8 @@ module: scaleway_user_data short_description: Scaleway user_data management module author: Remy Leone (@remyleone) description: - - "This module manages user_data on compute instances on Scaleway." - - "It can be used to configure cloud-init for instance" + - This module manages user_data on compute instances on Scaleway. + - It can be used to configure cloud-init for instance. extends_documentation_fragment: - community.general.scaleway @@ -30,20 +30,20 @@ options: server_id: type: str description: - - Scaleway Compute instance ID of the server + - Scaleway Compute instance ID of the server. required: true user_data: type: dict description: - User defined data. Typically used with C(cloud-init). - - Pass your cloud-init script here as a string + - Pass your C(cloud-init) script here as a string. required: false region: type: str description: - - Scaleway compute zone + - Scaleway compute zone. required: true choices: - ams1 diff --git a/plugins/modules/scaleway_volume.py b/plugins/modules/scaleway_volume.py index 315b5e7334..e633b4a1a7 100644 --- a/plugins/modules/scaleway_volume.py +++ b/plugins/modules/scaleway_volume.py @@ -18,8 +18,7 @@ module: scaleway_volume short_description: Scaleway volumes management module author: Henryk Konsek (@hekonsek) description: - - This module manages volumes on Scaleway account - U(https://developer.scaleway.com) + - "This module manages volumes on Scaleway account U(https://developer.scaleway.com)." extends_documentation_fragment: - community.general.scaleway @@ -28,7 +27,7 @@ options: state: type: str description: - - Indicate desired state of the volume. + - Indicate desired state of the volume. default: present choices: - present @@ -36,7 +35,7 @@ options: region: type: str description: - - Scaleway region to use (for example par1). + - Scaleway region to use (for example par1). required: true choices: - ams1 @@ -50,25 +49,25 @@ options: name: type: str description: - - Name used to identify the volume. + - Name used to identify the volume. required: true project: type: str description: - - Scaleway project ID to which volume belongs. + - Scaleway project ID to which volume belongs. version_added: 4.3.0 organization: type: str description: - - ScaleWay organization ID to which volume belongs. + - ScaleWay organization ID to which volume belongs. size: type: int description: - - Size of the volume in bytes. + - Size of the volume in bytes. volume_type: type: str description: - - Type of the volume (for example 'l_ssd'). + - Type of the volume (for example 'l_ssd'). ''' EXAMPLES = ''' @@ -91,8 +90,8 @@ EXAMPLES = ''' RETURN = ''' data: - description: This is only present when C(state=present) - returned: when C(state=present) + description: This is only present when I(state=present). + returned: when I(state=present) type: dict sample: { "volume": { @@ -100,9 +99,9 @@ data: "id": "c675f420-cfeb-48ff-ba2a-9d2a4dbe3fcd", "name": "volume-0-3", "project": "000a115d-2852-4b0a-9ce8-47f1134ba95a", - "server": null, - "size": 10000000000, - "volume_type": "l_ssd" + "server": null, + "size": 10000000000, + "volume_type": "l_ssd" } } ''' From 58eb49579762f78d04c5c15c9089c62670f7078d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Antonio=20Vali=C3=B1o=20Garc=C3=ADa?= Date: Thu, 12 Jan 2023 21:06:52 +0100 Subject: [PATCH 0119/1810] Fixes #5691. Support gitlab forking_access_level, builds_access_level and container_registry_access_level fields (#5706) * Fixes #5691. Support gitlab forking_access_level, builds_access_level and container_registry_access_level fields * Add changelog fragment * Fix revision issues --- ...06-add-builds-forks-container-registry.yml | 2 ++ plugins/modules/gitlab_project.py | 36 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 changelogs/fragments/5706-add-builds-forks-container-registry.yml diff --git a/changelogs/fragments/5706-add-builds-forks-container-registry.yml b/changelogs/fragments/5706-add-builds-forks-container-registry.yml new file mode 100644 index 0000000000..5635241b64 --- /dev/null +++ b/changelogs/fragments/5706-add-builds-forks-container-registry.yml @@ -0,0 +1,2 @@ +minor_changes: + - gitlab_project - add ``builds_access_level``, ``container_registry_access_level`` and ``forking_access_level`` options (https://github.com/ansible-collections/community.general/pull/5706). diff --git a/plugins/modules/gitlab_project.py b/plugins/modules/gitlab_project.py index ca1f8a6c64..1ab8ae220c 100644 --- a/plugins/modules/gitlab_project.py +++ b/plugins/modules/gitlab_project.py @@ -172,6 +172,30 @@ options: - This option is only used on creation, not for updates. This is also only used if I(initialize_with_readme=true). type: str version_added: "4.2.0" + builds_access_level: + description: + - C(private) means that repository CI/CD is allowed only to project members. + - C(disabled) means that repository CI/CD is disabled. + - C(enabled) means that repository CI/CD is enabled. + type: str + choices: ["private", "disabled", "enabled"] + version_added: "6.2.0" + forking_access_level: + description: + - C(private) means that repository forks is allowed only to project members. + - C(disabled) means that repository forks are disabled. + - C(enabled) means that repository forks are enabled. + type: str + choices: ["private", "disabled", "enabled"] + version_added: "6.2.0" + container_registry_access_level: + description: + - C(private) means that container registry is allowed only to project members. + - C(disabled) means that container registry is disabled. + - C(enabled) means that container registry is enabled. + type: str + choices: ["private", "disabled", "enabled"] + version_added: "6.2.0" ''' EXAMPLES = r''' @@ -287,6 +311,9 @@ class GitLabProject(object): 'squash_option': options['squash_option'], 'ci_config_path': options['ci_config_path'], 'shared_runners_enabled': options['shared_runners_enabled'], + 'builds_access_level': options['builds_access_level'], + 'forking_access_level': options['forking_access_level'], + 'container_registry_access_level': options['container_registry_access_level'], } # Because we have already call userExists in main() if self.project_object is None: @@ -417,6 +444,9 @@ def main(): ci_config_path=dict(type='str'), shared_runners_enabled=dict(type='bool'), avatar_path=dict(type='path'), + builds_access_level=dict(type='str', choices=['private', 'disabled', 'enabled']), + forking_access_level=dict(type='str', choices=['private', 'disabled', 'enabled']), + container_registry_access_level=dict(type='str', choices=['private', 'disabled', 'enabled']), )) module = AnsibleModule( @@ -464,6 +494,9 @@ def main(): shared_runners_enabled = module.params['shared_runners_enabled'] avatar_path = module.params['avatar_path'] default_branch = module.params['default_branch'] + builds_access_level = module.params['builds_access_level'] + forking_access_level = module.params['forking_access_level'] + container_registry_access_level = module.params['container_registry_access_level'] if default_branch and not initialize_with_readme: module.fail_json(msg="Param default_branch need param initialize_with_readme set to true") @@ -533,6 +566,9 @@ def main(): "ci_config_path": ci_config_path, "shared_runners_enabled": shared_runners_enabled, "avatar_path": avatar_path, + "builds_access_level": builds_access_level, + "forking_access_level": forking_access_level, + "container_registry_access_level": container_registry_access_level, }): module.exit_json(changed=True, msg="Successfully created or updated the project %s" % project_name, project=gitlab_project.project_object._attrs) From cc79c24c01010ed75b2dee116ddf36276ffd2763 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Sat, 14 Jan 2023 08:47:56 +1300 Subject: [PATCH 0120/1810] consul: deprecate params incompatible with state=absent (#5772) * consul: deprecate params incompatible with state=absent * Refrain from handling SystemExit exception * preposition * add changelog fragment * Update plugins/modules/consul.py * Update changelogs/fragments/5772-consul-deprecate-params-when-absent.yml Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein --- ...72-consul-deprecate-params-when-absent.yml | 2 ++ plugins/modules/consul.py | 26 ++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/5772-consul-deprecate-params-when-absent.yml diff --git a/changelogs/fragments/5772-consul-deprecate-params-when-absent.yml b/changelogs/fragments/5772-consul-deprecate-params-when-absent.yml new file mode 100644 index 0000000000..44d681765f --- /dev/null +++ b/changelogs/fragments/5772-consul-deprecate-params-when-absent.yml @@ -0,0 +1,2 @@ +deprecated_features: + - consul - deprecate using parameters unused for ``state=absent`` (https://github.com/ansible-collections/community.general/pull/5772). diff --git a/plugins/modules/consul.py b/plugins/modules/consul.py index ea329254a1..dea853b98e 100644 --- a/plugins/modules/consul.py +++ b/plugins/modules/consul.py @@ -149,6 +149,10 @@ options: type: str description: - The token key identifying an ACL rule set. May be required to register services. + ack_params_state_absent: + type: bool + description: + - Disable deprecation warning when using parameters incompatible with I(state=absent). ''' EXAMPLES = ''' @@ -584,7 +588,8 @@ def main(): http=dict(type='str'), timeout=dict(type='str'), tags=dict(type='list', elements='str'), - token=dict(no_log=True) + token=dict(no_log=True), + ack_params_state_absent=dict(type='bool'), ), required_if=[ ('state', 'present', ['service_name']), @@ -592,14 +597,29 @@ def main(): ], supports_check_mode=False, ) + p = module.params test_dependencies(module) + if p['state'] == 'absent' and any(p[x] for x in ['script', 'ttl', 'tcp', 'http', 'interval']) and not p['ack_params_state_absent']: + module.deprecate( + "The use of parameters 'script', 'ttl', 'tcp', 'http', 'interval' along with 'state=absent' is deprecated. " + "In community.general 8.0.0 their use will become an error. " + "To suppress this deprecation notice, set parameter ack_params_state_absent=true.", + version="8.0.0", + collection_name="community.general", + ) + # When reaching c.g 8.0.0: + # - Replace the deprecation with a fail_json(), remove the "ack_params_state_absent" condition from the "if" + # - Add mutually_exclusive for ('script', 'ttl', 'tcp', 'http'), then remove that validation from parse_check() + # - Add required_by {'script': 'interval', 'http': 'interval', 'tcp': 'interval'}, then remove checks for 'interval' in ConsulCheck.__init__() + # - Deprecate the parameter ack_params_state_absent try: register_with_consul(module) + except SystemExit: + raise except ConnectionError as e: - module.fail_json(msg='Could not connect to consul agent at %s:%s, error was %s' % ( - module.params['host'], module.params['port'], str(e))) + module.fail_json(msg='Could not connect to consul agent at %s:%s, error was %s' % (p['host'], p['port'], str(e))) except Exception as e: module.fail_json(msg=str(e)) From 08b0ea700d98d6d05724a435aa73c90ff841f4d5 Mon Sep 17 00:00:00 2001 From: bluikko <14869000+bluikko@users.noreply.github.com> Date: Sun, 15 Jan 2023 00:05:22 +0700 Subject: [PATCH 0121/1810] ldap.py: capitalize one letter (#5833) --- plugins/doc_fragments/ldap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/doc_fragments/ldap.py b/plugins/doc_fragments/ldap.py index c73e5080be..1f04c0f600 100644 --- a/plugins/doc_fragments/ldap.py +++ b/plugins/doc_fragments/ldap.py @@ -60,7 +60,7 @@ options: sasl_class: description: - The class to use for SASL authentication. - - possible choices are C(external), C(gssapi). + - Possible choices are C(external), C(gssapi). type: str choices: ['external', 'gssapi'] default: external From 6ec049734e4b54edcf8dffbad64bf777fc9701e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Servais?= Date: Sat, 14 Jan 2023 18:22:00 +0100 Subject: [PATCH 0122/1810] xml children module parameter does not exist (#5808) * Add changelog * Add integration tests * Rename children to set_children * Add PR information * Update changelogs/fragments/5808-xml-children-parameter-does-not-exist.yml Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein --- ...-xml-children-parameter-does-not-exist.yml | 2 ++ plugins/modules/xml.py | 4 +-- .../test-set-children-elements-empty-list.xml | 11 ++++++++ ...t-children-elements-empty-list.xml.license | 3 +++ .../xml/tasks/test-set-children-elements.yml | 26 +++++++++++++++++++ 5 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/5808-xml-children-parameter-does-not-exist.yml create mode 100644 tests/integration/targets/xml/results/test-set-children-elements-empty-list.xml create mode 100644 tests/integration/targets/xml/results/test-set-children-elements-empty-list.xml.license diff --git a/changelogs/fragments/5808-xml-children-parameter-does-not-exist.yml b/changelogs/fragments/5808-xml-children-parameter-does-not-exist.yml new file mode 100644 index 0000000000..2bad2c9886 --- /dev/null +++ b/changelogs/fragments/5808-xml-children-parameter-does-not-exist.yml @@ -0,0 +1,2 @@ +bugfixes: +- xml - fixed a bug where empty ``children`` list would not be set (https://github.com/ansible-collections/community.general/pull/5808). \ No newline at end of file diff --git a/plugins/modules/xml.py b/plugins/modules/xml.py index a35cc31ef0..9f16ee1344 100644 --- a/plugins/modules/xml.py +++ b/plugins/modules/xml.py @@ -266,7 +266,7 @@ EXAMPLES = r''' community.general.xml: path: /foo/bar.xml xpath: /business/website - children: [] + set_children: [] # In case of namespaces, like in below XML, they have to be explicitly stated. # @@ -961,7 +961,7 @@ def main(): # add_children && set_children both set?: should have already aborted by now # set_children set? - if set_children: + if set_children is not None: set_target_children(module, doc, xpath, namespaces, set_children, input_type) # add_children set? diff --git a/tests/integration/targets/xml/results/test-set-children-elements-empty-list.xml b/tests/integration/targets/xml/results/test-set-children-elements-empty-list.xml new file mode 100644 index 0000000000..51eb98f16b --- /dev/null +++ b/tests/integration/targets/xml/results/test-set-children-elements-empty-list.xml @@ -0,0 +1,11 @@ + + + Tasty Beverage Co. + + + 10 + + +
http://tastybeverageco.com
+
+
\ No newline at end of file diff --git a/tests/integration/targets/xml/results/test-set-children-elements-empty-list.xml.license b/tests/integration/targets/xml/results/test-set-children-elements-empty-list.xml.license new file mode 100644 index 0000000000..edff8c7685 --- /dev/null +++ b/tests/integration/targets/xml/results/test-set-children-elements-empty-list.xml.license @@ -0,0 +1,3 @@ +GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +SPDX-License-Identifier: GPL-3.0-or-later +SPDX-FileCopyrightText: Ansible Project diff --git a/tests/integration/targets/xml/tasks/test-set-children-elements.yml b/tests/integration/targets/xml/tasks/test-set-children-elements.yml index 8ab14d5080..147f493c97 100644 --- a/tests/integration/targets/xml/tasks/test-set-children-elements.yml +++ b/tests/integration/targets/xml/tasks/test-set-children-elements.yml @@ -8,6 +8,32 @@ src: fixtures/ansible-xml-beers.xml dest: /tmp/ansible-xml-beers.xml + - name: Set child elements - empty list + xml: + path: /tmp/ansible-xml-beers.xml + xpath: /business/beers + set_children: [] + register: set_children_elements + + - name: Compare to expected result + copy: + src: results/test-set-children-elements-empty-list.xml + dest: /tmp/ansible-xml-beers.xml + check_mode: yes + diff: yes + register: comparison + + - name: Test expected result + assert: + that: + - set_children_elements is changed + - comparison is not changed # identical + #command: diff -u {{ role_path }}/results/test-set-children-elements.xml /tmp/ansible-xml-beers.xml + + - name: Setup test fixture + copy: + src: fixtures/ansible-xml-beers.xml + dest: /tmp/ansible-xml-beers.xml - name: Set child elements xml: From 3985ade3fc7e97595bb3b17a15720681a16d9a5e Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 14 Jan 2023 18:35:01 +0100 Subject: [PATCH 0123/1810] Add PLATFORM docs fragment (#5837) Add PLATFORM docs fragment. --- plugins/doc_fragments/attributes.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/doc_fragments/attributes.py b/plugins/doc_fragments/attributes.py index da089dff21..e7ab495916 100644 --- a/plugins/doc_fragments/attributes.py +++ b/plugins/doc_fragments/attributes.py @@ -20,9 +20,11 @@ attributes: description: Will return details on what has changed (or possibly needs changing in C(check_mode)), when in diff mode. ''' -# platform: -# description: Target OS/families that can be operated against. -# support: N/A + PLATFORM = r''' + platform: + description: Target OS/families that can be operated against. + support: N/A +''' # Should be used together with the standard fragment INFO_MODULE = r''' From 756c0776d623ce928149db2d664451e549273ad8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Servais?= Date: Sat, 14 Jan 2023 18:37:33 +0100 Subject: [PATCH 0124/1810] apache2_module generates false/misleading warning (#5793) * Add parameter warn_mpm_module to control when warning are raised * Remoe whitespace * Add changelog fragment * Add missing license * Update changelogs/fragments/5793-apache2-module-npm-warnings.yml Co-authored-by: Felix Fontein * Update plugins/modules/apache2_module.py Co-authored-by: Felix Fontein * Update plugins/modules/apache2_module.py Co-authored-by: Felix Fontein * Update tests/integration/targets/apache2_module/tasks/635-apache2-misleading-warning.yml Co-authored-by: Felix Fontein * Refining integration test - previous was invalid * False to false * refactor assertion for suse * Revert "refactor assertion for suse" This reverts commit 61b86e7493c15a88160d0c0b955f2b08fa538a40. * Excluding test on Suse Co-authored-by: Felix Fontein --- .../5793-apache2-module-npm-warnings.yml | 2 + plugins/modules/apache2_module.py | 28 +++++++++-- .../tasks/635-apache2-misleading-warning.yml | 47 +++++++++++++++++++ .../apache2_module/tasks/actualtest.yml | 2 +- .../targets/apache2_module/tasks/main.yml | 5 ++ 5 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/5793-apache2-module-npm-warnings.yml create mode 100644 tests/integration/targets/apache2_module/tasks/635-apache2-misleading-warning.yml diff --git a/changelogs/fragments/5793-apache2-module-npm-warnings.yml b/changelogs/fragments/5793-apache2-module-npm-warnings.yml new file mode 100644 index 0000000000..a4750790a4 --- /dev/null +++ b/changelogs/fragments/5793-apache2-module-npm-warnings.yml @@ -0,0 +1,2 @@ +minor_changes: + - apache2_module - add module argument ``warn_mpm_absent`` to control whether warning are raised in some edge cases (https://github.com/ansible-collections/community.general/pull/5793). \ No newline at end of file diff --git a/plugins/modules/apache2_module.py b/plugins/modules/apache2_module.py index a58c0f0c54..e6998ad3f5 100644 --- a/plugins/modules/apache2_module.py +++ b/plugins/modules/apache2_module.py @@ -49,6 +49,12 @@ options: - Ignore configuration checks about inconsistent module configuration. Especially for mpm_* modules. type: bool default: false + warn_mpm_absent: + description: + - Control the behavior of the warning process for MPM modules. + type: bool + default: true + version_added: 6.3.0 requirements: ["a2enmod","a2dismod"] notes: - This does not work on RedHat-based distributions. It does work on Debian- and SuSE-based distributions. @@ -78,6 +84,18 @@ EXAMPLES = ''' name: mpm_worker ignore_configcheck: true +- name: Disable mpm_event, enable mpm_prefork and ignore warnings about missing mpm module + community.general.apache2_module: + name: "{{ item.module }}" + state: "{{ item.state }}" + warn_mpm_absent: false + ignore_configcheck: true + loop: + - module: mpm_event + state: absent + - module: mpm_prefork + state: present + - name: Enable dump_io module, which is identified as dumpio_module inside apache2 community.general.apache2_module: state: present @@ -140,10 +158,11 @@ def _module_is_enabled(module): error_msg = "Error executing %s: %s" % (control_binary, stderr) if module.params['ignore_configcheck']: if 'AH00534' in stderr and 'mpm_' in module.params['name']: - module.warnings.append( - "No MPM module loaded! apache2 reload AND other module actions" - " will fail if no MPM module is loaded immediately." - ) + if module.params['warn_mpm_absent']: + module.warnings.append( + "No MPM module loaded! apache2 reload AND other module actions" + " will fail if no MPM module is loaded immediately." + ) else: module.warnings.append(error_msg) return False @@ -249,6 +268,7 @@ def main(): force=dict(type='bool', default=False), state=dict(default='present', choices=['absent', 'present']), ignore_configcheck=dict(type='bool', default=False), + warn_mpm_absent=dict(type='bool', default=True), ), supports_check_mode=True, ) diff --git a/tests/integration/targets/apache2_module/tasks/635-apache2-misleading-warning.yml b/tests/integration/targets/apache2_module/tasks/635-apache2-misleading-warning.yml new file mode 100644 index 0000000000..5d93a9d300 --- /dev/null +++ b/tests/integration/targets/apache2_module/tasks/635-apache2-misleading-warning.yml @@ -0,0 +1,47 @@ +--- +# Copyright (c) Ansible Project +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later +# This test represent the misleading behavior of the following issue: https://github.com/ansible-collections/community.general/issues/635 +- name: Disable MPM event module + apache2_module: + name: "{{ item.module}}" + state: "{{ item.state}}" + ignore_configcheck: true + register: disable_mpm_modules + with_items: + - { module: mpm_event, state: absent } + - { module: mpm_prefork, state: present } + +- assert: + that: + - "'warnings' in disable_mpm_modules" + - disable_mpm_modules["warnings"] == [ + "No MPM module loaded! apache2 reload AND other module actions will fail if no MPM module is loaded immediately.", + "No MPM module loaded! apache2 reload AND other module actions will fail if no MPM module is loaded immediately." + ] + +- name: Enable MPM event module - Revert previous change + apache2_module: + name: "{{ item.module}}" + state: "{{ item.state}}" + ignore_configcheck: true + register: disable_mpm_modules + with_items: + - { module: mpm_prefork, state: absent } + - { module: mpm_event, state: present } + +- name: Disable MPM event module + apache2_module: + name: "{{ item.module}}" + state: "{{ item.state}}" + ignore_configcheck: true + warn_mpm_absent: false + register: disable_mpm_modules + with_items: + - { module: mpm_event, state: absent } + - { module: mpm_prefork, state: present } + +- assert: + that: + - "'warnings' not in disable_mpm_modules" diff --git a/tests/integration/targets/apache2_module/tasks/actualtest.yml b/tests/integration/targets/apache2_module/tasks/actualtest.yml index 156b54047d..1902cac5ee 100644 --- a/tests/integration/targets/apache2_module/tasks/actualtest.yml +++ b/tests/integration/targets/apache2_module/tasks/actualtest.yml @@ -180,7 +180,7 @@ - mpm_worker - mpm_event - mpm_prefork - ignore_errors: yes + ignore_errors: true register: remove_with_configcheck - name: ensure configcheck fails task with when run without mpm modules diff --git a/tests/integration/targets/apache2_module/tasks/main.yml b/tests/integration/targets/apache2_module/tasks/main.yml index 650e36474c..70ba14ea24 100644 --- a/tests/integration/targets/apache2_module/tasks/main.yml +++ b/tests/integration/targets/apache2_module/tasks/main.yml @@ -45,3 +45,8 @@ that: modules_before.stdout == modules_after.stdout when: ansible_os_family in ['Debian', 'Suse'] # centos/RHEL does not have a2enmod/a2dismod + +- name: include misleading warning test + include: 635-apache2-misleading-warning.yml + when: ansible_os_family in ['Debian'] + # Suse has mpm_event module compiled within the base apache2 \ No newline at end of file From f05f8bb49a54e11077adebfd7e3b2c8b1098139e Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Sun, 15 Jan 2023 06:39:05 +1300 Subject: [PATCH 0125/1810] rax modules: deprecation (#5752) * rax modules: deprecation * add changelog fragment * Update plugins/doc_fragments/rackspace.py Co-authored-by: Felix Fontein * add comment go sanity ignore files * changelog: fix typo + add rax module utils * add module utils and doc fragment to runtime.yml Co-authored-by: Felix Fontein --- changelogs/fragments/5752-rax-deprecation.yml | 28 +++++ meta/runtime.yml | 112 ++++++++++++++++++ plugins/doc_fragments/rackspace.py | 4 + tests/sanity/ignore-2.11.txt | 6 +- tests/sanity/ignore-2.12.txt | 6 +- tests/sanity/ignore-2.13.txt | 6 +- tests/sanity/ignore-2.14.txt | 6 +- tests/sanity/ignore-2.15.txt | 6 +- 8 files changed, 159 insertions(+), 15 deletions(-) create mode 100644 changelogs/fragments/5752-rax-deprecation.yml diff --git a/changelogs/fragments/5752-rax-deprecation.yml b/changelogs/fragments/5752-rax-deprecation.yml new file mode 100644 index 0000000000..4db8412208 --- /dev/null +++ b/changelogs/fragments/5752-rax-deprecation.yml @@ -0,0 +1,28 @@ +deprecated_features: + - rax_cbs_attachments - module relies on deprecated library ``pyrax`` and will be removed in community.general 9.0.0 (https://github.com/ansible-collections/community.general/pull/5752). + - rax_cbs - module relies on deprecated library ``pyrax`` and will be removed in community.general 9.0.0 (https://github.com/ansible-collections/community.general/pull/5752). + - rax_cdb_database - module relies on deprecated library ``pyrax`` and will be removed in community.general 9.0.0 (https://github.com/ansible-collections/community.general/pull/5752). + - rax_cdb - module relies on deprecated library ``pyrax`` and will be removed in community.general 9.0.0 (https://github.com/ansible-collections/community.general/pull/5752). + - rax_cdb_user - module relies on deprecated library ``pyrax`` and will be removed in community.general 9.0.0 (https://github.com/ansible-collections/community.general/pull/5752). + - rax_clb_nodes - module relies on deprecated library ``pyrax`` and will be removed in community.general 9.0.0 (https://github.com/ansible-collections/community.general/pull/5752). + - rax_clb - module relies on deprecated library ``pyrax`` and will be removed in community.general 9.0.0 (https://github.com/ansible-collections/community.general/pull/5752). + - rax_clb_ssl - module relies on deprecated library ``pyrax`` and will be removed in community.general 9.0.0 (https://github.com/ansible-collections/community.general/pull/5752). + - rax_dns - module relies on deprecated library ``pyrax`` and will be removed in community.general 9.0.0 (https://github.com/ansible-collections/community.general/pull/5752). + - rax_dns_record - module relies on deprecated library ``pyrax`` and will be removed in community.general 9.0.0 (https://github.com/ansible-collections/community.general/pull/5752). + - rax_facts - module relies on deprecated library ``pyrax`` and will be removed in community.general 9.0.0 (https://github.com/ansible-collections/community.general/pull/5752). + - rax_files_objects - module relies on deprecated library ``pyrax`` and will be removed in community.general 9.0.0 (https://github.com/ansible-collections/community.general/pull/5752). + - rax_files - module relies on deprecated library ``pyrax`` and will be removed in community.general 9.0.0 (https://github.com/ansible-collections/community.general/pull/5752). + - rax_identity - module relies on deprecated library ``pyrax`` and will be removed in community.general 9.0.0 (https://github.com/ansible-collections/community.general/pull/5752). + - rax_keypair - module relies on deprecated library ``pyrax`` and will be removed in community.general 9.0.0 (https://github.com/ansible-collections/community.general/pull/5752). + - rax_meta - module relies on deprecated library ``pyrax`` and will be removed in community.general 9.0.0 (https://github.com/ansible-collections/community.general/pull/5752). + - rax_mon_alarm - module relies on deprecated library ``pyrax`` and will be removed in community.general 9.0.0 (https://github.com/ansible-collections/community.general/pull/5752). + - rax_mon_check - module relies on deprecated library ``pyrax`` and will be removed in community.general 9.0.0 (https://github.com/ansible-collections/community.general/pull/5752). + - rax_mon_entity - module relies on deprecated library ``pyrax`` and will be removed in community.general 9.0.0 (https://github.com/ansible-collections/community.general/pull/5752). + - rax_mon_notification_plan - module relies on deprecated library ``pyrax`` and will be removed in community.general 9.0.0 (https://github.com/ansible-collections/community.general/pull/5752). + - rax_mon_notification - module relies on deprecated library ``pyrax`` and will be removed in community.general 9.0.0 (https://github.com/ansible-collections/community.general/pull/5752). + - rax_network - module relies on deprecated library ``pyrax`` and will be removed in community.general 9.0.0 (https://github.com/ansible-collections/community.general/pull/5752). + - rax - module relies on deprecated library ``pyrax`` and will be removed in community.general 9.0.0 (https://github.com/ansible-collections/community.general/pull/5752). + - rax_queue - module relies on deprecated library ``pyrax`` and will be removed in community.general 9.0.0 (https://github.com/ansible-collections/community.general/pull/5752). + - rax_scaling_group - module relies on deprecated library ``pyrax`` and will be removed in community.general 9.0.0 (https://github.com/ansible-collections/community.general/pull/5752). + - rax_scaling_policy - module relies on deprecated library ``pyrax`` and will be removed in community.general 9.0.0 (https://github.com/ansible-collections/community.general/pull/5752). + - rax module utils - module utils code relies on deprecated library ``pyrax`` and will be removed in community.general 9.0.0 (https://github.com/ansible-collections/community.general/pull/5752). diff --git a/meta/runtime.yml b/meta/runtime.yml index 9d15860ac4..0cdb1bedc8 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -22,6 +22,110 @@ plugin_routing: nios_next_network: redirect: infoblox.nios_modules.nios_next_network modules: + rax_cbs_attachments: + deprecation: + removal_version: 9.0.0 + warning_text: This module relies on the deprecated package pyrax. + rax_cbs: + deprecation: + removal_version: 9.0.0 + warning_text: This module relies on the deprecated package pyrax. + rax_cdb_database: + deprecation: + removal_version: 9.0.0 + warning_text: This module relies on the deprecated package pyrax. + rax_cdb_user: + deprecation: + removal_version: 9.0.0 + warning_text: This module relies on the deprecated package pyrax. + rax_cdb: + deprecation: + removal_version: 9.0.0 + warning_text: This module relies on the deprecated package pyrax. + rax_clb_nodes: + deprecation: + removal_version: 9.0.0 + warning_text: This module relies on the deprecated package pyrax. + rax_clb_ssl: + deprecation: + removal_version: 9.0.0 + warning_text: This module relies on the deprecated package pyrax. + rax_clb: + deprecation: + removal_version: 9.0.0 + warning_text: This module relies on the deprecated package pyrax. + rax_dns_record: + deprecation: + removal_version: 9.0.0 + warning_text: This module relies on the deprecated package pyrax. + rax_dns: + deprecation: + removal_version: 9.0.0 + warning_text: This module relies on the deprecated package pyrax. + rax_facts: + deprecation: + removal_version: 9.0.0 + warning_text: This module relies on the deprecated package pyrax. + rax_files_objects: + deprecation: + removal_version: 9.0.0 + warning_text: This module relies on the deprecated package pyrax. + rax_files: + deprecation: + removal_version: 9.0.0 + warning_text: This module relies on the deprecated package pyrax. + rax_identity: + deprecation: + removal_version: 9.0.0 + warning_text: This module relies on the deprecated package pyrax. + rax_keypair: + deprecation: + removal_version: 9.0.0 + warning_text: This module relies on the deprecated package pyrax. + rax_meta: + deprecation: + removal_version: 9.0.0 + warning_text: This module relies on the deprecated package pyrax. + rax_mon_alarm: + deprecation: + removal_version: 9.0.0 + warning_text: This module relies on the deprecated package pyrax. + rax: + deprecation: + removal_version: 9.0.0 + warning_text: This module relies on the deprecated package pyrax. + rax_mon_check: + deprecation: + removal_version: 9.0.0 + warning_text: This module relies on the deprecated package pyrax. + rax_mon_entity: + deprecation: + removal_version: 9.0.0 + warning_text: This module relies on the deprecated package pyrax. + rax_mon_notification_plan: + deprecation: + removal_version: 9.0.0 + warning_text: This module relies on the deprecated package pyrax. + rax_mon_notification: + deprecation: + removal_version: 9.0.0 + warning_text: This module relies on the deprecated package pyrax. + rax_network: + deprecation: + removal_version: 9.0.0 + warning_text: This module relies on the deprecated package pyrax. + rax_queue: + deprecation: + removal_version: 9.0.0 + warning_text: This module relies on the deprecated package pyrax. + rax_scaling_group: + deprecation: + removal_version: 9.0.0 + warning_text: This module relies on the deprecated package pyrax. + rax_scaling_policy: + deprecation: + removal_version: 9.0.0 + warning_text: This module relies on the deprecated package pyrax. database.aerospike.aerospike_migrations: redirect: community.general.aerospike_migrations deprecation: @@ -4499,6 +4603,10 @@ plugin_routing: modules. This has never been supported or documented, and will stop working in community.general 9.0.0. doc_fragments: + rackspace: + deprecation: + removal_version: 9.0.0 + warning_text: This doc fragment is used by rax modules, that rely on the deprecated package pyrax. _gcp: redirect: community.google._gcp docker: @@ -4514,6 +4622,10 @@ plugin_routing: postgresql: redirect: community.postgresql.postgresql module_utils: + rax: + deprecation: + removal_version: 9.0.0 + warning_text: This module util relies on the deprecated package pyrax. docker.common: redirect: community.docker.common docker.swarm: diff --git a/plugins/doc_fragments/rackspace.py b/plugins/doc_fragments/rackspace.py index 9e22316022..6f902a2395 100644 --- a/plugins/doc_fragments/rackspace.py +++ b/plugins/doc_fragments/rackspace.py @@ -105,6 +105,10 @@ options: - Whether or not to require SSL validation of API endpoints. type: bool aliases: [ verify_ssl ] +deprecated: + removed_in: 9.0.0 + why: This module relies on the deprecated package pyrax. + alternative: Use the Openstack modules instead. requirements: - python >= 2.6 - pyrax diff --git a/tests/sanity/ignore-2.11.txt b/tests/sanity/ignore-2.11.txt index 39b09d887a..508785f220 100644 --- a/tests/sanity/ignore-2.11.txt +++ b/tests/sanity/ignore-2.11.txt @@ -19,9 +19,9 @@ plugins/modules/manageiq_tags.py validate-modules:parameter-state-invalid-choice plugins/modules/osx_defaults.py validate-modules:parameter-state-invalid-choice plugins/modules/parted.py validate-modules:parameter-state-invalid-choice plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias - removed in 7.0.0 -plugins/modules/rax_files_objects.py use-argspec-type-path -plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice -plugins/modules/rax.py use-argspec-type-path # fix needed +plugins/modules/rax_files_objects.py use-argspec-type-path # module deprecated - removed in 9.0.0 +plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice # module deprecated - removed in 9.0.0 +plugins/modules/rax.py use-argspec-type-path # module deprecated - removed in 9.0.0 plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/xfconf.py validate-modules:return-syntax-error plugins/modules/yarn.py use-argspec-type-path diff --git a/tests/sanity/ignore-2.12.txt b/tests/sanity/ignore-2.12.txt index 47244bb515..77a0105529 100644 --- a/tests/sanity/ignore-2.12.txt +++ b/tests/sanity/ignore-2.12.txt @@ -14,9 +14,9 @@ plugins/modules/manageiq_tags.py validate-modules:parameter-state-invalid-choice plugins/modules/osx_defaults.py validate-modules:parameter-state-invalid-choice plugins/modules/parted.py validate-modules:parameter-state-invalid-choice plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias - removed in 7.0.0 -plugins/modules/rax_files_objects.py use-argspec-type-path -plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice -plugins/modules/rax.py use-argspec-type-path # fix needed +plugins/modules/rax_files_objects.py use-argspec-type-path # module deprecated - removed in 9.0.0 +plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice # module deprecated - removed in 9.0.0 +plugins/modules/rax.py use-argspec-type-path # module deprecated - removed in 9.0.0 plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/xfconf.py validate-modules:return-syntax-error plugins/modules/yarn.py use-argspec-type-path diff --git a/tests/sanity/ignore-2.13.txt b/tests/sanity/ignore-2.13.txt index 47244bb515..77a0105529 100644 --- a/tests/sanity/ignore-2.13.txt +++ b/tests/sanity/ignore-2.13.txt @@ -14,9 +14,9 @@ plugins/modules/manageiq_tags.py validate-modules:parameter-state-invalid-choice plugins/modules/osx_defaults.py validate-modules:parameter-state-invalid-choice plugins/modules/parted.py validate-modules:parameter-state-invalid-choice plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias - removed in 7.0.0 -plugins/modules/rax_files_objects.py use-argspec-type-path -plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice -plugins/modules/rax.py use-argspec-type-path # fix needed +plugins/modules/rax_files_objects.py use-argspec-type-path # module deprecated - removed in 9.0.0 +plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice # module deprecated - removed in 9.0.0 +plugins/modules/rax.py use-argspec-type-path # module deprecated - removed in 9.0.0 plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/xfconf.py validate-modules:return-syntax-error plugins/modules/yarn.py use-argspec-type-path diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt index a2e9e37325..db0e449b79 100644 --- a/tests/sanity/ignore-2.14.txt +++ b/tests/sanity/ignore-2.14.txt @@ -15,9 +15,9 @@ plugins/modules/manageiq_tags.py validate-modules:parameter-state-invalid-choice plugins/modules/osx_defaults.py validate-modules:parameter-state-invalid-choice plugins/modules/parted.py validate-modules:parameter-state-invalid-choice plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias - removed in 7.0.0 -plugins/modules/rax_files_objects.py use-argspec-type-path -plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice -plugins/modules/rax.py use-argspec-type-path # fix needed +plugins/modules/rax_files_objects.py use-argspec-type-path # module deprecated - removed in 9.0.0 +plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice # module deprecated - removed in 9.0.0 +plugins/modules/rax.py use-argspec-type-path # module deprecated - removed in 9.0.0 plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/udm_user.py import-3.11 # Uses deprecated stdlib library 'crypt' plugins/modules/xfconf.py validate-modules:return-syntax-error diff --git a/tests/sanity/ignore-2.15.txt b/tests/sanity/ignore-2.15.txt index a2e9e37325..db0e449b79 100644 --- a/tests/sanity/ignore-2.15.txt +++ b/tests/sanity/ignore-2.15.txt @@ -15,9 +15,9 @@ plugins/modules/manageiq_tags.py validate-modules:parameter-state-invalid-choice plugins/modules/osx_defaults.py validate-modules:parameter-state-invalid-choice plugins/modules/parted.py validate-modules:parameter-state-invalid-choice plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias - removed in 7.0.0 -plugins/modules/rax_files_objects.py use-argspec-type-path -plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice -plugins/modules/rax.py use-argspec-type-path # fix needed +plugins/modules/rax_files_objects.py use-argspec-type-path # module deprecated - removed in 9.0.0 +plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice # module deprecated - removed in 9.0.0 +plugins/modules/rax.py use-argspec-type-path # module deprecated - removed in 9.0.0 plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/udm_user.py import-3.11 # Uses deprecated stdlib library 'crypt' plugins/modules/xfconf.py validate-modules:return-syntax-error From 937dea6af33eb9b01aef405ab2bf6ee9ea242675 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sun, 15 Jan 2023 18:44:50 +0100 Subject: [PATCH 0126/1810] Remove leftovers. --- CHANGELOG.rst | 240 ++------------------------------------------------ 1 file changed, 5 insertions(+), 235 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 3b83faa551..119e04e170 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,236 +1,6 @@ -=============================== -Community General Release Notes -=============================== +Placeholder changelog +===================== -.. contents:: Topics - -This changelog describes changes after version 5.0.0. - -v6.0.0-a1 -========= - -Release Summary ---------------- - -This is a pre-release for the upcoming 6.0.0 major release. The main objective of this pre-release is to make it possible to test the large stuctural changes by flattening the directory structure. See the corresponding entry in the changelog for details. - -Major Changes -------------- - -- The internal structure of the collection was changed for modules and action plugins. These no longer live in a directory hierarchy ordered by topic, but instead are now all in a single (flat) directory. This has no impact on users *assuming they did not use internal FQCNs*. These will still work, but result in deprecation warnings. They were never officially supported and thus the redirects are kept as a courtsey, and this is not labelled as a breaking change. Note that for example the Ansible VScode plugin started recommending these internal names. If you followed its recommendation, you will now have to change back to the short names to avoid deprecation warnings, and potential errors in the future as these redirects will be removed in community.general 9.0.0 (https://github.com/ansible-collections/community.general/pull/5461). -- newrelic_deployment - removed New Relic v1 API, added support for v2 API (https://github.com/ansible-collections/community.general/pull/5341). - -Minor Changes -------------- - -- Added MIT license as ``LICENSES/MIT.txt`` for tests/unit/plugins/modules/packaging/language/test_gem.py (https://github.com/ansible-collections/community.general/pull/5065). -- All software licenses are now in the ``LICENSES/`` directory of the collection root (https://github.com/ansible-collections/community.general/pull/5065, https://github.com/ansible-collections/community.general/pull/5079, https://github.com/ansible-collections/community.general/pull/5080, https://github.com/ansible-collections/community.general/pull/5083, https://github.com/ansible-collections/community.general/pull/5087, https://github.com/ansible-collections/community.general/pull/5095, https://github.com/ansible-collections/community.general/pull/5098, https://github.com/ansible-collections/community.general/pull/5106). -- ModuleHelper module utils - added property ``verbosity`` to base class (https://github.com/ansible-collections/community.general/pull/5035). -- ModuleHelper module utils - improved ``ModuleHelperException``, using ``to_native()`` for the exception message (https://github.com/ansible-collections/community.general/pull/4755). -- The collection repository conforms to the `REUSE specification `__ except for the changelog fragments (https://github.com/ansible-collections/community.general/pull/5138). -- ali_instance - minor refactor when checking for installed dependency (https://github.com/ansible-collections/community.general/pull/5240). -- ali_instance_info - minor refactor when checking for installed dependency (https://github.com/ansible-collections/community.general/pull/5240). -- alternatives - add ``state=absent`` to be able to remove an alternative (https://github.com/ansible-collections/community.general/pull/4654). -- alternatives - add ``subcommands`` parameter (https://github.com/ansible-collections/community.general/pull/4654). -- ansible_galaxy_install - minor refactoring using latest ``ModuleHelper`` updates (https://github.com/ansible-collections/community.general/pull/4752). -- apk - add ``world`` parameter for supporting a custom world file (https://github.com/ansible-collections/community.general/pull/4976). -- bitwarden lookup plugin - add option ``search`` to search for other attributes than name (https://github.com/ansible-collections/community.general/pull/5297). -- cartesian lookup plugin - start using Ansible's configuration manager to parse options (https://github.com/ansible-collections/community.general/pull/5440). -- cmd_runner module util - added parameters ``check_mode_skip`` and ``check_mode_return`` to ``CmdRunner.context()``, so that the command is not executed when ``check_mode=True`` (https://github.com/ansible-collections/community.general/pull/4736). -- cmd_runner module utils - add ``__call__`` method to invoke context (https://github.com/ansible-collections/community.general/pull/4791). -- consul - adds ``ttl`` parameter for session (https://github.com/ansible-collections/community.general/pull/4996). -- consul - minor refactoring (https://github.com/ansible-collections/community.general/pull/5367). -- consul_session - adds ``token`` parameter for session (https://github.com/ansible-collections/community.general/pull/5193). -- cpanm - using ``do_raise()`` to raise exceptions in ``ModuleHelper`` derived modules (https://github.com/ansible-collections/community.general/pull/4674). -- credstash lookup plugin - start using Ansible's configuration manager to parse options (https://github.com/ansible-collections/community.general/pull/5440). -- dependent lookup plugin - start using Ansible's configuration manager to parse options (https://github.com/ansible-collections/community.general/pull/5440). -- dig lookup plugin - add option ``fail_on_error`` to allow stopping execution on lookup failures (https://github.com/ansible-collections/community.general/pull/4973). -- dig lookup plugin - start using Ansible's configuration manager to parse options. All documented options can now also be passed as lookup parameters (https://github.com/ansible-collections/community.general/pull/5440). -- dnstxt lookup plugin - start using Ansible's configuration manager to parse options (https://github.com/ansible-collections/community.general/pull/5440). -- filetree lookup plugin - start using Ansible's configuration manager to parse options (https://github.com/ansible-collections/community.general/pull/5440). -- flattened lookup plugin - start using Ansible's configuration manager to parse options (https://github.com/ansible-collections/community.general/pull/5440). -- gitlab module util - minor refactor when checking for installed dependency (https://github.com/ansible-collections/community.general/pull/5259). -- gitlab_branch - minor refactor when checking for installed dependency (https://github.com/ansible-collections/community.general/pull/5259). -- gitlab_deploy_key - minor refactor when checking for installed dependency (https://github.com/ansible-collections/community.general/pull/5259). -- gitlab_group - minor refactor when checking for installed dependency (https://github.com/ansible-collections/community.general/pull/5259). -- gitlab_group_members - minor refactor when checking for installed dependency (https://github.com/ansible-collections/community.general/pull/5259). -- gitlab_group_variable - minor refactor when checking for installed dependency (https://github.com/ansible-collections/community.general/pull/5259). -- gitlab_hook - minor refactor when checking for installed dependency (https://github.com/ansible-collections/community.general/pull/5259). -- gitlab_hook - minor refactoring (https://github.com/ansible-collections/community.general/pull/5271). -- gitlab_project - minor refactor when checking for installed dependency (https://github.com/ansible-collections/community.general/pull/5259). -- gitlab_project_members - minor refactor when checking for installed dependency (https://github.com/ansible-collections/community.general/pull/5259). -- gitlab_project_variable - minor refactor when checking for installed dependency (https://github.com/ansible-collections/community.general/pull/5259). -- gitlab_protected_branch - minor refactor when checking for installed dependency (https://github.com/ansible-collections/community.general/pull/5259). -- gitlab_runner - minor refactor when checking for installed dependency (https://github.com/ansible-collections/community.general/pull/5259). -- gitlab_user - minor refactor when checking for installed dependency (https://github.com/ansible-collections/community.general/pull/5259). -- hiera lookup plugin - start using Ansible's configuration manager to parse options. The Hiera executable and config file can now also be passed as lookup parameters (https://github.com/ansible-collections/community.general/pull/5440). -- homebrew, homebrew_tap - added Homebrew on Linux path to defaults (https://github.com/ansible-collections/community.general/pull/5241). -- keycloak_* modules - add ``http_agent`` parameter with default value ``Ansible`` (https://github.com/ansible-collections/community.general/issues/5023). -- keyring lookup plugin - start using Ansible's configuration manager to parse options (https://github.com/ansible-collections/community.general/pull/5440). -- lastpass - use config manager for handling plugin options (https://github.com/ansible-collections/community.general/pull/5022). -- linode inventory plugin - simplify option handling (https://github.com/ansible-collections/community.general/pull/5438). -- listen_ports_facts - add new ``include_non_listening`` option which adds ``-a`` option to ``netstat`` and ``ss``. This shows both listening and non-listening (for TCP this means established connections) sockets, and returns ``state`` and ``foreign_address`` (https://github.com/ansible-collections/community.general/issues/4762, https://github.com/ansible-collections/community.general/pull/4953). -- lmdb_kv lookup plugin - start using Ansible's configuration manager to parse options (https://github.com/ansible-collections/community.general/pull/5440). -- lxc_container - minor refactoring (https://github.com/ansible-collections/community.general/pull/5358). -- machinectl become plugin - can now be used with a password from another user than root, if a polkit rule is present (https://github.com/ansible-collections/community.general/pull/4849). -- machinectl become plugin - combine the success command when building the become command to be consistent with other become plugins (https://github.com/ansible-collections/community.general/pull/5287). -- manifold lookup plugin - start using Ansible's configuration manager to parse options (https://github.com/ansible-collections/community.general/pull/5440). -- maven_artifact - add a new ``unredirected_headers`` option that can be used with ansible-core 2.12 and above. The default value is to not use ``Authorization`` and ``Cookie`` headers on redirects for security reasons. With ansible-core 2.11, all headers are still passed on for redirects (https://github.com/ansible-collections/community.general/pull/4812). -- mksysb - using ``do_raise()`` to raise exceptions in ``ModuleHelper`` derived modules (https://github.com/ansible-collections/community.general/pull/4674). -- nagios - minor refactoring on parameter validation for different actions (https://github.com/ansible-collections/community.general/pull/5239). -- netcup_dnsapi - add ``timeout`` parameter (https://github.com/ansible-collections/community.general/pull/5301). -- nmcli - add ``transport_mode`` configuration for Infiniband devices (https://github.com/ansible-collections/community.general/pull/5361). -- nmcli - add bond option ``xmit_hash_policy`` to bond options (https://github.com/ansible-collections/community.general/issues/5148). -- nmcli - adds ``vpn`` type and parameter for supporting VPN with service type L2TP and PPTP (https://github.com/ansible-collections/community.general/pull/4746). -- nmcli - honor IP options for VPNs (https://github.com/ansible-collections/community.general/pull/5228). -- opentelemetry callback plugin - allow configuring opentelementry callback via config file (https://github.com/ansible-collections/community.general/pull/4916). -- opentelemetry callback plugin - send logs. This can be disabled by setting ``disable_logs=false`` (https://github.com/ansible-collections/community.general/pull/4175). -- pacman - added parameters ``reason`` and ``reason_for`` to set/change the install reason of packages (https://github.com/ansible-collections/community.general/pull/4956). -- passwordstore lookup plugin - allow options to be passed lookup options instead of being part of the term strings (https://github.com/ansible-collections/community.general/pull/5444). -- passwordstore lookup plugin - allow using alternative password managers by detecting wrapper scripts, allow explicit configuration of pass and gopass backends (https://github.com/ansible-collections/community.general/issues/4766). -- passwordstore lookup plugin - improve error messages to include stderr (https://github.com/ansible-collections/community.general/pull/5436) -- pipx - added state ``latest`` to the module (https://github.com/ansible-collections/community.general/pull/5105). -- pipx - changed implementation to use ``cmd_runner`` (https://github.com/ansible-collections/community.general/pull/5085). -- pipx - module fails faster when ``name`` is missing for states ``upgrade`` and ``reinstall`` (https://github.com/ansible-collections/community.general/pull/5100). -- pipx - using ``do_raise()`` to raise exceptions in ``ModuleHelper`` derived modules (https://github.com/ansible-collections/community.general/pull/4674). -- pipx module utils - created new module util ``pipx`` providing a ``cmd_runner`` specific for the ``pipx`` module (https://github.com/ansible-collections/community.general/pull/5085). -- portage - add knobs for Portage's ``--backtrack`` and ``--with-bdeps`` options (https://github.com/ansible-collections/community.general/pull/5349). -- portage - use Portage's python module instead of calling gentoolkit-provided program in shell (https://github.com/ansible-collections/community.general/pull/5349). -- proxmox inventory plugin - added new flag ``qemu_extended_statuses`` and new groups ``prelaunch``, ``paused``. They will be populated only when ``want_facts=true``, ``qemu_extended_statuses=true`` and only for ``QEMU`` machines (https://github.com/ansible-collections/community.general/pull/4723). -- proxmox inventory plugin - simplify option handling code (https://github.com/ansible-collections/community.general/pull/5437). -- proxmox module utils, the proxmox* modules - add ``api_task_ok`` helper to standardize API task status checks across all proxmox modules (https://github.com/ansible-collections/community.general/pull/5274). -- proxmox_kvm - allow ``agent`` argument to be a string (https://github.com/ansible-collections/community.general/pull/5107). -- proxmox_snap - add ``unbind`` param to support snapshotting containers with configured mountpoints (https://github.com/ansible-collections/community.general/pull/5274). -- puppet - adds ``confdir`` parameter to configure a custom confir location (https://github.com/ansible-collections/community.general/pull/4740). -- redfish - added new command GetVirtualMedia, VirtualMediaInsert and VirtualMediaEject to Systems category due to Redfish spec changes the virtualMedia resource location from Manager to System (https://github.com/ansible-collections/community.general/pull/5124). -- redfish_config - add ``SetSessionService`` to set default session timeout policy (https://github.com/ansible-collections/community.general/issues/5008). -- redfish_info - add ``GetManagerInventory`` to report list of Manager inventory information (https://github.com/ansible-collections/community.general/issues/4899). -- seport - added new argument ``local`` (https://github.com/ansible-collections/community.general/pull/5203) -- snap - using ``do_raise()`` to raise exceptions in ``ModuleHelper`` derived modules (https://github.com/ansible-collections/community.general/pull/4674). -- sudoers - will attempt to validate the proposed sudoers rule using visudo if available, optionally skipped, or required (https://github.com/ansible-collections/community.general/pull/4794, https://github.com/ansible-collections/community.general/issues/4745). -- terraform - adds capability to handle complex variable structures for ``variables`` parameter in the module. This must be enabled with the new ``complex_vars`` parameter (https://github.com/ansible-collections/community.general/pull/4797). -- terraform - run ``terraform init`` with ``-no-color`` not to mess up the stdout of the task (https://github.com/ansible-collections/community.general/pull/5147). -- wdc_redfish_command - add ``IndicatorLedOn`` and ``IndicatorLedOff`` commands for ``Chassis`` category (https://github.com/ansible-collections/community.general/pull/5059). -- wdc_redfish_command - add ``PowerModeLow`` and ``PowerModeNormal`` commands for ``Chassis`` category (https://github.com/ansible-collections/community.general/pull/5145). -- xfconf - add ``stdout``, ``stderr`` and ``cmd`` to the module results (https://github.com/ansible-collections/community.general/pull/5037). -- xfconf - changed implementation to use ``cmd_runner`` (https://github.com/ansible-collections/community.general/pull/4776). -- xfconf - use ``do_raise()`` instead of defining custom exception class (https://github.com/ansible-collections/community.general/pull/4975). -- xfconf - using ``do_raise()`` to raise exceptions in ``ModuleHelper`` derived modules (https://github.com/ansible-collections/community.general/pull/4674). -- xfconf module utils - created new module util ``xfconf`` providing a ``cmd_runner`` specific for ``xfconf`` modules (https://github.com/ansible-collections/community.general/pull/4776). -- xfconf_info - changed implementation to use ``cmd_runner`` (https://github.com/ansible-collections/community.general/pull/4776). -- xfconf_info - use ``do_raise()`` instead of defining custom exception class (https://github.com/ansible-collections/community.general/pull/4975). -- znode - possibility to use ZooKeeper ACL authentication (https://github.com/ansible-collections/community.general/pull/5306). - -Breaking Changes / Porting Guide --------------------------------- - -- newrelic_deployment - ``revision`` is required for v2 API (https://github.com/ansible-collections/community.general/pull/5341). - -Deprecated Features -------------------- - -- ArgFormat module utils - deprecated along ``CmdMixin``, in favor of the ``cmd_runner_fmt`` module util (https://github.com/ansible-collections/community.general/pull/5370). -- CmdMixin module utils - deprecated in favor of the ``CmdRunner`` module util (https://github.com/ansible-collections/community.general/pull/5370). -- CmdModuleHelper module utils - deprecated in favor of the ``CmdRunner`` module util (https://github.com/ansible-collections/community.general/pull/5370). -- CmdStateModuleHelper module utils - deprecated in favor of the ``CmdRunner`` module util (https://github.com/ansible-collections/community.general/pull/5370). -- cmd_runner module utils - deprecated ``fmt`` in favour of ``cmd_runner_fmt`` as the parameter format object (https://github.com/ansible-collections/community.general/pull/4777). -- django_manage - support for Django releases older than 4.1 has been deprecated and will be removed in community.general 9.0.0 (https://github.com/ansible-collections/community.general/pull/5400). -- django_manage - support for the commands ``cleanup``, ``syncdb`` and ``validate`` that have been deprecated in Django long time ago will be removed in community.general 9.0.0 (https://github.com/ansible-collections/community.general/pull/5400). -- django_manage - the behavior of "creating the virtual environment when missing" is being deprecated and will be removed in community.general version 9.0.0 (https://github.com/ansible-collections/community.general/pull/5405). -- gconftool2 - deprecates ``state=get`` in favor of using the module ``gconftool2_info`` (https://github.com/ansible-collections/community.general/pull/4778). -- lxc_container - the module will no longer make any effort to support Python 2 (https://github.com/ansible-collections/community.general/pull/5304). -- newrelic_deployment - ``appname`` and ``environment`` are no longer valid options in the v2 API. They will be removed in community.general 7.0.0 (https://github.com/ansible-collections/community.general/pull/5341). -- proxmox - deprecated the current ``unprivileged`` default value, will be changed to ``true`` in community.general 7.0.0 (https://github.com/pull/5224). -- xfconf - deprecated parameter ``disable_facts``, as since version 4.0.0 it only allows value ``true`` (https://github.com/ansible-collections/community.general/pull/4520). - -Removed Features (previously deprecated) ----------------------------------------- - -- bitbucket* modules - ``username`` is no longer an alias of ``workspace``, but of ``user`` (https://github.com/ansible-collections/community.general/pull/5326). -- gem - the default of the ``norc`` option changed from ``false`` to ``true`` (https://github.com/ansible-collections/community.general/pull/5326). -- gitlab_group_members - ``gitlab_group`` must now always contain the full path, and no longer just the name or path (https://github.com/ansible-collections/community.general/pull/5326). -- keycloak_authentication - the return value ``flow`` has been removed. Use ``end_state`` instead (https://github.com/ansible-collections/community.general/pull/5326). -- keycloak_group - the return value ``group`` has been removed. Use ``end_state`` instead (https://github.com/ansible-collections/community.general/pull/5326). -- lxd_container - the default of the ``ignore_volatile_options`` option changed from ``true`` to ``false`` (https://github.com/ansible-collections/community.general/pull/5326). -- mail callback plugin - the ``sender`` option is now required (https://github.com/ansible-collections/community.general/pull/5326). -- module_helper module utils - remove the ``VarDict`` attribute from ``ModuleHelper``. Import ``VarDict`` from ``ansible_collections.community.general.plugins.module_utils.mh.mixins.vars`` instead (https://github.com/ansible-collections/community.general/pull/5326). -- proxmox inventory plugin - the default of the ``want_proxmox_nodes_ansible_host`` option changed from ``true`` to ``false`` (https://github.com/ansible-collections/community.general/pull/5326). -- vmadm - the ``debug`` option has been removed. It was not used anyway (https://github.com/ansible-collections/community.general/pull/5326). - -Bugfixes --------- - -- Include ``PSF-license.txt`` file for ``plugins/module_utils/_mount.py``. -- Include ``simplified_bsd.txt`` license file for various module utils, the ``lxca_common`` docs fragment, and the ``utm_utils`` unit tests. -- alternatives - do not set the priority if the priority was not set by the user (https://github.com/ansible-collections/community.general/pull/4810). -- alternatives - only pass subcommands when they are specified as module arguments (https://github.com/ansible-collections/community.general/issues/4803, https://github.com/ansible-collections/community.general/issues/4804, https://github.com/ansible-collections/community.general/pull/4836). -- alternatives - when ``subcommands`` is specified, ``link`` must be given for every subcommand. This was already mentioned in the documentation, but not enforced by the code (https://github.com/ansible-collections/community.general/pull/4836). -- apache2_mod_proxy - avoid crash when reporting inability to parse balancer_member_page HTML caused by using an undefined variable in the error message (https://github.com/ansible-collections/community.general/pull/5111). -- archive - avoid crash when ``lzma`` is not present and ``format`` is not ``xz`` (https://github.com/ansible-collections/community.general/pull/5393). -- cmd_runner module utils - fix bug caused by using the ``command`` variable instead of ``self.command`` when looking for binary path (https://github.com/ansible-collections/community.general/pull/4903). -- consul - fixed bug introduced in PR 4590 (https://github.com/ansible-collections/community.general/issues/4680). -- credstash lookup plugin - pass plugin options to credstash for all terms, not just for the first (https://github.com/ansible-collections/community.general/pull/5440). -- dig lookup plugin - add option to return empty result without empty strings, and return empty list instead of ``NXDOMAIN`` (https://github.com/ansible-collections/community.general/pull/5439, https://github.com/ansible-collections/community.general/issues/5428). -- dig lookup plugin - fix evaluation of falsy values for boolean parameters ``fail_on_error`` and ``retry_servfail`` (https://github.com/ansible-collections/community.general/pull/5129). -- dnsimple_info - correctly report missing library as ``requests`` and not ``another_library`` (https://github.com/ansible-collections/community.general/pull/5111). -- dnstxt lookup plugin - add option to return empty result without empty strings, and return empty list instead of ``NXDOMAIN`` (https://github.com/ansible-collections/community.general/pull/5457, https://github.com/ansible-collections/community.general/issues/5428). -- dsv lookup plugin - do not ignore the ``tld`` parameter (https://github.com/ansible-collections/community.general/pull/4911). -- filesystem - handle ``fatresize --info`` output lines without ``:`` (https://github.com/ansible-collections/community.general/pull/4700). -- filesystem - improve error messages when output cannot be parsed by including newlines in escaped form (https://github.com/ansible-collections/community.general/pull/4700). -- funcd connection plugin - fix signature of ``exec_command`` (https://github.com/ansible-collections/community.general/pull/5111). -- ini_file - minor refactor fixing a python lint error (https://github.com/ansible-collections/community.general/pull/5307). -- keycloak_realm - fix default groups and roles (https://github.com/ansible-collections/community.general/issues/4241). -- keyring_info - fix the result from the keyring library never getting returned (https://github.com/ansible-collections/community.general/pull/4964). -- ldap_attrs - fix ordering issue by ignoring the ``{x}`` prefix on attribute values (https://github.com/ansible-collections/community.general/issues/977, https://github.com/ansible-collections/community.general/pull/5385). -- listen_ports_facts - removed leftover ``EnvironmentError`` . The ``else`` clause had a wrong indentation. The check is now handled in the ``split_pid_name`` function (https://github.com/ansible-collections/community.general/pull/5202). -- locale_gen - fix support for Ubuntu (https://github.com/ansible-collections/community.general/issues/5281). -- lxc_container - the module has been updated to support Python 3 (https://github.com/ansible-collections/community.general/pull/5304). -- lxd connection plugin - fix incorrect ``inventory_hostname`` in ``remote_addr``. This is needed for compatibility with ansible-core 2.13 (https://github.com/ansible-collections/community.general/issues/4886). -- manageiq_alert_profiles - avoid crash when reporting unknown profile caused by trying to return an undefined variable (https://github.com/ansible-collections/community.general/pull/5111). -- nmcli - avoid changed status for most cases with VPN connections (https://github.com/ansible-collections/community.general/pull/5126). -- nmcli - fix error caused by adding undefined module arguments for list options (https://github.com/ansible-collections/community.general/issues/4373, https://github.com/ansible-collections/community.general/pull/4813). -- nmcli - fix error when setting previously unset MAC address, ``gsm.apn`` or ``vpn.data``: current values were being normalized without checking if they might be ``None`` (https://github.com/ansible-collections/community.general/pull/5291). -- nmcli - fix int options idempotence (https://github.com/ansible-collections/community.general/issues/4998). -- nsupdate - compatibility with NS records (https://github.com/ansible-collections/community.general/pull/5112). -- nsupdate - fix silent failures when updating ``NS`` entries from Bind9 managed DNS zones (https://github.com/ansible-collections/community.general/issues/4657). -- opentelemetry callback plugin - support opentelemetry-api 1.13.0 that removed support for ``_time_ns`` (https://github.com/ansible-collections/community.general/pull/5342). -- osx_defaults - no longer expand ``~`` in ``value`` to the user's home directory, or expand environment variables (https://github.com/ansible-collections/community.general/issues/5234, https://github.com/ansible-collections/community.general/pull/5243). -- packet_ip_subnet - fix error reporting in case of invalid CIDR prefix lengths (https://github.com/ansible-collections/community.general/pull/5111). -- pacman - fixed name resolution of URL packages (https://github.com/ansible-collections/community.general/pull/4959). -- passwordstore lookup plugin - fix ``returnall`` for gopass (https://github.com/ansible-collections/community.general/pull/5027). -- passwordstore lookup plugin - fix password store path detection for gopass (https://github.com/ansible-collections/community.general/pull/4955). -- pfexec become plugin - remove superflous quotes preventing exe wrap from working as expected (https://github.com/ansible-collections/community.general/issues/3671, https://github.com/ansible-collections/community.general/pull/3889). -- pip_package_info - remove usage of global variable (https://github.com/ansible-collections/community.general/pull/5111). -- pkgng - fix case when ``pkg`` fails when trying to upgrade all packages (https://github.com/ansible-collections/community.general/issues/5363). -- proxmox - fix error handling when getting VM by name when ``state=absent`` (https://github.com/ansible-collections/community.general/pull/4945). -- proxmox inventory plugin - fix crash when ``enabled=1`` is used in agent config string (https://github.com/ansible-collections/community.general/pull/4910). -- proxmox inventory plugin - fixed extended status detection for qemu (https://github.com/ansible-collections/community.general/pull/4816). -- proxmox_kvm - fix ``agent`` parameter when boolean value is specified (https://github.com/ansible-collections/community.general/pull/5198). -- proxmox_kvm - fix error handling when getting VM by name when ``state=absent`` (https://github.com/ansible-collections/community.general/pull/4945). -- proxmox_kvm - fix exception when no ``agent`` argument is specified (https://github.com/ansible-collections/community.general/pull/5194). -- proxmox_kvm - fix wrong condition (https://github.com/ansible-collections/community.general/pull/5108). -- proxmox_kvm - replace new condition with proper condition to allow for using ``vmid`` on update (https://github.com/ansible-collections/community.general/pull/5206). -- rax_clb_nodes - fix code to be compatible with Python 3 (https://github.com/ansible-collections/community.general/pull/4933). -- redfish_command - fix the check if a virtual media is unmounted to just check for ``instered= false`` caused by Supermicro hardware that does not clear the ``ImageName`` (https://github.com/ansible-collections/community.general/pull/4839). -- redfish_command - the Supermicro Redfish implementation only supports the ``image_url`` parameter in the underlying API calls to ``VirtualMediaInsert`` and ``VirtualMediaEject``. Any values set (or the defaults) for ``write_protected`` or ``inserted`` will be ignored (https://github.com/ansible-collections/community.general/pull/4839). -- redfish_info - fix to ``GetChassisPower`` to correctly report power information when multiple chassis exist, but not all chassis report power information (https://github.com/ansible-collections/community.general/issues/4901). -- redfish_utils module utils - centralize payload checking when performing modification requests to a Redfish service (https://github.com/ansible-collections/community.general/issues/5210/). -- redhat_subscription - fix unsubscribing on RHEL 9 (https://github.com/ansible-collections/community.general/issues/4741). -- redhat_subscription - make module idempotent when ``pool_ids`` are used (https://github.com/ansible-collections/community.general/issues/5313). -- redis* modules - fix call to ``module.fail_json`` when failing because of missing Python libraries (https://github.com/ansible-collections/community.general/pull/4733). -- slack - fix incorrect channel prefix ``#`` caused by incomplete pattern detection by adding ``G0`` and ``GF`` as channel ID patterns (https://github.com/ansible-collections/community.general/pull/5019). -- slack - fix message update for channels which start with ``CP``. When ``message-id`` was passed it failed for channels which started with ``CP`` because the ``#`` symbol was added before the ``channel_id`` (https://github.com/ansible-collections/community.general/pull/5249). -- sudoers - ensure sudoers config files are created with the permissions requested by sudoers (0440) (https://github.com/ansible-collections/community.general/pull/4814). -- sudoers - fix incorrect handling of ``state: absent`` (https://github.com/ansible-collections/community.general/issues/4852). -- tss lookup plugin - adding support for updated Delinea library (https://github.com/DelineaXPM/python-tss-sdk/issues/9, https://github.com/ansible-collections/community.general/pull/5151). -- virtualbox inventory plugin - skip parsing values with keys that have both a value and nested data. Skip parsing values that are nested more than two keys deep (https://github.com/ansible-collections/community.general/issues/5332, https://github.com/ansible-collections/community.general/pull/5348). -- xcc_redfish_command - for compatibility due to Redfish spec changes the virtualMedia resource location changed from Manager to System (https://github.com/ansible-collections/community.general/pull/4682). -- xenserver_facts - fix broken ``AnsibleModule`` call that prevented the module from working at all (https://github.com/ansible-collections/community.general/pull/5383). -- xfconf - fix setting of boolean values (https://github.com/ansible-collections/community.general/issues/4999, https://github.com/ansible-collections/community.general/pull/5007). -- zfs - fix wrong quoting of properties (https://github.com/ansible-collections/community.general/issues/4707, https://github.com/ansible-collections/community.general/pull/4726). - -New Modules ------------ - -- scaleway_function_namespace - Scaleway Function namespace management -- scaleway_function_namespace_info - Retrieve information on Scaleway Function namespace +This file is a placeholder; a version-specific ``CHANGELOG-vX.rst`` will be generated during releases from fragments +under ``changelogs/fragments``. On release branches once a release has been created, consult the branch's version-specific +file for changes that have occurred in that branch. From 44172ddaa6130d2441954da54da0ea70caf41521 Mon Sep 17 00:00:00 2001 From: Kristian Heljas <11139388+kristianheljas@users.noreply.github.com> Date: Mon, 16 Jan 2023 23:54:07 +0200 Subject: [PATCH 0127/1810] Add -no-color argument to terraform validation (#5843) --- changelogs/fragments/5843-terraform-validate-no-color.yml | 2 ++ plugins/modules/terraform.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/5843-terraform-validate-no-color.yml diff --git a/changelogs/fragments/5843-terraform-validate-no-color.yml b/changelogs/fragments/5843-terraform-validate-no-color.yml new file mode 100644 index 0000000000..25cc6045ad --- /dev/null +++ b/changelogs/fragments/5843-terraform-validate-no-color.yml @@ -0,0 +1,2 @@ +bugfixes: +- terraform module - disable ANSI escape sequences during validation phase (https://github.com/ansible-collections/community.general/pull/5843). \ No newline at end of file diff --git a/plugins/modules/terraform.py b/plugins/modules/terraform.py index 2a018ea03c..b6b09b0eb2 100644 --- a/plugins/modules/terraform.py +++ b/plugins/modules/terraform.py @@ -299,9 +299,9 @@ def preflight_validation(bin_path, project_path, version, variables_args=None, p if not os.path.isdir(project_path): module.fail_json(msg="Path for Terraform project '{0}' doesn't exist on this host - check the path and try again please.".format(project_path)) if LooseVersion(version) < LooseVersion('0.15.0'): - rc, out, err = module.run_command([bin_path, 'validate'] + variables_args, check_rc=True, cwd=project_path) + module.run_command([bin_path, 'validate', '-no-color'] + variables_args, check_rc=True, cwd=project_path) else: - rc, out, err = module.run_command([bin_path, 'validate'], check_rc=True, cwd=project_path) + module.run_command([bin_path, 'validate', '-no-color'], check_rc=True, cwd=project_path) def _state_args(state_file): From 5ad703ac64026f88a401880b52fb25dab49237bc Mon Sep 17 00:00:00 2001 From: n0p90 <36303164+n0p90@users.noreply.github.com> Date: Tue, 17 Jan 2023 20:03:38 +0000 Subject: [PATCH 0128/1810] nsupdate: fix zone lookup (#5818) The SOA record for an existing zone is returned as an answer RR and not as an authority RR. It can be returned as an authority RR for subdomains of a zone. $ dig -t SOA example.com ;; ANSWER SECTION: example.com. 3530 IN SOA ns.icann.org. noc.dns.icann.org. 2022091184 7200 3600 1209600 3600 $ dig -t SOA www.example.com ;; AUTHORITY SECTION: example.com. 3600 IN SOA ns.icann.org. noc.dns.icann.org. 2022091184 7200 3600 1209600 3600 --- .../fragments/5818-nsupdate-fix-zone-lookup.yml | 2 ++ plugins/modules/nsupdate.py | 16 ++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 changelogs/fragments/5818-nsupdate-fix-zone-lookup.yml diff --git a/changelogs/fragments/5818-nsupdate-fix-zone-lookup.yml b/changelogs/fragments/5818-nsupdate-fix-zone-lookup.yml new file mode 100644 index 0000000000..4f6ed6a125 --- /dev/null +++ b/changelogs/fragments/5818-nsupdate-fix-zone-lookup.yml @@ -0,0 +1,2 @@ +bugfixes: + - nsupdate - fix zone lookup. The SOA record for an existing zone is returned as an answer RR and not as an authority RR (https://github.com/ansible-collections/community.general/issues/5817, https://github.com/ansible-collections/community.general/pull/5818). diff --git a/plugins/modules/nsupdate.py b/plugins/modules/nsupdate.py index 2be4863b68..bc31521cdb 100644 --- a/plugins/modules/nsupdate.py +++ b/plugins/modules/nsupdate.py @@ -269,12 +269,16 @@ class RecordManager(object): if lookup.rcode() in [dns.rcode.SERVFAIL, dns.rcode.REFUSED]: self.module.fail_json(msg='Zone lookup failure: \'%s\' will not respond to queries regarding \'%s\'.' % ( self.module.params['server'], self.module.params['record'])) - try: - zone = lookup.authority[0].name - if zone == name: - return zone.to_text() - except IndexError: - pass + # If the response contains an Answer SOA RR whose name matches the queried name, + # this is the name of the zone in which the record needs to be inserted. + for rr in lookup.answer: + if rr.rdtype == dns.rdatatype.SOA and rr.name == name: + return rr.name.to_text() + # If the response contains an Authority SOA RR whose name is a subdomain of the queried name, + # this SOA name is the zone in which the record needs to be inserted. + for rr in lookup.authority: + if rr.rdtype == dns.rdatatype.SOA and name.fullcompare(rr.name)[0] == dns.name.NAMERELN_SUBDOMAIN: + return rr.name.to_text() try: name = name.parent() except dns.name.NoParent: From 4a40f99cd69d5cc75cdd7537a928be09de70e23b Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Wed, 18 Jan 2023 07:54:50 +0100 Subject: [PATCH 0129/1810] Add extended PR template (#5622) * Add extended PR template. * Improvements. * Apply suggestions from code review Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> * Update .github/ISSUE_TEMPLATE/feature_request.yml Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> --- .github/ISSUE_TEMPLATE/bug_report.yml | 2 +- .../ISSUE_TEMPLATE/documentation_report.yml | 4 +-- .github/ISSUE_TEMPLATE/feature_request.yml | 4 +-- .github/pull_request_template.md | 32 +++++++++++++++++++ .github/pull_request_template.md.license | 3 ++ CONTRIBUTING.md | 2 +- 6 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 .github/pull_request_template.md create mode 100644 .github/pull_request_template.md.license diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index bd5030f2c2..f64de2abe3 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -47,7 +47,7 @@ body: label: Component Name description: >- Write the short name of the module, plugin, task or feature below, - *use your best guess if unsure*. + *use your best guess if unsure*. Do not include `community.general.`! placeholder: dnf, apt, yum, pip, user etc. validations: required: true diff --git a/.github/ISSUE_TEMPLATE/documentation_report.yml b/.github/ISSUE_TEMPLATE/documentation_report.yml index 3a2777f207..6ec49fcb37 100644 --- a/.github/ISSUE_TEMPLATE/documentation_report.yml +++ b/.github/ISSUE_TEMPLATE/documentation_report.yml @@ -46,8 +46,8 @@ body: attributes: label: Component Name description: >- - Write the short name of the rst file, module, plugin, task or - feature below, *use your best guess if unsure*. + Write the short name of the file, module, plugin, task or feature below, + *use your best guess if unsure*. Do not include `community.general.`! placeholder: mysql_user validations: required: true diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index 9630b67e12..f34564283c 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -42,8 +42,8 @@ body: attributes: label: Component Name description: >- - Write the short name of the module, plugin, task or feature below, - *use your best guess if unsure*. + Write the short name of the module or plugin, or which other part(s) of the collection this feature affects. + *use your best guess if unsure*. Do not include `community.general.`! placeholder: dnf, apt, yum, pip, user etc. validations: required: true diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000000..29a2d2e36a --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,32 @@ +##### SUMMARY + + + + + + +##### ISSUE TYPE + +- Bugfix Pull Request +- Docs Pull Request +- Feature Pull Request +- New Module/Plugin Pull Request +- Refactoring Pull Request +- Test Pull Request + +##### COMPONENT NAME + + +##### ADDITIONAL INFORMATION + + + + +```paste below + +``` diff --git a/.github/pull_request_template.md.license b/.github/pull_request_template.md.license new file mode 100644 index 0000000000..a1390a69ed --- /dev/null +++ b/.github/pull_request_template.md.license @@ -0,0 +1,3 @@ +Copyright (c) Ansible Project +GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +SPDX-License-Identifier: GPL-3.0-or-later diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 358daa5e91..4048f32a81 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -31,7 +31,7 @@ Also, consider taking up a valuable, reviewed, but abandoned pull request which * Try committing your changes with an informative but short commit message. * Do not squash your commits and force-push to your branch if not needed. Reviews of your pull request are much easier with individual commits to comprehend the pull request history. All commits of your pull request branch will be squashed into one commit by GitHub upon merge. * Do not add merge commits to your PR. The bot will complain and you will have to rebase ([instructions for rebasing](https://docs.ansible.com/ansible/latest/dev_guide/developing_rebasing.html)) to remove them before your PR can be merged. To avoid that git automatically does merges during pulls, you can configure it to do rebases instead by running `git config pull.rebase true` inside the repository checkout. -* Make sure your PR includes a [changelog fragment](https://docs.ansible.com/ansible/devel/community/development_process.html#creating-changelog-fragments). (You must not include a fragment for new modules or new plugins, except for test and filter plugins. Also you shouldn't include one for docs-only changes. If you're not sure, simply don't include one, we'll tell you whether one is needed or not :) ) +* Make sure your PR includes a [changelog fragment](https://docs.ansible.com/ansible/devel/community/development_process.html#creating-changelog-fragments). (You must not include a fragment for new modules or new plugins. Also you shouldn't include one for docs-only changes. If you're not sure, simply don't include one, we'll tell you whether one is needed or not :) ) * Avoid reformatting unrelated parts of the codebase in your PR. These types of changes will likely be requested for reversion, create additional work for reviewers, and may cause approval to be delayed. You can also read [our Quick-start development guide](https://github.com/ansible/community-docs/blob/main/create_pr_quick_start_guide.rst). From b92542dea2bf542c95bc2f4b494276bda2a5d18f Mon Sep 17 00:00:00 2001 From: Bhavya <44067558+Bhavya06@users.noreply.github.com> Date: Wed, 18 Jan 2023 12:29:13 +0530 Subject: [PATCH 0130/1810] Minor changes to HPE iLO collection (#5804) * Minor changes to setting IPs of servers * Lint fix * Added change log * Update changelogs/fragments/5804-minor-changes-to-hpe-ilo-collection.yml Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein --- ...04-minor-changes-to-hpe-ilo-collection.yml | 2 ++ plugins/module_utils/ilo_redfish_utils.py | 35 +++++++++---------- plugins/modules/ilo_redfish_config.py | 2 +- 3 files changed, 19 insertions(+), 20 deletions(-) create mode 100644 changelogs/fragments/5804-minor-changes-to-hpe-ilo-collection.yml diff --git a/changelogs/fragments/5804-minor-changes-to-hpe-ilo-collection.yml b/changelogs/fragments/5804-minor-changes-to-hpe-ilo-collection.yml new file mode 100644 index 0000000000..b53bd9eecf --- /dev/null +++ b/changelogs/fragments/5804-minor-changes-to-hpe-ilo-collection.yml @@ -0,0 +1,2 @@ +minor_changes: + - ilo_redfish_utils module utils - change implementation of DNS Server IP and NTP Server IP update (https://github.com/ansible-collections/community.general/pull/5804). diff --git a/plugins/module_utils/ilo_redfish_utils.py b/plugins/module_utils/ilo_redfish_utils.py index 2d4d999cef..a6ab42dba6 100644 --- a/plugins/module_utils/ilo_redfish_utils.py +++ b/plugins/module_utils/ilo_redfish_utils.py @@ -85,17 +85,16 @@ class iLORedfishUtils(RedfishUtils): datetime_uri = self.manager_uri + "DateTime" - response = self.get_request(self.root_uri + datetime_uri) - if not response['ret']: - return response + listofips = mgr_attributes['mgr_attr_value'].split(" ") + if len(listofips) > 2: + return {'ret': False, 'changed': False, 'msg': "More than 2 NTP Servers mentioned"} - data = response['data'] + ntp_list = [] + for ips in listofips: + ntp_list.append(ips) - ntp_list = data[setkey] - if len(ntp_list) == 2: - ntp_list.pop(0) - - ntp_list.append(mgr_attributes['mgr_attr_value']) + while len(ntp_list) < 2: + ntp_list.append("0.0.0.0") payload = {setkey: ntp_list} @@ -137,18 +136,16 @@ class iLORedfishUtils(RedfishUtils): nic_info = self.get_manager_ethernet_uri() uri = nic_info["nic_addr"] - response = self.get_request(self.root_uri + uri) - if not response['ret']: - return response + listofips = attr['mgr_attr_value'].split(" ") + if len(listofips) > 3: + return {'ret': False, 'changed': False, 'msg': "More than 3 DNS Servers mentioned"} - data = response['data'] + dns_list = [] + for ips in listofips: + dns_list.append(ips) - dns_list = data["Oem"]["Hpe"]["IPv4"][key] - - if len(dns_list) == 3: - dns_list.pop(0) - - dns_list.append(attr['mgr_attr_value']) + while len(dns_list) < 3: + dns_list.append("0.0.0.0") payload = { "Oem": { diff --git a/plugins/modules/ilo_redfish_config.py b/plugins/modules/ilo_redfish_config.py index d13d10dfdc..1c68127fa4 100644 --- a/plugins/modules/ilo_redfish_config.py +++ b/plugins/modules/ilo_redfish_config.py @@ -125,7 +125,7 @@ def main(): password=dict(no_log=True), auth_token=dict(no_log=True), attribute_name=dict(required=True), - attribute_value=dict(), + attribute_value=dict(type='str'), timeout=dict(type='int', default=10) ), required_together=[ From a35b2eda4c7dec53677063cb183a89b1236af608 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Wed, 18 Jan 2023 20:05:31 +1300 Subject: [PATCH 0131/1810] iptables_state: minor pythonisms (#5844) * iptables_state: minor pythonisms * add changelog fragment * fix typo --- .../5844-iptables-state-refactor.yml | 2 ++ plugins/modules/iptables_state.py | 20 +++++-------------- 2 files changed, 7 insertions(+), 15 deletions(-) create mode 100644 changelogs/fragments/5844-iptables-state-refactor.yml diff --git a/changelogs/fragments/5844-iptables-state-refactor.yml b/changelogs/fragments/5844-iptables-state-refactor.yml new file mode 100644 index 0000000000..a69b88de24 --- /dev/null +++ b/changelogs/fragments/5844-iptables-state-refactor.yml @@ -0,0 +1,2 @@ +minor_changes: + - iptables_state - minor refactoring within the module (https://github.com/ansible-collections/community.general/pull/5844). diff --git a/plugins/modules/iptables_state.py b/plugins/modules/iptables_state.py index 1e94631c7f..17f8d9eb70 100644 --- a/plugins/modules/iptables_state.py +++ b/plugins/modules/iptables_state.py @@ -260,10 +260,7 @@ def read_state(b_path): ''' with open(b_path, 'r') as f: text = f.read() - lines = text.splitlines() - while '' in lines: - lines.remove('') - return lines + return [t for t in text.splitlines() if t != ''] def write_state(b_path, lines, changed): @@ -273,8 +270,7 @@ def write_state(b_path, lines, changed): # Populate a temporary file tmpfd, tmpfile = tempfile.mkstemp() with os.fdopen(tmpfd, 'w') as f: - for line in lines: - f.write('%s\n' % line) + f.write("{0}\n".format("\n".join(lines))) # Prepare to copy temporary file to the final destination if not os.path.exists(b_path): @@ -335,9 +331,7 @@ def filter_and_format_state(string): string = re.sub(r'((^|\n)# (Generated|Completed)[^\n]*) on [^\n]*', r'\1', string) if not module.params['counters']: string = re.sub(r'\[[0-9]+:[0-9]+\]', r'[0:0]', string) - lines = string.splitlines() - while '' in lines: - lines.remove('') + lines = [line for line in string.splitlines() if line != ''] return lines @@ -354,10 +348,7 @@ def per_table_state(command, state): dummy, out, dummy = module.run_command(COMMAND, check_rc=True) out = re.sub(r'(^|\n)(# Generated|# Completed|[*]%s|COMMIT)[^\n]*' % t, r'', out) out = re.sub(r' *\[[0-9]+:[0-9]+\] *', r'', out) - table = out.splitlines() - while '' in table: - table.remove('') - tables[t] = table + tables[t] = [tt for tt in out.splitlines() if tt != ''] return tables @@ -548,8 +539,7 @@ def main(): if module.check_mode: tmpfd, tmpfile = tempfile.mkstemp() with os.fdopen(tmpfd, 'w') as f: - for line in initial_state: - f.write('%s\n' % line) + f.write("{0}\n".format("\n".join(initial_state))) if filecmp.cmp(tmpfile, b_path): restored_state = initial_state From 1430ed000c704fb03f0ad65d25285c0921f012a0 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Thu, 19 Jan 2023 09:28:16 +1300 Subject: [PATCH 0132/1810] pipx: add testcase w/ env vars PIPX_xxxx (#5845) * pipx: add testcase w/ env vars PIPX_xxxx * add note to the docs about env vars * add note to the docs about env vars * Apply suggestions from code review * Update plugins/modules/pipx.py Co-authored-by: Felix Fontein * Update plugins/modules/pipx_info.py Co-authored-by: Felix Fontein * break long lines into smaller ones Co-authored-by: Felix Fontein --- plugins/modules/pipx.py | 3 +++ plugins/modules/pipx_info.py | 3 +++ tests/integration/targets/pipx/tasks/main.yml | 27 +++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/plugins/modules/pipx.py b/plugins/modules/pipx.py index a94b7d8d03..773fbef8ea 100644 --- a/plugins/modules/pipx.py +++ b/plugins/modules/pipx.py @@ -95,6 +95,9 @@ options: notes: - This module does not install the C(pipx) python package, however that can be easily done with the module M(ansible.builtin.pip). - This module does not require C(pipx) to be in the shell C(PATH), but it must be loadable by Python as a module. + - > + This module will honor C(pipx) environment variables such as but not limited to C(PIPX_HOME) and C(PIPX_BIN_DIR) + passed using the R(environment Ansible keyword, playbooks_environment). - Please note that C(pipx) requires Python 3.6 or above. - > This first implementation does not verify whether a specified version constraint has been installed or not. diff --git a/plugins/modules/pipx_info.py b/plugins/modules/pipx_info.py index ff9698e31d..4487cdab5a 100644 --- a/plugins/modules/pipx_info.py +++ b/plugins/modules/pipx_info.py @@ -50,6 +50,9 @@ options: notes: - This module does not install the C(pipx) python package, however that can be easily done with the module M(ansible.builtin.pip). - This module does not require C(pipx) to be in the shell C(PATH), but it must be loadable by Python as a module. + - > + This module will honor C(pipx) environment variables such as but not limited to C(PIPX_HOME) and C(PIPX_BIN_DIR) + passed using the R(environment Ansible keyword, playbooks_environment). - Please note that C(pipx) requires Python 3.6 or above. - See also the C(pipx) documentation at U(https://pypa.github.io/pipx/). author: diff --git a/tests/integration/targets/pipx/tasks/main.yml b/tests/integration/targets/pipx/tasks/main.yml index 2318a59ba4..00f54aeb24 100644 --- a/tests/integration/targets/pipx/tasks/main.yml +++ b/tests/integration/targets/pipx/tasks/main.yml @@ -230,3 +230,30 @@ that: - install_jupyter is changed - '"ipython" in install_jupyter.stdout' + +############################################################################## +- name: ensure /opt/pipx + ansible.builtin.file: + path: /opt/pipx + state: directory + mode: 0755 + +- name: install tox site-wide + community.general.pipx: + name: tox + state: latest + register: install_tox_sitewide + environment: + PIPX_HOME: /opt/pipx + PIPX_BIN_DIR: /usr/local/bin + +- name: stat /usr/local/bin/tox + ansible.builtin.stat: + path: /usr/local/bin/tox + register: usrlocaltox + +- name: check assertions + ansible.builtin.assert: + that: + - install_tox_sitewide is changed + - usrlocaltox.stat.exists From c4b18361b990fac683e0438a154eeac23b38d590 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Wed, 18 Jan 2023 21:32:40 +0100 Subject: [PATCH 0133/1810] scaleway module utils: make function private that should be removed (#5499) * Make function private that should be removed (ref: #5497). * Maybe it works as a comment? * Try something else. * Ok, let's just add a comment. * Last try: docstring instead of comment. --- plugins/module_utils/scaleway.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/module_utils/scaleway.py b/plugins/module_utils/scaleway.py index a44c52aa78..43f2094800 100644 --- a/plugins/module_utils/scaleway.py +++ b/plugins/module_utils/scaleway.py @@ -84,6 +84,10 @@ def parse_pagination_link(header): def filter_sensitive_attributes(container, attributes): + ''' + WARNING: This function is effectively private, **do not use it**! + It will be removed or renamed once changing its name no longer triggers a pylint bug. + ''' for attr in attributes: container[attr] = "SENSITIVE_VALUE" From 59a9d34250aaf4bb213acf4ecda4ea91da1ae7ac Mon Sep 17 00:00:00 2001 From: Mike Moerk Date: Sun, 22 Jan 2023 09:10:36 -0700 Subject: [PATCH 0134/1810] Remote management modules for OCAPI-based devices. (#5754) * Remote management modules for OCAPI-based devices. Open Composable API (OCAPI) is a REST-based API designed for data center composability. For more information, see https://www.opencompute.org/documents/open-composable-api-for-ocp-2019-06-24-pdf This PR introduces ocapi_command and ocapi_info modules. These are based on the existing redfish_command and redfish_info modules and follow similar patterns. This initial implementation includes support for the folowing operations: - Indicator LED toggling - Power state toggling - Enclosure reset (reboot) - Firmware upload - Firmware update - Firmware activate - Job deletion - Job status These modules have been tested against Western Digital OpenFlex(tm) Data24 storage enclosures. API reference is at https://documents.westerndigital.com/content/dam/doc-library/en_us/assets/public/western-digital/product/platforms/openflex/reference-architecture-open-composable-api.pdf * Fix licensing issue for ocapi_utils.py * PR Feedback * Apply suggestions from code review Co-authored-by: Felix Fontein * Update plugins/module_utils/ocapi_utils.py Co-authored-by: Felix Fontein * Update plugins/modules/ocapi_info.py Co-authored-by: Felix Fontein * Apply suggestions from code review Co-authored-by: Felix Fontein * PR Feedback Use six module for urlparse * Apply suggestions from code review Documentation fixes. Co-authored-by: Felix Fontein * Fix sanity test line too long error. Co-authored-by: Felix Fontein --- .github/BOTMETA.yml | 4 + plugins/module_utils/ocapi_utils.py | 502 ++++++++++++++ plugins/modules/ocapi_command.py | 267 ++++++++ plugins/modules/ocapi_info.py | 221 ++++++ .../plugins/module_utils/test_ocapi_utils.py | 54 ++ .../plugins/modules/test_ocapi_command.py | 639 ++++++++++++++++++ tests/unit/plugins/modules/test_ocapi_info.py | 240 +++++++ 7 files changed, 1927 insertions(+) create mode 100644 plugins/module_utils/ocapi_utils.py create mode 100644 plugins/modules/ocapi_command.py create mode 100644 plugins/modules/ocapi_info.py create mode 100644 tests/unit/plugins/module_utils/test_ocapi_utils.py create mode 100644 tests/unit/plugins/modules/test_ocapi_command.py create mode 100644 tests/unit/plugins/modules/test_ocapi_info.py diff --git a/.github/BOTMETA.yml b/.github/BOTMETA.yml index 047d537895..2051e34e0a 100644 --- a/.github/BOTMETA.yml +++ b/.github/BOTMETA.yml @@ -828,6 +828,10 @@ files: maintainers: shane-walker xcambar $modules/nsupdate.py: maintainers: nerzhul + $modules/ocapi_command.py: + maintainers: $team_wdc + $modules/ocapi_info.py: + maintainers: $team_wdc $modules/oci_vcn.py: maintainers: $team_oracle rohitChaware $modules/odbc.py: diff --git a/plugins/module_utils/ocapi_utils.py b/plugins/module_utils/ocapi_utils.py new file mode 100644 index 0000000000..acc2ceae49 --- /dev/null +++ b/plugins/module_utils/ocapi_utils.py @@ -0,0 +1,502 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2022 Western Digital Corporation +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +import json +import os +import uuid + +from ansible.module_utils.urls import open_url +from ansible.module_utils.common.text.converters import to_native +from ansible.module_utils.common.text.converters import to_text +from ansible.module_utils.six.moves.urllib.error import URLError, HTTPError +from ansible.module_utils.six.moves.urllib.parse import urlparse + + +GET_HEADERS = {'accept': 'application/json'} +PUT_HEADERS = {'content-type': 'application/json', 'accept': 'application/json'} +POST_HEADERS = {'content-type': 'application/json', 'accept': 'application/json'} +DELETE_HEADERS = {'accept': 'application/json'} + +HEALTH_OK = 5 + + +class OcapiUtils(object): + + def __init__(self, creds, base_uri, proxy_slot_number, timeout, module): + self.root_uri = base_uri + self.proxy_slot_number = proxy_slot_number + self.creds = creds + self.timeout = timeout + self.module = module + + def _auth_params(self): + """ + Return tuple of required authentication params based on the username and password. + + :return: tuple of username, password + """ + username = self.creds['user'] + password = self.creds['pswd'] + force_basic_auth = True + return username, password, force_basic_auth + + def get_request(self, uri): + req_headers = dict(GET_HEADERS) + username, password, basic_auth = self._auth_params() + try: + resp = open_url(uri, method="GET", headers=req_headers, + url_username=username, url_password=password, + force_basic_auth=basic_auth, validate_certs=False, + follow_redirects='all', + use_proxy=True, timeout=self.timeout) + data = json.loads(to_native(resp.read())) + headers = dict((k.lower(), v) for (k, v) in resp.info().items()) + except HTTPError as e: + return {'ret': False, + 'msg': "HTTP Error %s on GET request to '%s'" + % (e.code, uri), + 'status': e.code} + except URLError as e: + return {'ret': False, 'msg': "URL Error on GET request to '%s': '%s'" + % (uri, e.reason)} + # Almost all errors should be caught above, but just in case + except Exception as e: + return {'ret': False, + 'msg': "Failed GET request to '%s': '%s'" % (uri, to_text(e))} + return {'ret': True, 'data': data, 'headers': headers} + + def delete_request(self, uri, etag=None): + req_headers = dict(DELETE_HEADERS) + if etag is not None: + req_headers['If-Match'] = etag + username, password, basic_auth = self._auth_params() + try: + resp = open_url(uri, method="DELETE", headers=req_headers, + url_username=username, url_password=password, + force_basic_auth=basic_auth, validate_certs=False, + follow_redirects='all', + use_proxy=True, timeout=self.timeout) + if resp.status != 204: + data = json.loads(to_native(resp.read())) + else: + data = "" + headers = dict((k.lower(), v) for (k, v) in resp.info().items()) + except HTTPError as e: + return {'ret': False, + 'msg': "HTTP Error %s on DELETE request to '%s'" + % (e.code, uri), + 'status': e.code} + except URLError as e: + return {'ret': False, 'msg': "URL Error on DELETE request to '%s': '%s'" + % (uri, e.reason)} + # Almost all errors should be caught above, but just in case + except Exception as e: + return {'ret': False, + 'msg': "Failed DELETE request to '%s': '%s'" % (uri, to_text(e))} + return {'ret': True, 'data': data, 'headers': headers} + + def put_request(self, uri, payload, etag=None): + req_headers = dict(PUT_HEADERS) + if etag is not None: + req_headers['If-Match'] = etag + username, password, basic_auth = self._auth_params() + try: + resp = open_url(uri, data=json.dumps(payload), + headers=req_headers, method="PUT", + url_username=username, url_password=password, + force_basic_auth=basic_auth, validate_certs=False, + follow_redirects='all', + use_proxy=True, timeout=self.timeout) + headers = dict((k.lower(), v) for (k, v) in resp.info().items()) + except HTTPError as e: + return {'ret': False, + 'msg': "HTTP Error %s on PUT request to '%s'" + % (e.code, uri), + 'status': e.code} + except URLError as e: + return {'ret': False, 'msg': "URL Error on PUT request to '%s': '%s'" + % (uri, e.reason)} + # Almost all errors should be caught above, but just in case + except Exception as e: + return {'ret': False, + 'msg': "Failed PUT request to '%s': '%s'" % (uri, to_text(e))} + return {'ret': True, 'headers': headers, 'resp': resp} + + def post_request(self, uri, payload, content_type="application/json", timeout=None): + req_headers = dict(POST_HEADERS) + if content_type != "application/json": + req_headers["content-type"] = content_type + username, password, basic_auth = self._auth_params() + if content_type == "application/json": + request_data = json.dumps(payload) + else: + request_data = payload + try: + resp = open_url(uri, data=request_data, + headers=req_headers, method="POST", + url_username=username, url_password=password, + force_basic_auth=basic_auth, validate_certs=False, + follow_redirects='all', + use_proxy=True, timeout=self.timeout if timeout is None else timeout) + headers = dict((k.lower(), v) for (k, v) in resp.info().items()) + except HTTPError as e: + return {'ret': False, + 'msg': "HTTP Error %s on POST request to '%s'" + % (e.code, uri), + 'status': e.code} + except URLError as e: + return {'ret': False, 'msg': "URL Error on POST request to '%s': '%s'" + % (uri, e.reason)} + # Almost all errors should be caught above, but just in case + except Exception as e: + return {'ret': False, + 'msg': "Failed POST request to '%s': '%s'" % (uri, to_text(e))} + return {'ret': True, 'headers': headers, 'resp': resp} + + def get_uri_with_slot_number_query_param(self, uri): + """Return the URI with proxy slot number added as a query param, if there is one. + + If a proxy slot number is provided, to access it, we must append it as a query parameter. + This method returns the given URI with the slotnumber query param added, if there is one. + If there is not a proxy slot number, it just returns the URI as it was passed in. + """ + if self.proxy_slot_number is not None: + parsed_url = urlparse(uri) + return parsed_url._replace(query="slotnumber=" + str(self.proxy_slot_number)).geturl() + else: + return uri + + def manage_system_power(self, command): + """Process a command to manage the system power. + + :param str command: The Ansible command being processed. + """ + if command == "PowerGracefulRestart": + resource_uri = self.root_uri + resource_uri = self.get_uri_with_slot_number_query_param(resource_uri) + + # Get the resource so that we have the Etag + response = self.get_request(resource_uri) + if 'etag' not in response['headers']: + return {'ret': False, 'msg': 'Etag not found in response.'} + etag = response['headers']['etag'] + if response['ret'] is False: + return response + + # Issue the PUT to do the reboot (unless we are in check mode) + if self.module.check_mode: + return { + 'ret': True, + 'changed': True, + 'msg': 'Update not performed in check mode.' + } + payload = {'Reboot': True} + response = self.put_request(resource_uri, payload, etag) + if response['ret'] is False: + return response + elif command.startswith("PowerMode"): + return self.manage_power_mode(command) + else: + return {'ret': False, 'msg': 'Invalid command: ' + command} + + return {'ret': True} + + def manage_chassis_indicator_led(self, command): + """Process a command to manage the chassis indicator LED. + + :param string command: The Ansible command being processed. + """ + return self.manage_indicator_led(command, self.root_uri) + + def manage_indicator_led(self, command, resource_uri=None): + """Process a command to manage an indicator LED. + + :param string command: The Ansible command being processed. + :param string resource_uri: URI of the resource whose indicator LED is being managed. + """ + key = "IndicatorLED" + if resource_uri is None: + resource_uri = self.root_uri + resource_uri = self.get_uri_with_slot_number_query_param(resource_uri) + + payloads = { + 'IndicatorLedOn': { + 'ID': 2 + }, + 'IndicatorLedOff': { + 'ID': 4 + } + } + + response = self.get_request(resource_uri) + if 'etag' not in response['headers']: + return {'ret': False, 'msg': 'Etag not found in response.'} + etag = response['headers']['etag'] + if response['ret'] is False: + return response + data = response['data'] + if key not in data: + return {'ret': False, 'msg': "Key %s not found" % key} + if 'ID' not in data[key]: + return {'ret': False, 'msg': 'IndicatorLED for resource has no ID.'} + + if command in payloads.keys(): + # See if the LED is already set as requested. + current_led_status = data[key]['ID'] + if current_led_status == payloads[command]['ID']: + return {'ret': True, 'changed': False} + + # Set the LED (unless we are in check mode) + if self.module.check_mode: + return { + 'ret': True, + 'changed': True, + 'msg': 'Update not performed in check mode.' + } + payload = {'IndicatorLED': payloads[command]} + response = self.put_request(resource_uri, payload, etag) + if response['ret'] is False: + return response + else: + return {'ret': False, 'msg': 'Invalid command'} + + return {'ret': True} + + def manage_power_mode(self, command): + key = "PowerState" + resource_uri = self.get_uri_with_slot_number_query_param(self.root_uri) + + payloads = { + "PowerModeNormal": 2, + "PowerModeLow": 4 + } + + response = self.get_request(resource_uri) + if 'etag' not in response['headers']: + return {'ret': False, 'msg': 'Etag not found in response.'} + etag = response['headers']['etag'] + if response['ret'] is False: + return response + data = response['data'] + if key not in data: + return {'ret': False, 'msg': "Key %s not found" % key} + if 'ID' not in data[key]: + return {'ret': False, 'msg': 'PowerState for resource has no ID.'} + + if command in payloads.keys(): + # See if the PowerState is already set as requested. + current_power_state = data[key]['ID'] + if current_power_state == payloads[command]: + return {'ret': True, 'changed': False} + + # Set the Power State (unless we are in check mode) + if self.module.check_mode: + return { + 'ret': True, + 'changed': True, + 'msg': 'Update not performed in check mode.' + } + payload = {'PowerState': {"ID": payloads[command]}} + response = self.put_request(resource_uri, payload, etag) + if response['ret'] is False: + return response + else: + return {'ret': False, 'msg': 'Invalid command: ' + command} + + return {'ret': True} + + def prepare_multipart_firmware_upload(self, filename): + """Prepare a multipart/form-data body for OCAPI firmware upload. + + :arg filename: The name of the file to upload. + :returns: tuple of (content_type, body) where ``content_type`` is + the ``multipart/form-data`` ``Content-Type`` header including + ``boundary`` and ``body`` is the prepared bytestring body + + Prepares the body to include "FirmwareFile" field with the contents of the file. + Because some OCAPI targets do not support Base-64 encoding for multipart/form-data, + this method sends the file as binary. + """ + boundary = str(uuid.uuid4()) # Generate a random boundary + body = "--" + boundary + '\r\n' + body += 'Content-Disposition: form-data; name="FirmwareFile"; filename="%s"\r\n' % to_native(os.path.basename(filename)) + body += 'Content-Type: application/octet-stream\r\n\r\n' + body_bytes = bytearray(body, 'utf-8') + with open(filename, 'rb') as f: + body_bytes += f.read() + body_bytes += bytearray("\r\n--%s--" % boundary, 'utf-8') + return ("multipart/form-data; boundary=%s" % boundary, + body_bytes) + + def upload_firmware_image(self, update_image_path): + """Perform Firmware Upload to the OCAPI storage device. + + :param str update_image_path: The path/filename of the firmware image, on the local filesystem. + """ + if not (os.path.exists(update_image_path) and os.path.isfile(update_image_path)): + return {'ret': False, 'msg': 'File does not exist.'} + url = self.root_uri + "OperatingSystem" + url = self.get_uri_with_slot_number_query_param(url) + content_type, b_form_data = self.prepare_multipart_firmware_upload(update_image_path) + + # Post the firmware (unless we are in check mode) + if self.module.check_mode: + return { + 'ret': True, + 'changed': True, + 'msg': 'Update not performed in check mode.' + } + result = self.post_request(url, b_form_data, content_type=content_type, timeout=300) + if result['ret'] is False: + return result + return {'ret': True} + + def update_firmware_image(self): + """Perform a Firmware Update on the OCAPI storage device.""" + resource_uri = self.root_uri + resource_uri = self.get_uri_with_slot_number_query_param(resource_uri) + # We have to do a GET to obtain the Etag. It's required on the PUT. + response = self.get_request(resource_uri) + if response['ret'] is False: + return response + if 'etag' not in response['headers']: + return {'ret': False, 'msg': 'Etag not found in response.'} + etag = response['headers']['etag'] + + # Issue the PUT (unless we are in check mode) + if self.module.check_mode: + return { + 'ret': True, + 'changed': True, + 'msg': 'Update not performed in check mode.' + } + payload = {'FirmwareUpdate': True} + response = self.put_request(resource_uri, payload, etag) + if response['ret'] is False: + return response + + return {'ret': True, 'jobUri': response["headers"]["location"]} + + def activate_firmware_image(self): + """Perform a Firmware Activate on the OCAPI storage device.""" + resource_uri = self.root_uri + resource_uri = self.get_uri_with_slot_number_query_param(resource_uri) + # We have to do a GET to obtain the Etag. It's required on the PUT. + response = self.get_request(resource_uri) + if 'etag' not in response['headers']: + return {'ret': False, 'msg': 'Etag not found in response.'} + etag = response['headers']['etag'] + if response['ret'] is False: + return response + + # Issue the PUT (unless we are in check mode) + if self.module.check_mode: + return { + 'ret': True, + 'changed': True, + 'msg': 'Update not performed in check mode.' + } + payload = {'FirmwareActivate': True} + response = self.put_request(resource_uri, payload, etag) + if response['ret'] is False: + return response + + return {'ret': True, 'jobUri': response["headers"]["location"]} + + def get_job_status(self, job_uri): + """Get the status of a job. + + :param str job_uri: The URI of the job's status monitor. + """ + job_uri = self.get_uri_with_slot_number_query_param(job_uri) + response = self.get_request(job_uri) + if response['ret'] is False: + if response.get('status') == 404: + # Job not found -- assume 0% + return { + "ret": True, + "percentComplete": 0, + "operationStatus": "Not Available", + "operationStatusId": 1, + "operationHealth": None, + "operationHealthId": None, + "details": "Job does not exist.", + "jobExists": False + } + else: + return response + details = response["data"]["Status"].get("Details") + if type(details) is str: + details = [details] + health_list = response["data"]["Status"]["Health"] + return_value = { + "ret": True, + "percentComplete": response["data"]["PercentComplete"], + "operationStatus": response["data"]["Status"]["State"]["Name"], + "operationStatusId": response["data"]["Status"]["State"]["ID"], + "operationHealth": health_list[0]["Name"] if len(health_list) > 0 else None, + "operationHealthId": health_list[0]["ID"] if len(health_list) > 0 else None, + "details": details, + "jobExists": True + } + return return_value + + def delete_job(self, job_uri): + """Delete the OCAPI job referenced by the specified job_uri.""" + job_uri = self.get_uri_with_slot_number_query_param(job_uri) + # We have to do a GET to obtain the Etag. It's required on the DELETE. + response = self.get_request(job_uri) + + if response['ret'] is True: + if 'etag' not in response['headers']: + return {'ret': False, 'msg': 'Etag not found in response.'} + else: + etag = response['headers']['etag'] + + if response['data']['PercentComplete'] != 100: + return { + 'ret': False, + 'changed': False, + 'msg': 'Cannot delete job because it is in progress.' + } + + if response['ret'] is False: + if response['status'] == 404: + return { + 'ret': True, + 'changed': False, + 'msg': 'Job already deleted.' + } + return response + if self.module.check_mode: + return { + 'ret': True, + 'changed': True, + 'msg': 'Update not performed in check mode.' + } + + # Do the DELETE (unless we are in check mode) + response = self.delete_request(job_uri, etag) + if response['ret'] is False: + if response['status'] == 404: + return { + 'ret': True, + 'changed': False + } + elif response['status'] == 409: + return { + 'ret': False, + 'changed': False, + 'msg': 'Cannot delete job because it is in progress.' + } + return response + return { + 'ret': True, + 'changed': True + } diff --git a/plugins/modules/ocapi_command.py b/plugins/modules/ocapi_command.py new file mode 100644 index 0000000000..7d8fca8064 --- /dev/null +++ b/plugins/modules/ocapi_command.py @@ -0,0 +1,267 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2022 Western Digital Corporation +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = ''' +--- +module: ocapi_command +version_added: 6.3.0 +short_description: Manages Out-Of-Band controllers using Open Composable API (OCAPI) +description: + - Builds OCAPI URIs locally and sends them to remote OOB controllers to + perform an action. + - Manages OOB controller such as Indicator LED, Reboot, Power Mode, Firmware Update. +options: + category: + required: true + description: + - Category to execute on OOB controller. + type: str + command: + required: true + description: + - Command to execute on OOB controller. + type: str + baseuri: + required: true + description: + - Base URI of OOB controller. + type: str + proxy_slot_number: + description: For proxied inband requests, the slot number of the IOM. Only applies if I(baseuri) is a proxy server. + type: int + update_image_path: + required: false + description: + - For C(FWUpload), the path on the local filesystem of the firmware update image. + type: str + job_name: + required: false + description: + - For C(DeleteJob) command, the name of the job to delete. + type: str + username: + required: true + description: + - Username for authenticating to OOB controller. + type: str + password: + required: true + description: + - Password for authenticating to OOB controller. + type: str + timeout: + description: + - Timeout in seconds for URL requests to OOB controller. + default: 10 + type: int + +author: "Mike Moerk (@mikemoerk)" +''' + +EXAMPLES = ''' + - name: Set the power state to low + community.general.ocapi_command: + category: Chassis + command: PowerModeLow + baseuri: "{{ baseuri }}" + username: "{{ username }}" + password: "{{ password }}" + + - name: Set the power state to normal + community.general.ocapi_command: + category: Chassis + command: PowerModeNormal + baseuri: "{{ baseuri }}" + username: "{{ username }}" + password: "{{ password }}" + - name: Set chassis indicator LED to on + community.general.ocapi_command: + category: Chassis + command: IndicatorLedOn + baseuri: "{{ baseuri }}" + proxy_slot_number: 2 + username: "{{ username }}" + password: "{{ password }}" + - name: Set chassis indicator LED to off + community.general.ocapi_command: + category: Chassis + command: IndicatorLedOff + baseuri: "{{ baseuri }}" + proxy_slot_number: 2 + username: "{{ username }}" + password: "{{ password }}" + - name: Reset Enclosure + community.general.ocapi_command: + category: Systems + command: PowerGracefulRestart + baseuri: "{{ baseuri }}" + proxy_slot_number: 2 + username: "{{ username }}" + password: "{{ password }}" + - name: Firmware Upload + community.general.ocapi_command: + category: Update + command: FWUpload + baseuri: "iom1.wdc.com" + proxy_slot_number: 2 + username: "{{ username }}" + password: "{{ password }}" + update_image_path: "/path/to/firmware.tar.gz" + - name: Firmware Update + community.general.ocapi_command: + category: Update + command: FWUpdate + baseuri: "iom1.wdc.com" + proxy_slot_number: 2 + username: "{{ username }}" + password: "{{ password }}" + - name: Firmware Activate + community.general.ocapi_command: + category: Update + command: FWActivate + baseuri: "iom1.wdc.com" + proxy_slot_number: 2 + username: "{{ username }}" + password: "{{ password }}" + - name: Delete Job + community.general.ocapi_command: + category: Jobs + command: DeleteJob + job_name: FirmwareUpdate + baseuri: "{{ baseuri }}" + proxy_slot_number: 2 + username: "{{ username }}" + password: "{{ password }}" +''' + +RETURN = ''' +msg: + description: Message with action result or error description. + returned: always + type: str + sample: "Action was successful" + +jobUri: + description: URI to use to monitor status of the operation. Returned for async commands such as Firmware Update, Firmware Activate. + returned: when supported + type: str + sample: "https://ioma.wdc.com/Storage/Devices/openflex-data24-usalp03020qb0003/Jobs/FirmwareUpdate/" + +operationStatusId: + description: OCAPI State ID (see OCAPI documentation for possible values). + returned: when supported + type: int + sample: 2 + +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.community.general.plugins.module_utils.ocapi_utils import OcapiUtils +from ansible.module_utils.common.text.converters import to_native +from ansible.module_utils.six.moves.urllib.parse import quote_plus, urljoin + +# More will be added as module features are expanded +CATEGORY_COMMANDS_ALL = { + "Chassis": ["IndicatorLedOn", "IndicatorLedOff", "PowerModeLow", "PowerModeNormal"], + "Systems": ["PowerGracefulRestart"], + "Update": ["FWUpload", "FWUpdate", "FWActivate"], + "Jobs": ["DeleteJob"] +} + + +def main(): + result = {} + module = AnsibleModule( + argument_spec=dict( + category=dict(required=True), + command=dict(required=True, type='str'), + job_name=dict(type='str'), + baseuri=dict(required=True, type='str'), + proxy_slot_number=dict(type='int'), + update_image_path=dict(type='str'), + username=dict(required=True), + password=dict(required=True, no_log=True), + timeout=dict(type='int', default=10) + ), + supports_check_mode=True + ) + + category = module.params['category'] + command = module.params['command'] + + # admin credentials used for authentication + creds = { + 'user': module.params['username'], + 'pswd': module.params['password'] + } + + # timeout + timeout = module.params['timeout'] + + base_uri = "https://" + module.params["baseuri"] + proxy_slot_number = module.params.get("proxy_slot_number") + ocapi_utils = OcapiUtils(creds, base_uri, proxy_slot_number, timeout, module) + + # Check that Category is valid + if category not in CATEGORY_COMMANDS_ALL: + module.fail_json(msg=to_native("Invalid Category '%s'. Valid Categories = %s" % (category, list(CATEGORY_COMMANDS_ALL.keys())))) + + # Check that the command is valid + if command not in CATEGORY_COMMANDS_ALL[category]: + module.fail_json(msg=to_native("Invalid Command '%s'. Valid Commands = %s" % (command, CATEGORY_COMMANDS_ALL[category]))) + + # Organize by Categories / Commands + if category == "Chassis": + if command.startswith("IndicatorLed"): + result = ocapi_utils.manage_chassis_indicator_led(command) + elif command.startswith("PowerMode"): + result = ocapi_utils.manage_system_power(command) + elif category == "Systems": + if command.startswith("Power"): + result = ocapi_utils.manage_system_power(command) + elif category == "Update": + if command == "FWUpload": + update_image_path = module.params.get("update_image_path") + if update_image_path is None: + module.fail_json(msg=to_native("Missing update_image_path.")) + result = ocapi_utils.upload_firmware_image(update_image_path) + elif command == "FWUpdate": + result = ocapi_utils.update_firmware_image() + elif command == "FWActivate": + result = ocapi_utils.activate_firmware_image() + elif category == "Jobs": + if command == "DeleteJob": + job_name = module.params.get("job_name") + if job_name is None: + module.fail_json("Missing job_name") + job_uri = urljoin(base_uri, "Jobs/" + job_name) + result = ocapi_utils.delete_job(job_uri) + + if result['ret'] is False: + module.fail_json(msg=to_native(result['msg'])) + else: + del result['ret'] + changed = result.get('changed', True) + session = result.get('session', dict()) + kwargs = { + "changed": changed, + "session": session, + "msg": "Action was successful." if not module.check_mode else result.get( + "msg", "No action performed in check mode." + ) + } + result_keys = [result_key for result_key in result if result_key not in kwargs] + for result_key in result_keys: + kwargs[result_key] = result[result_key] + module.exit_json(**kwargs) + + +if __name__ == '__main__': + main() diff --git a/plugins/modules/ocapi_info.py b/plugins/modules/ocapi_info.py new file mode 100644 index 0000000000..c827b4522d --- /dev/null +++ b/plugins/modules/ocapi_info.py @@ -0,0 +1,221 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2022 Western Digital Corporation +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +DOCUMENTATION = ''' +--- +module: ocapi_info +version_added: 6.3.0 +short_description: Manages Out-Of-Band controllers using Open Composable API (OCAPI) +description: + - Builds OCAPI URIs locally and sends them to remote OOB controllers to + get information back. +options: + category: + required: true + description: + - Category to execute on OOB controller. + type: str + command: + required: true + description: + - Command to execute on OOB controller. + type: str + baseuri: + required: true + description: + - Base URI of OOB controller. + type: str + proxy_slot_number: + description: For proxied inband requests, the slot number of the IOM. Only applies if I(baseuri) is a proxy server. + type: int + username: + required: true + description: + - Username for authenticating to OOB controller. + type: str + password: + required: true + description: + - Password for authenticating to OOB controller. + type: str + timeout: + description: + - Timeout in seconds for URL requests to OOB controller. + default: 10 + type: int + job_name: + description: + - Name of job for fetching status. + type: str + + +author: "Mike Moerk (@mikemoerk)" +''' + +EXAMPLES = ''' + - name: Get job status + community.general.ocapi_info: + category: Status + command: JobStatus + baseuri: "http://iom1.wdc.com" + jobName: FirmwareUpdate + username: "{{ username }}" + password: "{{ password }}" +''' + +RETURN = ''' +msg: + description: Message with action result or error description. + returned: always + type: str + sample: "Action was successful" + +percentComplete: + description: Percent complete of the relevant operation. Applies to C(JobStatus) command. + returned: when supported + type: int + sample: 99 + +operationStatus: + description: Status of the relevant operation. Applies to C(JobStatus) command. See OCAPI documentation for details. + returned: when supported + type: str + sample: "Activate needed" + +operationStatusId: + description: Integer value of status (corresponds to operationStatus). Applies to C(JobStatus) command. See OCAPI documentation for details. + returned: when supported + type: int + sample: 65540 + +operationHealth: + description: Health of the operation. Applies to C(JobStatus) command. See OCAPI documentation for details. + returned: when supported + type: str + sample: "OK" + +operationHealthId: + description: > + Integer value for health of the operation (corresponds to C(operationHealth)). Applies to C(JobStatus) command. + See OCAPI documentation for details. + returned: when supported + type: str + sample: "OK" + +details: + description: Details of the relevant operation. Applies to C(JobStatus) command. + returned: when supported + type: list + elements: str + +status: + description: Dict containing status information. See OCAPI documentation for details. + returned: when supported + type: dict + sample: { + "Details": [ + "None" + ], + "Health": [ + { + "ID": 5, + "Name": "OK" + } + ], + "State": { + "ID": 16, + "Name": "In service" + } + } +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.community.general.plugins.module_utils.ocapi_utils import OcapiUtils +from ansible.module_utils.common.text.converters import to_native +from ansible.module_utils.six.moves.urllib.parse import quote_plus, urljoin + +# More will be added as module features are expanded +CATEGORY_COMMANDS_ALL = { + "Jobs": ["JobStatus"] +} + + +def main(): + result = {} + module = AnsibleModule( + argument_spec=dict( + category=dict(required=True), + command=dict(required=True, type='str'), + job_name=dict(type='str'), + baseuri=dict(required=True, type='str'), + proxy_slot_number=dict(type='int'), + username=dict(required=True), + password=dict(required=True, no_log=True), + timeout=dict(type='int', default=10) + ), + supports_check_mode=True + ) + + category = module.params['category'] + command = module.params['command'] + + # admin credentials used for authentication + creds = { + 'user': module.params['username'], + 'pswd': module.params['password'] + } + + # timeout + timeout = module.params['timeout'] + + base_uri = "https://" + module.params["baseuri"] + proxy_slot_number = module.params.get("proxy_slot_number") + ocapi_utils = OcapiUtils(creds, base_uri, proxy_slot_number, timeout, module) + + # Check that Category is valid + if category not in CATEGORY_COMMANDS_ALL: + module.fail_json(msg=to_native("Invalid Category '%s'. Valid Categories = %s" % (category, list(CATEGORY_COMMANDS_ALL.keys())))) + + # Check that the command is valid + if command not in CATEGORY_COMMANDS_ALL[category]: + module.fail_json(msg=to_native("Invalid Command '%s'. Valid Commands = %s" % (command, CATEGORY_COMMANDS_ALL[category]))) + + # Organize by Categories / Commands + if category == "Jobs": + if command == "JobStatus": + if module.params.get("job_name") is None: + module.fail_json(msg=to_native( + "job_name required for JobStatus command.")) + job_uri = urljoin(base_uri, 'Jobs/' + module.params["job_name"]) + result = ocapi_utils.get_job_status(job_uri) + + if result['ret'] is False: + module.fail_json(msg=to_native(result['msg'])) + else: + del result['ret'] + changed = False + session = result.get('session', dict()) + kwargs = { + "changed": changed, + "session": session, + "msg": "Action was successful." if not module.check_mode else result.get( + "msg", "No action performed in check mode." + ) + } + result_keys = [result_key for result_key in result if result_key not in kwargs] + for result_key in result_keys: + kwargs[result_key] = result[result_key] + module.exit_json(**kwargs) + + +if __name__ == '__main__': + main() diff --git a/tests/unit/plugins/module_utils/test_ocapi_utils.py b/tests/unit/plugins/module_utils/test_ocapi_utils.py new file mode 100644 index 0000000000..3c939b5586 --- /dev/null +++ b/tests/unit/plugins/module_utils/test_ocapi_utils.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright (c) Ansible project +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os +import re +import shutil +import tempfile + +from ansible_collections.community.general.tests.unit.compat import unittest +from ansible_collections.community.general.plugins.module_utils.ocapi_utils import OcapiUtils + + +class TestOcapiUtils(unittest.TestCase): + def setUp(self): + self.tempdir = tempfile.mkdtemp() + self.utils = OcapiUtils(creds={"user": "a_user", "pswd": "a_password"}, + base_uri="fakeUri", + proxy_slot_number=None, + timeout=30, + module=None) + + def tearDown(self): + shutil.rmtree(self.tempdir) + + def test_prepare_multipart_firmware_upload(self): + # Generate a binary file and save it + filename = "fake_firmware.bin" + filepath = os.path.join(self.tempdir, filename) + file_contents = b'\x00\x01\x02\x03\x04' + with open(filepath, 'wb+') as f: + f.write(file_contents) + + # Call prepare_mutipart_firmware_upload + content_type, b_form_data = self.utils.prepare_multipart_firmware_upload(filepath) + + # Check the returned content-type + content_type_pattern = r"multipart/form-data; boundary=(.*)" + m = re.match(content_type_pattern, content_type) + self.assertIsNotNone(m) + + # Check the returned binary data + boundary = m.group(1) + expected_content_text = '--%s\r\n' % boundary + expected_content_text += 'Content-Disposition: form-data; name="FirmwareFile"; filename="%s"\r\n' % filename + expected_content_text += 'Content-Type: application/octet-stream\r\n\r\n' + expected_content_bytes = bytearray(expected_content_text, 'utf-8') + expected_content_bytes += file_contents + expected_content_bytes += bytearray('\r\n--%s--' % boundary, 'utf-8') + self.assertEqual(expected_content_bytes, b_form_data) diff --git a/tests/unit/plugins/modules/test_ocapi_command.py b/tests/unit/plugins/modules/test_ocapi_command.py new file mode 100644 index 0000000000..031fb9dd09 --- /dev/null +++ b/tests/unit/plugins/modules/test_ocapi_command.py @@ -0,0 +1,639 @@ +# -*- coding: utf-8 -*- +# Copyright (c) Ansible project +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os +import shutil +import tempfile + +from ansible_collections.community.general.tests.unit.compat.mock import patch +from ansible_collections.community.general.tests.unit.compat import unittest +from ansible.module_utils import basic +import ansible_collections.community.general.plugins.modules.ocapi_command as module +from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson +from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args, exit_json, fail_json +from ansible.module_utils.six.moves.urllib.parse import quote_plus, urljoin + + +MOCK_BASE_URI = "mockBaseUri/" +OPERATING_SYSTEM_URI = "OperatingSystem" +MOCK_JOB_NAME = "MockJob" + +ACTION_WAS_SUCCESSFUL = "Action was successful." +UPDATE_NOT_PERFORMED_IN_CHECK_MODE = "Update not performed in check mode." +NO_ACTION_PERFORMED_IN_CHECK_MODE = "No action performed in check mode." + +MOCK_SUCCESSFUL_HTTP_RESPONSE_LED_INDICATOR_OFF_WITH_ETAG = { + "ret": True, + "data": { + "IndicatorLED": { + "ID": 4, + "Name": "Off" + }, + "PowerState": { + "ID": 2, + "Name": "On" + } + }, + "headers": {"etag": "MockETag"} +} + +MOCK_SUCCESSFUL_HTTP_RESPONSE = { + "ret": True, + "data": {} +} + +MOCK_404_RESPONSE = { + "ret": False, + "status": 404 +} + +MOCK_SUCCESSFUL_HTTP_RESPONSE_WITH_LOCATION_HEADER = { + "ret": True, + "data": {}, + "headers": {"location": "mock_location"} +} + +MOCK_HTTP_RESPONSE_CONFLICT = { + "ret": False, + "msg": "Conflict", + "status": 409 +} + +MOCK_HTTP_RESPONSE_JOB_IN_PROGRESS = { + "ret": True, + "data": { + "PercentComplete": 99 + }, + "headers": { + "etag": "12345" + } +} + +MOCK_HTTP_RESPONSE_JOB_COMPLETE = { + "ret": True, + "data": { + "PercentComplete": 100 + }, + "headers": { + "etag": "12345" + } +} + + +def get_bin_path(self, arg, required=False): + """Mock AnsibleModule.get_bin_path""" + return arg + + +def get_exception_message(ansible_exit_json): + """From an AnsibleExitJson exception, get the message string.""" + return ansible_exit_json.exception.args[0]["msg"] + + +def is_changed(ansible_exit_json): + """From an AnsibleExitJson exception, return the value of the changed flag""" + return ansible_exit_json.exception.args[0]["changed"] + + +def mock_get_request(*args, **kwargs): + """Mock for get_request.""" + url = args[1] + if url == 'https://' + MOCK_BASE_URI: + return MOCK_SUCCESSFUL_HTTP_RESPONSE_LED_INDICATOR_OFF_WITH_ETAG + elif url == "mock_location": + return MOCK_SUCCESSFUL_HTTP_RESPONSE + raise RuntimeError("Illegal call to get_request in test: " + args[1]) + + +def mock_get_request_job_does_not_exist(*args, **kwargs): + """Mock for get_request.""" + url = args[1] + if url == 'https://' + MOCK_BASE_URI: + return MOCK_SUCCESSFUL_HTTP_RESPONSE_LED_INDICATOR_OFF_WITH_ETAG + elif url == urljoin('https://' + MOCK_BASE_URI, "Jobs/" + MOCK_JOB_NAME): + return MOCK_404_RESPONSE + raise RuntimeError("Illegal call to get_request in test: " + args[1]) + + +def mock_get_request_job_in_progress(*args, **kwargs): + url = args[1] + if url == 'https://' + MOCK_BASE_URI: + return MOCK_SUCCESSFUL_HTTP_RESPONSE_LED_INDICATOR_OFF_WITH_ETAG + elif url == urljoin('https://' + MOCK_BASE_URI, "Jobs/" + MOCK_JOB_NAME): + return MOCK_HTTP_RESPONSE_JOB_IN_PROGRESS + raise RuntimeError("Illegal call to get_request in test: " + args[1]) + + +def mock_get_request_job_complete(*args, **kwargs): + url = args[1] + if url == 'https://' + MOCK_BASE_URI: + return MOCK_SUCCESSFUL_HTTP_RESPONSE_LED_INDICATOR_OFF_WITH_ETAG + elif url == urljoin('https://' + MOCK_BASE_URI, "Jobs/" + MOCK_JOB_NAME): + return MOCK_HTTP_RESPONSE_JOB_COMPLETE + raise RuntimeError("Illegal call to get_request in test: " + args[1]) + + +def mock_put_request(*args, **kwargs): + """Mock put_request.""" + url = args[1] + if url == 'https://' + MOCK_BASE_URI: + return MOCK_SUCCESSFUL_HTTP_RESPONSE_WITH_LOCATION_HEADER + raise RuntimeError("Illegal PUT call to: " + args[1]) + + +def mock_delete_request(*args, **kwargs): + """Mock delete request.""" + url = args[1] + if url == urljoin('https://' + MOCK_BASE_URI, 'Jobs/' + MOCK_JOB_NAME): + return MOCK_SUCCESSFUL_HTTP_RESPONSE + raise RuntimeError("Illegal DELETE call to: " + args[1]) + + +def mock_post_request(*args, **kwargs): + """Mock post_request.""" + url = args[1] + if url == urljoin('https://' + MOCK_BASE_URI, OPERATING_SYSTEM_URI): + return MOCK_SUCCESSFUL_HTTP_RESPONSE + raise RuntimeError("Illegal POST call to: " + args[1]) + + +def mock_http_request_conflict(*args, **kwargs): + """Mock to make an HTTP request return 409 Conflict""" + return MOCK_HTTP_RESPONSE_CONFLICT + + +def mock_invalid_http_request(*args, **kwargs): + """Mock to make an HTTP request invalid. Raises an exception.""" + raise RuntimeError("Illegal HTTP call to " + args[1]) + + +class TestOcapiCommand(unittest.TestCase): + + def setUp(self): + self.mock_module_helper = patch.multiple(basic.AnsibleModule, + exit_json=exit_json, + fail_json=fail_json, + get_bin_path=get_bin_path) + self.mock_module_helper.start() + self.addCleanup(self.mock_module_helper.stop) + self.tempdir = tempfile.mkdtemp() + + def tearDown(self): + shutil.rmtree(self.tempdir) + + def test_module_fail_when_required_args_missing(self): + with self.assertRaises(AnsibleFailJson) as ansible_fail_json: + set_module_args({}) + module.main() + self.assertIn("missing required arguments:", get_exception_message(ansible_fail_json)) + + def test_module_fail_when_unknown_category(self): + with self.assertRaises(AnsibleFailJson) as ansible_fail_json: + set_module_args({ + 'category': 'unknown', + 'command': 'IndicatorLedOn', + 'username': 'USERID', + 'password': 'PASSW0RD=21', + 'baseuri': MOCK_BASE_URI + }) + module.main() + self.assertIn("Invalid Category 'unknown", get_exception_message(ansible_fail_json)) + + def test_set_power_mode(self): + """Test that we can set chassis power mode""" + with patch.multiple("ansible_collections.community.general.plugins.module_utils.ocapi_utils.OcapiUtils", + get_request=mock_get_request, + put_request=mock_put_request): + with self.assertRaises(AnsibleExitJson) as ansible_exit_json: + set_module_args({ + 'category': 'Chassis', + 'command': 'PowerModeLow', + 'baseuri': MOCK_BASE_URI, + 'username': 'USERID', + 'password': 'PASSWORD=21' + }) + module.main() + self.assertEqual(ACTION_WAS_SUCCESSFUL, get_exception_message(ansible_exit_json)) + self.assertTrue(is_changed(ansible_exit_json)) + + def test_set_chassis_led_indicator(self): + """Test that we can set chassis LED indicator.""" + with patch.multiple("ansible_collections.community.general.plugins.module_utils.ocapi_utils.OcapiUtils", + get_request=mock_get_request, + put_request=mock_put_request): + with self.assertRaises(AnsibleExitJson) as ansible_exit_json: + set_module_args({ + 'category': 'Chassis', + 'command': 'IndicatorLedOn', + 'baseuri': MOCK_BASE_URI, + 'username': 'USERID', + 'password': 'PASSWORD=21' + }) + module.main() + self.assertEqual(ACTION_WAS_SUCCESSFUL, get_exception_message(ansible_exit_json)) + self.assertTrue(is_changed(ansible_exit_json)) + + def test_set_power_mode_already_set(self): + """Test that if we set Power Mode to normal when it's already normal, we get changed=False.""" + with patch.multiple("ansible_collections.community.general.plugins.module_utils.ocapi_utils.OcapiUtils", + get_request=mock_get_request, + put_request=mock_invalid_http_request): + with self.assertRaises(AnsibleExitJson) as ansible_exit_json: + set_module_args({ + 'category': 'Chassis', + 'command': 'PowerModeNormal', + 'baseuri': MOCK_BASE_URI, + 'username': 'USERID', + 'password': 'PASSWORD=21' + }) + module.main() + self.assertEqual(ACTION_WAS_SUCCESSFUL, get_exception_message(ansible_exit_json)) + self.assertFalse(is_changed(ansible_exit_json)) + + def test_set_power_mode_check_mode(self): + """Test check mode when setting chassis Power Mode.""" + with patch.multiple("ansible_collections.community.general.plugins.module_utils.ocapi_utils.OcapiUtils", + get_request=mock_get_request, + put_request=mock_invalid_http_request): + with self.assertRaises(AnsibleExitJson) as ansible_exit_json: + set_module_args({ + 'category': 'Chassis', + 'command': 'IndicatorLedOn', + 'baseuri': MOCK_BASE_URI, + 'username': 'USERID', + 'password': 'PASSWORD=21', + '_ansible_check_mode': True + }) + module.main() + self.assertEqual(UPDATE_NOT_PERFORMED_IN_CHECK_MODE, get_exception_message(ansible_exit_json)) + self.assertTrue(is_changed(ansible_exit_json)) + + def test_set_chassis_led_indicator_check_mode(self): + """Test check mode when setting chassis LED indicator""" + with patch.multiple("ansible_collections.community.general.plugins.module_utils.ocapi_utils.OcapiUtils", + get_request=mock_get_request, + put_request=mock_invalid_http_request): + with self.assertRaises(AnsibleExitJson) as ansible_exit_json: + set_module_args({ + 'category': 'Chassis', + 'command': 'IndicatorLedOn', + 'baseuri': MOCK_BASE_URI, + 'username': 'USERID', + 'password': 'PASSWORD=21', + '_ansible_check_mode': True + }) + module.main() + self.assertEqual(UPDATE_NOT_PERFORMED_IN_CHECK_MODE, get_exception_message(ansible_exit_json)) + self.assertTrue(is_changed(ansible_exit_json)) + + def test_set_chassis_led_indicator_already_set(self): + """Test that if we set LED Indicator to off when it's already off, we get changed=False.""" + with patch.multiple("ansible_collections.community.general.plugins.module_utils.ocapi_utils.OcapiUtils", + get_request=mock_get_request, + put_request=mock_invalid_http_request): + with self.assertRaises(AnsibleExitJson) as ansible_exit_json: + set_module_args({ + 'category': 'Chassis', + 'command': 'IndicatorLedOff', + 'baseuri': MOCK_BASE_URI, + 'username': 'USERID', + 'password': 'PASSWORD=21' + }) + module.main() + self.assertEqual(ACTION_WAS_SUCCESSFUL, get_exception_message(ansible_exit_json)) + self.assertFalse(is_changed(ansible_exit_json)) + + def test_set_chassis_led_indicator_already_set_check_mode(self): + """Test that if we set LED Indicator to off when it's already off, we get changed=False even in check mode.""" + with patch.multiple("ansible_collections.community.general.plugins.module_utils.ocapi_utils.OcapiUtils", + get_request=mock_get_request, + put_request=mock_invalid_http_request): + with self.assertRaises(AnsibleExitJson) as ansible_exit_json: + set_module_args({ + 'category': 'Chassis', + 'command': 'IndicatorLedOff', + 'baseuri': MOCK_BASE_URI, + 'username': 'USERID', + 'password': 'PASSWORD=21', + "_ansible_check_mode": True + }) + module.main() + self.assertEqual(NO_ACTION_PERFORMED_IN_CHECK_MODE, get_exception_message(ansible_exit_json)) + self.assertFalse(is_changed(ansible_exit_json)) + + def test_set_chassis_invalid_indicator_command(self): + with patch.multiple("ansible_collections.community.general.plugins.module_utils.ocapi_utils.OcapiUtils", + get_request=mock_get_request, + put_request=mock_put_request): + with self.assertRaises(AnsibleFailJson) as ansible_fail_json: + set_module_args({ + 'category': 'Chassis', + 'command': 'IndicatorLedBright', + 'baseuri': MOCK_BASE_URI, + 'username': 'USERID', + 'password': 'PASSWORD=21' + }) + module.main() + self.assertIn("Invalid Command", get_exception_message(ansible_fail_json)) + + def test_reset_enclosure(self): + with patch.multiple("ansible_collections.community.general.plugins.module_utils.ocapi_utils.OcapiUtils", + get_request=mock_get_request, + put_request=mock_put_request): + with self.assertRaises(AnsibleExitJson) as ansible_exit_json: + set_module_args({ + 'category': 'Systems', + 'command': 'PowerGracefulRestart', + 'baseuri': MOCK_BASE_URI, + 'username': 'USERID', + 'password': 'PASSWORD=21' + }) + module.main() + self.assertEqual(ACTION_WAS_SUCCESSFUL, get_exception_message(ansible_exit_json)) + self.assertTrue(is_changed(ansible_exit_json)) + + def test_reset_enclosure_check_mode(self): + with patch.multiple("ansible_collections.community.general.plugins.module_utils.ocapi_utils.OcapiUtils", + get_request=mock_get_request, + put_request=mock_invalid_http_request): + with self.assertRaises(AnsibleExitJson) as ansible_exit_json: + set_module_args({ + 'category': 'Systems', + 'command': 'PowerGracefulRestart', + 'baseuri': MOCK_BASE_URI, + 'username': 'USERID', + 'password': 'PASSWORD=21', + "_ansible_check_mode": True + }) + module.main() + self.assertEqual(UPDATE_NOT_PERFORMED_IN_CHECK_MODE, get_exception_message(ansible_exit_json)) + self.assertTrue(is_changed(ansible_exit_json)) + + def test_firmware_upload_missing_update_image_path(self): + with patch.multiple("ansible_collections.community.general.plugins.module_utils.ocapi_utils.OcapiUtils", + get_request=mock_get_request, + put_request=mock_put_request): + with self.assertRaises(AnsibleFailJson) as ansible_fail_json: + set_module_args({ + 'category': 'Update', + 'command': 'FWUpload', + 'baseuri': MOCK_BASE_URI, + 'username': 'USERID', + 'password': 'PASSWORD=21' + }) + module.main() + self.assertEqual("Missing update_image_path.", get_exception_message(ansible_fail_json)) + + def test_firmware_upload_file_not_found(self): + with patch.multiple("ansible_collections.community.general.plugins.module_utils.ocapi_utils.OcapiUtils", + get_request=mock_get_request, + put_request=mock_invalid_http_request): + with self.assertRaises(AnsibleFailJson) as ansible_fail_json: + set_module_args({ + 'category': 'Update', + 'command': 'FWUpload', + 'update_image_path': 'nonexistentfile.bin', + 'baseuri': MOCK_BASE_URI, + 'username': 'USERID', + 'password': 'PASSWORD=21' + }) + module.main() + self.assertEqual("File does not exist.", get_exception_message(ansible_fail_json)) + + def test_firmware_upload(self): + filename = "fake_firmware.bin" + filepath = os.path.join(self.tempdir, filename) + file_contents = b'\x00\x01\x02\x03\x04' + with open(filepath, 'wb+') as f: + f.write(file_contents) + + with patch.multiple("ansible_collections.community.general.plugins.module_utils.ocapi_utils.OcapiUtils", + get_request=mock_get_request, + put_request=mock_put_request, + post_request=mock_post_request): + with self.assertRaises(AnsibleExitJson) as ansible_exit_json: + set_module_args({ + 'category': 'Update', + 'command': 'FWUpload', + 'update_image_path': filepath, + 'baseuri': MOCK_BASE_URI, + 'username': 'USERID', + 'password': 'PASSWORD=21' + }) + module.main() + self.assertEqual(ACTION_WAS_SUCCESSFUL, get_exception_message(ansible_exit_json)) + self.assertTrue(is_changed(ansible_exit_json)) + + def test_firmware_upload_check_mode(self): + filename = "fake_firmware.bin" + filepath = os.path.join(self.tempdir, filename) + file_contents = b'\x00\x01\x02\x03\x04' + with open(filepath, 'wb+') as f: + f.write(file_contents) + + with patch.multiple("ansible_collections.community.general.plugins.module_utils.ocapi_utils.OcapiUtils", + get_request=mock_get_request, + put_request=mock_put_request, + post_request=mock_invalid_http_request): + with self.assertRaises(AnsibleExitJson) as ansible_exit_json: + set_module_args({ + 'category': 'Update', + 'command': 'FWUpload', + 'update_image_path': filepath, + 'baseuri': MOCK_BASE_URI, + 'username': 'USERID', + 'password': 'PASSWORD=21', + "_ansible_check_mode": True + }) + module.main() + self.assertEqual(UPDATE_NOT_PERFORMED_IN_CHECK_MODE, get_exception_message(ansible_exit_json)) + self.assertTrue(is_changed(ansible_exit_json)) + + def test_firmware_update(self): + with patch.multiple("ansible_collections.community.general.plugins.module_utils.ocapi_utils.OcapiUtils", + get_request=mock_get_request, + put_request=mock_put_request, + post_request=mock_invalid_http_request): + with self.assertRaises(AnsibleExitJson) as ansible_exit_json: + set_module_args({ + 'category': 'Update', + 'command': 'FWUpdate', + 'baseuri': MOCK_BASE_URI, + 'username': 'USERID', + 'password': 'PASSWORD=21' + }) + module.main() + self.assertEqual(ACTION_WAS_SUCCESSFUL, get_exception_message(ansible_exit_json)) + self.assertTrue(is_changed(ansible_exit_json)) + + def test_firmware_update_check_mode(self): + with patch.multiple("ansible_collections.community.general.plugins.module_utils.ocapi_utils.OcapiUtils", + get_request=mock_get_request, + put_request=mock_invalid_http_request, + post_request=mock_invalid_http_request): + with self.assertRaises(AnsibleExitJson) as ansible_exit_json: + set_module_args({ + 'category': 'Update', + 'command': 'FWUpdate', + 'baseuri': MOCK_BASE_URI, + 'username': 'USERID', + 'password': 'PASSWORD=21', + "_ansible_check_mode": True + }) + module.main() + self.assertEqual(UPDATE_NOT_PERFORMED_IN_CHECK_MODE, get_exception_message(ansible_exit_json)) + self.assertTrue(is_changed(ansible_exit_json)) + + def test_firmware_activate(self): + with patch.multiple("ansible_collections.community.general.plugins.module_utils.ocapi_utils.OcapiUtils", + get_request=mock_get_request, + put_request=mock_put_request, + post_request=mock_invalid_http_request): + with self.assertRaises(AnsibleExitJson) as ansible_exit_json: + set_module_args({ + 'category': 'Update', + 'command': 'FWActivate', + 'baseuri': MOCK_BASE_URI, + 'username': 'USERID', + 'password': 'PASSWORD=21' + }) + module.main() + self.assertEqual(ACTION_WAS_SUCCESSFUL, get_exception_message(ansible_exit_json)) + self.assertTrue(is_changed(ansible_exit_json)) + + def test_firmware_activate_check_mode(self): + with patch.multiple("ansible_collections.community.general.plugins.module_utils.ocapi_utils.OcapiUtils", + get_request=mock_get_request, + put_request=mock_invalid_http_request, + post_request=mock_invalid_http_request): + with self.assertRaises(AnsibleExitJson) as ansible_exit_json: + set_module_args({ + 'category': 'Update', + 'command': 'FWActivate', + 'baseuri': MOCK_BASE_URI, + 'username': 'USERID', + 'password': 'PASSWORD=21', + "_ansible_check_mode": True + }) + module.main() + self.assertEqual(UPDATE_NOT_PERFORMED_IN_CHECK_MODE, get_exception_message(ansible_exit_json)) + self.assertTrue(is_changed(ansible_exit_json)) + + def test_delete_job(self): + with patch.multiple("ansible_collections.community.general.plugins.module_utils.ocapi_utils.OcapiUtils", + get_request=mock_get_request_job_complete, + delete_request=mock_delete_request, + put_request=mock_invalid_http_request, + post_request=mock_invalid_http_request): + with self.assertRaises(AnsibleExitJson) as ansible_exit_json: + set_module_args({ + 'category': 'Jobs', + 'command': 'DeleteJob', + 'baseuri': MOCK_BASE_URI, + 'job_name': MOCK_JOB_NAME, + 'username': 'USERID', + 'password': 'PASSWORD=21' + }) + module.main() + self.assertEqual(ACTION_WAS_SUCCESSFUL, get_exception_message(ansible_exit_json)) + self.assertTrue(is_changed(ansible_exit_json)) + + def test_delete_job_in_progress(self): + with patch.multiple("ansible_collections.community.general.plugins.module_utils.ocapi_utils.OcapiUtils", + get_request=mock_get_request_job_in_progress, + delete_request=mock_invalid_http_request, + put_request=mock_invalid_http_request, + post_request=mock_invalid_http_request): + with self.assertRaises(AnsibleFailJson) as ansible_fail_json: + set_module_args({ + 'category': 'Jobs', + 'command': 'DeleteJob', + 'baseuri': MOCK_BASE_URI, + 'job_name': MOCK_JOB_NAME, + 'username': 'USERID', + 'password': 'PASSWORD=21' + }) + module.main() + self.assertEqual("Cannot delete job because it is in progress.", get_exception_message(ansible_fail_json)) + + def test_delete_job_in_progress_only_on_delete(self): + with patch.multiple("ansible_collections.community.general.plugins.module_utils.ocapi_utils.OcapiUtils", + get_request=mock_get_request_job_complete, + delete_request=mock_http_request_conflict, + put_request=mock_invalid_http_request, + post_request=mock_invalid_http_request): + with self.assertRaises(AnsibleFailJson) as ansible_fail_json: + set_module_args({ + 'category': 'Jobs', + 'command': 'DeleteJob', + 'baseuri': MOCK_BASE_URI, + 'job_name': MOCK_JOB_NAME, + 'username': 'USERID', + 'password': 'PASSWORD=21' + }) + module.main() + self.assertEqual("Cannot delete job because it is in progress.", get_exception_message(ansible_fail_json)) + + def test_delete_job_check_mode(self): + with patch.multiple("ansible_collections.community.general.plugins.module_utils.ocapi_utils.OcapiUtils", + get_request=mock_get_request_job_complete, + delete_request=mock_delete_request, + put_request=mock_invalid_http_request, + post_request=mock_invalid_http_request): + with self.assertRaises(AnsibleExitJson) as ansible_exit_json: + set_module_args({ + 'category': 'Jobs', + 'command': 'DeleteJob', + 'baseuri': MOCK_BASE_URI, + 'job_name': MOCK_JOB_NAME, + 'username': 'USERID', + 'password': 'PASSWORD=21', + '_ansible_check_mode': True + }) + module.main() + self.assertEqual(UPDATE_NOT_PERFORMED_IN_CHECK_MODE, get_exception_message(ansible_exit_json)) + self.assertTrue(is_changed(ansible_exit_json)) + + def test_delete_job_check_mode_job_not_found(self): + with patch.multiple("ansible_collections.community.general.plugins.module_utils.ocapi_utils.OcapiUtils", + get_request=mock_get_request_job_does_not_exist, + delete_request=mock_delete_request, + put_request=mock_invalid_http_request, + post_request=mock_invalid_http_request): + with self.assertRaises(AnsibleExitJson) as ansible_exit_json: + set_module_args({ + 'category': 'Jobs', + 'command': 'DeleteJob', + 'baseuri': MOCK_BASE_URI, + 'job_name': MOCK_JOB_NAME, + 'username': 'USERID', + 'password': 'PASSWORD=21', + '_ansible_check_mode': True + }) + module.main() + self.assertEqual("Job already deleted.", get_exception_message(ansible_exit_json)) + self.assertFalse(is_changed(ansible_exit_json)) + + def test_delete_job_check_mode_job_in_progress(self): + with patch.multiple("ansible_collections.community.general.plugins.module_utils.ocapi_utils.OcapiUtils", + get_request=mock_get_request_job_in_progress, + delete_request=mock_delete_request, + put_request=mock_invalid_http_request, + post_request=mock_invalid_http_request): + with self.assertRaises(AnsibleFailJson) as ansible_fail_json: + set_module_args({ + 'category': 'Jobs', + 'command': 'DeleteJob', + 'baseuri': MOCK_BASE_URI, + 'job_name': MOCK_JOB_NAME, + 'username': 'USERID', + 'password': 'PASSWORD=21', + '_ansible_check_mode': True + }) + module.main() + self.assertEqual("Cannot delete job because it is in progress.", get_exception_message(ansible_fail_json)) diff --git a/tests/unit/plugins/modules/test_ocapi_info.py b/tests/unit/plugins/modules/test_ocapi_info.py new file mode 100644 index 0000000000..5010b328f8 --- /dev/null +++ b/tests/unit/plugins/modules/test_ocapi_info.py @@ -0,0 +1,240 @@ +# -*- coding: utf-8 -*- +# Copyright (c) Ansible project +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +from ansible_collections.community.general.tests.unit.compat.mock import patch +from ansible_collections.community.general.tests.unit.compat import unittest +from ansible.module_utils import basic +import ansible_collections.community.general.plugins.modules.ocapi_info as module +from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson +from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args, exit_json, fail_json + +MOCK_BASE_URI = "mockBaseUri" +MOCK_JOB_NAME_IN_PROGRESS = "MockJobInProgress" +MOCK_JOB_NAME_COMPLETE = "MockJobComplete" +MOCK_JOB_NAME_DOES_NOT_EXIST = "MockJobDoesNotExist" + +ACTION_WAS_SUCCESSFUL = "Action was successful." + +MOCK_SUCCESSFUL_HTTP_RESPONSE = { + "ret": True, + "data": {} +} + +MOCK_404_RESPONSE = { + "ret": False, + "status": 404 +} + +MOCK_HTTP_RESPONSE_JOB_IN_PROGRESS = { + "ret": True, + "data": { + "Self": "https://openflex-data24-usalp02120qo0012-iomb:443/Storage/Devices/openflex-data24-usalp02120qo0012/Jobs/FirmwareUpdate/", + "ID": MOCK_JOB_NAME_IN_PROGRESS, + "PercentComplete": 10, + "Status": { + "State": { + "ID": 16, + "Name": "In service" + }, + "Health": [ + { + "ID": 5, + "Name": "OK" + } + ] + } + } +} + +MOCK_HTTP_RESPONSE_JOB_COMPLETE = { + "ret": True, + "data": { + "Self": "https://openflex-data24-usalp02120qo0012-iomb:443/Storage/Devices/openflex-data24-usalp02120qo0012/Jobs/FirmwareUpdate/", + "ID": MOCK_JOB_NAME_COMPLETE, + "PercentComplete": 100, + "Status": { + "State": { + "ID": 65540, + "Name": "Activate needed" + }, + "Health": [ + { + "ID": 5, + "Name": "OK" + } + ], + "Details": [ + "Completed." + ] + } + } +} + + +def get_bin_path(self, arg, required=False): + """Mock AnsibleModule.get_bin_path""" + return arg + + +def get_exception_message(ansible_exit_json): + """From an AnsibleExitJson exception, get the message string.""" + return ansible_exit_json.exception.args[0]["msg"] + + +def mock_get_request(*args, **kwargs): + """Mock for get_request.""" + url = args[1] + if url == "https://" + MOCK_BASE_URI: + return MOCK_SUCCESSFUL_HTTP_RESPONSE + elif url == "https://" + MOCK_BASE_URI + '/Jobs/' + MOCK_JOB_NAME_IN_PROGRESS: + return MOCK_HTTP_RESPONSE_JOB_IN_PROGRESS + elif url == "https://" + MOCK_BASE_URI + '/Jobs/' + MOCK_JOB_NAME_COMPLETE: + return MOCK_HTTP_RESPONSE_JOB_COMPLETE + elif url == "https://" + MOCK_BASE_URI + '/Jobs/' + MOCK_JOB_NAME_DOES_NOT_EXIST: + return MOCK_404_RESPONSE + else: + raise RuntimeError("Illegal GET call to: " + args[1]) + + +def mock_put_request(*args, **kwargs): + """Mock put_request. PUT should never happen so it will raise an error.""" + raise RuntimeError("Illegal PUT call to: " + args[1]) + + +def mock_delete_request(*args, **kwargs): + """Mock delete request. DELETE should never happen so it will raise an error.""" + raise RuntimeError("Illegal DELETE call to: " + args[1]) + + +def mock_post_request(*args, **kwargs): + """Mock post_request. POST should never happen so it will raise an error.""" + raise RuntimeError("Illegal POST call to: " + args[1]) + + +class TestOcapiInfo(unittest.TestCase): + def setUp(self): + self.mock_module_helper = patch.multiple(basic.AnsibleModule, + exit_json=exit_json, + fail_json=fail_json, + get_bin_path=get_bin_path) + self.mock_module_helper.start() + self.addCleanup(self.mock_module_helper.stop) + + def test_module_fail_when_required_args_missing(self): + with self.assertRaises(AnsibleFailJson) as ansible_fail_json: + set_module_args({}) + module.main() + self.assertIn("missing required arguments:", get_exception_message(ansible_fail_json)) + + def test_module_fail_when_unknown_category(self): + with self.assertRaises(AnsibleFailJson) as ansible_fail_json: + set_module_args({ + 'category': 'unknown', + 'command': 'JobStatus', + 'username': 'USERID', + 'password': 'PASSW0RD=21', + 'baseuri': MOCK_BASE_URI + }) + module.main() + self.assertIn("Invalid Category 'unknown", get_exception_message(ansible_fail_json)) + + def test_module_fail_when_unknown_command(self): + with self.assertRaises(AnsibleFailJson) as ansible_fail_json: + set_module_args({ + 'category': 'Jobs', + 'command': 'unknown', + 'username': 'USERID', + 'password': 'PASSW0RD=21', + 'baseuri': MOCK_BASE_URI + }) + module.main() + self.assertIn("Invalid Command 'unknown", get_exception_message(ansible_fail_json)) + + def test_job_status_in_progress(self): + with patch.multiple("ansible_collections.community.general.plugins.module_utils.ocapi_utils.OcapiUtils", + get_request=mock_get_request, + put_request=mock_put_request, + delete_request=mock_delete_request, + post_request=mock_post_request): + with self.assertRaises(AnsibleExitJson) as ansible_exit_json: + set_module_args({ + 'category': 'Jobs', + 'command': 'JobStatus', + 'job_name': MOCK_JOB_NAME_IN_PROGRESS, + 'baseuri': MOCK_BASE_URI, + 'username': 'USERID', + 'password': 'PASSWORD=21' + }) + module.main() + self.assertEqual(ACTION_WAS_SUCCESSFUL, get_exception_message(ansible_exit_json)) + response_data = ansible_exit_json.exception.args[0] + self.assertEqual(MOCK_HTTP_RESPONSE_JOB_IN_PROGRESS["data"]["PercentComplete"], response_data["percentComplete"]) + self.assertEqual(MOCK_HTTP_RESPONSE_JOB_IN_PROGRESS["data"]["Status"]["State"]["ID"], response_data["operationStatusId"]) + self.assertEqual(MOCK_HTTP_RESPONSE_JOB_IN_PROGRESS["data"]["Status"]["State"]["Name"], response_data["operationStatus"]) + self.assertEqual(MOCK_HTTP_RESPONSE_JOB_IN_PROGRESS["data"]["Status"]["Health"][0]["Name"], response_data["operationHealth"]) + self.assertEqual(MOCK_HTTP_RESPONSE_JOB_IN_PROGRESS["data"]["Status"]["Health"][0]["ID"], response_data["operationHealthId"]) + self.assertTrue(response_data["jobExists"]) + self.assertFalse(response_data["changed"]) + self.assertEqual(ACTION_WAS_SUCCESSFUL, response_data["msg"]) + self.assertIsNone(response_data["details"]) + + def test_job_status_complete(self): + with patch.multiple("ansible_collections.community.general.plugins.module_utils.ocapi_utils.OcapiUtils", + get_request=mock_get_request, + put_request=mock_put_request, + delete_request=mock_delete_request, + post_request=mock_post_request): + with self.assertRaises(AnsibleExitJson) as ansible_exit_json: + set_module_args({ + 'category': 'Jobs', + 'command': 'JobStatus', + 'job_name': MOCK_JOB_NAME_COMPLETE, + 'baseuri': MOCK_BASE_URI, + 'username': 'USERID', + 'password': 'PASSWORD=21' + }) + module.main() + self.assertEqual(ACTION_WAS_SUCCESSFUL, get_exception_message(ansible_exit_json)) + response_data = ansible_exit_json.exception.args[0] + self.assertEqual(MOCK_HTTP_RESPONSE_JOB_COMPLETE["data"]["PercentComplete"], response_data["percentComplete"]) + self.assertEqual(MOCK_HTTP_RESPONSE_JOB_COMPLETE["data"]["Status"]["State"]["ID"], response_data["operationStatusId"]) + self.assertEqual(MOCK_HTTP_RESPONSE_JOB_COMPLETE["data"]["Status"]["State"]["Name"], response_data["operationStatus"]) + self.assertEqual(MOCK_HTTP_RESPONSE_JOB_COMPLETE["data"]["Status"]["Health"][0]["Name"], response_data["operationHealth"]) + self.assertEqual(MOCK_HTTP_RESPONSE_JOB_COMPLETE["data"]["Status"]["Health"][0]["ID"], response_data["operationHealthId"]) + self.assertTrue(response_data["jobExists"]) + self.assertFalse(response_data["changed"]) + self.assertEqual(ACTION_WAS_SUCCESSFUL, response_data["msg"]) + self.assertEqual(["Completed."], response_data["details"]) + + def test_job_status_not_found(self): + with patch.multiple("ansible_collections.community.general.plugins.module_utils.ocapi_utils.OcapiUtils", + get_request=mock_get_request, + put_request=mock_put_request, + delete_request=mock_delete_request, + post_request=mock_post_request): + with self.assertRaises(AnsibleExitJson) as ansible_exit_json: + set_module_args({ + 'category': 'Jobs', + 'command': 'JobStatus', + 'job_name': MOCK_JOB_NAME_DOES_NOT_EXIST, + 'baseuri': MOCK_BASE_URI, + 'username': 'USERID', + 'password': 'PASSWORD=21' + }) + module.main() + self.assertEqual(ACTION_WAS_SUCCESSFUL, get_exception_message(ansible_exit_json)) + response_data = ansible_exit_json.exception.args[0] + self.assertFalse(response_data["jobExists"]) + self.assertEqual(0, response_data["percentComplete"]) + self.assertEqual(1, response_data["operationStatusId"]) + self.assertEqual("Not Available", response_data["operationStatus"]) + self.assertIsNone(response_data["operationHealth"]) + self.assertIsNone(response_data["operationHealthId"]) + self.assertFalse(response_data["changed"]) + self.assertEqual(ACTION_WAS_SUCCESSFUL, response_data["msg"]) + self.assertEqual("Job does not exist.", response_data["details"]) From 098912c2293febb91cfca14631784ccb72c4b774 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sun, 22 Jan 2023 17:27:17 +0100 Subject: [PATCH 0135/1810] stormssh tests: do not install newer cryptography (#5868) Do not install newer cryptography. ci_complete --- tests/integration/targets/ssh_config/tasks/main.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/integration/targets/ssh_config/tasks/main.yml b/tests/integration/targets/ssh_config/tasks/main.yml index ce57493b84..d0b088302c 100644 --- a/tests/integration/targets/ssh_config/tasks/main.yml +++ b/tests/integration/targets/ssh_config/tasks/main.yml @@ -5,7 +5,9 @@ - name: Install required libs pip: - name: stormssh + name: + - stormssh + - 'paramiko<3.0.0' state: present extra_args: "-c {{ remote_constraints }}" From 0ca41dedce083b34fe06faa84eb001c1d1f5a8bd Mon Sep 17 00:00:00 2001 From: morco Date: Sun, 22 Jan 2023 17:27:57 +0100 Subject: [PATCH 0136/1810] Bugfix/keycloak userfed idempotency (#5732) * fix(modules/keycloak_user_federation): fixes ... ... federation read call not finding already existing federations properly because of bad parametrisation * fix(modules/keycloak_user_federation): added ... ... new integration test for module idempotency bugfix * added changelog fragment for pr Co-authored-by: Mirko Wilhelmi --- ...32-bugfix-keycloak-userfed-idempotency.yml | 6 + plugins/modules/keycloak_user_federation.py | 4 +- .../keycloak_user_federation/tasks/main.yml | 108 ++++++++++++++++++ 3 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/5732-bugfix-keycloak-userfed-idempotency.yml diff --git a/changelogs/fragments/5732-bugfix-keycloak-userfed-idempotency.yml b/changelogs/fragments/5732-bugfix-keycloak-userfed-idempotency.yml new file mode 100644 index 0000000000..c50a105c3f --- /dev/null +++ b/changelogs/fragments/5732-bugfix-keycloak-userfed-idempotency.yml @@ -0,0 +1,6 @@ +bugfixes: + - > + keycloak_user_federation - fixes idempotency detection issues. In some + cases the module could fail to properly detect already existing user + federations because of a buggy seemingly superflous extra query parameter + (https://github.com/ansible-collections/community.general/pull/5732). diff --git a/plugins/modules/keycloak_user_federation.py b/plugins/modules/keycloak_user_federation.py index 3e66c577ec..3659d757ac 100644 --- a/plugins/modules/keycloak_user_federation.py +++ b/plugins/modules/keycloak_user_federation.py @@ -24,7 +24,7 @@ description: to your needs and a user having the expected roles. - The names of module options are snake_cased versions of the camelCase ones found in the - Keycloak API and its documentation at U(https://www.keycloak.org/docs-api/15.0/rest-api/index.html). + Keycloak API and its documentation at U(https://www.keycloak.org/docs-api/20.0.2/rest-api/index.html). options: @@ -835,7 +835,7 @@ def main(): # See if it already exists in Keycloak if cid is None: - found = kc.get_components(urlencode(dict(type='org.keycloak.storage.UserStorageProvider', parent=realm, name=name)), realm) + found = kc.get_components(urlencode(dict(type='org.keycloak.storage.UserStorageProvider', name=name)), realm) if len(found) > 1: module.fail_json(msg='No ID given and found multiple user federations with name `{name}`. Cannot continue.'.format(name=name)) before_comp = next(iter(found), None) diff --git a/tests/integration/targets/keycloak_user_federation/tasks/main.yml b/tests/integration/targets/keycloak_user_federation/tasks/main.yml index 79e21dae03..139d6ee2be 100644 --- a/tests/integration/targets/keycloak_user_federation/tasks/main.yml +++ b/tests/integration/targets/keycloak_user_federation/tasks/main.yml @@ -66,6 +66,59 @@ - result.existing == {} - result.end_state.name == "{{ federation }}" +- name: Create new user federation in admin realm + community.general.keycloak_user_federation: + auth_keycloak_url: "{{ url }}" + auth_realm: "{{ admin_realm }}" + auth_username: "{{ admin_user }}" + auth_password: "{{ admin_password }}" + realm: "{{ admin_realm }}" + name: "{{ federation }}" + state: present + provider_id: ldap + provider_type: org.keycloak.storage.UserStorageProvider + config: + enabled: true + priority: 0 + fullSyncPeriod: -1 + changedSyncPeriod: -1 + cachePolicy: DEFAULT + batchSizeForSync: 1000 + editMode: READ_ONLY + importEnabled: true + syncRegistrations: false + vendor: other + usernameLDAPAttribute: uid + rdnLDAPAttribute: uid + uuidLDAPAttribute: entryUUID + userObjectClasses: "inetOrgPerson, organizationalPerson" + connectionUrl: "ldaps://ldap.example.com:636" + usersDn: "ou=Users,dc=example,dc=com" + authType: simple + bindDn: cn=directory reader + bindCredential: secret + searchScope: 1 + validatePasswordPolicy: false + trustEmail: false + useTruststoreSpi: "ldapsOnly" + connectionPooling: true + pagination: true + allowKerberosAuthentication: false + useKerberosForPasswordAuthentication: false + debug: false + register: result + +- name: Debug + debug: + var: result + +- name: Assert user federation created (admin realm) + assert: + that: + - result is changed + - result.existing == {} + - result.end_state.name == "{{ federation }}" + - name: Update existing user federation (no change) community.general.keycloak_user_federation: auth_keycloak_url: "{{ url }}" @@ -121,6 +174,61 @@ - result.end_state != {} - result.end_state.name == "{{ federation }}" +- name: Update existing user federation (no change, admin realm) + community.general.keycloak_user_federation: + auth_keycloak_url: "{{ url }}" + auth_realm: "{{ admin_realm }}" + auth_username: "{{ admin_user }}" + auth_password: "{{ admin_password }}" + realm: "{{ admin_realm }}" + name: "{{ federation }}" + state: present + provider_id: ldap + provider_type: org.keycloak.storage.UserStorageProvider + config: + enabled: true + priority: 0 + fullSyncPeriod: -1 + changedSyncPeriod: -1 + cachePolicy: DEFAULT + batchSizeForSync: 1000 + editMode: READ_ONLY + importEnabled: true + syncRegistrations: false + vendor: other + usernameLDAPAttribute: uid + rdnLDAPAttribute: uid + uuidLDAPAttribute: entryUUID + userObjectClasses: "inetOrgPerson, organizationalPerson" + connectionUrl: "ldaps://ldap.example.com:636" + usersDn: "ou=Users,dc=example,dc=com" + authType: simple + bindDn: cn=directory reader + bindCredential: "**********" + searchScope: 1 + validatePasswordPolicy: false + trustEmail: false + useTruststoreSpi: "ldapsOnly" + connectionPooling: true + pagination: true + allowKerberosAuthentication: false + useKerberosForPasswordAuthentication: false + debug: false + register: result + +- name: Debug + debug: + var: result + +- name: Assert user federation unchanged (admin realm) + assert: + that: + - result is not changed + - result.existing != {} + - result.existing.name == "{{ federation }}" + - result.end_state != {} + - result.end_state.name == "{{ federation }}" + - name: Update existing user federation (with change) community.general.keycloak_user_federation: auth_keycloak_url: "{{ url }}" From 6781dd19183a6c9322242461c1f6a585cca717fa Mon Sep 17 00:00:00 2001 From: morco Date: Sun, 22 Jan 2023 17:28:33 +0100 Subject: [PATCH 0137/1810] bugfixing keycloak user federation failing when updating default mapper simultaneously (#5750) * fix(modules/keycloak_user_federation): fixes ... ... user federation creation failing when also updating/changing default mappers at the same time * add changelog fragment for pr Co-authored-by: Mirko Wilhelmi --- ...n-update-default-mapper-simultaneously.yml | 7 ++ plugins/modules/keycloak_user_federation.py | 2 + .../keycloak_user_federation/tasks/main.yml | 88 +++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 changelogs/fragments/5750-bugfixing-keycloak-usrfed-fail-when-update-default-mapper-simultaneously.yml diff --git a/changelogs/fragments/5750-bugfixing-keycloak-usrfed-fail-when-update-default-mapper-simultaneously.yml b/changelogs/fragments/5750-bugfixing-keycloak-usrfed-fail-when-update-default-mapper-simultaneously.yml new file mode 100644 index 0000000000..93cfc3adcb --- /dev/null +++ b/changelogs/fragments/5750-bugfixing-keycloak-usrfed-fail-when-update-default-mapper-simultaneously.yml @@ -0,0 +1,7 @@ +bugfixes: + - >- + keycloak_user_federation - fixes federation creation issue. When a new + federation was created and at the same time a default / standard mapper + was also changed / updated the creation process failed as a bad None + set variable led to a bad malformed url request + (https://github.com/ansible-collections/community.general/pull/5750). diff --git a/plugins/modules/keycloak_user_federation.py b/plugins/modules/keycloak_user_federation.py index 3659d757ac..fbb31e695d 100644 --- a/plugins/modules/keycloak_user_federation.py +++ b/plugins/modules/keycloak_user_federation.py @@ -923,6 +923,8 @@ def main(): updated_mappers = desired_comp.pop('mappers', []) after_comp = kc.create_component(desired_comp, realm) + cid = after_comp['id'] + for mapper in updated_mappers: found = kc.get_components(urlencode(dict(parent=cid, name=mapper['name'])), realm) if len(found) > 1: diff --git a/tests/integration/targets/keycloak_user_federation/tasks/main.yml b/tests/integration/targets/keycloak_user_federation/tasks/main.yml index 139d6ee2be..ae0b4bf162 100644 --- a/tests/integration/targets/keycloak_user_federation/tasks/main.yml +++ b/tests/integration/targets/keycloak_user_federation/tasks/main.yml @@ -270,6 +270,14 @@ useKerberosForPasswordAuthentication: false debug: false mappers: + # overwrite / update pre existing default mapper + - name: "username" + providerId: "user-attribute-ldap-mapper" + config: + ldap.attribute: ldap_user + user.model.attribute: usr + read.only: true + # create new mapper - name: "full name" providerId: "full-name-ldap-mapper" providerType: "org.keycloak.storage.ldap.mappers.LDAPStorageMapper" @@ -335,3 +343,83 @@ - result is not changed - result.existing == {} - result.end_state == {} + +- name: Create new user federation together with mappers + community.general.keycloak_user_federation: + auth_keycloak_url: "{{ url }}" + auth_realm: "{{ admin_realm }}" + auth_username: "{{ admin_user }}" + auth_password: "{{ admin_password }}" + realm: "{{ realm }}" + name: "{{ federation }}" + state: present + provider_id: ldap + provider_type: org.keycloak.storage.UserStorageProvider + config: + enabled: true + priority: 0 + fullSyncPeriod: -1 + changedSyncPeriod: -1 + cachePolicy: DEFAULT + batchSizeForSync: 1000 + editMode: READ_ONLY + importEnabled: true + syncRegistrations: false + vendor: other + usernameLDAPAttribute: uid + rdnLDAPAttribute: uid + uuidLDAPAttribute: entryUUID + userObjectClasses: "inetOrgPerson, organizationalPerson" + connectionUrl: "ldaps://ldap.example.com:636" + usersDn: "ou=Users,dc=example,dc=com" + authType: simple + bindDn: cn=directory reader + bindCredential: secret + searchScope: 1 + validatePasswordPolicy: false + trustEmail: false + useTruststoreSpi: "ldapsOnly" + connectionPooling: true + pagination: true + allowKerberosAuthentication: false + useKerberosForPasswordAuthentication: false + debug: false + mappers: + # overwrite / update pre existing default mapper + - name: "username" + providerId: "user-attribute-ldap-mapper" + config: + ldap.attribute: ldap_user + user.model.attribute: usr + read.only: true + # create new mapper + - name: "full name" + providerId: "full-name-ldap-mapper" + providerType: "org.keycloak.storage.ldap.mappers.LDAPStorageMapper" + config: + ldap.full.name.attribute: cn + read.only: true + write.only: false + register: result + +- name: Debug + debug: + var: result + +- name: Assert user federation created + assert: + that: + - result is changed + - result.existing == {} + - result.end_state.name == "{{ federation }}" + +## no point in retesting this, just doing it to clean up introduced server changes +- name: Delete absent user federation + community.general.keycloak_user_federation: + auth_keycloak_url: "{{ url }}" + auth_realm: "{{ admin_realm }}" + auth_username: "{{ admin_user }}" + auth_password: "{{ admin_password }}" + realm: "{{ realm }}" + name: "{{ federation }}" + state: absent From bf117c839cdfbf5d6fd398df6750b53c71f8e16b Mon Sep 17 00:00:00 2001 From: Christoph <29735603+Chr1s70ph@users.noreply.github.com> Date: Sun, 22 Jan 2023 17:29:11 +0100 Subject: [PATCH 0138/1810] Clarify Error message when bitwarden vault not unlocked (#5811) * Clarify Error message when vault not unlocked You can be logged into the Bitwarden-CLI, but it can still be locked. This took me several hours to debug, since every time I ran 'bw login' it told me, that I am already logged in. If you run 'bw unlock' without being logged in, you are prompted to log in. This clarifies the Error occurring and can drastically reduce debugging time, since you don't have to look into the source code to get an understanding of whats wrong. * RM: negation Nobody needs negation * Update function name * FIX: tests * ADD: changelog * Update changelogs/fragments/5811-clarify-bitwarden-error.yml Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein --- changelogs/fragments/5811-clarify-bitwarden-error.yml | 2 ++ plugins/lookup/bitwarden.py | 6 +++--- tests/unit/plugins/lookup/test_bitwarden.py | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 changelogs/fragments/5811-clarify-bitwarden-error.yml diff --git a/changelogs/fragments/5811-clarify-bitwarden-error.yml b/changelogs/fragments/5811-clarify-bitwarden-error.yml new file mode 100644 index 0000000000..343faba478 --- /dev/null +++ b/changelogs/fragments/5811-clarify-bitwarden-error.yml @@ -0,0 +1,2 @@ +minor_changes: + - bitwarden lookup plugin - clarify what to do, if the bitwarden vault is not unlocked (https://github.com/ansible-collections/community.general/pull/5811). diff --git a/plugins/lookup/bitwarden.py b/plugins/lookup/bitwarden.py index dbcb88d456..344f960b0a 100644 --- a/plugins/lookup/bitwarden.py +++ b/plugins/lookup/bitwarden.py @@ -83,7 +83,7 @@ class Bitwarden(object): return self._cli_path @property - def logged_in(self): + def unlocked(self): out, err = self._run(['status'], stdin="") decoded = AnsibleJSONDecoder().raw_decode(out)[0] return decoded['status'] == 'unlocked' @@ -135,8 +135,8 @@ class LookupModule(LookupBase): self.set_options(var_options=variables, direct=kwargs) field = self.get_option('field') search_field = self.get_option('search') - if not _bitwarden.logged_in: - raise AnsibleError("Not logged into Bitwarden. Run 'bw login'.") + if not _bitwarden.unlocked: + raise AnsibleError("Bitwarden Vault locked. Run 'bw unlock'.") return [_bitwarden.get_field(field, term, search_field) for term in terms] diff --git a/tests/unit/plugins/lookup/test_bitwarden.py b/tests/unit/plugins/lookup/test_bitwarden.py index 7f86c39697..90f3ff7751 100644 --- a/tests/unit/plugins/lookup/test_bitwarden.py +++ b/tests/unit/plugins/lookup/test_bitwarden.py @@ -111,7 +111,7 @@ MOCK_RECORDS = [ class MockBitwarden(Bitwarden): - logged_in = True + unlocked = True def _get_matches(self, search_value, search_field="name"): return list(filter(lambda record: record[search_field] == search_value, MOCK_RECORDS)) @@ -119,7 +119,7 @@ class MockBitwarden(Bitwarden): class LoggedOutMockBitwarden(MockBitwarden): - logged_in = False + unlocked = False class TestLookupModule(unittest.TestCase): @@ -155,7 +155,7 @@ class TestLookupModule(unittest.TestCase): self.lookup.run(['a_test'])[0]) @patch('ansible_collections.community.general.plugins.lookup.bitwarden._bitwarden', LoggedOutMockBitwarden()) - def test_bitwarden_plugin_logged_out(self): + def test_bitwarden_plugin_unlocked(self): record = MOCK_RECORDS[0] record_name = record['name'] with self.assertRaises(AnsibleError): From f38bfaddf0d9cb63e028a4bc14d732bc35039492 Mon Sep 17 00:00:00 2001 From: castorsky Date: Tue, 24 Jan 2023 05:49:50 +0800 Subject: [PATCH 0139/1810] Bugfix: proxmox_disk - read time out on import (#5803) * Use async calls and fix docs * Add changelog fragment --- .../fragments/5803-proxmox-read-timeout.yml | 2 + plugins/modules/proxmox_disk.py | 61 ++++++++++++------- 2 files changed, 41 insertions(+), 22 deletions(-) create mode 100644 changelogs/fragments/5803-proxmox-read-timeout.yml diff --git a/changelogs/fragments/5803-proxmox-read-timeout.yml b/changelogs/fragments/5803-proxmox-read-timeout.yml new file mode 100644 index 0000000000..fc29605e4f --- /dev/null +++ b/changelogs/fragments/5803-proxmox-read-timeout.yml @@ -0,0 +1,2 @@ +bugfixes: + - proxmox_disk - fixed issue with read timeout on import action (https://github.com/ansible-collections/community.general/pull/5803). diff --git a/plugins/modules/proxmox_disk.py b/plugins/modules/proxmox_disk.py index 8a81f18a3f..8292b1de50 100644 --- a/plugins/modules/proxmox_disk.py +++ b/plugins/modules/proxmox_disk.py @@ -104,6 +104,7 @@ options: - Move the disk to this storage when I(state=moved). - You can move between storages only in scope of one VM. - Mutually exclusive with I(target_vmid). + - Consider increasing I(timeout) in case of large disk images or slow storage backend. type: str target_vmid: description: @@ -113,8 +114,8 @@ options: type: int timeout: description: - - Timeout in seconds to wait when moving disk. - - Used only when I(state=moved). + - Timeout in seconds to wait for slow operations such as importing disk or moving disk between storages. + - Used only when I(state) is C(present) or C(moved). type: int default: 600 aio: @@ -172,6 +173,7 @@ options: - C(:/) or C(/) - Attention! Only root can use absolute paths. - This parameter is mutually exclusive with I(size). + - Increase I(timeout) parameter when importing large disk images or using slow storage. type: str iops: description: @@ -471,6 +473,16 @@ class ProxmoxDiskAnsible(ProxmoxAnsible): params.update(dict((k, int(v)) for k, v in params.items() if isinstance(v, bool))) return params + def wait_till_complete_or_timeout(self, node_name, task_id): + timeout = self.module.params['timeout'] + while timeout: + if self.api_task_ok(node_name, task_id): + return True + timeout -= 1 + if timeout <= 0: + return False + sleep(1) + def create_disk(self, disk, vmid, vm, vm_config): create = self.module.params['create'] if create == 'disabled' and disk not in vm_config: @@ -484,20 +496,23 @@ class ProxmoxDiskAnsible(ProxmoxAnsible): if import_string: config_str = "%s:%s,import-from=%s" % (self.module.params["storage"], "0", import_string) + timeout_str = "Reached timeout while importing VM disk. Last line in task before timeout: %s" + ok_str = "Disk %s imported into VM %s" else: config_str = "%s:%s" % (self.module.params["storage"], self.module.params["size"]) + ok_str = "Disk %s created in VM %s" + timeout_str = "Reached timeout while creating VM disk. Last line in task before timeout: %s" for k, v in attributes.items(): config_str += ',%s=%s' % (k, v) - create_disk = {self.module.params["disk"]: config_str} - self.proxmox_api.nodes(vm['node']).qemu(vmid).config.set(**create_disk) - return True, "Disk %s created in VM %s" % (disk, vmid) + disk_config_to_apply = {self.module.params["disk"]: config_str} if create in ['disabled', 'regular'] and disk in vm_config: # UPDATE disk_config = disk_conf_str_to_dict(vm_config[disk]) config_str = disk_config["volume"] + ok_str = "Disk %s updated in VM %s" attributes = self.get_create_attributes() # 'import_from' fails on disk updates attributes.pop('import_from', None) @@ -513,9 +528,16 @@ class ProxmoxDiskAnsible(ProxmoxAnsible): if disk_config == attributes: return False, "Disk %s is up to date in VM %s" % (disk, vmid) - update_disk = {self.module.params["disk"]: config_str} - self.proxmox_api.nodes(vm['node']).qemu(vmid).config.set(**update_disk) - return True, "Disk %s updated in VM %s" % (disk, vmid) + disk_config_to_apply = {self.module.params["disk"]: config_str} + + current_task_id = self.proxmox_api.nodes(vm['node']).qemu(vmid).config.post(**disk_config_to_apply) + task_success = self.wait_till_complete_or_timeout(vm['node'], current_task_id) + if task_success: + return True, ok_str % (disk, vmid) + else: + self.module.fail_json( + msg=timeout_str % self.proxmox_api.nodes(vm['node']).tasks(current_task_id).log.get()[:1] + ) def move_disk(self, disk, vmid, vm, vm_config): params = dict() @@ -535,20 +557,15 @@ class ProxmoxDiskAnsible(ProxmoxAnsible): if params['storage'] == disk_config['storage_name']: return False - taskid = self.proxmox_api.nodes(vm['node']).qemu(vmid).move_disk.post(**params) - timeout = self.module.params['timeout'] - while timeout: - status_data = self.proxmox_api.nodes(vm['node']).tasks(taskid).status.get() - if status_data['status'] == 'stopped' and status_data['exitstatus'] == 'OK': - return True - if timeout <= 0: - self.module.fail_json( - msg='Reached timeout while waiting for moving VM disk. Last line in task before timeout: %s' % - self.proxmox_api.nodes(vm['node']).tasks(taskid).log.get()[:1]) - - sleep(1) - timeout -= 1 - return True + task_id = self.proxmox_api.nodes(vm['node']).qemu(vmid).move_disk.post(**params) + task_success = self.wait_till_complete_or_timeout(vm['node'], task_id) + if task_success: + return True + else: + self.module.fail_json( + msg='Reached timeout while waiting for moving VM disk. Last line in task before timeout: %s' % + self.proxmox_api.nodes(vm['node']).tasks(task_id).log.get()[:1] + ) def main(): From fe520a6b09aeab283f1477556b49cb64386a8e10 Mon Sep 17 00:00:00 2001 From: Juan Vela Date: Tue, 24 Jan 2023 19:43:28 +0100 Subject: [PATCH 0140/1810] Gem: Support force flag when uninstalling (#5822) * Gem: Support force flag when uninstalling * Improve docs' syntax * Add changelog fragment --- changelogs/fragments/5822-gem-uninstall-force.yml | 2 ++ plugins/modules/gem.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/5822-gem-uninstall-force.yml diff --git a/changelogs/fragments/5822-gem-uninstall-force.yml b/changelogs/fragments/5822-gem-uninstall-force.yml new file mode 100644 index 0000000000..7b8a0efbda --- /dev/null +++ b/changelogs/fragments/5822-gem-uninstall-force.yml @@ -0,0 +1,2 @@ +bugfixes: + - gem - fix force parameter not being passed to gem command when uninstalling (https://github.com/ansible-collections/community.general/pull/5822). diff --git a/plugins/modules/gem.py b/plugins/modules/gem.py index 21e9efea58..a44683c786 100644 --- a/plugins/modules/gem.py +++ b/plugins/modules/gem.py @@ -105,7 +105,7 @@ options: required: false force: description: - - Force gem to install, bypassing dependency checks. + - Force gem to (un-)install, bypassing dependency checks. required: false default: false type: bool @@ -235,6 +235,8 @@ def uninstall(module): else: cmd.append('--all') cmd.append('--executable') + if module.params['force']: + cmd.append('--force') cmd.append(module.params['name']) module.run_command(cmd, environ_update=environ, check_rc=True) From 855cbd67aed46e9cae30fda61535fa21183a40bb Mon Sep 17 00:00:00 2001 From: lapete Date: Wed, 25 Jan 2023 23:03:35 +0100 Subject: [PATCH 0141/1810] Update gitlab_deploy_key.py (#5888) * Update gitlab_deploy_key.py Change key title on key update * Create 5888-update-key-title Add changelog fragment for key title change * Update changelogs/fragments/5888-update-key-title Co-authored-by: Felix Fontein * Rename 5888-update-key-title to 5888-update-key-title.yml Co-authored-by: Felix Fontein --- changelogs/fragments/5888-update-key-title.yml | 2 ++ plugins/modules/gitlab_deploy_key.py | 1 + 2 files changed, 3 insertions(+) create mode 100644 changelogs/fragments/5888-update-key-title.yml diff --git a/changelogs/fragments/5888-update-key-title.yml b/changelogs/fragments/5888-update-key-title.yml new file mode 100644 index 0000000000..e620ad3d79 --- /dev/null +++ b/changelogs/fragments/5888-update-key-title.yml @@ -0,0 +1,2 @@ +minor_changes: + - gitlab_deploy_key - also update ``title`` and not just ``can_push`` (https://github.com/ansible-collections/community.general/pull/5888). diff --git a/plugins/modules/gitlab_deploy_key.py b/plugins/modules/gitlab_deploy_key.py index 3ed2b2d7a5..f4a9fb29fa 100644 --- a/plugins/modules/gitlab_deploy_key.py +++ b/plugins/modules/gitlab_deploy_key.py @@ -151,6 +151,7 @@ class GitLabDeployKey(object): changed = True else: changed, deploy_key = self.update_deploy_key(self.deploy_key_object, { + 'title': key_title, 'can_push': options['can_push']}) self.deploy_key_object = deploy_key From 7b8b73f17faee9f76b9cd62b770b277a5e752905 Mon Sep 17 00:00:00 2001 From: Piotr Date: Sat, 28 Jan 2023 11:28:18 +0100 Subject: [PATCH 0142/1810] Add support to Bitwarden Lookup for filtering results by collection (#5849) (#5851) * Add support to Bitwarden Lookup for filtering results by collection id (#5849) * Debug * Add support to Bitwarden Lookup for filtering results by collection id (#5849) * Update comments * Fix blank line issue * Fix unit tests for bitwarden lookup plugin. Add changelog fragment file. * Change collectionId to collection_id parameter on bitwarden plugin * Fix collection id parameter name when used in bw cli --- ...-add-filter-by-collection-id-parameter.yml | 2 ++ plugins/lookup/bitwarden.py | 32 +++++++++++++++---- tests/unit/plugins/lookup/test_bitwarden.py | 2 +- 3 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 changelogs/fragments/5851-lookup-bitwarden-add-filter-by-collection-id-parameter.yml diff --git a/changelogs/fragments/5851-lookup-bitwarden-add-filter-by-collection-id-parameter.yml b/changelogs/fragments/5851-lookup-bitwarden-add-filter-by-collection-id-parameter.yml new file mode 100644 index 0000000000..28b878a5b0 --- /dev/null +++ b/changelogs/fragments/5851-lookup-bitwarden-add-filter-by-collection-id-parameter.yml @@ -0,0 +1,2 @@ +minor_changes: + - bitwarden lookup plugin - implement filtering results by ``collection_id`` parameter (https://github.com/ansible-collections/community.general/issues/5849). \ No newline at end of file diff --git a/plugins/lookup/bitwarden.py b/plugins/lookup/bitwarden.py index 344f960b0a..389fa475bd 100644 --- a/plugins/lookup/bitwarden.py +++ b/plugins/lookup/bitwarden.py @@ -28,8 +28,12 @@ DOCUMENTATION = """ default: name version_added: 5.7.0 field: - description: Field to fetch; leave unset to fetch whole response. + description: Field to fetch. Leave unset to fetch whole response. type: str + collection_id: + description: Collection ID to filter results by collection. Leave unset to skip filtering. + type: str + version_added: 6.3.0 """ EXAMPLES = """ @@ -43,6 +47,11 @@ EXAMPLES = """ msg: >- {{ lookup('community.general.bitwarden', 'bafba515-af11-47e6-abe3-af1200cd18b2', search='id', field='password') }} +- name: "Get 'password' from Bitwarden record named 'a_test' from collection" + ansible.builtin.debug: + msg: >- + {{ lookup('community.general.bitwarden', 'a_test', field='password', collection_id='bafba515-af11-47e6-abe3-af1200cd18b2') }} + - name: "Get full Bitwarden record named 'a_test'" ansible.builtin.debug: msg: >- @@ -96,10 +105,17 @@ class Bitwarden(object): raise BitwardenException(err) return to_text(out, errors='surrogate_or_strict'), to_text(err, errors='surrogate_or_strict') - def _get_matches(self, search_value, search_field): + def _get_matches(self, search_value, search_field, collection_id): """Return matching records whose search_field is equal to key. """ - out, err = self._run(['list', 'items', '--search', search_value]) + + # Prepare set of params for Bitwarden CLI + params = ['list', 'items', '--search', search_value] + + if collection_id: + params.extend(['--collectionid', collection_id]) + + out, err = self._run(params) # This includes things that matched in different fields. initial_matches = AnsibleJSONDecoder().raw_decode(out)[0] @@ -107,12 +123,13 @@ class Bitwarden(object): # Filter to only include results from the right field. return [item for item in initial_matches if item[search_field] == search_value] - def get_field(self, field, search_value, search_field="name"): - """Return a list of the specified field for records whose search_field match search_value. + def get_field(self, field, search_value, search_field="name", collection_id=None): + """Return a list of the specified field for records whose search_field match search_value + and filtered by collection if collection has been provided. If field is None, return the whole record for each match. """ - matches = self._get_matches(search_value, search_field) + matches = self._get_matches(search_value, search_field, collection_id) if field in ['autofillOnPageLoad', 'password', 'passwordRevisionDate', 'totp', 'uris', 'username']: return [match['login'][field] for match in matches] @@ -135,10 +152,11 @@ class LookupModule(LookupBase): self.set_options(var_options=variables, direct=kwargs) field = self.get_option('field') search_field = self.get_option('search') + collection_id = self.get_option('collection_id') if not _bitwarden.unlocked: raise AnsibleError("Bitwarden Vault locked. Run 'bw unlock'.") - return [_bitwarden.get_field(field, term, search_field) for term in terms] + return [_bitwarden.get_field(field, term, search_field, collection_id) for term in terms] _bitwarden = Bitwarden() diff --git a/tests/unit/plugins/lookup/test_bitwarden.py b/tests/unit/plugins/lookup/test_bitwarden.py index 90f3ff7751..ac0242737e 100644 --- a/tests/unit/plugins/lookup/test_bitwarden.py +++ b/tests/unit/plugins/lookup/test_bitwarden.py @@ -113,7 +113,7 @@ class MockBitwarden(Bitwarden): unlocked = True - def _get_matches(self, search_value, search_field="name"): + def _get_matches(self, search_value, search_field="name", collection_id=None): return list(filter(lambda record: record[search_field] == search_value, MOCK_RECORDS)) From 8818a6f2421d50980229db464a710a84e4748eff Mon Sep 17 00:00:00 2001 From: Michal Opala Date: Sat, 28 Jan 2023 11:29:00 +0100 Subject: [PATCH 0143/1810] OpenNebula/one_vm implement the one.vm.updateconf API call (#5812) * opennebula: Add template manipulation helpers * one_vm: Use 'updateconf' API call to modify running VMs * one_vm: Emulate 'updateconf' API call for newly created VMs * opennebula/one_vm: Satisfy linter checks * opennebula/one_vm: Apply suggestions from code review Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> * opennebula/one_vm: Drop 'extend' function, use 'dict_merge' instead * Add changelog fragment * one_vm: Refactor 'parse_updateconf' function * opennebula/one_vm: Apply suggestions from code review Co-authored-by: Felix Fontein * one_vm: Allow for using updateconf in all scenarios --------- Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> Co-authored-by: Felix Fontein --- .../5812-implement-updateconf-api-call.yml | 2 + plugins/module_utils/opennebula.py | 30 ++ plugins/modules/one_vm.py | 259 ++++++++++++------ .../plugins/module_utils/test_opennebula.py | 91 ++++++ tests/unit/plugins/modules/test_one_vm.py | 62 +++++ 5 files changed, 364 insertions(+), 80 deletions(-) create mode 100644 changelogs/fragments/5812-implement-updateconf-api-call.yml create mode 100644 tests/unit/plugins/module_utils/test_opennebula.py create mode 100644 tests/unit/plugins/modules/test_one_vm.py diff --git a/changelogs/fragments/5812-implement-updateconf-api-call.yml b/changelogs/fragments/5812-implement-updateconf-api-call.yml new file mode 100644 index 0000000000..09058f044e --- /dev/null +++ b/changelogs/fragments/5812-implement-updateconf-api-call.yml @@ -0,0 +1,2 @@ +minor_changes: + - one_vm - add a new ``updateconf`` option which implements the ``one.vm.updateconf`` API call (https://github.com/ansible-collections/community.general/pull/5812). diff --git a/plugins/module_utils/opennebula.py b/plugins/module_utils/opennebula.py index b27ec229bf..0fe649ba5c 100644 --- a/plugins/module_utils/opennebula.py +++ b/plugins/module_utils/opennebula.py @@ -26,6 +26,36 @@ except ImportError: HAS_PYONE = False +# A helper function to mitigate https://github.com/OpenNebula/one/issues/6064. +# It allows for easily handling lists like "NIC" or "DISK" in the JSON-like template representation. +# There are either lists of dictionaries (length > 1) or just dictionaries. +def flatten(to_flatten, extract=False): + """Flattens nested lists (with optional value extraction).""" + def recurse(to_flatten): + return sum(map(recurse, to_flatten), []) if isinstance(to_flatten, list) else [to_flatten] + value = recurse(to_flatten) + if extract and len(value) == 1: + return value[0] + return value + + +# A helper function to mitigate https://github.com/OpenNebula/one/issues/6064. +# It renders JSON-like template representation into OpenNebula's template syntax (string). +def render(to_render): + """Converts dictionary to OpenNebula template.""" + def recurse(to_render): + for key, value in sorted(to_render.items()): + if isinstance(value, dict): + yield '{0:}=[{1:}]'.format(key, ','.join(recurse(value))) + continue + if isinstance(value, list): + for item in value: + yield '{0:}=[{1:}]'.format(key, ','.join(recurse(item))) + continue + yield '{0:}="{1:}"'.format(key, value) + return '\n'.join(recurse(to_render)) + + class OpenNebulaModule: """ Base class for all OpenNebula Ansible Modules. diff --git a/plugins/modules/one_vm.py b/plugins/modules/one_vm.py index 7122907d38..3724d9433d 100644 --- a/plugins/modules/one_vm.py +++ b/plugins/modules/one_vm.py @@ -196,6 +196,13 @@ options: - Name of Datastore to use to create a new instace version_added: '0.2.0' type: str + updateconf: + description: + - When I(instance_ids) is provided, updates running VMs with the C(updateconf) API call. + - When new VMs are being created, emulates the C(updateconf) API call via direct template merge. + - Allows for complete modifications of the C(CONTEXT) attribute. + type: dict + version_added: 6.3.0 author: - "Milan Ilic (@ilicmilan)" - "Jan Meerkamp (@meerkampdvv)" @@ -403,6 +410,30 @@ EXAMPLES = ''' disk_saveas: name: bar-image disk_id: 1 + +- name: "Deploy 2 new instances with a custom 'start script'" + community.general.one_vm: + template_name: app_template + count: 2 + updateconf: + CONTEXT: + START_SCRIPT: ip r r 169.254.16.86/32 dev eth0 + +- name: "Add a custom 'start script' to a running VM" + community.general.one_vm: + instance_ids: 351 + updateconf: + CONTEXT: + START_SCRIPT: ip r r 169.254.16.86/32 dev eth0 + +- name: "Update SSH public keys inside the VM's context" + community.general.one_vm: + instance_ids: 351 + updateconf: + CONTEXT: + SSH_PUBLIC_KEY: |- + ssh-rsa ... + ssh-ed25519 ... ''' RETURN = ''' @@ -510,6 +541,17 @@ instances: "TE_GALAXY": "bar", "USER_INPUTS": null } + updateconf: + description: A dictionary of key/values attributes that are set with the updateconf API call. + type: dict + version_added: 6.3.0 + sample: { + "OS": { "ARCH": "x86_64" }, + "CONTEXT": { + "START_SCRIPT": "ip r r 169.254.16.86/32 dev eth0", + "SSH_PUBLIC_KEY": "ssh-rsa ...\\nssh-ed25519 ..." + } + } tagged_instances: description: - A list of instances info based on a specific attributes and/or @@ -615,6 +657,17 @@ tagged_instances: "TE_GALAXY": "bar", "USER_INPUTS": null } + updateconf: + description: A dictionary of key/values attributes that are set with the updateconf API call + type: dict + version_added: 6.3.0 + sample: { + "OS": { "ARCH": "x86_64" }, + "CONTEXT": { + "START_SCRIPT": "ip r r 169.254.16.86/32 dev eth0", + "SSH_PUBLIC_KEY": "ssh-rsa ...\\nssh-ed25519 ..." + } + } ''' try: @@ -623,9 +676,52 @@ try: except ImportError: HAS_PYONE = False -from ansible.module_utils.basic import AnsibleModule + import os +from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils.common.dict_transformations import dict_merge + +from ansible_collections.community.general.plugins.module_utils.opennebula import flatten, render + + +UPDATECONF_ATTRIBUTES = { + "OS": ["ARCH", "MACHINE", "KERNEL", "INITRD", "BOOTLOADER", "BOOT", "SD_DISK_BUS", "UUID"], + "FEATURES": ["ACPI", "PAE", "APIC", "LOCALTIME", "HYPERV", "GUEST_AGENT"], + "INPUT": ["TYPE", "BUS"], + "GRAPHICS": ["TYPE", "LISTEN", "PASSWD", "KEYMAP"], + "RAW": ["DATA", "DATA_VMX", "TYPE"], + "CONTEXT": [], +} + + +def check_updateconf(module, to_check): + '''Checks if attributes are compatible with one.vm.updateconf API call.''' + for attr, subattributes in to_check.items(): + if attr not in UPDATECONF_ATTRIBUTES: + module.fail_json(msg="'{0:}' is not a valid VM attribute.".format(attr)) + if not UPDATECONF_ATTRIBUTES[attr]: + continue + for subattr in subattributes: + if subattr not in UPDATECONF_ATTRIBUTES[attr]: + module.fail_json(msg="'{0:}' is not a valid VM subattribute of '{1:}'".format(subattr, attr)) + + +def parse_updateconf(vm_template): + '''Extracts 'updateconf' attributes from a VM template.''' + updateconf = {} + for attr, subattributes in vm_template.items(): + if attr not in UPDATECONF_ATTRIBUTES: + continue + tmp = {} + for subattr, value in subattributes.items(): + if UPDATECONF_ATTRIBUTES[attr] and subattr not in UPDATECONF_ATTRIBUTES[attr]: + continue + tmp[subattr] = value + if tmp: + updateconf[attr] = tmp + return updateconf + def get_template(module, client, predicate): @@ -767,6 +863,8 @@ def get_vm_info(client, vm): vm_labels, vm_attributes = get_vm_labels_and_attributes_dict(client, vm.ID) + updateconf = parse_updateconf(vm.TEMPLATE) + info = { 'template_id': int(vm.TEMPLATE['TEMPLATE_ID']), 'vm_id': vm.ID, @@ -785,7 +883,8 @@ def get_vm_info(client, vm): 'uptime_h': int(vm_uptime), 'attributes': vm_attributes, 'mode': permissions_str, - 'labels': vm_labels + 'labels': vm_labels, + 'updateconf': updateconf, } return info @@ -844,6 +943,28 @@ def set_vm_ownership(module, client, vms, owner_id, group_id): return changed +def update_vm(module, client, vm, updateconf_dict): + changed = False + if not updateconf_dict: + return changed + + before = client.vm.info(vm.ID).TEMPLATE + + client.vm.updateconf(vm.ID, render(updateconf_dict), 1) # 1: Merge new template with the existing one. + + after = client.vm.info(vm.ID).TEMPLATE + + changed = before != after + return changed + + +def update_vms(module, client, vms, *args): + changed = False + for vm in vms: + changed = update_vm(module, client, vm, *args) or changed + return changed + + def get_size_in_MB(module, size_str): SYMBOLS = ['B', 'KB', 'MB', 'GB', 'TB'] @@ -871,81 +992,46 @@ def get_size_in_MB(module, size_str): return size_in_MB -def create_disk_str(module, client, template_id, disk_size_list): - - if not disk_size_list: - return '' - - template = client.template.info(template_id) - if isinstance(template.TEMPLATE['DISK'], list): - # check if the number of disks is correct - if len(template.TEMPLATE['DISK']) != len(disk_size_list): - module.fail_json(msg='This template has ' + str(len(template.TEMPLATE['DISK'])) + ' disks but you defined ' + str(len(disk_size_list))) - result = '' - index = 0 - for DISKS in template.TEMPLATE['DISK']: - disk = {} - diskresult = '' - # Get all info about existed disk e.g. IMAGE_ID,... - for key, value in DISKS.items(): - disk[key] = value - # copy disk attributes if it is not the size attribute - diskresult += 'DISK = [' + ','.join('{key}="{val}"'.format(key=key, val=val) for key, val in disk.items() if key != 'SIZE') - # Set the Disk Size - diskresult += ', SIZE=' + str(int(get_size_in_MB(module, disk_size_list[index]))) + ']\n' - result += diskresult - index += 1 - else: - if len(disk_size_list) > 1: - module.fail_json(msg='This template has one disk but you defined ' + str(len(disk_size_list))) - disk = {} - # Get all info about existed disk e.g. IMAGE_ID,... - for key, value in template.TEMPLATE['DISK'].items(): - disk[key] = value - # copy disk attributes if it is not the size attribute - result = 'DISK = [' + ','.join('{key}="{val}"'.format(key=key, val=val) for key, val in disk.items() if key != 'SIZE') - # Set the Disk Size - result += ', SIZE=' + str(int(get_size_in_MB(module, disk_size_list[0]))) + ']\n' - - return result - - -def create_attributes_str(attributes_dict, labels_list): - - attributes_str = '' - - if labels_list: - attributes_str += 'LABELS="' + ','.join('{label}'.format(label=label) for label in labels_list) + '"\n' - if attributes_dict: - attributes_str += '\n'.join('{key}="{val}"'.format(key=key.upper(), val=val) for key, val in attributes_dict.items()) + '\n' - - return attributes_str - - -def create_nics_str(network_attrs_list): - nics_str = '' - - for network in network_attrs_list: - # Packing key-value dict in string with format key="value", key="value" - network_str = ','.join('{key}="{val}"'.format(key=key, val=val) for key, val in network.items()) - nics_str = nics_str + 'NIC = [' + network_str + ']\n' - - return nics_str - - -def create_vm(module, client, template_id, attributes_dict, labels_list, disk_size, network_attrs_list, vm_start_on_hold, vm_persistent): - +def create_vm(module, client, template_id, attributes_dict, labels_list, disk_size, network_attrs_list, vm_start_on_hold, vm_persistent, updateconf_dict): if attributes_dict: vm_name = attributes_dict.get('NAME', '') - disk_str = create_disk_str(module, client, template_id, disk_size) - vm_extra_template_str = create_attributes_str(attributes_dict, labels_list) + create_nics_str(network_attrs_list) + disk_str + template = client.template.info(template_id).TEMPLATE + + disk_count = len(flatten(template.get('DISK', []))) + if disk_size: + size_count = len(flatten(disk_size)) + # check if the number of disks is correct + if disk_count != size_count: + module.fail_json(msg='This template has ' + str(disk_count) + ' disks but you defined ' + str(size_count)) + + vm_extra_template = dict_merge(template or {}, attributes_dict or {}) + vm_extra_template = dict_merge(vm_extra_template, { + 'LABELS': ','.join(labels_list), + 'NIC': flatten(network_attrs_list, extract=True), + 'DISK': flatten([ + disk if not size else dict_merge(disk, { + 'SIZE': str(int(get_size_in_MB(module, size))), + }) + for disk, size in zip( + flatten(template.get('DISK', [])), + flatten(disk_size or [None] * disk_count), + ) + if disk is not None + ], extract=True) + }) + vm_extra_template = dict_merge(vm_extra_template, updateconf_dict or {}) + try: - vm_id = client.template.instantiate(template_id, vm_name, vm_start_on_hold, vm_extra_template_str, vm_persistent) + vm_id = client.template.instantiate(template_id, + vm_name, + vm_start_on_hold, + render(vm_extra_template), + vm_persistent) except pyone.OneException as e: module.fail_json(msg=str(e)) - vm = get_vm_by_id(client, vm_id) + vm = get_vm_by_id(client, vm_id) return get_vm_info(client, vm) @@ -1028,8 +1114,10 @@ def get_all_vms_by_attributes(client, attributes_dict, labels_list): return vm_list -def create_count_of_vms( - module, client, template_id, count, attributes_dict, labels_list, disk_size, network_attrs_list, wait, wait_timeout, vm_start_on_hold, vm_persistent): +def create_count_of_vms(module, client, + template_id, count, + attributes_dict, labels_list, disk_size, network_attrs_list, + wait, wait_timeout, vm_start_on_hold, vm_persistent, updateconf_dict): new_vms_list = [] vm_name = '' @@ -1058,7 +1146,9 @@ def create_count_of_vms( new_vm_name += next_index # Update NAME value in the attributes in case there is index attributes_dict['NAME'] = new_vm_name - new_vm_dict = create_vm(module, client, template_id, attributes_dict, labels_list, disk_size, network_attrs_list, vm_start_on_hold, vm_persistent) + new_vm_dict = create_vm(module, client, + template_id, attributes_dict, labels_list, disk_size, network_attrs_list, + vm_start_on_hold, vm_persistent, updateconf_dict) new_vm_id = new_vm_dict.get('vm_id') new_vm = get_vm_by_id(client, new_vm_id) new_vms_list.append(new_vm) @@ -1076,9 +1166,10 @@ def create_count_of_vms( return True, new_vms_list, [] -def create_exact_count_of_vms(module, client, template_id, exact_count, attributes_dict, count_attributes_dict, - labels_list, count_labels_list, disk_size, network_attrs_list, hard, wait, wait_timeout, vm_start_on_hold, vm_persistent): - +def create_exact_count_of_vms(module, client, + template_id, exact_count, attributes_dict, count_attributes_dict, + labels_list, count_labels_list, disk_size, network_attrs_list, + hard, wait, wait_timeout, vm_start_on_hold, vm_persistent, updateconf_dict): vm_list = get_all_vms_by_attributes(client, count_attributes_dict, count_labels_list) vm_count_diff = exact_count - len(vm_list) @@ -1095,7 +1186,7 @@ def create_exact_count_of_vms(module, client, template_id, exact_count, attribut # Add more VMs changed, instances_list, tagged_instances = create_count_of_vms(module, client, template_id, vm_count_diff, attributes_dict, labels_list, disk_size, network_attrs_list, wait, wait_timeout, - vm_start_on_hold, vm_persistent) + vm_start_on_hold, vm_persistent, updateconf_dict) tagged_instances_list += instances_list elif vm_count_diff < 0: @@ -1398,7 +1489,8 @@ def main(): "labels": {"default": [], "type": "list", "elements": "str"}, "count_labels": {"required": False, "type": "list", "elements": "str"}, "disk_saveas": {"type": "dict"}, - "persistent": {"default": False, "type": "bool"} + "persistent": {"default": False, "type": "bool"}, + "updateconf": {"type": "dict"}, } module = AnsibleModule(argument_spec=fields, @@ -1452,6 +1544,7 @@ def main(): count_labels = params.get('count_labels') disk_saveas = params.get('disk_saveas') persistent = params.get('persistent') + updateconf = params.get('updateconf') if not (auth.username and auth.password): module.warn("Credentials missing") @@ -1470,6 +1563,9 @@ def main(): attributes = copy.copy(count_attributes) check_attributes(module, count_attributes) + if updateconf: + check_updateconf(module, updateconf) + if count_labels and not labels: module.warn('When you pass `count_labels` without `labels` option when deploying, `labels` option will have same values implicitly.') labels = count_labels @@ -1529,13 +1625,13 @@ def main(): # Deploy an exact count of VMs changed, instances_list, tagged_instances_list = create_exact_count_of_vms(module, one_client, template_id, exact_count, attributes, count_attributes, labels, count_labels, disk_size, - networks, hard, wait, wait_timeout, put_vm_on_hold, persistent) + networks, hard, wait, wait_timeout, put_vm_on_hold, persistent, updateconf) vms = tagged_instances_list elif template_id is not None and state == 'present': # Deploy count VMs changed, instances_list, tagged_instances_list = create_count_of_vms(module, one_client, template_id, count, attributes, labels, disk_size, networks, wait, wait_timeout, - put_vm_on_hold, persistent) + put_vm_on_hold, persistent, updateconf) # instances_list - new instances # tagged_instances_list - all instances with specified `count_attributes` and `count_labels` vms = instances_list @@ -1587,6 +1683,9 @@ def main(): if owner_id is not None or group_id is not None: changed = set_vm_ownership(module, one_client, vms, owner_id, group_id) or changed + if template_id is None and updateconf is not None: + changed = update_vms(module, one_client, vms, updateconf) or changed + if wait and not module.check_mode and state != 'present': wait_for = { 'absent': wait_for_done, diff --git a/tests/unit/plugins/module_utils/test_opennebula.py b/tests/unit/plugins/module_utils/test_opennebula.py new file mode 100644 index 0000000000..3dd2e91876 --- /dev/null +++ b/tests/unit/plugins/module_utils/test_opennebula.py @@ -0,0 +1,91 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2023, Michal Opala +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os +import textwrap + +import pytest + +from ansible_collections.community.general.plugins.module_utils.opennebula import flatten, render + + +FLATTEN_VALID = [ + ( + [[[1]], [2], 3], + False, + [1, 2, 3] + ), + ( + [[[1]], [2], 3], + True, + [1, 2, 3] + ), + ( + [[1]], + False, + [1] + ), + ( + [[1]], + True, + 1 + ), + ( + 1, + False, + [1] + ), + ( + 1, + True, + 1 + ), +] + +RENDER_VALID = [ + ( + { + "NIC": {"NAME": "NIC0", "NETWORK_ID": 0}, + "CPU": 1, + "MEMORY": 1024, + }, + textwrap.dedent(''' + CPU="1" + MEMORY="1024" + NIC=[NAME="NIC0",NETWORK_ID="0"] + ''').strip() + ), + ( + { + "NIC": [ + {"NAME": "NIC0", "NETWORK_ID": 0}, + {"NAME": "NIC1", "NETWORK_ID": 1}, + ], + "CPU": 1, + "MEMORY": 1024, + }, + textwrap.dedent(''' + CPU="1" + MEMORY="1024" + NIC=[NAME="NIC0",NETWORK_ID="0"] + NIC=[NAME="NIC1",NETWORK_ID="1"] + ''').strip() + ), +] + + +@pytest.mark.parametrize('to_flatten,extract,expected_result', FLATTEN_VALID) +def test_flatten(to_flatten, extract, expected_result): + result = flatten(to_flatten, extract) + assert result == expected_result, repr(result) + + +@pytest.mark.parametrize('to_render,expected_result', RENDER_VALID) +def test_render(to_render, expected_result): + result = render(to_render) + assert result == expected_result, repr(result) diff --git a/tests/unit/plugins/modules/test_one_vm.py b/tests/unit/plugins/modules/test_one_vm.py new file mode 100644 index 0000000000..f89a0c63df --- /dev/null +++ b/tests/unit/plugins/modules/test_one_vm.py @@ -0,0 +1,62 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2023, Michal Opala +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os + +import pytest + +from ansible_collections.community.general.plugins.modules.one_vm import parse_updateconf + + +PARSE_UPDATECONF_VALID = [ + ( + { + "CPU": 1, + "OS": {"ARCH": 2}, + }, + { + "OS": {"ARCH": 2}, + } + ), + ( + { + "OS": {"ARCH": 1, "ASD": 2}, # "ASD" is an invalid attribute, we ignore it + }, + { + "OS": {"ARCH": 1}, + } + ), + ( + { + "OS": {"ASD": 1}, # "ASD" is an invalid attribute, we ignore it + }, + { + } + ), + ( + { + "MEMORY": 1, + "CONTEXT": { + "PASSWORD": 2, + "SSH_PUBLIC_KEY": 3, + }, + }, + { + "CONTEXT": { + "PASSWORD": 2, + "SSH_PUBLIC_KEY": 3, + }, + } + ), +] + + +@pytest.mark.parametrize('vm_template,expected_result', PARSE_UPDATECONF_VALID) +def test_parse_updateconf(vm_template, expected_result): + result = parse_updateconf(vm_template) + assert result == expected_result, repr(result) From 6c6de8fb90cb273250517a603d61eb49bd2603ee Mon Sep 17 00:00:00 2001 From: yhal003 Date: Mon, 30 Jan 2023 03:18:40 +1300 Subject: [PATCH 0144/1810] add external user support to ipa_group module (#5897) * add external user support to ipa_group module * add changelog * fix style errors * remove trailing whitespace * Update plugins/modules/ipa_group.py Co-authored-by: Felix Fontein * Update plugins/modules/ipa_group.py Co-authored-by: Felix Fontein * Update plugins/modules/ipa_group.py Co-authored-by: Felix Fontein * Update plugins/modules/ipa_group.py Co-authored-by: Felix Fontein * Update changelogs/fragments/5897-ipa_group-add-external-users.yml Co-authored-by: Felix Fontein * Update plugins/modules/ipa_group.py Co-authored-by: Felix Fontein * Update plugins/modules/ipa_group.py Co-authored-by: Felix Fontein --------- Co-authored-by: Yuriy Halytskyy Co-authored-by: Felix Fontein --- .../5897-ipa_group-add-external-users.yml | 2 + plugins/modules/ipa_group.py | 56 ++++++++++++++++++- 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/5897-ipa_group-add-external-users.yml diff --git a/changelogs/fragments/5897-ipa_group-add-external-users.yml b/changelogs/fragments/5897-ipa_group-add-external-users.yml new file mode 100644 index 0000000000..e41ea7a97c --- /dev/null +++ b/changelogs/fragments/5897-ipa_group-add-external-users.yml @@ -0,0 +1,2 @@ +minor_changes: + - ipa_group - allow to add and remove external users with the ``external_user`` option (https://github.com/ansible-collections/community.general/pull/5897). \ No newline at end of file diff --git a/plugins/modules/ipa_group.py b/plugins/modules/ipa_group.py index fa3c610d90..89cc806d2d 100644 --- a/plugins/modules/ipa_group.py +++ b/plugins/modules/ipa_group.py @@ -64,6 +64,17 @@ options: - If option is omitted assigned users will not be checked or changed. type: list elements: str + external_user: + description: + - List of external users assigned to this group. + - Behaves identically to I(user) with respect to I(append) attribute. + - List entries can be in C(DOMAIN\\username) or SID format. + - Unless SIDs are provided, the module will always attempt to make changes even if the group already has all the users. + This is because only SIDs are returned by IPA query. + - I(external=true) is needed for this option to work. + type: list + elements: str + version_added: 6.3.0 state: description: - State to ensure @@ -116,6 +127,28 @@ EXAMPLES = r''' ipa_user: admin ipa_pass: topsecret +- name: Add external user to a group + community.general.ipa_group: + name: developers + external: true + append: true + external_user: + - S-1-5-21-123-1234-12345-63421 + ipa_host: ipa.example.com + ipa_user: admin + ipa_pass: topsecret + +- name: Add a user from MYDOMAIN + community.general.ipa_group: + name: developers + external: true + append: true + external_user: + - MYDOMAIN\\john + ipa_host: ipa.example.com + ipa_user: admin + ipa_pass: topsecret + - name: Ensure group is absent community.general.ipa_group: name: sysops @@ -164,6 +197,9 @@ class GroupIPAClient(IPAClient): def group_add_member_user(self, name, item): return self.group_add_member(name=name, item={'user': item}) + def group_add_member_externaluser(self, name, item): + return self.group_add_member(name=name, item={'ipaexternalmember': item}) + def group_remove_member(self, name, item): return self._post_json(method='group_remove_member', name=name, item=item) @@ -173,6 +209,9 @@ class GroupIPAClient(IPAClient): def group_remove_member_user(self, name, item): return self.group_remove_member(name=name, item={'user': item}) + def group_remove_member_externaluser(self, name, item): + return self.group_remove_member(name=name, item={'ipaexternalmember': item}) + def get_group_dict(description=None, external=None, gid=None, nonposix=None): group = {} @@ -208,12 +247,19 @@ def ensure(module, client): name = module.params['cn'] group = module.params['group'] user = module.params['user'] + external = module.params['external'] + external_user = module.params['external_user'] append = module.params['append'] - module_group = get_group_dict(description=module.params['description'], external=module.params['external'], - gid=module.params['gidnumber'], nonposix=module.params['nonposix']) + module_group = get_group_dict(description=module.params['description'], + external=external, + gid=module.params['gidnumber'], + nonposix=module.params['nonposix']) ipa_group = client.group_find(name=name) + if (not (external or external_user is None)): + module.fail_json("external_user can only be set if external = True") + changed = False if state == 'present': if not ipa_group: @@ -242,6 +288,11 @@ def ensure(module, client): client.group_remove_member_user, append=append) or changed + if external_user is not None: + changed = client.modify_if_diff(name, ipa_group.get('ipaexternalmember', []), external_user, + client.group_add_member_externaluser, + client.group_remove_member_externaluser, + append=append) or changed else: if ipa_group: changed = True @@ -256,6 +307,7 @@ def main(): argument_spec.update(cn=dict(type='str', required=True, aliases=['name']), description=dict(type='str'), external=dict(type='bool'), + external_user=dict(type='list', elements='str'), gidnumber=dict(type='str', aliases=['gid']), group=dict(type='list', elements='str'), nonposix=dict(type='bool'), From 3da24d50cdadfd4aa383800f72ca6dab22ee93f2 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sun, 29 Jan 2023 18:18:27 +0100 Subject: [PATCH 0145/1810] dig lookup: fix DNSKEY's algorithm handling (#5914) Fix DNSKEY's algorithm handling. --- changelogs/fragments/5914-dig-dnskey.yml | 2 ++ plugins/lookup/dig.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/5914-dig-dnskey.yml diff --git a/changelogs/fragments/5914-dig-dnskey.yml b/changelogs/fragments/5914-dig-dnskey.yml new file mode 100644 index 0000000000..d6a26388d2 --- /dev/null +++ b/changelogs/fragments/5914-dig-dnskey.yml @@ -0,0 +1,2 @@ +bugfixes: + - "dig lookup plugin - correctly handle DNSKEY record type's ``algorithm`` field (https://github.com/ansible-collections/community.general/pull/5914)." diff --git a/plugins/lookup/dig.py b/plugins/lookup/dig.py index ceaff15e9f..e8c6d86497 100644 --- a/plugins/lookup/dig.py +++ b/plugins/lookup/dig.py @@ -230,7 +230,7 @@ def make_rdata_dict(rdata): NSEC3PARAM: ['algorithm', 'flags', 'iterations', 'salt'], PTR: ['target'], RP: ['mbox', 'txt'], - # RRSIG: ['algorithm', 'labels', 'original_ttl', 'expiration', 'inception', 'signature'], + # RRSIG: ['type_covered', 'algorithm', 'labels', 'original_ttl', 'expiration', 'inception', 'key_tag', 'signer', 'signature'], SOA: ['mname', 'rname', 'serial', 'refresh', 'retry', 'expire', 'minimum'], SPF: ['strings'], SRV: ['priority', 'weight', 'port', 'target'], @@ -251,6 +251,8 @@ def make_rdata_dict(rdata): if rdata.rdtype == DS and f == 'digest': val = dns.rdata._hexify(rdata.digest).replace(' ', '') + if rdata.rdtype == DNSKEY and f == 'algorithm': + val = int(val) if rdata.rdtype == DNSKEY and f == 'key': val = dns.rdata._base64ify(rdata.key).replace(' ', '') if rdata.rdtype == NSEC3PARAM and f == 'salt': From 451c90251ad4b41e2f3b9a2c7e8bb557a1d5733f Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sun, 29 Jan 2023 18:19:14 +0100 Subject: [PATCH 0146/1810] dig lookup: support CAA record type (#5913) * Support CAA record type. * Update return docs. --- changelogs/fragments/5913-dig-caa.yml | 2 ++ plugins/lookup/dig.py | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/5913-dig-caa.yml diff --git a/changelogs/fragments/5913-dig-caa.yml b/changelogs/fragments/5913-dig-caa.yml new file mode 100644 index 0000000000..62ff698737 --- /dev/null +++ b/changelogs/fragments/5913-dig-caa.yml @@ -0,0 +1,2 @@ +minor_changes: + - "dig lookup plugin - support CAA record type (https://github.com/ansible-collections/community.general/pull/5913)." diff --git a/plugins/lookup/dig.py b/plugins/lookup/dig.py index e8c6d86497..d0d94e988a 100644 --- a/plugins/lookup/dig.py +++ b/plugins/lookup/dig.py @@ -35,9 +35,10 @@ DOCUMENTATION = ''' description: - Record type to query. - C(DLV) has been removed in community.general 6.0.0. + - C(CAA) has been added in community.general 6.3.0. type: str default: 'A' - choices: [A, ALL, AAAA, CNAME, DNAME, DNSKEY, DS, HINFO, LOC, MX, NAPTR, NS, NSEC3PARAM, PTR, RP, RRSIG, SOA, SPF, SRV, SSHFP, TLSA, TXT] + choices: [A, ALL, AAAA, CAA, CNAME, DNAME, DNSKEY, DS, HINFO, LOC, MX, NAPTR, NS, NSEC3PARAM, PTR, RP, RRSIG, SOA, SPF, SRV, SSHFP, TLSA, TXT] flat: description: If 0 each record is returned as a dictionary, otherwise a string. type: int @@ -129,6 +130,12 @@ RETURN = """ AAAA: description: - address + CAA: + description: + - flags + - tag + - value + version_added: 6.3.0 CNAME: description: - target @@ -198,7 +205,7 @@ try: import dns.resolver import dns.reversename import dns.rdataclass - from dns.rdatatype import (A, AAAA, CNAME, DNAME, DNSKEY, DS, HINFO, LOC, + from dns.rdatatype import (A, AAAA, CAA, CNAME, DNAME, DNSKEY, DS, HINFO, LOC, MX, NAPTR, NS, NSEC3PARAM, PTR, RP, SOA, SPF, SRV, SSHFP, TLSA, TXT) HAVE_DNS = True except ImportError: @@ -218,6 +225,7 @@ def make_rdata_dict(rdata): supported_types = { A: ['address'], AAAA: ['address'], + CAA: ['flags', 'tag', 'value'], CNAME: ['target'], DNAME: ['target'], DNSKEY: ['flags', 'algorithm', 'protocol', 'key'], From 393f2d615383e384002dd38cb123f423a6975907 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sun, 29 Jan 2023 22:12:27 +0100 Subject: [PATCH 0147/1810] Fix PLATFORM attributes docs fragment (#5918) Fix PLATFORM attributes docs fragment. --- plugins/doc_fragments/attributes.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/doc_fragments/attributes.py b/plugins/doc_fragments/attributes.py index e7ab495916..9b8488e0a5 100644 --- a/plugins/doc_fragments/attributes.py +++ b/plugins/doc_fragments/attributes.py @@ -21,6 +21,8 @@ attributes: ''' PLATFORM = r''' +options: {} +attributes: platform: description: Target OS/families that can be operated against. support: N/A From dcc3d4f50843b54aee82a44b059466149d692fa5 Mon Sep 17 00:00:00 2001 From: Renaud <33203203+redat00@users.noreply.github.com> Date: Mon, 30 Jan 2023 06:30:54 +0100 Subject: [PATCH 0148/1810] Add support for setenv parameters (#5883) --- ...doers-add-support-for-setenv-parameter.yml | 2 ++ plugins/modules/sudoers.py | 22 ++++++++++++++++++- .../targets/sudoers/tasks/main.yml | 16 +++++++++++++- 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/5883-sudoers-add-support-for-setenv-parameter.yml diff --git a/changelogs/fragments/5883-sudoers-add-support-for-setenv-parameter.yml b/changelogs/fragments/5883-sudoers-add-support-for-setenv-parameter.yml new file mode 100644 index 0000000000..f713428136 --- /dev/null +++ b/changelogs/fragments/5883-sudoers-add-support-for-setenv-parameter.yml @@ -0,0 +1,2 @@ +minor_changes: + - sudoers - add ``setenv`` parameters to support passing environment variables via sudo. (https://github.com/ansible-collections/community.general/pull/5883) diff --git a/plugins/modules/sudoers.py b/plugins/modules/sudoers.py index f2bcb20b75..fd29b189f0 100644 --- a/plugins/modules/sudoers.py +++ b/plugins/modules/sudoers.py @@ -43,6 +43,12 @@ options: - Whether a password will be required to run the sudo'd command. default: true type: bool + setenv: + description: + - Whether to allow keeping the environment when command is run with sudo. + default: false + type: bool + version_added: 6.3.0 host: description: - Specify the host the rule is for. @@ -123,6 +129,13 @@ EXAMPLES = ''' community.general.sudoers: name: alice-service state: absent + +- name: Allow alice to sudo /usr/local/bin/upload and keep env variables + community.general.sudoers: + name: allow-alice-upload + user: alice + commands: /usr/local/bin/upload + setenv: true ''' import os @@ -143,6 +156,7 @@ class Sudoers(object): self.group = module.params['group'] self.state = module.params['state'] self.nopassword = module.params['nopassword'] + self.setenv = module.params['setenv'] self.host = module.params['host'] self.runas = module.params['runas'] self.sudoers_path = module.params['sudoers_path'] @@ -185,12 +199,14 @@ class Sudoers(object): commands_str = ', '.join(self.commands) nopasswd_str = 'NOPASSWD:' if self.nopassword else '' + setenv_str = 'SETENV:' if self.setenv else '' runas_str = '({runas})'.format(runas=self.runas) if self.runas is not None else '' - return "{owner} {host}={runas}{nopasswd} {commands}\n".format( + return "{owner} {host}={runas}{nopasswd}{setenv} {commands}\n".format( owner=owner, host=self.host, runas=runas_str, nopasswd=nopasswd_str, + setenv=setenv_str, commands=commands_str ) @@ -239,6 +255,10 @@ def main(): 'type': 'bool', 'default': True, }, + 'setenv': { + 'type': 'bool', + 'default': False, + }, 'host': { 'type': 'str', 'default': 'ALL', diff --git a/tests/integration/targets/sudoers/tasks/main.yml b/tests/integration/targets/sudoers/tasks/main.yml index a44307ad9e..dd62025d5e 100644 --- a/tests/integration/targets/sudoers/tasks/main.yml +++ b/tests/integration/targets/sudoers/tasks/main.yml @@ -145,6 +145,20 @@ src: "{{ sudoers_path }}/my-sudo-rule-7" register: rule_7_contents +- name: Create rule with setenv parameters + community.general.sudoers: + name: my-sudo-rule-8 + state: present + user: alice + commands: /usr/local/bin/command + setenv: true + register: rule_8 + +- name: Grab contents of my-sudo-rule-8 + ansible.builtin.slurp: + src: "{{ sudoers_path }}/my-sudo-rule-8" + register: rule_8_contents + - name: Revoke rule 1 community.general.sudoers: name: my-sudo-rule-1 @@ -202,7 +216,6 @@ when: ansible_os_family != 'Darwin' register: edge_case_3 - - name: Revoke non-existing rule community.general.sudoers: name: non-existing-rule @@ -243,6 +256,7 @@ - "rule_5_contents['content'] | b64decode == 'alice ALL=NOPASSWD: /usr/local/bin/command\n'" - "rule_6_contents['content'] | b64decode == 'alice ALL=(bob)NOPASSWD: /usr/local/bin/command\n'" - "rule_7_contents['content'] | b64decode == 'alice host-1=NOPASSWD: /usr/local/bin/command\n'" + - "rule_8_contents['content'] | b64decode == 'alice ALL=NOPASSWD:SETENV: /usr/local/bin/command\n'" - name: Check revocation stat ansible.builtin.assert: From 31ff3f662d91fc36e453415ccb229282b479f96c Mon Sep 17 00:00:00 2001 From: cfiehe Date: Mon, 30 Jan 2023 21:03:13 +0100 Subject: [PATCH 0149/1810] Fixes #5907: gitlab_runner is not idempotent on first run after runner creation (#5908) This fix introduces the new boolean option 'access_level_on_creation'. It controls, whether the value of 'access_level' is used for runner registration or not. The option 'access_level' has been ignored on registration so far and was only used on updates. The user is informed by a deprecation warning, if the option is unspecified. For reasons of compatibility 'false' is assumed in that case. The option 'access_level_on_creation' will switch to 'true' for the next major release (community.general 7.0.0) Signed-off-by: Christoph Fiehe Co-authored-by: Christoph Fiehe --- .../5907-fix-gitlab_runner-not-idempotent.yml | 4 ++ plugins/modules/gitlab_runner.py | 53 +++++++++++++------ 2 files changed, 40 insertions(+), 17 deletions(-) create mode 100644 changelogs/fragments/5907-fix-gitlab_runner-not-idempotent.yml diff --git a/changelogs/fragments/5907-fix-gitlab_runner-not-idempotent.yml b/changelogs/fragments/5907-fix-gitlab_runner-not-idempotent.yml new file mode 100644 index 0000000000..a7386b8c73 --- /dev/null +++ b/changelogs/fragments/5907-fix-gitlab_runner-not-idempotent.yml @@ -0,0 +1,4 @@ +minor_changes: + - gitlab_runner - add new boolean option ``access_level_on_creation``. It controls, whether the value of ``access_level`` is used for runner registration or not. The option ``access_level`` has been ignored on registration so far and was only used on updates (https://github.com/ansible-collections/community.general/issues/5907, https://github.com/ansible-collections/community.general/pull/5908). +deprecated_features: + - gitlab_runner - the default of the new option ``access_level_on_creation`` will change from ``false`` to ``true`` in community.general 7.0.0. This will cause ``access_level`` to be used during runner registration as well, and not only during updates (https://github.com/ansible-collections/community.general/pull/5908). diff --git a/plugins/modules/gitlab_runner.py b/plugins/modules/gitlab_runner.py index 1094df9424..9d7c900cc5 100644 --- a/plugins/modules/gitlab_runner.py +++ b/plugins/modules/gitlab_runner.py @@ -84,12 +84,23 @@ options: access_level: description: - Determines if a runner can pick up jobs only from protected branches. + - If I(access_level_on_creation) is not explicitly set to C(true), this option is ignored on registration and + is only applied on updates. - If set to C(ref_protected), runner can pick up jobs only from protected branches. - If set to C(not_protected), runner can pick up jobs from both protected and unprotected branches. required: false default: ref_protected choices: ["ref_protected", "not_protected"] type: str + access_level_on_creation: + description: + - Whether the runner should be registered with an access level or not. + - If set to C(true), the value of I(access_level) is used for runner registration. + - If set to C(false), GitLab registers the runner with the default access level. + - The current default of this option is C(false). This default is deprecated and will change to C(true) in commuinty.general 7.0.0. + required: false + type: bool + version_added: 6.3.0 maximum_timeout: description: - The maximum time that a runner has to complete a specific job. @@ -207,27 +218,34 @@ class GitLabRunner(object): def create_or_update_runner(self, description, options): changed = False + arguments = { + 'active': options['active'], + 'locked': options['locked'], + 'run_untagged': options['run_untagged'], + 'maximum_timeout': options['maximum_timeout'], + 'tag_list': options['tag_list'], + } # Because we have already call userExists in main() if self.runner_object is None: - runner = self.create_runner({ - 'description': description, - 'active': options['active'], - 'token': options['registration_token'], - 'locked': options['locked'], - 'run_untagged': options['run_untagged'], - 'maximum_timeout': options['maximum_timeout'], - 'tag_list': options['tag_list'], - }) + arguments['description'] = description + arguments['token'] = options['registration_token'] + + access_level_on_creation = self._module.params['access_level_on_creation'] + if access_level_on_creation is None: + message = "The option 'access_level_on_creation' is unspecified, so 'false' is assumed. "\ + "That means any value of 'access_level' is ignored and GitLab registers the runner with its default value. "\ + "The option 'access_level_on_creation' will switch to 'true' in community.general 7.0.0" + self._module.deprecate(message, version='7.0.0', collection_name='community.general') + access_level_on_creation = False + + if access_level_on_creation: + arguments['access_level'] = options['access_level'] + + runner = self.create_runner(arguments) changed = True else: - changed, runner = self.update_runner(self.runner_object, { - 'active': options['active'], - 'locked': options['locked'], - 'run_untagged': options['run_untagged'], - 'maximum_timeout': options['maximum_timeout'], - 'access_level': options['access_level'], - 'tag_list': options['tag_list'], - }) + arguments['access_level'] = options['access_level'] + changed, runner = self.update_runner(self.runner_object, arguments) self.runner_object = runner if changed: @@ -328,6 +346,7 @@ def main(): run_untagged=dict(type='bool', default=True), locked=dict(type='bool', default=False), access_level=dict(type='str', default='ref_protected', choices=["not_protected", "ref_protected"]), + access_level_on_creation=dict(type='bool'), maximum_timeout=dict(type='int', default=3600), registration_token=dict(type='str', no_log=True), project=dict(type='str'), From ea5cbe2553716192c9a15f93532c286d1ddec1d1 Mon Sep 17 00:00:00 2001 From: Mike Raineri Date: Mon, 30 Jan 2023 15:05:22 -0500 Subject: [PATCH 0150/1810] Redfish: Removed basic auth header when performing a GET on the service root and POST to the session collection (#5903) * Redfish: Removed basic auth header when performing a GET on the service root and POST to the session collection * Update changelogs/fragments/5886-redfish-correct-basic-auth-usage-on-session-creation.yml Co-authored-by: Felix Fontein --------- Co-authored-by: Felix Fontein --- ...t-basic-auth-usage-on-session-creation.yml | 2 ++ plugins/module_utils/redfish_utils.py | 35 ++++++++++++------- 2 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 changelogs/fragments/5886-redfish-correct-basic-auth-usage-on-session-creation.yml diff --git a/changelogs/fragments/5886-redfish-correct-basic-auth-usage-on-session-creation.yml b/changelogs/fragments/5886-redfish-correct-basic-auth-usage-on-session-creation.yml new file mode 100644 index 0000000000..25ec0746a6 --- /dev/null +++ b/changelogs/fragments/5886-redfish-correct-basic-auth-usage-on-session-creation.yml @@ -0,0 +1,2 @@ +bugfixes: + - redfish_utils - removed basic auth HTTP header when performing a GET on the service root resource and when performing a POST to the session collection (https://github.com/ansible-collections/community.general/issues/5886). diff --git a/plugins/module_utils/redfish_utils.py b/plugins/module_utils/redfish_utils.py index 4a56346c3f..eadca28205 100644 --- a/plugins/module_utils/redfish_utils.py +++ b/plugins/module_utils/redfish_utils.py @@ -38,6 +38,8 @@ class RedfishUtils(object): self.timeout = timeout self.module = module self.service_root = '/redfish/v1/' + self.session_service_uri = '/redfish/v1/SessionService' + self.sessions_uri = '/redfish/v1/SessionService/Sessions' self.resource_id = resource_id self.data_modification = data_modification self.strip_etag_quotes = strip_etag_quotes @@ -125,6 +127,10 @@ class RedfishUtils(object): req_headers = dict(GET_HEADERS) username, password, basic_auth = self._auth_params(req_headers) try: + # Service root is an unauthenticated resource; remove credentials + # in case the caller will be using sessions later. + if uri == (self.root_uri + self.service_root): + basic_auth = False resp = open_url(uri, method="GET", headers=req_headers, url_username=username, url_password=password, force_basic_auth=basic_auth, validate_certs=False, @@ -151,6 +157,11 @@ class RedfishUtils(object): req_headers = dict(POST_HEADERS) username, password, basic_auth = self._auth_params(req_headers) try: + # When performing a POST to the session collection, credentials are + # provided in the request body. Do not provide the basic auth + # header since this can cause conflicts with some services + if self.sessions_uri is not None and uri == (self.root_uri + self.sessions_uri): + basic_auth = False resp = open_url(uri, data=json.dumps(pyld), headers=req_headers, method="POST", url_username=username, url_password=password, @@ -363,23 +374,23 @@ class RedfishUtils(object): return {'ret': True} def _find_sessionservice_resource(self): + # Get the service root response = self.get_request(self.root_uri + self.service_root) if response['ret'] is False: return response data = response['data'] - if 'SessionService' not in data: + + # Check for the session service and session collection. Well-known + # defaults are provided in the constructor, but services that predate + # Redfish 1.6.0 might contain different values. + self.session_service_uri = data.get('SessionService', {}).get('@odata.id') + self.sessions_uri = data.get('Links', {}).get('Sessions', {}).get('@odata.id') + + # If one isn't found, return an error + if self.session_service_uri is None: return {'ret': False, 'msg': "SessionService resource not found"} - else: - session_service = data["SessionService"]["@odata.id"] - self.session_service_uri = session_service - response = self.get_request(self.root_uri + session_service) - if response['ret'] is False: - return response - data = response['data'] - sessions = data['Sessions']['@odata.id'] - if sessions[-1:] == '/': - sessions = sessions[:-1] - self.sessions_uri = sessions + if self.sessions_uri is None: + return {'ret': False, 'msg': "SessionCollection resource not found"} return {'ret': True} def _get_resource_uri_by_id(self, uris, id_prop): From 84dbb286ebc26fcda1155eac5ca690faed7a5b56 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Tue, 31 Jan 2023 07:15:12 +0100 Subject: [PATCH 0151/1810] Fix changelog fragment types. --- changelogs/fragments/5811-clarify-bitwarden-error.yml | 2 +- changelogs/fragments/5888-update-key-title.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/changelogs/fragments/5811-clarify-bitwarden-error.yml b/changelogs/fragments/5811-clarify-bitwarden-error.yml index 343faba478..ee9a3c72b1 100644 --- a/changelogs/fragments/5811-clarify-bitwarden-error.yml +++ b/changelogs/fragments/5811-clarify-bitwarden-error.yml @@ -1,2 +1,2 @@ -minor_changes: +bugfixes: - bitwarden lookup plugin - clarify what to do, if the bitwarden vault is not unlocked (https://github.com/ansible-collections/community.general/pull/5811). diff --git a/changelogs/fragments/5888-update-key-title.yml b/changelogs/fragments/5888-update-key-title.yml index e620ad3d79..d98dcc4c17 100644 --- a/changelogs/fragments/5888-update-key-title.yml +++ b/changelogs/fragments/5888-update-key-title.yml @@ -1,2 +1,2 @@ -minor_changes: +bugfixes: - gitlab_deploy_key - also update ``title`` and not just ``can_push`` (https://github.com/ansible-collections/community.general/pull/5888). From 868699dc5f8ecfbf007681419dfe07b0c5db0ac2 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Tue, 31 Jan 2023 07:33:49 +0100 Subject: [PATCH 0152/1810] Next release will be 6.4.0. --- galaxy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/galaxy.yml b/galaxy.yml index 09c85cf2b8..b44b59bf5a 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -5,7 +5,7 @@ namespace: community name: general -version: 6.3.0 +version: 6.4.0 readme: README.md authors: - Ansible (https://github.com/ansible) From a64df658c5eb09621feffb2f6e4c6b0b14501c59 Mon Sep 17 00:00:00 2001 From: Lars Krahl <57526005+mmslkr@users.noreply.github.com> Date: Fri, 3 Feb 2023 11:02:14 +0100 Subject: [PATCH 0153/1810] Replace missing default favicon with docs.ansible.com favicon (#5928) * replace missing default favicon with docs.ansible.com * create changelog fragment for PR 5928 * move changelog fragment * fix parameter description Co-authored-by: Felix Fontein * fix parameter description Co-authored-by: Felix Fontein * add affected modules in changelog fragment Co-authored-by: Felix Fontein --------- Co-authored-by: Lars Krahl Co-authored-by: Felix Fontein --- changelogs/fragments/5928-fix-favicon-url.yml | 2 ++ plugins/modules/mattermost.py | 6 +++--- plugins/modules/rocketchat.py | 4 ++-- plugins/modules/slack.py | 6 +++--- tests/unit/plugins/modules/test_slack.py | 2 +- 5 files changed, 11 insertions(+), 9 deletions(-) create mode 100644 changelogs/fragments/5928-fix-favicon-url.yml diff --git a/changelogs/fragments/5928-fix-favicon-url.yml b/changelogs/fragments/5928-fix-favicon-url.yml new file mode 100644 index 0000000000..eccb9f4a0f --- /dev/null +++ b/changelogs/fragments/5928-fix-favicon-url.yml @@ -0,0 +1,2 @@ +minor_changes: + - mattermost, rocketchat, slack - replace missing default favicon with docs.ansible.com favicon (https://github.com/ansible-collections/community.general/pull/5928). diff --git a/plugins/modules/mattermost.py b/plugins/modules/mattermost.py index af6666b3cd..b3fe6b5680 100644 --- a/plugins/modules/mattermost.py +++ b/plugins/modules/mattermost.py @@ -60,8 +60,8 @@ options: icon_url: type: str description: - - Url for the message sender's icon. - default: https://www.ansible.com/favicon.ico + - URL for the message sender's icon. + default: https://docs.ansible.com/favicon.ico validate_certs: description: - If C(false), SSL certificates will not be validated. This should only be used @@ -127,7 +127,7 @@ def main(): text=dict(type='str'), channel=dict(type='str', default=None), username=dict(type='str', default='Ansible'), - icon_url=dict(type='str', default='https://www.ansible.com/favicon.ico'), + icon_url=dict(type='str', default='https://docs.ansible.com/favicon.ico'), validate_certs=dict(default=True, type='bool'), attachments=dict(type='list', elements='dict'), ), diff --git a/plugins/modules/rocketchat.py b/plugins/modules/rocketchat.py index 153567e22a..02458ed232 100644 --- a/plugins/modules/rocketchat.py +++ b/plugins/modules/rocketchat.py @@ -58,7 +58,7 @@ options: type: str description: - URL for the message sender's icon. - default: "https://www.ansible.com/favicon.ico" + default: "https://docs.ansible.com/favicon.ico" icon_emoji: type: str description: @@ -212,7 +212,7 @@ def main(): msg=dict(type='str', required=False), channel=dict(type='str'), username=dict(type='str', default='Ansible'), - icon_url=dict(type='str', default='https://www.ansible.com/favicon.ico'), + icon_url=dict(type='str', default='https://docs.ansible.com/favicon.ico'), icon_emoji=dict(type='str'), link_names=dict(type='int', default=1, choices=[0, 1]), validate_certs=dict(default=True, type='bool'), diff --git a/plugins/modules/slack.py b/plugins/modules/slack.py index 2854277f60..c1ae865cde 100644 --- a/plugins/modules/slack.py +++ b/plugins/modules/slack.py @@ -81,8 +81,8 @@ options: icon_url: type: str description: - - Url for the message sender's icon (default C(https://www.ansible.com/favicon.ico)) - default: https://www.ansible.com/favicon.ico + - URL for the message sender's icon (default C(https://docs.ansible.com/favicon.ico)) + default: https://docs.ansible.com/favicon.ico icon_emoji: type: str description: @@ -439,7 +439,7 @@ def main(): channel=dict(type='str'), thread_id=dict(type='str'), username=dict(type='str', default='Ansible'), - icon_url=dict(type='str', default='https://www.ansible.com/favicon.ico'), + icon_url=dict(type='str', default='https://docs.ansible.com/favicon.ico'), icon_emoji=dict(type='str'), link_names=dict(type='int', default=1, choices=[0, 1]), parse=dict(type='str', choices=['none', 'full']), diff --git a/tests/unit/plugins/modules/test_slack.py b/tests/unit/plugins/modules/test_slack.py index 352d3f4b94..ab4405baa7 100644 --- a/tests/unit/plugins/modules/test_slack.py +++ b/tests/unit/plugins/modules/test_slack.py @@ -142,7 +142,7 @@ class TestSlackModule(ModuleTestCase): }, 'accessory': { 'type': 'image', - 'image_url': 'https://www.ansible.com/favicon.ico', + 'image_url': 'https://docs.ansible.com/favicon.ico', 'alt_text': 'test' } }, { From b1d9507cd2986cc2f3e9d918a56477ef2eba3d1f Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 4 Feb 2023 17:05:08 +0100 Subject: [PATCH 0154/1810] Fix pylint errors (#5933) * Fix pylint errors. * Also adjust to https://github.com/ansible/ansible/pull/79909. --- changelogs/fragments/5933-linting.yml | 2 ++ plugins/modules/gconftool2.py | 4 ++-- plugins/modules/pritunl_org.py | 2 +- plugins/modules/pritunl_org_info.py | 2 +- plugins/modules/pritunl_user.py | 2 +- plugins/modules/pritunl_user_info.py | 2 +- plugins/modules/terraform.py | 2 +- plugins/modules/timezone.py | 1 + plugins/modules/xfconf.py | 4 ++-- 9 files changed, 12 insertions(+), 9 deletions(-) create mode 100644 changelogs/fragments/5933-linting.yml diff --git a/changelogs/fragments/5933-linting.yml b/changelogs/fragments/5933-linting.yml new file mode 100644 index 0000000000..d0c46542bf --- /dev/null +++ b/changelogs/fragments/5933-linting.yml @@ -0,0 +1,2 @@ +bugfixes: + - "terraform and timezone - slight refactoring to avoid linter reporting potentially undefined variables (https://github.com/ansible-collections/community.general/pull/5933)." diff --git a/plugins/modules/gconftool2.py b/plugins/modules/gconftool2.py index a3ac8bb8f1..788aed3423 100644 --- a/plugins/modules/gconftool2.py +++ b/plugins/modules/gconftool2.py @@ -88,8 +88,8 @@ from ansible_collections.community.general.plugins.module_utils.gconftool2 impor class GConftool(StateModuleHelper): - change_params = 'value', - diff_params = 'value', + change_params = ('value', ) + diff_params = ('value', ) output_params = ('key', 'value_type') facts_params = ('key', 'value_type') facts_name = 'gconftool2' diff --git a/plugins/modules/pritunl_org.py b/plugins/modules/pritunl_org.py index 75c3564f24..4a6a8a3444 100644 --- a/plugins/modules/pritunl_org.py +++ b/plugins/modules/pritunl_org.py @@ -181,7 +181,7 @@ def main(): required=False, choices=["present", "absent"], default="present" ), ) - ), + ) module = AnsibleModule(argument_spec=argument_spec) diff --git a/plugins/modules/pritunl_org_info.py b/plugins/modules/pritunl_org_info.py index 7f3974e0e5..979e29b5a0 100644 --- a/plugins/modules/pritunl_org_info.py +++ b/plugins/modules/pritunl_org_info.py @@ -118,7 +118,7 @@ def main(): dict( organization=dict(required=False, type="str", default=None, aliases=["org"]) ) - ), + ) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) diff --git a/plugins/modules/pritunl_user.py b/plugins/modules/pritunl_user.py index 817d6fb3f6..f3feb94eed 100644 --- a/plugins/modules/pritunl_user.py +++ b/plugins/modules/pritunl_user.py @@ -336,7 +336,7 @@ def main(): user_gravatar=dict(required=False, type="bool", default=None), user_mac_addresses=dict(required=False, type="list", elements="str", default=None), ) - ), + ) module = AnsibleModule(argument_spec=argument_spec) diff --git a/plugins/modules/pritunl_user_info.py b/plugins/modules/pritunl_user_info.py index d4c68ca6e0..7b0399061f 100644 --- a/plugins/modules/pritunl_user_info.py +++ b/plugins/modules/pritunl_user_info.py @@ -160,7 +160,7 @@ def main(): default="client", ), ) - ), + ) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) diff --git a/plugins/modules/terraform.py b/plugins/modules/terraform.py index b6b09b0eb2..9d1cc2ed02 100644 --- a/plugins/modules/terraform.py +++ b/plugins/modules/terraform.py @@ -628,9 +628,9 @@ def main(): outputs_command = [command[0], 'output', '-no-color', '-json'] + _state_args(state_file) rc, outputs_text, outputs_err = module.run_command(outputs_command, cwd=project_path) + outputs = {} if rc == 1: module.warn("Could not get Terraform outputs. This usually means none have been defined.\nstdout: {0}\nstderr: {1}".format(outputs_text, outputs_err)) - outputs = {} elif rc != 0: module.fail_json( msg="Failure when getting Terraform outputs. " diff --git a/plugins/modules/timezone.py b/plugins/modules/timezone.py index 9e89462089..20404d3a79 100644 --- a/plugins/modules/timezone.py +++ b/plugins/modules/timezone.py @@ -356,6 +356,7 @@ class NosystemdTimezone(Timezone): def __init__(self, module): super(NosystemdTimezone, self).__init__(module) # Validate given timezone + planned_tz = '' if 'name' in self.value: tzfile = self._verify_timezone() planned_tz = self.value['name']['planned'] diff --git a/plugins/modules/xfconf.py b/plugins/modules/xfconf.py index ec00763ee1..0fff6f0d14 100644 --- a/plugins/modules/xfconf.py +++ b/plugins/modules/xfconf.py @@ -169,8 +169,8 @@ from ansible_collections.community.general.plugins.module_utils.xfconf import xf class XFConfProperty(StateModuleHelper): - change_params = 'value', - diff_params = 'value', + change_params = ('value', ) + diff_params = ('value', ) output_params = ('property', 'channel', 'value') module = dict( argument_spec=dict( From de193ac1bf1c2336d8b9e465e28093cb20bb14c1 Mon Sep 17 00:00:00 2001 From: cfiehe Date: Fri, 10 Feb 2023 13:54:24 +0100 Subject: [PATCH 0155/1810] Align 'gitlab_runner' with GitLab's default access level. (#5930) Signed-off-by: Christoph Fiehe Co-authored-by: Christoph Fiehe --- ...unner_access_level_default_with_gitlab.yml | 2 ++ plugins/modules/gitlab_runner.py | 27 ++++++++++++++----- 2 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 changelogs/fragments/5925-align_gitlab_runner_access_level_default_with_gitlab.yml diff --git a/changelogs/fragments/5925-align_gitlab_runner_access_level_default_with_gitlab.yml b/changelogs/fragments/5925-align_gitlab_runner_access_level_default_with_gitlab.yml new file mode 100644 index 0000000000..a14561f07e --- /dev/null +++ b/changelogs/fragments/5925-align_gitlab_runner_access_level_default_with_gitlab.yml @@ -0,0 +1,2 @@ +deprecated_features: + - gitlab_runner - the option ``access_level`` will lose its default value in community.general 8.0.0. From that version on, you have set this option to ``ref_protected`` explicitly, if you want to have a protected runner (https://github.com/ansible-collections/community.general/issues/5925). diff --git a/plugins/modules/gitlab_runner.py b/plugins/modules/gitlab_runner.py index 9d7c900cc5..e0ef43a316 100644 --- a/plugins/modules/gitlab_runner.py +++ b/plugins/modules/gitlab_runner.py @@ -86,11 +86,13 @@ options: - Determines if a runner can pick up jobs only from protected branches. - If I(access_level_on_creation) is not explicitly set to C(true), this option is ignored on registration and is only applied on updates. - - If set to C(ref_protected), runner can pick up jobs only from protected branches. - If set to C(not_protected), runner can pick up jobs from both protected and unprotected branches. + - If set to C(ref_protected), runner can pick up jobs only from protected branches. + - The current default is C(ref_protected). This will change to no default in community.general 8.0.0. + From that version on, if this option is not specified explicitly, GitLab will use C(not_protected) + on creation, and the value set will not be changed on any updates. required: false - default: ref_protected - choices: ["ref_protected", "not_protected"] + choices: ["not_protected", "ref_protected"] type: str access_level_on_creation: description: @@ -225,6 +227,9 @@ class GitLabRunner(object): 'maximum_timeout': options['maximum_timeout'], 'tag_list': options['tag_list'], } + if arguments['access_level'] is not None: + arguments['access_level'] = options['access_level'] + # Because we have already call userExists in main() if self.runner_object is None: arguments['description'] = description @@ -238,13 +243,12 @@ class GitLabRunner(object): self._module.deprecate(message, version='7.0.0', collection_name='community.general') access_level_on_creation = False - if access_level_on_creation: - arguments['access_level'] = options['access_level'] + if not access_level_on_creation: + del arguments['access_level'] runner = self.create_runner(arguments) changed = True else: - arguments['access_level'] = options['access_level'] changed, runner = self.update_runner(self.runner_object, arguments) self.runner_object = runner @@ -345,7 +349,7 @@ def main(): tag_list=dict(type='list', elements='str', default=[]), run_untagged=dict(type='bool', default=True), locked=dict(type='bool', default=False), - access_level=dict(type='str', default='ref_protected', choices=["not_protected", "ref_protected"]), + access_level=dict(type='str', choices=["not_protected", "ref_protected"]), access_level_on_creation=dict(type='bool'), maximum_timeout=dict(type='int', default=3600), registration_token=dict(type='str', no_log=True), @@ -387,6 +391,15 @@ def main(): registration_token = module.params['registration_token'] project = module.params['project'] + if access_level is None: + message = "The option 'access_level' is unspecified, so 'ref_protected' is assumed. "\ + "In order to align the module with GitLab's runner API, this option will lose "\ + "its default value in community.general 8.0.0. From that version on, you must set "\ + "this option to 'ref_protected' explicitly, if you want to have a protected runner, "\ + "otherwise GitLab's default access level gets applied, which is 'not_protected'" + module.deprecate(message, version='8.0.0', collection_name='community.general') + access_level = 'ref_protected' + gitlab_instance = gitlab_authentication(module) gitlab_project = None if project: From 2b8ac3c6292570e257c3aed9fc2d2550ccf736b1 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sun, 12 Feb 2023 19:48:39 +0100 Subject: [PATCH 0156/1810] Remove unneccessary imports (#5940) * Remove unneccessary imports. * Keep unnecessary imports in module_utils - for now. * Make older sanity tests shut up. * Also make flake8 happier. --- changelogs/fragments/remove-unneeded-imports.yml | 2 ++ plugins/cache/memcached.py | 2 -- plugins/cache/redis.py | 2 -- plugins/callback/counter_enabled.py | 1 - plugins/callback/diy.py | 4 ---- plugins/callback/loganalytics.py | 1 - plugins/callback/mail.py | 1 - plugins/callback/nrdp.py | 3 --- plugins/callback/syslog_json.py | 3 --- plugins/callback/yaml.py | 6 ++---- plugins/filter/jc.py | 6 +++--- plugins/filter/lists_mergeby.py | 2 -- plugins/inventory/linode.py | 5 +---- plugins/inventory/lxd.py | 2 -- plugins/inventory/online.py | 2 +- plugins/lookup/consul_kv.py | 1 - plugins/lookup/credstash.py | 2 -- plugins/lookup/cyberarkpassword.py | 1 - plugins/lookup/etcd3.py | 5 ++--- plugins/lookup/hiera.py | 2 -- plugins/lookup/manifold.py | 1 - plugins/lookup/redis.py | 2 -- plugins/module_utils/dimensiondata.py | 7 ++++--- plugins/module_utils/influxdb.py | 4 ++-- plugins/module_utils/mh/module_helper.py | 3 ++- plugins/module_utils/module_helper.py | 15 ++++++++------- plugins/module_utils/oneview.py | 3 ++- plugins/module_utils/oracle/oci_utils.py | 5 +++-- plugins/module_utils/proxmox.py | 12 ++++++++---- plugins/module_utils/pure.py | 8 +++++--- plugins/module_utils/version.py | 4 ++-- plugins/modules/gitlab_project_variable.py | 2 +- plugins/modules/jenkins_plugin.py | 1 - plugins/modules/keycloak_authentication.py | 2 +- plugins/modules/keycloak_client_rolemapping.py | 5 +++-- plugins/modules/keycloak_clientscope.py | 2 +- plugins/modules/keycloak_user_rolemapping.py | 4 ++-- plugins/modules/lxc_container.py | 2 +- plugins/modules/macports.py | 1 - plugins/modules/manageiq_policies_info.py | 2 +- plugins/modules/mas.py | 1 - plugins/modules/memset_zone_record.py | 1 - plugins/modules/mksysb.py | 4 ---- plugins/modules/ocapi_command.py | 2 +- plugins/modules/ocapi_info.py | 2 +- plugins/modules/packet_device.py | 2 -- plugins/modules/scaleway_compute.py | 1 - plugins/modules/scaleway_container.py | 2 +- plugins/modules/scaleway_container_info.py | 2 +- plugins/modules/scaleway_container_namespace.py | 2 +- .../modules/scaleway_container_namespace_info.py | 2 +- plugins/modules/scaleway_container_registry.py | 2 +- .../modules/scaleway_container_registry_info.py | 2 +- plugins/modules/scaleway_function.py | 2 +- plugins/modules/scaleway_function_info.py | 2 +- plugins/modules/scaleway_function_namespace.py | 2 +- .../modules/scaleway_function_namespace_info.py | 2 +- plugins/modules/scaleway_security_group_rule.py | 3 +-- plugins/modules/xenserver_guest_info.py | 4 ++-- plugins/modules/xenserver_guest_powerstate.py | 4 ++-- 60 files changed, 74 insertions(+), 108 deletions(-) create mode 100644 changelogs/fragments/remove-unneeded-imports.yml diff --git a/changelogs/fragments/remove-unneeded-imports.yml b/changelogs/fragments/remove-unneeded-imports.yml new file mode 100644 index 0000000000..a5fed1d93e --- /dev/null +++ b/changelogs/fragments/remove-unneeded-imports.yml @@ -0,0 +1,2 @@ +bugfixes: + - "various plugins and modules - remove unnecessary imports (https://github.com/ansible-collections/community.general/pull/5940)." diff --git a/plugins/cache/memcached.py b/plugins/cache/memcached.py index 77f1717e45..0bc5256b3f 100644 --- a/plugins/cache/memcached.py +++ b/plugins/cache/memcached.py @@ -52,11 +52,9 @@ import time from multiprocessing import Lock from itertools import chain -from ansible import constants as C from ansible.errors import AnsibleError from ansible.module_utils.common._collections_compat import MutableSet from ansible.plugins.cache import BaseCacheModule -from ansible.release import __version__ as ansible_base_version from ansible.utils.display import Display try: diff --git a/plugins/cache/redis.py b/plugins/cache/redis.py index 81e960cf18..8c06217176 100644 --- a/plugins/cache/redis.py +++ b/plugins/cache/redis.py @@ -67,12 +67,10 @@ import re import time import json -from ansible import constants as C from ansible.errors import AnsibleError from ansible.module_utils.common.text.converters import to_native from ansible.parsing.ajson import AnsibleJSONEncoder, AnsibleJSONDecoder from ansible.plugins.cache import BaseCacheModule -from ansible.release import __version__ as ansible_base_version from ansible.utils.display import Display try: diff --git a/plugins/callback/counter_enabled.py b/plugins/callback/counter_enabled.py index 555ebd29a6..27adc97a6c 100644 --- a/plugins/callback/counter_enabled.py +++ b/plugins/callback/counter_enabled.py @@ -27,7 +27,6 @@ DOCUMENTATION = ''' from ansible import constants as C from ansible.plugins.callback import CallbackBase from ansible.utils.color import colorize, hostcolor -from ansible.template import Templar from ansible.playbook.task_include import TaskInclude diff --git a/plugins/callback/diy.py b/plugins/callback/diy.py index 55a07725f2..75b3f4e24b 100644 --- a/plugins/callback/diy.py +++ b/plugins/callback/diy.py @@ -786,10 +786,6 @@ playbook.yml: > import sys from contextlib import contextmanager -from ansible import constants as C -from ansible.playbook.task_include import TaskInclude -from ansible.plugins.callback import CallbackBase -from ansible.utils.color import colorize, hostcolor from ansible.template import Templar from ansible.vars.manager import VariableManager from ansible.plugins.callback.default import CallbackModule as Default diff --git a/plugins/callback/loganalytics.py b/plugins/callback/loganalytics.py index 8690aac934..fbcdc6f89f 100644 --- a/plugins/callback/loganalytics.py +++ b/plugins/callback/loganalytics.py @@ -54,7 +54,6 @@ examples: | import hashlib import hmac import base64 -import logging import json import uuid import socket diff --git a/plugins/callback/mail.py b/plugins/callback/mail.py index a605d13eac..9e8314baf8 100644 --- a/plugins/callback/mail.py +++ b/plugins/callback/mail.py @@ -79,7 +79,6 @@ import re import email.utils import smtplib -from ansible.module_utils.six import string_types from ansible.module_utils.common.text.converters import to_bytes from ansible.parsing.ajson import AnsibleJSONEncoder from ansible.plugins.callback import CallbackBase diff --git a/plugins/callback/nrdp.py b/plugins/callback/nrdp.py index 8295bf9759..c16a3c7bec 100644 --- a/plugins/callback/nrdp.py +++ b/plugins/callback/nrdp.py @@ -67,9 +67,6 @@ DOCUMENTATION = ''' type: string ''' -import os -import json - from ansible.module_utils.six.moves.urllib.parse import urlencode from ansible.module_utils.common.text.converters import to_bytes from ansible.module_utils.urls import open_url diff --git a/plugins/callback/syslog_json.py b/plugins/callback/syslog_json.py index 2bd8f6e604..0f5ec4d0d9 100644 --- a/plugins/callback/syslog_json.py +++ b/plugins/callback/syslog_json.py @@ -54,9 +54,6 @@ DOCUMENTATION = ''' version_added: 4.5.0 ''' -import os -import json - import logging import logging.handlers diff --git a/plugins/callback/yaml.py b/plugins/callback/yaml.py index 73782de151..ae2c8f8810 100644 --- a/plugins/callback/yaml.py +++ b/plugins/callback/yaml.py @@ -25,12 +25,10 @@ import yaml import json import re import string -import sys -from ansible.module_utils.common.text.converters import to_bytes, to_text -from ansible.module_utils.six import string_types +from ansible.module_utils.common.text.converters import to_text from ansible.parsing.yaml.dumper import AnsibleDumper -from ansible.plugins.callback import CallbackBase, strip_internal_keys, module_response_deepcopy +from ansible.plugins.callback import strip_internal_keys, module_response_deepcopy from ansible.plugins.callback.default import CallbackModule as Default diff --git a/plugins/filter/jc.py b/plugins/filter/jc.py index 6708f573d3..742d4147a1 100644 --- a/plugins/filter/jc.py +++ b/plugins/filter/jc.py @@ -80,13 +80,13 @@ from ansible.errors import AnsibleError, AnsibleFilterError import importlib try: - import jc + import jc # noqa: F401, pylint: disable=unused-import HAS_LIB = True except ImportError: HAS_LIB = False -def jc(data, parser, quiet=True, raw=False): +def jc_filter(data, parser, quiet=True, raw=False): """Convert returned command output to JSON using the JC library Arguments: @@ -150,5 +150,5 @@ class FilterModule(object): def filters(self): return { - 'jc': jc + 'jc': jc_filter, } diff --git a/plugins/filter/lists_mergeby.py b/plugins/filter/lists_mergeby.py index a89039ed89..036dfe4d7c 100644 --- a/plugins/filter/lists_mergeby.py +++ b/plugins/filter/lists_mergeby.py @@ -102,8 +102,6 @@ from ansible.errors import AnsibleFilterError from ansible.module_utils.six import string_types from ansible.module_utils.common._collections_compat import Mapping, Sequence from ansible.utils.vars import merge_hash -from ansible.release import __version__ as ansible_version -from ansible_collections.community.general.plugins.module_utils.version import LooseVersion from collections import defaultdict from operator import itemgetter diff --git a/plugins/inventory/linode.py b/plugins/inventory/linode.py index ea87a9a58e..b28cfa27ba 100644 --- a/plugins/inventory/linode.py +++ b/plugins/inventory/linode.py @@ -121,10 +121,7 @@ compose: ansible_host: "ipv4 | community.general.json_query('[?public==`false`].address') | first" ''' -import os - -from ansible.errors import AnsibleError, AnsibleParserError -from ansible.module_utils.six import string_types +from ansible.errors import AnsibleError from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable diff --git a/plugins/inventory/lxd.py b/plugins/inventory/lxd.py index 2e37de70c1..bd0a6ce008 100644 --- a/plugins/inventory/lxd.py +++ b/plugins/inventory/lxd.py @@ -150,12 +150,10 @@ groupby: attribute: internals ''' -import binascii import json import re import time import os -import socket from ansible.plugins.inventory import BaseInventoryPlugin from ansible.module_utils.common.text.converters import to_native, to_text from ansible.module_utils.common.dict_transformations import dict_merge diff --git a/plugins/inventory/online.py b/plugins/inventory/online.py index 261548d8a2..3fccd58d2f 100644 --- a/plugins/inventory/online.py +++ b/plugins/inventory/online.py @@ -65,7 +65,7 @@ from sys import version as python_version from ansible.errors import AnsibleError from ansible.module_utils.urls import open_url from ansible.plugins.inventory import BaseInventoryPlugin -from ansible.module_utils.common.text.converters import to_native, to_text +from ansible.module_utils.common.text.converters import to_text from ansible.module_utils.ansible_release import __version__ as ansible_version from ansible.module_utils.six.moves.urllib.parse import urljoin diff --git a/plugins/lookup/consul_kv.py b/plugins/lookup/consul_kv.py index 2d4a202d94..f17f1b2694 100644 --- a/plugins/lookup/consul_kv.py +++ b/plugins/lookup/consul_kv.py @@ -105,7 +105,6 @@ RETURN = """ type: dict """ -import os from ansible.module_utils.six.moves.urllib.parse import urlparse from ansible.errors import AnsibleError, AnsibleAssertionError from ansible.plugins.lookup import LookupBase diff --git a/plugins/lookup/credstash.py b/plugins/lookup/credstash.py index d49d5b23cb..6a3f58595b 100644 --- a/plugins/lookup/credstash.py +++ b/plugins/lookup/credstash.py @@ -93,8 +93,6 @@ RETURN = """ type: str """ -import os - from ansible.errors import AnsibleError from ansible.plugins.lookup import LookupBase diff --git a/plugins/lookup/cyberarkpassword.py b/plugins/lookup/cyberarkpassword.py index 1e005e23e8..c3cc427df8 100644 --- a/plugins/lookup/cyberarkpassword.py +++ b/plugins/lookup/cyberarkpassword.py @@ -80,7 +80,6 @@ from subprocess import Popen from ansible.errors import AnsibleError from ansible.plugins.lookup import LookupBase -from ansible.parsing.splitter import parse_kv from ansible.module_utils.common.text.converters import to_bytes, to_text, to_native from ansible.utils.display import Display diff --git a/plugins/lookup/etcd3.py b/plugins/lookup/etcd3.py index df41d791e8..7f0a0cf90e 100644 --- a/plugins/lookup/etcd3.py +++ b/plugins/lookup/etcd3.py @@ -136,12 +136,11 @@ RETURN = ''' import re -from ansible.plugins.lookup import LookupBase -from ansible.utils.display import Display +from ansible.errors import AnsibleLookupError from ansible.module_utils.basic import missing_required_lib from ansible.module_utils.common.text.converters import to_native from ansible.plugins.lookup import LookupBase -from ansible.errors import AnsibleError, AnsibleLookupError +from ansible.utils.display import Display try: import etcd3 diff --git a/plugins/lookup/hiera.py b/plugins/lookup/hiera.py index 1049e80b02..fa4d0a1999 100644 --- a/plugins/lookup/hiera.py +++ b/plugins/lookup/hiera.py @@ -61,8 +61,6 @@ RETURN = """ elements: str """ -import os - from ansible.plugins.lookup import LookupBase from ansible.utils.cmd_functions import run_cmd from ansible.module_utils.common.text.converters import to_text diff --git a/plugins/lookup/manifold.py b/plugins/lookup/manifold.py index 51064b9c2b..049d453e4f 100644 --- a/plugins/lookup/manifold.py +++ b/plugins/lookup/manifold.py @@ -69,7 +69,6 @@ from ansible.utils.display import Display from traceback import format_exception import json import sys -import os display = Display() diff --git a/plugins/lookup/redis.py b/plugins/lookup/redis.py index 490751a398..43b046a798 100644 --- a/plugins/lookup/redis.py +++ b/plugins/lookup/redis.py @@ -73,8 +73,6 @@ _raw: elements: str """ -import os - HAVE_REDIS = False try: import redis diff --git a/plugins/module_utils/dimensiondata.py b/plugins/module_utils/dimensiondata.py index 308615bfe4..0300f6c1e9 100644 --- a/plugins/module_utils/dimensiondata.py +++ b/plugins/module_utils/dimensiondata.py @@ -19,15 +19,16 @@ import os import re import traceback -from ansible.module_utils.basic import AnsibleModule, missing_required_lib +# (TODO: remove AnsibleModule from next line!) +from ansible.module_utils.basic import AnsibleModule, missing_required_lib # noqa: F401, pylint: disable=unused-import from ansible.module_utils.six.moves import configparser from os.path import expanduser from uuid import UUID LIBCLOUD_IMP_ERR = None try: - from libcloud.common.dimensiondata import API_ENDPOINTS, DimensionDataAPIException, DimensionDataStatus - from libcloud.compute.base import Node, NodeLocation + from libcloud.common.dimensiondata import API_ENDPOINTS, DimensionDataAPIException, DimensionDataStatus # noqa: F401, pylint: disable=unused-import + from libcloud.compute.base import Node, NodeLocation # noqa: F401, pylint: disable=unused-import from libcloud.compute.providers import get_driver from libcloud.compute.types import Provider diff --git a/plugins/module_utils/influxdb.py b/plugins/module_utils/influxdb.py index 9a30e76428..580cabe7d5 100644 --- a/plugins/module_utils/influxdb.py +++ b/plugins/module_utils/influxdb.py @@ -15,7 +15,7 @@ from ansible_collections.community.general.plugins.module_utils.version import L REQUESTS_IMP_ERR = None try: - import requests.exceptions + import requests.exceptions # noqa: F401, pylint: disable=unused-import HAS_REQUESTS = True except ImportError: REQUESTS_IMP_ERR = traceback.format_exc() @@ -25,7 +25,7 @@ INFLUXDB_IMP_ERR = None try: from influxdb import InfluxDBClient from influxdb import __version__ as influxdb_version - from influxdb import exceptions + from influxdb import exceptions # noqa: F401, pylint: disable=unused-import HAS_INFLUXDB = True except ImportError: INFLUXDB_IMP_ERR = traceback.format_exc() diff --git a/plugins/module_utils/mh/module_helper.py b/plugins/module_utils/mh/module_helper.py index 6813b5454b..212ebb48fe 100644 --- a/plugins/module_utils/mh/module_helper.py +++ b/plugins/module_utils/mh/module_helper.py @@ -9,7 +9,8 @@ __metaclass__ = type from ansible.module_utils.common.dict_transformations import dict_merge -from ansible_collections.community.general.plugins.module_utils.mh.base import ModuleHelperBase, AnsibleModule +# (TODO: remove AnsibleModule!) pylint: disable-next-line=unused-import +from ansible_collections.community.general.plugins.module_utils.mh.base import ModuleHelperBase, AnsibleModule # noqa: F401 from ansible_collections.community.general.plugins.module_utils.mh.mixins.cmd import CmdMixin from ansible_collections.community.general.plugins.module_utils.mh.mixins.state import StateMixin from ansible_collections.community.general.plugins.module_utils.mh.mixins.deps import DependencyMixin diff --git a/plugins/module_utils/module_helper.py b/plugins/module_utils/module_helper.py index 4cda4175c7..ec7f1b1b78 100644 --- a/plugins/module_utils/module_helper.py +++ b/plugins/module_utils/module_helper.py @@ -8,12 +8,13 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type -from ansible_collections.community.general.plugins.module_utils.mh.module_helper import ( +from ansible_collections.community.general.plugins.module_utils.mh.module_helper import ( # noqa: F401, pylint: disable=unused-import ModuleHelper, StateModuleHelper, CmdModuleHelper, CmdStateModuleHelper, AnsibleModule ) -from ansible_collections.community.general.plugins.module_utils.mh.mixins.cmd import CmdMixin, ArgFormat -from ansible_collections.community.general.plugins.module_utils.mh.mixins.state import StateMixin -from ansible_collections.community.general.plugins.module_utils.mh.mixins.deps import DependencyCtxMgr -from ansible_collections.community.general.plugins.module_utils.mh.exceptions import ModuleHelperException -from ansible_collections.community.general.plugins.module_utils.mh.deco import cause_changes, module_fails_on_exception -from ansible_collections.community.general.plugins.module_utils.mh.mixins.vars import VarMeta, VarDict +from ansible_collections.community.general.plugins.module_utils.mh.mixins.cmd import CmdMixin, ArgFormat # noqa: F401, pylint: disable=unused-import +from ansible_collections.community.general.plugins.module_utils.mh.mixins.state import StateMixin # noqa: F401, pylint: disable=unused-import +from ansible_collections.community.general.plugins.module_utils.mh.mixins.deps import DependencyCtxMgr # noqa: F401, pylint: disable=unused-import +from ansible_collections.community.general.plugins.module_utils.mh.exceptions import ModuleHelperException # noqa: F401, pylint: disable=unused-import +# pylint: disable-next-line=unused-import +from ansible_collections.community.general.plugins.module_utils.mh.deco import cause_changes, module_fails_on_exception # noqa: F401 +from ansible_collections.community.general.plugins.module_utils.mh.mixins.vars import VarMeta, VarDict # noqa: F401, pylint: disable=unused-import diff --git a/plugins/module_utils/oneview.py b/plugins/module_utils/oneview.py index dfd00c514e..4315a462dc 100644 --- a/plugins/module_utils/oneview.py +++ b/plugins/module_utils/oneview.py @@ -16,7 +16,8 @@ __metaclass__ = type import abc import collections import json -import os +# (TODO: remove next line!) +import os # noqa: F401, pylint: disable=unused-import import traceback HPE_ONEVIEW_IMP_ERR = None diff --git a/plugins/module_utils/oracle/oci_utils.py b/plugins/module_utils/oracle/oci_utils.py index 76fb45324b..3d9c20f2ac 100644 --- a/plugins/module_utils/oracle/oci_utils.py +++ b/plugins/module_utils/oracle/oci_utils.py @@ -10,13 +10,14 @@ import logging import logging.config import os import tempfile -from datetime import datetime +# (TODO: remove next line!) +from datetime import datetime # noqa: F401, pylint: disable=unused-import from operator import eq import time try: - import yaml + import yaml # noqa: F401, pylint: disable=unused-import import oci from oci.constants import HEADER_NEXT_PAGE diff --git a/plugins/module_utils/proxmox.py b/plugins/module_utils/proxmox.py index 96a96c8b3c..58287cec17 100644 --- a/plugins/module_utils/proxmox.py +++ b/plugins/module_utils/proxmox.py @@ -7,9 +7,12 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type -import atexit -import time -import re +# (TODO: remove next line!) +import atexit # noqa: F401, pylint: disable=unused-import +# (TODO: remove next line!) +import time # noqa: F401, pylint: disable=unused-import +# (TODO: remove next line!) +import re # noqa: F401, pylint: disable=unused-import import traceback PROXMOXER_IMP_ERR = None @@ -22,7 +25,8 @@ except ImportError: from ansible.module_utils.basic import env_fallback, missing_required_lib -from ansible.module_utils.common.text.converters import to_native +# (TODO: remove next line!) +from ansible.module_utils.common.text.converters import to_native # noqa: F401, pylint: disable=unused-import from ansible_collections.community.general.plugins.module_utils.version import LooseVersion diff --git a/plugins/module_utils/pure.py b/plugins/module_utils/pure.py index c9914c38b5..8210e28f4d 100644 --- a/plugins/module_utils/pure.py +++ b/plugins/module_utils/pure.py @@ -21,13 +21,15 @@ except ImportError: HAS_PURITY_FB = True try: - from purity_fb import PurityFb, FileSystem, FileSystemSnapshot, SnapshotSuffix, rest + from purity_fb import PurityFb, FileSystem, FileSystemSnapshot, SnapshotSuffix, rest # noqa: F401, pylint: disable=unused-import except ImportError: HAS_PURITY_FB = False -from functools import wraps +# (TODO: remove next line!) +from functools import wraps # noqa: F401, pylint: disable=unused-import from os import environ -from os import path +# (TODO: remove next line!) +from os import path # noqa: F401, pylint: disable=unused-import import platform VERSION = 1.2 diff --git a/plugins/module_utils/version.py b/plugins/module_utils/version.py index b671e59628..3699881978 100644 --- a/plugins/module_utils/version.py +++ b/plugins/module_utils/version.py @@ -13,10 +13,10 @@ __metaclass__ = type from ansible.module_utils.six import raise_from try: - from ansible.module_utils.compat.version import LooseVersion + from ansible.module_utils.compat.version import LooseVersion # noqa: F401, pylint: disable=unused-import except ImportError: try: - from distutils.version import LooseVersion + from distutils.version import LooseVersion # noqa: F401, pylint: disable=unused-import except ImportError as exc: msg = 'To use this plugin or module with ansible-core 2.11, you need to use Python < 3.12 with distutils.version present' raise_from(ImportError(msg), exc) diff --git a/plugins/modules/gitlab_project_variable.py b/plugins/modules/gitlab_project_variable.py index 986847c07b..5e6a2904dc 100644 --- a/plugins/modules/gitlab_project_variable.py +++ b/plugins/modules/gitlab_project_variable.py @@ -182,7 +182,7 @@ from ansible.module_utils.six import integer_types GITLAB_IMP_ERR = None try: - import gitlab + import gitlab # noqa: F401, pylint: disable=unused-import HAS_GITLAB_PACKAGE = True except Exception: GITLAB_IMP_ERR = traceback.format_exc() diff --git a/plugins/modules/jenkins_plugin.py b/plugins/modules/jenkins_plugin.py index c4e1b7fb66..9c4c42e675 100644 --- a/plugins/modules/jenkins_plugin.py +++ b/plugins/modules/jenkins_plugin.py @@ -295,7 +295,6 @@ import io import json import os import tempfile -import time from ansible.module_utils.basic import AnsibleModule, to_bytes from ansible.module_utils.six.moves import http_cookiejar as cookiejar diff --git a/plugins/modules/keycloak_authentication.py b/plugins/modules/keycloak_authentication.py index 4f56582951..5ec53f9d8c 100644 --- a/plugins/modules/keycloak_authentication.py +++ b/plugins/modules/keycloak_authentication.py @@ -206,7 +206,7 @@ end_state: ''' from ansible_collections.community.general.plugins.module_utils.identity.keycloak.keycloak \ - import KeycloakAPI, camel, keycloak_argument_spec, get_token, KeycloakError, is_struct_included + import KeycloakAPI, keycloak_argument_spec, get_token, KeycloakError, is_struct_included from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/keycloak_client_rolemapping.py b/plugins/modules/keycloak_client_rolemapping.py index f0da97ef59..efb9e77cf7 100644 --- a/plugins/modules/keycloak_client_rolemapping.py +++ b/plugins/modules/keycloak_client_rolemapping.py @@ -201,8 +201,9 @@ end_state: } ''' -from ansible_collections.community.general.plugins.module_utils.identity.keycloak.keycloak import KeycloakAPI, camel, \ - keycloak_argument_spec, get_token, KeycloakError, is_struct_included +from ansible_collections.community.general.plugins.module_utils.identity.keycloak.keycloak import ( + KeycloakAPI, keycloak_argument_spec, get_token, KeycloakError, +) from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/keycloak_clientscope.py b/plugins/modules/keycloak_clientscope.py index 0ac6836f7b..1bba8ba77d 100644 --- a/plugins/modules/keycloak_clientscope.py +++ b/plugins/modules/keycloak_clientscope.py @@ -295,7 +295,7 @@ end_state: ''' from ansible_collections.community.general.plugins.module_utils.identity.keycloak.keycloak import KeycloakAPI, camel, \ - keycloak_argument_spec, get_token, KeycloakError, is_struct_included + keycloak_argument_spec, get_token, KeycloakError from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/keycloak_user_rolemapping.py b/plugins/modules/keycloak_user_rolemapping.py index 72d403c637..9e909716ac 100644 --- a/plugins/modules/keycloak_user_rolemapping.py +++ b/plugins/modules/keycloak_user_rolemapping.py @@ -225,8 +225,8 @@ end_state: } ''' -from ansible_collections.community.general.plugins.module_utils.identity.keycloak.keycloak import KeycloakAPI, camel, \ - keycloak_argument_spec, get_token, KeycloakError, is_struct_included +from ansible_collections.community.general.plugins.module_utils.identity.keycloak.keycloak import KeycloakAPI, \ + keycloak_argument_spec, get_token, KeycloakError from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/lxc_container.py b/plugins/modules/lxc_container.py index 9fe27b8d81..4e7f43419a 100644 --- a/plugins/modules/lxc_container.py +++ b/plugins/modules/lxc_container.py @@ -433,7 +433,7 @@ else: HAS_LXC = True from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.parsing.convert_bool import boolean, BOOLEANS_FALSE +from ansible.module_utils.parsing.convert_bool import BOOLEANS_FALSE from ansible.module_utils.common.text.converters import to_text, to_bytes diff --git a/plugins/modules/macports.py b/plugins/modules/macports.py index 398a5552e0..7bf5c4f532 100644 --- a/plugins/modules/macports.py +++ b/plugins/modules/macports.py @@ -99,7 +99,6 @@ EXAMPLES = ''' import re from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.six.moves import shlex_quote def selfupdate(module, port_path): diff --git a/plugins/modules/manageiq_policies_info.py b/plugins/modules/manageiq_policies_info.py index c10ee95327..8a75ef6464 100644 --- a/plugins/modules/manageiq_policies_info.py +++ b/plugins/modules/manageiq_policies_info.py @@ -81,7 +81,7 @@ profiles: ''' from ansible.module_utils.basic import AnsibleModule -from ansible_collections.community.general.plugins.module_utils.manageiq import ManageIQ, ManageIQPolicies, manageiq_argument_spec, manageiq_entities +from ansible_collections.community.general.plugins.module_utils.manageiq import ManageIQ, manageiq_argument_spec, manageiq_entities def main(): diff --git a/plugins/modules/mas.py b/plugins/modules/mas.py index 49faa53d9d..af77110da7 100644 --- a/plugins/modules/mas.py +++ b/plugins/modules/mas.py @@ -97,7 +97,6 @@ EXAMPLES = ''' RETURN = r''' # ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.common.text.converters import to_native import os from ansible_collections.community.general.plugins.module_utils.version import LooseVersion diff --git a/plugins/modules/memset_zone_record.py b/plugins/modules/memset_zone_record.py index 925a034c56..16a1c3a742 100644 --- a/plugins/modules/memset_zone_record.py +++ b/plugins/modules/memset_zone_record.py @@ -166,7 +166,6 @@ memset_api: from ansible.module_utils.basic import AnsibleModule from ansible_collections.community.general.plugins.module_utils.memset import get_zone_id from ansible_collections.community.general.plugins.module_utils.memset import memset_api_call -from ansible_collections.community.general.plugins.module_utils.memset import get_zone_id def api_validation(args=None): diff --git a/plugins/modules/mksysb.py b/plugins/modules/mksysb.py index 15b6ad9442..39f3e6a1c4 100644 --- a/plugins/modules/mksysb.py +++ b/plugins/modules/mksysb.py @@ -101,10 +101,6 @@ import os from ansible_collections.community.general.plugins.module_utils.cmd_runner import CmdRunner, cmd_runner_fmt from ansible_collections.community.general.plugins.module_utils.module_helper import ModuleHelper -from ansible_collections.community.general.plugins.module_utils.module_helper import ( - ArgFormat -) - class MkSysB(ModuleHelper): module = dict( diff --git a/plugins/modules/ocapi_command.py b/plugins/modules/ocapi_command.py index 7d8fca8064..73c0e22bd5 100644 --- a/plugins/modules/ocapi_command.py +++ b/plugins/modules/ocapi_command.py @@ -165,7 +165,7 @@ operationStatusId: from ansible.module_utils.basic import AnsibleModule from ansible_collections.community.general.plugins.module_utils.ocapi_utils import OcapiUtils from ansible.module_utils.common.text.converters import to_native -from ansible.module_utils.six.moves.urllib.parse import quote_plus, urljoin +from ansible.module_utils.six.moves.urllib.parse import urljoin # More will be added as module features are expanded CATEGORY_COMMANDS_ALL = { diff --git a/plugins/modules/ocapi_info.py b/plugins/modules/ocapi_info.py index c827b4522d..2cb7a3afca 100644 --- a/plugins/modules/ocapi_info.py +++ b/plugins/modules/ocapi_info.py @@ -141,7 +141,7 @@ status: from ansible.module_utils.basic import AnsibleModule from ansible_collections.community.general.plugins.module_utils.ocapi_utils import OcapiUtils from ansible.module_utils.common.text.converters import to_native -from ansible.module_utils.six.moves.urllib.parse import quote_plus, urljoin +from ansible.module_utils.six.moves.urllib.parse import urljoin # More will be added as module features are expanded CATEGORY_COMMANDS_ALL = { diff --git a/plugins/modules/packet_device.py b/plugins/modules/packet_device.py index 500a400273..a2c2d1d653 100644 --- a/plugins/modules/packet_device.py +++ b/plugins/modules/packet_device.py @@ -292,8 +292,6 @@ try: except ImportError: HAS_PACKET_SDK = False -from ansible.module_utils.basic import AnsibleModule - NAME_RE = r'({0}|{0}{1}*{0})'.format(r'[a-zA-Z0-9]', r'[a-zA-Z0-9\-]') HOSTNAME_RE = r'({0}\.)*{0}$'.format(NAME_RE) diff --git a/plugins/modules/scaleway_compute.py b/plugins/modules/scaleway_compute.py index 3acdc8bd77..0da3f0ff24 100644 --- a/plugins/modules/scaleway_compute.py +++ b/plugins/modules/scaleway_compute.py @@ -177,7 +177,6 @@ import datetime import time from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.six.moves.urllib.parse import quote as urlquote from ansible_collections.community.general.plugins.module_utils.scaleway import SCALEWAY_LOCATION, scaleway_argument_spec, Scaleway SCALEWAY_SERVER_STATES = ( diff --git a/plugins/modules/scaleway_container.py b/plugins/modules/scaleway_container.py index 6bc237ee39..85e746e1f5 100644 --- a/plugins/modules/scaleway_container.py +++ b/plugins/modules/scaleway_container.py @@ -200,7 +200,7 @@ container: from copy import deepcopy from ansible_collections.community.general.plugins.module_utils.scaleway import ( - SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, + SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, scaleway_waitable_resource_argument_spec, resource_attributes_should_be_changed, SecretVariables ) diff --git a/plugins/modules/scaleway_container_info.py b/plugins/modules/scaleway_container_info.py index 993919c7ee..670c63a0bc 100644 --- a/plugins/modules/scaleway_container_info.py +++ b/plugins/modules/scaleway_container_info.py @@ -89,7 +89,7 @@ container: ''' from ansible_collections.community.general.plugins.module_utils.scaleway import ( - SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway + SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, ) from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/scaleway_container_namespace.py b/plugins/modules/scaleway_container_namespace.py index 4cfde73542..e7bf7c71f1 100644 --- a/plugins/modules/scaleway_container_namespace.py +++ b/plugins/modules/scaleway_container_namespace.py @@ -126,7 +126,7 @@ container_namespace: from copy import deepcopy from ansible_collections.community.general.plugins.module_utils.scaleway import ( - SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, + SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, scaleway_waitable_resource_argument_spec, resource_attributes_should_be_changed, SecretVariables ) diff --git a/plugins/modules/scaleway_container_namespace_info.py b/plugins/modules/scaleway_container_namespace_info.py index fea2d8474b..758720dd57 100644 --- a/plugins/modules/scaleway_container_namespace_info.py +++ b/plugins/modules/scaleway_container_namespace_info.py @@ -81,7 +81,7 @@ container_namespace: ''' from ansible_collections.community.general.plugins.module_utils.scaleway import ( - SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway + SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, ) from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/scaleway_container_registry.py b/plugins/modules/scaleway_container_registry.py index 294be2cb4c..f49b19917a 100644 --- a/plugins/modules/scaleway_container_registry.py +++ b/plugins/modules/scaleway_container_registry.py @@ -113,7 +113,7 @@ container_registry: ''' from ansible_collections.community.general.plugins.module_utils.scaleway import ( - SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, + SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, scaleway_waitable_resource_argument_spec, resource_attributes_should_be_changed ) from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/scaleway_container_registry_info.py b/plugins/modules/scaleway_container_registry_info.py index c0682cefbe..9c641edcbb 100644 --- a/plugins/modules/scaleway_container_registry_info.py +++ b/plugins/modules/scaleway_container_registry_info.py @@ -80,7 +80,7 @@ container_registry: ''' from ansible_collections.community.general.plugins.module_utils.scaleway import ( - SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway + SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, ) from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/scaleway_function.py b/plugins/modules/scaleway_function.py index b54091c6ab..5e7ac2a3d1 100644 --- a/plugins/modules/scaleway_function.py +++ b/plugins/modules/scaleway_function.py @@ -184,7 +184,7 @@ function: from copy import deepcopy from ansible_collections.community.general.plugins.module_utils.scaleway import ( - SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, + SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, scaleway_waitable_resource_argument_spec, resource_attributes_should_be_changed, SecretVariables ) diff --git a/plugins/modules/scaleway_function_info.py b/plugins/modules/scaleway_function_info.py index 14a4cd6289..c30f0cdb00 100644 --- a/plugins/modules/scaleway_function_info.py +++ b/plugins/modules/scaleway_function_info.py @@ -89,7 +89,7 @@ function: ''' from ansible_collections.community.general.plugins.module_utils.scaleway import ( - SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway + SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway ) from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/scaleway_function_namespace.py b/plugins/modules/scaleway_function_namespace.py index cae4c5ede5..243bb7124c 100644 --- a/plugins/modules/scaleway_function_namespace.py +++ b/plugins/modules/scaleway_function_namespace.py @@ -126,7 +126,7 @@ function_namespace: from copy import deepcopy from ansible_collections.community.general.plugins.module_utils.scaleway import ( - SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, + SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, scaleway_waitable_resource_argument_spec, resource_attributes_should_be_changed, SecretVariables ) diff --git a/plugins/modules/scaleway_function_namespace_info.py b/plugins/modules/scaleway_function_namespace_info.py index bb0b7fa9df..f3ea5ddfc8 100644 --- a/plugins/modules/scaleway_function_namespace_info.py +++ b/plugins/modules/scaleway_function_namespace_info.py @@ -81,7 +81,7 @@ function_namespace: ''' from ansible_collections.community.general.plugins.module_utils.scaleway import ( - SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway + SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, ) from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/scaleway_security_group_rule.py b/plugins/modules/scaleway_security_group_rule.py index cd27543a7b..52e69868cc 100644 --- a/plugins/modules/scaleway_security_group_rule.py +++ b/plugins/modules/scaleway_security_group_rule.py @@ -133,11 +133,10 @@ data: import traceback from ansible_collections.community.general.plugins.module_utils.scaleway import SCALEWAY_LOCATION, scaleway_argument_spec, Scaleway, payload_from_object -from ansible.module_utils.common.text.converters import to_text from ansible.module_utils.basic import AnsibleModule, missing_required_lib try: - from ipaddress import ip_network + from ipaddress import ip_network # noqa: F401, pylint: disable=unused-import except ImportError: IPADDRESS_IMP_ERR = traceback.format_exc() HAS_IPADDRESS = False diff --git a/plugins/modules/xenserver_guest_info.py b/plugins/modules/xenserver_guest_info.py index 5cdd52fc56..dd28cf7d07 100644 --- a/plugins/modules/xenserver_guest_info.py +++ b/plugins/modules/xenserver_guest_info.py @@ -153,13 +153,13 @@ instance: HAS_XENAPI = False try: - import XenAPI + import XenAPI # noqa: F401, pylint: disable=unused-import HAS_XENAPI = True except ImportError: pass from ansible.module_utils.basic import AnsibleModule -from ansible_collections.community.general.plugins.module_utils.xenserver import (xenserver_common_argument_spec, XAPI, XenServerObject, get_object_ref, +from ansible_collections.community.general.plugins.module_utils.xenserver import (xenserver_common_argument_spec, XenServerObject, get_object_ref, gather_vm_params, gather_vm_facts) diff --git a/plugins/modules/xenserver_guest_powerstate.py b/plugins/modules/xenserver_guest_powerstate.py index 7903ad8b9f..2bb7264875 100644 --- a/plugins/modules/xenserver_guest_powerstate.py +++ b/plugins/modules/xenserver_guest_powerstate.py @@ -173,13 +173,13 @@ instance: HAS_XENAPI = False try: - import XenAPI + import XenAPI # noqa: F401, pylint: disable=unused-import HAS_XENAPI = True except ImportError: pass from ansible.module_utils.basic import AnsibleModule -from ansible_collections.community.general.plugins.module_utils.xenserver import (xenserver_common_argument_spec, XAPI, XenServerObject, get_object_ref, +from ansible_collections.community.general.plugins.module_utils.xenserver import (xenserver_common_argument_spec, XenServerObject, get_object_ref, gather_vm_params, gather_vm_facts, set_vm_power_state, wait_for_vm_ip_address) From 9f87989e7ff629e53f0324d60f404ae2c3f77ac4 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sun, 12 Feb 2023 21:05:08 +0100 Subject: [PATCH 0157/1810] Remove unnecessary test imports (#5978) Remove unnecessary test imports. --- .../targets/module_helper/library/mdepfail.py | 2 +- .../module_helper/library/msimpleda.py | 5 +-- tests/sanity/extra/aliases.py | 1 - tests/sanity/extra/botmeta.py | 3 +- tests/unit/compat/builtins.py | 2 +- tests/unit/compat/mock.py | 4 +-- tests/unit/compat/unittest.py | 4 +-- tests/unit/plugins/become/helper.py | 1 - tests/unit/plugins/cache/test_redis.py | 1 - .../plugins/callback/test_loganalytics.py | 2 +- .../plugins/callback/test_opentelemetry.py | 2 +- tests/unit/plugins/callback/test_splunk.py | 2 +- tests/unit/plugins/connection/test_lxc.py | 1 - tests/unit/plugins/filter/test_crc32.py | 1 - tests/unit/plugins/inventory/test_cobbler.py | 2 -- tests/unit/plugins/inventory/test_linode.py | 2 +- tests/unit/plugins/inventory/test_lxd.py | 2 -- .../plugins/inventory/test_xen_orchestra.py | 1 - tests/unit/plugins/lookup/test_bitwarden.py | 4 +-- tests/unit/plugins/lookup/test_etcd3.py | 2 -- tests/unit/plugins/lookup/test_lastpass.py | 2 +- tests/unit/plugins/lookup/test_manifold.py | 2 +- .../module_utils/cloud/test_scaleway.py | 2 -- .../module_utils/test_module_helper.py | 6 ++-- .../plugins/module_utils/test_opennebula.py | 1 - tests/unit/plugins/modules/hpe_test_utils.py | 1 - .../plugins/modules/oneview_module_loader.py | 32 +++++++++++-------- tests/unit/plugins/modules/rhn_conftest.py | 1 - .../plugins/modules/test_alerta_customer.py | 2 +- tests/unit/plugins/modules/test_discord.py | 2 +- .../unit/plugins/modules/test_github_repo.py | 1 - .../modules/test_gitlab_protected_branch.py | 2 +- .../modules/test_keycloak_authentication.py | 4 +-- .../plugins/modules/test_keycloak_client.py | 5 ++- .../test_keycloak_client_rolemapping.py | 4 +-- .../modules/test_keycloak_clientscope.py | 5 ++- .../test_keycloak_identity_provider.py | 4 +-- .../plugins/modules/test_keycloak_realm.py | 4 +-- .../modules/test_keycloak_realm_info.py | 2 +- .../plugins/modules/test_keycloak_role.py | 4 +-- .../modules/test_keycloak_user_federation.py | 4 +-- tests/unit/plugins/modules/test_linode.py | 2 +- tests/unit/plugins/modules/test_linode_v4.py | 2 +- tests/unit/plugins/modules/test_lxca_nodes.py | 2 -- tests/unit/plugins/modules/test_macports.py | 1 - tests/unit/plugins/modules/test_npm.py | 3 +- .../plugins/modules/test_ocapi_command.py | 2 +- tests/unit/plugins/modules/test_one_vm.py | 2 -- .../modules/test_oneview_datacenter_info.py | 2 +- .../modules/test_oneview_enclosure_info.py | 1 - .../modules/test_oneview_ethernet_network.py | 1 - .../test_oneview_ethernet_network_info.py | 1 - .../modules/test_oneview_fc_network.py | 1 - .../modules/test_oneview_fc_network_info.py | 1 - .../modules/test_oneview_fcoe_network.py | 1 - .../modules/test_oneview_fcoe_network_info.py | 1 - ...test_oneview_logical_interconnect_group.py | 1 - ...oneview_logical_interconnect_group_info.py | 1 - .../modules/test_oneview_network_set.py | 1 - .../modules/test_oneview_network_set_info.py | 1 - .../modules/test_oneview_san_manager.py | 1 - .../modules/test_oneview_san_manager_info.py | 1 - tests/unit/plugins/modules/test_pacman.py | 6 +--- .../modules/test_proxmox_tasks_info.py | 7 +--- .../plugins/modules/test_redis_data_incr.py | 2 +- .../unit/plugins/modules/test_rhn_channel.py | 2 +- .../unit/plugins/modules/test_rhn_register.py | 2 +- tests/unit/plugins/modules/test_statsd.py | 2 -- .../modules/test_xcc_redfish_command.py | 3 -- .../modules/test_xenserver_guest_info.py | 2 +- .../test_xenserver_guest_powerstate.py | 2 +- 71 files changed, 70 insertions(+), 121 deletions(-) diff --git a/tests/integration/targets/module_helper/library/mdepfail.py b/tests/integration/targets/module_helper/library/mdepfail.py index d48727980a..92ebbde6e8 100644 --- a/tests/integration/targets/module_helper/library/mdepfail.py +++ b/tests/integration/targets/module_helper/library/mdepfail.py @@ -34,7 +34,7 @@ from ansible_collections.community.general.plugins.module_utils.module_helper im from ansible.module_utils.basic import missing_required_lib with ModuleHelper.dependency("nopackagewiththisname", missing_required_lib("nopackagewiththisname")): - import nopackagewiththisname + import nopackagewiththisname # noqa: F401, pylint: disable=unused-import class MSimple(ModuleHelper): diff --git a/tests/integration/targets/module_helper/library/msimpleda.py b/tests/integration/targets/module_helper/library/msimpleda.py index 74ec4ba010..c21c3d2ea4 100644 --- a/tests/integration/targets/module_helper/library/msimpleda.py +++ b/tests/integration/targets/module_helper/library/msimpleda.py @@ -6,7 +6,6 @@ # SPDX-License-Identifier: GPL-3.0-or-later from __future__ import absolute_import, division, print_function -import collections __metaclass__ = type DOCUMENTATION = ''' @@ -26,7 +25,9 @@ EXAMPLES = "" RETURN = "" from ansible_collections.community.general.plugins.module_utils.module_helper import ModuleHelper -from ansible_collections.community.general.plugins.module_utils.mh.mixins.deprecate_attrs import DeprecateAttrsMixin +from ansible_collections.community.general.plugins.module_utils.mh.mixins.deprecate_attrs import ( # noqa: F401, pylint: disable=unused-import + DeprecateAttrsMixin +) class MSimpleDA(ModuleHelper): diff --git a/tests/sanity/extra/aliases.py b/tests/sanity/extra/aliases.py index 8779fec513..c1dcba0df5 100755 --- a/tests/sanity/extra/aliases.py +++ b/tests/sanity/extra/aliases.py @@ -6,7 +6,6 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -import os import sys import yaml diff --git a/tests/sanity/extra/botmeta.py b/tests/sanity/extra/botmeta.py index c6d677ae5e..3b6c348344 100755 --- a/tests/sanity/extra/botmeta.py +++ b/tests/sanity/extra/botmeta.py @@ -13,8 +13,7 @@ import sys import yaml -from voluptuous import All, Any, MultipleInvalid, PREVENT_EXTRA -from voluptuous import Required, Schema, Invalid +from voluptuous import Any, MultipleInvalid, PREVENT_EXTRA, Schema from voluptuous.humanize import humanize_error diff --git a/tests/unit/compat/builtins.py b/tests/unit/compat/builtins.py index b0cc618676..d548601d46 100644 --- a/tests/unit/compat/builtins.py +++ b/tests/unit/compat/builtins.py @@ -13,7 +13,7 @@ __metaclass__ = type # One unittest needs to import builtins via __import__() so we need to have # the string that represents it try: - import __builtin__ + import __builtin__ # noqa: F401, pylint: disable=unused-import except ImportError: BUILTINS = 'builtins' else: diff --git a/tests/unit/compat/mock.py b/tests/unit/compat/mock.py index f8f565dcf3..bdbea945e6 100644 --- a/tests/unit/compat/mock.py +++ b/tests/unit/compat/mock.py @@ -20,12 +20,12 @@ try: # Allow wildcard import because we really do want to import all of mock's # symbols into this compat shim # pylint: disable=wildcard-import,unused-wildcard-import - from unittest.mock import * + from unittest.mock import * # noqa: F401, pylint: disable=unused-import except ImportError: # Python 2 # pylint: disable=wildcard-import,unused-wildcard-import try: - from mock import * + from mock import * # noqa: F401, pylint: disable=unused-import except ImportError: print('You need the mock library installed on python2.x to run tests') diff --git a/tests/unit/compat/unittest.py b/tests/unit/compat/unittest.py index 1872e58337..d50bab86f0 100644 --- a/tests/unit/compat/unittest.py +++ b/tests/unit/compat/unittest.py @@ -18,8 +18,8 @@ import sys if sys.version_info < (2, 7): try: # Need unittest2 on python2.6 - from unittest2 import * + from unittest2 import * # noqa: F401, pylint: disable=unused-import except ImportError: print('You need unittest2 installed on python2.6.x to run tests') else: - from unittest import * + from unittest import * # noqa: F401, pylint: disable=unused-import diff --git a/tests/unit/plugins/become/helper.py b/tests/unit/plugins/become/helper.py index 410738504b..9949e1befb 100644 --- a/tests/unit/plugins/become/helper.py +++ b/tests/unit/plugins/become/helper.py @@ -8,7 +8,6 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -from ansible.errors import AnsibleError from ansible.plugins.loader import become_loader, get_shell_plugin diff --git a/tests/unit/plugins/cache/test_redis.py b/tests/unit/plugins/cache/test_redis.py index 26f97c127e..81ae9293e3 100644 --- a/tests/unit/plugins/cache/test_redis.py +++ b/tests/unit/plugins/cache/test_redis.py @@ -10,7 +10,6 @@ import pytest pytest.importorskip('redis') -from ansible import constants as C from ansible.plugins.loader import cache_loader from ansible_collections.community.general.plugins.cache.redis import CacheModule as RedisCache diff --git a/tests/unit/plugins/callback/test_loganalytics.py b/tests/unit/plugins/callback/test_loganalytics.py index a61ad32d3a..f9fef3c5d6 100644 --- a/tests/unit/plugins/callback/test_loganalytics.py +++ b/tests/unit/plugins/callback/test_loganalytics.py @@ -7,7 +7,7 @@ __metaclass__ = type from ansible.executor.task_result import TaskResult from ansible_collections.community.general.tests.unit.compat import unittest -from ansible_collections.community.general.tests.unit.compat.mock import patch, call, MagicMock, Mock +from ansible_collections.community.general.tests.unit.compat.mock import patch, Mock from ansible_collections.community.general.plugins.callback.loganalytics import AzureLogAnalyticsSource from datetime import datetime diff --git a/tests/unit/plugins/callback/test_opentelemetry.py b/tests/unit/plugins/callback/test_opentelemetry.py index c6532bc2e5..dea2e29d41 100644 --- a/tests/unit/plugins/callback/test_opentelemetry.py +++ b/tests/unit/plugins/callback/test_opentelemetry.py @@ -10,7 +10,7 @@ from ansible.playbook.task import Task from ansible.executor.task_result import TaskResult from ansible_collections.community.general.tests.unit.compat import unittest from ansible_collections.community.general.tests.unit.compat.mock import patch, MagicMock, Mock -from ansible_collections.community.general.plugins.callback.opentelemetry import OpenTelemetrySource, TaskData, CallbackModule +from ansible_collections.community.general.plugins.callback.opentelemetry import OpenTelemetrySource, TaskData from collections import OrderedDict import sys diff --git a/tests/unit/plugins/callback/test_splunk.py b/tests/unit/plugins/callback/test_splunk.py index 595d1530b6..ddcdae24c7 100644 --- a/tests/unit/plugins/callback/test_splunk.py +++ b/tests/unit/plugins/callback/test_splunk.py @@ -7,7 +7,7 @@ __metaclass__ = type from ansible.executor.task_result import TaskResult from ansible_collections.community.general.tests.unit.compat import unittest -from ansible_collections.community.general.tests.unit.compat.mock import patch, call, MagicMock, Mock +from ansible_collections.community.general.tests.unit.compat.mock import patch, Mock from ansible_collections.community.general.plugins.callback.splunk import SplunkHTTPCollectorSource from datetime import datetime diff --git a/tests/unit/plugins/connection/test_lxc.py b/tests/unit/plugins/connection/test_lxc.py index 4a1139d6e9..8733a92e09 100644 --- a/tests/unit/plugins/connection/test_lxc.py +++ b/tests/unit/plugins/connection/test_lxc.py @@ -7,7 +7,6 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type from io import StringIO -import pytest from ansible_collections.community.general.tests.unit.compat import unittest from ansible_collections.community.general.plugins.connection import lxc diff --git a/tests/unit/plugins/filter/test_crc32.py b/tests/unit/plugins/filter/test_crc32.py index 961840235d..8201045136 100644 --- a/tests/unit/plugins/filter/test_crc32.py +++ b/tests/unit/plugins/filter/test_crc32.py @@ -7,7 +7,6 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type from ansible_collections.community.general.tests.unit.compat import unittest -from ansible.errors import AnsibleError from ansible_collections.community.general.plugins.filter.crc32 import crc32s diff --git a/tests/unit/plugins/inventory/test_cobbler.py b/tests/unit/plugins/inventory/test_cobbler.py index 6db9b91cbc..a09001ad62 100644 --- a/tests/unit/plugins/inventory/test_cobbler.py +++ b/tests/unit/plugins/inventory/test_cobbler.py @@ -7,9 +7,7 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type import pytest -import sys -from ansible.errors import AnsibleError, AnsibleParserError from ansible_collections.community.general.plugins.inventory.cobbler import InventoryModule diff --git a/tests/unit/plugins/inventory/test_linode.py b/tests/unit/plugins/inventory/test_linode.py index 4e6a018850..a4f556761d 100644 --- a/tests/unit/plugins/inventory/test_linode.py +++ b/tests/unit/plugins/inventory/test_linode.py @@ -16,7 +16,7 @@ mandatory_py_version = pytest.mark.skipif( ) -from ansible.errors import AnsibleError, AnsibleParserError +from ansible.errors import AnsibleError from ansible.parsing.dataloader import DataLoader from ansible.template import Templar from ansible_collections.community.general.plugins.inventory.linode import InventoryModule diff --git a/tests/unit/plugins/inventory/test_lxd.py b/tests/unit/plugins/inventory/test_lxd.py index 99c9e166c1..a1f31fdc58 100644 --- a/tests/unit/plugins/inventory/test_lxd.py +++ b/tests/unit/plugins/inventory/test_lxd.py @@ -8,9 +8,7 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type import pytest -import os -from ansible.errors import AnsibleError from ansible.inventory.data import InventoryData from ansible_collections.community.general.plugins.inventory.lxd import InventoryModule diff --git a/tests/unit/plugins/inventory/test_xen_orchestra.py b/tests/unit/plugins/inventory/test_xen_orchestra.py index 7d51f6f183..bae038e807 100644 --- a/tests/unit/plugins/inventory/test_xen_orchestra.py +++ b/tests/unit/plugins/inventory/test_xen_orchestra.py @@ -10,7 +10,6 @@ __metaclass__ = type import pytest -from ansible.errors import AnsibleError, AnsibleParserError from ansible.inventory.data import InventoryData from ansible_collections.community.general.plugins.inventory.xen_orchestra import InventoryModule diff --git a/tests/unit/plugins/lookup/test_bitwarden.py b/tests/unit/plugins/lookup/test_bitwarden.py index ac0242737e..d452639658 100644 --- a/tests/unit/plugins/lookup/test_bitwarden.py +++ b/tests/unit/plugins/lookup/test_bitwarden.py @@ -6,15 +6,13 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -from argparse import ArgumentParser - from ansible_collections.community.general.tests.unit.compat import unittest from ansible_collections.community.general.tests.unit.compat.mock import patch from ansible.errors import AnsibleError from ansible.module_utils import six from ansible.plugins.loader import lookup_loader -from ansible_collections.community.general.plugins.lookup.bitwarden import LookupModule, Bitwarden, BitwardenException +from ansible_collections.community.general.plugins.lookup.bitwarden import Bitwarden MOCK_RECORDS = [ diff --git a/tests/unit/plugins/lookup/test_etcd3.py b/tests/unit/plugins/lookup/test_etcd3.py index 798d537ed9..e9ac777ebe 100644 --- a/tests/unit/plugins/lookup/test_etcd3.py +++ b/tests/unit/plugins/lookup/test_etcd3.py @@ -8,10 +8,8 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -import pytest from ansible_collections.community.general.tests.unit.compat import unittest from ansible_collections.community.general.tests.unit.compat.mock import patch, MagicMock -from ansible.errors import AnsibleError from ansible_collections.community.general.plugins.lookup import etcd3 from ansible.plugins.loader import lookup_loader diff --git a/tests/unit/plugins/lookup/test_lastpass.py b/tests/unit/plugins/lookup/test_lastpass.py index f9749716d7..5f65c9f633 100644 --- a/tests/unit/plugins/lookup/test_lastpass.py +++ b/tests/unit/plugins/lookup/test_lastpass.py @@ -14,7 +14,7 @@ from ansible_collections.community.general.tests.unit.compat.mock import patch from ansible.errors import AnsibleError from ansible.module_utils import six from ansible.plugins.loader import lookup_loader -from ansible_collections.community.general.plugins.lookup.lastpass import LookupModule, LPass, LPassException +from ansible_collections.community.general.plugins.lookup.lastpass import LPass, LPassException MOCK_ENTRIES = [{'username': 'user', diff --git a/tests/unit/plugins/lookup/test_manifold.py b/tests/unit/plugins/lookup/test_manifold.py index f6f4a605a6..4fa3562763 100644 --- a/tests/unit/plugins/lookup/test_manifold.py +++ b/tests/unit/plugins/lookup/test_manifold.py @@ -12,7 +12,7 @@ from ansible.module_utils.urls import ConnectionError, SSLValidationError from ansible.module_utils.six.moves.urllib.error import HTTPError, URLError from ansible.module_utils import six from ansible.plugins.loader import lookup_loader -from ansible_collections.community.general.plugins.lookup.manifold import ManifoldApiClient, LookupModule, ApiError +from ansible_collections.community.general.plugins.lookup.manifold import ManifoldApiClient, ApiError import json import os diff --git a/tests/unit/plugins/module_utils/cloud/test_scaleway.py b/tests/unit/plugins/module_utils/cloud/test_scaleway.py index 3dbd7fbbbc..dc53bc1261 100644 --- a/tests/unit/plugins/module_utils/cloud/test_scaleway.py +++ b/tests/unit/plugins/module_utils/cloud/test_scaleway.py @@ -5,8 +5,6 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -import random - from ansible_collections.community.general.tests.unit.compat import unittest from ansible_collections.community.general.plugins.module_utils.scaleway import SecretVariables, argon2 diff --git a/tests/unit/plugins/module_utils/test_module_helper.py b/tests/unit/plugins/module_utils/test_module_helper.py index 18251cf2e9..3d8a4b654c 100644 --- a/tests/unit/plugins/module_utils/test_module_helper.py +++ b/tests/unit/plugins/module_utils/test_module_helper.py @@ -95,14 +95,14 @@ def test_arg_format_fail(fmt, style, stars, value, expected): def test_dependency_ctxmgr(): ctx = DependencyCtxMgr("POTATOES", "Potatoes must be installed") with ctx: - import potatoes_that_will_never_be_there + import potatoes_that_will_never_be_there # noqa: F401, pylint: disable=unused-import print("POTATOES: ctx.text={0}".format(ctx.text)) assert ctx.text == "Potatoes must be installed" assert not ctx.has_it ctx = DependencyCtxMgr("POTATOES2") with ctx: - import potatoes_that_will_never_be_there_again + import potatoes_that_will_never_be_there_again # noqa: F401, pylint: disable=unused-import assert not ctx.has_it print("POTATOES2: ctx.text={0}".format(ctx.text)) assert ctx.text.startswith("No module named") @@ -110,7 +110,7 @@ def test_dependency_ctxmgr(): ctx = DependencyCtxMgr("TYPING") with ctx: - import sys + import sys # noqa: F401, pylint: disable=unused-import assert ctx.has_it diff --git a/tests/unit/plugins/module_utils/test_opennebula.py b/tests/unit/plugins/module_utils/test_opennebula.py index 3dd2e91876..550d403711 100644 --- a/tests/unit/plugins/module_utils/test_opennebula.py +++ b/tests/unit/plugins/module_utils/test_opennebula.py @@ -6,7 +6,6 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -import os import textwrap import pytest diff --git a/tests/unit/plugins/modules/hpe_test_utils.py b/tests/unit/plugins/modules/hpe_test_utils.py index 56b4d11045..ab16d8f22b 100644 --- a/tests/unit/plugins/modules/hpe_test_utils.py +++ b/tests/unit/plugins/modules/hpe_test_utils.py @@ -13,7 +13,6 @@ import yaml from mock import Mock, patch from .oneview_module_loader import ONEVIEW_MODULE_UTILS_PATH -from .oneview_conftest import mock_ov_client, mock_ansible_module from hpOneView.oneview_client import OneViewClient diff --git a/tests/unit/plugins/modules/oneview_module_loader.py b/tests/unit/plugins/modules/oneview_module_loader.py index 51dcee788b..ae62d9ced1 100644 --- a/tests/unit/plugins/modules/oneview_module_loader.py +++ b/tests/unit/plugins/modules/oneview_module_loader.py @@ -15,18 +15,22 @@ if 'hpOneView' not in sys.modules: sys.modules['hpOneView.oneview_client'] = Mock() ONEVIEW_MODULE_UTILS_PATH = 'ansible_collections.community.general.plugins.module_utils.oneview' -from ansible_collections.community.general.plugins.module_utils.oneview import (OneViewModuleException, - OneViewModuleTaskError, - OneViewModuleResourceNotFound, - OneViewModuleBase) +from ansible_collections.community.general.plugins.module_utils.oneview import ( # noqa: F401, pylint: disable=unused-import + OneViewModuleException, + OneViewModuleTaskError, + OneViewModuleResourceNotFound, + OneViewModuleBase, +) -from ansible_collections.community.general.plugins.modules.oneview_ethernet_network import EthernetNetworkModule -from ansible_collections.community.general.plugins.modules.oneview_ethernet_network_info import EthernetNetworkInfoModule -from ansible_collections.community.general.plugins.modules.oneview_fc_network import FcNetworkModule -from ansible_collections.community.general.plugins.modules.oneview_fc_network_info import FcNetworkInfoModule -from ansible_collections.community.general.plugins.modules.oneview_fcoe_network import FcoeNetworkModule -from ansible_collections.community.general.plugins.modules.oneview_fcoe_network_info import FcoeNetworkInfoModule -from ansible_collections.community.general.plugins.modules.oneview_network_set import NetworkSetModule -from ansible_collections.community.general.plugins.modules.oneview_network_set_info import NetworkSetInfoModule -from ansible_collections.community.general.plugins.modules.oneview_san_manager import SanManagerModule -from ansible_collections.community.general.plugins.modules.oneview_san_manager_info import SanManagerInfoModule +from ansible_collections.community.general.plugins.modules.oneview_ethernet_network import EthernetNetworkModule # noqa: F401, pylint: disable=unused-import +from ansible_collections.community.general.plugins.modules.oneview_ethernet_network_info import ( # noqa: F401, pylint: disable=unused-import + EthernetNetworkInfoModule, +) +from ansible_collections.community.general.plugins.modules.oneview_fc_network import FcNetworkModule # noqa: F401, pylint: disable=unused-import +from ansible_collections.community.general.plugins.modules.oneview_fc_network_info import FcNetworkInfoModule # noqa: F401, pylint: disable=unused-import +from ansible_collections.community.general.plugins.modules.oneview_fcoe_network import FcoeNetworkModule # noqa: F401, pylint: disable=unused-import +from ansible_collections.community.general.plugins.modules.oneview_fcoe_network_info import FcoeNetworkInfoModule # noqa: F401, pylint: disable=unused-import +from ansible_collections.community.general.plugins.modules.oneview_network_set import NetworkSetModule # noqa: F401, pylint: disable=unused-import +from ansible_collections.community.general.plugins.modules.oneview_network_set_info import NetworkSetInfoModule # noqa: F401, pylint: disable=unused-import +from ansible_collections.community.general.plugins.modules.oneview_san_manager import SanManagerModule # noqa: F401, pylint: disable=unused-import +from ansible_collections.community.general.plugins.modules.oneview_san_manager_info import SanManagerInfoModule # noqa: F401, pylint: disable=unused-import diff --git a/tests/unit/plugins/modules/rhn_conftest.py b/tests/unit/plugins/modules/rhn_conftest.py index a8f890050e..acc0e2f221 100644 --- a/tests/unit/plugins/modules/rhn_conftest.py +++ b/tests/unit/plugins/modules/rhn_conftest.py @@ -5,7 +5,6 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -from ansible_collections.community.general.tests.unit.compat.mock import patch from ansible.module_utils.six.moves import xmlrpc_client import pytest diff --git a/tests/unit/plugins/modules/test_alerta_customer.py b/tests/unit/plugins/modules/test_alerta_customer.py index 2b63464e09..ccd0ced50e 100644 --- a/tests/unit/plugins/modules/test_alerta_customer.py +++ b/tests/unit/plugins/modules/test_alerta_customer.py @@ -7,7 +7,7 @@ __metaclass__ = type import json import pytest -from ansible_collections.community.general.tests.unit.compat.mock import Mock, patch +from ansible_collections.community.general.tests.unit.compat.mock import patch from ansible_collections.community.general.plugins.modules import alerta_customer from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args diff --git a/tests/unit/plugins/modules/test_discord.py b/tests/unit/plugins/modules/test_discord.py index 007cd0038e..83069d279d 100644 --- a/tests/unit/plugins/modules/test_discord.py +++ b/tests/unit/plugins/modules/test_discord.py @@ -7,7 +7,7 @@ __metaclass__ = type import json import pytest -from ansible_collections.community.general.tests.unit.compat.mock import Mock, patch +from ansible_collections.community.general.tests.unit.compat.mock import patch from ansible_collections.community.general.plugins.modules import discord from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args diff --git a/tests/unit/plugins/modules/test_github_repo.py b/tests/unit/plugins/modules/test_github_repo.py index e86179f874..10227aadfb 100644 --- a/tests/unit/plugins/modules/test_github_repo.py +++ b/tests/unit/plugins/modules/test_github_repo.py @@ -5,7 +5,6 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -import requests import re import json import sys diff --git a/tests/unit/plugins/modules/test_gitlab_protected_branch.py b/tests/unit/plugins/modules/test_gitlab_protected_branch.py index de35a4b28b..1162d8a351 100644 --- a/tests/unit/plugins/modules/test_gitlab_protected_branch.py +++ b/tests/unit/plugins/modules/test_gitlab_protected_branch.py @@ -31,7 +31,7 @@ try: # GitLab module requirements if python_version_match_requirement(): - from gitlab.v4.objects import Project + from gitlab.v4.objects import Project # noqa: F401, pylint: disable=unused-import gitlab_req_version = python_gitlab_version_match_requirement() gitlab_module_version = python_gitlab_module_version() if LooseVersion(gitlab_module_version) < LooseVersion(gitlab_req_version): diff --git a/tests/unit/plugins/modules/test_keycloak_authentication.py b/tests/unit/plugins/modules/test_keycloak_authentication.py index 19bea8ac0e..aaa1fa9b1b 100644 --- a/tests/unit/plugins/modules/test_keycloak_authentication.py +++ b/tests/unit/plugins/modules/test_keycloak_authentication.py @@ -10,8 +10,8 @@ __metaclass__ = type from contextlib import contextmanager from ansible_collections.community.general.tests.unit.compat import unittest -from ansible_collections.community.general.tests.unit.compat.mock import call, patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args +from ansible_collections.community.general.tests.unit.compat.mock import patch +from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args from ansible_collections.community.general.plugins.modules import keycloak_authentication diff --git a/tests/unit/plugins/modules/test_keycloak_client.py b/tests/unit/plugins/modules/test_keycloak_client.py index bc71b37327..b44013af13 100644 --- a/tests/unit/plugins/modules/test_keycloak_client.py +++ b/tests/unit/plugins/modules/test_keycloak_client.py @@ -11,9 +11,8 @@ __metaclass__ = type from contextlib import contextmanager from ansible_collections.community.general.tests.unit.compat import unittest -from ansible_collections.community.general.tests.unit.compat.mock import call, patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, \ - ModuleTestCase, set_module_args +from ansible_collections.community.general.tests.unit.compat.mock import patch +from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args from ansible_collections.community.general.plugins.modules import keycloak_client diff --git a/tests/unit/plugins/modules/test_keycloak_client_rolemapping.py b/tests/unit/plugins/modules/test_keycloak_client_rolemapping.py index 648d04aa23..58c8b95483 100644 --- a/tests/unit/plugins/modules/test_keycloak_client_rolemapping.py +++ b/tests/unit/plugins/modules/test_keycloak_client_rolemapping.py @@ -10,8 +10,8 @@ __metaclass__ = type from contextlib import contextmanager from ansible_collections.community.general.tests.unit.compat import unittest -from ansible_collections.community.general.tests.unit.compat.mock import call, patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args +from ansible_collections.community.general.tests.unit.compat.mock import patch +from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args from ansible_collections.community.general.plugins.modules import keycloak_client_rolemapping diff --git a/tests/unit/plugins/modules/test_keycloak_clientscope.py b/tests/unit/plugins/modules/test_keycloak_clientscope.py index 2d09496bbf..ea015b05bf 100644 --- a/tests/unit/plugins/modules/test_keycloak_clientscope.py +++ b/tests/unit/plugins/modules/test_keycloak_clientscope.py @@ -11,9 +11,8 @@ __metaclass__ = type from contextlib import contextmanager from ansible_collections.community.general.tests.unit.compat import unittest -from ansible_collections.community.general.tests.unit.compat.mock import call, patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, \ - ModuleTestCase, set_module_args +from ansible_collections.community.general.tests.unit.compat.mock import patch +from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args from ansible_collections.community.general.plugins.modules import keycloak_clientscope diff --git a/tests/unit/plugins/modules/test_keycloak_identity_provider.py b/tests/unit/plugins/modules/test_keycloak_identity_provider.py index ecee7eb9ef..6fd258b8a3 100644 --- a/tests/unit/plugins/modules/test_keycloak_identity_provider.py +++ b/tests/unit/plugins/modules/test_keycloak_identity_provider.py @@ -10,8 +10,8 @@ __metaclass__ = type from contextlib import contextmanager from ansible_collections.community.general.tests.unit.compat import unittest -from ansible_collections.community.general.tests.unit.compat.mock import call, patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args +from ansible_collections.community.general.tests.unit.compat.mock import patch +from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args from ansible_collections.community.general.plugins.modules import keycloak_identity_provider diff --git a/tests/unit/plugins/modules/test_keycloak_realm.py b/tests/unit/plugins/modules/test_keycloak_realm.py index 1572d79cbd..72993cbdfe 100644 --- a/tests/unit/plugins/modules/test_keycloak_realm.py +++ b/tests/unit/plugins/modules/test_keycloak_realm.py @@ -10,8 +10,8 @@ __metaclass__ = type from contextlib import contextmanager from ansible_collections.community.general.tests.unit.compat import unittest -from ansible_collections.community.general.tests.unit.compat.mock import call, patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args +from ansible_collections.community.general.tests.unit.compat.mock import patch +from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args from ansible_collections.community.general.plugins.modules import keycloak_realm diff --git a/tests/unit/plugins/modules/test_keycloak_realm_info.py b/tests/unit/plugins/modules/test_keycloak_realm_info.py index c1860e41ff..41095a8784 100644 --- a/tests/unit/plugins/modules/test_keycloak_realm_info.py +++ b/tests/unit/plugins/modules/test_keycloak_realm_info.py @@ -10,7 +10,7 @@ __metaclass__ = type from contextlib import contextmanager from ansible_collections.community.general.tests.unit.compat import unittest -from ansible_collections.community.general.tests.unit.compat.mock import call, patch +from ansible_collections.community.general.tests.unit.compat.mock import patch from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args from ansible_collections.community.general.plugins.modules import keycloak_realm_info diff --git a/tests/unit/plugins/modules/test_keycloak_role.py b/tests/unit/plugins/modules/test_keycloak_role.py index 74cd7bc9a3..c48c9771a5 100644 --- a/tests/unit/plugins/modules/test_keycloak_role.py +++ b/tests/unit/plugins/modules/test_keycloak_role.py @@ -10,8 +10,8 @@ __metaclass__ = type from contextlib import contextmanager from ansible_collections.community.general.tests.unit.compat import unittest -from ansible_collections.community.general.tests.unit.compat.mock import call, patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args +from ansible_collections.community.general.tests.unit.compat.mock import patch +from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args from ansible_collections.community.general.plugins.modules import keycloak_role diff --git a/tests/unit/plugins/modules/test_keycloak_user_federation.py b/tests/unit/plugins/modules/test_keycloak_user_federation.py index 7b624ef067..8d3dcaa230 100644 --- a/tests/unit/plugins/modules/test_keycloak_user_federation.py +++ b/tests/unit/plugins/modules/test_keycloak_user_federation.py @@ -10,8 +10,8 @@ __metaclass__ = type from contextlib import contextmanager from ansible_collections.community.general.tests.unit.compat import unittest -from ansible_collections.community.general.tests.unit.compat.mock import call, patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args +from ansible_collections.community.general.tests.unit.compat.mock import patch +from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args from ansible_collections.community.general.plugins.modules import keycloak_user_federation diff --git a/tests/unit/plugins/modules/test_linode.py b/tests/unit/plugins/modules/test_linode.py index 684a5f0c67..9e7b158d8e 100644 --- a/tests/unit/plugins/modules/test_linode.py +++ b/tests/unit/plugins/modules/test_linode.py @@ -10,7 +10,7 @@ import pytest from ansible_collections.community.general.plugins.modules import linode from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args -from .linode_conftest import api_key, auth +from .linode_conftest import api_key, auth # noqa: F401, pylint: disable=unused-import if not linode.HAS_LINODE: pytestmark = pytest.mark.skip('test_linode.py requires the `linode-python` module') diff --git a/tests/unit/plugins/modules/test_linode_v4.py b/tests/unit/plugins/modules/test_linode_v4.py index 37774bfd44..915a82f087 100644 --- a/tests/unit/plugins/modules/test_linode_v4.py +++ b/tests/unit/plugins/modules/test_linode_v4.py @@ -25,7 +25,7 @@ from ansible_collections.community.general.plugins.module_utils.linode import ge from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args from ansible_collections.community.general.tests.unit.compat import mock -from .linode_conftest import access_token, no_access_token_in_env, default_args, mock_linode +from .linode_conftest import access_token, no_access_token_in_env, default_args, mock_linode # noqa: F401, pylint: disable=unused-import def test_mandatory_state_is_validated(capfd): diff --git a/tests/unit/plugins/modules/test_lxca_nodes.py b/tests/unit/plugins/modules/test_lxca_nodes.py index 677587f1c4..87effa0c01 100644 --- a/tests/unit/plugins/modules/test_lxca_nodes.py +++ b/tests/unit/plugins/modules/test_lxca_nodes.py @@ -10,8 +10,6 @@ import json import pytest from ansible_collections.community.general.tests.unit.compat import mock from ansible_collections.community.general.plugins.modules import lxca_nodes -from ansible_collections.community.general.plugins.module_utils.remote_management.lxca.common import setup_conn -from ansible_collections.community.general.plugins.module_utils.remote_management.lxca.common import close_conn @pytest.fixture(scope='module') diff --git a/tests/unit/plugins/modules/test_macports.py b/tests/unit/plugins/modules/test_macports.py index 8fa3942e88..61de27654e 100644 --- a/tests/unit/plugins/modules/test_macports.py +++ b/tests/unit/plugins/modules/test_macports.py @@ -5,7 +5,6 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -from ansible.module_utils import basic from ansible_collections.community.general.plugins.modules import macports import pytest diff --git a/tests/unit/plugins/modules/test_npm.py b/tests/unit/plugins/modules/test_npm.py index 6041fcb0cf..f5d3127759 100644 --- a/tests/unit/plugins/modules/test_npm.py +++ b/tests/unit/plugins/modules/test_npm.py @@ -8,8 +8,7 @@ __metaclass__ = type from ansible_collections.community.general.tests.unit.compat.mock import call, patch from ansible_collections.community.general.plugins.modules import npm -from ansible_collections.community.general.tests.unit.plugins.modules.utils import ( - AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args) +from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args class NPMModuleTestCase(ModuleTestCase): diff --git a/tests/unit/plugins/modules/test_ocapi_command.py b/tests/unit/plugins/modules/test_ocapi_command.py index 031fb9dd09..3ce267c4e9 100644 --- a/tests/unit/plugins/modules/test_ocapi_command.py +++ b/tests/unit/plugins/modules/test_ocapi_command.py @@ -16,7 +16,7 @@ from ansible.module_utils import basic import ansible_collections.community.general.plugins.modules.ocapi_command as module from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args, exit_json, fail_json -from ansible.module_utils.six.moves.urllib.parse import quote_plus, urljoin +from ansible.module_utils.six.moves.urllib.parse import urljoin MOCK_BASE_URI = "mockBaseUri/" diff --git a/tests/unit/plugins/modules/test_one_vm.py b/tests/unit/plugins/modules/test_one_vm.py index f89a0c63df..fcfa685af7 100644 --- a/tests/unit/plugins/modules/test_one_vm.py +++ b/tests/unit/plugins/modules/test_one_vm.py @@ -6,8 +6,6 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -import os - import pytest from ansible_collections.community.general.plugins.modules.one_vm import parse_updateconf diff --git a/tests/unit/plugins/modules/test_oneview_datacenter_info.py b/tests/unit/plugins/modules/test_oneview_datacenter_info.py index 1224a8fde7..eb5e05d229 100644 --- a/tests/unit/plugins/modules/test_oneview_datacenter_info.py +++ b/tests/unit/plugins/modules/test_oneview_datacenter_info.py @@ -8,7 +8,7 @@ __metaclass__ = type import pytest from .hpe_test_utils import FactsParamsTest -from .oneview_conftest import mock_ov_client, mock_ansible_module +from .oneview_conftest import mock_ov_client, mock_ansible_module # noqa: F401, pylint: disable=unused-import from ansible_collections.community.general.plugins.modules.oneview_datacenter_info import DatacenterInfoModule diff --git a/tests/unit/plugins/modules/test_oneview_enclosure_info.py b/tests/unit/plugins/modules/test_oneview_enclosure_info.py index 4356e70e29..e8ef3449fb 100644 --- a/tests/unit/plugins/modules/test_oneview_enclosure_info.py +++ b/tests/unit/plugins/modules/test_oneview_enclosure_info.py @@ -6,7 +6,6 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type from .hpe_test_utils import FactsParamsTestCase -from .oneview_conftest import mock_ov_client, mock_ansible_module from ansible_collections.community.general.tests.unit.compat import unittest from ansible_collections.community.general.plugins.modules.oneview_enclosure_info import EnclosureInfoModule diff --git a/tests/unit/plugins/modules/test_oneview_ethernet_network.py b/tests/unit/plugins/modules/test_oneview_ethernet_network.py index 834c6c88c6..f1398740ee 100644 --- a/tests/unit/plugins/modules/test_oneview_ethernet_network.py +++ b/tests/unit/plugins/modules/test_oneview_ethernet_network.py @@ -11,7 +11,6 @@ import yaml from ansible_collections.community.general.tests.unit.compat import unittest, mock from .oneview_module_loader import EthernetNetworkModule -from .oneview_conftest import mock_ov_client, mock_ansible_module from .hpe_test_utils import OneViewBaseTestCase FAKE_MSG_ERROR = 'Fake message error' diff --git a/tests/unit/plugins/modules/test_oneview_ethernet_network_info.py b/tests/unit/plugins/modules/test_oneview_ethernet_network_info.py index f922bc8f48..4a2813e2f8 100644 --- a/tests/unit/plugins/modules/test_oneview_ethernet_network_info.py +++ b/tests/unit/plugins/modules/test_oneview_ethernet_network_info.py @@ -8,7 +8,6 @@ __metaclass__ = type from ansible_collections.community.general.tests.unit.compat import unittest from .oneview_module_loader import EthernetNetworkInfoModule -from .oneview_conftest import mock_ov_client, mock_ansible_module from .hpe_test_utils import FactsParamsTestCase ERROR_MSG = 'Fake message error' diff --git a/tests/unit/plugins/modules/test_oneview_fc_network.py b/tests/unit/plugins/modules/test_oneview_fc_network.py index 97d5ef85b6..6def80fc43 100644 --- a/tests/unit/plugins/modules/test_oneview_fc_network.py +++ b/tests/unit/plugins/modules/test_oneview_fc_network.py @@ -9,7 +9,6 @@ __metaclass__ = type from ansible_collections.community.general.tests.unit.compat import unittest from .oneview_module_loader import FcNetworkModule -from .oneview_conftest import mock_ov_client, mock_ansible_module from .hpe_test_utils import OneViewBaseTestCase FAKE_MSG_ERROR = 'Fake message error' diff --git a/tests/unit/plugins/modules/test_oneview_fc_network_info.py b/tests/unit/plugins/modules/test_oneview_fc_network_info.py index c548bf02f7..236ce136ad 100644 --- a/tests/unit/plugins/modules/test_oneview_fc_network_info.py +++ b/tests/unit/plugins/modules/test_oneview_fc_network_info.py @@ -7,7 +7,6 @@ __metaclass__ = type from ansible_collections.community.general.tests.unit.compat import unittest from .oneview_module_loader import FcNetworkInfoModule -from .oneview_conftest import mock_ov_client, mock_ansible_module from .hpe_test_utils import FactsParamsTestCase ERROR_MSG = 'Fake message error' diff --git a/tests/unit/plugins/modules/test_oneview_fcoe_network.py b/tests/unit/plugins/modules/test_oneview_fcoe_network.py index 8e74f8c73d..224e5471e9 100644 --- a/tests/unit/plugins/modules/test_oneview_fcoe_network.py +++ b/tests/unit/plugins/modules/test_oneview_fcoe_network.py @@ -9,7 +9,6 @@ __metaclass__ = type from ansible_collections.community.general.tests.unit.compat import unittest from .oneview_module_loader import FcoeNetworkModule -from .oneview_conftest import mock_ov_client, mock_ansible_module from .hpe_test_utils import OneViewBaseTestCase FAKE_MSG_ERROR = 'Fake message error' diff --git a/tests/unit/plugins/modules/test_oneview_fcoe_network_info.py b/tests/unit/plugins/modules/test_oneview_fcoe_network_info.py index a8fda975a8..387c1da3c1 100644 --- a/tests/unit/plugins/modules/test_oneview_fcoe_network_info.py +++ b/tests/unit/plugins/modules/test_oneview_fcoe_network_info.py @@ -8,7 +8,6 @@ __metaclass__ = type from ansible_collections.community.general.tests.unit.compat import unittest from .oneview_module_loader import FcoeNetworkInfoModule -from .oneview_conftest import mock_ov_client, mock_ansible_module from .hpe_test_utils import FactsParamsTestCase ERROR_MSG = 'Fake message error' diff --git a/tests/unit/plugins/modules/test_oneview_logical_interconnect_group.py b/tests/unit/plugins/modules/test_oneview_logical_interconnect_group.py index 99b4a8bc63..1f941fb50f 100644 --- a/tests/unit/plugins/modules/test_oneview_logical_interconnect_group.py +++ b/tests/unit/plugins/modules/test_oneview_logical_interconnect_group.py @@ -9,7 +9,6 @@ from copy import deepcopy from ansible_collections.community.general.tests.unit.compat import unittest, mock from .hpe_test_utils import OneViewBaseTestCase -from .oneview_conftest import mock_ov_client, mock_ansible_module from ansible_collections.community.general.plugins.modules.oneview_logical_interconnect_group import LogicalInterconnectGroupModule diff --git a/tests/unit/plugins/modules/test_oneview_logical_interconnect_group_info.py b/tests/unit/plugins/modules/test_oneview_logical_interconnect_group_info.py index 425aac6ba8..9fa602a8cf 100644 --- a/tests/unit/plugins/modules/test_oneview_logical_interconnect_group_info.py +++ b/tests/unit/plugins/modules/test_oneview_logical_interconnect_group_info.py @@ -7,7 +7,6 @@ __metaclass__ = type from ansible_collections.community.general.tests.unit.compat import unittest from .hpe_test_utils import FactsParamsTestCase -from .oneview_conftest import mock_ov_client, mock_ansible_module from ansible_collections.community.general.plugins.modules.oneview_logical_interconnect_group_info import ( LogicalInterconnectGroupInfoModule ) diff --git a/tests/unit/plugins/modules/test_oneview_network_set.py b/tests/unit/plugins/modules/test_oneview_network_set.py index be89898aed..f801cd102a 100644 --- a/tests/unit/plugins/modules/test_oneview_network_set.py +++ b/tests/unit/plugins/modules/test_oneview_network_set.py @@ -8,7 +8,6 @@ __metaclass__ = type from ansible_collections.community.general.tests.unit.compat import unittest, mock from .hpe_test_utils import OneViewBaseTestCase from .oneview_module_loader import NetworkSetModule -from .oneview_conftest import mock_ov_client, mock_ansible_module FAKE_MSG_ERROR = 'Fake message error' diff --git a/tests/unit/plugins/modules/test_oneview_network_set_info.py b/tests/unit/plugins/modules/test_oneview_network_set_info.py index 67d8f28201..13cd0400a4 100644 --- a/tests/unit/plugins/modules/test_oneview_network_set_info.py +++ b/tests/unit/plugins/modules/test_oneview_network_set_info.py @@ -7,7 +7,6 @@ __metaclass__ = type from ansible_collections.community.general.tests.unit.compat import unittest from .oneview_module_loader import NetworkSetInfoModule -from .oneview_conftest import mock_ov_client, mock_ansible_module from .hpe_test_utils import FactsParamsTestCase ERROR_MSG = 'Fake message error' diff --git a/tests/unit/plugins/modules/test_oneview_san_manager.py b/tests/unit/plugins/modules/test_oneview_san_manager.py index 22ee624f24..d675c3b353 100644 --- a/tests/unit/plugins/modules/test_oneview_san_manager.py +++ b/tests/unit/plugins/modules/test_oneview_san_manager.py @@ -7,7 +7,6 @@ __metaclass__ = type from ansible_collections.community.general.tests.unit.compat import unittest, mock from .oneview_module_loader import SanManagerModule -from .oneview_conftest import mock_ov_client, mock_ansible_module from .hpe_test_utils import OneViewBaseTestCase from copy import deepcopy diff --git a/tests/unit/plugins/modules/test_oneview_san_manager_info.py b/tests/unit/plugins/modules/test_oneview_san_manager_info.py index c786e504e0..be1f243161 100644 --- a/tests/unit/plugins/modules/test_oneview_san_manager_info.py +++ b/tests/unit/plugins/modules/test_oneview_san_manager_info.py @@ -7,7 +7,6 @@ __metaclass__ = type from ansible_collections.community.general.tests.unit.compat import unittest from .oneview_module_loader import SanManagerInfoModule -from .oneview_conftest import mock_ov_client, mock_ansible_module from .hpe_test_utils import FactsParamsTestCase diff --git a/tests/unit/plugins/modules/test_pacman.py b/tests/unit/plugins/modules/test_pacman.py index c3e455c034..04ff5bb3e8 100644 --- a/tests/unit/plugins/modules/test_pacman.py +++ b/tests/unit/plugins/modules/test_pacman.py @@ -6,12 +6,9 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type -import sys - from ansible.module_utils import basic -from ansible_collections.community.general.tests.unit.compat import mock, unittest -from ansible_collections.community.general.tests.unit.compat.mock import patch +from ansible_collections.community.general.tests.unit.compat import mock from ansible_collections.community.general.tests.unit.plugins.modules.utils import ( AnsibleExitJson, AnsibleFailJson, @@ -27,7 +24,6 @@ from ansible_collections.community.general.plugins.modules.pacman import ( ) import pytest -import json def get_bin_path(self, arg, required=False): diff --git a/tests/unit/plugins/modules/test_proxmox_tasks_info.py b/tests/unit/plugins/modules/test_proxmox_tasks_info.py index aff3fe189a..0d1b5a7bfb 100644 --- a/tests/unit/plugins/modules/test_proxmox_tasks_info.py +++ b/tests/unit/plugins/modules/test_proxmox_tasks_info.py @@ -15,13 +15,8 @@ import json from ansible_collections.community.general.plugins.modules import proxmox_tasks_info import ansible_collections.community.general.plugins.module_utils.proxmox as proxmox_utils -from ansible_collections.community.general.plugins.module_utils.proxmox import ProxmoxAnsible -from ansible_collections.community.general.tests.unit.compat.mock import MagicMock, patch -from ansible_collections.community.general.tests.unit.plugins.modules.utils import ( - AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args -) +from ansible_collections.community.general.tests.unit.compat.mock import patch from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args -from ansible_collections.community.general.plugins.module_utils import proxmox NODE = 'node01' TASK_UPID = 'UPID:iaclab-01-01:000029DD:1599528B:6108F068:srvreload:networking:root@pam:' diff --git a/tests/unit/plugins/modules/test_redis_data_incr.py b/tests/unit/plugins/modules/test_redis_data_incr.py index 24c792adb1..d819b2f7e2 100644 --- a/tests/unit/plugins/modules/test_redis_data_incr.py +++ b/tests/unit/plugins/modules/test_redis_data_incr.py @@ -21,7 +21,7 @@ HAS_REDIS_USERNAME_OPTION = True if tuple(map(int, __version__.split('.'))) < (3, 4, 0): HAS_REDIS_USERNAME_OPTION = False if HAS_REDIS_USERNAME_OPTION: - from redis.exceptions import NoPermissionError, RedisError, ResponseError + from redis.exceptions import NoPermissionError def test_redis_data_incr_without_arguments(capfd): diff --git a/tests/unit/plugins/modules/test_rhn_channel.py b/tests/unit/plugins/modules/test_rhn_channel.py index cfbb11e118..fd3bdc5fe0 100644 --- a/tests/unit/plugins/modules/test_rhn_channel.py +++ b/tests/unit/plugins/modules/test_rhn_channel.py @@ -10,7 +10,7 @@ import json from ansible_collections.community.general.plugins.modules import rhn_channel -from .rhn_conftest import mock_request +from .rhn_conftest import mock_request # noqa: F401, pylint: disable=unused-import import pytest diff --git a/tests/unit/plugins/modules/test_rhn_register.py b/tests/unit/plugins/modules/test_rhn_register.py index 62d952a428..1394c07b65 100644 --- a/tests/unit/plugins/modules/test_rhn_register.py +++ b/tests/unit/plugins/modules/test_rhn_register.py @@ -15,7 +15,7 @@ import ansible.module_utils.six from ansible.module_utils.six.moves import xmlrpc_client from ansible_collections.community.general.plugins.modules import rhn_register -from .rhn_conftest import mock_request +from .rhn_conftest import mock_request # noqa: F401, pylint: disable=unused-import import pytest diff --git a/tests/unit/plugins/modules/test_statsd.py b/tests/unit/plugins/modules/test_statsd.py index 49aadf2b90..7d458c5eb4 100644 --- a/tests/unit/plugins/modules/test_statsd.py +++ b/tests/unit/plugins/modules/test_statsd.py @@ -5,8 +5,6 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -import pytest - from ansible_collections.community.general.plugins.modules import statsd from ansible_collections.community.general.tests.unit.compat.mock import patch, MagicMock from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args diff --git a/tests/unit/plugins/modules/test_xcc_redfish_command.py b/tests/unit/plugins/modules/test_xcc_redfish_command.py index c4132125cc..c3902a2f30 100644 --- a/tests/unit/plugins/modules/test_xcc_redfish_command.py +++ b/tests/unit/plugins/modules/test_xcc_redfish_command.py @@ -5,12 +5,9 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -import json -from ansible_collections.community.general.tests.unit.compat import mock from ansible_collections.community.general.tests.unit.compat.mock import patch from ansible_collections.community.general.tests.unit.compat import unittest from ansible.module_utils import basic -from ansible.module_utils.common.text.converters import to_bytes import ansible_collections.community.general.plugins.modules.xcc_redfish_command as module from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args, exit_json, fail_json diff --git a/tests/unit/plugins/modules/test_xenserver_guest_info.py b/tests/unit/plugins/modules/test_xenserver_guest_info.py index fd669953a8..6eb22a7671 100644 --- a/tests/unit/plugins/modules/test_xenserver_guest_info.py +++ b/tests/unit/plugins/modules/test_xenserver_guest_info.py @@ -12,7 +12,7 @@ import json import pytest from .xenserver_common import fake_xenapi_ref -from .xenserver_conftest import XenAPI, xenserver_guest_info +from .xenserver_conftest import XenAPI, xenserver_guest_info # noqa: F401, pylint: disable=unused-import pytestmark = pytest.mark.usefixtures('patch_ansible_module') diff --git a/tests/unit/plugins/modules/test_xenserver_guest_powerstate.py b/tests/unit/plugins/modules/test_xenserver_guest_powerstate.py index d209ca1600..74b21fcf36 100644 --- a/tests/unit/plugins/modules/test_xenserver_guest_powerstate.py +++ b/tests/unit/plugins/modules/test_xenserver_guest_powerstate.py @@ -11,7 +11,7 @@ import json import pytest from .xenserver_common import fake_xenapi_ref -from .xenserver_conftest import fake_ansible_module, XenAPI, xenserver_guest_powerstate +from .xenserver_conftest import fake_ansible_module, XenAPI, xenserver_guest_powerstate # noqa: F401, pylint: disable=unused-import testcase_set_powerstate = { From 68d0cac310d4e06af103d51afddf473fac4a0a33 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sun, 12 Feb 2023 22:02:24 +0100 Subject: [PATCH 0158/1810] Ignore more unnecessary import warnings (#5981) Fix imports. --- plugins/module_utils/mh/module_helper.py | 2 +- plugins/module_utils/module_helper.py | 2 +- plugins/modules/pubnub_blocks.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/module_utils/mh/module_helper.py b/plugins/module_utils/mh/module_helper.py index 212ebb48fe..c5973262d2 100644 --- a/plugins/module_utils/mh/module_helper.py +++ b/plugins/module_utils/mh/module_helper.py @@ -9,7 +9,7 @@ __metaclass__ = type from ansible.module_utils.common.dict_transformations import dict_merge -# (TODO: remove AnsibleModule!) pylint: disable-next-line=unused-import +# (TODO: remove AnsibleModule!) pylint: disable-next=unused-import from ansible_collections.community.general.plugins.module_utils.mh.base import ModuleHelperBase, AnsibleModule # noqa: F401 from ansible_collections.community.general.plugins.module_utils.mh.mixins.cmd import CmdMixin from ansible_collections.community.general.plugins.module_utils.mh.mixins.state import StateMixin diff --git a/plugins/module_utils/module_helper.py b/plugins/module_utils/module_helper.py index ec7f1b1b78..8a51de6658 100644 --- a/plugins/module_utils/module_helper.py +++ b/plugins/module_utils/module_helper.py @@ -15,6 +15,6 @@ from ansible_collections.community.general.plugins.module_utils.mh.mixins.cmd im from ansible_collections.community.general.plugins.module_utils.mh.mixins.state import StateMixin # noqa: F401, pylint: disable=unused-import from ansible_collections.community.general.plugins.module_utils.mh.mixins.deps import DependencyCtxMgr # noqa: F401, pylint: disable=unused-import from ansible_collections.community.general.plugins.module_utils.mh.exceptions import ModuleHelperException # noqa: F401, pylint: disable=unused-import -# pylint: disable-next-line=unused-import +# pylint: disable-next=unused-import from ansible_collections.community.general.plugins.module_utils.mh.deco import cause_changes, module_fails_on_exception # noqa: F401 from ansible_collections.community.general.plugins.module_utils.mh.mixins.vars import VarMeta, VarDict # noqa: F401, pylint: disable=unused-import diff --git a/plugins/modules/pubnub_blocks.py b/plugins/modules/pubnub_blocks.py index 28b17b5431..7d15b0d9eb 100644 --- a/plugins/modules/pubnub_blocks.py +++ b/plugins/modules/pubnub_blocks.py @@ -235,7 +235,7 @@ import os try: # Import PubNub BLOCKS client. - from pubnub_blocks_client import User, Account, Owner, Application, Keyset + from pubnub_blocks_client import User, Account, Owner, Application, Keyset # noqa: F401, pylint: disable=unused-import from pubnub_blocks_client import Block, EventHandler from pubnub_blocks_client import exceptions HAS_PUBNUB_BLOCKS_CLIENT = True From f0fd6aa97d0dd6a5979fc9e262ce38688e2df4f4 Mon Sep 17 00:00:00 2001 From: Boik Date: Tue, 14 Feb 2023 04:36:09 +0800 Subject: [PATCH 0159/1810] Suppress urllib3 InsecureRequestWarnings when `validate_certs` option is false (#5931) * Suppress urllib3 InsecureRequestWarnings when validate_certs option is false Suppress urllib3 InsecureRequestWarnings when `validate_certs` option is false. It's clear that the user would know the possible risk when he or she chose to turn off the option, so the warning message could be ignored and make the output clean. * Create 5915-suppress-urllib3-insecure-request-warnings.yml * Update changelogs/fragments/5915-suppress-urllib3-insecure-request-warnings.yml Co-authored-by: Felix Fontein * Remove extra whitespaces --------- Co-authored-by: Felix Fontein --- .../5915-suppress-urllib3-insecure-request-warnings.yml | 2 ++ plugins/inventory/proxmox.py | 5 +++++ 2 files changed, 7 insertions(+) create mode 100644 changelogs/fragments/5915-suppress-urllib3-insecure-request-warnings.yml diff --git a/changelogs/fragments/5915-suppress-urllib3-insecure-request-warnings.yml b/changelogs/fragments/5915-suppress-urllib3-insecure-request-warnings.yml new file mode 100644 index 0000000000..9fa285154a --- /dev/null +++ b/changelogs/fragments/5915-suppress-urllib3-insecure-request-warnings.yml @@ -0,0 +1,2 @@ +minor_changes: + - proxmox - suppress urllib3 ``InsecureRequestWarnings`` when ``validate_certs`` option is ``false`` (https://github.com/ansible-collections/community.general/pull/5931). diff --git a/plugins/inventory/proxmox.py b/plugins/inventory/proxmox.py index e33f7ed77d..dc2e1febca 100644 --- a/plugins/inventory/proxmox.py +++ b/plugins/inventory/proxmox.py @@ -277,6 +277,11 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable): credentials = urlencode({'username': self.proxmox_user, 'password': self.proxmox_password, }) a = self._get_session() + + if a.verify is False: + from requests.packages.urllib3 import disable_warnings + disable_warnings() + ret = a.post('%s/api2/json/access/ticket' % self.proxmox_url, data=credentials) json = ret.json() From c587c09df1d839aa072883d3c9fd3082b2ed8a69 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Mon, 13 Feb 2023 21:40:26 +0100 Subject: [PATCH 0160/1810] Remove skornehl as maintainer for datadog_monitor (#5885) Remove skornehl as maintainer for datadog_monitor. --- .github/BOTMETA.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/BOTMETA.yml b/.github/BOTMETA.yml index 2051e34e0a..769b4d273b 100644 --- a/.github/BOTMETA.yml +++ b/.github/BOTMETA.yml @@ -440,7 +440,7 @@ files: labels: datadog_event maintainers: n0ts $modules/datadog_monitor.py: - maintainers: skornehl + ignore: skornehl $modules/dconf.py: maintainers: azaghal $modules/deploy_helper.py: From cd0a414e9f13331752a4a53c798626666aca33d4 Mon Sep 17 00:00:00 2001 From: cybernet Date: Mon, 13 Feb 2023 20:53:49 +0000 Subject: [PATCH 0161/1810] Update gitlab_project_members.py - typo fix (#5989) Update gitlab_project_members.py ##### SUMMARY typo fix ##### ISSUE TYPE - Docs Pull Request +label: docsite_pr --- plugins/modules/gitlab_project_members.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/gitlab_project_members.py b/plugins/modules/gitlab_project_members.py index 811033f312..84e3c9b8e1 100644 --- a/plugins/modules/gitlab_project_members.py +++ b/plugins/modules/gitlab_project_members.py @@ -136,7 +136,7 @@ EXAMPLES = r''' project: projectname gitlab_user: username access_level: developer - pruge_users: developer + purge_users: developer state: present - name: Remove a list of Users with Dedicated Access Levels to A GitLab project From 4c4ef80ca9518792bc4e0551864a7929254a27a0 Mon Sep 17 00:00:00 2001 From: Sargun Vohra Date: Mon, 13 Feb 2023 12:54:56 -0800 Subject: [PATCH 0162/1810] yarn: Fix state=latest not working with global=true (#5829) * Yarn module: fix state=latest not working with global=true * fix whitespace * add changelog fragment * add integration test cases * add only tests for this PR (install+upgrade) * fix assuming default global dir * fix list() not working when global=true and name a package with no binary * remove ignores * whitespace * Update changelogs/fragments/5829-fix-yarn-global.yml Co-authored-by: Felix Fontein * Update changelogs/fragments/5829-fix-yarn-global.yml Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> --------- Co-authored-by: Felix Fontein Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> --- changelogs/fragments/5829-fix-yarn-global.yml | 4 + plugins/modules/yarn.py | 41 ++++----- tests/integration/targets/yarn/tasks/run.yml | 87 +++++++++++++++++++ tests/sanity/ignore-2.11.txt | 1 - tests/sanity/ignore-2.12.txt | 1 - tests/sanity/ignore-2.13.txt | 1 - tests/sanity/ignore-2.14.txt | 1 - tests/sanity/ignore-2.15.txt | 1 - 8 files changed, 112 insertions(+), 25 deletions(-) create mode 100644 changelogs/fragments/5829-fix-yarn-global.yml diff --git a/changelogs/fragments/5829-fix-yarn-global.yml b/changelogs/fragments/5829-fix-yarn-global.yml new file mode 100644 index 0000000000..fade7d97f6 --- /dev/null +++ b/changelogs/fragments/5829-fix-yarn-global.yml @@ -0,0 +1,4 @@ +bugfixes: + - yarn - fix ``state=latest`` not working with ``global=true`` (https://github.com/ansible-collections/community.general/issues/5712). + - yarn - fix ``global=true`` to check for the configured global folder instead of assuming the default (https://github.com/ansible-collections/community.general/pull/5829) + - yarn - fix ``state=absent`` not working with ``global=true`` when the package does not include a binary (https://github.com/ansible-collections/community.general/pull/5829) diff --git a/plugins/modules/yarn.py b/plugins/modules/yarn.py index 2e96cb799d..df55925dba 100644 --- a/plugins/modules/yarn.py +++ b/plugins/modules/yarn.py @@ -163,8 +163,6 @@ from ansible.module_utils.basic import AnsibleModule class Yarn(object): - DEFAULT_GLOBAL_INSTALLATION_PATH = os.path.expanduser('~/.config/yarn/global') - def __init__(self, module, **kwargs): self.module = module self.globally = kwargs['globally'] @@ -188,10 +186,12 @@ class Yarn(object): elif self.name is not None: self.name_version = self.name - def _exec(self, args, run_in_check_mode=False, check_rc=True): + def _exec(self, args, run_in_check_mode=False, check_rc=True, unsupported_with_global=False): if not self.module.check_mode or (self.module.check_mode and run_in_check_mode): - if self.globally: + with_global_arg = self.globally and not unsupported_with_global + + if with_global_arg: # Yarn global arg is inserted before the command (e.g. `yarn global {some-command}`) args.insert(0, 'global') @@ -207,7 +207,7 @@ class Yarn(object): # If path is specified, cd into that path and run the command. cwd = None - if self.path and not self.globally: + if self.path and not with_global_arg: if not os.path.exists(self.path): # Module will make directory if not exists. os.makedirs(self.path) @@ -233,24 +233,21 @@ class Yarn(object): missing.append(self.name) return installed, missing - result, error = self._exec(cmd, True, False) + # `yarn global list` should be treated as "unsupported with global" even though it exists, + # because it only only lists binaries, but `yarn global add` can install libraries too. + result, error = self._exec(cmd, run_in_check_mode=True, check_rc=False, unsupported_with_global=True) if error: self.module.fail_json(msg=error) for json_line in result.strip().split('\n'): data = json.loads(json_line) - if self.globally: - if data['type'] == 'list' and data['data']['type'].startswith('bins-'): - # This is a string in format: 'bins-' - installed.append(data['data']['type'][5:]) - else: - if data['type'] == 'tree': - dependencies = data['data']['trees'] + if data['type'] == 'tree': + dependencies = data['data']['trees'] - for dep in dependencies: - name, version = dep['name'].rsplit('@', 1) - installed.append(name) + for dep in dependencies: + name, version = dep['name'].rsplit('@', 1) + installed.append(name) if self.name not in installed: missing.append(self.name) @@ -276,9 +273,12 @@ class Yarn(object): if not os.path.isfile(os.path.join(self.path, 'yarn.lock')): return outdated - cmd_result, err = self._exec(['outdated', '--json'], True, False) - if err: - self.module.fail_json(msg=err) + cmd_result, err = self._exec(['outdated', '--json'], True, False, unsupported_with_global=True) + + # the package.json in the global dir is missing a license field, so warnings are expected on stderr + for line in err.splitlines(): + if json.loads(line)['type'] == 'error': + self.module.fail_json(msg=err) if not cmd_result: return outdated @@ -340,7 +340,8 @@ def main(): # When installing globally, use the defined path for global node_modules if globally: - path = Yarn.DEFAULT_GLOBAL_INSTALLATION_PATH + _rc, out, _err = module.run_command([executable, 'global', 'dir'], check_rc=True) + path = out.strip() yarn = Yarn(module, name=name, diff --git a/tests/integration/targets/yarn/tasks/run.yml b/tests/integration/targets/yarn/tasks/run.yml index 367d7dcf2c..6521d45fcf 100644 --- a/tests/integration/targets/yarn/tasks/run.yml +++ b/tests/integration/targets/yarn/tasks/run.yml @@ -39,6 +39,7 @@ package: 'iconv-lite' environment: PATH: "{{ node_bin_path }}:{{ansible_env.PATH}}" + YARN_IGNORE_ENGINES: true block: # Get the version of Yarn and register to a variable @@ -135,3 +136,89 @@ assert: that: - yarn_uninstall_package is changed + + - name: 'Global install binary with explicit version (older version of package)' + yarn: + global: true + executable: '{{ yarn_bin_path }}/yarn' + name: prettier + version: 2.0.0 + state: present + environment: + PATH: '{{ node_bin_path }}:{{ ansible_env.PATH }}' + register: yarn_global_install_old_binary + + - assert: + that: + - yarn_global_install_old_binary is changed + + - name: 'Global upgrade old binary' + yarn: + global: true + executable: '{{ yarn_bin_path }}/yarn' + name: prettier + state: latest + environment: + PATH: '{{ node_bin_path }}:{{ ansible_env.PATH }}' + register: yarn_global_update_old_binary + + - assert: + that: + - yarn_global_update_old_binary is changed + + - name: 'Global remove a binary' + yarn: + global: true + executable: '{{ yarn_bin_path }}/yarn' + name: prettier + state: absent + environment: + PATH: '{{ node_bin_path }}:{{ ansible_env.PATH }}' + register: yarn_global_uninstall_binary + + - assert: + that: + - yarn_global_uninstall_binary is changed + + - name: 'Global install package with no binary with explicit version (older version of package)' + yarn: + global: true + executable: '{{ yarn_bin_path }}/yarn' + name: left-pad + version: 1.1.0 + state: present + environment: + PATH: '{{ node_bin_path }}:{{ ansible_env.PATH }}' + register: yarn_global_install_old_package + + - assert: + that: + - yarn_global_install_old_package is changed + + - name: 'Global upgrade old package with no binary' + yarn: + global: true + executable: '{{ yarn_bin_path }}/yarn' + name: left-pad + state: latest + environment: + PATH: '{{ node_bin_path }}:{{ ansible_env.PATH }}' + register: yarn_global_update_old_package + + - assert: + that: + - yarn_global_update_old_package is changed + + - name: 'Global remove a package with no binary' + yarn: + global: true + executable: '{{ yarn_bin_path }}/yarn' + name: left-pad + state: absent + environment: + PATH: '{{ node_bin_path }}:{{ ansible_env.PATH }}' + register: yarn_global_uninstall_package + + - assert: + that: + - yarn_global_uninstall_package is changed diff --git a/tests/sanity/ignore-2.11.txt b/tests/sanity/ignore-2.11.txt index 508785f220..336a923589 100644 --- a/tests/sanity/ignore-2.11.txt +++ b/tests/sanity/ignore-2.11.txt @@ -24,6 +24,5 @@ plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice plugins/modules/rax.py use-argspec-type-path # module deprecated - removed in 9.0.0 plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/xfconf.py validate-modules:return-syntax-error -plugins/modules/yarn.py use-argspec-type-path tests/integration/targets/django_manage/files/base_test/simple_project/p1/manage.py compile-2.6 # django generated code tests/integration/targets/django_manage/files/base_test/simple_project/p1/manage.py compile-2.7 # django generated code diff --git a/tests/sanity/ignore-2.12.txt b/tests/sanity/ignore-2.12.txt index 77a0105529..2386cda087 100644 --- a/tests/sanity/ignore-2.12.txt +++ b/tests/sanity/ignore-2.12.txt @@ -19,4 +19,3 @@ plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice plugins/modules/rax.py use-argspec-type-path # module deprecated - removed in 9.0.0 plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/xfconf.py validate-modules:return-syntax-error -plugins/modules/yarn.py use-argspec-type-path diff --git a/tests/sanity/ignore-2.13.txt b/tests/sanity/ignore-2.13.txt index 77a0105529..2386cda087 100644 --- a/tests/sanity/ignore-2.13.txt +++ b/tests/sanity/ignore-2.13.txt @@ -19,4 +19,3 @@ plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice plugins/modules/rax.py use-argspec-type-path # module deprecated - removed in 9.0.0 plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/xfconf.py validate-modules:return-syntax-error -plugins/modules/yarn.py use-argspec-type-path diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt index db0e449b79..ec887e18b8 100644 --- a/tests/sanity/ignore-2.14.txt +++ b/tests/sanity/ignore-2.14.txt @@ -21,4 +21,3 @@ plugins/modules/rax.py use-argspec-type-path plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/udm_user.py import-3.11 # Uses deprecated stdlib library 'crypt' plugins/modules/xfconf.py validate-modules:return-syntax-error -plugins/modules/yarn.py use-argspec-type-path diff --git a/tests/sanity/ignore-2.15.txt b/tests/sanity/ignore-2.15.txt index db0e449b79..ec887e18b8 100644 --- a/tests/sanity/ignore-2.15.txt +++ b/tests/sanity/ignore-2.15.txt @@ -21,4 +21,3 @@ plugins/modules/rax.py use-argspec-type-path plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/udm_user.py import-3.11 # Uses deprecated stdlib library 'crypt' plugins/modules/xfconf.py validate-modules:return-syntax-error -plugins/modules/yarn.py use-argspec-type-path From 24efe9ee9a39fb41bfe3a185c46450df19c5db31 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Wed, 15 Feb 2023 22:55:23 +0100 Subject: [PATCH 0163/1810] Normalize bools in tests (#5996) * Normalize bools in tests. * Fix typo. --- .../targets/aix_devices/tasks/main.yml | 4 +- .../targets/aix_filesystem/tasks/main.yml | 6 +- .../targets/archive/tasks/main.yml | 4 +- .../targets/archive/tests/broken-link.yml | 2 +- .../targets/archive/tests/remove.yml | 10 +- .../targets/cargo/tasks/test_general.yml | 2 +- .../cloud_init_data_facts/tasks/main.yml | 2 +- .../targets/connection/test_connection.yml | 2 +- tests/integration/targets/copr/tasks/main.yml | 2 +- .../integration/targets/cpanm/tasks/main.yml | 10 +- .../dnf_versionlock/tasks/lock_updates.yml | 2 +- .../targets/dpkg_divert/tasks/prepare.yml | 8 +- .../dpkg_divert/tasks/tests/01-basic.yml | 20 ++-- .../dpkg_divert/tasks/tests/02-rename.yml | 98 +++++++++---------- .../targets/filesize/tasks/basics.yml | 20 ++-- .../targets/filesize/tasks/errors.yml | 26 ++--- .../targets/filesize/tasks/floats.yml | 12 +-- .../targets/filesize/tasks/sparse.yml | 60 ++++++------ .../targets/filesize/tasks/symlinks.yml | 8 +- .../targets/filesystem/tasks/create_fs.yml | 6 +- .../filesystem/tasks/overwrite_another_fs.yml | 2 +- .../targets/filesystem/tasks/remove_fs.yml | 4 +- .../targets/filter_counter/tasks/main.yml | 4 +- .../targets/filter_random_mac/tasks/main.yml | 6 +- .../targets/filter_time/tasks/main.yml | 6 +- .../gandi_livedns/tasks/create_record.yml | 2 +- .../gandi_livedns/tasks/remove_record.yml | 2 +- .../gandi_livedns/tasks/update_record.yml | 2 +- tests/integration/targets/gem/tasks/main.yml | 16 +-- .../tasks/exclusion_state_list-all.yml | 2 +- .../targets/git_config/tasks/setup.yml | 4 +- .../git_config/tasks/unset_check_mode.yml | 2 +- .../gitlab_group_variable/tasks/main.yml | 6 +- .../gitlab_project_badge/tasks/main.yml | 6 +- .../gitlab_project_variable/tasks/main.yml | 6 +- tests/integration/targets/hg/tasks/main.yml | 2 +- .../targets/hg/tasks/run-tests.yml | 4 +- .../targets/hg/tasks/uninstall.yml | 4 +- .../targets/homebrew/tasks/main.yml | 24 ++--- .../targets/homebrew_cask/tasks/main.yml | 10 +- .../targets/homectl/tasks/main.yml | 26 ++--- .../targets/hwc_ecs_instance/tasks/main.yml | 6 +- .../targets/hwc_evs_disk/tasks/main.yml | 4 +- .../targets/hwc_vpc_eip/tasks/main.yml | 8 +- .../hwc_vpc_peering_connect/tasks/main.yml | 8 +- .../targets/hwc_vpc_port/tasks/main.yml | 6 +- .../targets/hwc_vpc_private_ip/tasks/main.yml | 8 +- .../targets/hwc_vpc_route/tasks/main.yml | 8 +- .../hwc_vpc_security_group/tasks/main.yml | 6 +- .../tasks/main.yml | 4 +- .../targets/hwc_vpc_subnet/tasks/main.yml | 8 +- .../targets/ini_file/tasks/tests/01-value.yml | 16 +-- .../ini_file/tasks/tests/02-values.yml | 2 +- .../targets/iptables_state/tasks/main.yml | 4 +- .../iptables_state/tasks/tests/00-basic.yml | 58 +++++------ .../iptables_state/tasks/tests/01-tables.yml | 28 +++--- .../tasks/tests/10-rollback.yml | 2 +- .../targets/ipwcli_dns/tasks/main.yml | 4 +- .../targets/iso_create/tasks/main.yml | 2 +- .../targets/iso_extract/tasks/7zip.yml | 6 +- .../targets/iso_extract/tasks/main.yml | 6 +- .../targets/java_cert/tasks/main.yml | 6 +- .../targets/java_cert/tasks/state_change.yml | 8 +- .../targets/java_keystore/tasks/tests.yml | 18 ++-- .../integration/targets/jboss/tasks/jboss.yml | 16 +-- .../targets/keycloak_client/tasks/main.yml | 2 +- .../targets/launchd/tasks/setup.yml | 4 +- .../targets/launchd/tasks/teardown.yml | 6 +- .../launchd/tasks/tests/test_reload.yml | 12 +-- .../launchd/tasks/tests/test_restart.yml | 8 +- .../launchd/tasks/tests/test_runatload.yml | 6 +- .../launchd/tasks/tests/test_start_stop.yml | 14 +-- .../launchd/tasks/tests/test_unload.yml | 10 +- .../targets/ldap_search/tasks/tests/basic.yml | 2 +- .../targets/lookup_dig/tasks/main.yml | 2 +- .../lookup_passwordstore/tasks/package.yml | 12 +-- .../lookup_passwordstore/tasks/tests.yml | 2 +- .../targets/lookup_random_pet/test.yml | 2 +- .../targets/lookup_random_string/test.yml | 4 +- .../targets/lvg/tasks/test_pvresize.yml | 8 +- tests/integration/targets/mail/tasks/main.yml | 6 +- tests/integration/targets/mas/tasks/main.yml | 12 +-- .../targets/module_helper/library/mstate.py | 2 +- .../targets/module_helper/tasks/mdepfail.yml | 2 +- .../targets/module_helper/tasks/msimple.yml | 2 +- .../tasks/msimple_output_conflict.yml | 2 +- .../integration/targets/monit/tasks/main.yml | 14 +-- .../targets/mssql_script/tasks/main.yml | 2 +- tests/integration/targets/npm/tasks/setup.yml | 2 +- .../targets/osx_defaults/tasks/main.yml | 10 +- .../targets/pacman/tasks/remove_nosave.yml | 2 +- .../targets/pam_limits/tasks/main.yml | 2 +- tests/integration/targets/pipx/tasks/main.yml | 8 +- .../pkgng/tasks/create-outofdate-pkg.yml | 4 +- .../targets/pkgng/tasks/freebsd.yml | 44 ++++----- .../pkgng/tasks/install_single_package.yml | 16 +-- .../targets/pkgng/tasks/setup-testjail.yml | 8 +- .../targets/pkgutil/tasks/main.yml | 8 +- .../targets/read_csv/tasks/main.yml | 8 +- .../targets/redis_info/tasks/main.yml | 2 +- .../targets/scaleway_compute/tasks/ip.yml | 6 +- .../scaleway_compute/tasks/security_group.yml | 4 +- .../targets/scaleway_compute/tasks/state.yml | 16 +-- .../targets/scaleway_container/tasks/main.yml | 8 +- .../tasks/main.yml | 8 +- .../tasks/main.yml | 6 +- .../scaleway_database_backup/tasks/main.yml | 10 +- .../targets/scaleway_function/tasks/main.yml | 8 +- .../tasks/main.yml | 8 +- .../targets/scaleway_ip/tasks/main.yml | 12 +-- .../targets/scaleway_lb/tasks/main.yml | 6 +- .../scaleway_security_group/tasks/main.yml | 4 +- .../targets/scaleway_sshkey/tasks/main.yml | 4 +- .../targets/scaleway_user_data/tasks/main.yml | 2 +- .../targets/sefcontext/tasks/sefcontext.yml | 12 +-- .../targets/setup_etcd3/tasks/main.yml | 2 +- .../targets/setup_gnutar/handlers/main.yml | 2 +- .../targets/setup_gnutar/tasks/main.yml | 2 +- .../targets/setup_mosquitto/tasks/ubuntu.yml | 2 +- .../targets/setup_pkg_mgr/tasks/main.yml | 6 +- .../setup_postgresql_db/tasks/main.yml | 8 +- .../tasks/default-cleanup.yml | 2 +- .../tasks/default-cleanup.yml | 2 +- .../setup_wildfly_server/handlers/main.yml | 2 +- .../setup_wildfly_server/tasks/main.yml | 14 +-- .../targets/shutdown/tasks/main.yml | 4 +- .../targets/ssh_config/tasks/main.yml | 6 +- .../targets/ssh_config/tasks/options.yml | 6 +- .../supervisorctl/tasks/install_Linux.yml | 2 +- .../integration/targets/sysrc/tasks/main.yml | 14 +-- .../targets/sysrc/tasks/setup-testjail.yml | 4 +- .../terraform/tasks/complex_variables.yml | 2 +- .../targets/terraform/tasks/main.yml | 2 +- .../terraform/tasks/test_provider_upgrade.yml | 4 +- .../targets/terraform/vars/main.yml | 4 +- .../targets/timezone/tasks/test.yml | 44 ++++----- tests/integration/targets/ufw/tasks/main.yml | 6 +- .../targets/ufw/tasks/tests/basic.yml | 78 +++++++-------- .../targets/ufw/tasks/tests/global-state.yml | 26 ++--- .../targets/ufw/tasks/tests/interface.yml | 8 +- .../targets/wakeonlan/tasks/main.yml | 6 +- .../integration/targets/xattr/tasks/main.yml | 2 +- .../targets/xfs_quota/tasks/main.yml | 4 +- .../test-add-children-elements-unicode.yml | 4 +- .../xml/tasks/test-add-children-elements.yml | 4 +- .../test-add-children-from-groupvars.yml | 4 +- .../tasks/test-add-children-insertafter.yml | 8 +- .../tasks/test-add-children-insertbefore.yml | 8 +- ...t-add-children-with-attributes-unicode.yml | 4 +- .../test-add-children-with-attributes.yml | 4 +- .../xml/tasks/test-add-element-implicitly.yml | 24 ++--- .../test-add-namespaced-children-elements.yml | 4 +- .../xml/tasks/test-children-elements-xml.yml | 4 +- .../targets/xml/tasks/test-count-unicode.yml | 2 +- .../targets/xml/tasks/test-count.yml | 2 +- .../test-mutually-exclusive-attributes.yml | 2 +- .../xml/tasks/test-pretty-print-only.yml | 6 +- .../targets/xml/tasks/test-pretty-print.yml | 6 +- .../tasks/test-remove-attribute-nochange.yml | 4 +- .../xml/tasks/test-remove-attribute.yml | 4 +- .../tasks/test-remove-element-nochange.yml | 4 +- .../targets/xml/tasks/test-remove-element.yml | 4 +- ...t-remove-namespaced-attribute-nochange.yml | 4 +- .../test-remove-namespaced-attribute.yml | 4 +- ...est-remove-namespaced-element-nochange.yml | 4 +- .../tasks/test-remove-namespaced-element.yml | 4 +- .../test-set-attribute-value-unicode.yml | 4 +- .../xml/tasks/test-set-attribute-value.yml | 4 +- .../test-set-children-elements-level.yml | 8 +- .../test-set-children-elements-unicode.yml | 8 +- .../xml/tasks/test-set-children-elements.yml | 12 +-- .../tasks/test-set-element-value-empty.yml | 4 +- .../tasks/test-set-element-value-unicode.yml | 4 +- .../xml/tasks/test-set-element-value.yml | 4 +- .../test-set-namespaced-attribute-value.yml | 4 +- .../test-set-namespaced-children-elements.yml | 10 +- .../test-set-namespaced-element-value.yml | 4 +- .../targets/xml/tasks/test-xmlstring.yml | 16 +-- tests/integration/targets/yarn/tasks/run.yml | 4 +- .../targets/yum_versionlock/tasks/main.yml | 2 +- .../targets/zypper/tasks/zypper.yml | 16 +-- .../tasks/zypper_repository.yml | 4 +- 182 files changed, 770 insertions(+), 770 deletions(-) diff --git a/tests/integration/targets/aix_devices/tasks/main.yml b/tests/integration/targets/aix_devices/tasks/main.yml index d007e9b611..c2b829d42f 100644 --- a/tests/integration/targets/aix_devices/tasks/main.yml +++ b/tests/integration/targets/aix_devices/tasks/main.yml @@ -47,13 +47,13 @@ - name: Put vscsi1 and children devices in Defined state. aix_devices: device: vscsi1 - recursive: yes + recursive: true state: defined - name: Removes vscsi1 and children devices. aix_devices: device: vscsi1 - recursive: yes + recursive: true state: absent - name: Changes en1 mtu to 9000 and disables arp. diff --git a/tests/integration/targets/aix_filesystem/tasks/main.yml b/tests/integration/targets/aix_filesystem/tasks/main.yml index e17ec4d263..25146062d6 100644 --- a/tests/integration/targets/aix_filesystem/tasks/main.yml +++ b/tests/integration/targets/aix_filesystem/tasks/main.yml @@ -104,7 +104,7 @@ - name: Remove NFS filesystem /home/ftp aix_filesystem: filesystem: /home/ftp - rm_mount_point: yes + rm_mount_point: true state: absent - name: Mount filesystem /newfs @@ -115,7 +115,7 @@ - name: Remove mounted /newfs aix_filesystem: filesystem: /newfs - rm_mount_point: yes + rm_mount_point: true state: absent - name: Umount /newfs @@ -126,5 +126,5 @@ - name: Remove /newfs aix_filesystem: filesystem: /newfs - rm_mount_point: yes + rm_mount_point: true state: absent diff --git a/tests/integration/targets/archive/tasks/main.yml b/tests/integration/targets/archive/tasks/main.yml index 4043f95b62..afe278bcf4 100644 --- a/tests/integration/targets/archive/tasks/main.yml +++ b/tests/integration/targets/archive/tasks/main.yml @@ -78,8 +78,8 @@ homebrew: name: xz state: present - update_homebrew: no - become: yes + update_homebrew: false + become: true become_user: "{{ brew_stat.stat.pw_name }}" # Newer versions of brew want to compile a package which takes a long time. Do not upgrade homebrew until a # proper solution can be found diff --git a/tests/integration/targets/archive/tests/broken-link.yml b/tests/integration/targets/archive/tests/broken-link.yml index 8f8b534d58..7c64443719 100644 --- a/tests/integration/targets/archive/tests/broken-link.yml +++ b/tests/integration/targets/archive/tests/broken-link.yml @@ -9,7 +9,7 @@ src: /nowhere dest: "{{ remote_tmp_dir }}/nowhere.txt" state: link - force: yes + force: true - name: Archive - broken link ({{ format }}) archive: diff --git a/tests/integration/targets/archive/tests/remove.yml b/tests/integration/targets/archive/tests/remove.yml index b58046af6a..8f0b8cff86 100644 --- a/tests/integration/targets/archive/tests/remove.yml +++ b/tests/integration/targets/archive/tests/remove.yml @@ -8,7 +8,7 @@ path: "{{ remote_tmp_dir }}/*.txt" dest: "{{ remote_tmp_dir }}/archive_remove_source_files.{{ format }}" format: "{{ format }}" - remove: yes + remove: true register: archive_remove_source_files - name: Verify archive exists - remove source files ({{ format }}) @@ -64,7 +64,7 @@ path: "{{ remote_tmp_dir }}/tmpdir" dest: "{{ remote_tmp_dir }}/archive_remove_source_directory.{{ format }}" format: "{{ format }}" - remove: yes + remove: true register: archive_remove_source_directory - name: Verify archive exists - remove source directory ({{ format }}) @@ -107,7 +107,7 @@ path: "{{ remote_tmp_dir }}/tmpdir/*" dest: "{{ remote_tmp_dir }}/archive_remove_source_excluding_path.{{ format }}" format: "{{ format }}" - remove: yes + remove: true exclude_path: "{{ remote_tmp_dir }}/tmpdir/empty.txt" register: archive_remove_source_excluding_path @@ -150,7 +150,7 @@ - "{{ remote_tmp_dir }}/tmpdir/sub/*" dest: "{{ remote_tmp_dir }}/archive_remove_source_excluding_sub_path.{{ format }}" format: "{{ format }}" - remove: yes + remove: true exclude_path: "{{ remote_tmp_dir }}/tmpdir/sub/subfile.txt" register: archive_remove_source_excluding_sub_path @@ -185,7 +185,7 @@ path: "{{ remote_tmp_dir }}/tmpdir/" dest: "{{ remote_tmp_dir }}/archive_remove_source_nested_paths.{{ format }}" format: "{{ format }}" - remove: yes + remove: true register: archive_remove_nested_paths - name: Verify archive exists - remove source with nested paths ({{ format }}) diff --git a/tests/integration/targets/cargo/tasks/test_general.yml b/tests/integration/targets/cargo/tasks/test_general.yml index e07264b517..2bffa08f0d 100644 --- a/tests/integration/targets/cargo/tasks/test_general.yml +++ b/tests/integration/targets/cargo/tasks/test_general.yml @@ -18,7 +18,7 @@ community.general.cargo: name: helloworld register: install_present_helloworld - ignore_errors: yes + ignore_errors: true - name: Uninstall application helloworld community.general.cargo: diff --git a/tests/integration/targets/cloud_init_data_facts/tasks/main.yml b/tests/integration/targets/cloud_init_data_facts/tasks/main.yml index fe38d4ca5b..40e762d689 100644 --- a/tests/integration/targets/cloud_init_data_facts/tasks/main.yml +++ b/tests/integration/targets/cloud_init_data_facts/tasks/main.yml @@ -42,7 +42,7 @@ - name: test gather cloud-init facts in check mode cloud_init_data_facts: - check_mode: yes + check_mode: true register: result - name: verify test gather cloud-init facts in check mode assert: diff --git a/tests/integration/targets/connection/test_connection.yml b/tests/integration/targets/connection/test_connection.yml index 157a7821ba..bb0a993995 100644 --- a/tests/integration/targets/connection/test_connection.yml +++ b/tests/integration/targets/connection/test_connection.yml @@ -4,7 +4,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later - hosts: "{{ target_hosts }}" - gather_facts: no + gather_facts: false serial: 1 tasks: diff --git a/tests/integration/targets/copr/tasks/main.yml b/tests/integration/targets/copr/tasks/main.yml index 917e44b7ec..0e46517240 100644 --- a/tests/integration/targets/copr/tasks/main.yml +++ b/tests/integration/targets/copr/tasks/main.yml @@ -34,7 +34,7 @@ - result.info == 'Please note that this repository is not part of the main distribution' - name: enable copr project - check_mode: yes + check_mode: true copr: state: enabled name: '{{ copr_fullname }}' diff --git a/tests/integration/targets/cpanm/tasks/main.yml b/tests/integration/targets/cpanm/tasks/main.yml index ed3c02b692..c9adc1ca6b 100644 --- a/tests/integration/targets/cpanm/tasks/main.yml +++ b/tests/integration/targets/cpanm/tasks/main.yml @@ -15,7 +15,7 @@ - perl-devel - perl-App-cpanminus state: present - become: yes + become: true when: ansible_os_family == "RedHat" - name: install perl development package for Debian family @@ -23,13 +23,13 @@ name: - cpanminus state: present - become: yes + become: true when: ansible_os_family == "Debian" - name: install a Perl package cpanm: name: JSON - notest: yes + notest: true register: install_perl_package_result - name: assert package is installed @@ -41,7 +41,7 @@ - name: install same Perl package cpanm: name: JSON - notest: yes + notest: true register: install_same_perl_package_result - name: assert same package is installed @@ -54,7 +54,7 @@ cpanm: name: JSON version: "@4.01" - notest: yes + notest: true mode: new register: install_perl_package_with_version_op_result diff --git a/tests/integration/targets/dnf_versionlock/tasks/lock_updates.yml b/tests/integration/targets/dnf_versionlock/tasks/lock_updates.yml index edbfcabd40..b3fceb26f5 100644 --- a/tests/integration/targets/dnf_versionlock/tasks/lock_updates.yml +++ b/tests/integration/targets/dnf_versionlock/tasks/lock_updates.yml @@ -63,7 +63,7 @@ dnf: name: "{{ _packages }}" state: latest - check_mode: yes + check_mode: true register: update_packages - assert: diff --git a/tests/integration/targets/dpkg_divert/tasks/prepare.yml b/tests/integration/targets/dpkg_divert/tasks/prepare.yml index 7697d0fd2d..94566b41e1 100644 --- a/tests/integration/targets/dpkg_divert/tasks/prepare.yml +++ b/tests/integration/targets/dpkg_divert/tasks/prepare.yml @@ -19,7 +19,7 @@ dpkg_divert: path: "{{ foobarrc }}" state: absent - become: yes + become: true - name: "remove test files" file: @@ -30,7 +30,7 @@ - "{{ foobarrc_distrib }}" loop_control: loop_var: dpkg_divert_item - become: yes + become: true - block: @@ -39,5 +39,5 @@ - name: "include tasks to perform other tests (rename)" include_tasks: tests/02-rename.yml - become: yes - diff: yes + become: true + diff: true diff --git a/tests/integration/targets/dpkg_divert/tasks/tests/01-basic.yml b/tests/integration/targets/dpkg_divert/tasks/tests/01-basic.yml index 0668a8aa02..78863d1db8 100644 --- a/tests/integration/targets/dpkg_divert/tasks/tests/01-basic.yml +++ b/tests/integration/targets/dpkg_divert/tasks/tests/01-basic.yml @@ -46,14 +46,14 @@ dpkg_divert: path: "{{ foobarrc }}" state: present - rename: yes + rename: true register: diversion_4 - name: "divert foobarrc (check mode, rename, must NOT report a change, idempotency)" dpkg_divert: path: "{{ foobarrc }}" state: present - rename: yes + rename: true register: diversion_5 check_mode: true @@ -88,7 +88,7 @@ - diversion_0.commands == diversion_1.commands - diversion_2.commands == diversion_3.commands - diversion_4.commands == diversion_5.commands - quiet: yes + quiet: true ################################################################################ @@ -148,7 +148,7 @@ - diversion_2.diversion == diversion_3.diversion - diversion_0.commands == diversion_1.commands - diversion_2.commands == diversion_3.commands - quiet: yes + quiet: true ################################################################################ @@ -164,7 +164,7 @@ path: "{{ foobarrc }}" holder: "ansible" register: diversion_0 - check_mode: yes + check_mode: true - name: "update foobarrc diversion holder (must report a change)" dpkg_divert: @@ -184,7 +184,7 @@ path: "{{ foobarrc }}" holder: "ansible" register: diversion_3 - check_mode: yes + check_mode: true # Check results @@ -213,7 +213,7 @@ - diversion_2.diversion == diversion_3.diversion - diversion_0.commands == diversion_1.commands - diversion_2.commands == diversion_3.commands - quiet: yes + quiet: true - name: "remove foobarrc diversion" dpkg_divert: @@ -234,7 +234,7 @@ path: "{{ foobarrc }}" divert: "{{ foobarrc_ansible }}" register: diversion_0 - check_mode: yes + check_mode: true - name: "update foobarrc divert path (must report a change)" dpkg_divert: @@ -254,7 +254,7 @@ path: "{{ foobarrc }}" divert: "{{ foobarrc_ansible }}" register: diversion_3 - check_mode: yes + check_mode: true # Check results @@ -283,7 +283,7 @@ - diversion_2.diversion == diversion_3.diversion - diversion_0.commands == diversion_1.commands - diversion_2.commands == diversion_3.commands - quiet: yes + quiet: true - name: "remove foobarrc diversion" dpkg_divert: diff --git a/tests/integration/targets/dpkg_divert/tasks/tests/02-rename.yml b/tests/integration/targets/dpkg_divert/tasks/tests/02-rename.yml index 077004029d..6c95a72912 100644 --- a/tests/integration/targets/dpkg_divert/tasks/tests/02-rename.yml +++ b/tests/integration/targets/dpkg_divert/tasks/tests/02-rename.yml @@ -9,29 +9,29 @@ - name: "create diversion for foobarrc (check mode, rename, must report a change)" dpkg_divert: path: "{{ foobarrc }}" - rename: yes + rename: true register: diversion_0 - check_mode: yes + check_mode: true - name: "create diversion for foobarrc (rename, must report a change)" dpkg_divert: path: "{{ foobarrc }}" - rename: yes + rename: true register: diversion_1 - name: "create diversion for foobarrc (rename, must NOT report a change, idempotency)" dpkg_divert: path: "{{ foobarrc }}" - rename: yes + rename: true register: diversion_2 - name: "create diversion for foobarrc (check mode, rename, must NOT report a change, idempotency)" dpkg_divert: path: "{{ foobarrc }}" - rename: yes + rename: true register: diversion_3 - check_mode: yes + check_mode: true # Get results @@ -60,7 +60,7 @@ - diversion_2.diversion == diversion_3.diversion - diversion_0.commands == diversion_1.commands - diversion_2.commands == diversion_3.commands - quiet: yes + quiet: true ################################################################################ @@ -69,15 +69,15 @@ - name: "remove diversion for foobarrc (check mode, rename, must report a change)" dpkg_divert: path: "{{ foobarrc }}" - rename: yes + rename: true state: absent register: diversion_0 - check_mode: yes + check_mode: true - name: "remove diversion for foobarrc (rename, must report a change)" dpkg_divert: path: "{{ foobarrc }}" - rename: yes + rename: true state: absent register: diversion_1 @@ -85,17 +85,17 @@ - name: "remove diversion for foobarrc (rename, must NOT report a change, idempotency)" dpkg_divert: path: "{{ foobarrc }}" - rename: yes + rename: true state: absent register: diversion_2 - name: "remove diversion for foobarrc (check mode, rename, must NOT report a change, idempotency)" dpkg_divert: path: "{{ foobarrc }}" - rename: yes + rename: true state: absent register: diversion_3 - check_mode: yes + check_mode: true # Check results @@ -124,7 +124,7 @@ - diversion_2.diversion == diversion_3.diversion - diversion_0.commands == diversion_1.commands - diversion_2.commands == diversion_3.commands - quiet: yes + quiet: true ################################################################################ @@ -139,49 +139,49 @@ - name: "create diversion for foobarrc (check mode, rename, must fail)" dpkg_divert: path: "{{ foobarrc }}" - rename: yes + rename: true register: diversion_0 - ignore_errors: yes - check_mode: yes + ignore_errors: true + check_mode: true - name: "create diversion for foobarrc (rename, must fail)" dpkg_divert: path: "{{ foobarrc }}" - rename: yes + rename: true register: diversion_1 - ignore_errors: yes + ignore_errors: true - name: "create diversion for foobarrc (check mode, force rename, must report a change)" dpkg_divert: path: "{{ foobarrc }}" - rename: yes - force: yes + rename: true + force: true register: diversion_2 - check_mode: yes + check_mode: true - name: "create diversion for foobarrc (force rename, must report a change)" dpkg_divert: path: "{{ foobarrc }}" - rename: yes - force: yes + rename: true + force: true register: diversion_3 - name: "create diversion for foobarrc (force rename, must NOT report a change, idempotency)" dpkg_divert: path: "{{ foobarrc }}" - rename: yes - force: yes + rename: true + force: true register: diversion_4 - name: "create diversion for foobarrc (check mode, force rename, must NOT report a change, idempotency)" dpkg_divert: path: "{{ foobarrc }}" - rename: yes - force: yes + rename: true + force: true register: diversion_5 - check_mode: yes + check_mode: true # Check results @@ -213,7 +213,7 @@ - diversion_4.diversion == diversion_5.diversion - diversion_2.commands == diversion_3.commands - diversion_4.commands == diversion_5.commands - quiet: yes + quiet: true ################################################################################ @@ -230,7 +230,7 @@ path: "{{ foobarrc }}" divert: "{{ foobarrc_ansible }}" register: diversion_0 - check_mode: yes + check_mode: true - name: "create diversion for foobarrc (update divert path, must report a change)" dpkg_divert: @@ -250,7 +250,7 @@ path: "{{ foobarrc }}" divert: "{{ foobarrc_ansible }}" register: diversion_3 - check_mode: yes + check_mode: true # Check results @@ -286,7 +286,7 @@ - diversion_2.diversion == diversion_3.diversion - diversion_0.commands == diversion_1.commands - diversion_2.commands == diversion_3.commands - quiet: yes + quiet: true ################################################################################ @@ -296,35 +296,35 @@ dpkg_divert: path: "{{ foobarrc }}" state: absent - rename: yes + rename: true register: diversion_0 - ignore_errors: yes - check_mode: yes + ignore_errors: true + check_mode: true - name: "remove diversion for foobarrc (rename, must fail)" dpkg_divert: path: "{{ foobarrc }}" state: absent - rename: yes + rename: true register: diversion_1 - ignore_errors: yes + ignore_errors: true - name: "remove diversion for foobarrc (check mode, force rename, must report a change)" dpkg_divert: path: "{{ foobarrc }}" state: absent - rename: yes - force: yes + rename: true + force: true register: diversion_2 - check_mode: yes + check_mode: true - name: "remove diversion for foobarrc (force rename, must report a change)" dpkg_divert: path: "{{ foobarrc }}" state: absent - rename: yes - force: yes + rename: true + force: true register: diversion_3 @@ -332,18 +332,18 @@ dpkg_divert: path: "{{ foobarrc }}" state: absent - rename: yes - force: yes + rename: true + force: true register: diversion_4 - name: "remove diversion for foobarrc (check mode, force rename, must NOT report a change, idempotency)" dpkg_divert: path: "{{ foobarrc }}" state: absent - rename: yes - force: yes + rename: true + force: true register: diversion_5 - check_mode: yes + check_mode: true # Check results @@ -381,4 +381,4 @@ - diversion_4.diversion == diversion_5.diversion - diversion_2.commands == diversion_3.commands - diversion_4.commands == diversion_5.commands - quiet: yes + quiet: true diff --git a/tests/integration/targets/filesize/tasks/basics.yml b/tests/integration/targets/filesize/tasks/basics.yml index ac99778a30..3c06731899 100644 --- a/tests/integration/targets/filesize/tasks/basics.yml +++ b/tests/integration/targets/filesize/tasks/basics.yml @@ -14,7 +14,7 @@ path: "{{ filesize_testfile }}" size: 0 register: filesize_test_basic_01 - check_mode: yes + check_mode: true - name: Stat the file (should not exist) ansible.builtin.stat: @@ -39,7 +39,7 @@ path: "{{ filesize_testfile }}" size: 0G register: filesize_test_basic_03 - check_mode: yes + check_mode: true - name: Create an empty file (idempotency) community.general.filesize: @@ -102,7 +102,7 @@ size: 57kB source: /dev/urandom register: filesize_test_basic_11 - check_mode: yes + check_mode: true - name: Stat the file (should still be unchanged) ansible.builtin.stat: @@ -133,7 +133,7 @@ size: 57000B source: /dev/urandom register: filesize_test_basic_13 - check_mode: yes + check_mode: true - name: Fill the file up to 57000B (57kB) with random data (idempotency) community.general.filesize: @@ -183,7 +183,7 @@ path: "{{ filesize_testfile }}" size: 57001B register: filesize_test_basic_21 - check_mode: yes + check_mode: true - name: Stat the file again (should remain the same) ansible.builtin.stat: @@ -208,7 +208,7 @@ path: "{{ filesize_testfile }}" size: 57.001 kB register: filesize_test_basic_23 - check_mode: yes + check_mode: true - name: Expand the file with 1 byte (57.001 kB) (idempotency) community.general.filesize: @@ -259,7 +259,7 @@ path: "{{ filesize_testfile }}" size: 2 MiB register: filesize_test_basic_31 - check_mode: yes + check_mode: true - name: Stat the file again (should remain the same) ansible.builtin.stat: @@ -285,7 +285,7 @@ size: 2 blocksize: 1M register: filesize_test_basic_33 - check_mode: yes + check_mode: true - name: Expand the file up to 2×1M (2*1024*1024 bytes) (idempotency) community.general.filesize: @@ -333,7 +333,7 @@ path: "{{ filesize_testfile }}" size: 57kB register: filesize_test_basic_41 - check_mode: yes + check_mode: true - name: Stat the resulting file (should be unchanged) ansible.builtin.stat: @@ -358,7 +358,7 @@ path: "{{ filesize_testfile }}" size: 57000 B register: filesize_test_basic_43 - check_mode: yes + check_mode: true - name: Truncate the file to 57000 B (57kB) (idempotency) community.general.filesize: diff --git a/tests/integration/targets/filesize/tasks/errors.yml b/tests/integration/targets/filesize/tasks/errors.yml index ba65934e5a..351a90ac6c 100644 --- a/tests/integration/targets/filesize/tasks/errors.yml +++ b/tests/integration/targets/filesize/tasks/errors.yml @@ -11,24 +11,24 @@ community.general.filesize: size: 1kB register: filesize_test_error_01 - ignore_errors: yes + ignore_errors: true - name: Trigger an error due to missing parameter (size) community.general.filesize: path: "{{ filesize_testfile }}" register: filesize_test_error_02 - ignore_errors: yes + ignore_errors: true - name: Trigger an error due to conflicting parameters (force|sparse) community.general.filesize: path: "{{ filesize_testfile }}" size: 1MB - force: yes - sparse: yes + force: true + sparse: true register: filesize_test_error_03 - ignore_errors: yes + ignore_errors: true - name: Trigger an error due to invalid file path (not a file) @@ -36,7 +36,7 @@ path: "{{ filesize_testdir }}" size: 4096B register: filesize_test_error_04 - ignore_errors: yes + ignore_errors: true - name: Trigger an error due to invalid file path (unexisting parent dir) @@ -44,7 +44,7 @@ path: "/unexistent/{{ filesize_testfile }}" size: 4096B register: filesize_test_error_05 - ignore_errors: yes + ignore_errors: true - name: Trigger an error due to invalid size unit (b)" @@ -52,7 +52,7 @@ path: "{{ filesize_testfile }}" size: 4096b register: filesize_test_error_06 - ignore_errors: yes + ignore_errors: true - name: Trigger an error due to invalid size value (bytes require integer) @@ -60,7 +60,7 @@ path: "{{ filesize_testfile }}" size: 1000.5B register: filesize_test_error_07 - ignore_errors: yes + ignore_errors: true - name: Trigger an error due to invalid blocksize value (not an integer) @@ -69,7 +69,7 @@ size: 1M blocksize: "12.5" register: filesize_test_error_08 - ignore_errors: yes + ignore_errors: true - name: Trigger an error due to invalid blocksize value type (dict) @@ -79,7 +79,7 @@ blocksize: bytes: 512 register: filesize_test_error_09 - ignore_errors: yes + ignore_errors: true - name: Trigger an error due to invalid source device (/dev/unexistent) @@ -88,7 +88,7 @@ size: 1M source: /dev/unexistent register: filesize_test_error_10 - ignore_errors: yes + ignore_errors: true - name: Trigger an error due to invalid source device (/dev/null) @@ -97,7 +97,7 @@ size: 1M source: /dev/null register: filesize_test_error_11 - ignore_errors: yes + ignore_errors: true - name: Assert that expected errors have been triggered diff --git a/tests/integration/targets/filesize/tasks/floats.yml b/tests/integration/targets/filesize/tasks/floats.yml index d7b5a4c9a7..6d1bde22c9 100644 --- a/tests/integration/targets/filesize/tasks/floats.yml +++ b/tests/integration/targets/filesize/tasks/floats.yml @@ -14,7 +14,7 @@ path: "{{ filesize_testfile }}" size: 512.512kB register: filesize_test_float_01 - check_mode: yes + check_mode: true - name: Stat the file (should not exist) ansible.builtin.stat: @@ -39,7 +39,7 @@ path: "{{ filesize_testfile }}" size: 0.512512MB register: filesize_test_float_03 - check_mode: yes + check_mode: true - name: Create a file with a size of 0.512512MB (idempotency) community.general.filesize: @@ -95,7 +95,7 @@ path: "{{ filesize_testfile }}" size: 512.513kB register: filesize_test_float_11 - check_mode: yes + check_mode: true - name: Stat the file again (should remain the same) ansible.builtin.stat: @@ -120,7 +120,7 @@ path: "{{ filesize_testfile }}" size: 0.512513MB register: filesize_test_float_13 - check_mode: yes + check_mode: true - name: Create a file with a size of 0.512513MB (idempotency) community.general.filesize: @@ -172,7 +172,7 @@ path: "{{ filesize_testfile }}" size: 4.004MB register: filesize_test_float_21 - check_mode: yes + check_mode: true - name: Stat the file again (should remain the same) ansible.builtin.stat: @@ -197,7 +197,7 @@ path: "{{ filesize_testfile }}" size: 4.004MB register: filesize_test_float_23 - check_mode: yes + check_mode: true - name: Create a file with a size of 4.004MB (idempotency) community.general.filesize: diff --git a/tests/integration/targets/filesize/tasks/sparse.yml b/tests/integration/targets/filesize/tasks/sparse.yml index 9a8a9cfe90..79145b6e23 100644 --- a/tests/integration/targets/filesize/tasks/sparse.yml +++ b/tests/integration/targets/filesize/tasks/sparse.yml @@ -9,14 +9,14 @@ community.general.filesize: path: "{{ filesize_testfile }}" size: 4TB - sparse: yes + sparse: true register: filesize_test_sparse_01 - check_mode: yes + check_mode: true - name: Stat the file (should not exist) ansible.builtin.stat: path: "{{ filesize_testfile }}" - get_checksum: no + get_checksum: false register: filesize_stat_sparse_01 @@ -24,13 +24,13 @@ community.general.filesize: path: "{{ filesize_testfile }}" size: 4TB - sparse: yes + sparse: true register: filesize_test_sparse_02 - name: Stat the resulting file (should exist now) ansible.builtin.stat: path: "{{ filesize_testfile }}" - get_checksum: no + get_checksum: false register: filesize_stat_sparse_02 @@ -38,15 +38,15 @@ community.general.filesize: path: "{{ filesize_testfile }}" size: 4000GB - sparse: yes + sparse: true register: filesize_test_sparse_03 - check_mode: yes + check_mode: true - name: Create a huge sparse file of 4TB (4000GB) (idempotency) community.general.filesize: path: "{{ filesize_testfile }}" size: 4000GB - sparse: yes + sparse: true register: filesize_test_sparse_04 - name: Create a huge sparse file of 4TB (4000000 × 1MB) (check mode, idempotency) @@ -54,22 +54,22 @@ path: "{{ filesize_testfile }}" size: 4000000 blocksize: 1MB - sparse: yes + sparse: true register: filesize_test_sparse_05 - check_mode: yes + check_mode: true - name: Create a huge sparse file of 4TB (4000000 × 1MB) (idempotency) community.general.filesize: path: "{{ filesize_testfile }}" size: 4000000 blocksize: 1MB - sparse: yes + sparse: true register: filesize_test_sparse_06 - name: Stat the file again (should remain the same) ansible.builtin.stat: path: "{{ filesize_testfile }}" - get_checksum: no + get_checksum: false register: filesize_stat_sparse_06 @@ -124,14 +124,14 @@ community.general.filesize: path: "{{ filesize_testfile }}" size: 4TiB - sparse: yes + sparse: true register: filesize_test_sparse_11 - check_mode: yes + check_mode: true - name: Stat the file again (should remain the same) ansible.builtin.stat: path: "{{ filesize_testfile }}" - get_checksum: no + get_checksum: false register: filesize_stat_sparse_11 @@ -139,13 +139,13 @@ community.general.filesize: path: "{{ filesize_testfile }}" size: 4TiB - sparse: yes + sparse: true register: filesize_test_sparse_12 - name: Stat the file again (should have grown) ansible.builtin.stat: path: "{{ filesize_testfile }}" - get_checksum: no + get_checksum: false register: filesize_stat_sparse_12 @@ -153,21 +153,21 @@ community.general.filesize: path: "{{ filesize_testfile }}" size: 4096GiB - sparse: yes + sparse: true register: filesize_test_sparse_13 - check_mode: yes + check_mode: true - name: Change sparse file size to 4TiB (4096GiB) (idempotency) community.general.filesize: path: "{{ filesize_testfile }}" size: 4096GiB - sparse: yes + sparse: true register: filesize_test_sparse_14 - name: Stat the file again (should remain the same) ansible.builtin.stat: path: "{{ filesize_testfile }}" - get_checksum: no + get_checksum: false register: filesize_stat_sparse_14 @@ -203,14 +203,14 @@ community.general.filesize: path: "{{ filesize_testfile }}" size: 4.321TB - sparse: yes + sparse: true register: filesize_test_sparse_21 - check_mode: yes + check_mode: true - name: Stat the file again (should remain the same) ansible.builtin.stat: path: "{{ filesize_testfile }}" - get_checksum: no + get_checksum: false register: filesize_stat_sparse_21 @@ -218,13 +218,13 @@ community.general.filesize: path: "{{ filesize_testfile }}" size: 4.321TB - sparse: yes + sparse: true register: filesize_test_sparse_22 - name: Stat the file again (should have been reduced) ansible.builtin.stat: path: "{{ filesize_testfile }}" - get_checksum: no + get_checksum: false register: filesize_stat_sparse_22 @@ -233,22 +233,22 @@ path: "{{ filesize_testfile }}" size: 4321 blocksize: 1GB - sparse: yes + sparse: true register: filesize_test_sparse_23 - check_mode: yes + check_mode: true - name: Change sparse file size to 4321×1GB (idempotency) community.general.filesize: path: "{{ filesize_testfile }}" size: 4321 blocksize: 1GB - sparse: yes + sparse: true register: filesize_test_sparse_24 - name: Stat the file again (should remain the same) ansible.builtin.stat: path: "{{ filesize_testfile }}" - get_checksum: no + get_checksum: false register: filesize_stat_sparse_24 diff --git a/tests/integration/targets/filesize/tasks/symlinks.yml b/tests/integration/targets/filesize/tasks/symlinks.yml index ee75777101..0118896568 100644 --- a/tests/integration/targets/filesize/tasks/symlinks.yml +++ b/tests/integration/targets/filesize/tasks/symlinks.yml @@ -16,8 +16,8 @@ src: "{{ filesize_testfile | basename }}" dest: "{{ filesize_testlink }}" state: link - force: yes - follow: no + force: true + follow: false @@ -26,7 +26,7 @@ path: "{{ filesize_testlink }}" size: "512 kB" register: filesize_test_symlink_01 - check_mode: yes + check_mode: true - name: Create a file with a size of 512 kB (512000 bytes) community.general.filesize: @@ -45,7 +45,7 @@ path: "{{ filesize_testlink }}" size: "500 KiB" register: filesize_test_symlink_03 - check_mode: yes + check_mode: true - name: Create a file with a size of 500 KiB (512000 bytes) (idempotency) community.general.filesize: diff --git a/tests/integration/targets/filesystem/tasks/create_fs.yml b/tests/integration/targets/filesystem/tasks/create_fs.yml index 82f92f4cc3..d5470fa56b 100644 --- a/tests/integration/targets/filesystem/tasks/create_fs.yml +++ b/tests/integration/targets/filesystem/tasks/create_fs.yml @@ -44,7 +44,7 @@ community.general.filesystem: dev: '{{ dev }}' fstype: '{{ fstype }}' - force: yes + force: true register: fs3_result - name: "Get UUID of the new filesystem" @@ -84,7 +84,7 @@ community.general.filesystem: dev: '{{ dev }}' fstype: '{{ fstype }}' - resizefs: yes + resizefs: true register: fs4_result - name: "Get UUID of the filesystem" @@ -109,7 +109,7 @@ community.general.filesystem: dev: '{{ dev }}' fstype: '{{ fstype }}' - resizefs: yes + resizefs: true register: fs5_result - name: "Assert that the state did not change" diff --git a/tests/integration/targets/filesystem/tasks/overwrite_another_fs.yml b/tests/integration/targets/filesystem/tasks/overwrite_another_fs.yml index 25bc9a0699..de0ad4d66b 100644 --- a/tests/integration/targets/filesystem/tasks/overwrite_another_fs.yml +++ b/tests/integration/targets/filesystem/tasks/overwrite_another_fs.yml @@ -42,7 +42,7 @@ community.general.filesystem: dev: '{{ dev }}' fstype: '{{ fstype }}' - force: yes + force: true register: fs_result2 - name: 'Get UUID of the new filesystem' diff --git a/tests/integration/targets/filesystem/tasks/remove_fs.yml b/tests/integration/targets/filesystem/tasks/remove_fs.yml index aaa78ae563..c5428b309f 100644 --- a/tests/integration/targets/filesystem/tasks/remove_fs.yml +++ b/tests/integration/targets/filesystem/tasks/remove_fs.yml @@ -28,7 +28,7 @@ dev: '{{ dev }}' state: absent register: wipefs - check_mode: yes + check_mode: true - name: "Get filesystem UUID with 'blkid' (should remain the same)" ansible.builtin.shell: @@ -81,7 +81,7 @@ dev: '{{ dev }}' state: absent register: wipefs - check_mode: yes + check_mode: true - name: "Assert that the state did not change" ansible.builtin.assert: diff --git a/tests/integration/targets/filter_counter/tasks/main.yml b/tests/integration/targets/filter_counter/tasks/main.yml index 881d55d2f6..77d6b1b020 100644 --- a/tests/integration/targets/filter_counter/tasks/main.yml +++ b/tests/integration/targets/filter_counter/tasks/main.yml @@ -19,7 +19,7 @@ - name: test fail argument not a sequence debug: msg: "{{ {'a': 'b'} | community.general.counter }}" - ignore_errors: yes + ignore_errors: true register: res - name: verify test fail argument not a sequence @@ -31,7 +31,7 @@ - name: test fail element not hashable debug: msg: "{{ [{'a': 'b'}] | community.general.counter }}" - ignore_errors: yes + ignore_errors: true register: res - name: verify test fail element not hashable diff --git a/tests/integration/targets/filter_random_mac/tasks/main.yml b/tests/integration/targets/filter_random_mac/tasks/main.yml index f9f85e986b..230f9776d5 100644 --- a/tests/integration/targets/filter_random_mac/tasks/main.yml +++ b/tests/integration/targets/filter_random_mac/tasks/main.yml @@ -13,7 +13,7 @@ debug: var: "0 | community.general.random_mac" register: _bad_random_mac_filter - ignore_errors: yes + ignore_errors: true - name: Verify random_mac filter showed a bad argument type error message assert: @@ -25,7 +25,7 @@ debug: var: "'dummy' | community.general.random_mac" register: _bad_random_mac_filter - ignore_errors: yes + ignore_errors: true - name: Verify random_mac filter showed a bad argument value error message assert: @@ -37,7 +37,7 @@ debug: var: "'00:00:00:00:00:00' | community.general.random_mac" register: _bad_random_mac_filter - ignore_errors: yes + ignore_errors: true - name: Verify random_mac filter showed a prefix too big error message assert: diff --git a/tests/integration/targets/filter_time/tasks/main.yml b/tests/integration/targets/filter_time/tasks/main.yml index bd8c53ac31..3b6539499e 100644 --- a/tests/integration/targets/filter_time/tasks/main.yml +++ b/tests/integration/targets/filter_time/tasks/main.yml @@ -81,7 +81,7 @@ - name: test fail unknown unit debug: msg: "{{ '1s' | community.general.to_time_unit('lightyears') }}" - ignore_errors: yes + ignore_errors: true register: res - name: verify test fail unknown unit @@ -93,7 +93,7 @@ - name: test fail unknown string debug: msg: "{{ '1 s' | community.general.to_time_unit('s') }}" - ignore_errors: yes + ignore_errors: true register: res - name: test fail unknown string @@ -105,7 +105,7 @@ - name: test fail unknown kwarg debug: msg: "{{ '1s' | community.general.to_time_unit('s', second=23) }}" - ignore_errors: yes + ignore_errors: true register: res - name: test fail unknown kwarg diff --git a/tests/integration/targets/gandi_livedns/tasks/create_record.yml b/tests/integration/targets/gandi_livedns/tasks/create_record.yml index 9d764a4198..c3f1c17981 100644 --- a/tests/integration/targets/gandi_livedns/tasks/create_record.yml +++ b/tests/integration/targets/gandi_livedns/tasks/create_record.yml @@ -25,7 +25,7 @@ values: "{{ item['values'] }}" ttl: "{{ item.ttl }}" type: "{{ item.type }}" - check_mode: yes + check_mode: true register: result - name: verify test create a dns record in check mode assert: diff --git a/tests/integration/targets/gandi_livedns/tasks/remove_record.yml b/tests/integration/targets/gandi_livedns/tasks/remove_record.yml index 6f497d2375..c4b937fd5a 100644 --- a/tests/integration/targets/gandi_livedns/tasks/remove_record.yml +++ b/tests/integration/targets/gandi_livedns/tasks/remove_record.yml @@ -11,7 +11,7 @@ values: "{{ item.update_values | default(item['values']) }}" type: "{{ item.type }}" state: absent - check_mode: yes + check_mode: true register: result - name: verify test remove a dns record in check mode assert: diff --git a/tests/integration/targets/gandi_livedns/tasks/update_record.yml b/tests/integration/targets/gandi_livedns/tasks/update_record.yml index 7489059de1..a080560a75 100644 --- a/tests/integration/targets/gandi_livedns/tasks/update_record.yml +++ b/tests/integration/targets/gandi_livedns/tasks/update_record.yml @@ -11,7 +11,7 @@ values: "{{ item.update_values | default(item['values']) }}" ttl: "{{ item.update_ttl | default(item.ttl) }}" type: "{{ item.type }}" - check_mode: yes + check_mode: true register: result - name: verify test update in check mode assert: diff --git a/tests/integration/targets/gem/tasks/main.yml b/tests/integration/targets/gem/tasks/main.yml index edf813ba4a..7b975f0351 100644 --- a/tests/integration/targets/gem/tasks/main.yml +++ b/tests/integration/targets/gem/tasks/main.yml @@ -34,7 +34,7 @@ name: gist state: present register: install_gem_result - ignore_errors: yes + ignore_errors: true # when running as root on Fedora, '--install-dir' is set in the os defaults which is # incompatible with '--user-install', we ignore this error for this case only @@ -79,7 +79,7 @@ gem: name: gist state: present - user_install: no + user_install: false register: install_gem_result - name: List gems @@ -115,7 +115,7 @@ name: gist state: present install_dir: "{{ remote_tmp_dir }}/gems" - ignore_errors: yes + ignore_errors: true register: install_gem_fail_result - debug: @@ -132,7 +132,7 @@ gem: name: gist state: present - user_install: no + user_install: false install_dir: "{{ remote_tmp_dir }}/gems" register: install_gem_result @@ -148,13 +148,13 @@ that: - install_gem_result is changed - gem_search.files[0].path is search('gist-[0-9.]+') - ignore_errors: yes + ignore_errors: true - name: Remove a gem in a custom directory gem: name: gist state: absent - user_install: no + user_install: false install_dir: "{{ remote_tmp_dir }}/gems" register: install_gem_result @@ -177,7 +177,7 @@ name: gist state: present bindir: "{{ remote_tmp_dir }}/custom_bindir" - norc: yes + norc: true user_install: no # Avoid conflicts between --install-dir and --user-install when running as root on CentOS / Fedora / RHEL register: install_gem_result @@ -197,7 +197,7 @@ name: gist state: absent bindir: "{{ remote_tmp_dir }}/custom_bindir" - norc: yes + norc: true user_install: no # Avoid conflicts between --install-dir and --user-install when running as root on CentOS / Fedora / RHEL register: install_gem_result diff --git a/tests/integration/targets/git_config/tasks/exclusion_state_list-all.yml b/tests/integration/targets/git_config/tasks/exclusion_state_list-all.yml index d908f6e737..e294a83fb5 100644 --- a/tests/integration/targets/git_config/tasks/exclusion_state_list-all.yml +++ b/tests/integration/targets/git_config/tasks/exclusion_state_list-all.yml @@ -10,7 +10,7 @@ list_all: true state: absent register: result - ignore_errors: yes + ignore_errors: true - name: assert git_config failed assert: diff --git a/tests/integration/targets/git_config/tasks/setup.yml b/tests/integration/targets/git_config/tasks/setup.yml index 0112011bd6..6e5516da57 100644 --- a/tests/integration/targets/git_config/tasks/setup.yml +++ b/tests/integration/targets/git_config/tasks/setup.yml @@ -6,10 +6,10 @@ - name: verify that git is installed so this test can continue command: which git register: git_installed - ignore_errors: yes + ignore_errors: true - name: get git version, only newer than {{git_version_supporting_includes}} has includes option shell: "git --version | grep 'git version' | sed 's/git version //'" register: git_version - ignore_errors: yes + ignore_errors: true ... diff --git a/tests/integration/targets/git_config/tasks/unset_check_mode.yml b/tests/integration/targets/git_config/tasks/unset_check_mode.yml index 52ab4a27f3..39bce33790 100644 --- a/tests/integration/targets/git_config/tasks/unset_check_mode.yml +++ b/tests/integration/targets/git_config/tasks/unset_check_mode.yml @@ -10,7 +10,7 @@ name: "{{ option_name }}" scope: "{{ option_scope }}" state: absent - check_mode: yes + check_mode: true register: unset_result - name: getting value diff --git a/tests/integration/targets/gitlab_group_variable/tasks/main.yml b/tests/integration/targets/gitlab_group_variable/tasks/main.yml index 0f4a93f461..3ba0a176cd 100644 --- a/tests/integration/targets/gitlab_group_variable/tasks/main.yml +++ b/tests/integration/targets/gitlab_group_variable/tasks/main.yml @@ -27,7 +27,7 @@ group: "{{ gitlab_group_name }}" vars: ACCESS_KEY_ID: checkmode - check_mode: yes + check_mode: true register: gitlab_group_variable_state - name: check_mode state must be changed @@ -202,7 +202,7 @@ group: "{{ gitlab_group_name }}" vars: ACCESS_KEY_ID: checkmode - check_mode: yes + check_mode: true register: gitlab_group_variable_state - name: check_mode state must not be changed @@ -665,7 +665,7 @@ variables: - name: delete_me register: gitlab_group_variable_state - ignore_errors: yes + ignore_errors: true - name: verify fail assert: diff --git a/tests/integration/targets/gitlab_project_badge/tasks/main.yml b/tests/integration/targets/gitlab_project_badge/tasks/main.yml index fa8a806efe..dfd0bee75b 100644 --- a/tests/integration/targets/gitlab_project_badge/tasks/main.yml +++ b/tests/integration/targets/gitlab_project_badge/tasks/main.yml @@ -23,7 +23,7 @@ state: present - name: Create Badge (check) - check_mode: yes + check_mode: true gitlab_project_badge: api_url: "{{ gitlab_api_url }}" validate_certs: False @@ -84,7 +84,7 @@ - not gitlab_badge_create_confirmation_task.failed - name: Update Badge (check) - check_mode: yes + check_mode: true gitlab_project_badge: api_url: "{{ gitlab_api_url }}" validate_certs: False @@ -145,7 +145,7 @@ - not gitlab_badge_update_confirmation_task.failed - name: Delete Badge (check) - check_mode: yes + check_mode: true gitlab_project_badge: api_url: "{{ gitlab_api_url }}" validate_certs: False diff --git a/tests/integration/targets/gitlab_project_variable/tasks/main.yml b/tests/integration/targets/gitlab_project_variable/tasks/main.yml index 3c90bfe467..c82671aeae 100644 --- a/tests/integration/targets/gitlab_project_variable/tasks/main.yml +++ b/tests/integration/targets/gitlab_project_variable/tasks/main.yml @@ -27,7 +27,7 @@ project: "{{ gitlab_project_name }}" vars: ACCESS_KEY_ID: checkmode - check_mode: yes + check_mode: true register: gitlab_project_variable_state - name: check_mode state must be changed @@ -202,7 +202,7 @@ project: "{{ gitlab_project_name }}" vars: ACCESS_KEY_ID: checkmode - check_mode: yes + check_mode: true register: gitlab_project_variable_state - name: check_mode state must not be changed @@ -660,7 +660,7 @@ variables: - name: delete_me register: gitlab_project_variable_state - ignore_errors: yes + ignore_errors: true - name: verify fail assert: diff --git a/tests/integration/targets/hg/tasks/main.yml b/tests/integration/targets/hg/tasks/main.yml index a2cb8df903..1ca30459c8 100644 --- a/tests/integration/targets/hg/tasks/main.yml +++ b/tests/integration/targets/hg/tasks/main.yml @@ -12,7 +12,7 @@ - name: determine if mercurial is already installed command: which hg register: has_hg - ignore_errors: yes + ignore_errors: true - name: warn if the underlying system is not capable of running these tests debug: diff --git a/tests/integration/targets/hg/tasks/run-tests.yml b/tests/integration/targets/hg/tasks/run-tests.yml index e38aeae104..928b7cb68d 100644 --- a/tests/integration/targets/hg/tasks/run-tests.yml +++ b/tests/integration/targets/hg/tasks/run-tests.yml @@ -72,8 +72,8 @@ - name: Checkout non-existent repo clone hg: repo: "http://hg.pf.osdn.net/view/a/ak/akasurde/hg_project_test_1" - clone: no - update: no + clone: false + update: false register: hg_result3 ignore_errors: true diff --git a/tests/integration/targets/hg/tasks/uninstall.yml b/tests/integration/targets/hg/tasks/uninstall.yml index 80a28f0623..4a26995ef4 100644 --- a/tests/integration/targets/hg/tasks/uninstall.yml +++ b/tests/integration/targets/hg/tasks/uninstall.yml @@ -25,7 +25,7 @@ dnf: name: mercurial state: absent - autoremove: yes + autoremove: true when: ansible_facts.pkg_mgr == 'dnf' # the yum module does not have an autoremove parameter @@ -37,7 +37,7 @@ package: name: mercurial state: absent - autoremove: yes + autoremove: true when: ansible_facts.pkg_mgr in ['pkgng', 'community.general.pkgng'] - name: uninstall packages which were not originally installed (zypper) diff --git a/tests/integration/targets/homebrew/tasks/main.yml b/tests/integration/targets/homebrew/tasks/main.yml index 07cc81d034..1db3ef1a6a 100644 --- a/tests/integration/targets/homebrew/tasks/main.yml +++ b/tests/integration/targets/homebrew/tasks/main.yml @@ -22,9 +22,9 @@ #- name: Use ignored-pinned option while upgrading all # homebrew: -# upgrade_all: yes +# upgrade_all: true # upgrade_options: ignore-pinned -# become: yes +# become: true # become_user: "{{ brew_stat.stat.pw_name }}" # register: upgrade_option_result # environment: @@ -42,16 +42,16 @@ homebrew: name: "{{ package_name }}" state: absent - update_homebrew: no - become: yes + update_homebrew: false + become: true become_user: "{{ brew_stat.stat.pw_name }}" - name: Install {{ package_name }} package using homebrew homebrew: name: "{{ package_name }}" state: present - update_homebrew: no - become: yes + update_homebrew: false + become: true become_user: "{{ brew_stat.stat.pw_name }}" register: package_result @@ -63,8 +63,8 @@ homebrew: name: "{{ package_name }}" state: present - update_homebrew: no - become: yes + update_homebrew: false + become: true become_user: "{{ brew_stat.stat.pw_name }}" register: package_result @@ -76,8 +76,8 @@ homebrew: name: "{{ package_name }}" state: absent - update_homebrew: no - become: yes + update_homebrew: false + become: true become_user: "{{ brew_stat.stat.pw_name }}" register: package_result @@ -89,8 +89,8 @@ homebrew: name: "{{ package_name }}" state: absent - update_homebrew: no - become: yes + update_homebrew: false + become: true become_user: "{{ brew_stat.stat.pw_name }}" register: package_result diff --git a/tests/integration/targets/homebrew_cask/tasks/main.yml b/tests/integration/targets/homebrew_cask/tasks/main.yml index 9d7ac47b5a..85f2572664 100644 --- a/tests/integration/targets/homebrew_cask/tasks/main.yml +++ b/tests/integration/targets/homebrew_cask/tasks/main.yml @@ -25,7 +25,7 @@ homebrew_cask: name: "{{ cask }}" state: present - become: yes + become: true become_user: "{{ brew_stat.stat.pw_name }}" register: cask_install_result @@ -38,7 +38,7 @@ homebrew_cask: name: "{{ cask }}" state: present - become: yes + become: true become_user: "{{ brew_stat.stat.pw_name }}" register: cask_install_result @@ -53,7 +53,7 @@ name: "{{ cask }}" state: present install_options: force - become: yes + become: true become_user: "{{ brew_stat.stat.pw_name }}" register: cask_install_result @@ -68,6 +68,6 @@ name: "{{ cask }}" state: absent install_options: force - become: yes + become: true become_user: "{{ brew_stat.stat.pw_name }}" - ignore_errors: yes + ignore_errors: true diff --git a/tests/integration/targets/homectl/tasks/main.yml b/tests/integration/targets/homectl/tasks/main.yml index c57052c5d8..93c1089b47 100644 --- a/tests/integration/targets/homectl/tasks/main.yml +++ b/tests/integration/targets/homectl/tasks/main.yml @@ -7,19 +7,19 @@ - name: check systemd version command: "systemctl --version" register: systemd_version - ignore_errors: yes + ignore_errors: true - name: check homectl version command: homectl --version register: homectl_version - ignore_errors: yes + ignore_errors: true - block: - name: Check and start systemd-homed service service: name: systemd-homed.service state: started - enabled: yes + enabled: true - name: Add a user 'james' community.general.homectl: @@ -55,9 +55,9 @@ name: foo password: uq4895738!@#$%dfd state: present - resize: yes + resize: true register: resize_out - ignore_errors: yes + ignore_errors: true - name: Use option 'disksize=1G' without option resize (allowed) community.general.homectl: @@ -66,13 +66,13 @@ state: present disksize: 1G register: disk_out - ignore_errors: yes + ignore_errors: true - name: Try to Create user without giving password community.general.homectl: name: danielle register: danielle_out - ignore_errors: yes + ignore_errors: true - name: remove user 'foobar' without requiring password community.general.homectl: @@ -102,20 +102,20 @@ name: janet state: absent register: user_not_exist - ignore_errors: yes + ignore_errors: true - name: Use check_mode to try and create user 'diana' community.general.homectl: name: diana password: helloworld123!@ state: present - check_mode: yes + check_mode: true register: diana_create_checkmode_out - name: Verify user 'diana' was not created with check_mode command: homectl inspect diana register: user_diana_exists - ignore_errors: yes + ignore_errors: true - name: Try to modify user 'jake' with only noexec mount option in check_mode community.general.homectl: @@ -123,7 +123,7 @@ password: myreallysecurepassword12! state: present mountopts: noexec - check_mode: yes + check_mode: true register: jake_checkmode_out - name: Verify user 'jake' was not modified and still has all mount options @@ -152,8 +152,8 @@ password: incorrectPassword! state: present mountopts: noexec - locked: yes - ignore_errors: yes + locked: true + ignore_errors: true register: jake_incorrect_pass_out - assert: diff --git a/tests/integration/targets/hwc_ecs_instance/tasks/main.yml b/tests/integration/targets/hwc_ecs_instance/tasks/main.yml index 9322558f96..dd70861522 100644 --- a/tests/integration/targets/hwc_ecs_instance/tasks/main.yml +++ b/tests/integration/targets/hwc_ecs_instance/tasks/main.yml @@ -84,7 +84,7 @@ root_volume: volume_type: "SAS" state: present - check_mode: yes + check_mode: true register: result - name: assert changed is true assert: @@ -139,7 +139,7 @@ root_volume: volume_type: "SAS" state: present - check_mode: yes + check_mode: true register: result - name: idemponent assert: @@ -195,7 +195,7 @@ root_volume: volume_type: "SAS" state: absent - check_mode: yes + check_mode: true register: result - name: assert changed is true assert: diff --git a/tests/integration/targets/hwc_evs_disk/tasks/main.yml b/tests/integration/targets/hwc_evs_disk/tasks/main.yml index e691169016..63b7d03f95 100644 --- a/tests/integration/targets/hwc_evs_disk/tasks/main.yml +++ b/tests/integration/targets/hwc_evs_disk/tasks/main.yml @@ -64,7 +64,7 @@ volume_type: "SATA" size: 10 state: absent - check_mode: yes + check_mode: true register: result - name: assert changed is true assert: @@ -91,7 +91,7 @@ volume_type: "SATA" size: 10 state: absent - check_mode: yes + check_mode: true register: result - name: assert changed is false assert: diff --git a/tests/integration/targets/hwc_vpc_eip/tasks/main.yml b/tests/integration/targets/hwc_vpc_eip/tasks/main.yml index 462b5ff93f..bbcefcaa62 100644 --- a/tests/integration/targets/hwc_vpc_eip/tasks/main.yml +++ b/tests/integration/targets/hwc_vpc_eip/tasks/main.yml @@ -49,7 +49,7 @@ size: 1 port_id: "{{ port.id }}" state: present - check_mode: yes + check_mode: true register: result - name: assert changed is true assert: @@ -80,7 +80,7 @@ size: 1 port_id: "{{ port.id }}" state: present - check_mode: yes + check_mode: true register: result - name: idemponent assert: @@ -112,7 +112,7 @@ size: 1 port_id: "{{ port.id }}" state: absent - check_mode: yes + check_mode: true register: result - name: assert changed is true assert: @@ -143,7 +143,7 @@ size: 1 port_id: "{{ port.id }}" state: absent - check_mode: yes + check_mode: true register: result - name: idemponent assert: diff --git a/tests/integration/targets/hwc_vpc_peering_connect/tasks/main.yml b/tests/integration/targets/hwc_vpc_peering_connect/tasks/main.yml index 6a5eb19b89..b8e02a5394 100644 --- a/tests/integration/targets/hwc_vpc_peering_connect/tasks/main.yml +++ b/tests/integration/targets/hwc_vpc_peering_connect/tasks/main.yml @@ -36,7 +36,7 @@ peering_vpc: vpc_id: "{{ vpc2.id }}" state: present - check_mode: yes + check_mode: true register: result - name: assert changed is true assert: @@ -64,7 +64,7 @@ peering_vpc: vpc_id: "{{ vpc2.id }}" state: present - check_mode: yes + check_mode: true register: result - name: idemponent assert: @@ -92,7 +92,7 @@ peering_vpc: vpc_id: "{{ vpc2.id }}" state: absent - check_mode: yes + check_mode: true register: result - name: assert changed is true assert: @@ -119,7 +119,7 @@ peering_vpc: vpc_id: "{{ vpc2.id }}" state: absent - check_mode: yes + check_mode: true register: result - name: assert changed is false assert: diff --git a/tests/integration/targets/hwc_vpc_port/tasks/main.yml b/tests/integration/targets/hwc_vpc_port/tasks/main.yml index d78498cbb6..bb8cf81b0b 100644 --- a/tests/integration/targets/hwc_vpc_port/tasks/main.yml +++ b/tests/integration/targets/hwc_vpc_port/tasks/main.yml @@ -35,7 +35,7 @@ subnet_id: "{{ subnet.id }}" ip_address: "192.168.100.33" state: present - check_mode: yes + check_mode: true register: result - name: assert changed is true assert: @@ -81,7 +81,7 @@ subnet_id: "{{ subnet.id }}" ip_address: "192.168.100.33" state: absent - check_mode: yes + check_mode: true register: result - name: assert changed is true assert: @@ -104,7 +104,7 @@ subnet_id: "{{ subnet.id }}" ip_address: "192.168.100.33" state: absent - check_mode: yes + check_mode: true register: result - name: idemponent assert: diff --git a/tests/integration/targets/hwc_vpc_private_ip/tasks/main.yml b/tests/integration/targets/hwc_vpc_private_ip/tasks/main.yml index 8bfd3e4d82..25972d7e9f 100644 --- a/tests/integration/targets/hwc_vpc_private_ip/tasks/main.yml +++ b/tests/integration/targets/hwc_vpc_private_ip/tasks/main.yml @@ -35,7 +35,7 @@ subnet_id: "{{ subnet.id }}" ip_address: "192.168.100.33" state: present - check_mode: yes + check_mode: true register: result - name: assert changed is true assert: @@ -58,7 +58,7 @@ subnet_id: "{{ subnet.id }}" ip_address: "192.168.100.33" state: present - check_mode: yes + check_mode: true register: result - name: idemponent assert: @@ -82,7 +82,7 @@ subnet_id: "{{ subnet.id }}" ip_address: "192.168.100.33" state: absent - check_mode: yes + check_mode: true register: result - name: assert changed is true assert: @@ -105,7 +105,7 @@ subnet_id: "{{ subnet.id }}" ip_address: "192.168.100.33" state: absent - check_mode: yes + check_mode: true register: result - name: idemponent assert: diff --git a/tests/integration/targets/hwc_vpc_route/tasks/main.yml b/tests/integration/targets/hwc_vpc_route/tasks/main.yml index c7ae7989ca..8e2e2ca825 100644 --- a/tests/integration/targets/hwc_vpc_route/tasks/main.yml +++ b/tests/integration/targets/hwc_vpc_route/tasks/main.yml @@ -43,7 +43,7 @@ vpc_id: "{{ vpc1.id }}" destination: "192.168.0.0/16" next_hop: "{{ connect.id }}" - check_mode: yes + check_mode: true register: result - assert: that: @@ -68,7 +68,7 @@ destination: "192.168.0.0/16" next_hop: "{{ connect.id }}" state: present - check_mode: yes + check_mode: true register: result - name: idemponent assert: @@ -94,7 +94,7 @@ destination: "192.168.0.0/16" next_hop: "{{ connect.id }}" state: absent - check_mode: yes + check_mode: true #---------------------------------------------------------- - name: delete a route hwc_vpc_route: @@ -114,7 +114,7 @@ destination: "192.168.0.0/16" next_hop: "{{ connect.id }}" state: absent - check_mode: yes + check_mode: true register: result - name: not changed assert: diff --git a/tests/integration/targets/hwc_vpc_security_group/tasks/main.yml b/tests/integration/targets/hwc_vpc_security_group/tasks/main.yml index f9d8e5bf76..b6ee25e25b 100644 --- a/tests/integration/targets/hwc_vpc_security_group/tasks/main.yml +++ b/tests/integration/targets/hwc_vpc_security_group/tasks/main.yml @@ -18,7 +18,7 @@ hwc_vpc_security_group: name: "ansible_network_security_group_test" state: present - check_mode: yes + check_mode: true register: result - name: assert changed is true assert: @@ -40,7 +40,7 @@ hwc_vpc_security_group: name: "ansible_network_security_group_test" state: present - check_mode: yes + check_mode: true register: idemponent - name: idemponent assert: @@ -62,7 +62,7 @@ hwc_vpc_security_group: name: "ansible_network_security_group_test" state: absent - check_mode: yes + check_mode: true register: result - name: assert changed is true assert: diff --git a/tests/integration/targets/hwc_vpc_security_group_rule/tasks/main.yml b/tests/integration/targets/hwc_vpc_security_group_rule/tasks/main.yml index 0b7f99fd61..4ce4bafdc4 100644 --- a/tests/integration/targets/hwc_vpc_security_group_rule/tasks/main.yml +++ b/tests/integration/targets/hwc_vpc_security_group_rule/tasks/main.yml @@ -35,7 +35,7 @@ port_range_min: 22 remote_ip_prefix: "0.0.0.0/0" state: present - check_mode: yes + check_mode: true register: result - name: assert changed is true assert: @@ -102,7 +102,7 @@ port_range_min: 22 remote_ip_prefix: "0.0.0.0/0" state: absent - check_mode: yes + check_mode: true register: result - name: assert changed is true assert: diff --git a/tests/integration/targets/hwc_vpc_subnet/tasks/main.yml b/tests/integration/targets/hwc_vpc_subnet/tasks/main.yml index 90243203f6..2eb7980b34 100644 --- a/tests/integration/targets/hwc_vpc_subnet/tasks/main.yml +++ b/tests/integration/targets/hwc_vpc_subnet/tasks/main.yml @@ -32,7 +32,7 @@ name: "ansible_network_subnet_test" dhcp_enable: True state: present - check_mode: yes + check_mode: true register: result - name: assert changed is true assert: @@ -62,7 +62,7 @@ name: "ansible_network_subnet_test" dhcp_enable: True state: present - check_mode: yes + check_mode: true register: result - name: idemponent assert: @@ -92,7 +92,7 @@ name: "ansible_network_subnet_test" dhcp_enable: True state: absent - check_mode: yes + check_mode: true register: result - name: assert changed is true assert: @@ -121,7 +121,7 @@ name: "ansible_network_subnet_test" dhcp_enable: True state: absent - check_mode: yes + check_mode: true register: result - name: idemponent assert: diff --git a/tests/integration/targets/ini_file/tasks/tests/01-value.yml b/tests/integration/targets/ini_file/tasks/tests/01-value.yml index 9670cd20f9..f95f166fe5 100644 --- a/tests/integration/targets/ini_file/tasks/tests/01-value.yml +++ b/tests/integration/targets/ini_file/tasks/tests/01-value.yml @@ -174,7 +174,7 @@ path: "{{ output_file }}" section: mysqld option: skip-name - allow_no_value: yes + allow_no_value: true register: result8 - name: test-value 8 - read content from output file @@ -203,7 +203,7 @@ path: "{{ output_file }}" section: mysqld option: skip-name - allow_no_value: yes + allow_no_value: true register: result9 - name: test-value 9 - assert 'changed' is false @@ -217,7 +217,7 @@ ini_file: path: "{{ output_file }}" section: new_empty_section - allow_no_value: yes + allow_no_value: true register: result10 - name: test-value 10 - assert 'changed' is true and section added @@ -231,7 +231,7 @@ ini_file: path: "{{ output_file }}" section: new_empty_section - allow_no_value: yes + allow_no_value: true register: result11 - name: test-value 11 - assert 'changed' is false @@ -246,7 +246,7 @@ state: absent path: "{{ output_file }}" section: new_empty_section - allow_no_value: yes + allow_no_value: true - name: test-value 12 - test allow_no_value with loop ini_file: @@ -254,7 +254,7 @@ section: mysqld option: "{{ item.o }}" value: "{{ item.v | d(omit) }}" - allow_no_value: yes + allow_no_value: true loop: - { o: "skip-name-resolve" } - { o: "max_connections", v: "500" } @@ -316,7 +316,7 @@ path: "{{ output_file }}" section: mysqld option: skip-name - allow_no_value: yes + allow_no_value: true register: result14 - name: test-value 14 - read content from output file @@ -376,7 +376,7 @@ copy: content: "" dest: "{{ output_file }}" - force: yes + force: true - name: test-value 16 - Ensure "beverage=coke" is created within no section ini_file: diff --git a/tests/integration/targets/ini_file/tasks/tests/02-values.yml b/tests/integration/targets/ini_file/tasks/tests/02-values.yml index 23071ebccc..b19a8799c1 100644 --- a/tests/integration/targets/ini_file/tasks/tests/02-values.yml +++ b/tests/integration/targets/ini_file/tasks/tests/02-values.yml @@ -722,7 +722,7 @@ copy: content: "" dest: "{{ output_file }}" - force: yes + force: true - name: "test-values 25 - Ensure 'beverage=[coke, pepsi]' is created within no section" ini_file: diff --git a/tests/integration/targets/iptables_state/tasks/main.yml b/tests/integration/targets/iptables_state/tasks/main.yml index 8ed0b46d0e..a74e74df48 100644 --- a/tests/integration/targets/iptables_state/tasks/main.yml +++ b/tests/integration/targets/iptables_state/tasks/main.yml @@ -12,7 +12,7 @@ package: name: - iptables - become: yes + become: true - name: include tasks @@ -35,4 +35,4 @@ - xtables_lock is undefined - ansible_connection in ['ssh', 'paramiko', 'smart'] - become: yes + become: true diff --git a/tests/integration/targets/iptables_state/tasks/tests/00-basic.yml b/tests/integration/targets/iptables_state/tasks/tests/00-basic.yml index 722f362da9..7b366edcec 100644 --- a/tests/integration/targets/iptables_state/tasks/tests/00-basic.yml +++ b/tests/integration/targets/iptables_state/tasks/tests/00-basic.yml @@ -22,14 +22,14 @@ iptables_state: name: foobar register: iptables_state - ignore_errors: yes + ignore_errors: true - name: "assert that results are as expected" assert: that: - iptables_state is failed - iptables_state.msg is match("Invalid options") - quiet: yes + quiet: true @@ -37,14 +37,14 @@ iptables_state: path: foobar register: iptables_state - ignore_errors: yes + ignore_errors: true - name: "assert that results are as expected" assert: that: - iptables_state is failed - iptables_state.msg is match("missing required arguments") - quiet: yes + quiet: true @@ -52,14 +52,14 @@ iptables_state: state: saved register: iptables_state - ignore_errors: yes + ignore_errors: true - name: "assert that results are as expected" assert: that: - iptables_state is failed - iptables_state.msg is match("missing required arguments") - quiet: yes + quiet: true @@ -68,14 +68,14 @@ path: foobar state: present register: iptables_state - ignore_errors: yes + ignore_errors: true - name: "assert that results are as expected" assert: that: - iptables_state is failed - iptables_state.msg is match("value of state must be one of") - quiet: yes + quiet: true # @@ -89,14 +89,14 @@ path: "{{ iptables_saved }}" state: saved register: iptables_state - check_mode: yes + check_mode: true - name: "assert that results are as expected" assert: that: - iptables_state is changed - iptables_state.initial_state == iptables_state.saved - quiet: yes + quiet: true @@ -111,7 +111,7 @@ that: - iptables_state is changed - iptables_state.initial_state == iptables_state.saved - quiet: yes + quiet: true @@ -126,7 +126,7 @@ that: - iptables_state is not changed - iptables_state.initial_state == iptables_state.saved - quiet: yes + quiet: true @@ -135,14 +135,14 @@ path: "{{ iptables_saved }}" state: saved register: iptables_state - check_mode: yes + check_mode: true - name: "assert that results are as expected" assert: that: - iptables_state is not changed - iptables_state.initial_state == iptables_state.saved - quiet: yes + quiet: true @@ -157,14 +157,14 @@ path: "{{ iptables_saved }}" state: restored register: iptables_state - check_mode: yes + check_mode: true - name: "assert that results are as expected" assert: that: - iptables_state is not changed - iptables_state.initial_state == iptables_state.restored - quiet: yes + quiet: true rescue: - name: "assert that results are not as expected for only one reason (xtables lock)" @@ -172,7 +172,7 @@ that: - iptables_state is failed - iptables_state.stderr is search('xtables lock') - quiet: yes + quiet: true register: xtables_lock @@ -190,7 +190,7 @@ that: - iptables_state is not changed - iptables_state.initial_state == iptables_state.restored - quiet: yes + quiet: true rescue: - name: "assert that results are not as expected for only one reason (xtables lock)" @@ -198,7 +198,7 @@ that: - iptables_state is failed - iptables_state.stderr is search('xtables lock') - quiet: yes + quiet: true register: xtables_lock @@ -217,14 +217,14 @@ path: "{{ iptables_saved }}" state: restored register: iptables_state - check_mode: yes + check_mode: true - name: "assert that results are as expected" assert: that: - iptables_state is changed - iptables_state.initial_state != iptables_state.restored - quiet: yes + quiet: true rescue: - name: "assert that results are not as expected for only one reason (xtables lock)" @@ -232,7 +232,7 @@ that: - iptables_state is failed - iptables_state.stderr is search('xtables lock') - quiet: yes + quiet: true register: xtables_lock @@ -253,7 +253,7 @@ - iptables_state is changed - iptables_state.initial_state != iptables_state.restored - iptables_state.applied - quiet: yes + quiet: true rescue: - name: "assert that results are not as expected for only one reason (xtables lock)" @@ -261,7 +261,7 @@ that: - iptables_state is failed - iptables_state.stderr is search('xtables lock') - quiet: yes + quiet: true register: xtables_lock @@ -281,7 +281,7 @@ that: - iptables_state is not changed - iptables_state.initial_state == iptables_state.restored - quiet: yes + quiet: true rescue: - name: "assert that results are not as expected for only one reason (xtables lock)" @@ -289,7 +289,7 @@ that: - iptables_state is failed - iptables_state.stderr is search('xtables lock') - quiet: yes + quiet: true register: xtables_lock @@ -301,14 +301,14 @@ path: "{{ iptables_saved }}" state: restored register: iptables_state - check_mode: yes + check_mode: true - name: "assert that results are as expected" assert: that: - iptables_state is not changed - iptables_state.initial_state == iptables_state.restored - quiet: yes + quiet: true rescue: - name: "assert that results are not as expected for only one reason (xtables lock)" @@ -316,5 +316,5 @@ that: - iptables_state is failed - iptables_state.stderr is search('xtables lock') - quiet: yes + quiet: true register: xtables_lock diff --git a/tests/integration/targets/iptables_state/tasks/tests/01-tables.yml b/tests/integration/targets/iptables_state/tasks/tests/01-tables.yml index 929928c8e7..8a9869c437 100644 --- a/tests/integration/targets/iptables_state/tasks/tests/01-tables.yml +++ b/tests/integration/targets/iptables_state/tasks/tests/01-tables.yml @@ -17,7 +17,7 @@ path: "{{ iptables_saved }}" register: iptables_state changed_when: false - check_mode: yes + check_mode: true - name: "assert that results are as expected" assert: @@ -25,7 +25,7 @@ - "'*filter' in iptables_state.initial_state" - iptables_state.tables.filter is defined - iptables_state.tables.nat is undefined - quiet: yes + quiet: true @@ -36,7 +36,7 @@ path: "{{ iptables_saved }}" register: iptables_state changed_when: false - check_mode: yes + check_mode: true - name: "assert that results are as expected" assert: @@ -45,7 +45,7 @@ - "'*filter' in iptables_state.initial_state" - iptables_state.tables.nat is defined - iptables_state.tables.filter is undefined - quiet: yes + quiet: true @@ -65,7 +65,7 @@ - "'*nat' not in iptables_state.saved" - iptables_state.tables.filter is defined - iptables_state.tables.nat is undefined - quiet: yes + quiet: true @@ -86,7 +86,7 @@ - "'*filter' not in iptables_state.saved" - iptables_state.tables.nat is defined - iptables_state.tables.filter is undefined - quiet: yes + quiet: true @@ -106,7 +106,7 @@ - "'*nat' in iptables_state.saved" - iptables_state.tables.filter is defined - iptables_state.tables.nat is defined - quiet: yes + quiet: true @@ -129,7 +129,7 @@ - iptables_state.tables.nat is defined - iptables_state.tables.filter is undefined - iptables_state is not changed - quiet: yes + quiet: true @@ -163,7 +163,7 @@ - "'-A INPUT -j ACCEPT' not in iptables_state.restored" - iptables_state.tables.filter is undefined - iptables_state is changed - quiet: yes + quiet: true @@ -176,7 +176,7 @@ - raw - mangle changed_when: false - check_mode: yes + check_mode: true @@ -197,7 +197,7 @@ - "'*nat' in iptables_state.saved" - "'raw' in iptables_state.tables" - "'*raw' in iptables_state.saved" - quiet: yes + quiet: true @@ -239,7 +239,7 @@ - "'*nat' not in iptables_state.restored" - "'*raw' not in iptables_state.restored" - iptables_state is not changed - quiet: yes + quiet: true @@ -267,7 +267,7 @@ - "'*nat' in iptables_state.restored" - "'*raw' in iptables_state.restored" - iptables_state is not changed - quiet: yes + quiet: true @@ -279,7 +279,7 @@ register: iptables_state async: "{{ ansible_timeout }}" poll: 0 - ignore_errors: yes + ignore_errors: true - name: "explain expected failure" assert: diff --git a/tests/integration/targets/iptables_state/tasks/tests/10-rollback.yml b/tests/integration/targets/iptables_state/tasks/tests/10-rollback.yml index af49482114..53fdd3ca03 100644 --- a/tests/integration/targets/iptables_state/tasks/tests/10-rollback.yml +++ b/tests/integration/targets/iptables_state/tasks/tests/10-rollback.yml @@ -18,7 +18,7 @@ path: "{{ iptables_tests }}" state: restored register: iptables_state - check_mode: yes + check_mode: true - name: "assert that results are as expected" assert: diff --git a/tests/integration/targets/ipwcli_dns/tasks/main.yml b/tests/integration/targets/ipwcli_dns/tasks/main.yml index ca47b4dece..9cbb4edc2e 100644 --- a/tests/integration/targets/ipwcli_dns/tasks/main.yml +++ b/tests/integration/targets/ipwcli_dns/tasks/main.yml @@ -83,7 +83,7 @@ username: '{{ username }}' password: '{{ password }}' register: result - ignore_errors: yes + ignore_errors: true - name: assert the failure of the new SRV record assert: @@ -105,7 +105,7 @@ flags: S username: '{{ username }}' password: '{{ password }}' - check_mode: yes + check_mode: true register: result - name: assert the NAPTR check_mode diff --git a/tests/integration/targets/iso_create/tasks/main.yml b/tests/integration/targets/iso_create/tasks/main.yml index 4d321c2d23..a719e91d8e 100644 --- a/tests/integration/targets/iso_create/tasks/main.yml +++ b/tests/integration/targets/iso_create/tasks/main.yml @@ -35,7 +35,7 @@ dest_iso: "{{ output_test_dir }}/test.iso" interchange_level: 3 register: iso_result - check_mode: yes + check_mode: true - debug: var=iso_result - name: Check if iso file created diff --git a/tests/integration/targets/iso_extract/tasks/7zip.yml b/tests/integration/targets/iso_extract/tasks/7zip.yml index 3d3c12250a..b16f202398 100644 --- a/tests/integration/targets/iso_extract/tasks/7zip.yml +++ b/tests/integration/targets/iso_extract/tasks/7zip.yml @@ -7,7 +7,7 @@ - name: Gather facts setup: - become: yes + become: true - name: Include distribution specific variables include_vars: "{{ lookup('first_found', params) }}" @@ -45,8 +45,8 @@ homebrew: name: p7zip state: present - update_homebrew: no - become: yes + update_homebrew: false + become: true become_user: "{{ brew_stat.stat.pw_name }}" # Newer versions of brew want to compile a package which takes a long time. Do not upgrade homebrew until a # proper solution can be found diff --git a/tests/integration/targets/iso_extract/tasks/main.yml b/tests/integration/targets/iso_extract/tasks/main.yml index 4a7097de8a..67ebfa7ab6 100644 --- a/tests/integration/targets/iso_extract/tasks/main.yml +++ b/tests/integration/targets/iso_extract/tasks/main.yml @@ -29,7 +29,7 @@ - name: Test in normal mode import_tasks: tests.yml vars: - in_check_mode: no + in_check_mode: false - name: Prepare environment import_tasks: prepare.yml @@ -37,7 +37,7 @@ - name: Test in check-mode import_tasks: tests.yml vars: - in_check_mode: yes - check_mode: yes + in_check_mode: true + check_mode: true # FIXME - fill this in after figuring out how to allow mounts diff --git a/tests/integration/targets/java_cert/tasks/main.yml b/tests/integration/targets/java_cert/tasks/main.yml index 54d205c255..25ec87e8f9 100644 --- a/tests/integration/targets/java_cert/tasks/main.yml +++ b/tests/integration/targets/java_cert/tasks/main.yml @@ -24,7 +24,7 @@ cert_alias: default keystore_path: "{{ remote_tmp_dir }}/{{ test_keystore_path }}" keystore_pass: changeme_keystore - keystore_create: yes + keystore_create: true state: present register: result_success @@ -41,7 +41,7 @@ cert_alias: default_new keystore_path: "{{ remote_tmp_dir }}/{{ test_keystore_path }}" keystore_pass: changeme_keystore - keystore_create: yes + keystore_create: true state: present ignore_errors: true register: result_wrong_pass @@ -58,7 +58,7 @@ cert_alias: default keystore_path: "{{ remote_tmp_dir }}/{{ test_keystore_path }}" keystore_pass: changeme_keystore - keystore_create: yes + keystore_create: true state: present ignore_errors: true register: result_excl_params diff --git a/tests/integration/targets/java_cert/tasks/state_change.yml b/tests/integration/targets/java_cert/tasks/state_change.yml index 114c51ef58..e135a60a3e 100644 --- a/tests/integration/targets/java_cert/tasks/state_change.yml +++ b/tests/integration/targets/java_cert/tasks/state_change.yml @@ -117,7 +117,7 @@ pkcs12_password: "{{ test_keystore2_password }}" keystore_path: "{{ test_keystore2_path }}" keystore_pass: "{{ test_keystore2_password }}" - keystore_create: yes + keystore_create: true - name: List newly created keystore content ansible.builtin.command: @@ -138,8 +138,8 @@ pkcs12_password: "{{ test_keystore2_password }}" keystore_path: "{{ test_keystore2_path }}" keystore_pass: "{{ test_keystore2_password }}" - keystore_create: yes - ignore_errors: yes + keystore_create: true + ignore_errors: true register: result_x509_changed - name: Verify the x509 status is failed @@ -153,7 +153,7 @@ cert_path: "{{ test_cert_path }}" keystore_path: "{{ test_keystore2_path }}" keystore_pass: "{{ test_keystore2_password }}" - keystore_create: yes + keystore_create: true state: present register: result_x509_changed diff --git a/tests/integration/targets/java_keystore/tasks/tests.yml b/tests/integration/targets/java_keystore/tasks/tests.yml index a3d6ebf7d9..899fe27e85 100644 --- a/tests/integration/targets/java_keystore/tasks/tests.yml +++ b/tests/integration/targets/java_keystore/tasks/tests.yml @@ -46,7 +46,7 @@ loop: "{{ java_keystore_certs }}" loop_control: index_var: loop_index - check_mode: yes + check_mode: true register: result_check - name: Create a Java keystore for the given certificates @@ -62,7 +62,7 @@ loop: "{{ java_keystore_certs }}" loop_control: index_var: loop_index - check_mode: yes + check_mode: true register: result_idem_check - name: Create a Java keystore for the given certificates (idempotency) @@ -102,7 +102,7 @@ loop: "{{ java_keystore_new_certs }}" loop_control: index_var: loop_index - check_mode: yes + check_mode: true register: result_change_check - name: Create a Java keystore for the given certificates (certificate changed) @@ -120,7 +120,7 @@ loop: "{{ java_keystore_new_certs }}" loop_control: index_var: loop_index - check_mode: yes + check_mode: true register: result_alias_change_check - name: Create a Java keystore for the given certificates (alias changed) @@ -141,7 +141,7 @@ loop: "{{ java_keystore_new_certs }}" loop_control: index_var: loop_index - check_mode: yes + check_mode: true register: result_pw_change_check - name: Create a Java keystore for the given certificates (password changed) @@ -164,7 +164,7 @@ loop: "{{ java_keystore_new_certs }}" loop_control: index_var: loop_index - check_mode: yes + check_mode: true register: result_type_pkcs12_check - name: Create a Java keystore for the given certificates (force keystore type jks, check mode) @@ -176,7 +176,7 @@ loop: "{{ java_keystore_new_certs }}" loop_control: index_var: loop_index - check_mode: yes + check_mode: true register: result_type_jks_check - name: Create a Java keystore for the given certificates (force keystore type jks) @@ -225,7 +225,7 @@ loop: "{{ java_keystore_new_certs }}" loop_control: index_var: loop_index - check_mode: yes + check_mode: true register: result_type_change_check - name: Create a Java keystore for the given certificates (keystore type changed) @@ -248,7 +248,7 @@ loop: "{{ java_keystore_new_certs }}" loop_control: index_var: loop_index - check_mode: yes + check_mode: true register: result_type_omit_check - name: Create a Java keystore for the given certificates (omit keystore type) diff --git a/tests/integration/targets/jboss/tasks/jboss.yml b/tests/integration/targets/jboss/tasks/jboss.yml index 13d0c6bc70..2403a02c4f 100644 --- a/tests/integration/targets/jboss/tasks/jboss.yml +++ b/tests/integration/targets/jboss/tasks/jboss.yml @@ -48,7 +48,7 @@ test_deployment: helloworld-1.war task_parameters: &task_parameters become_user: '{{ wf_user }}' - become: yes + become: true register: result block: @@ -67,7 +67,7 @@ jboss: deployment: '{{ war_file_1 }}' src: '{{ war_file_1_path }}' - check_mode: yes + check_mode: true - assert: that: @@ -78,7 +78,7 @@ <<: *task_parameters file: path: '{{ deploy_dir }}/{{ war_file_1 }}.deployed' - ignore_errors: yes + ignore_errors: true - assert: that: @@ -113,7 +113,7 @@ deployment: '{{ war_file_1 }}' src: '{{ war_file_1_path }}' deploy_path: '{{ deploy_dir }}' - check_mode: yes + check_mode: true - assert: that: @@ -148,7 +148,7 @@ deployment: '{{ war_file_1 }}' deploy_path: '{{ deploy_dir }}' state: absent - check_mode: yes + check_mode: true - assert: that: @@ -191,7 +191,7 @@ deployment: '{{ war_file_1 }}' deploy_path: '{{ deploy_dir }}' state: absent - check_mode: yes + check_mode: true - assert: that: @@ -217,7 +217,7 @@ deploy_path: '{{ deploy_dir }}' src: '{{ fake_src_path }}' state: present - ignore_errors: yes + ignore_errors: true - assert: that: @@ -230,7 +230,7 @@ jboss: deployment: '{{ war_file_1 }}' state: present - ignore_errors: yes + ignore_errors: true - assert: that: diff --git a/tests/integration/targets/keycloak_client/tasks/main.yml b/tests/integration/targets/keycloak_client/tasks/main.yml index 933f00bd15..513d5836b8 100644 --- a/tests/integration/targets/keycloak_client/tasks/main.yml +++ b/tests/integration/targets/keycloak_client/tasks/main.yml @@ -45,7 +45,7 @@ - name: Check client again with same props community.general.keycloak_client: "{{ auth_args | combine(call_args) }}" - check_mode: yes + check_mode: true vars: call_args: realm: "{{ realm }}" diff --git a/tests/integration/targets/launchd/tasks/setup.yml b/tests/integration/targets/launchd/tasks/setup.yml index 1df9667bf9..bd7134cc07 100644 --- a/tests/integration/targets/launchd/tasks/setup.yml +++ b/tests/integration/targets/launchd/tasks/setup.yml @@ -7,7 +7,7 @@ template: src: "{{ launchd_service_name }}.plist.j2" dest: "{{ launchd_plist_location }}" - become: yes + become: true - name: install the test daemon script copy: @@ -20,4 +20,4 @@ path: /usr/local/sbin/ansible_test_service line: "#!{{ ansible_python_interpreter | realpath }}" insertbefore: BOF - firstmatch: yes + firstmatch: true diff --git a/tests/integration/targets/launchd/tasks/teardown.yml b/tests/integration/targets/launchd/tasks/teardown.yml index e781757050..e364056e6d 100644 --- a/tests/integration/targets/launchd/tasks/teardown.yml +++ b/tests/integration/targets/launchd/tasks/teardown.yml @@ -7,7 +7,7 @@ launchd: name: "{{ launchd_service_name }}" state: unloaded - become: yes + become: true register: launchd_unloaded_result - name: "[{{ item }}] Validation" @@ -21,10 +21,10 @@ file: path: "{{ launchd_plist_location }}" state: absent - become: yes + become: true - name: "[{{ item }}] Remove test service server" file: path: "/usr/local/sbin/ansible_test_service" state: absent - become: yes + become: true diff --git a/tests/integration/targets/launchd/tasks/tests/test_reload.yml b/tests/integration/targets/launchd/tasks/tests/test_reload.yml index df2c1be9fa..04dc8ae72d 100644 --- a/tests/integration/targets/launchd/tasks/tests/test_reload.yml +++ b/tests/integration/targets/launchd/tasks/tests/test_reload.yml @@ -9,9 +9,9 @@ launchd: name: "{{ launchd_service_name }}" state: started - become: yes + become: true register: "test_1_launchd_start_result_check_mode" - check_mode: yes + check_mode: true - name: "[{{ item }}] Assert that everything work in check mode" assert: @@ -23,7 +23,7 @@ launchd: name: "{{ launchd_service_name }}" state: started - become: yes + become: true register: "test_1_launchd_start_result" @@ -37,13 +37,13 @@ template: src: "modified.{{ launchd_service_name }}.plist.j2" dest: "{{ launchd_plist_location }}" - become: yes + become: true - name: "[{{ item }}] When reloading the service..." launchd: name: "{{ launchd_service_name }}" state: reloaded - become: yes + become: true register: "test_1_launchd_reload_result" - name: "[{{ item }}] Validate that service was reloaded" @@ -60,7 +60,7 @@ launchd: name: "{{ launchd_service_name }}" state: started - become: yes + become: true register: "test_1_launchd_start_result" diff --git a/tests/integration/targets/launchd/tasks/tests/test_restart.yml b/tests/integration/targets/launchd/tasks/tests/test_restart.yml index 08ef62d919..44064cef12 100644 --- a/tests/integration/targets/launchd/tasks/tests/test_restart.yml +++ b/tests/integration/targets/launchd/tasks/tests/test_restart.yml @@ -9,7 +9,7 @@ launchd: name: "{{ launchd_service_name }}" state: started - become: yes + become: true register: "test_1_launchd_start_result" @@ -17,9 +17,9 @@ launchd: name: "{{ launchd_service_name }}" state: restarted - become: yes + become: true register: "test_1_launchd_restart_result_check_mode" - check_mode: yes + check_mode: true - name: "[{{ item }}] Validate that service was restarted in check mode" assert: @@ -31,7 +31,7 @@ launchd: name: "{{ launchd_service_name }}" state: restarted - become: yes + become: true register: "test_1_launchd_restart_result" - name: "[{{ item }}] Validate that service was restarted" diff --git a/tests/integration/targets/launchd/tasks/tests/test_runatload.yml b/tests/integration/targets/launchd/tasks/tests/test_runatload.yml index 03059fc884..87c72d5329 100644 --- a/tests/integration/targets/launchd/tasks/tests/test_runatload.yml +++ b/tests/integration/targets/launchd/tasks/tests/test_runatload.yml @@ -9,8 +9,8 @@ launchd: name: "{{ launchd_service_name }}" state: started - enabled: yes - become: yes + enabled: true + become: true register: test_1_launchd_start_result - name: "[{{ item }}] Validate that service was started" @@ -31,6 +31,6 @@ \s+RunAtLoad \s+ replace: found_run_at_load - check_mode: yes + check_mode: true register: contents_would_have failed_when: not contents_would_have is changed diff --git a/tests/integration/targets/launchd/tasks/tests/test_start_stop.yml b/tests/integration/targets/launchd/tasks/tests/test_start_stop.yml index 2a78f89c12..bf59979aaf 100644 --- a/tests/integration/targets/launchd/tasks/tests/test_start_stop.yml +++ b/tests/integration/targets/launchd/tasks/tests/test_start_stop.yml @@ -9,9 +9,9 @@ launchd: name: "{{ launchd_service_name }}" state: started - become: yes + become: true register: "test_1_launchd_start_result_check_mode" - check_mode: yes + check_mode: true - name: "[{{ item }}] Validate that service was started in check mode" @@ -25,7 +25,7 @@ launchd: name: "{{ launchd_service_name }}" state: started - become: yes + become: true register: "test_1_launchd_start_result" @@ -46,7 +46,7 @@ launchd: name: "{{ launchd_service_name }}" state: stopped - become: yes + become: true register: "test_2_launchd_stop_result" - name: "[{{ item }}] Validate that service was stopped after it was started" @@ -65,7 +65,7 @@ launchd: name: "{{ launchd_service_name }}" state: stopped - become: yes + become: true register: "test_3_launchd_stop_result" - name: "[{{ item }}] Validate that service can be stopped after being already stopped" @@ -84,7 +84,7 @@ launchd: name: "{{ launchd_service_name }}" state: started - become: yes + become: true register: "test_4_launchd_start_result" - name: "[{{ item }}] Validate that service was started..." @@ -102,7 +102,7 @@ launchd: name: "{{ launchd_service_name }}" state: started - become: yes + become: true register: "test_5_launchd_start_result" - name: "[{{ item }}] Validate that service is still in the same state as before" diff --git a/tests/integration/targets/launchd/tasks/tests/test_unload.yml b/tests/integration/targets/launchd/tasks/tests/test_unload.yml index aee9d8b5ee..8915aac8b6 100644 --- a/tests/integration/targets/launchd/tasks/tests/test_unload.yml +++ b/tests/integration/targets/launchd/tasks/tests/test_unload.yml @@ -9,7 +9,7 @@ launchd: name: "{{ launchd_service_name }}" state: started - become: yes + become: true register: "test_1_launchd_start_result" @@ -17,9 +17,9 @@ launchd: name: "{{ launchd_service_name }}" state: unloaded - become: yes + become: true register: "test_1_launchd_unloaded_result_check_mode" - check_mode: yes + check_mode: true - name: "[{{ item }}] Validate that service was unloaded in check mode" assert: @@ -32,7 +32,7 @@ launchd: name: "{{ launchd_service_name }}" state: unloaded - become: yes + become: true register: "test_1_launchd_unloaded_result" - name: "[{{ item }}] Validate that service was unloaded" @@ -51,7 +51,7 @@ launchd: name: "{{ launchd_service_name }}" state: unloaded - become: yes + become: true register: "test_2_launchd_unloaded_result" - name: "[{{ item }}] Validate that service did not change and is still unloaded" diff --git a/tests/integration/targets/ldap_search/tasks/tests/basic.yml b/tests/integration/targets/ldap_search/tasks/tests/basic.yml index ab6c745277..36d245d396 100644 --- a/tests/integration/targets/ldap_search/tasks/tests/basic.yml +++ b/tests/integration/targets/ldap_search/tasks/tests/basic.yml @@ -14,7 +14,7 @@ dn: "ou=users,dc=example,dc=com" scope: "onelevel" filter: "(uid=ldaptest)" - ignore_errors: yes + ignore_errors: true register: output - name: assert that test LDAP user can be found diff --git a/tests/integration/targets/lookup_dig/tasks/main.yml b/tests/integration/targets/lookup_dig/tasks/main.yml index 5c0ebeb761..2f48333cb0 100644 --- a/tests/integration/targets/lookup_dig/tasks/main.yml +++ b/tests/integration/targets/lookup_dig/tasks/main.yml @@ -29,7 +29,7 @@ - name: Test dig lookup with non-existing domain and fail_on_error=yes set_fact: dig_nonexisting_fail_yes: "{{ lookup('community.general.dig', 'non-existing.domain.', 'fail_on_error=yes') }}" - ignore_errors: yes + ignore_errors: true register: dig_nonexisting_fail_yes_result - name: Verify that the task failed diff --git a/tests/integration/targets/lookup_passwordstore/tasks/package.yml b/tests/integration/targets/lookup_passwordstore/tasks/package.yml index 89d750ee6d..3623101c86 100644 --- a/tests/integration/targets/lookup_passwordstore/tasks/package.yml +++ b/tests/integration/targets/lookup_passwordstore/tasks/package.yml @@ -32,14 +32,14 @@ package: name: password-store state: present - update_cache: yes - disable_gpg_check: yes + update_cache: true + disable_gpg_check: true when: ansible_facts.pkg_mgr in ['zypper', 'community.general.zypper'] # See https://github.com/gopasspw/gopass/issues/1849#issuecomment-802789285 - name: Install gopass on Debian when: ansible_facts.os_family == 'Debian' - become: yes + become: true block: - name: Fetch gopass repo keyring ansible.builtin.get_url: @@ -54,7 +54,7 @@ - name: Update apt-cache and install gopass package ansible.builtin.apt: name: gopass - update_cache: yes + update_cache: true - name: Install on macOS when: ansible_facts.distribution == 'MacOSX' @@ -75,8 +75,8 @@ - pass - gopass state: present - update_homebrew: no - become: yes + update_homebrew: false + become: true become_user: "{{ brew_stat.stat.pw_name }}" # Newer versions of brew want to compile a package which takes a long time. Do not upgrade homebrew until a # proper solution can be found diff --git a/tests/integration/targets/lookup_passwordstore/tasks/tests.yml b/tests/integration/targets/lookup_passwordstore/tasks/tests.yml index 583aafd108..65a578c962 100644 --- a/tests/integration/targets/lookup_passwordstore/tasks/tests.yml +++ b/tests/integration/targets/lookup_passwordstore/tasks/tests.yml @@ -14,7 +14,7 @@ - name: Stop gpg-agent so we can remove any locks on the GnuPG dir command: gpgconf --kill gpg-agent - ignore_errors: yes + ignore_errors: true - name: Remove previous password files and directory file: diff --git a/tests/integration/targets/lookup_random_pet/test.yml b/tests/integration/targets/lookup_random_pet/test.yml index 31ce38c4d0..c61461867a 100644 --- a/tests/integration/targets/lookup_random_pet/test.yml +++ b/tests/integration/targets/lookup_random_pet/test.yml @@ -4,7 +4,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later - hosts: localhost - gather_facts: no + gather_facts: false tasks: - name: Call plugin set_fact: diff --git a/tests/integration/targets/lookup_random_string/test.yml b/tests/integration/targets/lookup_random_string/test.yml index 2ce57ad2cb..b1f6234102 100644 --- a/tests/integration/targets/lookup_random_string/test.yml +++ b/tests/integration/targets/lookup_random_string/test.yml @@ -4,7 +4,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later - hosts: localhost - gather_facts: no + gather_facts: false tasks: - name: Call plugin set_fact: @@ -25,7 +25,7 @@ - name: Raise error when impossible constraints are provided set_fact: impossible: "{{ query('community.general.random_string', upper=false, lower=false, special=false, numbers=false) }}" - ignore_errors: yes + ignore_errors: true register: impossible_result - name: Check results diff --git a/tests/integration/targets/lvg/tasks/test_pvresize.yml b/tests/integration/targets/lvg/tasks/test_pvresize.yml index eef9503040..f15add91cb 100644 --- a/tests/integration/targets/lvg/tasks/test_pvresize.yml +++ b/tests/integration/targets/lvg/tasks/test_pvresize.yml @@ -27,7 +27,7 @@ lvg: vg: testvg pvs: "{{ loop_device1 }}" - pvresize: no + pvresize: false register: cmd_result - assert: @@ -47,8 +47,8 @@ lvg: vg: testvg pvs: "{{ loop_device1 }}" - pvresize: yes - check_mode: yes + pvresize: true + check_mode: true register: cmd_result - name: Assert that the module returned the state was changed @@ -69,7 +69,7 @@ lvg: vg: testvg pvs: "{{ loop_device1 }}" - pvresize: yes + pvresize: true - name: Gets current vg size shell: vgs -v testvg -o pv_size --noheading --units b | xargs diff --git a/tests/integration/targets/mail/tasks/main.yml b/tests/integration/targets/mail/tasks/main.yml index a79d9e9162..4f3f90a51d 100644 --- a/tests/integration/targets/mail/tasks/main.yml +++ b/tests/integration/targets/mail/tasks/main.yml @@ -15,7 +15,7 @@ pip: name: smtpd-tls state: present - ignore_errors: yes + ignore_errors: true register: smtpd_tls - name: Install test smtpserver @@ -70,7 +70,7 @@ body: Test body 4 attach: /etc/group secure: starttls - ignore_errors: yes + ignore_errors: true register: starttls_support # NOTE: This might fail if smtpd-tls is missing or python 2.7.8 or older is used @@ -83,7 +83,7 @@ body: Test body 5 attach: /etc/group secure: always - ignore_errors: yes + ignore_errors: true register: tls_support - fail: diff --git a/tests/integration/targets/mas/tasks/main.yml b/tests/integration/targets/mas/tasks/main.yml index ce50c39eb1..f659160dcc 100644 --- a/tests/integration/targets/mas/tasks/main.yml +++ b/tests/integration/targets/mas/tasks/main.yml @@ -14,7 +14,7 @@ mas: id: 421879749 state: absent - become: yes + become: true - name: Determine whether the app is installed stat: @@ -36,7 +36,7 @@ id: 421879749 state: present register: install_check - check_mode: yes + check_mode: true - name: Ensure that the status would have changed assert: @@ -98,8 +98,8 @@ id: 421879749 state: absent register: uninstall_check - become: yes - check_mode: yes + become: true + check_mode: true - name: Ensure that the status would have changed assert: @@ -122,7 +122,7 @@ id: 421879749 state: absent register: uninstall - become: yes + become: true - name: Ensure that the status changed assert: @@ -149,7 +149,7 @@ id: 421879749 state: absent register: uninstall_again - become: yes + become: true - name: Ensure that the status is unchanged (already uninstalled) assert: diff --git a/tests/integration/targets/module_helper/library/mstate.py b/tests/integration/targets/module_helper/library/mstate.py index 9e70ed4364..bfaab03755 100644 --- a/tests/integration/targets/module_helper/library/mstate.py +++ b/tests/integration/targets/module_helper/library/mstate.py @@ -18,7 +18,7 @@ options: a: description: aaaa type: int - required: yes + required: true b: description: bbbb type: str diff --git a/tests/integration/targets/module_helper/tasks/mdepfail.yml b/tests/integration/targets/module_helper/tasks/mdepfail.yml index 3f4ed9039d..1655be54e3 100644 --- a/tests/integration/targets/module_helper/tasks/mdepfail.yml +++ b/tests/integration/targets/module_helper/tasks/mdepfail.yml @@ -5,7 +5,7 @@ - name: test failing dependency mdepfail: a: 123 - ignore_errors: yes + ignore_errors: true register: result - name: assert failing dependency diff --git a/tests/integration/targets/module_helper/tasks/msimple.yml b/tests/integration/targets/module_helper/tasks/msimple.yml index 9010c455ca..03818639c7 100644 --- a/tests/integration/targets/module_helper/tasks/msimple.yml +++ b/tests/integration/targets/module_helper/tasks/msimple.yml @@ -18,7 +18,7 @@ - name: test msimple 2 msimple: a: 101 - ignore_errors: yes + ignore_errors: true register: simple2 - name: assert simple2 diff --git a/tests/integration/targets/module_helper/tasks/msimple_output_conflict.yml b/tests/integration/targets/module_helper/tasks/msimple_output_conflict.yml index 55e0a06eca..62fe1e327b 100644 --- a/tests/integration/targets/module_helper/tasks/msimple_output_conflict.yml +++ b/tests/integration/targets/module_helper/tasks/msimple_output_conflict.yml @@ -37,7 +37,7 @@ msimple: a: 101 m: a message in a bottle - ignore_errors: yes + ignore_errors: true register: simple3 - name: assert simple3 diff --git a/tests/integration/targets/monit/tasks/main.yml b/tests/integration/targets/monit/tasks/main.yml index 73b6cfc8a6..ea85954125 100644 --- a/tests/integration/targets/monit/tasks/main.yml +++ b/tests/integration/targets/monit/tasks/main.yml @@ -17,7 +17,7 @@ - ansible_distribution_major_version is version('9', '<') - name: create required directories - become: yes + become: true file: path: "{{ item }}" state: directory @@ -27,7 +27,7 @@ - "{{ process_root }}" - name: install monit - become: yes + become: true package: name: monit state: present @@ -40,13 +40,13 @@ - 'defaults.yml' - name: monit config - become: yes + become: true template: src: "monitrc.j2" dest: "{{ monitrc }}" - name: copy process file - become: yes + become: true copy: src: httpd_echo.py dest: "{{ process_file }}" @@ -73,7 +73,7 @@ - python-daemon - name: restart monit - become: yes + become: true service: name: monit state: restarted @@ -82,13 +82,13 @@ always: - name: stop monit - become: yes + become: true service: name: monit state: stopped - name: uninstall monit - become: yes + become: true package: name: monit state: absent diff --git a/tests/integration/targets/mssql_script/tasks/main.yml b/tests/integration/targets/mssql_script/tasks/main.yml index 2ecfd51c15..7f8d6d1840 100644 --- a/tests/integration/targets/mssql_script/tasks/main.yml +++ b/tests/integration/targets/mssql_script/tasks/main.yml @@ -169,7 +169,7 @@ login_host: "{{ mssql_host }}" login_port: "{{ mssql_port }}" script: SELECT Invalid_Column FROM Does_Not_Exist WITH Invalid Syntax - check_mode: yes + check_mode: true register: check_mode - assert: that: check_mode.query_results is undefined diff --git a/tests/integration/targets/npm/tasks/setup.yml b/tests/integration/targets/npm/tasks/setup.yml index 0c7a9eabfb..bad927915b 100644 --- a/tests/integration/targets/npm/tasks/setup.yml +++ b/tests/integration/targets/npm/tasks/setup.yml @@ -7,5 +7,5 @@ unarchive: src: 'https://ansible-ci-files.s3.amazonaws.com/test/integration/targets/npm/{{ nodejs_path }}.tar.gz' dest: '{{ remote_tmp_dir }}' - remote_src: yes + remote_src: true creates: '{{ remote_tmp_dir }}/{{ nodejs_path }}.tar.gz' diff --git a/tests/integration/targets/osx_defaults/tasks/main.yml b/tests/integration/targets/osx_defaults/tasks/main.yml index 0de351991a..c3cb09d394 100644 --- a/tests/integration/targets/osx_defaults/tasks/main.yml +++ b/tests/integration/targets/osx_defaults/tasks/main.yml @@ -16,7 +16,7 @@ type: string state: present register: missing_value - ignore_errors: yes + ignore_errors: true - name: Test if state and value are required together assert: @@ -31,7 +31,7 @@ value: Centimeter state: present register: measure_task_check_mode - check_mode: yes + check_mode: true - name: Test if AppleMeasurementUnits value is changed to Centimeters in check_mode assert: @@ -163,7 +163,7 @@ key: ExampleKeyToRemove state: absent register: absent_check_mode_task - check_mode: yes + check_mode: true - debug: msg: "{{ absent_check_mode_task }}" @@ -225,7 +225,7 @@ value: - 'Value with spaces' type: array - array_add: yes + array_add: true register: test_array_add - assert: @@ -238,7 +238,7 @@ value: - 'Value with spaces' type: array - array_add: yes + array_add: true register: test_array_add - assert: diff --git a/tests/integration/targets/pacman/tasks/remove_nosave.yml b/tests/integration/targets/pacman/tasks/remove_nosave.yml index c6d1c961cb..2271ebc037 100644 --- a/tests/integration/targets/pacman/tasks/remove_nosave.yml +++ b/tests/integration/targets/pacman/tasks/remove_nosave.yml @@ -61,7 +61,7 @@ - name: Remove {{ package_name }} - nosave pacman: name: '{{ package_name }}' - remove_nosave: yes + remove_nosave: true state: absent - name: Make sure {{config_file}}.pacsave does not exist diff --git a/tests/integration/targets/pam_limits/tasks/main.yml b/tests/integration/targets/pam_limits/tasks/main.yml index 1c73394fb3..5ad68f4a64 100644 --- a/tests/integration/targets/pam_limits/tasks/main.yml +++ b/tests/integration/targets/pam_limits/tasks/main.yml @@ -19,7 +19,7 @@ limit_item: nofile value: '64000' dest: "{{ test_limit_file }}" - check_mode: yes + check_mode: true register: check_mode_test - name: Test that check mode is working diff --git a/tests/integration/targets/pipx/tasks/main.yml b/tests/integration/targets/pipx/tasks/main.yml index 00f54aeb24..267c2a2d1a 100644 --- a/tests/integration/targets/pipx/tasks/main.yml +++ b/tests/integration/targets/pipx/tasks/main.yml @@ -32,7 +32,7 @@ - name: install application tox again force community.general.pipx: name: tox - force: yes + force: true register: install_tox_again_force - name: uninstall application tox @@ -68,7 +68,7 @@ community.general.pipx: state: reinstall register: reinstall_noname - ignore_errors: yes + ignore_errors: true - name: upgrade tox from 3.24.0 community.general.pipx: @@ -80,13 +80,13 @@ community.general.pipx: state: upgrade register: upgrade_noname - ignore_errors: yes + ignore_errors: true - name: downgrade tox 3.24.0 community.general.pipx: name: tox source: tox==3.24.0 - force: yes + force: true register: downgrade_tox_324 - name: cleanup tox 3.24.0 diff --git a/tests/integration/targets/pkgng/tasks/create-outofdate-pkg.yml b/tests/integration/targets/pkgng/tasks/create-outofdate-pkg.yml index e63cb72312..4028c57d8f 100644 --- a/tests/integration/targets/pkgng/tasks/create-outofdate-pkg.yml +++ b/tests/integration/targets/pkgng/tasks/create-outofdate-pkg.yml @@ -31,7 +31,7 @@ - name: Find created package file find: path: '{{ pkgng_test_outofdate_pkg_tempdir.path }}' - use_regex: yes + use_regex: true pattern: '.*\.(pkg|tzst|t[xbg]z|tar)' register: pkgng_test_outofdate_pkg_tempfile @@ -42,7 +42,7 @@ - name: Copy the created package file to the expected location copy: - remote_src: yes + remote_src: true src: '{{ pkgng_test_outofdate_pkg_tempfile.files[0].path }}' dest: '{{ pkgng_test_outofdate_pkg_path }}' diff --git a/tests/integration/targets/pkgng/tasks/freebsd.yml b/tests/integration/targets/pkgng/tasks/freebsd.yml index a822b4c7e9..fd9a4a4c5b 100644 --- a/tests/integration/targets/pkgng/tasks/freebsd.yml +++ b/tests/integration/targets/pkgng/tasks/freebsd.yml @@ -37,15 +37,15 @@ - name: Verify package sentinel file is present stat: path: '{{ pkgng_test_pkg_sentinelfile_path }}' - get_attributes: no - get_checksum: no - get_mime: no + get_attributes: false + get_checksum: false + get_mime: false register: pkgng_example3_stat_before - name: Install package (checkmode) pkgng: name: '{{ pkgng_test_pkg_name }}' - check_mode: yes + check_mode: true register: pkgng_example3_checkmode - name: Remove package @@ -63,9 +63,9 @@ - name: Verify package sentinel file is not present stat: path: '{{ pkgng_test_pkg_sentinelfile_path }}' - get_attributes: no - get_checksum: no - get_mime: no + get_attributes: false + get_checksum: false + get_mime: false register: pkgng_example3_stat_after - name: Ensure pkgng installs package correctly @@ -104,14 +104,14 @@ pkgng: name: '*' state: latest - check_mode: yes + check_mode: true register: pkgng_example4_wildcard_checkmode - name: Check for available package upgrade (checkmode) pkgng: name: '{{ pkgng_test_pkg_name }}' state: latest - check_mode: yes + check_mode: true register: pkgng_example4_checkmode - name: Upgrade out-of-date package @@ -183,7 +183,7 @@ pkgng: name: '{{ pkgng_test_pkg_name }}' state: absent - check_mode: yes + check_mode: true register: pkgng_example5_prepare - name: Install three packages @@ -219,7 +219,7 @@ pkgng: name: '{{ pkgng_test_pkg_name }}' state: absent - check_mode: yes + check_mode: true register: pkgng_example6_check - name: Create out-of-date test package @@ -279,7 +279,7 @@ pkgng: name: autotools state: absent - autoremove: yes + autoremove: true register: pkgng_example7 - name: Check if autoremove uninstalled known autotools dependencies @@ -290,7 +290,7 @@ - libtool - m4 state: absent - check_mode: yes + check_mode: true register: pkgng_example7_cleanup - name: Ensure pkgng autoremove works correctly @@ -313,7 +313,7 @@ pkgng: name: '{{ pkgng_test_pkg_name }}' annotation: '+ansibletest_example8=duplicate' - ignore_errors: yes + ignore_errors: true register: pkgng_example8_add_annotation_failure - name: Verify annotation is actually there @@ -324,14 +324,14 @@ pkgng: name: '{{ pkgng_test_pkg_name }}' annotation: '+ansibletest_example8=added' - check_mode: yes + check_mode: true register: pkgng_example8_add_annotation_checkmode_nochange - name: Install and annotate single package (checkmode, changed) pkgng: name: '{{ pkgng_test_pkg_name }}' annotation: '+ansibletest_example8_checkmode=added' - check_mode: yes + check_mode: true register: pkgng_example8_add_annotation_checkmode_change - name: Verify check_mode did not add an annotation @@ -348,7 +348,7 @@ pkgng: name: '{{ pkgng_test_pkg_name }}' annotation: ':ansiblemissing=modified' - ignore_errors: yes + ignore_errors: true register: pkgng_example8_modify_annotation_failure - name: Verify annotation has been modified @@ -451,7 +451,7 @@ pkgng: name: '{{ pkgng_test_pkg_name }}' annotation: '{{ item }}' - ignore_errors: yes + ignore_errors: true register: pkgng_example8_invalid_annotation_failure loop: - 'naked_string' @@ -484,7 +484,7 @@ pkgng: name: '{{ pkgng_test_pkg_name }}' pkgsite: DoesNotExist - ignore_errors: yes + ignore_errors: true register: pkgng_example10_invalid_pkgsite_failure - name: Ensure invalid pkgsite fails as expected @@ -524,21 +524,21 @@ vars: pkgng_test_rootdir: /usr/jails/testjail pkgng_test_install_prefix: /usr/jails/testjail - pkgng_test_install_cleanup: yes + pkgng_test_install_cleanup: true - name: Install package in jail include_tasks: install_single_package.yml vars: pkgng_test_jail: testjail pkgng_test_install_prefix: /usr/jails/testjail - pkgng_test_install_cleanup: yes + pkgng_test_install_cleanup: true - name: Install package in jail as chroot include_tasks: install_single_package.yml vars: pkgng_test_chroot: /usr/jails/testjail pkgng_test_install_prefix: /usr/jails/testjail - pkgng_test_install_cleanup: yes + pkgng_test_install_cleanup: true always: - name: Stop and remove testjail failed_when: false diff --git a/tests/integration/targets/pkgng/tasks/install_single_package.yml b/tests/integration/targets/pkgng/tasks/install_single_package.yml index 00768085ca..5ba529af35 100644 --- a/tests/integration/targets/pkgng/tasks/install_single_package.yml +++ b/tests/integration/targets/pkgng/tasks/install_single_package.yml @@ -6,9 +6,9 @@ - name: Verify package sentinel file is not present stat: path: '{{ pkgng_test_install_prefix | default("") }}{{ pkgng_test_pkg_sentinelfile_path }}' - get_attributes: no - get_checksum: no - get_mime: no + get_attributes: false + get_checksum: false + get_mime: false register: pkgng_install_stat_before - name: Install package @@ -23,21 +23,21 @@ pkgng: <<: *pkgng_install_params state: absent - check_mode: yes + check_mode: true register: pkgng_install_checkmode - name: Install package (idempotent, cached) pkgng: <<: *pkgng_install_params - cached: yes + cached: true register: pkgng_install_idempotent_cached - name: Verify package sentinel file is present stat: path: '{{ pkgng_test_install_prefix | default("") }}{{ pkgng_test_pkg_sentinelfile_path }}' - get_attributes: no - get_checksum: no - get_mime: no + get_attributes: false + get_checksum: false + get_mime: false register: pkgng_install_stat_after - name: Remove test package (if requested) diff --git a/tests/integration/targets/pkgng/tasks/setup-testjail.yml b/tests/integration/targets/pkgng/tasks/setup-testjail.yml index 99505af591..3055d29e88 100644 --- a/tests/integration/targets/pkgng/tasks/setup-testjail.yml +++ b/tests/integration/targets/pkgng/tasks/setup-testjail.yml @@ -28,7 +28,7 @@ service: name: pf state: started - enabled: yes + enabled: true - name: Install ezjail pkgng: @@ -49,11 +49,11 @@ line: ezjail_ftphost=http://ftp-archive.freebsd.org - name: Start ezjail - ignore_errors: yes + ignore_errors: true service: name: ezjail state: started - enabled: yes + enabled: true - name: Redirect logs depending on verbosity set_fact: @@ -84,7 +84,7 @@ dest: /usr/jails/testjail/etc/resolv.conf regexp: "^nameserver[[:blank:]]+{{ item }}$" line: "nameserver {{ item }}" - create: yes + create: true loop: - "1.1.1.1" - "1.0.0.1" diff --git a/tests/integration/targets/pkgutil/tasks/main.yml b/tests/integration/targets/pkgutil/tasks/main.yml index e6f32ccc7a..8ceb4adcc3 100644 --- a/tests/integration/targets/pkgutil/tasks/main.yml +++ b/tests/integration/targets/pkgutil/tasks/main.yml @@ -18,7 +18,7 @@ pkgutil: name: CSWtop state: present - check_mode: yes + check_mode: true register: cm_add_package - name: Verify cm_add_package @@ -41,7 +41,7 @@ pkgutil: name: CSWtop state: present - check_mode: yes + check_mode: true register: cm_add_package_again - name: Verify cm_add_package_again @@ -66,7 +66,7 @@ pkgutil: name: CSWtop state: absent - check_mode: yes + check_mode: true register: cm_remove_package - name: Verify cm_remove_package @@ -89,7 +89,7 @@ pkgutil: name: CSWtop state: absent - check_mode: yes + check_mode: true register: cm_remove_package_again - name: Verify cm_remove_package_again diff --git a/tests/integration/targets/read_csv/tasks/main.yml b/tests/integration/targets/read_csv/tasks/main.yml index 325a102c21..a21af95182 100644 --- a/tests/integration/targets/read_csv/tasks/main.yml +++ b/tests/integration/targets/read_csv/tasks/main.yml @@ -68,7 +68,7 @@ read_csv: path: users_nonunique.csv key: name - unique: no + unique: false delimiter: ';' register: users_nonunique @@ -90,7 +90,7 @@ path: users_nonunique.csv dialect: placebo register: users_placebo - ignore_errors: yes + ignore_errors: true - assert: that: @@ -140,9 +140,9 @@ read_csv: path: users_broken.csv key: name - strict: yes + strict: true register: users_broken - ignore_errors: yes + ignore_errors: true - assert: that: diff --git a/tests/integration/targets/redis_info/tasks/main.yml b/tests/integration/targets/redis_info/tasks/main.yml index e696066b26..4a11de3650 100644 --- a/tests/integration/targets/redis_info/tasks/main.yml +++ b/tests/integration/targets/redis_info/tasks/main.yml @@ -24,7 +24,7 @@ login_host: 127.0.0.1 login_port: "{{ master_port }}" login_password: "{{ redis_password }}" - check_mode: yes + check_mode: true register: result - assert: diff --git a/tests/integration/targets/scaleway_compute/tasks/ip.yml b/tests/integration/targets/scaleway_compute/tasks/ip.yml index f6b7840fd9..094176ce86 100644 --- a/tests/integration/targets/scaleway_compute/tasks/ip.yml +++ b/tests/integration/targets/scaleway_compute/tasks/ip.yml @@ -4,7 +4,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later - name: Create a server with no IP (Check) - check_mode: yes + check_mode: true scaleway_compute: name: '{{ scaleway_name }}' state: present @@ -66,7 +66,7 @@ # Add a dynamic IP to the instance - name: Patch server tags (Check) - check_mode: yes + check_mode: true scaleway_compute: name: '{{ scaleway_name }}' state: present @@ -127,7 +127,7 @@ # Remove dynamic IP - name: Patch server tags (Check) - check_mode: yes + check_mode: true scaleway_compute: name: '{{ scaleway_name }}' state: present diff --git a/tests/integration/targets/scaleway_compute/tasks/security_group.yml b/tests/integration/targets/scaleway_compute/tasks/security_group.yml index 6126514212..59f81e6af1 100644 --- a/tests/integration/targets/scaleway_compute/tasks/security_group.yml +++ b/tests/integration/targets/scaleway_compute/tasks/security_group.yml @@ -20,7 +20,7 @@ - block: - name: Create a server with security_group (Check) - check_mode: yes + check_mode: true scaleway_compute: name: '{{ scaleway_name }}' state: present @@ -80,7 +80,7 @@ - server_creation_confirmation_task is not changed - name: Keep current security_group (Check) - check_mode: yes + check_mode: true scaleway_compute: name: '{{ scaleway_name }}' state: present diff --git a/tests/integration/targets/scaleway_compute/tasks/state.yml b/tests/integration/targets/scaleway_compute/tasks/state.yml index 8f015ad337..b3f2567626 100644 --- a/tests/integration/targets/scaleway_compute/tasks/state.yml +++ b/tests/integration/targets/scaleway_compute/tasks/state.yml @@ -4,7 +4,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later - name: Create a server (Check) - check_mode: yes + check_mode: true scaleway_compute: name: '{{ scaleway_name }}' state: present @@ -61,7 +61,7 @@ - server_creation_confirmation_task is not changed - name: Patch server tags (Check) - check_mode: yes + check_mode: true scaleway_compute: name: '{{ scaleway_name }}' state: present @@ -124,7 +124,7 @@ - server_patching_confirmation_task is not changed - name: Run it (Check mode) - check_mode: yes + check_mode: true scaleway_compute: name: '{{ scaleway_name }}' state: running @@ -187,7 +187,7 @@ - server_run_confirmation_task is not changed - name: Reboot it (Check mode) - check_mode: yes + check_mode: true scaleway_compute: name: '{{ scaleway_name }}' state: restarted @@ -229,7 +229,7 @@ - server_reboot_task is changed - name: Stop it (Check mode) - check_mode: yes + check_mode: true scaleway_compute: name: '{{ scaleway_name }}' state: stopped @@ -292,7 +292,7 @@ - server_stop_confirmation_task is not changed - name: Destroy it (Check mode) - check_mode: yes + check_mode: true scaleway_compute: name: '{{ scaleway_name }}' state: absent @@ -355,7 +355,7 @@ - server_destroy_confirmation_task is not changed - name: Testing for unauthorized organization - ignore_errors: yes + ignore_errors: true scaleway_compute: name: '{{ scaleway_name }}' state: present @@ -373,7 +373,7 @@ - unauthorized_organization_task is not changed - name: Testing for unexisting image - ignore_errors: yes + ignore_errors: true scaleway_compute: name: '{{ scaleway_name }}' state: present diff --git a/tests/integration/targets/scaleway_container/tasks/main.yml b/tests/integration/targets/scaleway_container/tasks/main.yml index 1ac5bf1768..d0bf4206f6 100644 --- a/tests/integration/targets/scaleway_container/tasks/main.yml +++ b/tests/integration/targets/scaleway_container/tasks/main.yml @@ -18,7 +18,7 @@ register: integration_container_namespace - name: Create a container (Check) - check_mode: yes + check_mode: true community.general.scaleway_container: state: present name: '{{ name }}' @@ -87,7 +87,7 @@ - cn_creation_confirmation_task.container.status in ["created", "ready"] - name: Update container (Check) - check_mode: yes + check_mode: true community.general.scaleway_container: state: present name: '{{ name }}' @@ -156,7 +156,7 @@ - cn_update_confirmation_task.container.status in ["created", "ready"] - name: Update container secret variables (Check) - check_mode: yes + check_mode: true community.general.scaleway_container: state: present name: '{{ name }}' @@ -227,7 +227,7 @@ - "'hashed_value' in cn_update_secret_confirmation_task.container.secret_environment_variables[0]" - name: Delete container (Check) - check_mode: yes + check_mode: true community.general.scaleway_container: state: absent name: '{{ name }}' diff --git a/tests/integration/targets/scaleway_container_namespace/tasks/main.yml b/tests/integration/targets/scaleway_container_namespace/tasks/main.yml index bab42ee13f..73e43ff156 100644 --- a/tests/integration/targets/scaleway_container_namespace/tasks/main.yml +++ b/tests/integration/targets/scaleway_container_namespace/tasks/main.yml @@ -9,7 +9,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later - name: Create a container namespace (Check) - check_mode: yes + check_mode: true community.general.scaleway_container_namespace: state: present name: '{{ name }}' @@ -72,7 +72,7 @@ - cn_creation_confirmation_task.container_namespace.status == "ready" - name: Update container namespace (Check) - check_mode: yes + check_mode: true community.general.scaleway_container_namespace: state: present name: '{{ name }}' @@ -135,7 +135,7 @@ - cn_update_confirmation_task.container_namespace.status == "ready" - name: Update container namespace secret variables (Check) - check_mode: yes + check_mode: true community.general.scaleway_container_namespace: state: present name: '{{ name }}' @@ -200,7 +200,7 @@ - "'hashed_value' in cn_update_secret_confirmation_task.container_namespace.secret_environment_variables[0]" - name: Delete container namespace (Check) - check_mode: yes + check_mode: true community.general.scaleway_container_namespace: state: absent name: '{{ name }}' diff --git a/tests/integration/targets/scaleway_container_registry/tasks/main.yml b/tests/integration/targets/scaleway_container_registry/tasks/main.yml index 24b1f0cbc9..91cea20f3f 100644 --- a/tests/integration/targets/scaleway_container_registry/tasks/main.yml +++ b/tests/integration/targets/scaleway_container_registry/tasks/main.yml @@ -9,7 +9,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later - name: Create a container registry (Check) - check_mode: yes + check_mode: true community.general.scaleway_container_registry: state: present name: '{{ name }}' @@ -66,7 +66,7 @@ - cr_creation_confirmation_task.container_registry.status == "ready" - name: Update container registry (Check) - check_mode: yes + check_mode: true community.general.scaleway_container_registry: state: present name: '{{ name }}' @@ -123,7 +123,7 @@ - cr_update_confirmation_task.container_registry.status == "ready" - name: Delete container registry (Check) - check_mode: yes + check_mode: true community.general.scaleway_container_registry: state: absent name: '{{ name }}' diff --git a/tests/integration/targets/scaleway_database_backup/tasks/main.yml b/tests/integration/targets/scaleway_database_backup/tasks/main.yml index b0af65c0ae..fdef03fb30 100644 --- a/tests/integration/targets/scaleway_database_backup/tasks/main.yml +++ b/tests/integration/targets/scaleway_database_backup/tasks/main.yml @@ -9,7 +9,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later - name: Create a backup (Check) - check_mode: yes + check_mode: true scaleway_database_backup: name: '{{ scaleway_name }}' state: present @@ -63,7 +63,7 @@ - backup_creation_confirmation_task is not changed - name: Patch backup name (Check) - check_mode: yes + check_mode: true scaleway_database_backup: name: '{{ scaleway_name }}-changed' state: present @@ -115,7 +115,7 @@ - backup_patching_confirmation_task is not changed - name: Export backup (Check) - check_mode: yes + check_mode: true scaleway_database_backup: id: '{{ backup_creation_task.metadata.id }}' state: exported @@ -161,7 +161,7 @@ - backup_export_confirmation_task.metadata.download_url != "" - name: Restore backup (Check) - check_mode: yes + check_mode: true scaleway_database_backup: id: '{{ backup_creation_task.metadata.id }}' state: restored @@ -195,7 +195,7 @@ - backup_restore_task is changed - name: Delete backup (Check) - check_mode: yes + check_mode: true scaleway_database_backup: id: '{{ backup_creation_task.metadata.id }}' state: absent diff --git a/tests/integration/targets/scaleway_function/tasks/main.yml b/tests/integration/targets/scaleway_function/tasks/main.yml index 92ebfb8f7d..d4552d0b39 100644 --- a/tests/integration/targets/scaleway_function/tasks/main.yml +++ b/tests/integration/targets/scaleway_function/tasks/main.yml @@ -18,7 +18,7 @@ register: integration_function_namespace - name: Create a function (Check) - check_mode: yes + check_mode: true community.general.scaleway_function: state: present name: '{{ name }}' @@ -84,7 +84,7 @@ - fn_creation_confirmation_task.function.status in ["created", "ready"] - name: Update function (Check) - check_mode: yes + check_mode: true community.general.scaleway_function: state: present name: '{{ name }}' @@ -150,7 +150,7 @@ - fn_update_confirmation_task.function.status in ["created", "ready"] - name: Update function secret variables (Check) - check_mode: yes + check_mode: true community.general.scaleway_function: state: present name: '{{ name }}' @@ -218,7 +218,7 @@ - "'hashed_value' in fn_update_secret_confirmation_task.function.secret_environment_variables[0]" - name: Delete function (Check) - check_mode: yes + check_mode: true community.general.scaleway_function: state: absent name: '{{ name }}' diff --git a/tests/integration/targets/scaleway_function_namespace/tasks/main.yml b/tests/integration/targets/scaleway_function_namespace/tasks/main.yml index 78b7c95757..50af4449d5 100644 --- a/tests/integration/targets/scaleway_function_namespace/tasks/main.yml +++ b/tests/integration/targets/scaleway_function_namespace/tasks/main.yml @@ -9,7 +9,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later - name: Create a function namespace (Check) - check_mode: yes + check_mode: true community.general.scaleway_function_namespace: state: present name: '{{ name }}' @@ -74,7 +74,7 @@ - "'hashed_value' in fn_creation_task.function_namespace.secret_environment_variables[0]" - name: Update function namespace (Check) - check_mode: yes + check_mode: true community.general.scaleway_function_namespace: state: present name: '{{ name }}' @@ -139,7 +139,7 @@ - "'hashed_value' in fn_creation_task.function_namespace.secret_environment_variables[0]" - name: Update function namespace secret variables (Check) - check_mode: yes + check_mode: true community.general.scaleway_function_namespace: state: present name: '{{ name }}' @@ -204,7 +204,7 @@ - "'hashed_value' in fn_update_secret_confirmation_task.function_namespace.secret_environment_variables[0]" - name: Delete function namespace (Check) - check_mode: yes + check_mode: true community.general.scaleway_function_namespace: state: absent name: '{{ name }}' diff --git a/tests/integration/targets/scaleway_ip/tasks/main.yml b/tests/integration/targets/scaleway_ip/tasks/main.yml index fe0f578fa8..5a396ba4f2 100644 --- a/tests/integration/targets/scaleway_ip/tasks/main.yml +++ b/tests/integration/targets/scaleway_ip/tasks/main.yml @@ -9,7 +9,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later - name: Create IP (Check) - check_mode: yes + check_mode: true scaleway_ip: state: present region: '{{ scaleway_region }}' @@ -78,7 +78,7 @@ - '{{ ip_creation_task.scaleway_ip.server is none }}' - name: Assign reverse to server (Check) - check_mode: yes + check_mode: true scaleway_ip: state: present id: '{{ ip_creation_task.scaleway_ip.id }}' @@ -162,7 +162,7 @@ - server_creation_task is success - name: Assign IP to server (Check) - check_mode: yes + check_mode: true scaleway_ip: state: present id: '{{ ip_creation_task.scaleway_ip.id }}' @@ -229,7 +229,7 @@ - ip_assignation_confirmation_task is not changed - name: Unassign IP to server (Check) - check_mode: yes + check_mode: true scaleway_ip: state: present id: '{{ ip_creation_task.scaleway_ip.id }}' @@ -303,7 +303,7 @@ - '{{ ip_unassignation_task.scaleway_ip.server is none }}' - name: Unassign reverse to IP (Check) - check_mode: yes + check_mode: true scaleway_ip: state: present id: '{{ ip_creation_task.scaleway_ip.id }}' @@ -397,7 +397,7 @@ - server_destroy_task is changed - name: Delete IP (Check) - check_mode: yes + check_mode: true scaleway_ip: state: absent region: '{{ scaleway_region }}' diff --git a/tests/integration/targets/scaleway_lb/tasks/main.yml b/tests/integration/targets/scaleway_lb/tasks/main.yml index 05237e1a78..2567abd078 100644 --- a/tests/integration/targets/scaleway_lb/tasks/main.yml +++ b/tests/integration/targets/scaleway_lb/tasks/main.yml @@ -9,7 +9,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later - name: Create a load-balancer (Check) - check_mode: yes + check_mode: true scaleway_lb: state: present name: '{{ name }}' @@ -87,7 +87,7 @@ - lb_creation_confirmation_task.scaleway_lb.status == "ready" - name: Update load-balancer (Check) - check_mode: yes + check_mode: true scaleway_lb: state: present name: '{{ name }}' @@ -165,7 +165,7 @@ - lb_update_confirmation_task.scaleway_lb.status == "ready" - name: Delete load-balancer (Check) - check_mode: yes + check_mode: true scaleway_lb: state: absent name: '{{ name }}' diff --git a/tests/integration/targets/scaleway_security_group/tasks/main.yml b/tests/integration/targets/scaleway_security_group/tasks/main.yml index 362166e291..cab972ae50 100644 --- a/tests/integration/targets/scaleway_security_group/tasks/main.yml +++ b/tests/integration/targets/scaleway_security_group/tasks/main.yml @@ -9,7 +9,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later - name: Create security group check - check_mode: yes + check_mode: true scaleway_security_group: state: present region: '{{ scaleway_region }}' @@ -74,7 +74,7 @@ - security_group_creation is not changed - name: Delete security group check - check_mode: yes + check_mode: true scaleway_security_group: state: absent region: '{{ scaleway_region }}' diff --git a/tests/integration/targets/scaleway_sshkey/tasks/main.yml b/tests/integration/targets/scaleway_sshkey/tasks/main.yml index 2871086251..588745abdc 100644 --- a/tests/integration/targets/scaleway_sshkey/tasks/main.yml +++ b/tests/integration/targets/scaleway_sshkey/tasks/main.yml @@ -11,7 +11,7 @@ - scaleway_sshkey: ssh_pub_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDf29yyommeGyKSIgSmX0ISVXP+3x6RUY4JDGLoAMFh2efkfDaRVdsvkvnFuUywgP2RewrjTyLE8w0NpCBHVS5Fm1BAn3yvxOUtTMxTbsQcw6HQ8swJ02+1tewJYjHPwc4GrBqiDo3Nmlq354Us0zBOJg/bBzuEnVD5eJ3GO3gKaCSUYTVrYwO0U4eJE0D9OJeUP9J48kl4ULbCub976+mTHdBvlzRw0Tzfl2kxgdDwlks0l2NefY/uiTdz2oMt092bAY3wZHxjto/DXoChxvaf5s2k8Zb+J7CjimUYnzPlH+zA9F6ROjP5AUu6ZWPd0jOIBl1nDWWb2j/qfNLYM43l sieben@sieben-macbook.local" state: present - check_mode: yes + check_mode: true - scaleway_sshkey: ssh_pub_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDf29yyommeGyKSIgSmX0ISVXP+3x6RUY4JDGLoAMFh2efkfDaRVdsvkvnFuUywgP2RewrjTyLE8w0NpCBHVS5Fm1BAn3yvxOUtTMxTbsQcw6HQ8swJ02+1tewJYjHPwc4GrBqiDo3Nmlq354Us0zBOJg/bBzuEnVD5eJ3GO3gKaCSUYTVrYwO0U4eJE0D9OJeUP9J48kl4ULbCub976+mTHdBvlzRw0Tzfl2kxgdDwlks0l2NefY/uiTdz2oMt092bAY3wZHxjto/DXoChxvaf5s2k8Zb+J7CjimUYnzPlH+zA9F6ROjP5AUu6ZWPd0jOIBl1nDWWb2j/qfNLYM43l sieben@sieben-macbook.local" @@ -31,7 +31,7 @@ - scaleway_sshkey: ssh_pub_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDf29yyommeGyKSIgSmX0ISVXP+3x6RUY4JDGLoAMFh2efkfDaRVdsvkvnFuUywgP2RewrjTyLE8w0NpCBHVS5Fm1BAn3yvxOUtTMxTbsQcw6HQ8swJ02+1tewJYjHPwc4GrBqiDo3Nmlq354Us0zBOJg/bBzuEnVD5eJ3GO3gKaCSUYTVrYwO0U4eJE0D9OJeUP9J48kl4ULbCub976+mTHdBvlzRw0Tzfl2kxgdDwlks0l2NefY/uiTdz2oMt092bAY3wZHxjto/DXoChxvaf5s2k8Zb+J7CjimUYnzPlH+zA9F6ROjP5AUu6ZWPd0jOIBl1nDWWb2j/qfNLYM43l sieben@sieben-macbook.local" state: absent - check_mode: yes + check_mode: true - scaleway_sshkey: ssh_pub_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDf29yyommeGyKSIgSmX0ISVXP+3x6RUY4JDGLoAMFh2efkfDaRVdsvkvnFuUywgP2RewrjTyLE8w0NpCBHVS5Fm1BAn3yvxOUtTMxTbsQcw6HQ8swJ02+1tewJYjHPwc4GrBqiDo3Nmlq354Us0zBOJg/bBzuEnVD5eJ3GO3gKaCSUYTVrYwO0U4eJE0D9OJeUP9J48kl4ULbCub976+mTHdBvlzRw0Tzfl2kxgdDwlks0l2NefY/uiTdz2oMt092bAY3wZHxjto/DXoChxvaf5s2k8Zb+J7CjimUYnzPlH+zA9F6ROjP5AUu6ZWPd0jOIBl1nDWWb2j/qfNLYM43l sieben@sieben-macbook.local" diff --git a/tests/integration/targets/scaleway_user_data/tasks/main.yml b/tests/integration/targets/scaleway_user_data/tasks/main.yml index b1cd856ec8..ce42841277 100644 --- a/tests/integration/targets/scaleway_user_data/tasks/main.yml +++ b/tests/integration/targets/scaleway_user_data/tasks/main.yml @@ -28,7 +28,7 @@ - debug: var=server_id - name: Patch user_data cloud-init configuration (Check) - check_mode: yes + check_mode: true scaleway_user_data: region: '{{ scaleway_region }}' server_id: "{{ server_id }}" diff --git a/tests/integration/targets/sefcontext/tasks/sefcontext.yml b/tests/integration/targets/sefcontext/tasks/sefcontext.yml index e4d2d50baa..8f5039b85a 100644 --- a/tests/integration/targets/sefcontext/tasks/sefcontext.yml +++ b/tests/integration/targets/sefcontext/tasks/sefcontext.yml @@ -28,7 +28,7 @@ path: '/tmp/foo/bar(/.*)?' setype: httpd_sys_content_t state: present - reload: no + reload: false register: first - assert: @@ -41,7 +41,7 @@ path: '/tmp/foo/bar(/.*)?' setype: httpd_sys_content_t state: present - reload: no + reload: false register: second - assert: @@ -54,7 +54,7 @@ path: '/tmp/foo/bar(/.*)?' setype: unlabeled_t state: present - reload: no + reload: false register: third - assert: @@ -67,7 +67,7 @@ path: '/tmp/foo/bar(/.*)?' setype: unlabeled_t state: present - reload: no + reload: false register: fourth - assert: @@ -80,7 +80,7 @@ path: '/tmp/foo/bar(/.*)?' setype: httpd_sys_content_t state: absent - reload: no + reload: false register: fifth - assert: @@ -93,7 +93,7 @@ path: '/tmp/foo/bar(/.*)?' setype: unlabeled_t state: absent - reload: no + reload: false register: sixth - assert: diff --git a/tests/integration/targets/setup_etcd3/tasks/main.yml b/tests/integration/targets/setup_etcd3/tasks/main.yml index ddd7ab8988..fe6b9cd028 100644 --- a/tests/integration/targets/setup_etcd3/tasks/main.yml +++ b/tests/integration/targets/setup_etcd3/tasks/main.yml @@ -86,7 +86,7 @@ unarchive: src: "{{ etcd3_download_url }}" dest: "{{ etcd3_download_location }}" - remote_src: yes + remote_src: true # Running etcd3 and kill afterwards if it wasn't running before. - name: Run etcd3 diff --git a/tests/integration/targets/setup_gnutar/handlers/main.yml b/tests/integration/targets/setup_gnutar/handlers/main.yml index 975e0b47a8..f75354097f 100644 --- a/tests/integration/targets/setup_gnutar/handlers/main.yml +++ b/tests/integration/targets/setup_gnutar/handlers/main.yml @@ -7,5 +7,5 @@ community.general.homebrew: name: gnu-tar state: absent - become: yes + become: true become_user: "{{ brew_stat.stat.pw_name }}" diff --git a/tests/integration/targets/setup_gnutar/tasks/main.yml b/tests/integration/targets/setup_gnutar/tasks/main.yml index c7024666b0..8dbfebf6f8 100644 --- a/tests/integration/targets/setup_gnutar/tasks/main.yml +++ b/tests/integration/targets/setup_gnutar/tasks/main.yml @@ -18,7 +18,7 @@ community.general.homebrew: name: gnu-tar state: present - become: yes + become: true become_user: "{{ brew_stat.stat.pw_name }}" notify: - uninstall gnu-tar diff --git a/tests/integration/targets/setup_mosquitto/tasks/ubuntu.yml b/tests/integration/targets/setup_mosquitto/tasks/ubuntu.yml index dd1c340d08..8222aa175a 100644 --- a/tests/integration/targets/setup_mosquitto/tasks/ubuntu.yml +++ b/tests/integration/targets/setup_mosquitto/tasks/ubuntu.yml @@ -7,7 +7,7 @@ apt: name: apt-transport-https state: latest - force: yes + force: true - name: Install Mosquitto Server apt: diff --git a/tests/integration/targets/setup_pkg_mgr/tasks/main.yml b/tests/integration/targets/setup_pkg_mgr/tasks/main.yml index a42b4b4a03..7c6ab4ef9f 100644 --- a/tests/integration/targets/setup_pkg_mgr/tasks/main.yml +++ b/tests/integration/targets/setup_pkg_mgr/tasks/main.yml @@ -11,19 +11,19 @@ - set_fact: pkg_mgr: community.general.pkgng ansible_pkg_mgr: community.general.pkgng - cacheable: yes + cacheable: true when: ansible_os_family == "FreeBSD" - set_fact: pkg_mgr: community.general.zypper ansible_pkg_mgr: community.general.zypper - cacheable: yes + cacheable: true when: ansible_os_family == "Suse" - set_fact: pkg_mgr: community.general.pacman ansible_pkg_mgr: community.general.pacman - cacheable: yes + cacheable: true when: ansible_os_family == "Archlinux" - shell: diff --git a/tests/integration/targets/setup_postgresql_db/tasks/main.yml b/tests/integration/targets/setup_postgresql_db/tasks/main.yml index 7c9baa4074..3dac4a0986 100644 --- a/tests/integration/targets/setup_postgresql_db/tasks/main.yml +++ b/tests/integration/targets/setup_postgresql_db/tasks/main.yml @@ -50,9 +50,9 @@ - name: Kill all postgres processes shell: 'pkill -u {{ pg_user }}' - become: yes + become: true when: ansible_facts.distribution == 'CentOS' and ansible_facts.distribution_major_version == '8' - ignore_errors: yes + ignore_errors: true - name: stop postgresql service service: name={{ postgresql_service }} state=stopped @@ -202,9 +202,9 @@ - name: Kill all postgres processes shell: 'pkill -u {{ pg_user }}' - become: yes + become: true when: ansible_facts.distribution == 'CentOS' and ansible_facts.distribution_major_version == '8' - ignore_errors: yes + ignore_errors: true register: terminate - name: Stop postgresql service diff --git a/tests/integration/targets/setup_remote_tmp_dir/tasks/default-cleanup.yml b/tests/integration/targets/setup_remote_tmp_dir/tasks/default-cleanup.yml index e19d903e6b..cc74b70afc 100644 --- a/tests/integration/targets/setup_remote_tmp_dir/tasks/default-cleanup.yml +++ b/tests/integration/targets/setup_remote_tmp_dir/tasks/default-cleanup.yml @@ -7,4 +7,4 @@ file: path: "{{ remote_tmp_dir }}" state: absent - no_log: yes + no_log: true diff --git a/tests/integration/targets/setup_remote_tmp_dir_outside_tmp/tasks/default-cleanup.yml b/tests/integration/targets/setup_remote_tmp_dir_outside_tmp/tasks/default-cleanup.yml index e19d903e6b..cc74b70afc 100644 --- a/tests/integration/targets/setup_remote_tmp_dir_outside_tmp/tasks/default-cleanup.yml +++ b/tests/integration/targets/setup_remote_tmp_dir_outside_tmp/tasks/default-cleanup.yml @@ -7,4 +7,4 @@ file: path: "{{ remote_tmp_dir }}" state: absent - no_log: yes + no_log: true diff --git a/tests/integration/targets/setup_wildfly_server/handlers/main.yml b/tests/integration/targets/setup_wildfly_server/handlers/main.yml index 641025edb1..1383b15753 100644 --- a/tests/integration/targets/setup_wildfly_server/handlers/main.yml +++ b/tests/integration/targets/setup_wildfly_server/handlers/main.yml @@ -7,7 +7,7 @@ systemd: name: wildfly state: stopped - ignore_errors: yes + ignore_errors: true - name: Remove files file: diff --git a/tests/integration/targets/setup_wildfly_server/tasks/main.yml b/tests/integration/targets/setup_wildfly_server/tasks/main.yml index e2bda5736e..26f5083b0a 100644 --- a/tests/integration/targets/setup_wildfly_server/tasks/main.yml +++ b/tests/integration/targets/setup_wildfly_server/tasks/main.yml @@ -31,7 +31,7 @@ unarchive: src: '{{ wf_tmp_dir }}/wildfly-{{ wf_version }}.tar.gz' dest: '{{ wf_tmp_dir }}' - remote_src: yes + remote_src: true - name: Remove tar file: @@ -47,12 +47,12 @@ - name: Create group for wildfly group: name: '{{ wf_user }}' - system: yes + system: true - name: Create user for wildfly user: name: '{{ wf_user }}' - system: yes + system: true group: '{{ wf_user }}' home: '{{ wf_homedir }}' @@ -62,7 +62,7 @@ state: directory owner: '{{ wf_user }}' group: '{{ wf_user }}' - recurse: yes + recurse: true - name: Create config file copy: @@ -86,11 +86,11 @@ mode: "0644" - name: Create directories for testing the default deploy_path - become: yes + become: true file: path: '{{ default_deploy_root }}' state: directory - recurse: yes + recurse: true owner: '{{ wf_user }}' group: '{{ wf_user }}' @@ -102,6 +102,6 @@ - name: Reload systemd and start wildfly systemd: - daemon_reload: yes + daemon_reload: true name: wildfly state: started diff --git a/tests/integration/targets/shutdown/tasks/main.yml b/tests/integration/targets/shutdown/tasks/main.yml index 3f765ff059..dadeb62699 100644 --- a/tests/integration/targets/shutdown/tasks/main.yml +++ b/tests/integration/targets/shutdown/tasks/main.yml @@ -20,13 +20,13 @@ delay: 100 msg: "Custom Message" register: shutdown_result - check_mode: yes + check_mode: true - name: Execute shutdown with minus delay community.general.shutdown: delay: -100 register: shutdown_result_minus - check_mode: yes + check_mode: true - name: Verify Custom Message except Alpine, AIX assert: diff --git a/tests/integration/targets/ssh_config/tasks/main.yml b/tests/integration/targets/ssh_config/tasks/main.yml index d0b088302c..d594835bf1 100644 --- a/tests/integration/targets/ssh_config/tasks/main.yml +++ b/tests/integration/targets/ssh_config/tasks/main.yml @@ -36,7 +36,7 @@ - name: Fail for required argument community.general.ssh_config: ssh_config_file: "{{ ssh_config_test }}" - ignore_errors: yes + ignore_errors: true register: host_required - name: Check if ssh_config fails for required parameter host @@ -53,7 +53,7 @@ port: '2223' state: present register: host_add - check_mode: yes + check_mode: true - name: Check if changes are made in check mode assert: @@ -179,7 +179,7 @@ port: '2223' state: present register: mut_ex - ignore_errors: yes + ignore_errors: true - name: Check mutual exclusive test - user and ssh_config_file assert: diff --git a/tests/integration/targets/ssh_config/tasks/options.yml b/tests/integration/targets/ssh_config/tasks/options.yml index 65ce691cf8..9b617ad356 100644 --- a/tests/integration/targets/ssh_config/tasks/options.yml +++ b/tests/integration/targets/ssh_config/tasks/options.yml @@ -18,7 +18,7 @@ host_key_algorithms: "+ssh-rsa" state: present register: options_add - check_mode: yes + check_mode: true - name: Options - Check if changes are made in check mode assert: @@ -91,7 +91,7 @@ ssh_config_file: "{{ ssh_config_test }}" host: "options.example.com" proxycommand: "ssh new-jumphost.example.com -W %h:%p" - forward_agent: no + forward_agent: false host_key_algorithms: "+ssh-ed25519" state: present register: options_update @@ -111,7 +111,7 @@ ssh_config_file: "{{ ssh_config_test }}" host: "options.example.com" proxycommand: "ssh new-jumphost.example.com -W %h:%p" - forward_agent: no + forward_agent: false host_key_algorithms: "+ssh-ed25519" state: present register: options_update diff --git a/tests/integration/targets/supervisorctl/tasks/install_Linux.yml b/tests/integration/targets/supervisorctl/tasks/install_Linux.yml index e5a7b009e0..2f70b284cc 100644 --- a/tests/integration/targets/supervisorctl/tasks/install_Linux.yml +++ b/tests/integration/targets/supervisorctl/tasks/install_Linux.yml @@ -12,4 +12,4 @@ service: name: '{{ supervisor_service_name }}' state: stopped - enabled: no + enabled: false diff --git a/tests/integration/targets/sysrc/tasks/main.yml b/tests/integration/targets/sysrc/tasks/main.yml index 544dc63c65..df24cf1f94 100644 --- a/tests/integration/targets/sysrc/tasks/main.yml +++ b/tests/integration/targets/sysrc/tasks/main.yml @@ -29,7 +29,7 @@ sysrc: name: mysql_pidfile value: checkmode - check_mode: yes + check_mode: true register: sysrc_example1_checkmode - name: Configure mysql pid file (idempotent) @@ -68,7 +68,7 @@ state: present value: "NO" path: /boot/loader.conf - check_mode: yes + check_mode: true register: sysrc_example2_checkmode - name: Enable accf_http kld in /boot/loader.conf (idempotent) @@ -112,7 +112,7 @@ name: cloned_interfaces state: value_present value: "gif1" - check_mode: yes + check_mode: true register: sysrc_example3_checkmode - name: Add gif0 interface (idempotent) @@ -159,7 +159,7 @@ name: nginx_enable value: "NO" jail: testjail - check_mode: yes + check_mode: true register: sysrc_example4_checkmode - name: Enable nginx in test jail (idempotent) @@ -198,7 +198,7 @@ sysrc: name: sysrc_absent state: absent - check_mode: yes + check_mode: true register: sysrc_absent_checkmode - name: Remove sysrc_absent @@ -255,7 +255,7 @@ state: value_present delim: "," value: t4 - check_mode: yes + check_mode: true register: sysrc_delim_checkmode - name: Add to value with delimiter (idempotent) @@ -305,7 +305,7 @@ state: value_absent value: t2 delim: "," - check_mode: yes + check_mode: true register: sysrc_value_absent_checkmode - name: Remove value from sysrc_delim (idempotent diff --git a/tests/integration/targets/sysrc/tasks/setup-testjail.yml b/tests/integration/targets/sysrc/tasks/setup-testjail.yml index 4ad0d63b16..8aac7a430d 100644 --- a/tests/integration/targets/sysrc/tasks/setup-testjail.yml +++ b/tests/integration/targets/sysrc/tasks/setup-testjail.yml @@ -36,11 +36,11 @@ line: ezjail_ftphost=http://ftp-archive.freebsd.org - name: Start ezjail - ignore_errors: yes + ignore_errors: true service: name: ezjail state: started - enabled: yes + enabled: true - name: Has ezjail register: ezjail_base_jail diff --git a/tests/integration/targets/terraform/tasks/complex_variables.yml b/tests/integration/targets/terraform/tasks/complex_variables.yml index 180a1fb98c..9788a3eed1 100644 --- a/tests/integration/targets/terraform/tasks/complex_variables.yml +++ b/tests/integration/targets/terraform/tasks/complex_variables.yml @@ -23,7 +23,7 @@ community.general.terraform: project_path: "{{ terraform_project_dir }}/complex_vars" binary_path: "{{ terraform_binary_path }}" - force_init: yes + force_init: true complex_vars: true variables: dictionaries: diff --git a/tests/integration/targets/terraform/tasks/main.yml b/tests/integration/targets/terraform/tasks/main.yml index db9fc3fc5b..1c66990be2 100644 --- a/tests/integration/targets/terraform/tasks/main.yml +++ b/tests/integration/targets/terraform/tasks/main.yml @@ -43,7 +43,7 @@ src: "{{ terraform_url }}" dest: "{{ remote_tmp_dir }}" mode: 0755 - remote_src: yes + remote_src: true validate_certs: "{{ validate_certs }}" when: terraform_version_installed is not defined or terraform_version_installed != terraform_version diff --git a/tests/integration/targets/terraform/tasks/test_provider_upgrade.yml b/tests/integration/targets/terraform/tasks/test_provider_upgrade.yml index 711dfc1a33..b20182c9f3 100644 --- a/tests/integration/targets/terraform/tasks/test_provider_upgrade.yml +++ b/tests/integration/targets/terraform/tasks/test_provider_upgrade.yml @@ -16,7 +16,7 @@ ansible.builtin.template: src: templates/provider_test/main.tf.j2 dest: "{{ terraform_project_dir }}/{{ tf_provider['name'] }}/main.tf" - force: yes + force: true register: terraform_provider_hcl # The purpose of this task is to init terraform multiple times with different provider module @@ -26,7 +26,7 @@ community.general.terraform: project_path: "{{ terraform_provider_hcl.dest | dirname }}" binary_path: "{{ terraform_binary_path }}" - force_init: yes + force_init: true provider_upgrade: "{{ terraform_provider_upgrade }}" state: present register: terraform_init_result diff --git a/tests/integration/targets/terraform/vars/main.yml b/tests/integration/targets/terraform/vars/main.yml index 7474836387..1032adee4f 100644 --- a/tests/integration/targets/terraform/vars/main.yml +++ b/tests/integration/targets/terraform/vars/main.yml @@ -14,13 +14,13 @@ terraform_arch: "{{ ansible_system | lower }}_{{terraform_arch_map[ansible_archi terraform_url: "https://releases.hashicorp.com/terraform/{{ terraform_version }}/terraform_{{ terraform_version }}_{{ terraform_arch }}.zip" # Controls whether the unarchive task will validate TLS certs of the Terraform binary host -validate_certs: yes +validate_certs: true # Directory where Terraform tests will be created terraform_project_dir: "{{ remote_tmp_dir }}/tf_provider_test" # Controls whether terraform init will use the `-upgrade` flag -terraform_provider_upgrade: yes +terraform_provider_upgrade: true # list of dicts containing Terraform providers that will be tested # The null provider is a good candidate, as it's small and has no external dependencies diff --git a/tests/integration/targets/timezone/tasks/test.yml b/tests/integration/targets/timezone/tasks/test.yml index 5a58559d7c..975526800e 100644 --- a/tests/integration/targets/timezone/tasks/test.yml +++ b/tests/integration/targets/timezone/tasks/test.yml @@ -10,7 +10,7 @@ - name: set timezone to Australia/Brisbane (checkmode) timezone: name: Australia/Brisbane - check_mode: yes + check_mode: true register: timezone_set_checkmode - name: ensure timezone reported as changed in checkmode @@ -24,7 +24,7 @@ command: cmp /etc/localtime /usr/share/zoneinfo/Australia/Brisbane register: result failed_when: result is not failed - changed_when: no + changed_when: false - name: ensure that checkmode didn't update the timezone in the config file command: egrep '^(TIME)?ZONE="Etc/UTC"' {{ timezone_config_file }} @@ -52,7 +52,7 @@ - name: ensure that the timezone is actually set command: cmp /etc/localtime /usr/share/zoneinfo/Australia/Brisbane - changed_when: no + changed_when: false - name: ensure that the timezone is updated in the config file command: egrep '^(TIME)?ZONE="Australia/Brisbane"' {{ timezone_config_file }} @@ -93,14 +93,14 @@ - name: check dpkg-reconfigure shell: type dpkg-reconfigure register: check_dpkg_reconfigure - ignore_errors: yes - changed_when: no + ignore_errors: true + changed_when: false - name: check timedatectl shell: type timedatectl && timedatectl register: check_timedatectl - ignore_errors: yes - changed_when: no + ignore_errors: true + changed_when: false - block: - name: set timezone to Etc/UTC @@ -161,7 +161,7 @@ - name: check if the timezone is actually set (empty config file) command: cmp /etc/localtime /usr/share/zoneinfo/Europe/Belgrade - changed_when: no + changed_when: false ## @@ -187,7 +187,7 @@ - name: check if the timezone is actually set (no config file) command: cmp /etc/localtime /usr/share/zoneinfo/Europe/Belgrade - changed_when: no + changed_when: false ## @@ -199,7 +199,7 @@ src: /usr/share/zoneinfo/Etc/UTC dest: /etc/localtime state: link - force: yes + force: true - name: set timezone to Europe/Belgrade (over symlink) timezone: @@ -215,7 +215,7 @@ - name: check if the timezone is actually set (over symlink) command: cmp /etc/localtime /usr/share/zoneinfo/Europe/Belgrade - changed_when: no + changed_when: false ## @@ -227,7 +227,7 @@ src: /tmp/foo dest: /etc/localtime state: link - force: yes + force: true - name: set timezone to Europe/Belgrade (over broken symlink) timezone: @@ -243,7 +243,7 @@ - name: check if the timezone is actually set (over broken symlink) command: cmp /etc/localtime /usr/share/zoneinfo/Europe/Belgrade - changed_when: no + changed_when: false ## @@ -254,7 +254,7 @@ copy: src: /usr/share/zoneinfo/Etc/UTC dest: /etc/localtime - remote_src: yes + remote_src: true - name: set timezone to Europe/Belgrade (over copied file) timezone: @@ -270,7 +270,7 @@ - name: check if the timezone is actually set (over copied file) command: cmp /etc/localtime /usr/share/zoneinfo/Europe/Belgrade - changed_when: no + changed_when: false when: - ansible_service_mgr != 'systemd' - timezone_config_file is defined @@ -283,12 +283,12 @@ - name: check if hwclock is supported in the environment command: hwclock --test register: hwclock_test - ignore_errors: yes + ignore_errors: true - name: check if timedatectl works in the environment command: timedatectl register: timedatectl_test - ignore_errors: yes + ignore_errors: true - name: set_fact: @@ -305,7 +305,7 @@ - name: set hwclock to UTC (checkmode) timezone: hwclock: UTC - check_mode: yes + check_mode: true register: hwclock_set_checkmode - name: ensure hwclock reported as changed (checkmode) @@ -358,7 +358,7 @@ - name: set hwclock to RTC again (checkmode) timezone: hwclock: UTC - check_mode: yes + check_mode: true register: hwclock_again_checkmode - name: set hwclock idempotency (checkmode) @@ -510,7 +510,7 @@ timezone: name: Europe/Belgrade hwclock: UTC - check_mode: yes + check_mode: true register: tzclock_set_checkmode - name: ensure timezone and hwclock reported as changed in checkmode @@ -526,7 +526,7 @@ command: cmp /etc/localtime /usr/share/zoneinfo/Australia/Brisbane register: result failed_when: result is not failed - changed_when: no + changed_when: false - block: - name: ensure that checkmode didn't update the timezone in the config file @@ -565,7 +565,7 @@ - name: ensure that the timezone is actually set command: cmp /etc/localtime /usr/share/zoneinfo/Europe/Belgrade - changed_when: no + changed_when: false - block: - name: ensure that the timezone is updated in the config file diff --git a/tests/integration/targets/ufw/tasks/main.yml b/tests/integration/targets/ufw/tasks/main.yml index c870f85d47..5fba2fa4d7 100644 --- a/tests/integration/targets/ufw/tasks/main.yml +++ b/tests/integration/targets/ufw/tasks/main.yml @@ -18,10 +18,10 @@ - name: Install iptables (SuSE only) package: name: iptables - become: yes + become: true when: ansible_os_family == 'Suse' - name: Install ufw - become: yes + become: true package: name: ufw @@ -30,7 +30,7 @@ - include_tasks: run-test.yml with_fileglob: - "tests/*.yml" - become: yes + become: true # Cleanup always: diff --git a/tests/integration/targets/ufw/tasks/tests/basic.yml b/tests/integration/targets/ufw/tasks/tests/basic.yml index 9aac5e6dd8..8c179d7aed 100644 --- a/tests/integration/targets/ufw/tasks/tests/basic.yml +++ b/tests/integration/targets/ufw/tasks/tests/basic.yml @@ -10,7 +10,7 @@ - name: Enable (check mode) ufw: state: enabled - check_mode: yes + check_mode: true register: enable_check - name: Enable ufw: @@ -23,7 +23,7 @@ - name: Enable (idempotency, check mode) ufw: state: enabled - check_mode: yes + check_mode: true register: enable_idem_check - assert: that: @@ -38,7 +38,7 @@ rule: allow port: 23 to_ip: 0.0.0.0 - check_mode: yes + check_mode: true register: ipv4_allow_check - name: ipv4 allow ufw: @@ -57,7 +57,7 @@ rule: allow port: 23 to_ip: 0.0.0.0 - check_mode: yes + check_mode: true register: ipv4_allow_idem_check - assert: that: @@ -72,30 +72,30 @@ rule: allow port: 23 to_ip: 0.0.0.0 - delete: yes - check_mode: yes + delete: true + check_mode: true register: delete_ipv4_allow_check - name: delete ipv4 allow ufw: rule: allow port: 23 to_ip: 0.0.0.0 - delete: yes + delete: true register: delete_ipv4_allow - name: delete ipv4 allow (idempotency) ufw: rule: allow port: 23 to_ip: 0.0.0.0 - delete: yes + delete: true register: delete_ipv4_allow_idem - name: delete ipv4 allow (idempotency, check mode) ufw: rule: allow port: 23 to_ip: 0.0.0.0 - delete: yes - check_mode: yes + delete: true + check_mode: true register: delete_ipv4_allow_idem_check - assert: that: @@ -110,7 +110,7 @@ rule: allow port: 23 to_ip: "::" - check_mode: yes + check_mode: true register: ipv6_allow_check - name: ipv6 allow ufw: @@ -129,7 +129,7 @@ rule: allow port: 23 to_ip: "::" - check_mode: yes + check_mode: true register: ipv6_allow_idem_check - assert: that: @@ -144,30 +144,30 @@ rule: allow port: 23 to_ip: "::" - delete: yes - check_mode: yes + delete: true + check_mode: true register: delete_ipv6_allow_check - name: delete ipv6 allow ufw: rule: allow port: 23 to_ip: "::" - delete: yes + delete: true register: delete_ipv6_allow - name: delete ipv6 allow (idempotency) ufw: rule: allow port: 23 to_ip: "::" - delete: yes + delete: true register: delete_ipv6_allow_idem - name: delete ipv6 allow (idempotency, check mode) ufw: rule: allow port: 23 to_ip: "::" - delete: yes - check_mode: yes + delete: true + check_mode: true register: delete_ipv6_allow_idem_check - assert: that: @@ -183,7 +183,7 @@ rule: allow port: 23 to_ip: 0.0.0.0 - check_mode: yes + check_mode: true register: ipv4_allow_check - name: ipv4 allow ufw: @@ -202,7 +202,7 @@ rule: allow port: 23 to_ip: 0.0.0.0 - check_mode: yes + check_mode: true register: ipv4_allow_idem_check - assert: that: @@ -217,30 +217,30 @@ rule: allow port: 23 to_ip: 0.0.0.0 - delete: yes - check_mode: yes + delete: true + check_mode: true register: delete_ipv4_allow_check - name: delete ipv4 allow ufw: rule: allow port: 23 to_ip: 0.0.0.0 - delete: yes + delete: true register: delete_ipv4_allow - name: delete ipv4 allow (idempotency) ufw: rule: allow port: 23 to_ip: 0.0.0.0 - delete: yes + delete: true register: delete_ipv4_allow_idem - name: delete ipv4 allow (idempotency, check mode) ufw: rule: allow port: 23 to_ip: 0.0.0.0 - delete: yes - check_mode: yes + delete: true + check_mode: true register: delete_ipv4_allow_idem_check - assert: that: @@ -255,7 +255,7 @@ rule: allow port: 23 to_ip: "::" - check_mode: yes + check_mode: true register: ipv6_allow_check - name: ipv6 allow ufw: @@ -274,7 +274,7 @@ rule: allow port: 23 to_ip: "::" - check_mode: yes + check_mode: true register: ipv6_allow_idem_check - assert: that: @@ -289,30 +289,30 @@ rule: allow port: 23 to_ip: "::" - delete: yes - check_mode: yes + delete: true + check_mode: true register: delete_ipv6_allow_check - name: delete ipv6 allow ufw: rule: allow port: 23 to_ip: "::" - delete: yes + delete: true register: delete_ipv6_allow - name: delete ipv6 allow (idempotency) ufw: rule: allow port: 23 to_ip: "::" - delete: yes + delete: true register: delete_ipv6_allow_idem - name: delete ipv6 allow (idempotency, check mode) ufw: rule: allow port: 23 to_ip: "::" - delete: yes - check_mode: yes + delete: true + check_mode: true register: delete_ipv6_allow_idem_check - assert: that: @@ -329,7 +329,7 @@ - name: Reload ufw (check mode) ufw: state: reloaded - check_mode: yes + check_mode: true register: reload_check - assert: that: @@ -340,7 +340,7 @@ - name: Disable (check mode) ufw: state: disabled - check_mode: yes + check_mode: true register: disable_check - name: Disable ufw: @@ -353,7 +353,7 @@ - name: Disable (idempotency, check mode) ufw: state: disabled - check_mode: yes + check_mode: true register: disable_idem_check - assert: that: @@ -369,7 +369,7 @@ - name: Reset (check mode) ufw: state: reset - check_mode: yes + check_mode: true register: reset_check - pause: # Should not be needed, but since ufw is ignoring --dry-run for reset @@ -396,7 +396,7 @@ - name: Reset (idempotency, check mode) ufw: state: reset - check_mode: yes + check_mode: true register: reset_idem_check - assert: that: diff --git a/tests/integration/targets/ufw/tasks/tests/global-state.yml b/tests/integration/targets/ufw/tasks/tests/global-state.yml index 3e8ab4460e..f5f1007510 100644 --- a/tests/integration/targets/ufw/tasks/tests/global-state.yml +++ b/tests/integration/targets/ufw/tasks/tests/global-state.yml @@ -10,15 +10,15 @@ # ############################################ - name: Make sure logging is off ufw: - logging: no + logging: false - name: Logging (check mode) ufw: - logging: yes - check_mode: yes + logging: true + check_mode: true register: logging_check - name: Logging ufw: - logging: yes + logging: true register: logging - name: Get logging shell: | @@ -28,17 +28,17 @@ LC_ALL: C - name: Logging (idempotency) ufw: - logging: yes + logging: true register: logging_idem - name: Logging (idempotency, check mode) ufw: - logging: yes - check_mode: yes + logging: true + check_mode: true register: logging_idem_check - name: Logging (change, check mode) ufw: logging: full - check_mode: yes + check_mode: true register: logging_change_check - name: Logging (change) ufw: @@ -66,7 +66,7 @@ ufw: default: reject direction: incoming - check_mode: yes + check_mode: true register: default_check - name: Default ufw: @@ -88,13 +88,13 @@ ufw: default: reject direction: incoming - check_mode: yes + check_mode: true register: default_idem_check - name: Default (change, check mode) ufw: default: allow direction: incoming - check_mode: yes + check_mode: true register: default_change_check - name: Default (change) ufw: @@ -115,7 +115,7 @@ - name: Default (change incoming implicitly, check mode) ufw: default: allow - check_mode: yes + check_mode: true register: default_change_implicit_check - name: Default (change incoming implicitly) ufw: @@ -130,7 +130,7 @@ - name: Default (change incoming implicitly, idempotent, check mode) ufw: default: allow - check_mode: yes + check_mode: true register: default_change_implicit_idem_check - name: Default (change incoming implicitly, idempotent) ufw: diff --git a/tests/integration/targets/ufw/tasks/tests/interface.yml b/tests/integration/targets/ufw/tasks/tests/interface.yml index 9c7c570dc7..1ec3568aa2 100644 --- a/tests/integration/targets/ufw/tasks/tests/interface.yml +++ b/tests/integration/targets/ufw/tasks/tests/interface.yml @@ -10,7 +10,7 @@ - name: Route with interface in and out ufw: rule: allow - route: yes + route: true interface_in: foo interface_out: bar proto: tcp @@ -22,7 +22,7 @@ - name: Route with interface in ufw: rule: allow - route: yes + route: true interface_in: foo proto: tcp from_ip: 1.1.1.1 @@ -31,7 +31,7 @@ - name: Route with interface out ufw: rule: allow - route: yes + route: true interface_out: bar proto: tcp from_ip: 1.1.1.1 @@ -77,7 +77,7 @@ from_port: 1111 to_ip: 8.8.8.8 to_port: 2222 - ignore_errors: yes + ignore_errors: true register: ufw_non_route_iface - assert: diff --git a/tests/integration/targets/wakeonlan/tasks/main.yml b/tests/integration/targets/wakeonlan/tasks/main.yml index 03df57e989..0597480318 100644 --- a/tests/integration/targets/wakeonlan/tasks/main.yml +++ b/tests/integration/targets/wakeonlan/tasks/main.yml @@ -22,7 +22,7 @@ wakeonlan: mac: 00-00-5E-00-53-66-AB port: 9 - ignore_errors: yes + ignore_errors: true register: incorrect_mac_length - name: Check error message @@ -35,7 +35,7 @@ wakeonlan: mac: ZW-YX-WV-UT-SR-QP port: 9 - ignore_errors: yes + ignore_errors: true register: incorrect_mac_format - name: Check error message @@ -48,7 +48,7 @@ wakeonlan: mac: 00-00-5E-00-53-66 broadcast: 345.567.678.890 - ignore_errors: yes + ignore_errors: true register: incorrect_broadcast_address - name: Check error message diff --git a/tests/integration/targets/xattr/tasks/main.yml b/tests/integration/targets/xattr/tasks/main.yml index b5293db770..b6e93d92bc 100644 --- a/tests/integration/targets/xattr/tasks/main.yml +++ b/tests/integration/targets/xattr/tasks/main.yml @@ -13,7 +13,7 @@ - name: Check availability of xattr support command: setfattr -n user.foo {{ test_file }} - ignore_errors: yes + ignore_errors: true register: xattr - name: Test diff --git a/tests/integration/targets/xfs_quota/tasks/main.yml b/tests/integration/targets/xfs_quota/tasks/main.yml index e98b1452ab..b1ad1da4e9 100644 --- a/tests/integration/targets/xfs_quota/tasks/main.yml +++ b/tests/integration/targets/xfs_quota/tasks/main.yml @@ -13,7 +13,7 @@ user: name: xfsquotauser state: present - become: yes + become: true - include_tasks: uquota.yml - include_tasks: gquota.yml @@ -24,4 +24,4 @@ user: name: xfsquotauser state: absent - become: yes + become: true diff --git a/tests/integration/targets/xml/tasks/test-add-children-elements-unicode.yml b/tests/integration/targets/xml/tasks/test-add-children-elements-unicode.yml index fbc74a9367..e15ac5fd92 100644 --- a/tests/integration/targets/xml/tasks/test-add-children-elements-unicode.yml +++ b/tests/integration/targets/xml/tasks/test-add-children-elements-unicode.yml @@ -24,8 +24,8 @@ copy: src: results/test-add-children-elements-unicode.xml dest: /tmp/ansible-xml-beers.xml - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison - name: Test expected result diff --git a/tests/integration/targets/xml/tasks/test-add-children-elements.yml b/tests/integration/targets/xml/tasks/test-add-children-elements.yml index 7b5e0be42a..29467f6d6f 100644 --- a/tests/integration/targets/xml/tasks/test-add-children-elements.yml +++ b/tests/integration/targets/xml/tasks/test-add-children-elements.yml @@ -24,8 +24,8 @@ copy: src: results/test-add-children-elements.xml dest: /tmp/ansible-xml-beers.xml - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison - name: Test expected result diff --git a/tests/integration/targets/xml/tasks/test-add-children-from-groupvars.yml b/tests/integration/targets/xml/tasks/test-add-children-from-groupvars.yml index f6733d6e82..2b232b6d0d 100644 --- a/tests/integration/targets/xml/tasks/test-add-children-from-groupvars.yml +++ b/tests/integration/targets/xml/tasks/test-add-children-from-groupvars.yml @@ -23,8 +23,8 @@ copy: src: results/test-add-children-from-groupvars.xml dest: /tmp/ansible-xml-beers.xml - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison - name: Test expected result diff --git a/tests/integration/targets/xml/tasks/test-add-children-insertafter.yml b/tests/integration/targets/xml/tasks/test-add-children-insertafter.yml index fbeff105b2..7795c89663 100644 --- a/tests/integration/targets/xml/tasks/test-add-children-insertafter.yml +++ b/tests/integration/targets/xml/tasks/test-add-children-insertafter.yml @@ -13,20 +13,20 @@ xml: path: /tmp/ansible-xml-beers.xml xpath: '/business/beers/beer[text()="St. Bernardus Abbot 12"]' - insertafter: yes + insertafter: true add_children: - beer: Old Rasputin - beer: Old Motor Oil - beer: Old Curmudgeon - pretty_print: yes + pretty_print: true register: add_children_insertafter - name: Compare to expected result copy: src: results/test-add-children-insertafter.xml dest: /tmp/ansible-xml-beers.xml - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison - name: Test expected result diff --git a/tests/integration/targets/xml/tasks/test-add-children-insertbefore.yml b/tests/integration/targets/xml/tasks/test-add-children-insertbefore.yml index 3c3212c30e..b14c5e06fc 100644 --- a/tests/integration/targets/xml/tasks/test-add-children-insertbefore.yml +++ b/tests/integration/targets/xml/tasks/test-add-children-insertbefore.yml @@ -13,20 +13,20 @@ xml: path: /tmp/ansible-xml-beers.xml xpath: '/business/beers/beer[text()="St. Bernardus Abbot 12"]' - insertbefore: yes + insertbefore: true add_children: - beer: Old Rasputin - beer: Old Motor Oil - beer: Old Curmudgeon - pretty_print: yes + pretty_print: true register: add_children_insertbefore - name: Compare to expected result copy: src: results/test-add-children-insertbefore.xml dest: /tmp/ansible-xml-beers.xml - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison - name: Test expected result diff --git a/tests/integration/targets/xml/tasks/test-add-children-with-attributes-unicode.yml b/tests/integration/targets/xml/tasks/test-add-children-with-attributes-unicode.yml index 7c928b239d..07905aa15c 100644 --- a/tests/integration/targets/xml/tasks/test-add-children-with-attributes-unicode.yml +++ b/tests/integration/targets/xml/tasks/test-add-children-with-attributes-unicode.yml @@ -26,8 +26,8 @@ copy: src: results/test-add-children-with-attributes-unicode.xml dest: /tmp/ansible-xml-beers.xml - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison - name: Test expected result diff --git a/tests/integration/targets/xml/tasks/test-add-children-with-attributes.yml b/tests/integration/targets/xml/tasks/test-add-children-with-attributes.yml index e11dda7639..fede24395f 100644 --- a/tests/integration/targets/xml/tasks/test-add-children-with-attributes.yml +++ b/tests/integration/targets/xml/tasks/test-add-children-with-attributes.yml @@ -26,8 +26,8 @@ copy: src: results/test-add-children-with-attributes.xml dest: /tmp/ansible-xml-beers.xml - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison # NOTE: This test may fail if lxml does not support predictable element attribute order diff --git a/tests/integration/targets/xml/tasks/test-add-element-implicitly.yml b/tests/integration/targets/xml/tasks/test-add-element-implicitly.yml index e3ed8080f7..b1718e452e 100644 --- a/tests/integration/targets/xml/tasks/test-add-element-implicitly.yml +++ b/tests/integration/targets/xml/tasks/test-add-element-implicitly.yml @@ -57,28 +57,28 @@ file: /tmp/ansible-xml-beers-implicit.xml xpath: /business/testnormalelement value: xml tag with no special characters - pretty_print: yes + pretty_print: true - name: Add an element with dash xml: file: /tmp/ansible-xml-beers-implicit.xml xpath: /business/test-with-dash value: xml tag with dashes - pretty_print: yes + pretty_print: true - name: Add an element with dot xml: file: /tmp/ansible-xml-beers-implicit.xml xpath: /business/test-with-dash.and.dot value: xml tag with dashes and dots - pretty_print: yes + pretty_print: true - name: Add an element with underscore xml: file: /tmp/ansible-xml-beers-implicit.xml xpath: /business/test-with.dash_and.dot_and-underscores value: xml tag with dashes, dots and underscores - pretty_print: yes + pretty_print: true - name: Add an attribute on a conditional element xml: @@ -99,14 +99,14 @@ - name: Pretty Print this! xml: file: /tmp/ansible-xml-beers-implicit.xml - pretty_print: yes + pretty_print: true - name: Compare to expected result copy: src: results/test-add-element-implicitly.xml dest: /tmp/ansible-xml-beers-implicit.xml - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison - name: Test expected result @@ -203,7 +203,7 @@ file: /tmp/ansible-xml-beers-implicit.xml xpath: /business/testnormalelement value: xml tag with no special characters - pretty_print: yes + pretty_print: true namespaces: a: http://example.com/some/namespace @@ -213,7 +213,7 @@ file: /tmp/ansible-xml-beers-implicit.xml xpath: /business/test-with-dash value: xml tag with dashes - pretty_print: yes + pretty_print: true namespaces: a: http://example.com/some/namespace @@ -222,7 +222,7 @@ file: /tmp/ansible-xml-beers-implicit.xml xpath: /business/test-with-dash.and.dot value: xml tag with dashes and dots - pretty_print: yes + pretty_print: true namespaces: a: http://example.com/some/namespace @@ -231,11 +231,11 @@ file: /tmp/ansible-xml-beers-implicit.xml xpath: /business/test-with.dash_and.dot_and-underscores value: xml tag with dashes, dots and underscores - pretty_print: yes + pretty_print: true namespaces: a: http://example.com/some/namespace - name: Pretty Print this! xml: file: /tmp/ansible-xml-beers-implicit.xml - pretty_print: yes + pretty_print: true diff --git a/tests/integration/targets/xml/tasks/test-add-namespaced-children-elements.yml b/tests/integration/targets/xml/tasks/test-add-namespaced-children-elements.yml index dd3ada48e1..2a9daab787 100644 --- a/tests/integration/targets/xml/tasks/test-add-namespaced-children-elements.yml +++ b/tests/integration/targets/xml/tasks/test-add-namespaced-children-elements.yml @@ -27,8 +27,8 @@ copy: src: results/test-add-namespaced-children-elements.xml dest: /tmp/ansible-xml-namespaced-beers.xml - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison - name: Test expected result diff --git a/tests/integration/targets/xml/tasks/test-children-elements-xml.yml b/tests/integration/targets/xml/tasks/test-children-elements-xml.yml index 139281fb34..1c8c2b804d 100644 --- a/tests/integration/targets/xml/tasks/test-children-elements-xml.yml +++ b/tests/integration/targets/xml/tasks/test-children-elements-xml.yml @@ -25,8 +25,8 @@ copy: src: results/test-add-children-elements.xml dest: /tmp/ansible-xml-beers.xml - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison - name: Test expected result diff --git a/tests/integration/targets/xml/tasks/test-count-unicode.yml b/tests/integration/targets/xml/tasks/test-count-unicode.yml index 58d01b8318..118e2986db 100644 --- a/tests/integration/targets/xml/tasks/test-count-unicode.yml +++ b/tests/integration/targets/xml/tasks/test-count-unicode.yml @@ -13,7 +13,7 @@ xml: path: /tmp/ansible-xml-beers-unicode.xml xpath: /business/beers/beer - count: yes + count: true register: beers - name: Test expected result diff --git a/tests/integration/targets/xml/tasks/test-count.yml b/tests/integration/targets/xml/tasks/test-count.yml index cc778ddcd6..79be9402fe 100644 --- a/tests/integration/targets/xml/tasks/test-count.yml +++ b/tests/integration/targets/xml/tasks/test-count.yml @@ -13,7 +13,7 @@ xml: path: /tmp/ansible-xml-beers.xml xpath: /business/beers/beer - count: yes + count: true register: beers - name: Test expected result diff --git a/tests/integration/targets/xml/tasks/test-mutually-exclusive-attributes.yml b/tests/integration/targets/xml/tasks/test-mutually-exclusive-attributes.yml index 0eb92fe083..33f129e2e6 100644 --- a/tests/integration/targets/xml/tasks/test-mutually-exclusive-attributes.yml +++ b/tests/integration/targets/xml/tasks/test-mutually-exclusive-attributes.yml @@ -17,7 +17,7 @@ - child02 value: conflict! register: module_output - ignore_errors: yes + ignore_errors: true - name: Test expected result assert: diff --git a/tests/integration/targets/xml/tasks/test-pretty-print-only.yml b/tests/integration/targets/xml/tasks/test-pretty-print-only.yml index 0657186ca5..03d3299aa7 100644 --- a/tests/integration/targets/xml/tasks/test-pretty-print-only.yml +++ b/tests/integration/targets/xml/tasks/test-pretty-print-only.yml @@ -14,15 +14,15 @@ - name: Pretty print without modification xml: path: /tmp/ansible-xml-beers.xml - pretty_print: yes + pretty_print: true register: pretty_print_only - name: Compare to expected result copy: src: results/test-pretty-print-only.xml dest: /tmp/ansible-xml-beers.xml - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison - name: Test expected result diff --git a/tests/integration/targets/xml/tasks/test-pretty-print.yml b/tests/integration/targets/xml/tasks/test-pretty-print.yml index 2ef0a0ce8b..51b34502d5 100644 --- a/tests/integration/targets/xml/tasks/test-pretty-print.yml +++ b/tests/integration/targets/xml/tasks/test-pretty-print.yml @@ -13,7 +13,7 @@ xml: path: /tmp/ansible-xml-beers.xml xpath: /business/beers - pretty_print: yes + pretty_print: true add_children: - beer: Old Rasputin register: pretty_print @@ -22,8 +22,8 @@ copy: src: results/test-pretty-print.xml dest: /tmp/ansible-xml-beers.xml - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison - name: Test expected result diff --git a/tests/integration/targets/xml/tasks/test-remove-attribute-nochange.yml b/tests/integration/targets/xml/tasks/test-remove-attribute-nochange.yml index 97bc7f525a..3222bd4368 100644 --- a/tests/integration/targets/xml/tasks/test-remove-attribute-nochange.yml +++ b/tests/integration/targets/xml/tasks/test-remove-attribute-nochange.yml @@ -20,8 +20,8 @@ copy: src: results/test-remove-attribute.xml dest: /tmp/ansible-xml-beers.xml - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison - name: Test expected result diff --git a/tests/integration/targets/xml/tasks/test-remove-attribute.yml b/tests/integration/targets/xml/tasks/test-remove-attribute.yml index 84e15aa446..e8952a655e 100644 --- a/tests/integration/targets/xml/tasks/test-remove-attribute.yml +++ b/tests/integration/targets/xml/tasks/test-remove-attribute.yml @@ -23,8 +23,8 @@ copy: src: results/test-remove-attribute.xml dest: /tmp/ansible-xml-beers.xml - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison - name: Test expected result diff --git a/tests/integration/targets/xml/tasks/test-remove-element-nochange.yml b/tests/integration/targets/xml/tasks/test-remove-element-nochange.yml index ada95029e8..c1312c5a75 100644 --- a/tests/integration/targets/xml/tasks/test-remove-element-nochange.yml +++ b/tests/integration/targets/xml/tasks/test-remove-element-nochange.yml @@ -20,8 +20,8 @@ copy: src: results/test-remove-element.xml dest: /tmp/ansible-xml-beers.xml - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison - name: Test expected result diff --git a/tests/integration/targets/xml/tasks/test-remove-element.yml b/tests/integration/targets/xml/tasks/test-remove-element.yml index 243e148984..bea376ba93 100644 --- a/tests/integration/targets/xml/tasks/test-remove-element.yml +++ b/tests/integration/targets/xml/tasks/test-remove-element.yml @@ -23,8 +23,8 @@ copy: src: results/test-remove-element.xml dest: /tmp/ansible-xml-beers.xml - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison - name: Test expected result diff --git a/tests/integration/targets/xml/tasks/test-remove-namespaced-attribute-nochange.yml b/tests/integration/targets/xml/tasks/test-remove-namespaced-attribute-nochange.yml index 80dc6fee42..61b7179ba0 100644 --- a/tests/integration/targets/xml/tasks/test-remove-namespaced-attribute-nochange.yml +++ b/tests/integration/targets/xml/tasks/test-remove-namespaced-attribute-nochange.yml @@ -25,8 +25,8 @@ copy: src: results/test-remove-namespaced-attribute.xml dest: /tmp/ansible-xml-namespaced-beers.xml - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison - name: Test expected result diff --git a/tests/integration/targets/xml/tasks/test-remove-namespaced-attribute.yml b/tests/integration/targets/xml/tasks/test-remove-namespaced-attribute.yml index 75c1a505d9..a725ee79cf 100644 --- a/tests/integration/targets/xml/tasks/test-remove-namespaced-attribute.yml +++ b/tests/integration/targets/xml/tasks/test-remove-namespaced-attribute.yml @@ -28,8 +28,8 @@ copy: src: results/test-remove-namespaced-attribute.xml dest: /tmp/ansible-xml-namespaced-beers.xml - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison - name: Test expected result diff --git a/tests/integration/targets/xml/tasks/test-remove-namespaced-element-nochange.yml b/tests/integration/targets/xml/tasks/test-remove-namespaced-element-nochange.yml index 5bbb9ef7c7..fd83c54c32 100644 --- a/tests/integration/targets/xml/tasks/test-remove-namespaced-element-nochange.yml +++ b/tests/integration/targets/xml/tasks/test-remove-namespaced-element-nochange.yml @@ -25,8 +25,8 @@ copy: src: results/test-remove-element.xml dest: /tmp/ansible-xml-namespaced-beers.xml - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison - name: Test expected result diff --git a/tests/integration/targets/xml/tasks/test-remove-namespaced-element.yml b/tests/integration/targets/xml/tasks/test-remove-namespaced-element.yml index 70a86dcd30..c4129f33e2 100644 --- a/tests/integration/targets/xml/tasks/test-remove-namespaced-element.yml +++ b/tests/integration/targets/xml/tasks/test-remove-namespaced-element.yml @@ -28,8 +28,8 @@ copy: src: results/test-remove-element.xml dest: /tmp/ansible-xml-namespaced-beers.xml - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison - name: Test expected result diff --git a/tests/integration/targets/xml/tasks/test-set-attribute-value-unicode.yml b/tests/integration/targets/xml/tasks/test-set-attribute-value-unicode.yml index 27e759c6b8..bf35bfdd95 100644 --- a/tests/integration/targets/xml/tasks/test-set-attribute-value-unicode.yml +++ b/tests/integration/targets/xml/tasks/test-set-attribute-value-unicode.yml @@ -24,8 +24,8 @@ copy: src: results/test-set-attribute-value-unicode.xml dest: /tmp/ansible-xml-beers.xml - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison - name: Test expected result diff --git a/tests/integration/targets/xml/tasks/test-set-attribute-value.yml b/tests/integration/targets/xml/tasks/test-set-attribute-value.yml index ada4d9ab56..2908e00aa3 100644 --- a/tests/integration/targets/xml/tasks/test-set-attribute-value.yml +++ b/tests/integration/targets/xml/tasks/test-set-attribute-value.yml @@ -24,8 +24,8 @@ copy: src: results/test-set-attribute-value.xml dest: /tmp/ansible-xml-beers.xml - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison - name: Test expected result diff --git a/tests/integration/targets/xml/tasks/test-set-children-elements-level.yml b/tests/integration/targets/xml/tasks/test-set-children-elements-level.yml index 7fb755bfcc..648f5b25af 100644 --- a/tests/integration/targets/xml/tasks/test-set-children-elements-level.yml +++ b/tests/integration/targets/xml/tasks/test-set-children-elements-level.yml @@ -47,8 +47,8 @@ copy: src: results/test-set-children-elements-level.xml dest: /tmp/ansible-xml-beers.xml - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison - name: Test expected result @@ -70,8 +70,8 @@ copy: src: results/test-set-children-elements-level.xml dest: /tmp/ansible-xml-beers.xml - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison - name: Test expected result diff --git a/tests/integration/targets/xml/tasks/test-set-children-elements-unicode.yml b/tests/integration/targets/xml/tasks/test-set-children-elements-unicode.yml index 5e3a7a5758..8c4fc10941 100644 --- a/tests/integration/targets/xml/tasks/test-set-children-elements-unicode.yml +++ b/tests/integration/targets/xml/tasks/test-set-children-elements-unicode.yml @@ -25,8 +25,8 @@ copy: src: results/test-set-children-elements-unicode.xml dest: /tmp/ansible-xml-beers.xml - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison - name: Test expected result @@ -41,8 +41,8 @@ copy: src: results/test-set-children-elements-unicode.xml dest: /tmp/ansible-xml-beers.xml - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison - name: Test expected result diff --git a/tests/integration/targets/xml/tasks/test-set-children-elements.yml b/tests/integration/targets/xml/tasks/test-set-children-elements.yml index 147f493c97..ed9e4a54ee 100644 --- a/tests/integration/targets/xml/tasks/test-set-children-elements.yml +++ b/tests/integration/targets/xml/tasks/test-set-children-elements.yml @@ -19,8 +19,8 @@ copy: src: results/test-set-children-elements-empty-list.xml dest: /tmp/ansible-xml-beers.xml - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison - name: Test expected result @@ -51,8 +51,8 @@ copy: src: results/test-set-children-elements.xml dest: /tmp/ansible-xml-beers.xml - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison - name: Test expected result @@ -74,8 +74,8 @@ copy: src: results/test-set-children-elements.xml dest: /tmp/ansible-xml-beers.xml - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison - name: Test expected result diff --git a/tests/integration/targets/xml/tasks/test-set-element-value-empty.yml b/tests/integration/targets/xml/tasks/test-set-element-value-empty.yml index 49a4903ad0..4041bf9106 100644 --- a/tests/integration/targets/xml/tasks/test-set-element-value-empty.yml +++ b/tests/integration/targets/xml/tasks/test-set-element-value-empty.yml @@ -23,8 +23,8 @@ copy: src: results/test-set-element-value-empty.xml dest: /tmp/ansible-xml-beers.xml - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison - name: Test expected result diff --git a/tests/integration/targets/xml/tasks/test-set-element-value-unicode.yml b/tests/integration/targets/xml/tasks/test-set-element-value-unicode.yml index 9dbb47b94b..616f26ddc8 100644 --- a/tests/integration/targets/xml/tasks/test-set-element-value-unicode.yml +++ b/tests/integration/targets/xml/tasks/test-set-element-value-unicode.yml @@ -37,8 +37,8 @@ copy: src: results/test-set-element-value-unicode.xml dest: /tmp/ansible-xml-beers.xml - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison - name: Test expected result diff --git a/tests/integration/targets/xml/tasks/test-set-element-value.yml b/tests/integration/targets/xml/tasks/test-set-element-value.yml index 50bbe71f95..b563b25766 100644 --- a/tests/integration/targets/xml/tasks/test-set-element-value.yml +++ b/tests/integration/targets/xml/tasks/test-set-element-value.yml @@ -37,8 +37,8 @@ copy: src: results/test-set-element-value.xml dest: /tmp/ansible-xml-beers.xml - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison - name: Test expected result diff --git a/tests/integration/targets/xml/tasks/test-set-namespaced-attribute-value.yml b/tests/integration/targets/xml/tasks/test-set-namespaced-attribute-value.yml index 90a9aef725..7c1bbd2376 100644 --- a/tests/integration/targets/xml/tasks/test-set-namespaced-attribute-value.yml +++ b/tests/integration/targets/xml/tasks/test-set-namespaced-attribute-value.yml @@ -29,8 +29,8 @@ copy: src: results/test-set-namespaced-attribute-value.xml dest: /tmp/ansible-xml-namespaced-beers.xml - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison - name: Test expected result diff --git a/tests/integration/targets/xml/tasks/test-set-namespaced-children-elements.yml b/tests/integration/targets/xml/tasks/test-set-namespaced-children-elements.yml index 72d342c514..e6ed1bdecc 100644 --- a/tests/integration/targets/xml/tasks/test-set-namespaced-children-elements.yml +++ b/tests/integration/targets/xml/tasks/test-set-namespaced-children-elements.yml @@ -23,7 +23,7 @@ copy: src: /tmp/ansible-xml-namespaced-beers.xml dest: /tmp/ansible-xml-namespaced-beers-1.xml - remote_src: yes + remote_src: true - name: Set child elements again xml: @@ -41,15 +41,15 @@ copy: src: /tmp/ansible-xml-namespaced-beers.xml dest: /tmp/ansible-xml-namespaced-beers-2.xml - remote_src: yes + remote_src: true - name: Compare to expected result copy: src: /tmp/ansible-xml-namespaced-beers-1.xml dest: /tmp/ansible-xml-namespaced-beers-2.xml - remote_src: yes - check_mode: yes - diff: yes + remote_src: true + check_mode: true + diff: true register: comparison #command: diff /tmp/ansible-xml-namespaced-beers-1.xml /tmp/ansible-xml-namespaced-beers-2.xml diff --git a/tests/integration/targets/xml/tasks/test-set-namespaced-element-value.yml b/tests/integration/targets/xml/tasks/test-set-namespaced-element-value.yml index 7b3839a2b3..9944da8a55 100644 --- a/tests/integration/targets/xml/tasks/test-set-namespaced-element-value.yml +++ b/tests/integration/targets/xml/tasks/test-set-namespaced-element-value.yml @@ -40,8 +40,8 @@ copy: src: results/test-set-namespaced-element-value.xml dest: /tmp/ansible-xml-namespaced-beers.xml - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison #command: diff -u {{ role_path }}/results/test-set-namespaced-element-value.xml /tmp/ansible-xml-namespaced-beers.xml diff --git a/tests/integration/targets/xml/tasks/test-xmlstring.yml b/tests/integration/targets/xml/tasks/test-xmlstring.yml index 4a0e4ad343..1c2e4de4a8 100644 --- a/tests/integration/targets/xml/tasks/test-xmlstring.yml +++ b/tests/integration/targets/xml/tasks/test-xmlstring.yml @@ -22,8 +22,8 @@ copy: content: "{{ xmlresponse.xmlstring }}\n" dest: '/tmp/test-pretty-print-only.xml' - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison - name: Test expected result @@ -38,15 +38,15 @@ - name: Read from xmlstring (using pretty_print) xml: xmlstring: "{{ lookup('file', '{{ role_path }}/fixtures/ansible-xml-beers.xml') }}" - pretty_print: yes + pretty_print: true register: xmlresponse - name: Compare to expected result copy: content: '{{ xmlresponse.xmlstring }}' dest: '/tmp/test-pretty-print-only.xml' - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison # FIXME: This change is related to the newline added by pretty_print @@ -63,7 +63,7 @@ xml: xmlstring: "{{ lookup('file', '{{ role_path }}/fixtures/ansible-xml-beers.xml') }}" xpath: /business/beers - pretty_print: yes + pretty_print: true add_children: - beer: Old Rasputin register: xmlresponse_modification @@ -72,8 +72,8 @@ copy: content: '{{ xmlresponse_modification.xmlstring }}' dest: '/tmp/test-pretty-print.xml' - check_mode: yes - diff: yes + check_mode: true + diff: true register: comparison # FIXME: This change is related to the newline added by pretty_print diff --git a/tests/integration/targets/yarn/tasks/run.yml b/tests/integration/targets/yarn/tasks/run.yml index 6521d45fcf..93a3d5bb55 100644 --- a/tests/integration/targets/yarn/tasks/run.yml +++ b/tests/integration/targets/yarn/tasks/run.yml @@ -12,14 +12,14 @@ unarchive: src: 'https://ansible-ci-files.s3.amazonaws.com/test/integration/targets/yarn/{{ nodejs_path }}.tar.gz' dest: '{{ remote_tmp_dir }}' - remote_src: yes + remote_src: true creates: '{{ remote_tmp_dir }}/{{ nodejs_path }}.tar.gz' - name: 'Download Yarn' unarchive: src: 'https://ansible-ci-files.s3.amazonaws.com/test/integration/targets/yarn/yarn-v{{yarn_version}}.tar.gz' dest: '{{ remote_tmp_dir }}' - remote_src: yes + remote_src: true creates: '{{ remote_tmp_dir }}/yarn-v{{yarn_version}}_pkg.tar.gz' - name: 'Copy node to directory created earlier' diff --git a/tests/integration/targets/yum_versionlock/tasks/main.yml b/tests/integration/targets/yum_versionlock/tasks/main.yml index d1d6726247..05f1f74954 100644 --- a/tests/integration/targets/yum_versionlock/tasks/main.yml +++ b/tests/integration/targets/yum_versionlock/tasks/main.yml @@ -63,7 +63,7 @@ yum: name: '*' state: latest - check_mode: yes + check_mode: true register: update_all_packages when: yum_updates.results | length != 0 diff --git a/tests/integration/targets/zypper/tasks/zypper.yml b/tests/integration/targets/zypper/tasks/zypper.yml index ab1bc179eb..9e840676e9 100644 --- a/tests/integration/targets/zypper/tasks/zypper.yml +++ b/tests/integration/targets/zypper/tasks/zypper.yml @@ -144,7 +144,7 @@ name: doesnotexist state: present register: zypper_result - ignore_errors: yes + ignore_errors: true - name: verify package installation failed assert: @@ -168,7 +168,7 @@ name: "{{remote_tmp_dir | expanduser}}/zypper1/broken.rpm" state: present register: zypper_result - ignore_errors: yes + ignore_errors: true - debug: var=zypper_result @@ -219,7 +219,7 @@ - name: install empty rpm zypper: name: "{{ remote_tmp_dir | expanduser }}/zypper2/rpm-build/noarch/empty-1-0.noarch.rpm" - disable_gpg_check: yes + disable_gpg_check: true register: zypper_result - name: check empty with rpm @@ -243,7 +243,7 @@ zypper: name: "{{ remote_tmp_dir | expanduser }}/zypper2/rpm-build/noarch/empty-1-0.noarch.rpm" state: installed - disable_gpg_check: yes + disable_gpg_check: true extra_args_precommand: --root {{ remote_tmp_dir | expanduser }}/testdir/ - name: check that dir var is exist @@ -322,7 +322,7 @@ - +hello state: absent register: zypper_res - ignore_errors: yes + ignore_errors: true - name: verify simultaneous install/remove failed with absent assert: @@ -335,7 +335,7 @@ name: openSUSE-2016-128 type: patch state: absent - ignore_errors: yes + ignore_errors: true register: zypper_patch - assert: that: @@ -346,7 +346,7 @@ zypper: name: "{{ hello_package_url }}" state: absent - ignore_errors: yes + ignore_errors: true register: zypper_rm - assert: that: @@ -440,7 +440,7 @@ # zypper: # name: gnu-netcat # state: present -# ignore_errors: yes +# ignore_errors: true # register: zypper_pkg_conflict # # - assert: diff --git a/tests/integration/targets/zypper_repository/tasks/zypper_repository.yml b/tests/integration/targets/zypper_repository/tasks/zypper_repository.yml index 740cffd37d..db4c3afb5d 100644 --- a/tests/integration/targets/zypper_repository/tasks/zypper_repository.yml +++ b/tests/integration/targets/zypper_repository/tasks/zypper_repository.yml @@ -53,7 +53,7 @@ - name: use refresh option community.general.zypper_repository: name: testrefresh - refresh: no + refresh: false state: present repo: http://download.videolan.org/pub/vlc/SuSE/Leap_{{ ansible_distribution_version }}/ @@ -94,7 +94,7 @@ - name: check repo is updated by url command: zypper lr chrome1 register: zypper_result1 - ignore_errors: yes + ignore_errors: true - name: check repo is updated by url command: zypper lr chrome2 From 33df7b61c008ee3331b27af2b43d8c90e04f0c9c Mon Sep 17 00:00:00 2001 From: Ivan Bakalov Date: Fri, 17 Feb 2023 08:48:46 +0200 Subject: [PATCH 0164/1810] Set User-Agent for API requests to DNSimple (#5927) * Set the user-agent for API requests to DNSimple * Update user agent format * Add changelog fragment * Update changelogs/fragments/5927-set-user-agent-dnsimple.yml Co-authored-by: Felix Fontein --------- Co-authored-by: Felix Fontein --- changelogs/fragments/5927-set-user-agent-dnsimple.yml | 2 ++ plugins/modules/dnsimple.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/5927-set-user-agent-dnsimple.yml diff --git a/changelogs/fragments/5927-set-user-agent-dnsimple.yml b/changelogs/fragments/5927-set-user-agent-dnsimple.yml new file mode 100644 index 0000000000..1082b41481 --- /dev/null +++ b/changelogs/fragments/5927-set-user-agent-dnsimple.yml @@ -0,0 +1,2 @@ +minor_changes: + - "dnsimple - set custom User-Agent for API requests to DNSimple (https://github.com/ansible-collections/community.general/pull/5927)." diff --git a/plugins/modules/dnsimple.py b/plugins/modules/dnsimple.py index e96c22613f..ddd3ba0bab 100644 --- a/plugins/modules/dnsimple.py +++ b/plugins/modules/dnsimple.py @@ -168,7 +168,7 @@ class DNSimpleV2(): def dnsimple_client(self): """creates a dnsimple client object""" if self.account_email and self.account_api_token: - client = Client(sandbox=self.sandbox, email=self.account_email, access_token=self.account_api_token) + client = Client(sandbox=self.sandbox, email=self.account_email, access_token=self.account_api_token, user_agent="ansible/community.general") else: msg = "Option account_email or account_api_token not provided. " \ "Dnsimple authentiction with a .dnsimple config file is not " \ From 49e3da36461eef7a3cc9b23d31cd8ac8336dfdbc Mon Sep 17 00:00:00 2001 From: TSKushal <44438079+TSKushal@users.noreply.github.com> Date: Fri, 17 Feb 2023 12:19:54 +0530 Subject: [PATCH 0165/1810] Adding VerifyBiosAttributes functionality (#5900) * Adding VerifyBiosAttributes functionality * Updating authors information * PR comment changes * Update plugins/modules/redfish_command.py Agreed Co-authored-by: Felix Fontein * Adding author as redfish maintainer * Adding changelog fragment * Update changelogs/fragments/5900-adding-verifybiosattribute-fucntionality-to-redfish-command.yml Agreed Co-authored-by: Felix Fontein --------- Co-authored-by: Kushal Co-authored-by: Felix Fontein --- .github/BOTMETA.yml | 2 +- ...ibute-fucntionality-to-redfish-command.yml | 2 ++ plugins/module_utils/redfish_utils.py | 35 +++++++++++++++++++ plugins/modules/redfish_command.py | 29 +++++++++++++-- 4 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/5900-adding-verifybiosattribute-fucntionality-to-redfish-command.yml diff --git a/.github/BOTMETA.yml b/.github/BOTMETA.yml index 769b4d273b..7a6a1c1eea 100644 --- a/.github/BOTMETA.yml +++ b/.github/BOTMETA.yml @@ -1037,7 +1037,7 @@ files: maintainers: dagwieers $modules/redfish_: ignore: jose-delarosa - maintainers: $team_redfish + maintainers: $team_redfish TSKushal $modules/redhat_subscription.py: labels: redhat_subscription maintainers: barnabycourt alikins kahowell diff --git a/changelogs/fragments/5900-adding-verifybiosattribute-fucntionality-to-redfish-command.yml b/changelogs/fragments/5900-adding-verifybiosattribute-fucntionality-to-redfish-command.yml new file mode 100644 index 0000000000..bbbb464534 --- /dev/null +++ b/changelogs/fragments/5900-adding-verifybiosattribute-fucntionality-to-redfish-command.yml @@ -0,0 +1,2 @@ +minor_changes: + - redfish_command - adding ``VerifyBiosAttributes`` functionality (https://github.com/ansible-collections/community.general/pull/5900). diff --git a/plugins/module_utils/redfish_utils.py b/plugins/module_utils/redfish_utils.py index eadca28205..b7fda59a52 100644 --- a/plugins/module_utils/redfish_utils.py +++ b/plugins/module_utils/redfish_utils.py @@ -3163,3 +3163,38 @@ class RedfishUtils(object): if resp['ret'] and resp['changed']: resp['msg'] = 'Modified session service' return resp + + def verify_bios_attributes(self, bios_attributes): + # This method verifies BIOS attributes against the provided input + server_bios = self.get_multi_bios_attributes() + if server_bios["ret"] is False: + return server_bios + + bios_dict = {} + wrong_param = {} + + # Verify bios_attributes with BIOS settings available in the server + for key, value in bios_attributes.items(): + if key in server_bios["entries"][0][1]: + if server_bios["entries"][0][1][key] != value: + bios_dict.update({key: value}) + else: + wrong_param.update({key: value}) + + if wrong_param: + return { + "ret": False, + "msg": "Wrong parameters are provided: %s" % wrong_param + } + + if bios_dict: + return { + "ret": False, + "msg": "BIOS parameters are not matching: %s" % bios_dict + } + + return { + "ret": True, + "changed": False, + "msg": "BIOS verification completed" + } diff --git a/plugins/modules/redfish_command.py b/plugins/modules/redfish_command.py index 9d5640996a..ac19fb0e2b 100644 --- a/plugins/modules/redfish_command.py +++ b/plugins/modules/redfish_command.py @@ -239,8 +239,16 @@ options: type: bool default: false version_added: 3.7.0 + bios_attributes: + required: false + description: + - BIOS attributes that needs to be verified in the given server. + type: dict + version_added: 6.4.0 -author: "Jose Delarosa (@jose-delarosa)" +author: + - "Jose Delarosa (@jose-delarosa)" + - "T S Kushal (@TSKushal)" ''' EXAMPLES = ''' @@ -629,6 +637,17 @@ EXAMPLES = ''' category: Manager command: PowerReboot resource_id: BMC + + - name: Verify BIOS attributes + community.general.redfish_command: + category: Systems + command: VerifyBiosAttributes + baseuri: "{{ baseuri }}" + username: "{{ username }}" + password: "{{ password }}" + bios_attributes: + SubNumaClustering: "Disabled" + WorkloadProfile: "Virtualization-MaxPerformance" ''' RETURN = ''' @@ -662,7 +681,7 @@ from ansible.module_utils.common.text.converters import to_native CATEGORY_COMMANDS_ALL = { "Systems": ["PowerOn", "PowerForceOff", "PowerForceRestart", "PowerGracefulRestart", "PowerGracefulShutdown", "PowerReboot", "SetOneTimeBoot", "EnableContinuousBootOverride", "DisableBootOverride", - "IndicatorLedOn", "IndicatorLedOff", "IndicatorLedBlink", "VirtualMediaInsert", "VirtualMediaEject"], + "IndicatorLedOn", "IndicatorLedOff", "IndicatorLedBlink", "VirtualMediaInsert", "VirtualMediaEject", "VerifyBiosAttributes"], "Chassis": ["IndicatorLedOn", "IndicatorLedOff", "IndicatorLedBlink"], "Accounts": ["AddUser", "EnableUser", "DeleteUser", "DisableUser", "UpdateUserRole", "UpdateUserPassword", "UpdateUserName", @@ -726,6 +745,7 @@ def main(): ) ), strip_etag_quotes=dict(type='bool', default=False), + bios_attributes=dict(type="dict") ), required_together=[ ('username', 'password'), @@ -785,6 +805,9 @@ def main(): # Etag options strip_etag_quotes = module.params['strip_etag_quotes'] + # BIOS Attributes options + bios_attributes = module.params['bios_attributes'] + # Build root URI root_uri = "https://" + module.params['baseuri'] rf_utils = RedfishUtils(creds, root_uri, timeout, module, @@ -845,6 +868,8 @@ def main(): result = rf_utils.virtual_media_insert(virtual_media, category) elif command == 'VirtualMediaEject': result = rf_utils.virtual_media_eject(virtual_media, category) + elif command == 'VerifyBiosAttributes': + result = rf_utils.verify_bios_attributes(bios_attributes) elif category == "Chassis": result = rf_utils._find_chassis_resource() From 71d74a796092e912be5798e54ec034571cb6c804 Mon Sep 17 00:00:00 2001 From: TSKushal <44438079+TSKushal@users.noreply.github.com> Date: Fri, 17 Feb 2023 17:54:35 +0530 Subject: [PATCH 0166/1810] Adding EnableSecureBoot functionality (#5899) * rebase merge * Sanity fixes * Optimizing code as suggested by PR comments * Optimizing code as suggested by PR comments * PR comment changes * Adding changelog fragment * Update changelogs/fragments/5899-adding-enablesecureboot-functionality-to-redfish-config.yml Agreed Co-authored-by: Felix Fontein --------- Co-authored-by: Kushal Co-authored-by: Felix Fontein --- ...reboot-functionality-to-redfish-config.yml | 2 ++ plugins/module_utils/redfish_utils.py | 19 +++++++++++++++++++ plugins/modules/redfish_config.py | 16 ++++++++++++++-- 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/5899-adding-enablesecureboot-functionality-to-redfish-config.yml diff --git a/changelogs/fragments/5899-adding-enablesecureboot-functionality-to-redfish-config.yml b/changelogs/fragments/5899-adding-enablesecureboot-functionality-to-redfish-config.yml new file mode 100644 index 0000000000..fba75df0eb --- /dev/null +++ b/changelogs/fragments/5899-adding-enablesecureboot-functionality-to-redfish-config.yml @@ -0,0 +1,2 @@ +minor_changes: + - redfish_command - adding ``EnableSecureBoot`` functionality (https://github.com/ansible-collections/community.general/pull/5899). diff --git a/plugins/module_utils/redfish_utils.py b/plugins/module_utils/redfish_utils.py index b7fda59a52..4803cf1ac8 100644 --- a/plugins/module_utils/redfish_utils.py +++ b/plugins/module_utils/redfish_utils.py @@ -3198,3 +3198,22 @@ class RedfishUtils(object): "changed": False, "msg": "BIOS verification completed" } + + def enable_secure_boot(self): + # This function enable Secure Boot on an OOB controller + + response = self.get_request(self.root_uri + self.systems_uri) + if response["ret"] is False: + return response + + server_details = response["data"] + secure_boot_url = server_details["SecureBoot"]["@odata.id"] + + response = self.get_request(self.root_uri + secure_boot_url) + if response["ret"] is False: + return response + + body = {} + body["SecureBootEnable"] = True + + return self.patch_request(self.root_uri + secure_boot_url, body, check_pyld=True) diff --git a/plugins/modules/redfish_config.py b/plugins/modules/redfish_config.py index 07ac2e1588..df8cd732bd 100644 --- a/plugins/modules/redfish_config.py +++ b/plugins/modules/redfish_config.py @@ -124,7 +124,9 @@ options: default: {} version_added: '5.7.0' -author: "Jose Delarosa (@jose-delarosa)" +author: + - "Jose Delarosa (@jose-delarosa)" + - "T S Kushal (@TSKushal)" ''' EXAMPLES = ''' @@ -255,6 +257,14 @@ EXAMPLES = ''' baseuri: "{{ baseuri }}" username: "{{ username }}" password: "{{ password }}" + + - name: Enable SecureBoot + community.general.redfish_config: + category: Systems + command: EnableSecureBoot + baseuri: "{{ baseuri }}" + username: "{{ username }}" + password: "{{ password }}" ''' RETURN = ''' @@ -273,7 +283,7 @@ from ansible.module_utils.common.text.converters import to_native # More will be added as module features are expanded CATEGORY_COMMANDS_ALL = { "Systems": ["SetBiosDefaultSettings", "SetBiosAttributes", "SetBootOrder", - "SetDefaultBootOrder"], + "SetDefaultBootOrder", "EnableSecureBoot"], "Manager": ["SetNetworkProtocols", "SetManagerNic", "SetHostInterface"], "Sessions": ["SetSessionService"], } @@ -386,6 +396,8 @@ def main(): result = rf_utils.set_boot_order(boot_order) elif command == "SetDefaultBootOrder": result = rf_utils.set_default_boot_order() + elif command == "EnableSecureBoot": + result = rf_utils.enable_secure_boot() elif category == "Manager": # execute only if we find a Manager service resource From 1b2c2af9a87b7cf364529108e95696c4d966058f Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 18 Feb 2023 16:32:28 +0100 Subject: [PATCH 0167/1810] Disable Arch Linux tests for now (#6013) Disable Arch Linux tests for now until https://github.com/ansible-community/images/pull/40 and https://github.com/systemd/systemd/issues/26474 are resolved. --- .azure-pipelines/azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.azure-pipelines/azure-pipelines.yml b/.azure-pipelines/azure-pipelines.yml index 3816369497..ddf43bf9b0 100644 --- a/.azure-pipelines/azure-pipelines.yml +++ b/.azure-pipelines/azure-pipelines.yml @@ -401,8 +401,8 @@ stages: targets: - name: Debian Bullseye test: debian-bullseye/3.9 - - name: ArchLinux - test: archlinux/3.10 + #- name: ArchLinux + # test: archlinux/3.10 - name: CentOS Stream 8 test: centos-stream8/3.9 groups: From 3186a944e929358e78c9c1c0824692d6be2ee706 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Mon, 20 Feb 2023 17:26:28 +0100 Subject: [PATCH 0168/1810] Add attributes to git* modules (#5947) Add attributes to git* modules. --- plugins/modules/git_config.py | 13 ++++++++++--- plugins/modules/github_deploy_key.py | 7 +++++++ plugins/modules/github_issue.py | 9 ++++++++- plugins/modules/github_key.py | 9 ++++++++- plugins/modules/github_release.py | 7 +++++++ plugins/modules/github_repo.py | 12 +++++++++--- plugins/modules/github_webhook.py | 7 +++++++ plugins/modules/gitlab_branch.py | 7 +++++++ plugins/modules/gitlab_deploy_key.py | 7 +++++++ plugins/modules/gitlab_group.py | 7 +++++++ plugins/modules/gitlab_group_members.py | 9 +++++++-- plugins/modules/gitlab_group_variable.py | 9 +++++++-- plugins/modules/gitlab_hook.py | 7 +++++++ plugins/modules/gitlab_project.py | 7 +++++++ plugins/modules/gitlab_project_members.py | 9 +++++++-- plugins/modules/gitlab_project_variable.py | 7 +++++++ plugins/modules/gitlab_protected_branch.py | 7 +++++++ plugins/modules/gitlab_runner.py | 7 +++++++ plugins/modules/gitlab_user.py | 7 +++++++ 19 files changed, 140 insertions(+), 14 deletions(-) diff --git a/plugins/modules/git_config.py b/plugins/modules/git_config.py index 9191de0e87..d673121748 100644 --- a/plugins/modules/git_config.py +++ b/plugins/modules/git_config.py @@ -21,10 +21,17 @@ requirements: ['git'] short_description: Read and write git configuration description: - The C(git_config) module changes git configuration by invoking 'git config'. - This is needed if you don't want to use M(ansible.builtin.template) for the entire git - config file (e.g. because you need to change just C(user.email) in + This is needed if you do not want to use M(ansible.builtin.template) for the entire git + config file (for example because you need to change just C(user.email) in /etc/.git/config). Solutions involving M(ansible.builtin.command) are cumbersome or - don't work correctly in check mode. + do not work correctly in check mode. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: list_all: description: diff --git a/plugins/modules/github_deploy_key.py b/plugins/modules/github_deploy_key.py index bd32438b0a..322650bf70 100644 --- a/plugins/modules/github_deploy_key.py +++ b/plugins/modules/github_deploy_key.py @@ -18,6 +18,13 @@ description: - "Adds or removes deploy keys for GitHub repositories. Supports authentication using username and password, username and password and 2-factor authentication code (OTP), OAuth2 token, or personal access token. Admin rights on the repository are required." +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: github_url: description: diff --git a/plugins/modules/github_issue.py b/plugins/modules/github_issue.py index d49837499a..4e10e9f925 100644 --- a/plugins/modules/github_issue.py +++ b/plugins/modules/github_issue.py @@ -14,7 +14,14 @@ DOCUMENTATION = ''' module: github_issue short_description: View GitHub issue description: - - View GitHub issue for a given repository and organization. + - View GitHub issue for a given repository and organization. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: repo: description: diff --git a/plugins/modules/github_key.py b/plugins/modules/github_key.py index 3c7ee7bd7b..683a963a7f 100644 --- a/plugins/modules/github_key.py +++ b/plugins/modules/github_key.py @@ -13,7 +13,14 @@ DOCUMENTATION = ''' module: github_key short_description: Manage GitHub access keys description: - - Creates, removes, or updates GitHub access keys. + - Creates, removes, or updates GitHub access keys. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: token: description: diff --git a/plugins/modules/github_release.py b/plugins/modules/github_release.py index 0b3a5a886c..3ddd6c8820 100644 --- a/plugins/modules/github_release.py +++ b/plugins/modules/github_release.py @@ -15,6 +15,13 @@ module: github_release short_description: Interact with GitHub Releases description: - Fetch metadata about GitHub Releases +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: token: description: diff --git a/plugins/modules/github_repo.py b/plugins/modules/github_repo.py index d01312fcfa..97076c58af 100644 --- a/plugins/modules/github_repo.py +++ b/plugins/modules/github_repo.py @@ -14,8 +14,15 @@ module: github_repo short_description: Manage your repositories on Github version_added: 2.2.0 description: -- Manages Github repositories using PyGithub library. -- Authentication can be done with I(access_token) or with I(username) and I(password). + - Manages Github repositories using PyGithub library. + - Authentication can be done with I(access_token) or with I(username) and I(password). +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: username: description: @@ -89,7 +96,6 @@ notes: - For Python 3, PyGithub>=1.54 should be used. - "For Python 3.5, PyGithub==1.54 should be used. More information: U(https://pygithub.readthedocs.io/en/latest/changes.html#version-1-54-november-30-2020)." - "For Python 2.7, PyGithub==1.45 should be used. More information: U(https://pygithub.readthedocs.io/en/latest/changes.html#version-1-45-december-29-2019)." -- Supports C(check_mode). author: - Álvaro Torres Cogollo (@atorrescogollo) ''' diff --git a/plugins/modules/github_webhook.py b/plugins/modules/github_webhook.py index b97087d221..71e199adbe 100644 --- a/plugins/modules/github_webhook.py +++ b/plugins/modules/github_webhook.py @@ -16,6 +16,13 @@ description: - "Create and delete GitHub webhooks" requirements: - "PyGithub >= 1.3.5" +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: repository: description: diff --git a/plugins/modules/gitlab_branch.py b/plugins/modules/gitlab_branch.py index e57ca4922f..d7eecb33fb 100644 --- a/plugins/modules/gitlab_branch.py +++ b/plugins/modules/gitlab_branch.py @@ -21,6 +21,13 @@ requirements: extends_documentation_fragment: - community.general.auth_basic - community.general.gitlab + - community.general.attributes + +attributes: + check_mode: + support: none + diff_mode: + support: none options: state: diff --git a/plugins/modules/gitlab_deploy_key.py b/plugins/modules/gitlab_deploy_key.py index f4a9fb29fa..27cb01f87e 100644 --- a/plugins/modules/gitlab_deploy_key.py +++ b/plugins/modules/gitlab_deploy_key.py @@ -25,6 +25,13 @@ requirements: extends_documentation_fragment: - community.general.auth_basic - community.general.gitlab + - community.general.attributes + +attributes: + check_mode: + support: full + diff_mode: + support: none options: project: diff --git a/plugins/modules/gitlab_group.py b/plugins/modules/gitlab_group.py index d099a0c274..624028f298 100644 --- a/plugins/modules/gitlab_group.py +++ b/plugins/modules/gitlab_group.py @@ -25,6 +25,13 @@ requirements: extends_documentation_fragment: - community.general.auth_basic - community.general.gitlab + - community.general.attributes + +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: diff --git a/plugins/modules/gitlab_group_members.py b/plugins/modules/gitlab_group_members.py index 6edc8c983f..66298e882c 100644 --- a/plugins/modules/gitlab_group_members.py +++ b/plugins/modules/gitlab_group_members.py @@ -22,6 +22,13 @@ requirements: extends_documentation_fragment: - community.general.auth_basic - community.general.gitlab + - community.general.attributes + +attributes: + check_mode: + support: full + diff_mode: + support: none options: gitlab_group: @@ -81,8 +88,6 @@ options: elements: str choices: ['guest', 'reporter', 'developer', 'maintainer', 'owner'] version_added: 3.6.0 -notes: - - Supports C(check_mode). ''' EXAMPLES = r''' diff --git a/plugins/modules/gitlab_group_variable.py b/plugins/modules/gitlab_group_variable.py index 4a185b2394..c7befe123c 100644 --- a/plugins/modules/gitlab_group_variable.py +++ b/plugins/modules/gitlab_group_variable.py @@ -26,6 +26,13 @@ requirements: extends_documentation_fragment: - community.general.auth_basic - community.general.gitlab + - community.general.attributes + +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: @@ -99,8 +106,6 @@ options: - The scope for the variable. type: str default: '*' -notes: -- Supports I(check_mode). ''' diff --git a/plugins/modules/gitlab_hook.py b/plugins/modules/gitlab_hook.py index 70864207ed..adf90eb7bc 100644 --- a/plugins/modules/gitlab_hook.py +++ b/plugins/modules/gitlab_hook.py @@ -26,6 +26,13 @@ requirements: extends_documentation_fragment: - community.general.auth_basic - community.general.gitlab + - community.general.attributes + +attributes: + check_mode: + support: full + diff_mode: + support: none options: project: diff --git a/plugins/modules/gitlab_project.py b/plugins/modules/gitlab_project.py index 1ab8ae220c..cd34db4431 100644 --- a/plugins/modules/gitlab_project.py +++ b/plugins/modules/gitlab_project.py @@ -26,6 +26,13 @@ requirements: extends_documentation_fragment: - community.general.auth_basic - community.general.gitlab + - community.general.attributes + +attributes: + check_mode: + support: full + diff_mode: + support: none options: group: diff --git a/plugins/modules/gitlab_project_members.py b/plugins/modules/gitlab_project_members.py index 84e3c9b8e1..9053584431 100644 --- a/plugins/modules/gitlab_project_members.py +++ b/plugins/modules/gitlab_project_members.py @@ -25,6 +25,13 @@ requirements: extends_documentation_fragment: - community.general.auth_basic - community.general.gitlab + - community.general.attributes + +attributes: + check_mode: + support: full + diff_mode: + support: none options: project: @@ -82,8 +89,6 @@ options: elements: str choices: ['guest', 'reporter', 'developer', 'maintainer'] version_added: 3.7.0 -notes: - - Supports C(check_mode). ''' EXAMPLES = r''' diff --git a/plugins/modules/gitlab_project_variable.py b/plugins/modules/gitlab_project_variable.py index 5e6a2904dc..63569dd789 100644 --- a/plugins/modules/gitlab_project_variable.py +++ b/plugins/modules/gitlab_project_variable.py @@ -23,6 +23,13 @@ requirements: extends_documentation_fragment: - community.general.auth_basic - community.general.gitlab + - community.general.attributes + +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: diff --git a/plugins/modules/gitlab_protected_branch.py b/plugins/modules/gitlab_protected_branch.py index 335e1445a2..fea374cbfd 100644 --- a/plugins/modules/gitlab_protected_branch.py +++ b/plugins/modules/gitlab_protected_branch.py @@ -21,6 +21,13 @@ requirements: extends_documentation_fragment: - community.general.auth_basic - community.general.gitlab + - community.general.attributes + +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: diff --git a/plugins/modules/gitlab_runner.py b/plugins/modules/gitlab_runner.py index e0ef43a316..f0da30e8f2 100644 --- a/plugins/modules/gitlab_runner.py +++ b/plugins/modules/gitlab_runner.py @@ -35,6 +35,13 @@ requirements: extends_documentation_fragment: - community.general.auth_basic - community.general.gitlab + - community.general.attributes + +attributes: + check_mode: + support: full + diff_mode: + support: none options: project: diff --git a/plugins/modules/gitlab_user.py b/plugins/modules/gitlab_user.py index 4824f7301f..94f3713160 100644 --- a/plugins/modules/gitlab_user.py +++ b/plugins/modules/gitlab_user.py @@ -33,6 +33,13 @@ requirements: extends_documentation_fragment: - community.general.auth_basic - community.general.gitlab + - community.general.attributes + +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: From ed79a685533b2940abcf5af64fbce8fa31de1ca3 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Mon, 20 Feb 2023 17:27:38 +0100 Subject: [PATCH 0169/1810] Add attributes to atomic, memset, one, oneview, packet, proxmox, and xenserver modules (#5958) Add attributes to atomic, memset, one, oneview, packet, proxmox, and xenserver modules. --- plugins/modules/atomic_container.py | 7 +++++++ plugins/modules/atomic_host.py | 7 +++++++ plugins/modules/atomic_image.py | 7 +++++++ plugins/modules/memset_dns_reload.py | 9 ++++++++- plugins/modules/memset_zone.py | 9 ++++++++- plugins/modules/memset_zone_domain.py | 9 ++++++++- plugins/modules/memset_zone_record.py | 9 ++++++++- plugins/modules/one_host.py | 10 ++++++++-- plugins/modules/one_image.py | 7 +++++++ plugins/modules/one_service.py | 7 +++++++ plugins/modules/one_template.py | 12 +++++++++--- plugins/modules/one_vm.py | 7 +++++++ plugins/modules/oneview_ethernet_network.py | 10 ++++++++-- plugins/modules/oneview_fc_network.py | 10 ++++++++-- plugins/modules/oneview_fcoe_network.py | 10 ++++++++-- .../modules/oneview_logical_interconnect_group.py | 10 ++++++++-- plugins/modules/oneview_network_set.py | 10 ++++++++-- plugins/modules/oneview_san_manager.py | 10 ++++++++-- plugins/modules/packet_device.py | 12 +++++++++--- plugins/modules/packet_ip_subnet.py | 9 +++++++++ plugins/modules/packet_project.py | 9 +++++++++ plugins/modules/packet_sshkey.py | 7 +++++++ plugins/modules/packet_volume.py | 9 +++++++++ plugins/modules/packet_volume_attachment.py | 9 +++++++++ plugins/modules/proxmox.py | 6 ++++++ plugins/modules/proxmox_disk.py | 6 ++++++ plugins/modules/proxmox_kvm.py | 6 ++++++ plugins/modules/proxmox_nic.py | 6 ++++++ plugins/modules/proxmox_snap.py | 7 ++++++- plugins/modules/proxmox_template.py | 9 ++++++++- plugins/modules/xenserver_guest.py | 6 ++++++ plugins/modules/xenserver_guest_powerstate.py | 6 ++++++ 32 files changed, 241 insertions(+), 26 deletions(-) diff --git a/plugins/modules/atomic_container.py b/plugins/modules/atomic_container.py index c32e617a22..c265102960 100644 --- a/plugins/modules/atomic_container.py +++ b/plugins/modules/atomic_container.py @@ -22,6 +22,13 @@ notes: requirements: - atomic - "python >= 2.6" +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: backend: description: diff --git a/plugins/modules/atomic_host.py b/plugins/modules/atomic_host.py index 5aa389e174..bb44c44896 100644 --- a/plugins/modules/atomic_host.py +++ b/plugins/modules/atomic_host.py @@ -22,6 +22,13 @@ notes: requirements: - atomic - python >= 2.6 +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: revision: description: diff --git a/plugins/modules/atomic_image.py b/plugins/modules/atomic_image.py index 2705304f01..65aec1e9d5 100644 --- a/plugins/modules/atomic_image.py +++ b/plugins/modules/atomic_image.py @@ -22,6 +22,13 @@ notes: requirements: - atomic - python >= 2.6 +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: backend: description: diff --git a/plugins/modules/memset_dns_reload.py b/plugins/modules/memset_dns_reload.py index 580740d1a3..c69df6d783 100644 --- a/plugins/modules/memset_dns_reload.py +++ b/plugins/modules/memset_dns_reload.py @@ -21,7 +21,14 @@ notes: I(dns.reload). If you wish to poll the job status to wait until the reload has completed, then I(job.status) is also required. description: - - Request a reload of Memset's DNS infrastructure, and optionally poll until it finishes. + - Request a reload of Memset's DNS infrastructure, and optionally poll until it finishes. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: api_key: required: true diff --git a/plugins/modules/memset_zone.py b/plugins/modules/memset_zone.py index 02b5fd28f0..738d9e16ba 100644 --- a/plugins/modules/memset_zone.py +++ b/plugins/modules/memset_zone.py @@ -19,7 +19,14 @@ notes: Memset customer control panel is needed with the following minimum scope - I(dns.zone_create), I(dns.zone_delete), I(dns.zone_list). description: - - Manage DNS zones in a Memset account. + - Manage DNS zones in a Memset account. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: required: true diff --git a/plugins/modules/memset_zone_domain.py b/plugins/modules/memset_zone_domain.py index 1e18a984b6..26276f68a5 100644 --- a/plugins/modules/memset_zone_domain.py +++ b/plugins/modules/memset_zone_domain.py @@ -21,7 +21,14 @@ notes: - Currently this module can only create one domain at a time. Multiple domains should be created using C(with_items). description: - - Manage DNS zone domains in a Memset account. + - Manage DNS zone domains in a Memset account. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: default: present diff --git a/plugins/modules/memset_zone_record.py b/plugins/modules/memset_zone_record.py index 16a1c3a742..021ad461d2 100644 --- a/plugins/modules/memset_zone_record.py +++ b/plugins/modules/memset_zone_record.py @@ -21,7 +21,14 @@ notes: - Currently this module can only create one DNS record at a time. Multiple records should be created using C(with_items). description: - - Manage DNS records in a Memset account. + - Manage DNS records in a Memset account. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: default: present diff --git a/plugins/modules/one_host.py b/plugins/modules/one_host.py index 20bdaa4088..c4578f9501 100644 --- a/plugins/modules/one_host.py +++ b/plugins/modules/one_host.py @@ -23,6 +23,12 @@ requirements: description: - "Manages OpenNebula Hosts" +attributes: + check_mode: + support: none + diff_mode: + support: none + options: name: description: @@ -77,8 +83,8 @@ options: type: dict extends_documentation_fragment: -- community.general.opennebula - + - community.general.opennebula + - community.general.attributes author: - Rafael del Valle (@rvalle) diff --git a/plugins/modules/one_image.py b/plugins/modules/one_image.py index fb255dc590..a50b33e93e 100644 --- a/plugins/modules/one_image.py +++ b/plugins/modules/one_image.py @@ -16,6 +16,13 @@ description: - Manages OpenNebula images requirements: - pyone +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: api_url: description: diff --git a/plugins/modules/one_service.py b/plugins/modules/one_service.py index 6bc3137cc3..4f51438870 100644 --- a/plugins/modules/one_service.py +++ b/plugins/modules/one_service.py @@ -14,6 +14,13 @@ module: one_service short_description: Deploy and manage OpenNebula services description: - Manage OpenNebula services +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: api_url: description: diff --git a/plugins/modules/one_template.py b/plugins/modules/one_template.py index 8cfac6baf0..97d0f856ed 100644 --- a/plugins/modules/one_template.py +++ b/plugins/modules/one_template.py @@ -23,6 +23,14 @@ requirements: description: - "Manages OpenNebula templates." +attributes: + check_mode: + support: partial + details: + - Note that check mode always returns C(changed=true) for existing templates, even if the template would not actually change. + diff_mode: + support: none + options: id: description: @@ -47,11 +55,9 @@ options: default: present type: str -notes: - - Supports C(check_mode). Note that check mode always returns C(changed=true) for existing templates, even if the template would not actually change. - extends_documentation_fragment: - community.general.opennebula + - community.general.attributes author: - "Georg Gadinger (@nilsding)" diff --git a/plugins/modules/one_vm.py b/plugins/modules/one_vm.py index 3724d9433d..1bbf474661 100644 --- a/plugins/modules/one_vm.py +++ b/plugins/modules/one_vm.py @@ -17,6 +17,13 @@ description: - Manages OpenNebula instances requirements: - pyone +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: api_url: description: diff --git a/plugins/modules/oneview_ethernet_network.py b/plugins/modules/oneview_ethernet_network.py index 3c8711fe05..8eb63db5aa 100644 --- a/plugins/modules/oneview_ethernet_network.py +++ b/plugins/modules/oneview_ethernet_network.py @@ -19,6 +19,11 @@ author: - Felipe Bulsoni (@fgbulsoni) - Thiago Miotto (@tmiotto) - Adriane Cardozo (@adriane-cardozo) +attributes: + check_mode: + support: none + diff_mode: + support: none options: state: description: @@ -35,8 +40,9 @@ options: type: dict required: true extends_documentation_fragment: -- community.general.oneview -- community.general.oneview.validateetag + - community.general.oneview + - community.general.oneview.validateetag + - community.general.attributes ''' diff --git a/plugins/modules/oneview_fc_network.py b/plugins/modules/oneview_fc_network.py index 2898447c0b..4c5f867e23 100644 --- a/plugins/modules/oneview_fc_network.py +++ b/plugins/modules/oneview_fc_network.py @@ -16,6 +16,11 @@ description: requirements: - "hpOneView >= 4.0.0" author: "Felipe Bulsoni (@fgbulsoni)" +attributes: + check_mode: + support: none + diff_mode: + support: none options: state: description: @@ -32,8 +37,9 @@ options: required: true extends_documentation_fragment: -- community.general.oneview -- community.general.oneview.validateetag + - community.general.oneview + - community.general.oneview.validateetag + - community.general.attributes ''' diff --git a/plugins/modules/oneview_fcoe_network.py b/plugins/modules/oneview_fcoe_network.py index 61102dff15..73eef5af08 100644 --- a/plugins/modules/oneview_fcoe_network.py +++ b/plugins/modules/oneview_fcoe_network.py @@ -17,6 +17,11 @@ requirements: - "python >= 2.7.9" - "hpOneView >= 4.0.0" author: "Felipe Bulsoni (@fgbulsoni)" +attributes: + check_mode: + support: none + diff_mode: + support: none options: state: description: @@ -33,8 +38,9 @@ options: required: true extends_documentation_fragment: -- community.general.oneview -- community.general.oneview.validateetag + - community.general.oneview + - community.general.oneview.validateetag + - community.general.attributes ''' diff --git a/plugins/modules/oneview_logical_interconnect_group.py b/plugins/modules/oneview_logical_interconnect_group.py index ed51722672..cd8e875285 100644 --- a/plugins/modules/oneview_logical_interconnect_group.py +++ b/plugins/modules/oneview_logical_interconnect_group.py @@ -20,6 +20,11 @@ author: - Felipe Bulsoni (@fgbulsoni) - Thiago Miotto (@tmiotto) - Adriane Cardozo (@adriane-cardozo) +attributes: + check_mode: + support: none + diff_mode: + support: none options: state: description: @@ -35,8 +40,9 @@ options: type: dict required: true extends_documentation_fragment: -- community.general.oneview -- community.general.oneview.validateetag + - community.general.oneview + - community.general.oneview.validateetag + - community.general.attributes ''' diff --git a/plugins/modules/oneview_network_set.py b/plugins/modules/oneview_network_set.py index 6dac04c5ca..a6a62a05c2 100644 --- a/plugins/modules/oneview_network_set.py +++ b/plugins/modules/oneview_network_set.py @@ -19,6 +19,11 @@ author: - Felipe Bulsoni (@fgbulsoni) - Thiago Miotto (@tmiotto) - Adriane Cardozo (@adriane-cardozo) +attributes: + check_mode: + support: none + diff_mode: + support: none options: state: description: @@ -35,8 +40,9 @@ options: required: true extends_documentation_fragment: -- community.general.oneview -- community.general.oneview.validateetag + - community.general.oneview + - community.general.oneview.validateetag + - community.general.attributes ''' diff --git a/plugins/modules/oneview_san_manager.py b/plugins/modules/oneview_san_manager.py index a22398074a..65a016b1c2 100644 --- a/plugins/modules/oneview_san_manager.py +++ b/plugins/modules/oneview_san_manager.py @@ -19,6 +19,11 @@ author: - Felipe Bulsoni (@fgbulsoni) - Thiago Miotto (@tmiotto) - Adriane Cardozo (@adriane-cardozo) +attributes: + check_mode: + support: none + diff_mode: + support: none options: state: description: @@ -36,8 +41,9 @@ options: required: true extends_documentation_fragment: -- community.general.oneview -- community.general.oneview.validateetag + - community.general.oneview + - community.general.oneview.validateetag + - community.general.attributes ''' diff --git a/plugins/modules/packet_device.py b/plugins/modules/packet_device.py index a2c2d1d653..d220c5f8f7 100644 --- a/plugins/modules/packet_device.py +++ b/plugins/modules/packet_device.py @@ -28,6 +28,15 @@ author: - Matt Baldwin (@baldwinSPC) - Thibaud Morel l'Horset (@teebes) +extends_documentation_fragment: + - community.general.attributes + +attributes: + check_mode: + support: none + diff_mode: + support: none + options: auth_token: description: @@ -149,9 +158,6 @@ options: requirements: - "packet-python >= 1.35" -notes: - - Doesn't support check mode. - ''' EXAMPLES = ''' diff --git a/plugins/modules/packet_ip_subnet.py b/plugins/modules/packet_ip_subnet.py index 63790e1c6a..afeb7ea04c 100644 --- a/plugins/modules/packet_ip_subnet.py +++ b/plugins/modules/packet_ip_subnet.py @@ -28,6 +28,15 @@ author: - Tomas Karasek (@t0mk) - Nurfet Becirevic (@nurfet-becirevic) +extends_documentation_fragment: + - community.general.attributes + +attributes: + check_mode: + support: full + diff_mode: + support: none + options: auth_token: description: diff --git a/plugins/modules/packet_project.py b/plugins/modules/packet_project.py index 9a82c2ec72..da4a2bb89f 100644 --- a/plugins/modules/packet_project.py +++ b/plugins/modules/packet_project.py @@ -26,6 +26,15 @@ author: - Tomas Karasek (@t0mk) - Nurfet Becirevic (@nurfet-becirevic) +extends_documentation_fragment: + - community.general.attributes + +attributes: + check_mode: + support: full + diff_mode: + support: none + options: state: description: diff --git a/plugins/modules/packet_sshkey.py b/plugins/modules/packet_sshkey.py index 87beb01aa8..97f55ba23b 100644 --- a/plugins/modules/packet_sshkey.py +++ b/plugins/modules/packet_sshkey.py @@ -16,6 +16,13 @@ description: - Create/delete an SSH key in Packet host. - API is documented at U(https://www.packet.net/help/api/#page:ssh-keys,header:ssh-keys-ssh-keys-post). author: "Tomas Karasek (@t0mk) " +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: state: description: diff --git a/plugins/modules/packet_volume.py b/plugins/modules/packet_volume.py index b06e57b56c..910d64b55b 100644 --- a/plugins/modules/packet_volume.py +++ b/plugins/modules/packet_volume.py @@ -25,6 +25,15 @@ author: - Tomas Karasek (@t0mk) - Nurfet Becirevic (@nurfet-becirevic) +extends_documentation_fragment: + - community.general.attributes + +attributes: + check_mode: + support: full + diff_mode: + support: none + options: state: description: diff --git a/plugins/modules/packet_volume_attachment.py b/plugins/modules/packet_volume_attachment.py index 74b42ab479..7f6c68e054 100644 --- a/plugins/modules/packet_volume_attachment.py +++ b/plugins/modules/packet_volume_attachment.py @@ -29,6 +29,15 @@ author: - Tomas Karasek (@t0mk) - Nurfet Becirevic (@nurfet-becirevic) +extends_documentation_fragment: + - community.general.attributes + +attributes: + check_mode: + support: full + diff_mode: + support: none + options: state: description: diff --git a/plugins/modules/proxmox.py b/plugins/modules/proxmox.py index 640f9b4114..315ee601ad 100644 --- a/plugins/modules/proxmox.py +++ b/plugins/modules/proxmox.py @@ -16,6 +16,11 @@ description: - allows you to create/delete/stop instances in Proxmox VE cluster - Starting in Ansible 2.1, it automatically detects containerization type (lxc for PVE 4, openvz for older) - Since community.general 4.0.0 on, there are no more default values, see I(proxmox_default_behavior). +attributes: + check_mode: + support: none + diff_mode: + support: none options: password: description: @@ -202,6 +207,7 @@ author: Sergei Antipov (@UnderGreen) extends_documentation_fragment: - community.general.proxmox.documentation - community.general.proxmox.selection + - community.general.attributes ''' EXAMPLES = r''' diff --git a/plugins/modules/proxmox_disk.py b/plugins/modules/proxmox_disk.py index 8292b1de50..df6735cc0c 100644 --- a/plugins/modules/proxmox_disk.py +++ b/plugins/modules/proxmox_disk.py @@ -16,6 +16,11 @@ version_added: 5.7.0 description: - Allows you to perform some supported operations on a disk in Qemu(KVM) Virtual Machines in a Proxmox VE cluster. author: "Castor Sky (@castorsky) " +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: description: @@ -311,6 +316,7 @@ options: type: str extends_documentation_fragment: - community.general.proxmox.documentation + - community.general.attributes ''' EXAMPLES = ''' diff --git a/plugins/modules/proxmox_kvm.py b/plugins/modules/proxmox_kvm.py index 25e252bee9..852f6333b7 100644 --- a/plugins/modules/proxmox_kvm.py +++ b/plugins/modules/proxmox_kvm.py @@ -16,6 +16,11 @@ description: - Allows you to create/delete/stop Qemu(KVM) Virtual Machines in Proxmox VE cluster. - Since community.general 4.0.0 on, there are no more default values, see I(proxmox_default_behavior). author: "Abdoul Bah (@helldorado) " +attributes: + check_mode: + support: none + diff_mode: + support: none options: acpi: description: @@ -519,6 +524,7 @@ options: extends_documentation_fragment: - community.general.proxmox.documentation - community.general.proxmox.selection + - community.general.attributes ''' EXAMPLES = ''' diff --git a/plugins/modules/proxmox_nic.py b/plugins/modules/proxmox_nic.py index 5c8c3f47df..26d07c7ecc 100644 --- a/plugins/modules/proxmox_nic.py +++ b/plugins/modules/proxmox_nic.py @@ -16,6 +16,11 @@ version_added: 3.1.0 description: - Allows you to create/update/delete a NIC on Qemu(KVM) Virtual Machines in a Proxmox VE cluster. author: "Lammert Hellinga (@Kogelvis) " +attributes: + check_mode: + support: full + diff_mode: + support: none options: bridge: description: @@ -90,6 +95,7 @@ options: type: int extends_documentation_fragment: - community.general.proxmox.documentation + - community.general.attributes ''' EXAMPLES = ''' diff --git a/plugins/modules/proxmox_snap.py b/plugins/modules/proxmox_snap.py index 3bd7c4ee32..0c17f83763 100644 --- a/plugins/modules/proxmox_snap.py +++ b/plugins/modules/proxmox_snap.py @@ -16,6 +16,11 @@ version_added: 2.0.0 description: - Allows you to create/delete/restore snapshots from instances in Proxmox VE cluster. - Supports both KVM and LXC, OpenVZ has not been tested, as it is no longer supported on Proxmox VE. +attributes: + check_mode: + support: full + diff_mode: + support: none options: hostname: description: @@ -72,11 +77,11 @@ options: notes: - Requires proxmoxer and requests modules on host. These modules can be installed with pip. - - Supports C(check_mode). requirements: [ "proxmoxer", "python >= 2.7", "requests" ] author: Jeffrey van Pelt (@Thulium-Drake) extends_documentation_fragment: - community.general.proxmox.documentation + - community.general.attributes ''' EXAMPLES = r''' diff --git a/plugins/modules/proxmox_template.py b/plugins/modules/proxmox_template.py index a09af2f2a3..2bf24ff845 100644 --- a/plugins/modules/proxmox_template.py +++ b/plugins/modules/proxmox_template.py @@ -15,6 +15,11 @@ module: proxmox_template short_description: Management of OS templates in Proxmox VE cluster description: - allows you to upload/delete templates in Proxmox VE cluster +attributes: + check_mode: + support: none + diff_mode: + support: none options: node: description: @@ -62,7 +67,9 @@ options: notes: - Requires C(proxmoxer) and C(requests) modules on host. This modules can be installed with M(ansible.builtin.pip). author: Sergei Antipov (@UnderGreen) -extends_documentation_fragment: community.general.proxmox.documentation +extends_documentation_fragment: + - community.general.proxmox.documentation + - community.general.attributes ''' EXAMPLES = ''' diff --git a/plugins/modules/xenserver_guest.py b/plugins/modules/xenserver_guest.py index 95b25174cf..7659ee2aed 100644 --- a/plugins/modules/xenserver_guest.py +++ b/plugins/modules/xenserver_guest.py @@ -46,6 +46,11 @@ notes: requirements: - python >= 2.6 - XenAPI +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: description: @@ -286,6 +291,7 @@ options: default: false extends_documentation_fragment: - community.general.xenserver.documentation +- community.general.attributes ''' diff --git a/plugins/modules/xenserver_guest_powerstate.py b/plugins/modules/xenserver_guest_powerstate.py index 2bb7264875..ba88bbf1de 100644 --- a/plugins/modules/xenserver_guest_powerstate.py +++ b/plugins/modules/xenserver_guest_powerstate.py @@ -30,6 +30,11 @@ notes: requirements: - python >= 2.6 - XenAPI +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: description: @@ -67,6 +72,7 @@ options: default: 0 extends_documentation_fragment: - community.general.xenserver.documentation +- community.general.attributes ''' From 755a49692dedf42ca4b9f8d9dcb09ba250ff6210 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Mon, 20 Feb 2023 17:28:13 +0100 Subject: [PATCH 0170/1810] Add attributes to remove management modules (#5961) Add attributes to remove management modules. --- plugins/modules/hpilo_boot.py | 13 ++++++++++--- plugins/modules/idrac_redfish_command.py | 7 +++++++ plugins/modules/idrac_redfish_config.py | 7 +++++++ plugins/modules/ilo_redfish_config.py | 7 +++++++ plugins/modules/ipmi_boot.py | 7 +++++++ plugins/modules/ipmi_power.py | 7 +++++++ plugins/modules/ocapi_command.py | 7 +++++++ plugins/modules/redfish_command.py | 7 +++++++ plugins/modules/redfish_config.py | 7 +++++++ plugins/modules/wdc_redfish_command.py | 7 +++++++ plugins/modules/xcc_redfish_command.py | 7 +++++++ 11 files changed, 80 insertions(+), 3 deletions(-) diff --git a/plugins/modules/hpilo_boot.py b/plugins/modules/hpilo_boot.py index f663a7b5f5..ace79a493a 100644 --- a/plugins/modules/hpilo_boot.py +++ b/plugins/modules/hpilo_boot.py @@ -15,9 +15,16 @@ module: hpilo_boot author: Dag Wieers (@dagwieers) short_description: Boot system using specific media through HP iLO interface description: -- "This module boots a system through its HP iLO interface. The boot media - can be one of: cdrom, floppy, hdd, network or usb." -- This module requires the hpilo python module. + - "This module boots a system through its HP iLO interface. The boot media + can be one of: cdrom, floppy, hdd, network or usb." + - This module requires the hpilo python module. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: host: description: diff --git a/plugins/modules/idrac_redfish_command.py b/plugins/modules/idrac_redfish_command.py index 9e523b6d11..3c81267f45 100644 --- a/plugins/modules/idrac_redfish_command.py +++ b/plugins/modules/idrac_redfish_command.py @@ -16,6 +16,13 @@ description: - Builds Redfish URIs locally and sends them to remote OOB controllers to perform an action. - For use with Dell iDRAC operations that require Redfish OEM extensions. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: category: required: true diff --git a/plugins/modules/idrac_redfish_config.py b/plugins/modules/idrac_redfish_config.py index f995258c7d..cc47e62d2e 100644 --- a/plugins/modules/idrac_redfish_config.py +++ b/plugins/modules/idrac_redfish_config.py @@ -16,6 +16,13 @@ description: - For use with Dell iDRAC operations that require Redfish OEM extensions - Builds Redfish URIs locally and sends them to remote iDRAC controllers to set or update a configuration attribute. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: category: required: true diff --git a/plugins/modules/ilo_redfish_config.py b/plugins/modules/ilo_redfish_config.py index 1c68127fa4..1f021895dc 100644 --- a/plugins/modules/ilo_redfish_config.py +++ b/plugins/modules/ilo_redfish_config.py @@ -15,6 +15,13 @@ description: - Builds Redfish URIs locally and sends them to iLO to set or update a configuration attribute. - For use with HPE iLO operations that require Redfish OEM extensions. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: category: required: true diff --git a/plugins/modules/ipmi_boot.py b/plugins/modules/ipmi_boot.py index 3cfa60d18e..7a4d2b6ec4 100644 --- a/plugins/modules/ipmi_boot.py +++ b/plugins/modules/ipmi_boot.py @@ -15,6 +15,13 @@ module: ipmi_boot short_description: Management of order of boot devices description: - Use this module to manage order of boot devices +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/ipmi_power.py b/plugins/modules/ipmi_power.py index fa23b289b5..c5ec27a480 100644 --- a/plugins/modules/ipmi_power.py +++ b/plugins/modules/ipmi_power.py @@ -15,6 +15,13 @@ module: ipmi_power short_description: Power management for machine description: - Use this module for power management +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/ocapi_command.py b/plugins/modules/ocapi_command.py index 73c0e22bd5..ed2366736a 100644 --- a/plugins/modules/ocapi_command.py +++ b/plugins/modules/ocapi_command.py @@ -17,6 +17,13 @@ description: - Builds OCAPI URIs locally and sends them to remote OOB controllers to perform an action. - Manages OOB controller such as Indicator LED, Reboot, Power Mode, Firmware Update. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: category: required: true diff --git a/plugins/modules/redfish_command.py b/plugins/modules/redfish_command.py index ac19fb0e2b..400677eabb 100644 --- a/plugins/modules/redfish_command.py +++ b/plugins/modules/redfish_command.py @@ -18,6 +18,13 @@ description: - Manages OOB controller ex. reboot, log management. - Manages OOB controller users ex. add, remove, update. - Manages system power ex. on, off, graceful and forced reboot. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: category: required: true diff --git a/plugins/modules/redfish_config.py b/plugins/modules/redfish_config.py index df8cd732bd..9f31870e32 100644 --- a/plugins/modules/redfish_config.py +++ b/plugins/modules/redfish_config.py @@ -17,6 +17,13 @@ description: set or update a configuration attribute. - Manages BIOS configuration settings. - Manages OOB controller configuration settings. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: category: required: true diff --git a/plugins/modules/wdc_redfish_command.py b/plugins/modules/wdc_redfish_command.py index 0b89a1ff15..a51d454d9b 100644 --- a/plugins/modules/wdc_redfish_command.py +++ b/plugins/modules/wdc_redfish_command.py @@ -17,6 +17,13 @@ description: - Builds Redfish URIs locally and sends them to remote OOB controllers to perform an action. - Manages OOB controller firmware. For example, Firmware Activate, Update and Activate. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: category: required: true diff --git a/plugins/modules/xcc_redfish_command.py b/plugins/modules/xcc_redfish_command.py index 4fb0dfe178..494ea061ee 100644 --- a/plugins/modules/xcc_redfish_command.py +++ b/plugins/modules/xcc_redfish_command.py @@ -20,6 +20,13 @@ description: - Supports getting information back via GET method. - Supports updating a configuration attribute via PATCH method. - Supports performing an action via POST method. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: category: required: true From 9de145482bcd855735c8306999381bd6489492e0 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Mon, 20 Feb 2023 17:28:47 +0100 Subject: [PATCH 0171/1810] Add attributes to various basic modules (#5964) * Add attributes to various basic modules. * Check and diff mode for pam_limits was added in #830. --- plugins/modules/alternatives.py | 7 +++++++ plugins/modules/archive.py | 9 ++++++++- plugins/modules/cronvar.py | 7 +++++++ plugins/modules/crypttab.py | 7 +++++++ plugins/modules/dconf.py | 7 +++++++ plugins/modules/gconftool2.py | 9 ++++++++- plugins/modules/homectl.py | 7 +++++++ plugins/modules/ini_file.py | 21 ++++++++++++++------- plugins/modules/interfaces_file.py | 15 +++++++++++---- plugins/modules/java_cert.py | 7 +++++++ plugins/modules/java_keystore.py | 8 +++++++- plugins/modules/kernel_blacklist.py | 9 ++++++++- plugins/modules/keyring.py | 7 +++++++ plugins/modules/launchd.py | 11 +++++++++-- plugins/modules/locale_gen.py | 23 +++++++++++++++-------- plugins/modules/make.py | 9 ++++++++- plugins/modules/mksysb.py | 7 +++++++ plugins/modules/modprobe.py | 7 +++++++ plugins/modules/nmcli.py | 11 +++++++++-- plugins/modules/osx_defaults.py | 7 +++++++ plugins/modules/pam_limits.py | 9 +++++++++ plugins/modules/pamd.py | 7 +++++++ plugins/modules/read_csv.py | 7 +++++++ plugins/modules/sefcontext.py | 11 +++++++++-- plugins/modules/selinux_permissive.py | 7 +++++++ plugins/modules/selogin.py | 9 ++++++++- plugins/modules/seport.py | 7 +++++++ plugins/modules/ssh_config.py | 9 +++++++-- plugins/modules/sudoers.py | 7 +++++++ plugins/modules/sysrc.py | 7 +++++++ plugins/modules/timezone.py | 7 +++++++ plugins/modules/ufw.py | 7 +++++++ plugins/modules/xattr.py | 7 +++++++ plugins/modules/xfconf.py | 9 +++++++++ plugins/modules/xml.py | 9 ++++++++- 35 files changed, 280 insertions(+), 34 deletions(-) diff --git a/plugins/modules/alternatives.py b/plugins/modules/alternatives.py index 48cacb4540..97d4f51fbb 100644 --- a/plugins/modules/alternatives.py +++ b/plugins/modules/alternatives.py @@ -22,6 +22,13 @@ author: - Marius Rieder (@jiuka) - David Wittman (@DavidWittman) - Gabe Mulley (@mulby) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: full options: name: description: diff --git a/plugins/modules/archive.py b/plugins/modules/archive.py index 83eae34f56..5744925312 100644 --- a/plugins/modules/archive.py +++ b/plugins/modules/archive.py @@ -14,11 +14,18 @@ DOCUMENTATION = r''' --- module: archive short_description: Creates a compressed archive of one or more files or trees -extends_documentation_fragment: files +extends_documentation_fragment: + - files + - community.general.attributes description: - Creates or extends an archive. - The source and archive are on the remote host, and the archive I(is not) copied to the local host. - Source files can be deleted after archival by specifying I(remove=True). +attributes: + check_mode: + support: full + diff_mode: + support: none options: path: description: diff --git a/plugins/modules/cronvar.py b/plugins/modules/cronvar.py index 9299880537..7effed2ae1 100644 --- a/plugins/modules/cronvar.py +++ b/plugins/modules/cronvar.py @@ -24,6 +24,13 @@ short_description: Manage variables in crontabs description: - Use this module to manage crontab variables. - This module allows you to create, update, or delete cron variable definitions. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/crypttab.py b/plugins/modules/crypttab.py index a334e8ab3f..6aea362e74 100644 --- a/plugins/modules/crypttab.py +++ b/plugins/modules/crypttab.py @@ -14,6 +14,13 @@ module: crypttab short_description: Encrypted Linux block devices description: - Control Linux encrypted block devices that are set up during system boot in C(/etc/crypttab). +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/dconf.py b/plugins/modules/dconf.py index 61bf6f0e3f..4d7ed34bf9 100644 --- a/plugins/modules/dconf.py +++ b/plugins/modules/dconf.py @@ -44,6 +44,13 @@ notes: key is by making the configuration change in application affected by the key, and then having a look at value set via commands C(dconf dump /path/to/dir/) or C(dconf read /path/to/key). +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: key: type: str diff --git a/plugins/modules/gconftool2.py b/plugins/modules/gconftool2.py index 788aed3423..949e92b306 100644 --- a/plugins/modules/gconftool2.py +++ b/plugins/modules/gconftool2.py @@ -12,11 +12,18 @@ __metaclass__ = type DOCUMENTATION = ''' module: gconftool2 author: - - Kenneth D. Evensen (@kevensen) + - Kenneth D. Evensen (@kevensen) short_description: Edit GNOME Configurations description: - This module allows for the manipulation of GNOME 2 Configuration via gconftool-2. Please see the gconftool-2(1) man pages for more details. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: key: type: str diff --git a/plugins/modules/homectl.py b/plugins/modules/homectl.py index c14dc4af9a..301e388d38 100644 --- a/plugins/modules/homectl.py +++ b/plugins/modules/homectl.py @@ -17,6 +17,13 @@ short_description: Manage user accounts with systemd-homed version_added: 4.4.0 description: - Manages a user's home directory managed by systemd-homed. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/ini_file.py b/plugins/modules/ini_file.py index ee4ad62b72..231a0e836a 100644 --- a/plugins/modules/ini_file.py +++ b/plugins/modules/ini_file.py @@ -15,14 +15,21 @@ DOCUMENTATION = r''' --- module: ini_file short_description: Tweak settings in INI files -extends_documentation_fragment: files +extends_documentation_fragment: + - files + - community.general.attributes description: - - Manage (add, remove, change) individual settings in an INI-style file without having - to manage the file as a whole with, say, M(ansible.builtin.template) or M(ansible.builtin.assemble). - - Adds missing sections if they don't exist. - - Before Ansible 2.0, comments are discarded when the source file is read, and therefore will not show up in the destination file. - - Since Ansible 2.3, this module adds missing ending newlines to files to keep in line with the POSIX standard, even when - no other modifications need to be applied. + - Manage (add, remove, change) individual settings in an INI-style file without having + to manage the file as a whole with, say, M(ansible.builtin.template) or M(ansible.builtin.assemble). + - Adds missing sections if they don't exist. + - Before Ansible 2.0, comments are discarded when the source file is read, and therefore will not show up in the destination file. + - Since Ansible 2.3, this module adds missing ending newlines to files to keep in line with the POSIX standard, even when + no other modifications need to be applied. +attributes: + check_mode: + support: full + diff_mode: + support: full options: path: description: diff --git a/plugins/modules/interfaces_file.py b/plugins/modules/interfaces_file.py index fe4223a12f..8e643fb797 100644 --- a/plugins/modules/interfaces_file.py +++ b/plugins/modules/interfaces_file.py @@ -13,11 +13,18 @@ DOCUMENTATION = ''' --- module: interfaces_file short_description: Tweak settings in /etc/network/interfaces files -extends_documentation_fragment: files +extends_documentation_fragment: + - ansible.builtin.files + - community.general.attributes description: - - Manage (add, remove, change) individual interface options in an interfaces-style file without having - to manage the file as a whole with, say, M(ansible.builtin.template) or M(ansible.builtin.assemble). Interface has to be presented in a file. - - Read information about interfaces from interfaces-styled files + - Manage (add, remove, change) individual interface options in an interfaces-style file without having + to manage the file as a whole with, say, M(ansible.builtin.template) or M(ansible.builtin.assemble). Interface has to be presented in a file. + - Read information about interfaces from interfaces-styled files +attributes: + check_mode: + support: full + diff_mode: + support: none options: dest: type: path diff --git a/plugins/modules/java_cert.py b/plugins/modules/java_cert.py index 461f365a72..a188b16c38 100644 --- a/plugins/modules/java_cert.py +++ b/plugins/modules/java_cert.py @@ -16,6 +16,13 @@ short_description: Uses keytool to import/remove certificate to/from java keysto description: - This is a wrapper module around keytool, which can be used to import certificates and optionally private keys to a given java keystore, or remove them from it. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: full options: cert_url: description: diff --git a/plugins/modules/java_keystore.py b/plugins/modules/java_keystore.py index 2383c8cc48..7c2c4884dc 100644 --- a/plugins/modules/java_keystore.py +++ b/plugins/modules/java_keystore.py @@ -16,6 +16,11 @@ module: java_keystore short_description: Create a Java keystore in JKS format description: - Bundle a x509 certificate and its private key into a Java Keystore in JKS format. +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: @@ -124,7 +129,8 @@ author: - Guillaume Grossetie (@Mogztter) - quidame (@quidame) extends_documentation_fragment: - - files + - ansible.builtin.files + - community.general.attributes seealso: - module: community.crypto.openssl_pkcs12 - module: community.general.java_cert diff --git a/plugins/modules/kernel_blacklist.py b/plugins/modules/kernel_blacklist.py index c4352ac08a..1b40999cae 100644 --- a/plugins/modules/kernel_blacklist.py +++ b/plugins/modules/kernel_blacklist.py @@ -13,10 +13,17 @@ DOCUMENTATION = ''' --- module: kernel_blacklist author: -- Matthias Vogelgesang (@matze) + - Matthias Vogelgesang (@matze) short_description: Blacklist kernel modules description: - Add or remove kernel modules from blacklist. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: full options: name: type: str diff --git a/plugins/modules/keyring.py b/plugins/modules/keyring.py index 43dfb8c5dc..ada22ed581 100644 --- a/plugins/modules/keyring.py +++ b/plugins/modules/keyring.py @@ -26,6 +26,13 @@ requirements: - keyring (Python library) - gnome-keyring (application - required for headless Gnome keyring access) - dbus-run-session (application - required for headless Gnome keyring access) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: service: description: The name of the service. diff --git a/plugins/modules/launchd.py b/plugins/modules/launchd.py index 250bbffb9e..13a8ce0862 100644 --- a/plugins/modules/launchd.py +++ b/plugins/modules/launchd.py @@ -12,11 +12,18 @@ DOCUMENTATION = r''' --- module: launchd author: -- Martin Migasiewicz (@martinm82) + - Martin Migasiewicz (@martinm82) short_description: Manage macOS services version_added: 1.0.0 description: -- Manage launchd services on target macOS hosts. + - Manage launchd services on target macOS hosts. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/locale_gen.py b/plugins/modules/locale_gen.py index 743570b7ab..fccdf977a4 100644 --- a/plugins/modules/locale_gen.py +++ b/plugins/modules/locale_gen.py @@ -13,21 +13,28 @@ DOCUMENTATION = ''' module: locale_gen short_description: Creates or removes locales description: - - Manages locales by editing /etc/locale.gen and invoking locale-gen. + - Manages locales by editing /etc/locale.gen and invoking locale-gen. author: -- Augustus Kling (@AugustusKling) + - Augustus Kling (@AugustusKling) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: type: str description: - - Name and encoding of the locale, such as "en_GB.UTF-8". + - Name and encoding of the locale, such as "en_GB.UTF-8". required: true state: - type: str - description: - - Whether the locale shall be present. - choices: [ absent, present ] - default: present + type: str + description: + - Whether the locale shall be present. + choices: [ absent, present ] + default: present ''' EXAMPLES = ''' diff --git a/plugins/modules/make.py b/plugins/modules/make.py index 31da07c579..be2a32bd45 100644 --- a/plugins/modules/make.py +++ b/plugins/modules/make.py @@ -13,10 +13,17 @@ DOCUMENTATION = r''' module: make short_description: Run targets in a Makefile requirements: -- make + - make author: Linus Unnebäck (@LinusU) description: - Run targets in a Makefile. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: target: description: diff --git a/plugins/modules/mksysb.py b/plugins/modules/mksysb.py index 39f3e6a1c4..c43a268f33 100644 --- a/plugins/modules/mksysb.py +++ b/plugins/modules/mksysb.py @@ -17,6 +17,13 @@ module: mksysb short_description: Generates AIX mksysb rootvg backups description: - This module manages a basic AIX mksysb (image) of rootvg. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: backup_crypt_files: description: diff --git a/plugins/modules/modprobe.py b/plugins/modules/modprobe.py index df460e7161..e386117945 100644 --- a/plugins/modules/modprobe.py +++ b/plugins/modules/modprobe.py @@ -18,6 +18,13 @@ author: - Matt Jeffery (@mattjeffery) description: - Load or unload kernel modules. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: type: str diff --git a/plugins/modules/nmcli.py b/plugins/modules/nmcli.py index aa2ddafe1d..461bcc58f9 100644 --- a/plugins/modules/nmcli.py +++ b/plugins/modules/nmcli.py @@ -13,16 +13,23 @@ DOCUMENTATION = r''' --- module: nmcli author: -- Chris Long (@alcamie101) + - Chris Long (@alcamie101) short_description: Manage Networking requirements: -- nmcli + - nmcli +extends_documentation_fragment: + - community.general.attributes description: - 'Manage the network devices. Create, modify and manage various connection and device type e.g., ethernet, teams, bonds, vlans etc.' - 'On CentOS 8 and Fedora >=29 like systems, the requirements can be met by installing the following packages: NetworkManager.' - 'On CentOS 7 and Fedora <=28 like systems, the requirements can be met by installing the following packages: NetworkManager-tui.' - 'On Ubuntu and Debian like systems, the requirements can be met by installing the following packages: network-manager' - 'On openSUSE, the requirements can be met by installing the following packages: NetworkManager.' +attributes: + check_mode: + support: full + diff_mode: + support: full options: state: description: diff --git a/plugins/modules/osx_defaults.py b/plugins/modules/osx_defaults.py index f905493a31..480f40af56 100644 --- a/plugins/modules/osx_defaults.py +++ b/plugins/modules/osx_defaults.py @@ -22,6 +22,13 @@ description: - macOS applications and other programs use the defaults system to record user preferences and other information that must be maintained when the applications are not running (such as default font for new documents, or the position of an Info panel). +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: domain: description: diff --git a/plugins/modules/pam_limits.py b/plugins/modules/pam_limits.py index d80ba5ffbf..dbb70045df 100644 --- a/plugins/modules/pam_limits.py +++ b/plugins/modules/pam_limits.py @@ -18,6 +18,15 @@ description: - The C(pam_limits) module modifies PAM limits. - The default file is C(/etc/security/limits.conf). - For the full documentation, see C(man 5 limits.conf). +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + version_added: 2.0.0 + diff_mode: + support: full + version_added: 2.0.0 options: domain: type: str diff --git a/plugins/modules/pamd.py b/plugins/modules/pamd.py index 9b7ac77857..6ffc8624e9 100644 --- a/plugins/modules/pamd.py +++ b/plugins/modules/pamd.py @@ -20,6 +20,13 @@ description: module_path must match an existing rule. See man(5) pam.d for details. notes: - This module does not handle authselect profiles. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/read_csv.py b/plugins/modules/read_csv.py index 38c91ded07..f2a359fa7d 100644 --- a/plugins/modules/read_csv.py +++ b/plugins/modules/read_csv.py @@ -16,6 +16,13 @@ description: - Read a CSV file and return a list or a dictionary, containing one dictionary per row. author: - Dag Wieers (@dagwieers) +extends_documentation_fragment: +- community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: path: description: diff --git a/plugins/modules/sefcontext.py b/plugins/modules/sefcontext.py index 8183ed7d71..c2fee45ee2 100644 --- a/plugins/modules/sefcontext.py +++ b/plugins/modules/sefcontext.py @@ -13,8 +13,15 @@ DOCUMENTATION = r''' module: sefcontext short_description: Manages SELinux file context mapping definitions description: -- Manages SELinux file context mapping definitions. -- Similar to the C(semanage fcontext) command. + - Manages SELinux file context mapping definitions. + - Similar to the C(semanage fcontext) command. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: full options: target: description: diff --git a/plugins/modules/selinux_permissive.py b/plugins/modules/selinux_permissive.py index 3563775d14..7249a01b82 100644 --- a/plugins/modules/selinux_permissive.py +++ b/plugins/modules/selinux_permissive.py @@ -15,6 +15,13 @@ module: selinux_permissive short_description: Change permissive domain in SELinux policy description: - Add and remove a domain from the list of permissive domains. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: domain: description: diff --git a/plugins/modules/selogin.py b/plugins/modules/selogin.py index 59222e073a..57482b0908 100644 --- a/plugins/modules/selogin.py +++ b/plugins/modules/selogin.py @@ -13,7 +13,14 @@ DOCUMENTATION = ''' module: selogin short_description: Manages linux user to SELinux user mapping description: - - Manages linux user to SELinux user mapping + - Manages linux user to SELinux user mapping +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: login: type: str diff --git a/plugins/modules/seport.py b/plugins/modules/seport.py index b43b501058..964e8f0eda 100644 --- a/plugins/modules/seport.py +++ b/plugins/modules/seport.py @@ -14,6 +14,13 @@ module: seport short_description: Manages SELinux network port type definitions description: - Manages SELinux network port type definitions. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: ports: description: diff --git a/plugins/modules/ssh_config.py b/plugins/modules/ssh_config.py index f2fa8aa457..c69f95d22b 100644 --- a/plugins/modules/ssh_config.py +++ b/plugins/modules/ssh_config.py @@ -20,6 +20,13 @@ description: author: - Björn Andersson (@gaqzi) - Abhijeet Kasurde (@Akasurde) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: description: @@ -95,8 +102,6 @@ options: version_added: 6.1.0 requirements: - StormSSH -notes: -- Supports check mode. ''' EXAMPLES = r''' diff --git a/plugins/modules/sudoers.py b/plugins/modules/sudoers.py index fd29b189f0..fd8289b1ca 100644 --- a/plugins/modules/sudoers.py +++ b/plugins/modules/sudoers.py @@ -19,6 +19,13 @@ description: - This module allows for the manipulation of sudoers files. author: - "Jon Ellis (@JonEllis) " +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: commands: description: diff --git a/plugins/modules/sysrc.py b/plugins/modules/sysrc.py index ccd5c2c545..9652b629ab 100644 --- a/plugins/modules/sysrc.py +++ b/plugins/modules/sysrc.py @@ -18,6 +18,13 @@ short_description: Manage FreeBSD using sysrc version_added: '2.0.0' description: - Manages C(/etc/rc.conf) for FreeBSD. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/timezone.py b/plugins/modules/timezone.py index 20404d3a79..05849e4bb1 100644 --- a/plugins/modules/timezone.py +++ b/plugins/modules/timezone.py @@ -26,6 +26,13 @@ description: - As of Ansible 2.4 support was added for macOS. - As of Ansible 2.9 support was added for AIX 6.1+ - Windows and HPUX are not supported, please let us know if you find any other OS/distro in which this fails. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: full options: name: description: diff --git a/plugins/modules/ufw.py b/plugins/modules/ufw.py index 6d18f3f781..45c98fd639 100644 --- a/plugins/modules/ufw.py +++ b/plugins/modules/ufw.py @@ -25,6 +25,13 @@ notes: - See C(man ufw) for more examples. requirements: - C(ufw) package +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: description: diff --git a/plugins/modules/xattr.py b/plugins/modules/xattr.py index 9cc74a1382..0b44fdaadf 100644 --- a/plugins/modules/xattr.py +++ b/plugins/modules/xattr.py @@ -16,6 +16,13 @@ description: - Manages filesystem user defined extended attributes. - Requires that extended attributes are enabled on the target filesystem and that the setfattr/getfattr utilities are present. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: path: description: diff --git a/plugins/modules/xfconf.py b/plugins/modules/xfconf.py index 0fff6f0d14..680c814e16 100644 --- a/plugins/modules/xfconf.py +++ b/plugins/modules/xfconf.py @@ -26,6 +26,15 @@ seealso: description: XFCE documentation for the Xfconf configuration system. link: 'https://docs.xfce.org/xfce/xfconf/start' +extends_documentation_fragment: + - community.general.attributes + +attributes: + check_mode: + support: full + diff_mode: + support: full + options: channel: description: diff --git a/plugins/modules/xml.py b/plugins/modules/xml.py index 9f16ee1344..5b9bba355c 100644 --- a/plugins/modules/xml.py +++ b/plugins/modules/xml.py @@ -16,7 +16,14 @@ DOCUMENTATION = r''' module: xml short_description: Manage bits and pieces of XML files or strings description: -- A CRUD-like interface to managing bits of XML files. + - A CRUD-like interface to managing bits of XML files. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: full options: path: description: From 0ef805699d6830a644ef207bf6c966edd7ad6878 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Mon, 20 Feb 2023 17:29:14 +0100 Subject: [PATCH 0172/1810] Add attributes to more modules (1/4) (#5965) * Add attributes to more modules. * Apply suggestions from code review. Co-authored-by: Kristian Heljas <11139388+kristianheljas@users.noreply.github.com> --------- Co-authored-by: Kristian Heljas <11139388+kristianheljas@users.noreply.github.com> --- plugins/doc_fragments/hpe3par.py | 3 +- plugins/modules/ali_instance.py | 6 +++ plugins/modules/deploy_helper.py | 10 +++- plugins/modules/heroku_collaborator.py | 7 +++ plugins/modules/honeybadger_deployment.py | 9 +++- plugins/modules/hponcfg.py | 9 +++- plugins/modules/imc_rest.py | 21 ++++++--- plugins/modules/imgadm.py | 7 +++ plugins/modules/infinity.py | 7 +++ plugins/modules/ip_netns.py | 7 +++ plugins/modules/ipwcli_dns.py | 9 ++++ plugins/modules/linode.py | 9 +++- plugins/modules/linode_v4.py | 7 +++ plugins/modules/lxc_container.py | 7 +++ plugins/modules/netcup_dns.py | 7 +++ plugins/modules/ohai.py | 19 +++++--- plugins/modules/omapi_host.py | 9 +++- plugins/modules/open_iscsi.py | 9 +++- plugins/modules/opendj_backendprop.py | 11 ++++- plugins/modules/openwrt_init.py | 7 +++ plugins/modules/pacemaker_cluster.py | 13 ++++-- plugins/modules/pmem.py | 7 +++ plugins/modules/pubnub_blocks.py | 56 +++++++++++++---------- plugins/modules/pulp_repo.py | 8 +++- plugins/modules/puppet.py | 7 +++ plugins/modules/pushbullet.py | 9 +++- plugins/modules/pushover.py | 15 ++++-- plugins/modules/serverless.py | 9 +++- plugins/modules/sl_vm.py | 7 +++ plugins/modules/ss_3par_cpg.py | 6 +++ plugins/modules/vdo.py | 9 ++++ plugins/modules/vexata_eg.py | 6 +++ plugins/modules/vexata_volume.py | 6 +++ plugins/modules/wakeonlan.py | 9 +++- plugins/modules/znode.py | 7 +++ 35 files changed, 296 insertions(+), 58 deletions(-) diff --git a/plugins/doc_fragments/hpe3par.py b/plugins/doc_fragments/hpe3par.py index 96e53846e1..606a2502a6 100644 --- a/plugins/doc_fragments/hpe3par.py +++ b/plugins/doc_fragments/hpe3par.py @@ -29,8 +29,7 @@ options: required: true requirements: - - hpe3par_sdk >= 1.0.2. Install using 'pip install hpe3par_sdk' + - hpe3par_sdk >= 1.0.2. Install using C(pip install hpe3par_sdk). - WSAPI service should be enabled on the 3PAR storage array. notes: - - check_mode not supported ''' diff --git a/plugins/modules/ali_instance.py b/plugins/modules/ali_instance.py index 96a042f5ca..232c21ee0f 100644 --- a/plugins/modules/ali_instance.py +++ b/plugins/modules/ali_instance.py @@ -31,6 +31,11 @@ short_description: Create, Start, Stop, Restart or Terminate an Instance in ECS; description: - Create, start, stop, restart, modify or terminate ecs instances. - Add or remove ecs instances to/from security group. +attributes: + check_mode: + support: none + diff_mode: + support: none options: state: description: @@ -252,6 +257,7 @@ requirements: - "footmark >= 1.19.0" extends_documentation_fragment: - community.general.alicloud + - community.general.attributes ''' EXAMPLES = ''' diff --git a/plugins/modules/deploy_helper.py b/plugins/modules/deploy_helper.py index afa63cba19..f0246cae63 100644 --- a/plugins/modules/deploy_helper.py +++ b/plugins/modules/deploy_helper.py @@ -31,6 +31,12 @@ description: C(new_release), either the 'release' parameter or a generated timestamp, C(new_release_path), the path to the new release folder (not created by the module)." +attributes: + check_mode: + support: full + diff_mode: + support: none + options: path: type: path @@ -111,7 +117,9 @@ notes: - Because of the default behaviour of generating the I(new_release) fact, this module will not be idempotent unless you pass your own release name with I(release). Due to the nature of deploying software, this should not be much of a problem. -extends_documentation_fragment: files +extends_documentation_fragment: + - ansible.builtin.files + - community.general.attributes ''' EXAMPLES = ''' diff --git a/plugins/modules/heroku_collaborator.py b/plugins/modules/heroku_collaborator.py index d76b2b6507..e7b0de3f99 100644 --- a/plugins/modules/heroku_collaborator.py +++ b/plugins/modules/heroku_collaborator.py @@ -21,6 +21,13 @@ author: - Marcel Arns (@marns93) requirements: - heroku3 +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: api_key: type: str diff --git a/plugins/modules/honeybadger_deployment.py b/plugins/modules/honeybadger_deployment.py index be8412f9af..820e4538e8 100644 --- a/plugins/modules/honeybadger_deployment.py +++ b/plugins/modules/honeybadger_deployment.py @@ -14,7 +14,14 @@ module: honeybadger_deployment author: "Benjamin Curtis (@stympy)" short_description: Notify Honeybadger.io about app deployments description: - - Notify Honeybadger.io about app deployments (see http://docs.honeybadger.io/article/188-deployment-tracking) + - Notify Honeybadger.io about app deployments (see U(http://docs.honeybadger.io/article/188-deployment-tracking)). +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: token: type: str diff --git a/plugins/modules/hponcfg.py b/plugins/modules/hponcfg.py index 65e40c46ed..612a20d923 100644 --- a/plugins/modules/hponcfg.py +++ b/plugins/modules/hponcfg.py @@ -15,7 +15,14 @@ module: hponcfg author: Dag Wieers (@dagwieers) short_description: Configure HP iLO interface using hponcfg description: - - This modules configures the HP iLO interface using hponcfg. + - This modules configures the HP iLO interface using hponcfg. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: path: description: diff --git a/plugins/modules/imc_rest.py b/plugins/modules/imc_rest.py index 4d90bcc54d..4bbaad23af 100644 --- a/plugins/modules/imc_rest.py +++ b/plugins/modules/imc_rest.py @@ -13,15 +13,22 @@ DOCUMENTATION = r''' module: imc_rest short_description: Manage Cisco IMC hardware through its REST API description: -- Provides direct access to the Cisco IMC REST API. -- Perform any configuration changes and actions that the Cisco IMC supports. -- More information about the IMC REST API is available from - U(http://www.cisco.com/c/en/us/td/docs/unified_computing/ucs/c/sw/api/3_0/b_Cisco_IMC_api_301.html) + - Provides direct access to the Cisco IMC REST API. + - Perform any configuration changes and actions that the Cisco IMC supports. + - More information about the IMC REST API is available from + U(http://www.cisco.com/c/en/us/td/docs/unified_computing/ucs/c/sw/api/3_0/b_Cisco_IMC_api_301.html). author: -- Dag Wieers (@dagwieers) + - Dag Wieers (@dagwieers) requirements: -- lxml -- xmljson >= 0.1.8 + - lxml + - xmljson >= 0.1.8 +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: hostname: description: diff --git a/plugins/modules/imgadm.py b/plugins/modules/imgadm.py index 2357fffa30..6e4b810982 100644 --- a/plugins/modules/imgadm.py +++ b/plugins/modules/imgadm.py @@ -16,6 +16,13 @@ short_description: Manage SmartOS images description: - Manage SmartOS virtual machine images through imgadm(1M) author: Jasper Lievisse Adriaanse (@jasperla) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: force: required: false diff --git a/plugins/modules/infinity.py b/plugins/modules/infinity.py index 4b0e835209..65aa591f4c 100644 --- a/plugins/modules/infinity.py +++ b/plugins/modules/infinity.py @@ -15,6 +15,13 @@ description: - Manage Infinity IPAM using REST API. author: - Meirong Liu (@MeganLiu) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: server_ip: description: diff --git a/plugins/modules/ip_netns.py b/plugins/modules/ip_netns.py index e719874f7d..69534c810d 100644 --- a/plugins/modules/ip_netns.py +++ b/plugins/modules/ip_netns.py @@ -15,6 +15,13 @@ short_description: Manage network namespaces requirements: [ ip ] description: - Create or delete network namespaces using the ip command. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: required: false diff --git a/plugins/modules/ipwcli_dns.py b/plugins/modules/ipwcli_dns.py index 9436decc8c..7b05aefb77 100644 --- a/plugins/modules/ipwcli_dns.py +++ b/plugins/modules/ipwcli_dns.py @@ -25,6 +25,15 @@ requirements: notes: - To make the DNS record changes effective, you need to run C(update dnsserver) on the ipwcli. +extends_documentation_fragment: + - community.general.attributes + +attributes: + check_mode: + support: full + diff_mode: + support: none + options: dnsname: description: diff --git a/plugins/modules/linode.py b/plugins/modules/linode.py index 5304ed3d89..404e7a393f 100644 --- a/plugins/modules/linode.py +++ b/plugins/modules/linode.py @@ -13,7 +13,14 @@ DOCUMENTATION = ''' module: linode short_description: Manage instances on the Linode Public Cloud description: - - Manage Linode Public Cloud instances and optionally wait for it to be 'running'. + - Manage Linode Public Cloud instances and optionally wait for it to be 'running'. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: state: description: diff --git a/plugins/modules/linode_v4.py b/plugins/modules/linode_v4.py index 3613fc7b50..f213af125e 100644 --- a/plugins/modules/linode_v4.py +++ b/plugins/modules/linode_v4.py @@ -22,6 +22,13 @@ notes: - No Linode resizing is currently implemented. This module will, in time, replace the current Linode module which uses deprecated API bindings on the Linode side. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: region: description: diff --git a/plugins/modules/lxc_container.py b/plugins/modules/lxc_container.py index 4e7f43419a..aec8f12dc4 100644 --- a/plugins/modules/lxc_container.py +++ b/plugins/modules/lxc_container.py @@ -16,6 +16,13 @@ short_description: Manage LXC Containers description: - Management of LXC containers. author: "Kevin Carter (@cloudnull)" +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/netcup_dns.py b/plugins/modules/netcup_dns.py index 4c3c015ebd..77be50b2c6 100644 --- a/plugins/modules/netcup_dns.py +++ b/plugins/modules/netcup_dns.py @@ -16,6 +16,13 @@ notes: [] short_description: Manage Netcup DNS records description: - "Manages DNS records via the Netcup API, see the docs U(https://ccp.netcup.net/run/webservice/servers/endpoint.php)." +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: api_key: description: diff --git a/plugins/modules/ohai.py b/plugins/modules/ohai.py index c7322c0962..7fdab3bb75 100644 --- a/plugins/modules/ohai.py +++ b/plugins/modules/ohai.py @@ -14,16 +14,23 @@ DOCUMENTATION = ''' module: ohai short_description: Returns inventory data from I(Ohai) description: - - Similar to the M(community.general.facter) module, this runs the I(Ohai) discovery program - (U(https://docs.chef.io/ohai.html)) on the remote host and - returns JSON inventory data. - I(Ohai) data is a bit more verbose and nested than I(facter). + - Similar to the M(community.general.facter) module, this runs the I(Ohai) discovery program + (U(https://docs.chef.io/ohai.html)) on the remote host and + returns JSON inventory data. + I(Ohai) data is a bit more verbose and nested than I(facter). +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: {} notes: [] requirements: [ "ohai" ] author: - - "Ansible Core Team" - - "Michael DeHaan (@mpdehaan)" + - "Ansible Core Team" + - "Michael DeHaan (@mpdehaan)" ''' EXAMPLES = ''' diff --git a/plugins/modules/omapi_host.py b/plugins/modules/omapi_host.py index 4e3a6247d6..c93c578535 100644 --- a/plugins/modules/omapi_host.py +++ b/plugins/modules/omapi_host.py @@ -18,7 +18,14 @@ description: Manage OMAPI hosts into compatible DHCPd servers requirements: - pypureomapi author: -- Loic Blot (@nerzhul) + - Loic Blot (@nerzhul) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: state: description: diff --git a/plugins/modules/open_iscsi.py b/plugins/modules/open_iscsi.py index 7704fd8b7f..af08d1c54f 100644 --- a/plugins/modules/open_iscsi.py +++ b/plugins/modules/open_iscsi.py @@ -12,13 +12,20 @@ DOCUMENTATION = r''' --- module: open_iscsi author: -- Serge van Ginderachter (@srvg) + - Serge van Ginderachter (@srvg) short_description: Manage iSCSI targets with Open-iSCSI description: - Discover targets on given portal, (dis)connect targets, mark targets to manually or auto start, return device nodes of connected targets. requirements: - open_iscsi library and tools (iscsiadm) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: portal: description: diff --git a/plugins/modules/opendj_backendprop.py b/plugins/modules/opendj_backendprop.py index 7e620c4305..fed53532d9 100644 --- a/plugins/modules/opendj_backendprop.py +++ b/plugins/modules/opendj_backendprop.py @@ -13,10 +13,17 @@ DOCUMENTATION = ''' module: opendj_backendprop short_description: Will update the backend configuration of OpenDJ via the dsconfig set-backend-prop command description: - - This module will update settings for OpenDJ with the command set-backend-prop. - - It will check first via de get-backend-prop if configuration needs to be applied. + - This module will update settings for OpenDJ with the command set-backend-prop. + - It will check first via de get-backend-prop if configuration needs to be applied. author: - Werner Dijkerman (@dj-wasabi) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: opendj_bindir: description: diff --git a/plugins/modules/openwrt_init.py b/plugins/modules/openwrt_init.py index 978a6bec35..a0e156b33a 100644 --- a/plugins/modules/openwrt_init.py +++ b/plugins/modules/openwrt_init.py @@ -15,6 +15,13 @@ author: short_description: Manage services on OpenWrt description: - Controls OpenWrt services on remote hosts. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: type: str diff --git a/plugins/modules/pacemaker_cluster.py b/plugins/modules/pacemaker_cluster.py index a71c1b0044..47b827908f 100644 --- a/plugins/modules/pacemaker_cluster.py +++ b/plugins/modules/pacemaker_cluster.py @@ -13,10 +13,17 @@ DOCUMENTATION = ''' module: pacemaker_cluster short_description: Manage pacemaker clusters author: -- Mathieu Bultel (@matbu) + - Mathieu Bultel (@matbu) description: - - This module can manage a pacemaker cluster and nodes from Ansible using - the pacemaker cli. + - This module can manage a pacemaker cluster and nodes from Ansible using + the pacemaker cli. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: description: diff --git a/plugins/modules/pmem.py b/plugins/modules/pmem.py index 8cc14c4693..d7fcb8e010 100644 --- a/plugins/modules/pmem.py +++ b/plugins/modules/pmem.py @@ -20,6 +20,13 @@ description: requirements: - ipmctl and ndctl command line tools - xmltodict +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: appdirect: description: diff --git a/plugins/modules/pubnub_blocks.py b/plugins/modules/pubnub_blocks.py index 7d15b0d9eb..a03553c5c7 100644 --- a/plugins/modules/pubnub_blocks.py +++ b/plugins/modules/pubnub_blocks.py @@ -20,21 +20,28 @@ module: pubnub_blocks short_description: PubNub blocks management module description: - "This module allows Ansible to interface with the PubNub BLOCKS - infrastructure by providing the following operations: create / remove, - start / stop and rename for blocks and create / modify / remove for event - handlers" + infrastructure by providing the following operations: create / remove, + start / stop and rename for blocks and create / modify / remove for event + handlers." author: - PubNub (@pubnub) - Sergey Mamontov (@parfeon) requirements: - "python >= 2.7" - "pubnub_blocks_client >= 1.0" +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: email: description: - Email from account for which new session should be started. - "Not required if C(cache) contains result of previous module call (in - same play)." + same play)." required: false type: str default: '' @@ -42,7 +49,7 @@ options: description: - Password which match to account to which specified C(email) belong. - "Not required if C(cache) contains result of previous module call (in - same play)." + same play)." required: false type: str default: '' @@ -57,14 +64,14 @@ options: account: description: - "Name of PubNub account for from which C(application) will be used to - manage blocks." + manage blocks." - "User's account will be used if value not set or empty." type: str default: '' application: description: - "Name of target PubNub application for which blocks configuration on - specific C(keyset) will be done." + specific C(keyset) will be done." type: str required: true keyset: @@ -75,7 +82,7 @@ options: state: description: - "Intended block state after event handlers creation / update process - will be completed." + will be completed." required: false default: 'present' choices: ['started', 'stopped', 'present', 'absent'] @@ -95,23 +102,23 @@ options: event_handlers: description: - "List of event handlers which should be updated for specified block - C(name)." + C(name)." - "Each entry for new event handler should contain: C(name), C(src), - C(channels), C(event). C(name) used as event handler name which can be - used later to make changes to it." + C(channels), C(event). C(name) used as event handler name which can be + used later to make changes to it." - C(src) is full path to file with event handler code. - "C(channels) is name of channel from which event handler is waiting - for events." + for events." - "C(event) is type of event which is able to trigger event handler: - I(js-before-publish), I(js-after-publish), I(js-after-presence)." + I(js-before-publish), I(js-after-publish), I(js-after-presence)." - "Each entry for existing handlers should contain C(name) (so target - handler can be identified). Rest parameters (C(src), C(channels) and - C(event)) can be added if changes required for them." + handler can be identified). Rest parameters (C(src), C(channels) and + C(event)) can be added if changes required for them." - "It is possible to rename event handler by adding C(changes) key to - event handler payload and pass dictionary, which will contain single key - C(name), where new name should be passed." + event handler payload and pass dictionary, which will contain single key + C(name), where new name should be passed." - "To remove particular event handler it is possible to set C(state) for - it to C(absent) and it will be removed." + it to C(absent) and it will be removed." required: false default: [] type: list @@ -119,7 +126,7 @@ options: changes: description: - "List of fields which should be changed by block itself (doesn't - affect any event handlers)." + affect any event handlers)." - "Possible options for change is: C(name)." required: false default: {} @@ -127,8 +134,8 @@ options: validate_certs: description: - "This key allow to try skip certificates check when performing REST API - calls. Sometimes host may have issues with certificates on it and this - will cause problems to call PubNub REST API." + calls. Sometimes host may have issues with certificates on it and this + will cause problems to call PubNub REST API." - If check should be ignored C(False) should be passed to this parameter. required: false default: true @@ -224,9 +231,10 @@ EXAMPLES = ''' RETURN = ''' module_cache: - description: "Cached account information. In case if with single play module - used few times it is better to pass cached data to next module calls to speed - up process." + description: + - Cached account information. In case if with single play module + used few times it is better to pass cached data to next module calls to speed + up process. type: dict returned: always ''' diff --git a/plugins/modules/pulp_repo.py b/plugins/modules/pulp_repo.py index 9e100ba93e..d7333f89ec 100644 --- a/plugins/modules/pulp_repo.py +++ b/plugins/modules/pulp_repo.py @@ -18,6 +18,11 @@ short_description: Add or remove Pulp repos from a remote host description: - Add or remove Pulp repos from a remote host. - Note, this is for Pulp 2 only. +attributes: + check_mode: + support: full + diff_mode: + support: none options: add_export_distributor: description: @@ -165,7 +170,8 @@ notes: - This module can currently only create distributors and importers on rpm repositories. Contributions to support other repo types are welcome. extends_documentation_fragment: - - url + - ansible.builtin.url + - community.general.attributes ''' EXAMPLES = ''' diff --git a/plugins/modules/puppet.py b/plugins/modules/puppet.py index 8454bb60fd..a93dddc63e 100644 --- a/plugins/modules/puppet.py +++ b/plugins/modules/puppet.py @@ -14,6 +14,13 @@ module: puppet short_description: Runs puppet description: - Runs I(puppet) agent or apply in a reliable manner. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: timeout: description: diff --git a/plugins/modules/pushbullet.py b/plugins/modules/pushbullet.py index a3e4104554..c7e20c3733 100644 --- a/plugins/modules/pushbullet.py +++ b/plugins/modules/pushbullet.py @@ -16,7 +16,14 @@ requirements: [ pushbullet.py ] module: pushbullet short_description: Sends notifications to Pushbullet description: - - This module sends push notifications via Pushbullet to channels or devices. + - This module sends push notifications via Pushbullet to channels or devices. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: api_key: type: str diff --git a/plugins/modules/pushover.py b/plugins/modules/pushover.py index c4c12a4670..f5493731fa 100644 --- a/plugins/modules/pushover.py +++ b/plugins/modules/pushover.py @@ -14,11 +14,18 @@ DOCUMENTATION = ''' module: pushover short_description: Send notifications via U(https://pushover.net) description: - - Send notifications via pushover, to subscriber list of devices, and email - addresses. Requires pushover app on devices. + - Send notifications via pushover, to subscriber list of devices, and email + addresses. Requires pushover app on devices. notes: - - You will require a pushover.net account to use this module. But no account - is required to receive messages. + - You will require a pushover.net account to use this module. But no account + is required to receive messages. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: msg: type: str diff --git a/plugins/modules/serverless.py b/plugins/modules/serverless.py index 4d36ba679a..67d673d4d7 100644 --- a/plugins/modules/serverless.py +++ b/plugins/modules/serverless.py @@ -13,7 +13,14 @@ DOCUMENTATION = r''' module: serverless short_description: Manages a Serverless Framework project description: - - Provides support for managing Serverless Framework (https://serverless.com/) project deployments and stacks. + - Provides support for managing Serverless Framework (U(https://serverless.com/)) project deployments and stacks. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: state: description: diff --git a/plugins/modules/sl_vm.py b/plugins/modules/sl_vm.py index ca925c345f..94055d1d22 100644 --- a/plugins/modules/sl_vm.py +++ b/plugins/modules/sl_vm.py @@ -15,6 +15,13 @@ short_description: Create or cancel a virtual instance in SoftLayer description: - Creates or cancels SoftLayer instances. - When created, optionally waits for it to be 'running'. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: instance_id: description: diff --git a/plugins/modules/ss_3par_cpg.py b/plugins/modules/ss_3par_cpg.py index f692ff3ecb..32c1cd443f 100644 --- a/plugins/modules/ss_3par_cpg.py +++ b/plugins/modules/ss_3par_cpg.py @@ -18,6 +18,11 @@ author: description: - Create and delete CPG on HPE 3PAR. module: ss_3par_cpg +attributes: + check_mode: + support: none + diff_mode: + support: none options: cpg_name: description: @@ -88,6 +93,7 @@ options: default: false extends_documentation_fragment: - community.general.hpe3par +- community.general.attributes ''' diff --git a/plugins/modules/vdo.py b/plugins/modules/vdo.py index d2d4afe944..f1ea40e2e4 100644 --- a/plugins/modules/vdo.py +++ b/plugins/modules/vdo.py @@ -24,6 +24,15 @@ description: provides inline block-level deduplication, compression, and thin provisioning capabilities to primary storage. +extends_documentation_fragment: + - community.general.attributes + +attributes: + check_mode: + support: none + diff_mode: + support: none + options: name: description: diff --git a/plugins/modules/vexata_eg.py b/plugins/modules/vexata_eg.py index f1d3960406..457d1fa9ed 100644 --- a/plugins/modules/vexata_eg.py +++ b/plugins/modules/vexata_eg.py @@ -20,6 +20,11 @@ description: through specific array ports. author: - Sandeep Kasargod (@vexata) +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: @@ -46,6 +51,7 @@ options: type: str extends_documentation_fragment: - community.general.vexata.vx100 +- community.general.attributes ''' diff --git a/plugins/modules/vexata_volume.py b/plugins/modules/vexata_volume.py index e443e5f6c4..7fdfc7e5fa 100644 --- a/plugins/modules/vexata_volume.py +++ b/plugins/modules/vexata_volume.py @@ -17,6 +17,11 @@ description: - Create, deletes or extend volumes on a Vexata VX100 array. author: - Sandeep Kasargod (@vexata) +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: @@ -35,6 +40,7 @@ options: type: str extends_documentation_fragment: - community.general.vexata.vx100 +- community.general.attributes ''' diff --git a/plugins/modules/wakeonlan.py b/plugins/modules/wakeonlan.py index bbdbcfdeff..6d7e094527 100644 --- a/plugins/modules/wakeonlan.py +++ b/plugins/modules/wakeonlan.py @@ -14,7 +14,14 @@ DOCUMENTATION = r''' module: wakeonlan short_description: Send a magic Wake-on-LAN (WoL) broadcast packet description: -- The C(wakeonlan) module sends magic Wake-on-LAN (WoL) broadcast packets. + - The C(wakeonlan) module sends magic Wake-on-LAN (WoL) broadcast packets. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: mac: description: diff --git a/plugins/modules/znode.py b/plugins/modules/znode.py index d9d05c3170..66f11465d6 100644 --- a/plugins/modules/znode.py +++ b/plugins/modules/znode.py @@ -14,6 +14,13 @@ module: znode short_description: Create, delete, retrieve, and update znodes using ZooKeeper description: - Create, delete, retrieve, and update znodes using ZooKeeper. +attributes: + check_mode: + support: none + diff_mode: + support: none +extends_documentation_fragment: + - community.general.attributes options: hosts: description: From b4a500103a4f617cfa0e92da6faf9d3d726b2f41 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Mon, 20 Feb 2023 17:29:41 +0100 Subject: [PATCH 0173/1810] Add attributes to more modules (2/4) (#5966) Add attributes to more modules. --- plugins/modules/aerospike_migrations.py | 7 ++++++ plugins/modules/airbrake_deployment.py | 7 ++++++ plugins/modules/alerta_customer.py | 7 ++++++ plugins/modules/awall.py | 7 ++++++ plugins/modules/bearychat.py | 7 ++++++ plugins/modules/bigpanda.py | 7 ++++++ plugins/modules/capabilities.py | 7 ++++++ plugins/modules/catapult.py | 9 ++++++- plugins/modules/circonus_annotation.py | 7 ++++++ plugins/modules/cloudflare_dns.py | 7 ++++++ plugins/modules/django_manage.py | 7 ++++++ plugins/modules/dnsimple.py | 7 ++++++ plugins/modules/dnsmadeeasy.py | 7 ++++++ plugins/modules/ejabberd_user.py | 7 ++++++ plugins/modules/elasticsearch_plugin.py | 7 ++++++ plugins/modules/emc_vnx_sg_member.py | 8 ++++++- plugins/modules/facter.py | 7 ++++++ plugins/modules/flowdock.py | 9 ++++++- plugins/modules/gandi_livedns.py | 13 +++++++---- plugins/modules/grove.py | 7 ++++++ plugins/modules/gunicorn.py | 17 ++++++++++---- plugins/modules/haproxy.py | 9 ++++++- plugins/modules/htpasswd.py | 9 ++++++- plugins/modules/iso_create.py | 17 ++++++++++---- plugins/modules/iso_customize.py | 9 +++++++ plugins/modules/iso_extract.py | 31 +++++++++++++++---------- plugins/modules/jboss.py | 7 ++++++ plugins/modules/jira.py | 9 +++++++ plugins/modules/kibana_plugin.py | 7 ++++++ plugins/modules/lbu.py | 13 +++++++++-- plugins/modules/lldp.py | 7 ++++++ plugins/modules/logstash_plugin.py | 7 ++++++ 32 files changed, 261 insertions(+), 32 deletions(-) diff --git a/plugins/modules/aerospike_migrations.py b/plugins/modules/aerospike_migrations.py index 32ab06a853..1eee5b1a2f 100644 --- a/plugins/modules/aerospike_migrations.py +++ b/plugins/modules/aerospike_migrations.py @@ -19,6 +19,13 @@ description: - If waiting for migrations is not desired, simply just poll until port 3000 if available or asinfo -v status returns ok author: "Albert Autin (@Alb0t)" +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: host: description: diff --git a/plugins/modules/airbrake_deployment.py b/plugins/modules/airbrake_deployment.py index 2fb5b58737..42ac037e1e 100644 --- a/plugins/modules/airbrake_deployment.py +++ b/plugins/modules/airbrake_deployment.py @@ -18,6 +18,13 @@ author: short_description: Notify airbrake about app deployments description: - Notify airbrake about app deployments (see U(https://airbrake.io/docs/api/#deploys-v4)). +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: project_id: description: diff --git a/plugins/modules/alerta_customer.py b/plugins/modules/alerta_customer.py index b9bfd4b265..120d989328 100644 --- a/plugins/modules/alerta_customer.py +++ b/plugins/modules/alerta_customer.py @@ -20,6 +20,13 @@ seealso: - name: API documentation description: Documentation for Alerta API link: https://docs.alerta.io/api/reference.html#customers +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: customer: description: diff --git a/plugins/modules/awall.py b/plugins/modules/awall.py index dc13d46789..856cf782d4 100644 --- a/plugins/modules/awall.py +++ b/plugins/modules/awall.py @@ -18,6 +18,13 @@ description: - This modules allows for enable/disable/activate of I(awall) policies. - Alpine Wall (I(awall)) generates a firewall configuration from the enabled policy files and activates the configuration on the system. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/bearychat.py b/plugins/modules/bearychat.py index 48d5c994fc..28f1f8fcd9 100644 --- a/plugins/modules/bearychat.py +++ b/plugins/modules/bearychat.py @@ -14,6 +14,13 @@ description: - The M(community.general.bearychat) module sends notifications to U(https://bearychat.com) via the Incoming Robot integration. author: "Jiangge Zhang (@tonyseek)" +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: url: type: str diff --git a/plugins/modules/bigpanda.py b/plugins/modules/bigpanda.py index 4e653aadb7..bab200bc44 100644 --- a/plugins/modules/bigpanda.py +++ b/plugins/modules/bigpanda.py @@ -15,6 +15,13 @@ author: "Hagai Kariti (@hkariti)" short_description: Notify BigPanda about deployments description: - Notify BigPanda when deployments start and end (successfully or not). Returns a deployment object containing all the parameters for future module calls. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: component: type: str diff --git a/plugins/modules/capabilities.py b/plugins/modules/capabilities.py index 9309958eca..9b72ac6ea1 100644 --- a/plugins/modules/capabilities.py +++ b/plugins/modules/capabilities.py @@ -14,6 +14,13 @@ module: capabilities short_description: Manage Linux capabilities description: - This module manipulates files privileges using the Linux capabilities(7) system. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: path: description: diff --git a/plugins/modules/catapult.py b/plugins/modules/catapult.py index 8b8c72974d..a3bbef6c42 100644 --- a/plugins/modules/catapult.py +++ b/plugins/modules/catapult.py @@ -16,7 +16,14 @@ DOCUMENTATION = ''' module: catapult short_description: Send a sms / mms using the catapult bandwidth api description: - - Allows notifications to be sent using sms / mms via the catapult bandwidth api. + - Allows notifications to be sent using sms / mms via the catapult bandwidth api. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: src: type: str diff --git a/plugins/modules/circonus_annotation.py b/plugins/modules/circonus_annotation.py index 661c854e6d..9376107761 100644 --- a/plugins/modules/circonus_annotation.py +++ b/plugins/modules/circonus_annotation.py @@ -20,6 +20,13 @@ requirements: - requests (either >= 2.0.0 for Python 3, or >= 1.0.0 for Python 2) notes: - Check mode isn't supported. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: api_key: type: str diff --git a/plugins/modules/cloudflare_dns.py b/plugins/modules/cloudflare_dns.py index 92132c0f6f..a0fa8a38b2 100644 --- a/plugins/modules/cloudflare_dns.py +++ b/plugins/modules/cloudflare_dns.py @@ -18,6 +18,13 @@ requirements: short_description: Manage Cloudflare DNS records description: - "Manages dns records via the Cloudflare API, see the docs: U(https://api.cloudflare.com/)." +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: api_token: description: diff --git a/plugins/modules/django_manage.py b/plugins/modules/django_manage.py index 188ff2d3df..537cf0fa74 100644 --- a/plugins/modules/django_manage.py +++ b/plugins/modules/django_manage.py @@ -17,6 +17,13 @@ short_description: Manages a Django application description: - Manages a Django application using the C(manage.py) application frontend to C(django-admin). With the I(virtualenv) parameter, all management commands will be executed by the given C(virtualenv) installation. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: command: description: diff --git a/plugins/modules/dnsimple.py b/plugins/modules/dnsimple.py index ddd3ba0bab..df41f73a69 100644 --- a/plugins/modules/dnsimple.py +++ b/plugins/modules/dnsimple.py @@ -16,6 +16,13 @@ module: dnsimple short_description: Interface with dnsimple.com (a DNS hosting service) description: - "Manages domains and records via the DNSimple API, see the docs: U(http://developer.dnsimple.com/)." +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: account_email: description: diff --git a/plugins/modules/dnsmadeeasy.py b/plugins/modules/dnsmadeeasy.py index b775f24ab0..44587ca39c 100644 --- a/plugins/modules/dnsmadeeasy.py +++ b/plugins/modules/dnsmadeeasy.py @@ -17,6 +17,13 @@ description: - > Manages DNS records via the v2 REST API of the DNS Made Easy service. It handles records only; there is no manipulation of domains or monitor/account support yet. See: U(https://www.dnsmadeeasy.com/integration/restapi/) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: account_key: description: diff --git a/plugins/modules/ejabberd_user.py b/plugins/modules/ejabberd_user.py index f7189fa08e..397207ae61 100644 --- a/plugins/modules/ejabberd_user.py +++ b/plugins/modules/ejabberd_user.py @@ -18,6 +18,13 @@ requirements: - ejabberd with mod_admin_extra description: - This module provides user management for ejabberd servers +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: username: type: str diff --git a/plugins/modules/elasticsearch_plugin.py b/plugins/modules/elasticsearch_plugin.py index a68ff086c3..cd4bb45de7 100644 --- a/plugins/modules/elasticsearch_plugin.py +++ b/plugins/modules/elasticsearch_plugin.py @@ -18,6 +18,13 @@ description: author: - Mathew Davies (@ThePixelDeveloper) - Sam Doran (@samdoran) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/emc_vnx_sg_member.py b/plugins/modules/emc_vnx_sg_member.py index 39c0ab3a99..487b6feefa 100644 --- a/plugins/modules/emc_vnx_sg_member.py +++ b/plugins/modules/emc_vnx_sg_member.py @@ -23,8 +23,14 @@ description: - "This module manages the members of an existing storage group." extends_documentation_fragment: -- community.general.emc.emc_vnx + - community.general.emc.emc_vnx + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: diff --git a/plugins/modules/facter.py b/plugins/modules/facter.py index be45e3ce14..e7cf52e203 100644 --- a/plugins/modules/facter.py +++ b/plugins/modules/facter.py @@ -16,6 +16,13 @@ description: - Runs the C(facter) discovery program (U(https://github.com/puppetlabs/facter)) on the remote system, returning JSON data that can be useful for inventory purposes. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: arguments: description: diff --git a/plugins/modules/flowdock.py b/plugins/modules/flowdock.py index 965ae62d7a..c78716ba40 100644 --- a/plugins/modules/flowdock.py +++ b/plugins/modules/flowdock.py @@ -15,7 +15,14 @@ module: flowdock author: "Matt Coddington (@mcodd)" short_description: Send a message to a flowdock description: - - Send a message to a flowdock team inbox or chat using the push API (see https://www.flowdock.com/api/team-inbox and https://www.flowdock.com/api/chat) + - Send a message to a flowdock team inbox or chat using the push API (see https://www.flowdock.com/api/team-inbox and https://www.flowdock.com/api/chat) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: token: type: str diff --git a/plugins/modules/gandi_livedns.py b/plugins/modules/gandi_livedns.py index 9566661f41..cc9dd630b4 100644 --- a/plugins/modules/gandi_livedns.py +++ b/plugins/modules/gandi_livedns.py @@ -12,11 +12,18 @@ DOCUMENTATION = r''' --- module: gandi_livedns author: -- Gregory Thiemonge (@gthiemonge) + - Gregory Thiemonge (@gthiemonge) version_added: "2.3.0" short_description: Manage Gandi LiveDNS records description: -- "Manages DNS records by the Gandi LiveDNS API, see the docs: U(https://doc.livedns.gandi.net/)." + - "Manages DNS records by the Gandi LiveDNS API, see the docs: U(https://doc.livedns.gandi.net/)." +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: api_key: description: @@ -55,8 +62,6 @@ options: - The name of the Domain to work with (for example, "example.com"). required: true type: str -notes: -- Supports C(check_mode). ''' EXAMPLES = r''' diff --git a/plugins/modules/grove.py b/plugins/modules/grove.py index d3ad6bb019..b3e0508ffa 100644 --- a/plugins/modules/grove.py +++ b/plugins/modules/grove.py @@ -16,6 +16,13 @@ short_description: Sends a notification to a grove.io channel description: - The C(grove) module sends a message for a service to a Grove.io channel. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: channel_token: type: str diff --git a/plugins/modules/gunicorn.py b/plugins/modules/gunicorn.py index ff88cead7c..2b2abcf8e6 100644 --- a/plugins/modules/gunicorn.py +++ b/plugins/modules/gunicorn.py @@ -14,14 +14,21 @@ DOCUMENTATION = ''' module: gunicorn short_description: Run gunicorn with various settings description: - - Starts gunicorn with the parameters specified. Common settings for gunicorn - configuration are supported. For additional configuration use a config file - See U(https://gunicorn-docs.readthedocs.io/en/latest/settings.html) for more - options. It's recommended to always use the chdir option to avoid problems - with the location of the app. + - Starts gunicorn with the parameters specified. Common settings for gunicorn + configuration are supported. For additional configuration use a config file + See U(https://gunicorn-docs.readthedocs.io/en/latest/settings.html) for more + options. It's recommended to always use the chdir option to avoid problems + with the location of the app. requirements: [gunicorn] author: - "Alejandro Gomez (@agmezr)" +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: app: type: str diff --git a/plugins/modules/haproxy.py b/plugins/modules/haproxy.py index 38033bc81a..56f987d80f 100644 --- a/plugins/modules/haproxy.py +++ b/plugins/modules/haproxy.py @@ -13,7 +13,7 @@ DOCUMENTATION = r''' module: haproxy short_description: Enable, disable, and set weights for HAProxy backend servers using socket commands author: -- Ravi Bhure (@ravibhure) + - Ravi Bhure (@ravibhure) description: - Enable, disable, drain and set weights for HAProxy backend servers using socket commands. notes: @@ -23,6 +23,13 @@ notes: haproxy.cfg. See U(http://haproxy.1wt.eu/download/1.5/doc/configuration.txt). - Depends on netcat (C(nc)) being available; you need to install the appropriate package for your operating system before this module can be used. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: backend: description: diff --git a/plugins/modules/htpasswd.py b/plugins/modules/htpasswd.py index 231506984a..180b020733 100644 --- a/plugins/modules/htpasswd.py +++ b/plugins/modules/htpasswd.py @@ -15,6 +15,11 @@ short_description: Manage user files for basic authentication description: - Add and remove username/password entries in a password file using htpasswd. - This is used by web servers such as Apache and Nginx for basic authentication. +attributes: + check_mode: + support: full + diff_mode: + support: none options: path: type: path @@ -68,7 +73,9 @@ notes: - "On RHEL or CentOS: Enable EPEL, then install I(python-passlib)." requirements: [ passlib>=1.6 ] author: "Ansible Core Team" -extends_documentation_fragment: files +extends_documentation_fragment: + - files + - community.general.attributes ''' EXAMPLES = """ diff --git a/plugins/modules/iso_create.py b/plugins/modules/iso_create.py index c457f5a412..4b51be96d2 100644 --- a/plugins/modules/iso_create.py +++ b/plugins/modules/iso_create.py @@ -14,14 +14,23 @@ DOCUMENTATION = r''' module: iso_create short_description: Generate ISO file with specified files or folders description: - - This module is used to generate ISO file with specified path of files. + - This module is used to generate ISO file with specified path of files. author: - - Diane Wang (@Tomorrow9) + - Diane Wang (@Tomorrow9) requirements: -- "pycdlib" -- "python >= 2.7" + - "pycdlib" + - "python >= 2.7" version_added: '0.2.0' +extends_documentation_fragment: + - community.general.attributes + +attributes: + check_mode: + support: full + diff_mode: + support: none + options: src_files: description: diff --git a/plugins/modules/iso_customize.py b/plugins/modules/iso_customize.py index 4f902f47e4..9add080b11 100644 --- a/plugins/modules/iso_customize.py +++ b/plugins/modules/iso_customize.py @@ -23,6 +23,15 @@ requirements: - "python >= 2.7" version_added: '5.8.0' +extends_documentation_fragment: + - community.general.attributes + +attributes: + check_mode: + support: full + diff_mode: + support: none + options: src_iso: description: diff --git a/plugins/modules/iso_extract.py b/plugins/modules/iso_extract.py index 6693fc3884..599cbe4de5 100644 --- a/plugins/modules/iso_extract.py +++ b/plugins/modules/iso_extract.py @@ -14,22 +14,29 @@ __metaclass__ = type DOCUMENTATION = r''' --- author: -- Jeroen Hoekx (@jhoekx) -- Matt Robinson (@ribbons) -- Dag Wieers (@dagwieers) + - Jeroen Hoekx (@jhoekx) + - Matt Robinson (@ribbons) + - Dag Wieers (@dagwieers) module: iso_extract short_description: Extract files from an ISO image description: -- This module has two possible ways of operation. -- If 7zip is installed on the system, this module extracts files from an ISO - into a temporary directory and copies files to a given destination, - if needed. -- If the user has mount-capabilities (CAP_SYS_ADMIN on Linux) this module - mounts the ISO image to a temporary location, and copies files to a given - destination, if needed. + - This module has two possible ways of operation. + - If 7zip is installed on the system, this module extracts files from an ISO + into a temporary directory and copies files to a given destination, + if needed. + - If the user has mount-capabilities (CAP_SYS_ADMIN on Linux) this module + mounts the ISO image to a temporary location, and copies files to a given + destination, if needed. requirements: -- Either 7z (from C(7zip) or C(p7zip) package) -- Or mount capabilities (root-access, or CAP_SYS_ADMIN capability on Linux) + - Either 7z (from C(7zip) or C(p7zip) package) + - Or mount capabilities (root-access, or CAP_SYS_ADMIN capability on Linux) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: image: description: diff --git a/plugins/modules/jboss.py b/plugins/modules/jboss.py index 2dc82f5594..b389e7e662 100644 --- a/plugins/modules/jboss.py +++ b/plugins/modules/jboss.py @@ -14,6 +14,13 @@ module: jboss short_description: Deploy applications to JBoss description: - Deploy applications to JBoss standalone using the filesystem. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: deployment: required: true diff --git a/plugins/modules/jira.py b/plugins/modules/jira.py index 5e0a55119c..91aeb67037 100644 --- a/plugins/modules/jira.py +++ b/plugins/modules/jira.py @@ -20,6 +20,15 @@ short_description: Create and modify issues in a JIRA instance description: - Create and modify issues in a JIRA instance. +extends_documentation_fragment: + - community.general.attributes + +attributes: + check_mode: + support: none + diff_mode: + support: none + options: uri: type: str diff --git a/plugins/modules/kibana_plugin.py b/plugins/modules/kibana_plugin.py index 94838e22b6..a52eda2fdd 100644 --- a/plugins/modules/kibana_plugin.py +++ b/plugins/modules/kibana_plugin.py @@ -18,6 +18,13 @@ short_description: Manage Kibana plugins description: - This module can be used to manage Kibana plugins. author: Thierno IB. BARRY (@barryib) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/lbu.py b/plugins/modules/lbu.py index 86f01f62af..c961b6060d 100644 --- a/plugins/modules/lbu.py +++ b/plugins/modules/lbu.py @@ -17,7 +17,16 @@ short_description: Local Backup Utility for Alpine Linux version_added: '0.2.0' description: -- Manage Local Backup Utility of Alpine Linux in run-from-RAM mode + - Manage Local Backup Utility of Alpine Linux in run-from-RAM mode + +extends_documentation_fragment: + - community.general.attributes + +attributes: + check_mode: + support: full + diff_mode: + support: none options: commit: @@ -36,7 +45,7 @@ options: elements: str author: -- Kaarle Ritvanen (@kunkku) + - Kaarle Ritvanen (@kunkku) ''' EXAMPLES = ''' diff --git a/plugins/modules/lldp.py b/plugins/modules/lldp.py index 3a050ae29e..fb608ff138 100644 --- a/plugins/modules/lldp.py +++ b/plugins/modules/lldp.py @@ -16,6 +16,13 @@ requirements: [ lldpctl ] short_description: Get details reported by lldp description: - Reads data out of lldpctl +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: {} author: "Andy Hill (@andyhky)" notes: diff --git a/plugins/modules/logstash_plugin.py b/plugins/modules/logstash_plugin.py index a4979646dd..7ee118ff28 100644 --- a/plugins/modules/logstash_plugin.py +++ b/plugins/modules/logstash_plugin.py @@ -15,6 +15,13 @@ short_description: Manage Logstash plugins description: - Manages Logstash plugins. author: Loic Blot (@nerzhul) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: type: str From d03ae532edfd25dd8d7748323d08207a1d4b23c6 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Mon, 20 Feb 2023 17:30:26 +0100 Subject: [PATCH 0174/1810] Add attributes to more modules (3/4) (#5967) Add attributes to more modules. --- plugins/modules/mas.py | 9 +++++++-- plugins/modules/maven_artifact.py | 8 +++++++- plugins/modules/monit.py | 7 +++++++ plugins/modules/mqtt.py | 9 ++++++++- plugins/modules/nagios.py | 7 +++++++ plugins/modules/newrelic_deployment.py | 7 +++++++ plugins/modules/nexmo.py | 8 +++++++- plugins/modules/nictagadm.py | 9 ++++++++- plugins/modules/nomad_job.py | 14 +++++++++----- plugins/modules/nosh.py | 7 +++++++ plugins/modules/nsupdate.py | 7 +++++++ plugins/modules/oci_vcn.py | 14 ++++++++++---- plugins/modules/office_365_connector_card.py | 7 +++++++ plugins/modules/pids.py | 7 +++++++ plugins/modules/pingdom.py | 7 +++++++ plugins/modules/redhat_subscription.py | 7 +++++++ plugins/modules/rhevm.py | 9 ++++++++- plugins/modules/rhn_channel.py | 10 ++++++++-- plugins/modules/rhn_register.py | 9 ++++++++- plugins/modules/rhsm_release.py | 7 +++++++ plugins/modules/rhsm_repository.py | 7 +++++++ plugins/modules/rollbar_deployment.py | 7 +++++++ plugins/modules/runit.py | 9 ++++++++- 23 files changed, 172 insertions(+), 20 deletions(-) diff --git a/plugins/modules/mas.py b/plugins/modules/mas.py index af77110da7..5b8958beb0 100644 --- a/plugins/modules/mas.py +++ b/plugins/modules/mas.py @@ -19,6 +19,13 @@ version_added: '0.2.0' author: - Michael Heap (@mheap) - Lukas Bestle (@lukasbestle) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: id: description: @@ -46,8 +53,6 @@ requirements: - macOS 10.11+ - "mas-cli (U(https://github.com/mas-cli/mas)) 1.5.0+ available as C(mas) in the bin path" - The Apple ID to use already needs to be signed in to the Mac App Store (check with C(mas account)). -notes: - - This module supports C(check_mode). ''' EXAMPLES = ''' diff --git a/plugins/modules/maven_artifact.py b/plugins/modules/maven_artifact.py index 754c2392ba..3f9defa529 100644 --- a/plugins/modules/maven_artifact.py +++ b/plugins/modules/maven_artifact.py @@ -23,6 +23,11 @@ author: "Chris Schmidt (@chrisisbeef)" requirements: - lxml - boto if using a S3 repository (s3://...) +attributes: + check_mode: + support: none + diff_mode: + support: none options: group_id: type: str @@ -166,7 +171,8 @@ options: description: - Filesystem permission mode applied recursively to I(dest) when it is a directory. extends_documentation_fragment: - - files + - ansible.builtin.files + - community.general.attributes ''' EXAMPLES = ''' diff --git a/plugins/modules/monit.py b/plugins/modules/monit.py index 729b05b5d1..d2a1606789 100644 --- a/plugins/modules/monit.py +++ b/plugins/modules/monit.py @@ -15,6 +15,13 @@ module: monit short_description: Manage the state of a program monitored via Monit description: - Manage the state of a program monitored via I(Monit). +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/mqtt.py b/plugins/modules/mqtt.py index fe6e7347fc..3893826491 100644 --- a/plugins/modules/mqtt.py +++ b/plugins/modules/mqtt.py @@ -14,7 +14,14 @@ DOCUMENTATION = ''' module: mqtt short_description: Publish a message on an MQTT topic for the IoT description: - - Publish a message on an MQTT topic. + - Publish a message on an MQTT topic. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: server: type: str diff --git a/plugins/modules/nagios.py b/plugins/modules/nagios.py index ec526a3959..1831d04961 100644 --- a/plugins/modules/nagios.py +++ b/plugins/modules/nagios.py @@ -28,6 +28,13 @@ description: e.g., I(service=host). This keyword may not be given with other services at the same time. I(Setting alerts/downtime/acknowledge for a host does not affect alerts/downtime/acknowledge for any of the services running on it.) To schedule downtime for all services on particular host use keyword "all", e.g., I(service=all). +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: action: description: diff --git a/plugins/modules/newrelic_deployment.py b/plugins/modules/newrelic_deployment.py index 91f49fbe65..ac9903b576 100644 --- a/plugins/modules/newrelic_deployment.py +++ b/plugins/modules/newrelic_deployment.py @@ -16,6 +16,13 @@ author: "Matt Coddington (@mcodd)" short_description: Notify New Relic about app deployments description: - Notify New Relic about app deployments (see https://docs.newrelic.com/docs/apm/new-relic-apm/maintenance/record-monitor-deployments/) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: token: type: str diff --git a/plugins/modules/nexmo.py b/plugins/modules/nexmo.py index d1e6b8d35c..7461c1cb97 100644 --- a/plugins/modules/nexmo.py +++ b/plugins/modules/nexmo.py @@ -15,6 +15,11 @@ short_description: Send a SMS via nexmo description: - Send a SMS message via nexmo author: "Matt Martz (@sivel)" +attributes: + check_mode: + support: none + diff_mode: + support: none options: api_key: type: str @@ -50,7 +55,8 @@ options: type: bool default: true extends_documentation_fragment: - - url + - ansible.builtin.url + - community.general.attributes ''' EXAMPLES = """ diff --git a/plugins/modules/nictagadm.py b/plugins/modules/nictagadm.py index e70d93c8a1..074e09b4ac 100644 --- a/plugins/modules/nictagadm.py +++ b/plugins/modules/nictagadm.py @@ -15,7 +15,14 @@ short_description: Manage nic tags on SmartOS systems description: - Create or delete nic tags on SmartOS systems. author: -- Bruce Smith (@SmithX10) + - Bruce Smith (@SmithX10) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/nomad_job.py b/plugins/modules/nomad_job.py index 05e2556c1b..ca76536b46 100644 --- a/plugins/modules/nomad_job.py +++ b/plugins/modules/nomad_job.py @@ -15,13 +15,19 @@ author: FERREIRA Christophe (@chris93111) version_added: "1.3.0" short_description: Launch a Nomad Job description: - - Launch a Nomad job. - - Stop a Nomad job. - - Force start a Nomad job + - Launch a Nomad job. + - Stop a Nomad job. + - Force start a Nomad job requirements: - python-nomad extends_documentation_fragment: - community.general.nomad + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: @@ -51,8 +57,6 @@ options: choices: ["hcl", "json"] default: hcl type: str -notes: - - C(check_mode) is supported. seealso: - name: Nomad jobs documentation description: Complete documentation for Nomad API jobs. diff --git a/plugins/modules/nosh.py b/plugins/modules/nosh.py index 432990a4d2..2dfb8d5901 100644 --- a/plugins/modules/nosh.py +++ b/plugins/modules/nosh.py @@ -18,6 +18,13 @@ short_description: Manage services with nosh description: - Control running and enabled state for system-wide or user services. - BSD and Linux systems are supported. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: type: str diff --git a/plugins/modules/nsupdate.py b/plugins/modules/nsupdate.py index bc31521cdb..b2a84f76ba 100644 --- a/plugins/modules/nsupdate.py +++ b/plugins/modules/nsupdate.py @@ -24,6 +24,13 @@ description: requirements: - dnspython author: "Loic Blot (@nerzhul)" +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: description: diff --git a/plugins/modules/oci_vcn.py b/plugins/modules/oci_vcn.py index 87568e1893..4e6487b8f6 100644 --- a/plugins/modules/oci_vcn.py +++ b/plugins/modules/oci_vcn.py @@ -16,6 +16,11 @@ description: - This module allows the user to create, delete and update virtual cloud networks(VCNs) in OCI. The complete Oracle Cloud Infrastructure Ansible Modules can be downloaded from U(https://github.com/oracle/oci-ansible-modules/releases). +attributes: + check_mode: + support: none + diff_mode: + support: none options: cidr_block: description: The CIDR IP address block of the VCN. Required when creating a VCN with I(state=present). @@ -48,10 +53,11 @@ options: aliases: [ 'id' ] author: "Rohit Chaware (@rohitChaware)" extends_documentation_fragment: -- community.general.oracle -- community.general.oracle_creatable_resource -- community.general.oracle_wait_options -- community.general.oracle_tags + - community.general.oracle + - community.general.oracle_creatable_resource + - community.general.oracle_wait_options + - community.general.oracle_tags + - community.general.attributes ''' diff --git a/plugins/modules/office_365_connector_card.py b/plugins/modules/office_365_connector_card.py index fc9a24aa57..eb774fded9 100644 --- a/plugins/modules/office_365_connector_card.py +++ b/plugins/modules/office_365_connector_card.py @@ -18,6 +18,13 @@ author: "Marc Sensenich (@marc-sensenich)" notes: - This module is not idempotent, therefore if the same task is run twice there will be two Connector Cards created +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: webhook: type: str diff --git a/plugins/modules/pids.py b/plugins/modules/pids.py index 2fe2a6b8ac..665adb1424 100644 --- a/plugins/modules/pids.py +++ b/plugins/modules/pids.py @@ -15,6 +15,13 @@ author: - Saranya Sridharan (@saranyasridharan) requirements: - psutil(python module) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: The name of the process(es) you want to get PID(s) for. diff --git a/plugins/modules/pingdom.py b/plugins/modules/pingdom.py index e9ee40eb96..bd4826a780 100644 --- a/plugins/modules/pingdom.py +++ b/plugins/modules/pingdom.py @@ -19,6 +19,13 @@ author: - "Justin Johns (!UNKNOWN)" requirements: - "This pingdom python library: https://github.com/mbabineau/pingdom-python" +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: state: type: str diff --git a/plugins/modules/redhat_subscription.py b/plugins/modules/redhat_subscription.py index 2649092e8a..569b12d14d 100644 --- a/plugins/modules/redhat_subscription.py +++ b/plugins/modules/redhat_subscription.py @@ -25,6 +25,13 @@ notes: config file and default to None. requirements: - subscription-manager +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: state: description: diff --git a/plugins/modules/rhevm.py b/plugins/modules/rhevm.py index 994f737093..c129a2df52 100644 --- a/plugins/modules/rhevm.py +++ b/plugins/modules/rhevm.py @@ -19,7 +19,14 @@ description: requirements: - ovirtsdk author: -- Timothy Vandenbrande (@TimothyVandenbrande) + - Timothy Vandenbrande (@TimothyVandenbrande) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: user: description: diff --git a/plugins/modules/rhn_channel.py b/plugins/modules/rhn_channel.py index 02fc30dad0..e544af51ea 100644 --- a/plugins/modules/rhn_channel.py +++ b/plugins/modules/rhn_channel.py @@ -15,10 +15,16 @@ short_description: Adds or removes Red Hat software channels description: - Adds or removes Red Hat software channels. author: -- Vincent Van der Kussen (@vincentvdk) + - Vincent Van der Kussen (@vincentvdk) notes: - This module fetches the system id from RHN. - - This module doesn't support I(check_mode). +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/rhn_register.py b/plugins/modules/rhn_register.py index ba58c3345f..1fe9297d2b 100644 --- a/plugins/modules/rhn_register.py +++ b/plugins/modules/rhn_register.py @@ -15,13 +15,20 @@ short_description: Manage Red Hat Network registration using the C(rhnreg_ks) co description: - Manage registration to the Red Hat Network. author: -- James Laska (@jlaska) + - James Laska (@jlaska) notes: - This is for older Red Hat products. You probably want the M(community.general.redhat_subscription) module instead. - In order to register a system, C(rhnreg_ks) requires either a username and password, or an activationkey. requirements: - rhnreg_ks - either libxml2 or lxml +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: state: description: diff --git a/plugins/modules/rhsm_release.py b/plugins/modules/rhsm_release.py index 698e64f995..8ad763a778 100644 --- a/plugins/modules/rhsm_release.py +++ b/plugins/modules/rhsm_release.py @@ -20,6 +20,13 @@ notes: prior to setting the RHSM release. requirements: - Red Hat Enterprise Linux 6+ with subscription-manager installed +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: release: description: diff --git a/plugins/modules/rhsm_repository.py b/plugins/modules/rhsm_repository.py index 2ff0cd4c96..0517582403 100644 --- a/plugins/modules/rhsm_repository.py +++ b/plugins/modules/rhsm_repository.py @@ -22,6 +22,13 @@ notes: requirements: - subscription-manager +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: full options: state: description: diff --git a/plugins/modules/rollbar_deployment.py b/plugins/modules/rollbar_deployment.py index c899d60163..314e65bc6c 100644 --- a/plugins/modules/rollbar_deployment.py +++ b/plugins/modules/rollbar_deployment.py @@ -17,6 +17,13 @@ short_description: Notify Rollbar about app deployments description: - Notify Rollbar about app deployments (see https://rollbar.com/docs/deploys_other/) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: token: type: str diff --git a/plugins/modules/runit.py b/plugins/modules/runit.py index 7b60215300..7c5882af88 100644 --- a/plugins/modules/runit.py +++ b/plugins/modules/runit.py @@ -12,10 +12,17 @@ DOCUMENTATION = r''' --- module: runit author: -- James Sumners (@jsumners) + - James Sumners (@jsumners) short_description: Manage runit services description: - Controls runit services on remote hosts using the sv utility. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: From 4b262e39f0bc6c4bdce394b355dd72d33b352478 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Mon, 20 Feb 2023 17:30:53 +0100 Subject: [PATCH 0175/1810] Add attributes to more modules (4/4) (#5968) * Add attributes to more modules. * Adjust indentation. Co-authored-by: Kristian Heljas <11139388+kristianheljas@users.noreply.github.com> --------- Co-authored-by: Kristian Heljas <11139388+kristianheljas@users.noreply.github.com> --- plugins/modules/solaris_zone.py | 9 ++++++++- plugins/modules/sorcery.py | 7 +++++++ plugins/modules/spotinst_aws_elastigroup.py | 7 +++++++ plugins/modules/stackdriver.py | 7 +++++++ plugins/modules/stacki_host.py | 7 +++++++ plugins/modules/statsd.py | 7 +++++++ plugins/modules/statusio_maintenance.py | 7 +++++++ plugins/modules/supervisorctl.py | 9 ++++++++- plugins/modules/svc.py | 7 +++++++ plugins/modules/swdepot.py | 7 +++++++ plugins/modules/swupd.py | 7 +++++++ plugins/modules/terraform.py | 11 +++++++++-- plugins/modules/uptimerobot.py | 7 +++++++ plugins/modules/urpmi.py | 7 +++++++ plugins/modules/vmadm.py | 7 +++++++ 15 files changed, 109 insertions(+), 4 deletions(-) diff --git a/plugins/modules/solaris_zone.py b/plugins/modules/solaris_zone.py index 5d07dbfc60..0f970704ef 100644 --- a/plugins/modules/solaris_zone.py +++ b/plugins/modules/solaris_zone.py @@ -16,9 +16,16 @@ description: - Create, start, stop and delete Solaris zones. - This module does not currently allow changing of options for a zone that is already been created. author: -- Paul Markham (@pmarkham) + - Paul Markham (@pmarkham) requirements: - Solaris 10 or 11 +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: description: diff --git a/plugins/modules/sorcery.py b/plugins/modules/sorcery.py index bd16da1f52..3278ce0abd 100644 --- a/plugins/modules/sorcery.py +++ b/plugins/modules/sorcery.py @@ -24,6 +24,13 @@ notes: yet supported. requirements: - bash +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/spotinst_aws_elastigroup.py b/plugins/modules/spotinst_aws_elastigroup.py index 481ba70cb9..02f2d3c5c2 100644 --- a/plugins/modules/spotinst_aws_elastigroup.py +++ b/plugins/modules/spotinst_aws_elastigroup.py @@ -21,6 +21,13 @@ description: requirements: - python >= 2.7 - spotinst_sdk >= 1.0.38 +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: credentials_path: diff --git a/plugins/modules/stackdriver.py b/plugins/modules/stackdriver.py index 6fe2a7caa9..cf7cb2f475 100644 --- a/plugins/modules/stackdriver.py +++ b/plugins/modules/stackdriver.py @@ -15,6 +15,13 @@ short_description: Send code deploy and annotation events to stackdriver description: - Send code deploy and annotation events to Stackdriver author: "Ben Whaley (@bwhaley)" +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: key: type: str diff --git a/plugins/modules/stacki_host.py b/plugins/modules/stacki_host.py index d5f968c909..e286bc9617 100644 --- a/plugins/modules/stacki_host.py +++ b/plugins/modules/stacki_host.py @@ -15,6 +15,13 @@ short_description: Add or remove host to stacki front-end description: - Use this module to add or remove hosts to a stacki front-end via API. - Information on stacki can be found at U(https://github.com/StackIQ/stacki). +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/statsd.py b/plugins/modules/statsd.py index aed1c08397..65d33b7099 100644 --- a/plugins/modules/statsd.py +++ b/plugins/modules/statsd.py @@ -19,6 +19,13 @@ description: author: "Mark Mercado (@mamercad)" requirements: - statsd +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: state: type: str diff --git a/plugins/modules/statusio_maintenance.py b/plugins/modules/statusio_maintenance.py index b884a943aa..31b422453e 100644 --- a/plugins/modules/statusio_maintenance.py +++ b/plugins/modules/statusio_maintenance.py @@ -21,6 +21,13 @@ notes: capture API traffic - Use start_date and start_time with minutes to set future maintenance window author: Benjamin Copeland (@bhcopeland) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: title: type: str diff --git a/plugins/modules/supervisorctl.py b/plugins/modules/supervisorctl.py index e108ebb81d..e9df16108a 100644 --- a/plugins/modules/supervisorctl.py +++ b/plugins/modules/supervisorctl.py @@ -14,7 +14,14 @@ DOCUMENTATION = ''' module: supervisorctl short_description: Manage the state of a program or group of programs running via supervisord description: - - Manage the state of a program or group of programs running via supervisord + - Manage the state of a program or group of programs running via supervisord +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: type: str diff --git a/plugins/modules/svc.py b/plugins/modules/svc.py index 4d92892ce3..bd2eaeb22e 100644 --- a/plugins/modules/svc.py +++ b/plugins/modules/svc.py @@ -16,6 +16,13 @@ author: short_description: Manage daemontools services description: - Controls daemontools services on remote hosts using the svc utility. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/swdepot.py b/plugins/modules/swdepot.py index 17d0157bb5..c4660c70d5 100644 --- a/plugins/modules/swdepot.py +++ b/plugins/modules/swdepot.py @@ -20,6 +20,13 @@ description: - Will install, upgrade and remove packages with swdepot package manager (HP-UX) notes: [] author: "Raul Melo (@melodous)" +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/swupd.py b/plugins/modules/swupd.py index a47dd667ae..efd7ca7c1f 100644 --- a/plugins/modules/swupd.py +++ b/plugins/modules/swupd.py @@ -18,6 +18,13 @@ description: - Manages updates and bundles with the swupd bundle manager, which is used by the Clear Linux Project for Intel Architecture. author: Alberto Murillo (@albertomurillo) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: contenturl: description: diff --git a/plugins/modules/terraform.py b/plugins/modules/terraform.py index 9d1cc2ed02..0247da68cf 100644 --- a/plugins/modules/terraform.py +++ b/plugins/modules/terraform.py @@ -13,8 +13,15 @@ DOCUMENTATION = r''' module: terraform short_description: Manages a Terraform deployment (and plans) description: - - Provides support for deploying resources with Terraform and pulling - resource information back into Ansible. + - Provides support for deploying resources with Terraform and pulling + resource information back into Ansible. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: choices: ['planned', 'present', 'absent'] diff --git a/plugins/modules/uptimerobot.py b/plugins/modules/uptimerobot.py index 527e59ac1f..c1894e90a0 100644 --- a/plugins/modules/uptimerobot.py +++ b/plugins/modules/uptimerobot.py @@ -17,6 +17,13 @@ description: author: "Nate Kingsley (@nate-kingsley)" requirements: - Valid Uptime Robot API Key +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: state: type: str diff --git a/plugins/modules/urpmi.py b/plugins/modules/urpmi.py index 7b1db9c415..34e099e4d5 100644 --- a/plugins/modules/urpmi.py +++ b/plugins/modules/urpmi.py @@ -17,6 +17,13 @@ module: urpmi short_description: Urpmi manager description: - Manages packages with I(urpmi) (such as for Mageia or Mandriva) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/vmadm.py b/plugins/modules/vmadm.py index d6110726f4..56ade17e49 100644 --- a/plugins/modules/vmadm.py +++ b/plugins/modules/vmadm.py @@ -16,6 +16,13 @@ short_description: Manage SmartOS virtual machines and zones description: - Manage SmartOS virtual machines through vmadm(1M). author: Jasper Lievisse Adriaanse (@jasperla) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: archive_on_delete: required: false From 867aee606e42ad52e8ea653d890397b033c8bf7d Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Mon, 20 Feb 2023 17:49:31 +0100 Subject: [PATCH 0176/1810] Check mode has only been added for some _info and _facts modules in a bugfix (#5969) Check mode has only been added for some _info and _facts modules in a bugfix. --- plugins/modules/ali_instance_info.py | 5 +++++ plugins/modules/idrac_redfish_info.py | 4 ++++ plugins/modules/memset_memstore_info.py | 4 ++++ plugins/modules/memset_server_info.py | 4 ++++ plugins/modules/oneview_datacenter_info.py | 4 ++++ plugins/modules/oneview_enclosure_info.py | 4 ++++ plugins/modules/oneview_ethernet_network_info.py | 4 ++++ plugins/modules/oneview_fc_network_info.py | 4 ++++ plugins/modules/oneview_fcoe_network_info.py | 4 ++++ plugins/modules/oneview_logical_interconnect_group_info.py | 4 ++++ plugins/modules/oneview_network_set_info.py | 4 ++++ plugins/modules/oneview_san_manager_info.py | 4 ++++ plugins/modules/rax_facts.py | 4 ++++ plugins/modules/redfish_info.py | 4 ++++ plugins/modules/smartos_image_info.py | 4 ++++ plugins/modules/snmp_facts.py | 4 ++++ plugins/modules/utm_aaa_group_info.py | 4 ++++ plugins/modules/utm_ca_host_key_cert_info.py | 4 ++++ plugins/modules/utm_network_interface_address_info.py | 4 ++++ plugins/modules/utm_proxy_frontend_info.py | 4 ++++ plugins/modules/utm_proxy_location_info.py | 4 ++++ plugins/modules/xenserver_facts.py | 4 ++++ plugins/modules/xfconf_info.py | 4 ++++ 23 files changed, 93 insertions(+) diff --git a/plugins/modules/ali_instance_info.py b/plugins/modules/ali_instance_info.py index f489f96372..e7ec7f3956 100644 --- a/plugins/modules/ali_instance_info.py +++ b/plugins/modules/ali_instance_info.py @@ -33,6 +33,11 @@ description: The module must be called from within the ECS instance itself. - This module was called C(ali_instance_facts) before Ansible 2.9. The usage did not change. +attributes: + check_mode: + version_added: 3.3.0 + # This was backported to 2.5.4 and 1.3.11 as well, since this was a bugfix + options: name_prefix: description: diff --git a/plugins/modules/idrac_redfish_info.py b/plugins/modules/idrac_redfish_info.py index cb44a75961..aece616641 100644 --- a/plugins/modules/idrac_redfish_info.py +++ b/plugins/modules/idrac_redfish_info.py @@ -21,6 +21,10 @@ description: extends_documentation_fragment: - community.general.attributes - community.general.attributes.info_module +attributes: + check_mode: + version_added: 3.3.0 + # This was backported to 2.5.4 and 1.3.11 as well, since this was a bugfix options: category: required: true diff --git a/plugins/modules/memset_memstore_info.py b/plugins/modules/memset_memstore_info.py index 8ce3d5b05a..4ee7cfc2a5 100644 --- a/plugins/modules/memset_memstore_info.py +++ b/plugins/modules/memset_memstore_info.py @@ -22,6 +22,10 @@ description: extends_documentation_fragment: - community.general.attributes - community.general.attributes.info_module +attributes: + check_mode: + version_added: 3.3.0 + # This was backported to 2.5.4 and 1.3.11 as well, since this was a bugfix options: api_key: required: true diff --git a/plugins/modules/memset_server_info.py b/plugins/modules/memset_server_info.py index 0c78f2bd1d..9023c0f8f0 100644 --- a/plugins/modules/memset_server_info.py +++ b/plugins/modules/memset_server_info.py @@ -22,6 +22,10 @@ description: extends_documentation_fragment: - community.general.attributes - community.general.attributes.info_module +attributes: + check_mode: + version_added: 3.3.0 + # This was backported to 2.5.4 and 1.3.11 as well, since this was a bugfix options: api_key: required: true diff --git a/plugins/modules/oneview_datacenter_info.py b/plugins/modules/oneview_datacenter_info.py index 76e752f399..541f3d6694 100644 --- a/plugins/modules/oneview_datacenter_info.py +++ b/plugins/modules/oneview_datacenter_info.py @@ -22,6 +22,10 @@ author: - Madhav Bharadwaj (@madhav-bharadwaj) - Priyanka Sood (@soodpr) - Ricardo Galeno (@ricardogpsf) +attributes: + check_mode: + version_added: 3.3.0 + # This was backported to 2.5.4 and 1.3.11 as well, since this was a bugfix options: name: description: diff --git a/plugins/modules/oneview_enclosure_info.py b/plugins/modules/oneview_enclosure_info.py index dfef893542..3e593b7ae8 100644 --- a/plugins/modules/oneview_enclosure_info.py +++ b/plugins/modules/oneview_enclosure_info.py @@ -22,6 +22,10 @@ author: - Felipe Bulsoni (@fgbulsoni) - Thiago Miotto (@tmiotto) - Adriane Cardozo (@adriane-cardozo) +attributes: + check_mode: + version_added: 3.3.0 + # This was backported to 2.5.4 and 1.3.11 as well, since this was a bugfix options: name: description: diff --git a/plugins/modules/oneview_ethernet_network_info.py b/plugins/modules/oneview_ethernet_network_info.py index cb58575a3b..e107f3b479 100644 --- a/plugins/modules/oneview_ethernet_network_info.py +++ b/plugins/modules/oneview_ethernet_network_info.py @@ -21,6 +21,10 @@ author: - Felipe Bulsoni (@fgbulsoni) - Thiago Miotto (@tmiotto) - Adriane Cardozo (@adriane-cardozo) +attributes: + check_mode: + version_added: 3.3.0 + # This was backported to 2.5.4 and 1.3.11 as well, since this was a bugfix options: name: description: diff --git a/plugins/modules/oneview_fc_network_info.py b/plugins/modules/oneview_fc_network_info.py index 6927ba438c..d4044b08b7 100644 --- a/plugins/modules/oneview_fc_network_info.py +++ b/plugins/modules/oneview_fc_network_info.py @@ -21,6 +21,10 @@ author: - Felipe Bulsoni (@fgbulsoni) - Thiago Miotto (@tmiotto) - Adriane Cardozo (@adriane-cardozo) +attributes: + check_mode: + version_added: 3.3.0 + # This was backported to 2.5.4 and 1.3.11 as well, since this was a bugfix options: name: description: diff --git a/plugins/modules/oneview_fcoe_network_info.py b/plugins/modules/oneview_fcoe_network_info.py index 52bcb12c89..d9ee1b3798 100644 --- a/plugins/modules/oneview_fcoe_network_info.py +++ b/plugins/modules/oneview_fcoe_network_info.py @@ -21,6 +21,10 @@ author: - Felipe Bulsoni (@fgbulsoni) - Thiago Miotto (@tmiotto) - Adriane Cardozo (@adriane-cardozo) +attributes: + check_mode: + version_added: 3.3.0 + # This was backported to 2.5.4 and 1.3.11 as well, since this was a bugfix options: name: description: diff --git a/plugins/modules/oneview_logical_interconnect_group_info.py b/plugins/modules/oneview_logical_interconnect_group_info.py index 8d355cdaa0..0111bf2c11 100644 --- a/plugins/modules/oneview_logical_interconnect_group_info.py +++ b/plugins/modules/oneview_logical_interconnect_group_info.py @@ -22,6 +22,10 @@ author: - Felipe Bulsoni (@fgbulsoni) - Thiago Miotto (@tmiotto) - Adriane Cardozo (@adriane-cardozo) +attributes: + check_mode: + version_added: 3.3.0 + # This was backported to 2.5.4 and 1.3.11 as well, since this was a bugfix options: name: description: diff --git a/plugins/modules/oneview_network_set_info.py b/plugins/modules/oneview_network_set_info.py index 1c793dbfb5..d1a1f2913f 100644 --- a/plugins/modules/oneview_network_set_info.py +++ b/plugins/modules/oneview_network_set_info.py @@ -21,6 +21,10 @@ author: - Felipe Bulsoni (@fgbulsoni) - Thiago Miotto (@tmiotto) - Adriane Cardozo (@adriane-cardozo) +attributes: + check_mode: + version_added: 3.3.0 + # This was backported to 2.5.4 and 1.3.11 as well, since this was a bugfix options: name: description: diff --git a/plugins/modules/oneview_san_manager_info.py b/plugins/modules/oneview_san_manager_info.py index 87b3c0534f..9b00a6bb5d 100644 --- a/plugins/modules/oneview_san_manager_info.py +++ b/plugins/modules/oneview_san_manager_info.py @@ -21,6 +21,10 @@ author: - Felipe Bulsoni (@fgbulsoni) - Thiago Miotto (@tmiotto) - Adriane Cardozo (@adriane-cardozo) +attributes: + check_mode: + version_added: 3.3.0 + # This was backported to 2.5.4 and 1.3.11 as well, since this was a bugfix options: provider_display_name: description: diff --git a/plugins/modules/rax_facts.py b/plugins/modules/rax_facts.py index 53657f3c9a..f8bb0e0506 100644 --- a/plugins/modules/rax_facts.py +++ b/plugins/modules/rax_facts.py @@ -14,6 +14,10 @@ module: rax_facts short_description: Gather facts for Rackspace Cloud Servers description: - Gather facts for Rackspace Cloud Servers. +attributes: + check_mode: + version_added: 3.3.0 + # This was backported to 2.5.4 and 1.3.11 as well, since this was a bugfix options: address: type: str diff --git a/plugins/modules/redfish_info.py b/plugins/modules/redfish_info.py index e6df4813ad..32e8766481 100644 --- a/plugins/modules/redfish_info.py +++ b/plugins/modules/redfish_info.py @@ -21,6 +21,10 @@ description: extends_documentation_fragment: - community.general.attributes - community.general.attributes.info_module +attributes: + check_mode: + version_added: 3.3.0 + # This was backported to 2.5.4 and 1.3.11 as well, since this was a bugfix options: category: required: false diff --git a/plugins/modules/smartos_image_info.py b/plugins/modules/smartos_image_info.py index 37267d115a..e93ffb9ac1 100644 --- a/plugins/modules/smartos_image_info.py +++ b/plugins/modules/smartos_image_info.py @@ -21,6 +21,10 @@ author: Adam Števko (@xen0l) extends_documentation_fragment: - community.general.attributes - community.general.attributes.info_module +attributes: + check_mode: + version_added: 3.3.0 + # This was backported to 2.5.4 and 1.3.11 as well, since this was a bugfix options: filters: description: diff --git a/plugins/modules/snmp_facts.py b/plugins/modules/snmp_facts.py index 0242bc6dde..e54473ffaf 100644 --- a/plugins/modules/snmp_facts.py +++ b/plugins/modules/snmp_facts.py @@ -24,6 +24,10 @@ extends_documentation_fragment: - community.general.attributes - community.general.attributes.facts - community.general.attributes.facts_module +attributes: + check_mode: + version_added: 3.3.0 + # This was backported to 2.5.4 and 1.3.11 as well, since this was a bugfix options: host: description: diff --git a/plugins/modules/utm_aaa_group_info.py b/plugins/modules/utm_aaa_group_info.py index 8798fda7f3..37e01c736c 100644 --- a/plugins/modules/utm_aaa_group_info.py +++ b/plugins/modules/utm_aaa_group_info.py @@ -22,6 +22,10 @@ short_description: Get info for reverse_proxy frontend entry in Sophos UTM description: - get info for a reverse_proxy frontend entry in SOPHOS UTM. +attributes: + check_mode: + version_added: 3.3.0 + # This was backported to 2.5.4 and 1.3.11 as well, since this was a bugfix options: name: diff --git a/plugins/modules/utm_ca_host_key_cert_info.py b/plugins/modules/utm_ca_host_key_cert_info.py index e5de74cd4c..d81eede69f 100644 --- a/plugins/modules/utm_ca_host_key_cert_info.py +++ b/plugins/modules/utm_ca_host_key_cert_info.py @@ -21,6 +21,10 @@ short_description: Get info for a ca host_key_cert entry in Sophos UTM description: - Get info for a ca host_key_cert entry in SOPHOS UTM. +attributes: + check_mode: + version_added: 3.3.0 + # This was backported to 2.5.4 and 1.3.11 as well, since this was a bugfix options: name: diff --git a/plugins/modules/utm_network_interface_address_info.py b/plugins/modules/utm_network_interface_address_info.py index 736ea501ef..9dc08ad094 100644 --- a/plugins/modules/utm_network_interface_address_info.py +++ b/plugins/modules/utm_network_interface_address_info.py @@ -20,6 +20,10 @@ short_description: Get info for a network/interface_address object description: - Get info for a network/interface_address object in SOPHOS UTM. +attributes: + check_mode: + version_added: 3.3.0 + # This was backported to 2.5.4 and 1.3.11 as well, since this was a bugfix options: name: diff --git a/plugins/modules/utm_proxy_frontend_info.py b/plugins/modules/utm_proxy_frontend_info.py index 65faecfbc8..0435ef9494 100644 --- a/plugins/modules/utm_proxy_frontend_info.py +++ b/plugins/modules/utm_proxy_frontend_info.py @@ -22,6 +22,10 @@ description: - Create, update or destroy a reverse_proxy frontend entry in SOPHOS UTM. - This module needs to have the REST Ability of the UTM to be activated. +attributes: + check_mode: + version_added: 3.3.0 + # This was backported to 2.5.4 and 1.3.11 as well, since this was a bugfix options: name: diff --git a/plugins/modules/utm_proxy_location_info.py b/plugins/modules/utm_proxy_location_info.py index 4b502df296..58a32107bd 100644 --- a/plugins/modules/utm_proxy_location_info.py +++ b/plugins/modules/utm_proxy_location_info.py @@ -22,6 +22,10 @@ description: - Create, update or destroy a reverse_proxy location entry in SOPHOS UTM. - This module needs to have the REST Ability of the UTM to be activated. +attributes: + check_mode: + version_added: 3.3.0 + # This was backported to 2.5.4 and 1.3.11 as well, since this was a bugfix options: name: diff --git a/plugins/modules/xenserver_facts.py b/plugins/modules/xenserver_facts.py index 59c457c7f7..9924c4a9e8 100644 --- a/plugins/modules/xenserver_facts.py +++ b/plugins/modules/xenserver_facts.py @@ -23,6 +23,10 @@ extends_documentation_fragment: - community.general.attributes - community.general.attributes.facts - community.general.attributes.facts_module +attributes: + check_mode: + version_added: 3.3.0 + # This was backported to 2.5.4 and 1.3.11 as well, since this was a bugfix options: {} ''' diff --git a/plugins/modules/xfconf_info.py b/plugins/modules/xfconf_info.py index 149325ebac..0a99201ef9 100644 --- a/plugins/modules/xfconf_info.py +++ b/plugins/modules/xfconf_info.py @@ -18,6 +18,10 @@ description: extends_documentation_fragment: - community.general.attributes - community.general.attributes.info_module +attributes: + check_mode: + version_added: 3.3.0 + # This was backported to 2.5.4 and 1.3.11 as well, since this was a bugfix options: channel: description: From 7e3c73ceb274ab8c0682a302423781e6b2cbb4de Mon Sep 17 00:00:00 2001 From: Prawn Date: Wed, 22 Feb 2023 14:41:46 +0100 Subject: [PATCH 0177/1810] `lxd_container`: add check- and diff-mode support (#5866) * lxd_container module: Automate CONFIG_PARAM handling. Signed-off-by: InsanePrawn * lxd_container: check- and diff mode Signed-off-by: InsanePrawn * Make JSON lookups safer and fix crashes in check mode when instance is absent * lxd_profile: fix docstring typos * lxd_container: simplify _needs_to_change_instance_config() * lxd_container: add docstring for check- and diff-mode and changelog fragment * style fixes * lxd_container: fix typo in actions: "unfreez" lacks an "e" --------- Signed-off-by: InsanePrawn --- ...5866-lxd_container-diff-and-check-mode.yml | 2 + plugins/modules/lxd_container.py | 145 ++++++++++-------- plugins/modules/lxd_profile.py | 4 +- 3 files changed, 87 insertions(+), 64 deletions(-) create mode 100644 changelogs/fragments/5866-lxd_container-diff-and-check-mode.yml diff --git a/changelogs/fragments/5866-lxd_container-diff-and-check-mode.yml b/changelogs/fragments/5866-lxd_container-diff-and-check-mode.yml new file mode 100644 index 0000000000..eb337cd42a --- /dev/null +++ b/changelogs/fragments/5866-lxd_container-diff-and-check-mode.yml @@ -0,0 +1,2 @@ +minor_changes: + - lxd_container - add diff and check mode (https://github.com/ansible-collections/community.general/pull/5866). diff --git a/plugins/modules/lxd_container.py b/plugins/modules/lxd_container.py index 30dc855617..00649a076f 100644 --- a/plugins/modules/lxd_container.py +++ b/plugins/modules/lxd_container.py @@ -16,6 +16,15 @@ short_description: Manage LXD instances description: - Management of LXD containers and virtual machines. author: "Hiroaki Nakamura (@hnakamur)" +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + version_added: 6.4.0 + diff_mode: + support: full + version_added: 6.4.0 options: name: description: @@ -396,6 +405,7 @@ actions: type: list sample: ["create", "start"] ''' +import copy import datetime import os import time @@ -411,7 +421,7 @@ LXD_ANSIBLE_STATES = { 'stopped': '_stopped', 'restarted': '_restarted', 'absent': '_destroyed', - 'frozen': '_frozen' + 'frozen': '_frozen', } # ANSIBLE_LXD_STATES is a map of states of lxd containers to the Ansible @@ -430,6 +440,10 @@ CONFIG_PARAMS = [ 'architecture', 'config', 'devices', 'ephemeral', 'profiles', 'source' ] +# CONFIG_CREATION_PARAMS is a list of attribute names that are only applied +# on instance creation. +CONFIG_CREATION_PARAMS = ['source'] + class LXDContainerManagement(object): def __init__(self, module): @@ -488,6 +502,9 @@ class LXDContainerManagement(object): self.module.fail_json(msg=e.msg) self.trust_password = self.module.params.get('trust_password', None) self.actions = [] + self.diff = {'before': {}, 'after': {}} + self.old_instance_json = {} + self.old_sections = {} def _build_config(self): self.config = {} @@ -521,7 +538,8 @@ class LXDContainerManagement(object): body_json = {'action': action, 'timeout': self.timeout} if force_stop: body_json['force'] = True - return self.client.do('PUT', url, body_json=body_json) + if not self.module.check_mode: + return self.client.do('PUT', url, body_json=body_json) def _create_instance(self): url = self.api_endpoint @@ -534,7 +552,8 @@ class LXDContainerManagement(object): url = '{0}?{1}'.format(url, urlencode(url_params)) config = self.config.copy() config['name'] = self.name - self.client.do('POST', url, config, wait_for_container=self.wait_for_container) + if not self.module.check_mode: + self.client.do('POST', url, config, wait_for_container=self.wait_for_container) self.actions.append('create') def _start_instance(self): @@ -553,7 +572,8 @@ class LXDContainerManagement(object): url = '{0}/{1}'.format(self.api_endpoint, self.name) if self.project: url = '{0}?{1}'.format(url, urlencode(dict(project=self.project))) - self.client.do('DELETE', url) + if not self.module.check_mode: + self.client.do('DELETE', url) self.actions.append('delete') def _freeze_instance(self): @@ -562,15 +582,13 @@ class LXDContainerManagement(object): def _unfreeze_instance(self): self._change_state('unfreeze') - self.actions.append('unfreez') + self.actions.append('unfreeze') def _instance_ipv4_addresses(self, ignore_devices=None): ignore_devices = ['lo'] if ignore_devices is None else ignore_devices - - resp_json = self._get_instance_state_json() - network = resp_json['metadata']['network'] or {} - network = dict((k, v) for k, v in network.items() if k not in ignore_devices) or {} - addresses = dict((k, [a['address'] for a in v['addresses'] if a['family'] == 'inet']) for k, v in network.items()) or {} + data = (self._get_instance_state_json() or {}).get('metadata', None) or {} + network = dict((k, v) for k, v in (data.get('network', None) or {}).items() if k not in ignore_devices) + addresses = dict((k, [a['address'] for a in v['addresses'] if a['family'] == 'inet']) for k, v in network.items()) return addresses @staticmethod @@ -583,7 +601,7 @@ class LXDContainerManagement(object): while datetime.datetime.now() < due: time.sleep(1) addresses = self._instance_ipv4_addresses() - if self._has_all_ipv4_addresses(addresses): + if self._has_all_ipv4_addresses(addresses) or self.module.check_mode: self.addresses = addresses return except LXDClientException as e: @@ -656,16 +674,10 @@ class LXDContainerManagement(object): def _needs_to_change_instance_config(self, key): if key not in self.config: return False - if key == 'config' and self.ignore_volatile_options: # the old behavior is to ignore configurations by keyword "volatile" - old_configs = dict((k, v) for k, v in self.old_instance_json['metadata'][key].items() if not k.startswith('volatile.')) - for k, v in self.config['config'].items(): - if k not in old_configs: - return True - if old_configs[k] != v: - return True - return False - elif key == 'config': # next default behavior - old_configs = dict((k, v) for k, v in self.old_instance_json['metadata'][key].items()) + + if key == 'config': + # self.old_sections is already filtered for volatile keys if necessary + old_configs = dict(self.old_sections.get(key, None) or {}) for k, v in self.config['config'].items(): if k not in old_configs: return True @@ -673,43 +685,35 @@ class LXDContainerManagement(object): return True return False else: - old_configs = self.old_instance_json['metadata'][key] + old_configs = self.old_sections.get(key, {}) return self.config[key] != old_configs def _needs_to_apply_instance_configs(self): - return ( - self._needs_to_change_instance_config('architecture') or - self._needs_to_change_instance_config('config') or - self._needs_to_change_instance_config('ephemeral') or - self._needs_to_change_instance_config('devices') or - self._needs_to_change_instance_config('profiles') - ) + for param in set(CONFIG_PARAMS) - set(CONFIG_CREATION_PARAMS): + if self._needs_to_change_instance_config(param): + return True + return False def _apply_instance_configs(self): - old_metadata = self.old_instance_json['metadata'] - body_json = { - 'architecture': old_metadata['architecture'], - 'config': old_metadata['config'], - 'devices': old_metadata['devices'], - 'profiles': old_metadata['profiles'] - } - - if self._needs_to_change_instance_config('architecture'): - body_json['architecture'] = self.config['architecture'] - if self._needs_to_change_instance_config('config'): - for k, v in self.config['config'].items(): - body_json['config'][k] = v - if self._needs_to_change_instance_config('ephemeral'): - body_json['ephemeral'] = self.config['ephemeral'] - if self._needs_to_change_instance_config('devices'): - body_json['devices'] = self.config['devices'] - if self._needs_to_change_instance_config('profiles'): - body_json['profiles'] = self.config['profiles'] + old_metadata = copy.deepcopy(self.old_instance_json).get('metadata', None) or {} + body_json = {} + for param in set(CONFIG_PARAMS) - set(CONFIG_CREATION_PARAMS): + if param in old_metadata: + body_json[param] = old_metadata[param] + if self._needs_to_change_instance_config(param): + if param == 'config': + body_json['config'] = body_json.get('config', None) or {} + for k, v in self.config['config'].items(): + body_json['config'][k] = v + else: + body_json[param] = self.config[param] + self.diff['after']['instance'] = body_json url = '{0}/{1}'.format(self.api_endpoint, self.name) if self.project: url = '{0}?{1}'.format(url, urlencode(dict(project=self.project))) - self.client.do('PUT', url, body_json=body_json) + if not self.module.check_mode: + self.client.do('PUT', url, body_json=body_json) self.actions.append('apply_instance_configs') def run(self): @@ -721,7 +725,22 @@ class LXDContainerManagement(object): self.ignore_volatile_options = self.module.params.get('ignore_volatile_options') self.old_instance_json = self._get_instance_json() + self.old_sections = dict( + (section, content) if not isinstance(content, dict) + else (section, dict((k, v) for k, v in content.items() + if not (self.ignore_volatile_options and k.startswith('volatile.')))) + for section, content in (self.old_instance_json.get('metadata', None) or {}).items() + if section in set(CONFIG_PARAMS) - set(CONFIG_CREATION_PARAMS) + ) + + self.diff['before']['instance'] = self.old_sections + # preliminary, will be overwritten in _apply_instance_configs() if called + self.diff['after']['instance'] = self.config + self.old_state = self._instance_json_to_module_state(self.old_instance_json) + self.diff['before']['state'] = self.old_state + self.diff['after']['state'] = self.state + action = getattr(self, LXD_ANSIBLE_STATES[self.state]) action() @@ -730,7 +749,8 @@ class LXDContainerManagement(object): 'log_verbosity': self.module._verbosity, 'changed': state_changed, 'old_state': self.old_state, - 'actions': self.actions + 'actions': self.actions, + 'diff': self.diff, } if self.client.debug: result_json['logs'] = self.client.logs @@ -742,7 +762,8 @@ class LXDContainerManagement(object): fail_params = { 'msg': e.msg, 'changed': state_changed, - 'actions': self.actions + 'actions': self.actions, + 'diff': self.diff, } if self.client.debug: fail_params['logs'] = e.kwargs['logs'] @@ -756,7 +777,7 @@ def main(): argument_spec=dict( name=dict( type='str', - required=True + required=True, ), project=dict( type='str', @@ -786,7 +807,7 @@ def main(): ), state=dict( choices=list(LXD_ANSIBLE_STATES.keys()), - default='started' + default='started', ), target=dict( type='str', @@ -802,35 +823,35 @@ def main(): ), wait_for_container=dict( type='bool', - default=False + default=False, ), wait_for_ipv4_addresses=dict( type='bool', - default=False + default=False, ), force_stop=dict( type='bool', - default=False + default=False, ), url=dict( type='str', - default=ANSIBLE_LXD_DEFAULT_URL + default=ANSIBLE_LXD_DEFAULT_URL, ), snap_url=dict( type='str', - default='unix:/var/snap/lxd/common/lxd/unix.socket' + default='unix:/var/snap/lxd/common/lxd/unix.socket', ), client_key=dict( type='path', - aliases=['key_file'] + aliases=['key_file'], ), client_cert=dict( type='path', - aliases=['cert_file'] + aliases=['cert_file'], ), - trust_password=dict(type='str', no_log=True) + trust_password=dict(type='str', no_log=True), ), - supports_check_mode=False, + supports_check_mode=True, ) lxd_manage = LXDContainerManagement(module=module) diff --git a/plugins/modules/lxd_profile.py b/plugins/modules/lxd_profile.py index 3d1b28b8fc..1410d16e02 100644 --- a/plugins/modules/lxd_profile.py +++ b/plugins/modules/lxd_profile.py @@ -35,7 +35,7 @@ options: type: str config: description: - - 'The config for the container (e.g. {"limits.memory": "4GB"}). + - 'The config for the instance (e.g. {"limits.memory": "4GB"}). See U(https://github.com/lxc/lxd/blob/master/doc/rest-api.md#patch-3)' - If the profile already exists and its "config" value in metadata obtained from @@ -247,7 +247,7 @@ CONFIG_PARAMS = [ class LXDProfileManagement(object): def __init__(self, module): - """Management of LXC containers via Ansible. + """Management of LXC profiles via Ansible. :param module: Processed Ansible Module. :type module: ``object`` From cb7a970f6f3cdd77f867f54a135140399f206467 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Wed, 22 Feb 2023 14:46:01 +0100 Subject: [PATCH 0178/1810] Add attributes for modules with action plugin (#5951) Add attributes for modules with action plugin. --- plugins/modules/iptables_state.py | 13 ++++++++++++- plugins/modules/shutdown.py | 14 +++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/plugins/modules/iptables_state.py b/plugins/modules/iptables_state.py index 17f8d9eb70..d0ea7ad798 100644 --- a/plugins/modules/iptables_state.py +++ b/plugins/modules/iptables_state.py @@ -15,6 +15,9 @@ module: iptables_state short_description: Save iptables state into a file or restore it from a file version_added: '1.1.0' author: quidame (@quidame) +extends_documentation_fragment: + - community.general.attributes + - community.general.attributes.flow description: - C(iptables) is used to set up, maintain, and inspect the tables of IP packet filter rules in the Linux kernel. @@ -36,7 +39,15 @@ notes: still happen if it shall happen, but you will experience a connection timeout instead of more relevant info returned by the module after its failure. - - This module supports I(check_mode). +attributes: + check_mode: + support: full + diff_mode: + support: none + action: + support: full + async: + support: full options: counters: description: diff --git a/plugins/modules/shutdown.py b/plugins/modules/shutdown.py index cc4108c8a7..5d66fad16b 100644 --- a/plugins/modules/shutdown.py +++ b/plugins/modules/shutdown.py @@ -15,8 +15,20 @@ notes: - C(PATH) is ignored on the remote node when searching for the C(shutdown) command. Use I(search_paths) to specify locations to search if the default paths do not work. description: - - Shut downs a machine. + - Shut downs a machine. version_added: "1.1.0" +extends_documentation_fragment: + - community.general.attributes + - community.general.attributes.flow +attributes: + check_mode: + support: full + diff_mode: + support: none + action: + support: full + async: + support: full options: delay: description: From 78297e44b74992c2108b6ffbb9b0b37e0d708c79 Mon Sep 17 00:00:00 2001 From: Claude Dioudonnat Date: Wed, 22 Feb 2023 15:14:33 +0100 Subject: [PATCH 0179/1810] Fix keycloak sanitize_cr (#5934) * Fix keycloak sanitize_cr * Update changelogs/fragments/5934-fix-keycloak-sanitize_cr.yml Co-authored-by: Felix Fontein --------- Co-authored-by: Claude Dioudonnat Co-authored-by: Felix Fontein --- changelogs/fragments/5934-fix-keycloak-sanitize_cr.yml | 2 ++ plugins/modules/keycloak_client.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/5934-fix-keycloak-sanitize_cr.yml diff --git a/changelogs/fragments/5934-fix-keycloak-sanitize_cr.yml b/changelogs/fragments/5934-fix-keycloak-sanitize_cr.yml new file mode 100644 index 0000000000..1c3163023c --- /dev/null +++ b/changelogs/fragments/5934-fix-keycloak-sanitize_cr.yml @@ -0,0 +1,2 @@ +bugfixes: + - "keycloak_client - fix accidental replacement of value for attribute ``saml.signing.private.key`` with ``no_log`` in wrong contexts (https://github.com/ansible-collections/community.general/pull/5934)." \ No newline at end of file diff --git a/plugins/modules/keycloak_client.py b/plugins/modules/keycloak_client.py index 22ba6a810a..51e516221b 100644 --- a/plugins/modules/keycloak_client.py +++ b/plugins/modules/keycloak_client.py @@ -712,6 +712,7 @@ end_state: from ansible_collections.community.general.plugins.module_utils.identity.keycloak.keycloak import KeycloakAPI, camel, \ keycloak_argument_spec, get_token, KeycloakError from ansible.module_utils.basic import AnsibleModule +import copy def normalise_cr(clientrep, remove_ids=False): @@ -750,7 +751,7 @@ def sanitize_cr(clientrep): :param clientrep: the clientrep dict to be sanitized :return: sanitized clientrep dict """ - result = clientrep.copy() + result = copy.deepcopy(clientrep) if 'secret' in result: result['secret'] = 'no_log' if 'attributes' in result: From 5648e0e2aff5ac1c677dc9047c332498d595dc45 Mon Sep 17 00:00:00 2001 From: Glenn Marcy Date: Wed, 22 Feb 2023 09:23:50 -0500 Subject: [PATCH 0180/1810] onepassword: ignore errors from "op account get" (#5942) * ignore errors from "op account get" * add changelog fragment * Update changelogs/fragments/5942-onepassword-ignore-errors-from-op-account-get.yml Co-authored-by: Felix Fontein --------- Co-authored-by: Felix Fontein --- .../5942-onepassword-ignore-errors-from-op-account-get.yml | 2 ++ plugins/lookup/onepassword.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/5942-onepassword-ignore-errors-from-op-account-get.yml diff --git a/changelogs/fragments/5942-onepassword-ignore-errors-from-op-account-get.yml b/changelogs/fragments/5942-onepassword-ignore-errors-from-op-account-get.yml new file mode 100644 index 0000000000..e6b774dd35 --- /dev/null +++ b/changelogs/fragments/5942-onepassword-ignore-errors-from-op-account-get.yml @@ -0,0 +1,2 @@ +bugfixes: +- onepassword lookup plugin - Changed to ignore errors from "op account get" calls. Previously, errors would prevent auto-signin code from executing (https://github.com/ansible-collections/community.general/pull/5942). diff --git a/plugins/lookup/onepassword.py b/plugins/lookup/onepassword.py index 5e9549c2b7..0e78e4b1a0 100644 --- a/plugins/lookup/onepassword.py +++ b/plugins/lookup/onepassword.py @@ -488,7 +488,7 @@ class OnePassCLIv2(OnePassCLIBase): account = "{subdomain}.{domain}".format(subdomain=self.subdomain, domain=self.domain) args.extend(["--account", account]) - rc, out, err = self._run(args) + rc, out, err = self._run(args, ignore_errors=True) return not bool(rc) From e348d28559449adbb69f8008b8d4c8447f471fb1 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Wed, 22 Feb 2023 17:18:58 +0100 Subject: [PATCH 0181/1810] Re-enable Arch Linux tests (#6031) Revert "Disable Arch Linux tests for now (#6013)" This reverts commit 1b2c2af9a87b7cf364529108e95696c4d966058f. --- .azure-pipelines/azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.azure-pipelines/azure-pipelines.yml b/.azure-pipelines/azure-pipelines.yml index ddf43bf9b0..3816369497 100644 --- a/.azure-pipelines/azure-pipelines.yml +++ b/.azure-pipelines/azure-pipelines.yml @@ -401,8 +401,8 @@ stages: targets: - name: Debian Bullseye test: debian-bullseye/3.9 - #- name: ArchLinux - # test: archlinux/3.10 + - name: ArchLinux + test: archlinux/3.10 - name: CentOS Stream 8 test: centos-stream8/3.9 groups: From a7e8e95b506c2b0beac404781080687fc4369ef6 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Wed, 22 Feb 2023 23:01:01 +0100 Subject: [PATCH 0182/1810] onepassword lookup: fix unit tests (#6041) Fix unit tests. --- .../lookup/onepassword/test_onepassword_cli_v2.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/unit/plugins/lookup/onepassword/test_onepassword_cli_v2.py b/tests/unit/plugins/lookup/onepassword/test_onepassword_cli_v2.py index d1a5eac5d3..f9c3e48ab6 100644 --- a/tests/unit/plugins/lookup/onepassword/test_onepassword_cli_v2.py +++ b/tests/unit/plugins/lookup/onepassword/test_onepassword_cli_v2.py @@ -12,19 +12,19 @@ from ansible_collections.community.general.plugins.lookup.onepassword import One @pytest.mark.parametrize( - ("args", "out", "expected_call_args", "expected"), + ("args", "out", "expected_call_args", "expected_call_kwargs", "expected"), ( - ([], "list of accounts", ["account", "get"], True,), - (["acme"], "list of accounts", ["account", "get", "--account", "acme.1password.com"], True,), - ([], "", ["account", "list"], False,), + ([], "list of accounts", ["account", "get"], {"ignore_errors": True}, True,), + (["acme"], "list of accounts", ["account", "get", "--account", "acme.1password.com"], {"ignore_errors": True}, True,), + ([], "", ["account", "list"], {}, False,), ) ) -def test_assert_logged_in(mocker, args, out, expected_call_args, expected): +def test_assert_logged_in(mocker, args, out, expected_call_args, expected_call_kwargs, expected): mocker.patch.object(OnePassCLIv2, "_run", return_value=[0, out, ""]) op_cli = OnePassCLIv2(*args) result = op_cli.assert_logged_in() - op_cli._run.assert_called_with(expected_call_args) + op_cli._run.assert_called_with(expected_call_args, **expected_call_kwargs) assert result == expected From c168f9c3bee5153a6a09e30b2462c85a166f6a90 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Thu, 23 Feb 2023 07:54:38 -0800 Subject: [PATCH 0183/1810] JC: Add plugin parser functionality to JC Filter Plugin (#6043) * Add plugin parser functionality to JC Filter Plugin The parse function was added in jc v1.18.0 which allows plugin parsers to be used. This change will try the new API if available, else fallback to the old API so there is no change in behavior. * remove whitespace from blank line * Add changelog fragment for JC plugin parser support * add .yml extension to file name * Formatting * add period at end --- changelogs/fragments/6043-jc_plugin_parser_support.yml | 2 ++ plugins/filter/jc.py | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/6043-jc_plugin_parser_support.yml diff --git a/changelogs/fragments/6043-jc_plugin_parser_support.yml b/changelogs/fragments/6043-jc_plugin_parser_support.yml new file mode 100644 index 0000000000..3684f32fe4 --- /dev/null +++ b/changelogs/fragments/6043-jc_plugin_parser_support.yml @@ -0,0 +1,2 @@ +minor_changes: + - jc filter plugin - added the ability to use parser plugins (https://github.com/ansible-collections/community.general/pull/6043). diff --git a/plugins/filter/jc.py b/plugins/filter/jc.py index 742d4147a1..3aa8d20a5f 100644 --- a/plugins/filter/jc.py +++ b/plugins/filter/jc.py @@ -138,8 +138,14 @@ def jc_filter(data, parser, quiet=True, raw=False): raise AnsibleError('You need to install "jc" as a Python library on the Ansible controller prior to running jc filter') try: - jc_parser = importlib.import_module('jc.parsers.' + parser) - return jc_parser.parse(data, quiet=quiet, raw=raw) + # new API (jc v1.18.0 and higher) allows use of plugin parsers + if hasattr(jc, 'parse'): + return jc.parse(parser, data, quiet=quiet, raw=raw) + + # old API (jc v1.17.7 and lower) + else: + jc_parser = importlib.import_module('jc.parsers.' + parser) + return jc_parser.parse(data, quiet=quiet, raw=raw) except Exception as e: raise AnsibleFilterError('Error in jc filter plugin: %s' % e) From 490899f87faee52e3f300533f6ae9a2c150103e6 Mon Sep 17 00:00:00 2001 From: Jonathan Kamens Date: Fri, 24 Feb 2023 03:10:41 -0500 Subject: [PATCH 0184/1810] nmcli: two fixes needed to make wifi.wake-on-wlan settings work properly (#5431) * nmcli: Convert current value of wifi.wake-on-wlan before comparing The new value of wifi.wake-on-wlan is specified as an integer, but in the nmcli output it's specified as a hex string followed by a textual description of it. Therefore, to determine properly whether it's being changed we need to pull the hex string out of the current value, convert it into an integer, and finally convert the integer back to a string so that we can compare it to the new specified value. Without this change, whenever wifi.wake-on-wlan is specified in the module arguments the module will think the value is being changed even when it isn't. * nmcli: Handle wifi options correctly when connection type not specified When an nmcli task does not specify the connection type and the module ask nmcli for it, the module needs to convert nmcli's `802-11-wireless` to `wifi`, the term for this connection type used by the module. * nmcli: Correctly detect values changed to the integer 0 If the user specifies a value of 0 (without quotes) in a task, we should interpret that as an actual value, not empty, when comparing the new value to the old one. Otherwise we incorrectly conclude that there was no change. * Changelog fragment for #5431 --- changelogs/fragments/5431-nmcli-wifi.yml | 4 ++++ plugins/modules/nmcli.py | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/5431-nmcli-wifi.yml diff --git a/changelogs/fragments/5431-nmcli-wifi.yml b/changelogs/fragments/5431-nmcli-wifi.yml new file mode 100644 index 0000000000..0f6f4edde5 --- /dev/null +++ b/changelogs/fragments/5431-nmcli-wifi.yml @@ -0,0 +1,4 @@ +bugfixes: + - nmcli - fix failure to handle WIFI settings when connection type not specified (https://github.com/ansible-collections/community.general/pull/5431). + - nmcli - fix improper detection of changes to ``wifi.wake-on-wlan`` (https://github.com/ansible-collections/community.general/pull/5431). + - nmcli - fix change handling of values specified as an integer 0 (https://github.com/ansible-collections/community.general/pull/5431). diff --git a/plugins/modules/nmcli.py b/plugins/modules/nmcli.py index 461bcc58f9..999e06cc12 100644 --- a/plugins/modules/nmcli.py +++ b/plugins/modules/nmcli.py @@ -2107,11 +2107,18 @@ class Nmcli(object): diff_after = dict() for key, value in options.items(): - if not value: + # We can't just do `if not value` because then if there's a value + # of 0 specified as an integer it'll be interpreted as empty when + # it actually isn't. + if value != 0 and not value: continue if key in conn_info: current_value = conn_info[key] + if key == '802-11-wireless.wake-on-wlan' and current_value is not None: + match = re.match('0x([0-9A-Fa-f]+)', current_value) + if match: + current_value = str(int(match.group(1), 16)) if key in ('ipv4.routes', 'ipv6.routes') and current_value is not None: current_value = self.get_route_params(current_value) if key == self.mac_setting: @@ -2167,6 +2174,8 @@ class Nmcli(object): if not self.type: current_con_type = self.show_connection().get('connection.type') if current_con_type: + if current_con_type == '802-11-wireless': + current_con_type = 'wifi' self.type = current_con_type options.update(self.connection_options(detect_change=True)) From 6bd131f2fbd6da7ee1226b4e048613c63d6fd2ef Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Fri, 24 Feb 2023 09:21:43 +0100 Subject: [PATCH 0185/1810] Add attributes to oneandone, ovh, and rackspace modules (#5948) Add attributes to oneandone, ovh, and rackspace modules. --- plugins/modules/oneandone_firewall_policy.py | 11 +++++++++-- plugins/modules/oneandone_load_balancer.py | 11 +++++++++-- plugins/modules/oneandone_monitoring_policy.py | 13 ++++++++++--- plugins/modules/oneandone_private_network.py | 11 +++++++++-- plugins/modules/oneandone_public_ip.py | 11 +++++++++-- plugins/modules/oneandone_server.py | 11 +++++++++-- plugins/modules/ovh_ip_failover.py | 7 +++++++ plugins/modules/ovh_ip_loadbalancing_backend.py | 7 +++++++ plugins/modules/ovh_monthly_billing.py | 7 +++++++ plugins/modules/rax.py | 8 +++++++- plugins/modules/rax_cbs.py | 8 +++++++- plugins/modules/rax_cbs_attachments.py | 8 +++++++- plugins/modules/rax_cdb.py | 10 ++++++++-- plugins/modules/rax_cdb_database.py | 10 ++++++++-- plugins/modules/rax_cdb_user.py | 10 ++++++++-- plugins/modules/rax_clb.py | 10 ++++++++-- plugins/modules/rax_clb_nodes.py | 10 ++++++++-- plugins/modules/rax_clb_ssl.py | 10 ++++++++-- plugins/modules/rax_dns.py | 10 ++++++++-- plugins/modules/rax_dns_record.py | 10 ++++++++-- plugins/modules/rax_files.py | 10 ++++++++-- plugins/modules/rax_files_objects.py | 10 ++++++++-- plugins/modules/rax_identity.py | 8 +++++++- plugins/modules/rax_keypair.py | 8 +++++++- plugins/modules/rax_meta.py | 8 +++++++- plugins/modules/rax_mon_alarm.py | 8 +++++++- plugins/modules/rax_mon_check.py | 8 +++++++- plugins/modules/rax_mon_entity.py | 8 +++++++- plugins/modules/rax_mon_notification.py | 8 +++++++- plugins/modules/rax_mon_notification_plan.py | 8 +++++++- plugins/modules/rax_network.py | 8 +++++++- plugins/modules/rax_queue.py | 10 ++++++++-- plugins/modules/rax_scaling_group.py | 10 ++++++++-- plugins/modules/rax_scaling_policy.py | 10 ++++++++-- 34 files changed, 264 insertions(+), 51 deletions(-) diff --git a/plugins/modules/oneandone_firewall_policy.py b/plugins/modules/oneandone_firewall_policy.py index 5cceffa812..37dca74f28 100644 --- a/plugins/modules/oneandone_firewall_policy.py +++ b/plugins/modules/oneandone_firewall_policy.py @@ -12,8 +12,15 @@ DOCUMENTATION = ''' module: oneandone_firewall_policy short_description: Configure 1&1 firewall policy description: - - Create, remove, reconfigure, update firewall policies. - This module has a dependency on 1and1 >= 1.0 + - Create, remove, reconfigure, update firewall policies. + This module has a dependency on 1and1 >= 1.0. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: description: diff --git a/plugins/modules/oneandone_load_balancer.py b/plugins/modules/oneandone_load_balancer.py index 432fc456b1..7f7af9c4fc 100644 --- a/plugins/modules/oneandone_load_balancer.py +++ b/plugins/modules/oneandone_load_balancer.py @@ -12,8 +12,15 @@ DOCUMENTATION = ''' module: oneandone_load_balancer short_description: Configure 1&1 load balancer description: - - Create, remove, update load balancers. - This module has a dependency on 1and1 >= 1.0 + - Create, remove, update load balancers. + This module has a dependency on 1and1 >= 1.0. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: description: diff --git a/plugins/modules/oneandone_monitoring_policy.py b/plugins/modules/oneandone_monitoring_policy.py index 04e9c67570..6118645bfe 100644 --- a/plugins/modules/oneandone_monitoring_policy.py +++ b/plugins/modules/oneandone_monitoring_policy.py @@ -12,9 +12,16 @@ DOCUMENTATION = ''' module: oneandone_monitoring_policy short_description: Configure 1&1 monitoring policy description: - - Create, remove, update monitoring policies - (and add/remove ports, processes, and servers). - This module has a dependency on 1and1 >= 1.0 + - Create, remove, update monitoring policies + (and add/remove ports, processes, and servers). + This module has a dependency on 1and1 >= 1.0. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: description: diff --git a/plugins/modules/oneandone_private_network.py b/plugins/modules/oneandone_private_network.py index 4a912a0f35..114bf2f223 100644 --- a/plugins/modules/oneandone_private_network.py +++ b/plugins/modules/oneandone_private_network.py @@ -12,8 +12,15 @@ DOCUMENTATION = ''' module: oneandone_private_network short_description: Configure 1&1 private networking description: - - Create, remove, reconfigure, update a private network. - This module has a dependency on 1and1 >= 1.0 + - Create, remove, reconfigure, update a private network. + This module has a dependency on 1and1 >= 1.0. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: description: diff --git a/plugins/modules/oneandone_public_ip.py b/plugins/modules/oneandone_public_ip.py index 31ed082c74..df5476feb1 100644 --- a/plugins/modules/oneandone_public_ip.py +++ b/plugins/modules/oneandone_public_ip.py @@ -12,8 +12,15 @@ DOCUMENTATION = ''' module: oneandone_public_ip short_description: Configure 1&1 public IPs description: - - Create, update, and remove public IPs. - This module has a dependency on 1and1 >= 1.0 + - Create, update, and remove public IPs. + This module has a dependency on 1and1 >= 1.0. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: description: diff --git a/plugins/modules/oneandone_server.py b/plugins/modules/oneandone_server.py index e0f1b0eb03..59f5041785 100644 --- a/plugins/modules/oneandone_server.py +++ b/plugins/modules/oneandone_server.py @@ -12,8 +12,15 @@ DOCUMENTATION = ''' module: oneandone_server short_description: Create, destroy, start, stop, and reboot a 1&1 Host server description: - - Create, destroy, update, start, stop, and reboot a 1&1 Host server. - When the server is created it can optionally wait for it to be 'running' before returning. + - Create, destroy, update, start, stop, and reboot a 1&1 Host server. + When the server is created it can optionally wait for it to be 'running' before returning. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: description: diff --git a/plugins/modules/ovh_ip_failover.py b/plugins/modules/ovh_ip_failover.py index 4a5c8e5346..cd3639a4cd 100644 --- a/plugins/modules/ovh_ip_failover.py +++ b/plugins/modules/ovh_ip_failover.py @@ -23,6 +23,13 @@ notes: key as described into U(https://docs.ovh.com/gb/en/customer/first-steps-with-ovh-api/) requirements: - ovh >= 0.4.8 +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: required: true diff --git a/plugins/modules/ovh_ip_loadbalancing_backend.py b/plugins/modules/ovh_ip_loadbalancing_backend.py index fe1e722507..f70b5804a7 100644 --- a/plugins/modules/ovh_ip_loadbalancing_backend.py +++ b/plugins/modules/ovh_ip_loadbalancing_backend.py @@ -22,6 +22,13 @@ notes: key as described into U(https://docs.ovh.com/gb/en/customer/first-steps-with-ovh-api/) requirements: - ovh > 0.3.5 +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: required: true diff --git a/plugins/modules/ovh_monthly_billing.py b/plugins/modules/ovh_monthly_billing.py index 445041a23b..43d64e6185 100644 --- a/plugins/modules/ovh_monthly_billing.py +++ b/plugins/modules/ovh_monthly_billing.py @@ -18,6 +18,13 @@ short_description: Manage OVH monthly billing description: - Enable monthly billing on OVH cloud intances (be aware OVH does not allow to disable it). requirements: [ "ovh" ] +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: project_id: required: true diff --git a/plugins/modules/rax.py b/plugins/modules/rax.py index fa929f7971..47c0a6d1bb 100644 --- a/plugins/modules/rax.py +++ b/plugins/modules/rax.py @@ -15,6 +15,11 @@ short_description: Create / delete an instance in Rackspace Public Cloud description: - creates / deletes a Rackspace Public Cloud instance and optionally waits for it to be 'running'. +attributes: + check_mode: + support: none + diff_mode: + support: none options: auto_increment: description: @@ -177,7 +182,8 @@ notes: In the case of deletion, the returned data structure will have C(action) set to C(delete), and the oldest servers in the group will be deleted. extends_documentation_fragment: -- community.general.rackspace.openstack + - community.general.rackspace.openstack + - community.general.attributes ''' diff --git a/plugins/modules/rax_cbs.py b/plugins/modules/rax_cbs.py index dd8bcefa35..77e7cebad4 100644 --- a/plugins/modules/rax_cbs.py +++ b/plugins/modules/rax_cbs.py @@ -14,6 +14,11 @@ module: rax_cbs short_description: Manipulate Rackspace Cloud Block Storage Volumes description: - Manipulate Rackspace Cloud Block Storage Volumes +attributes: + check_mode: + support: none + diff_mode: + support: none options: description: type: str @@ -73,7 +78,8 @@ author: - "Christopher H. Laco (@claco)" - "Matt Martz (@sivel)" extends_documentation_fragment: -- community.general.rackspace.openstack + - community.general.rackspace.openstack + - community.general.attributes ''' diff --git a/plugins/modules/rax_cbs_attachments.py b/plugins/modules/rax_cbs_attachments.py index 82a1f30cfb..00b860a90f 100644 --- a/plugins/modules/rax_cbs_attachments.py +++ b/plugins/modules/rax_cbs_attachments.py @@ -14,6 +14,11 @@ module: rax_cbs_attachments short_description: Manipulate Rackspace Cloud Block Storage Volume Attachments description: - Manipulate Rackspace Cloud Block Storage Volume Attachments +attributes: + check_mode: + support: none + diff_mode: + support: none options: device: type: str @@ -52,7 +57,8 @@ author: - "Christopher H. Laco (@claco)" - "Matt Martz (@sivel)" extends_documentation_fragment: -- community.general.rackspace.openstack + - community.general.rackspace.openstack + - community.general.attributes ''' diff --git a/plugins/modules/rax_cdb.py b/plugins/modules/rax_cdb.py index 3fb6194d9d..687b6ff249 100644 --- a/plugins/modules/rax_cdb.py +++ b/plugins/modules/rax_cdb.py @@ -16,6 +16,11 @@ description: - creates / deletes or resize a Rackspace Cloud Databases instance and optionally waits for it to be 'running'. The name option needs to be unique since it's used to identify the instance. +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: type: str @@ -63,8 +68,9 @@ options: default: 300 author: "Simon JAILLET (@jails)" extends_documentation_fragment: -- community.general.rackspace -- community.general.rackspace.openstack + - community.general.rackspace + - community.general.rackspace.openstack + - community.general.attributes ''' diff --git a/plugins/modules/rax_cdb_database.py b/plugins/modules/rax_cdb_database.py index 6e0e8411c2..b0db11814d 100644 --- a/plugins/modules/rax_cdb_database.py +++ b/plugins/modules/rax_cdb_database.py @@ -13,6 +13,11 @@ module: rax_cdb_database short_description: Create / delete a database in the Cloud Databases description: - create / delete a database in the Cloud Databases. +attributes: + check_mode: + support: none + diff_mode: + support: none options: cdb_id: type: str @@ -42,8 +47,9 @@ options: default: present author: "Simon JAILLET (@jails)" extends_documentation_fragment: -- community.general.rackspace -- community.general.rackspace.openstack + - community.general.rackspace + - community.general.rackspace.openstack + - community.general.attributes ''' diff --git a/plugins/modules/rax_cdb_user.py b/plugins/modules/rax_cdb_user.py index 63cb00b608..6ee86c4fe2 100644 --- a/plugins/modules/rax_cdb_user.py +++ b/plugins/modules/rax_cdb_user.py @@ -14,6 +14,11 @@ module: rax_cdb_user short_description: Create / delete a Rackspace Cloud Database description: - create / delete a database in the Cloud Databases. +attributes: + check_mode: + support: none + diff_mode: + support: none options: cdb_id: type: str @@ -51,8 +56,9 @@ options: default: present author: "Simon JAILLET (@jails)" extends_documentation_fragment: -- community.general.rackspace -- community.general.rackspace.openstack + - community.general.rackspace + - community.general.rackspace.openstack + - community.general.attributes ''' diff --git a/plugins/modules/rax_clb.py b/plugins/modules/rax_clb.py index 8355a42921..23c795f395 100644 --- a/plugins/modules/rax_clb.py +++ b/plugins/modules/rax_clb.py @@ -14,6 +14,11 @@ module: rax_clb short_description: Create / delete a load balancer in Rackspace Public Cloud description: - creates / deletes a Rackspace Public Cloud load balancer. +attributes: + check_mode: + support: none + diff_mode: + support: none options: algorithm: type: str @@ -105,8 +110,9 @@ author: - "Christopher H. Laco (@claco)" - "Matt Martz (@sivel)" extends_documentation_fragment: -- community.general.rackspace -- community.general.rackspace.openstack + - community.general.rackspace + - community.general.rackspace.openstack + - community.general.attributes ''' diff --git a/plugins/modules/rax_clb_nodes.py b/plugins/modules/rax_clb_nodes.py index e6d050de46..c076dced74 100644 --- a/plugins/modules/rax_clb_nodes.py +++ b/plugins/modules/rax_clb_nodes.py @@ -14,6 +14,11 @@ module: rax_clb_nodes short_description: Add, modify and remove nodes from a Rackspace Cloud Load Balancer description: - Adds, modifies and removes nodes from a Rackspace Cloud Load Balancer +attributes: + check_mode: + support: none + diff_mode: + support: none options: address: type: str @@ -85,8 +90,9 @@ options: - Virtualenv to execute this module in author: "Lukasz Kawczynski (@neuroid)" extends_documentation_fragment: -- community.general.rackspace -- community.general.rackspace.openstack + - community.general.rackspace + - community.general.rackspace.openstack + - community.general.attributes ''' diff --git a/plugins/modules/rax_clb_ssl.py b/plugins/modules/rax_clb_ssl.py index 85110d3390..b794130cfa 100644 --- a/plugins/modules/rax_clb_ssl.py +++ b/plugins/modules/rax_clb_ssl.py @@ -13,6 +13,11 @@ module: rax_clb_ssl short_description: Manage SSL termination for a Rackspace Cloud Load Balancer description: - Set up, reconfigure, or remove SSL termination for an existing load balancer. +attributes: + check_mode: + support: none + diff_mode: + support: none options: loadbalancer: type: str @@ -75,8 +80,9 @@ options: default: 300 author: Ash Wilson (@smashwilson) extends_documentation_fragment: -- community.general.rackspace -- community.general.rackspace.openstack + - community.general.rackspace + - community.general.rackspace.openstack + - community.general.attributes ''' diff --git a/plugins/modules/rax_dns.py b/plugins/modules/rax_dns.py index a97a4bb175..31782cd882 100644 --- a/plugins/modules/rax_dns.py +++ b/plugins/modules/rax_dns.py @@ -14,6 +14,11 @@ module: rax_dns short_description: Manage domains on Rackspace Cloud DNS description: - Manage domains on Rackspace Cloud DNS +attributes: + check_mode: + support: none + diff_mode: + support: none options: comment: type: str @@ -46,8 +51,9 @@ notes: the Rackspace CloudDNS API" author: "Matt Martz (@sivel)" extends_documentation_fragment: -- community.general.rackspace -- community.general.rackspace.openstack + - community.general.rackspace + - community.general.rackspace.openstack + - community.general.attributes ''' diff --git a/plugins/modules/rax_dns_record.py b/plugins/modules/rax_dns_record.py index e51424dc04..d4a0eeae22 100644 --- a/plugins/modules/rax_dns_record.py +++ b/plugins/modules/rax_dns_record.py @@ -14,6 +14,11 @@ module: rax_dns_record short_description: Manage DNS records on Rackspace Cloud DNS description: - Manage DNS records on Rackspace Cloud DNS +attributes: + check_mode: + support: none + diff_mode: + support: none options: comment: type: str @@ -92,8 +97,9 @@ notes: - C(PTR) record support was added in version 1.7 author: "Matt Martz (@sivel)" extends_documentation_fragment: -- community.general.rackspace -- community.general.rackspace.openstack + - community.general.rackspace + - community.general.rackspace.openstack + - community.general.attributes ''' diff --git a/plugins/modules/rax_files.py b/plugins/modules/rax_files.py index 1c549827cc..a63e107eb4 100644 --- a/plugins/modules/rax_files.py +++ b/plugins/modules/rax_files.py @@ -14,6 +14,11 @@ module: rax_files short_description: Manipulate Rackspace Cloud Files Containers description: - Manipulate Rackspace Cloud Files Containers +attributes: + check_mode: + support: none + diff_mode: + support: none options: clear_meta: description: @@ -75,8 +80,9 @@ options: - Sets an object to be presented as the HTTP index page when accessed by the CDN URL author: "Paul Durivage (@angstwad)" extends_documentation_fragment: -- community.general.rackspace -- community.general.rackspace.openstack + - community.general.rackspace + - community.general.rackspace.openstack + - community.general.attributes ''' diff --git a/plugins/modules/rax_files_objects.py b/plugins/modules/rax_files_objects.py index 82bedffddb..49ac40daf0 100644 --- a/plugins/modules/rax_files_objects.py +++ b/plugins/modules/rax_files_objects.py @@ -14,6 +14,11 @@ module: rax_files_objects short_description: Upload, download, and delete objects in Rackspace Cloud Files description: - Upload, download, and delete objects in Rackspace Cloud Files. +attributes: + check_mode: + support: none + diff_mode: + support: none options: clear_meta: description: @@ -76,8 +81,9 @@ options: default: file author: "Paul Durivage (@angstwad)" extends_documentation_fragment: -- community.general.rackspace -- community.general.rackspace.openstack + - community.general.rackspace + - community.general.rackspace.openstack + - community.general.attributes ''' diff --git a/plugins/modules/rax_identity.py b/plugins/modules/rax_identity.py index 6f7472bcf4..b2eb156273 100644 --- a/plugins/modules/rax_identity.py +++ b/plugins/modules/rax_identity.py @@ -14,6 +14,11 @@ module: rax_identity short_description: Load Rackspace Cloud Identity description: - Verifies Rackspace Cloud credentials and returns identity information +attributes: + check_mode: + support: none + diff_mode: + support: none options: state: type: str @@ -26,7 +31,8 @@ author: - "Christopher H. Laco (@claco)" - "Matt Martz (@sivel)" extends_documentation_fragment: -- community.general.rackspace.openstack + - community.general.rackspace.openstack + - community.general.attributes ''' diff --git a/plugins/modules/rax_keypair.py b/plugins/modules/rax_keypair.py index 6664ac8bd0..d7d7a2cc34 100644 --- a/plugins/modules/rax_keypair.py +++ b/plugins/modules/rax_keypair.py @@ -14,6 +14,11 @@ module: rax_keypair short_description: Create a keypair for use with Rackspace Cloud Servers description: - Create a keypair for use with Rackspace Cloud Servers +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: type: str @@ -38,7 +43,8 @@ notes: keypair you must first delete and then recreate. - The ability to specify a file path for the public key was added in 1.7 extends_documentation_fragment: -- community.general.rackspace.openstack + - community.general.rackspace.openstack + - community.general.attributes ''' diff --git a/plugins/modules/rax_meta.py b/plugins/modules/rax_meta.py index 33acad365c..7b52e906fe 100644 --- a/plugins/modules/rax_meta.py +++ b/plugins/modules/rax_meta.py @@ -14,6 +14,11 @@ module: rax_meta short_description: Manipulate metadata for Rackspace Cloud Servers description: - Manipulate metadata for Rackspace Cloud Servers +attributes: + check_mode: + support: none + diff_mode: + support: none options: address: type: str @@ -35,7 +40,8 @@ options: - A hash of metadata to associate with the instance author: "Matt Martz (@sivel)" extends_documentation_fragment: -- community.general.rackspace.openstack + - community.general.rackspace.openstack + - community.general.attributes ''' diff --git a/plugins/modules/rax_mon_alarm.py b/plugins/modules/rax_mon_alarm.py index d167420341..72b67a91eb 100644 --- a/plugins/modules/rax_mon_alarm.py +++ b/plugins/modules/rax_mon_alarm.py @@ -19,6 +19,11 @@ description: notifications. Rackspace monitoring module flow | rax_mon_entity -> rax_mon_check -> rax_mon_notification -> rax_mon_notification_plan -> *rax_mon_alarm* +attributes: + check_mode: + support: none + diff_mode: + support: none options: state: type: str @@ -71,7 +76,8 @@ options: keys and values between 1 and 255 characters long. author: Ash Wilson (@smashwilson) extends_documentation_fragment: -- community.general.rackspace.openstack + - community.general.rackspace.openstack + - community.general.attributes ''' diff --git a/plugins/modules/rax_mon_check.py b/plugins/modules/rax_mon_check.py index c6259dab47..878ae14e8e 100644 --- a/plugins/modules/rax_mon_check.py +++ b/plugins/modules/rax_mon_check.py @@ -20,6 +20,11 @@ description: monitor. Rackspace monitoring module flow | rax_mon_entity -> *rax_mon_check* -> rax_mon_notification -> rax_mon_notification_plan -> rax_mon_alarm +attributes: + check_mode: + support: none + diff_mode: + support: none options: state: type: str @@ -115,7 +120,8 @@ options: results. Must be less than the period. author: Ash Wilson (@smashwilson) extends_documentation_fragment: -- community.general.rackspace.openstack + - community.general.rackspace.openstack + - community.general.attributes ''' diff --git a/plugins/modules/rax_mon_entity.py b/plugins/modules/rax_mon_entity.py index cc502496dc..fbad9f98fc 100644 --- a/plugins/modules/rax_mon_entity.py +++ b/plugins/modules/rax_mon_entity.py @@ -18,6 +18,11 @@ description: provide a convenient, centralized place to store IP addresses. Rackspace monitoring module flow | *rax_mon_entity* -> rax_mon_check -> rax_mon_notification -> rax_mon_notification_plan -> rax_mon_alarm +attributes: + check_mode: + support: none + diff_mode: + support: none options: label: type: str @@ -53,7 +58,8 @@ options: long. author: Ash Wilson (@smashwilson) extends_documentation_fragment: -- community.general.rackspace.openstack + - community.general.rackspace.openstack + - community.general.attributes ''' diff --git a/plugins/modules/rax_mon_notification.py b/plugins/modules/rax_mon_notification.py index 73bfd1a78f..91d0793593 100644 --- a/plugins/modules/rax_mon_notification.py +++ b/plugins/modules/rax_mon_notification.py @@ -17,6 +17,11 @@ description: channel that can be used to communicate alarms, such as email, webhooks, or PagerDuty. Rackspace monitoring module flow | rax_mon_entity -> rax_mon_check -> *rax_mon_notification* -> rax_mon_notification_plan -> rax_mon_alarm +attributes: + check_mode: + support: none + diff_mode: + support: none options: state: type: str @@ -46,7 +51,8 @@ options: required: true author: Ash Wilson (@smashwilson) extends_documentation_fragment: -- community.general.rackspace.openstack + - community.general.rackspace.openstack + - community.general.attributes ''' diff --git a/plugins/modules/rax_mon_notification_plan.py b/plugins/modules/rax_mon_notification_plan.py index 7800ea0fe9..d64dee7736 100644 --- a/plugins/modules/rax_mon_notification_plan.py +++ b/plugins/modules/rax_mon_notification_plan.py @@ -18,6 +18,11 @@ description: associating existing rax_mon_notifications with severity levels. Rackspace monitoring module flow | rax_mon_entity -> rax_mon_check -> rax_mon_notification -> *rax_mon_notification_plan* -> rax_mon_alarm +attributes: + check_mode: + support: none + diff_mode: + support: none options: state: type: str @@ -52,7 +57,8 @@ options: valid rax_mon_notification ids. author: Ash Wilson (@smashwilson) extends_documentation_fragment: -- community.general.rackspace.openstack + - community.general.rackspace.openstack + - community.general.attributes ''' diff --git a/plugins/modules/rax_network.py b/plugins/modules/rax_network.py index edb7773b72..22f148366e 100644 --- a/plugins/modules/rax_network.py +++ b/plugins/modules/rax_network.py @@ -14,6 +14,11 @@ module: rax_network short_description: Create / delete an isolated network in Rackspace Public Cloud description: - creates / deletes a Rackspace Public Cloud isolated network. +attributes: + check_mode: + support: none + diff_mode: + support: none options: state: type: str @@ -36,7 +41,8 @@ author: - "Christopher H. Laco (@claco)" - "Jesse Keating (@omgjlk)" extends_documentation_fragment: -- community.general.rackspace.openstack + - community.general.rackspace.openstack + - community.general.attributes ''' diff --git a/plugins/modules/rax_queue.py b/plugins/modules/rax_queue.py index e053f3266d..00f730b279 100644 --- a/plugins/modules/rax_queue.py +++ b/plugins/modules/rax_queue.py @@ -14,6 +14,11 @@ module: rax_queue short_description: Create / delete a queue in Rackspace Public Cloud description: - creates / deletes a Rackspace Public Cloud queue. +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: type: str @@ -31,8 +36,9 @@ author: - "Christopher H. Laco (@claco)" - "Matt Martz (@sivel)" extends_documentation_fragment: -- community.general.rackspace -- community.general.rackspace.openstack + - community.general.rackspace + - community.general.rackspace.openstack + - community.general.attributes ''' diff --git a/plugins/modules/rax_scaling_group.py b/plugins/modules/rax_scaling_group.py index ed974ef0f9..677a75b336 100644 --- a/plugins/modules/rax_scaling_group.py +++ b/plugins/modules/rax_scaling_group.py @@ -14,6 +14,11 @@ module: rax_scaling_group short_description: Manipulate Rackspace Cloud Autoscale Groups description: - Manipulate Rackspace Cloud Autoscale Groups +attributes: + check_mode: + support: none + diff_mode: + support: none options: config_drive: description: @@ -122,8 +127,9 @@ options: default: 300 author: "Matt Martz (@sivel)" extends_documentation_fragment: -- community.general.rackspace -- community.general.rackspace.openstack + - community.general.rackspace + - community.general.rackspace.openstack + - community.general.attributes ''' diff --git a/plugins/modules/rax_scaling_policy.py b/plugins/modules/rax_scaling_policy.py index 3596575187..60b48bb2a9 100644 --- a/plugins/modules/rax_scaling_policy.py +++ b/plugins/modules/rax_scaling_policy.py @@ -14,6 +14,11 @@ module: rax_scaling_policy short_description: Manipulate Rackspace Cloud Autoscale Scaling Policy description: - Manipulate Rackspace Cloud Autoscale Scaling Policy +attributes: + check_mode: + support: none + diff_mode: + support: none options: at: type: str @@ -77,8 +82,9 @@ options: default: present author: "Matt Martz (@sivel)" extends_documentation_fragment: -- community.general.rackspace -- community.general.rackspace.openstack + - community.general.rackspace + - community.general.rackspace.openstack + - community.general.attributes ''' From 50d7597ddc243b32ac09f367305f95a213565d80 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Fri, 24 Feb 2023 09:21:52 +0100 Subject: [PATCH 0186/1810] Add attributes to scaleway and profitbricks modules (#5949) Add attributes to scaleway and profitbricks modules. --- plugins/modules/profitbricks.py | 7 +++++++ plugins/modules/profitbricks_datacenter.py | 7 +++++++ plugins/modules/profitbricks_nic.py | 9 ++++++++- plugins/modules/profitbricks_volume.py | 9 ++++++++- plugins/modules/profitbricks_volume_attachments.py | 9 ++++++++- plugins/modules/scaleway_compute.py | 8 +++++++- plugins/modules/scaleway_compute_private_network.py | 8 +++++++- plugins/modules/scaleway_container.py | 6 ++++++ plugins/modules/scaleway_container_info.py | 3 ++- plugins/modules/scaleway_container_namespace.py | 7 +++++++ plugins/modules/scaleway_container_registry.py | 6 ++++++ plugins/modules/scaleway_database_backup.py | 6 ++++++ plugins/modules/scaleway_function.py | 7 +++++++ plugins/modules/scaleway_function_namespace.py | 7 +++++++ plugins/modules/scaleway_ip.py | 8 +++++++- plugins/modules/scaleway_lb.py | 8 +++++++- plugins/modules/scaleway_private_network.py | 8 +++++++- plugins/modules/scaleway_security_group.py | 8 +++++++- plugins/modules/scaleway_security_group_rule.py | 7 +++++++ plugins/modules/scaleway_sshkey.py | 6 ++++++ plugins/modules/scaleway_user_data.py | 6 ++++++ plugins/modules/scaleway_volume.py | 6 ++++++ 22 files changed, 146 insertions(+), 10 deletions(-) diff --git a/plugins/modules/profitbricks.py b/plugins/modules/profitbricks.py index 6b0134cb99..c8bcceb936 100644 --- a/plugins/modules/profitbricks.py +++ b/plugins/modules/profitbricks.py @@ -15,6 +15,13 @@ short_description: Create, destroy, start, stop, and reboot a ProfitBricks virtu description: - Create, destroy, update, start, stop, and reboot a ProfitBricks virtual machine. When the virtual machine is created it can optionally wait for it to be 'running' before returning. This module has a dependency on profitbricks >= 1.0.0 +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: auto_increment: description: diff --git a/plugins/modules/profitbricks_datacenter.py b/plugins/modules/profitbricks_datacenter.py index a11d12bfd9..a096db752d 100644 --- a/plugins/modules/profitbricks_datacenter.py +++ b/plugins/modules/profitbricks_datacenter.py @@ -15,6 +15,13 @@ short_description: Create or destroy a ProfitBricks Virtual Datacenter description: - This is a simple module that supports creating or removing vDCs. A vDC is required before you can create servers. This module has a dependency on profitbricks >= 1.0.0 +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/profitbricks_nic.py b/plugins/modules/profitbricks_nic.py index c6239f5ef5..17a30b052c 100644 --- a/plugins/modules/profitbricks_nic.py +++ b/plugins/modules/profitbricks_nic.py @@ -13,7 +13,14 @@ DOCUMENTATION = ''' module: profitbricks_nic short_description: Create or Remove a NIC description: - - This module allows you to create or restore a volume snapshot. This module has a dependency on profitbricks >= 1.0.0 + - This module allows you to create or restore a volume snapshot. This module has a dependency on profitbricks >= 1.0.0 +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: datacenter: description: diff --git a/plugins/modules/profitbricks_volume.py b/plugins/modules/profitbricks_volume.py index 1d21897715..f9d257b682 100644 --- a/plugins/modules/profitbricks_volume.py +++ b/plugins/modules/profitbricks_volume.py @@ -13,7 +13,14 @@ DOCUMENTATION = ''' module: profitbricks_volume short_description: Create or destroy a volume description: - - Allows you to create or remove a volume from a ProfitBricks datacenter. This module has a dependency on profitbricks >= 1.0.0 + - Allows you to create or remove a volume from a ProfitBricks datacenter. This module has a dependency on profitbricks >= 1.0.0 +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: datacenter: description: diff --git a/plugins/modules/profitbricks_volume_attachments.py b/plugins/modules/profitbricks_volume_attachments.py index 49b418362b..75cd73df3c 100644 --- a/plugins/modules/profitbricks_volume_attachments.py +++ b/plugins/modules/profitbricks_volume_attachments.py @@ -13,7 +13,14 @@ DOCUMENTATION = ''' module: profitbricks_volume_attachments short_description: Attach or detach a volume description: - - Allows you to attach or detach a volume from a ProfitBricks server. This module has a dependency on profitbricks >= 1.0.0 + - Allows you to attach or detach a volume from a ProfitBricks server. This module has a dependency on profitbricks >= 1.0.0 +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: datacenter: description: diff --git a/plugins/modules/scaleway_compute.py b/plugins/modules/scaleway_compute.py index 0da3f0ff24..9bd8218071 100644 --- a/plugins/modules/scaleway_compute.py +++ b/plugins/modules/scaleway_compute.py @@ -21,8 +21,14 @@ author: Remy Leone (@remyleone) description: - "This module manages compute instances on Scaleway." extends_documentation_fragment: -- community.general.scaleway + - community.general.scaleway + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: diff --git a/plugins/modules/scaleway_compute_private_network.py b/plugins/modules/scaleway_compute_private_network.py index 201ec257f7..9a9d9adde8 100644 --- a/plugins/modules/scaleway_compute_private_network.py +++ b/plugins/modules/scaleway_compute_private_network.py @@ -21,8 +21,14 @@ description: - This module add or remove a private network to a compute instance (U(https://developer.scaleway.com)). extends_documentation_fragment: -- community.general.scaleway + - community.general.scaleway + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: diff --git a/plugins/modules/scaleway_container.py b/plugins/modules/scaleway_container.py index 85e746e1f5..19ffae4197 100644 --- a/plugins/modules/scaleway_container.py +++ b/plugins/modules/scaleway_container.py @@ -22,9 +22,15 @@ description: extends_documentation_fragment: - community.general.scaleway - community.general.scaleway_waitable_resource + - community.general.attributes requirements: - passlib[argon2] >= 1.7.4 +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: diff --git a/plugins/modules/scaleway_container_info.py b/plugins/modules/scaleway_container_info.py index 670c63a0bc..20ebece212 100644 --- a/plugins/modules/scaleway_container_info.py +++ b/plugins/modules/scaleway_container_info.py @@ -21,7 +21,8 @@ description: - This module return information about a container on Scaleway account. extends_documentation_fragment: - community.general.scaleway - + - community.general.attributes + - community.general.attributes.info_module options: namespace_id: diff --git a/plugins/modules/scaleway_container_namespace.py b/plugins/modules/scaleway_container_namespace.py index e7bf7c71f1..fb01b86728 100644 --- a/plugins/modules/scaleway_container_namespace.py +++ b/plugins/modules/scaleway_container_namespace.py @@ -22,9 +22,16 @@ description: extends_documentation_fragment: - community.general.scaleway - community.general.scaleway_waitable_resource + - community.general.attributes requirements: - passlib[argon2] >= 1.7.4 +attributes: + check_mode: + support: full + diff_mode: + support: none + options: state: type: str diff --git a/plugins/modules/scaleway_container_registry.py b/plugins/modules/scaleway_container_registry.py index f49b19917a..5eee571ec7 100644 --- a/plugins/modules/scaleway_container_registry.py +++ b/plugins/modules/scaleway_container_registry.py @@ -22,7 +22,13 @@ description: extends_documentation_fragment: - community.general.scaleway - community.general.scaleway_waitable_resource + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: diff --git a/plugins/modules/scaleway_database_backup.py b/plugins/modules/scaleway_database_backup.py index 9daa7921c0..edc9f6cab4 100644 --- a/plugins/modules/scaleway_database_backup.py +++ b/plugins/modules/scaleway_database_backup.py @@ -22,6 +22,12 @@ description: - "This module manages database backups on Scaleway account U(https://developer.scaleway.com)." extends_documentation_fragment: - community.general.scaleway + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: description: diff --git a/plugins/modules/scaleway_function.py b/plugins/modules/scaleway_function.py index 5e7ac2a3d1..3785458660 100644 --- a/plugins/modules/scaleway_function.py +++ b/plugins/modules/scaleway_function.py @@ -22,9 +22,16 @@ description: extends_documentation_fragment: - community.general.scaleway - community.general.scaleway_waitable_resource + - community.general.attributes requirements: - passlib[argon2] >= 1.7.4 +attributes: + check_mode: + support: full + diff_mode: + support: none + options: state: type: str diff --git a/plugins/modules/scaleway_function_namespace.py b/plugins/modules/scaleway_function_namespace.py index 243bb7124c..f6310b35be 100644 --- a/plugins/modules/scaleway_function_namespace.py +++ b/plugins/modules/scaleway_function_namespace.py @@ -22,9 +22,16 @@ description: extends_documentation_fragment: - community.general.scaleway - community.general.scaleway_waitable_resource + - community.general.attributes requirements: - passlib[argon2] >= 1.7.4 +attributes: + check_mode: + support: full + diff_mode: + support: none + options: state: type: str diff --git a/plugins/modules/scaleway_ip.py b/plugins/modules/scaleway_ip.py index a49e9c9f31..cf8e2e6015 100644 --- a/plugins/modules/scaleway_ip.py +++ b/plugins/modules/scaleway_ip.py @@ -20,8 +20,14 @@ description: - This module manages IP on Scaleway account U(https://developer.scaleway.com) extends_documentation_fragment: -- community.general.scaleway + - community.general.scaleway + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: diff --git a/plugins/modules/scaleway_lb.py b/plugins/modules/scaleway_lb.py index 578f4ae894..3e43a8ae2b 100644 --- a/plugins/modules/scaleway_lb.py +++ b/plugins/modules/scaleway_lb.py @@ -21,8 +21,14 @@ author: Remy Leone (@remyleone) description: - "This module manages load-balancers on Scaleway." extends_documentation_fragment: -- community.general.scaleway + - community.general.scaleway + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: diff --git a/plugins/modules/scaleway_private_network.py b/plugins/modules/scaleway_private_network.py index 57cf67ec1f..33fb7381ca 100644 --- a/plugins/modules/scaleway_private_network.py +++ b/plugins/modules/scaleway_private_network.py @@ -20,8 +20,14 @@ author: Pascal MANGIN (@pastral) description: - "This module manages private network on Scaleway account (U(https://developer.scaleway.com))." extends_documentation_fragment: -- community.general.scaleway + - community.general.scaleway + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: diff --git a/plugins/modules/scaleway_security_group.py b/plugins/modules/scaleway_security_group.py index d863156fa3..5523da41ce 100644 --- a/plugins/modules/scaleway_security_group.py +++ b/plugins/modules/scaleway_security_group.py @@ -20,8 +20,14 @@ author: Antoine Barbare (@abarbare) description: - "This module manages Security Group on Scaleway account U(https://developer.scaleway.com)." extends_documentation_fragment: -- community.general.scaleway + - community.general.scaleway + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: diff --git a/plugins/modules/scaleway_security_group_rule.py b/plugins/modules/scaleway_security_group_rule.py index 52e69868cc..136631d03d 100644 --- a/plugins/modules/scaleway_security_group_rule.py +++ b/plugins/modules/scaleway_security_group_rule.py @@ -21,9 +21,16 @@ description: - "This module manages Security Group Rule on Scaleway account U(https://developer.scaleway.com)." extends_documentation_fragment: - community.general.scaleway + - community.general.attributes requirements: - ipaddress +attributes: + check_mode: + support: full + diff_mode: + support: none + options: state: type: str diff --git a/plugins/modules/scaleway_sshkey.py b/plugins/modules/scaleway_sshkey.py index 8bb804165a..a39e57aa39 100644 --- a/plugins/modules/scaleway_sshkey.py +++ b/plugins/modules/scaleway_sshkey.py @@ -22,7 +22,13 @@ description: - "This module manages SSH keys on Scaleway account U(https://developer.scaleway.com)." extends_documentation_fragment: - community.general.scaleway +- community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: diff --git a/plugins/modules/scaleway_user_data.py b/plugins/modules/scaleway_user_data.py index 509ae44cc0..08ff86a55e 100644 --- a/plugins/modules/scaleway_user_data.py +++ b/plugins/modules/scaleway_user_data.py @@ -23,7 +23,13 @@ description: - It can be used to configure cloud-init for instance. extends_documentation_fragment: - community.general.scaleway +- community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: diff --git a/plugins/modules/scaleway_volume.py b/plugins/modules/scaleway_volume.py index e633b4a1a7..2ff09da544 100644 --- a/plugins/modules/scaleway_volume.py +++ b/plugins/modules/scaleway_volume.py @@ -21,7 +21,13 @@ description: - "This module manages volumes on Scaleway account U(https://developer.scaleway.com)." extends_documentation_fragment: - community.general.scaleway +- community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: From cc29b16536662c76d6a35dc28bf47d8c1b950922 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Fri, 24 Feb 2023 09:22:26 +0100 Subject: [PATCH 0187/1810] Add attributes to clc, hwc, and lxd modules (#5952) Add attributes to clc, hwc, and lxd modules. --- plugins/modules/clc_aa_policy.py | 7 ++++++ plugins/modules/clc_alert_policy.py | 7 ++++++ plugins/modules/clc_blueprint_package.py | 7 ++++++ plugins/modules/clc_firewall_policy.py | 7 ++++++ plugins/modules/clc_group.py | 7 ++++++ plugins/modules/clc_loadbalancer.py | 7 ++++++ plugins/modules/clc_modify_server.py | 7 ++++++ plugins/modules/clc_publicip.py | 7 ++++++ plugins/modules/clc_server.py | 7 ++++++ plugins/modules/clc_server_snapshot.py | 7 ++++++ plugins/modules/hwc_ecs_instance.py | 8 ++++++- plugins/modules/hwc_evs_disk.py | 8 ++++++- plugins/modules/hwc_network_vpc.py | 8 ++++++- plugins/modules/hwc_smn_topic.py | 8 ++++++- plugins/modules/hwc_vpc_eip.py | 8 ++++++- plugins/modules/hwc_vpc_peering_connect.py | 8 ++++++- plugins/modules/hwc_vpc_port.py | 8 ++++++- plugins/modules/hwc_vpc_private_ip.py | 14 ++++++++---- plugins/modules/hwc_vpc_route.py | 14 ++++++++---- plugins/modules/hwc_vpc_security_group.py | 22 ++++++++++++------- .../modules/hwc_vpc_security_group_rule.py | 22 ++++++++++++------- plugins/modules/hwc_vpc_subnet.py | 8 ++++++- plugins/modules/lxd_container.py | 12 +++++----- plugins/modules/lxd_profile.py | 7 ++++++ plugins/modules/lxd_project.py | 7 ++++++ 25 files changed, 194 insertions(+), 38 deletions(-) diff --git a/plugins/modules/clc_aa_policy.py b/plugins/modules/clc_aa_policy.py index d1fba2429a..05135bd957 100644 --- a/plugins/modules/clc_aa_policy.py +++ b/plugins/modules/clc_aa_policy.py @@ -14,6 +14,13 @@ module: clc_aa_policy short_description: Create or Delete Anti Affinity Policies at CenturyLink Cloud description: - An Ansible module to Create or Delete Anti Affinity Policies at CenturyLink Cloud. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/clc_alert_policy.py b/plugins/modules/clc_alert_policy.py index 1d733013d2..b77c83e3b7 100644 --- a/plugins/modules/clc_alert_policy.py +++ b/plugins/modules/clc_alert_policy.py @@ -15,6 +15,13 @@ module: clc_alert_policy short_description: Create or Delete Alert Policies at CenturyLink Cloud description: - An Ansible module to Create or Delete Alert Policies at CenturyLink Cloud. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: alias: description: diff --git a/plugins/modules/clc_blueprint_package.py b/plugins/modules/clc_blueprint_package.py index cb23df852b..672e06780f 100644 --- a/plugins/modules/clc_blueprint_package.py +++ b/plugins/modules/clc_blueprint_package.py @@ -14,6 +14,13 @@ module: clc_blueprint_package short_description: Deploys a blue print package on a set of servers in CenturyLink Cloud description: - An Ansible module to deploy blue print package on a set of servers in CenturyLink Cloud. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: server_ids: description: diff --git a/plugins/modules/clc_firewall_policy.py b/plugins/modules/clc_firewall_policy.py index cc77238db9..c832571d33 100644 --- a/plugins/modules/clc_firewall_policy.py +++ b/plugins/modules/clc_firewall_policy.py @@ -14,6 +14,13 @@ module: clc_firewall_policy short_description: Create/delete/update firewall policies description: - Create or delete or update firewall policies on Centurylink Cloud +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: location: description: diff --git a/plugins/modules/clc_group.py b/plugins/modules/clc_group.py index 21e6d93d28..88aef2d63d 100644 --- a/plugins/modules/clc_group.py +++ b/plugins/modules/clc_group.py @@ -15,6 +15,13 @@ module: clc_group short_description: Create/delete Server Groups at Centurylink Cloud description: - Create or delete Server Groups at Centurylink Centurylink Cloud +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/clc_loadbalancer.py b/plugins/modules/clc_loadbalancer.py index ab6d866fb6..675cc1100e 100644 --- a/plugins/modules/clc_loadbalancer.py +++ b/plugins/modules/clc_loadbalancer.py @@ -15,6 +15,13 @@ module: clc_loadbalancer short_description: Create, Delete shared loadbalancers in CenturyLink Cloud description: - An Ansible module to Create, Delete shared loadbalancers in CenturyLink Cloud. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/clc_modify_server.py b/plugins/modules/clc_modify_server.py index 786cdf2ae4..b375d9d47a 100644 --- a/plugins/modules/clc_modify_server.py +++ b/plugins/modules/clc_modify_server.py @@ -14,6 +14,13 @@ module: clc_modify_server short_description: Modify servers in CenturyLink Cloud description: - An Ansible module to modify servers in CenturyLink Cloud. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: server_ids: description: diff --git a/plugins/modules/clc_publicip.py b/plugins/modules/clc_publicip.py index 5111b3cf19..c1bffcea04 100644 --- a/plugins/modules/clc_publicip.py +++ b/plugins/modules/clc_publicip.py @@ -14,6 +14,13 @@ module: clc_publicip short_description: Add and Delete public ips on servers in CenturyLink Cloud description: - An Ansible module to add or delete public ip addresses on an existing server or servers in CenturyLink Cloud. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: protocol: description: diff --git a/plugins/modules/clc_server.py b/plugins/modules/clc_server.py index d8e4f16217..d2d019ff0d 100644 --- a/plugins/modules/clc_server.py +++ b/plugins/modules/clc_server.py @@ -14,6 +14,13 @@ module: clc_server short_description: Create, Delete, Start and Stop servers in CenturyLink Cloud description: - An Ansible module to Create, Delete, Start and Stop servers in CenturyLink Cloud. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: additional_disks: description: diff --git a/plugins/modules/clc_server_snapshot.py b/plugins/modules/clc_server_snapshot.py index 096abfe29b..82b2a99568 100644 --- a/plugins/modules/clc_server_snapshot.py +++ b/plugins/modules/clc_server_snapshot.py @@ -14,6 +14,13 @@ module: clc_server_snapshot short_description: Create, Delete and Restore server snapshots in CenturyLink Cloud description: - An Ansible module to Create, Delete and Restore server snapshots in CenturyLink Cloud. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: server_ids: description: diff --git a/plugins/modules/hwc_ecs_instance.py b/plugins/modules/hwc_ecs_instance.py index 10d913f9b5..434db242f2 100644 --- a/plugins/modules/hwc_ecs_instance.py +++ b/plugins/modules/hwc_ecs_instance.py @@ -22,6 +22,11 @@ version_added: '0.2.0' author: Huawei Inc. (@huaweicloud) requirements: - keystoneauth1 >= 3.6.0 +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: description: @@ -225,7 +230,8 @@ options: type: str required: false extends_documentation_fragment: -- community.general.hwc + - community.general.hwc + - community.general.attributes ''' diff --git a/plugins/modules/hwc_evs_disk.py b/plugins/modules/hwc_evs_disk.py index 7b5a99fb7f..7d445ddd21 100644 --- a/plugins/modules/hwc_evs_disk.py +++ b/plugins/modules/hwc_evs_disk.py @@ -22,6 +22,11 @@ version_added: '0.2.0' author: Huawei Inc. (@huaweicloud) requirements: - keystoneauth1 >= 3.6.0 +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: description: @@ -150,7 +155,8 @@ options: type: str required: false extends_documentation_fragment: -- community.general.hwc + - community.general.hwc + - community.general.attributes ''' diff --git a/plugins/modules/hwc_network_vpc.py b/plugins/modules/hwc_network_vpc.py index 78f5925e0c..357fd55204 100644 --- a/plugins/modules/hwc_network_vpc.py +++ b/plugins/modules/hwc_network_vpc.py @@ -22,6 +22,11 @@ author: Huawei Inc. (@huaweicloud) requirements: - requests >= 2.18.4 - keystoneauth1 >= 3.6.0 +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: description: @@ -61,7 +66,8 @@ options: type: str required: true extends_documentation_fragment: -- community.general.hwc + - community.general.hwc + - community.general.attributes ''' diff --git a/plugins/modules/hwc_smn_topic.py b/plugins/modules/hwc_smn_topic.py index 3752e1f18f..88207d3f93 100644 --- a/plugins/modules/hwc_smn_topic.py +++ b/plugins/modules/hwc_smn_topic.py @@ -22,6 +22,11 @@ author: Huawei Inc. (@huaweicloud) requirements: - requests >= 2.18.4 - keystoneauth1 >= 3.6.0 +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: description: @@ -45,7 +50,8 @@ options: type: str required: true extends_documentation_fragment: -- community.general.hwc + - community.general.hwc + - community.general.attributes ''' diff --git a/plugins/modules/hwc_vpc_eip.py b/plugins/modules/hwc_vpc_eip.py index e14fb0e502..9fc0361b30 100644 --- a/plugins/modules/hwc_vpc_eip.py +++ b/plugins/modules/hwc_vpc_eip.py @@ -22,6 +22,11 @@ version_added: '0.2.0' author: Huawei Inc. (@huaweicloud) requirements: - keystoneauth1 >= 3.6.0 +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: description: @@ -121,7 +126,8 @@ options: type: str required: false extends_documentation_fragment: -- community.general.hwc + - community.general.hwc + - community.general.attributes ''' diff --git a/plugins/modules/hwc_vpc_peering_connect.py b/plugins/modules/hwc_vpc_peering_connect.py index 01c52932ba..2d6832ce5d 100644 --- a/plugins/modules/hwc_vpc_peering_connect.py +++ b/plugins/modules/hwc_vpc_peering_connect.py @@ -23,6 +23,11 @@ version_added: '0.2.0' author: Huawei Inc. (@huaweicloud) requirements: - keystoneauth1 >= 3.6.0 +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: description: @@ -75,7 +80,8 @@ options: type: str required: false extends_documentation_fragment: -- community.general.hwc + - community.general.hwc + - community.general.attributes ''' diff --git a/plugins/modules/hwc_vpc_port.py b/plugins/modules/hwc_vpc_port.py index aac9636f88..2d830493d4 100644 --- a/plugins/modules/hwc_vpc_port.py +++ b/plugins/modules/hwc_vpc_port.py @@ -22,6 +22,11 @@ version_added: '0.2.0' author: Huawei Inc. (@huaweicloud) requirements: - keystoneauth1 >= 3.6.0 +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: description: @@ -105,7 +110,8 @@ options: elements: str required: false extends_documentation_fragment: -- community.general.hwc + - community.general.hwc + - community.general.attributes ''' diff --git a/plugins/modules/hwc_vpc_private_ip.py b/plugins/modules/hwc_vpc_private_ip.py index e05c14f74d..c57ddc6708 100644 --- a/plugins/modules/hwc_vpc_private_ip.py +++ b/plugins/modules/hwc_vpc_private_ip.py @@ -19,13 +19,18 @@ description: - vpc private ip management. short_description: Creates a resource of Vpc/PrivateIP in Huawei Cloud notes: - - If I(id) option is provided, it takes precedence over I(subnet_id), I(ip_address) for private ip selection. - - I(subnet_id), I(ip_address) are used for private ip selection. If more than one private ip with this options exists, execution is aborted. - - No parameter support updating. If one of option is changed, the module will create a new resource. + - If I(id) option is provided, it takes precedence over I(subnet_id), I(ip_address) for private ip selection. + - I(subnet_id), I(ip_address) are used for private ip selection. If more than one private ip with this options exists, execution is aborted. + - No parameter support updating. If one of option is changed, the module will create a new resource. version_added: '0.2.0' author: Huawei Inc. (@huaweicloud) requirements: - keystoneauth1 >= 3.6.0 +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: description: @@ -48,7 +53,8 @@ options: type: str required: false extends_documentation_fragment: -- community.general.hwc + - community.general.hwc + - community.general.attributes ''' diff --git a/plugins/modules/hwc_vpc_route.py b/plugins/modules/hwc_vpc_route.py index e08a9ebf38..1612cac50d 100644 --- a/plugins/modules/hwc_vpc_route.py +++ b/plugins/modules/hwc_vpc_route.py @@ -19,13 +19,18 @@ description: - vpc route management. short_description: Creates a resource of Vpc/Route in Huawei Cloud notes: - - If I(id) option is provided, it takes precedence over I(destination), I(vpc_id), I(type) and I(next_hop) for route selection. - - I(destination), I(vpc_id), I(type) and I(next_hop) are used for route selection. If more than one route with this options exists, execution is aborted. - - No parameter support updating. If one of option is changed, the module will create a new resource. + - If I(id) option is provided, it takes precedence over I(destination), I(vpc_id), I(type) and I(next_hop) for route selection. + - I(destination), I(vpc_id), I(type) and I(next_hop) are used for route selection. If more than one route with this options exists, execution is aborted. + - No parameter support updating. If one of option is changed, the module will create a new resource. version_added: '0.2.0' author: Huawei Inc. (@huaweicloud) requirements: - keystoneauth1 >= 3.6.0 +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: description: @@ -55,7 +60,8 @@ options: required: false default: 'peering' extends_documentation_fragment: -- community.general.hwc + - community.general.hwc + - community.general.attributes ''' diff --git a/plugins/modules/hwc_vpc_security_group.py b/plugins/modules/hwc_vpc_security_group.py index 2338623890..c210b912d4 100644 --- a/plugins/modules/hwc_vpc_security_group.py +++ b/plugins/modules/hwc_vpc_security_group.py @@ -19,17 +19,22 @@ description: - vpc security group management. short_description: Creates a resource of Vpc/SecurityGroup in Huawei Cloud notes: - - If I(id) option is provided, it takes precedence over I(name), - I(enterprise_project_id) and I(vpc_id) for security group selection. - - I(name), I(enterprise_project_id) and I(vpc_id) are used for security - group selection. If more than one security group with this options exists, - execution is aborted. - - No parameter support updating. If one of option is changed, the module - will create a new resource. + - If I(id) option is provided, it takes precedence over I(name), + I(enterprise_project_id) and I(vpc_id) for security group selection. + - I(name), I(enterprise_project_id) and I(vpc_id) are used for security + group selection. If more than one security group with this options exists, + execution is aborted. + - No parameter support updating. If one of option is changed, the module + will create a new resource. version_added: '0.2.0' author: Huawei Inc. (@huaweicloud) requirements: - keystoneauth1 >= 3.6.0 +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: description: @@ -58,7 +63,8 @@ options: type: str required: false extends_documentation_fragment: -- community.general.hwc + - community.general.hwc + - community.general.attributes ''' diff --git a/plugins/modules/hwc_vpc_security_group_rule.py b/plugins/modules/hwc_vpc_security_group_rule.py index ca6e2e9de8..bfb5d6a615 100644 --- a/plugins/modules/hwc_vpc_security_group_rule.py +++ b/plugins/modules/hwc_vpc_security_group_rule.py @@ -19,17 +19,22 @@ description: - vpc security group management. short_description: Creates a resource of Vpc/SecurityGroupRule in Huawei Cloud notes: - - If I(id) option is provided, it takes precedence over - I(enterprise_project_id) for security group rule selection. - - I(security_group_id) is used for security group rule selection. If more - than one security group rule with this options exists, execution is - aborted. - - No parameter support updating. If one of option is changed, the module - will create a new resource. + - If I(id) option is provided, it takes precedence over + I(enterprise_project_id) for security group rule selection. + - I(security_group_id) is used for security group rule selection. If more + than one security group rule with this options exists, execution is + aborted. + - No parameter support updating. If one of option is changed, the module + will create a new resource. version_added: '0.2.0' author: Huawei Inc. (@huaweicloud) requirements: - keystoneauth1 >= 3.6.0 +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: description: @@ -100,7 +105,8 @@ options: type: str required: false extends_documentation_fragment: -- community.general.hwc + - community.general.hwc + - community.general.attributes ''' diff --git a/plugins/modules/hwc_vpc_subnet.py b/plugins/modules/hwc_vpc_subnet.py index 4b192a5682..7fb107f534 100644 --- a/plugins/modules/hwc_vpc_subnet.py +++ b/plugins/modules/hwc_vpc_subnet.py @@ -22,6 +22,11 @@ version_added: '0.2.0' author: Huawei Inc. (@huaweicloud) requirements: - keystoneauth1 >= 3.6.0 +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: description: @@ -94,7 +99,8 @@ options: elements: str required: false extends_documentation_fragment: -- community.general.hwc + - community.general.hwc + - community.general.attributes ''' diff --git a/plugins/modules/lxd_container.py b/plugins/modules/lxd_container.py index 00649a076f..f10fc4872f 100644 --- a/plugins/modules/lxd_container.py +++ b/plugins/modules/lxd_container.py @@ -19,12 +19,12 @@ author: "Hiroaki Nakamura (@hnakamur)" extends_documentation_fragment: - community.general.attributes attributes: - check_mode: - support: full - version_added: 6.4.0 - diff_mode: - support: full - version_added: 6.4.0 + check_mode: + support: full + version_added: 6.4.0 + diff_mode: + support: full + version_added: 6.4.0 options: name: description: diff --git a/plugins/modules/lxd_profile.py b/plugins/modules/lxd_profile.py index 1410d16e02..45f499b784 100644 --- a/plugins/modules/lxd_profile.py +++ b/plugins/modules/lxd_profile.py @@ -16,6 +16,13 @@ short_description: Manage LXD profiles description: - Management of LXD profiles author: "Hiroaki Nakamura (@hnakamur)" +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/lxd_project.py b/plugins/modules/lxd_project.py index ad6019c2ec..983531fa08 100644 --- a/plugins/modules/lxd_project.py +++ b/plugins/modules/lxd_project.py @@ -15,6 +15,13 @@ version_added: 4.8.0 description: - Management of LXD projects. author: "Raymond Chang (@we10710aa)" +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: description: From cc3a79bc48be212c843a1599851c04835f8f113d Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Fri, 24 Feb 2023 09:23:04 +0100 Subject: [PATCH 0188/1810] Add attributes to some database modules (#5953) Add attributes to some database modules. --- plugins/modules/etcd3.py | 11 +++++++++-- plugins/modules/influxdb_database.py | 8 +++++++- plugins/modules/influxdb_query.py | 8 +++++++- plugins/modules/influxdb_retention_policy.py | 8 +++++++- plugins/modules/influxdb_user.py | 8 +++++++- plugins/modules/influxdb_write.py | 8 +++++++- plugins/modules/ldap_attrs.py | 8 +++++++- plugins/modules/ldap_entry.py | 8 +++++++- plugins/modules/ldap_passwd.py | 8 +++++++- plugins/modules/ldap_search.py | 8 +++++++- plugins/modules/mssql_db.py | 9 ++++++++- plugins/modules/mssql_script.py | 11 +++++++++++ plugins/modules/odbc.py | 7 +++++++ plugins/modules/redis.py | 6 ++++++ plugins/modules/redis_data.py | 6 ++++++ plugins/modules/redis_data_incr.py | 17 +++++++++++------ plugins/modules/riak.py | 11 +++++++++-- plugins/modules/vertica_configuration.py | 7 +++++++ plugins/modules/vertica_role.py | 7 +++++++ plugins/modules/vertica_schema.py | 7 +++++++ plugins/modules/vertica_user.py | 7 +++++++ 21 files changed, 158 insertions(+), 20 deletions(-) diff --git a/plugins/modules/etcd3.py b/plugins/modules/etcd3.py index 2a89c71968..9cd0274068 100644 --- a/plugins/modules/etcd3.py +++ b/plugins/modules/etcd3.py @@ -16,8 +16,15 @@ short_description: Set or delete key value pairs from an etcd3 cluster requirements: - etcd3 description: - - Sets or deletes values in etcd3 cluster using its v3 api. - - Needs python etcd3 lib to work + - Sets or deletes values in etcd3 cluster using its v3 api. + - Needs python etcd3 lib to work +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: key: type: str diff --git a/plugins/modules/influxdb_database.py b/plugins/modules/influxdb_database.py index 8ffbece606..046b16e18c 100644 --- a/plugins/modules/influxdb_database.py +++ b/plugins/modules/influxdb_database.py @@ -20,6 +20,11 @@ requirements: - "python >= 2.6" - "influxdb >= 0.9" - requests +attributes: + check_mode: + support: full + diff_mode: + support: none options: database_name: description: @@ -33,7 +38,8 @@ options: default: present type: str extends_documentation_fragment: -- community.general.influxdb + - community.general.influxdb + - community.general.attributes ''' diff --git a/plugins/modules/influxdb_query.py b/plugins/modules/influxdb_query.py index 14a65a60dc..c2e3d8acc4 100644 --- a/plugins/modules/influxdb_query.py +++ b/plugins/modules/influxdb_query.py @@ -18,6 +18,11 @@ author: "René Moser (@resmo)" requirements: - "python >= 2.6" - "influxdb >= 0.9" +attributes: + check_mode: + support: full + diff_mode: + support: none options: query: description: @@ -30,7 +35,8 @@ options: required: true type: str extends_documentation_fragment: -- community.general.influxdb + - community.general.influxdb + - community.general.attributes ''' diff --git a/plugins/modules/influxdb_retention_policy.py b/plugins/modules/influxdb_retention_policy.py index 1b7d7eec9a..28d5450ff0 100644 --- a/plugins/modules/influxdb_retention_policy.py +++ b/plugins/modules/influxdb_retention_policy.py @@ -20,6 +20,11 @@ requirements: - "python >= 2.6" - "influxdb >= 0.9" - requests +attributes: + check_mode: + support: full + diff_mode: + support: none options: database_name: description: @@ -64,7 +69,8 @@ options: type: str version_added: '2.0.0' extends_documentation_fragment: -- community.general.influxdb + - community.general.influxdb + - community.general.attributes ''' diff --git a/plugins/modules/influxdb_user.py b/plugins/modules/influxdb_user.py index 25bc2a95ce..e893fc0759 100644 --- a/plugins/modules/influxdb_user.py +++ b/plugins/modules/influxdb_user.py @@ -20,6 +20,11 @@ author: "Vitaliy Zhhuta (@zhhuta)" requirements: - "python >= 2.6" - "influxdb >= 0.9" +attributes: + check_mode: + support: full + diff_mode: + support: none options: user_name: description: @@ -52,7 +57,8 @@ options: type: list elements: dict extends_documentation_fragment: -- community.general.influxdb + - community.general.influxdb + - community.general.attributes ''' diff --git a/plugins/modules/influxdb_write.py b/plugins/modules/influxdb_write.py index 68e722ae1c..f95b6dae8c 100644 --- a/plugins/modules/influxdb_write.py +++ b/plugins/modules/influxdb_write.py @@ -18,6 +18,11 @@ author: "René Moser (@resmo)" requirements: - "python >= 2.6" - "influxdb >= 0.9" +attributes: + check_mode: + support: none + diff_mode: + support: none options: data_points: description: @@ -31,7 +36,8 @@ options: required: true type: str extends_documentation_fragment: -- community.general.influxdb + - community.general.influxdb + - community.general.attributes ''' diff --git a/plugins/modules/ldap_attrs.py b/plugins/modules/ldap_attrs.py index 61ae291956..01e8c0b9e1 100644 --- a/plugins/modules/ldap_attrs.py +++ b/plugins/modules/ldap_attrs.py @@ -40,6 +40,11 @@ author: - Maciej Delmanowski (@drybjed) requirements: - python-ldap +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: required: false @@ -68,7 +73,8 @@ options: attributes specified in the current task. This is useful mostly with I(olcAccess) attribute to easily manage LDAP Access Control Lists. extends_documentation_fragment: -- community.general.ldap.documentation + - community.general.ldap.documentation + - community.general.attributes ''' diff --git a/plugins/modules/ldap_entry.py b/plugins/modules/ldap_entry.py index 8cacbc42c1..9179b5238b 100644 --- a/plugins/modules/ldap_entry.py +++ b/plugins/modules/ldap_entry.py @@ -30,6 +30,11 @@ author: - Jiri Tyr (@jtyr) requirements: - python-ldap +attributes: + check_mode: + support: full + diff_mode: + support: none options: attributes: description: @@ -59,7 +64,8 @@ options: default: false version_added: 4.6.0 extends_documentation_fragment: -- community.general.ldap.documentation + - community.general.ldap.documentation + - community.general.attributes ''' diff --git a/plugins/modules/ldap_passwd.py b/plugins/modules/ldap_passwd.py index 029b5df252..f47fa330e3 100644 --- a/plugins/modules/ldap_passwd.py +++ b/plugins/modules/ldap_passwd.py @@ -28,13 +28,19 @@ author: - Keller Fuchs (@KellerFuchs) requirements: - python-ldap +attributes: + check_mode: + support: full + diff_mode: + support: none options: passwd: description: - The (plaintext) password to be set for I(dn). type: str extends_documentation_fragment: -- community.general.ldap.documentation + - community.general.ldap.documentation + - community.general.attributes ''' diff --git a/plugins/modules/ldap_search.py b/plugins/modules/ldap_search.py index 02ba4d3529..32efd4edd6 100644 --- a/plugins/modules/ldap_search.py +++ b/plugins/modules/ldap_search.py @@ -27,6 +27,11 @@ author: - Sebastian Pfahl (@eryx12o45) requirements: - python-ldap +attributes: + check_mode: + support: full + diff_mode: + support: none options: dn: required: true @@ -57,7 +62,8 @@ options: - Set to C(true) to return the full attribute schema of entries, not their attribute values. Overrides I(attrs) when provided. extends_documentation_fragment: - - community.general.ldap.documentation + - community.general.ldap.documentation + - community.general.attributes """ EXAMPLES = r""" diff --git a/plugins/modules/mssql_db.py b/plugins/modules/mssql_db.py index 58a8c4dea9..4006033cf2 100644 --- a/plugins/modules/mssql_db.py +++ b/plugins/modules/mssql_db.py @@ -15,7 +15,14 @@ DOCUMENTATION = ''' module: mssql_db short_description: Add or remove MSSQL databases from a remote host description: - - Add or remove MSSQL databases from a remote host. + - Add or remove MSSQL databases from a remote host. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/mssql_script.py b/plugins/modules/mssql_script.py index 1a5f45736f..1696000db2 100644 --- a/plugins/modules/mssql_script.py +++ b/plugins/modules/mssql_script.py @@ -18,6 +18,17 @@ version_added: "4.0.0" description: - Execute SQL scripts on a MSSQL database. +extends_documentation_fragment: + - community.general.attributes + +attributes: + check_mode: + support: partial + details: + - The script will not be executed in check mode. + diff_mode: + support: none + options: name: description: Database to run script against. diff --git a/plugins/modules/odbc.py b/plugins/modules/odbc.py index 3b6e8ad226..fbc4b63ae5 100644 --- a/plugins/modules/odbc.py +++ b/plugins/modules/odbc.py @@ -16,6 +16,13 @@ version_added: "1.0.0" short_description: Execute SQL via ODBC description: - Read/Write info via ODBC drivers. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: dsn: description: diff --git a/plugins/modules/redis.py b/plugins/modules/redis.py index 298b3aaf8c..1778a067e4 100644 --- a/plugins/modules/redis.py +++ b/plugins/modules/redis.py @@ -16,6 +16,12 @@ description: - Unified utility to interact with redis instances. extends_documentation_fragment: - community.general.redis + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: command: description: diff --git a/plugins/modules/redis_data.py b/plugins/modules/redis_data.py index 633afbff54..c0c8dcc9a6 100644 --- a/plugins/modules/redis_data.py +++ b/plugins/modules/redis_data.py @@ -16,6 +16,11 @@ version_added: 3.7.0 description: - Set key value pairs in Redis database. author: "Andreas Botzner (@paginabianca)" +attributes: + check_mode: + support: full + diff_mode: + support: none options: key: description: @@ -59,6 +64,7 @@ options: extends_documentation_fragment: - community.general.redis.documentation + - community.general.attributes seealso: - module: community.general.redis_data_incr diff --git a/plugins/modules/redis_data_incr.py b/plugins/modules/redis_data_incr.py index 4d1c119349..f927fb11f0 100644 --- a/plugins/modules/redis_data_incr.py +++ b/plugins/modules/redis_data_incr.py @@ -17,9 +17,17 @@ description: - Increment integers or float keys in Redis database and get new value. - Default increment for all keys is 1. For specific increments use the I(increment_int) and I(increment_float) options. - - When using I(check_mode) the module will try to calculate the value that - Redis would return. If the key is not present, 0.0 is used as value. author: "Andreas Botzner (@paginabianca)" +attributes: + check_mode: + support: partial + details: + - For C(check_mode) to work, the specified I(redis_user) needs permission to + run the C(GET) command on the key, otherwise the module will fail. + - When using I(check_mode) the module will try to calculate the value that + Redis would return. If the key is not present, 0.0 is used as value. + diff_mode: + support: none options: key: description: @@ -42,10 +50,7 @@ options: extends_documentation_fragment: - community.general.redis.documentation - -notes: - - For C(check_mode) to work, the specified I(redis_user) needs permission to - run the C(GET) command on the key, otherwise the module will fail. + - community.general.attributes seealso: - module: community.general.redis_data diff --git a/plugins/modules/riak.py b/plugins/modules/riak.py index 38f1c33c78..024e5424d2 100644 --- a/plugins/modules/riak.py +++ b/plugins/modules/riak.py @@ -14,11 +14,18 @@ DOCUMENTATION = ''' module: riak short_description: This module handles some common Riak operations description: - - This module can be used to join nodes to a cluster, check - the status of the cluster. + - This module can be used to join nodes to a cluster, check + the status of the cluster. author: - "James Martin (@jsmartin)" - "Drew Kerrigan (@drewkerrigan)" +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: command: description: diff --git a/plugins/modules/vertica_configuration.py b/plugins/modules/vertica_configuration.py index 553630da39..09b80df3d7 100644 --- a/plugins/modules/vertica_configuration.py +++ b/plugins/modules/vertica_configuration.py @@ -14,6 +14,13 @@ module: vertica_configuration short_description: Updates Vertica configuration parameters description: - Updates Vertica configuration parameters. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: parameter: description: diff --git a/plugins/modules/vertica_role.py b/plugins/modules/vertica_role.py index dde9919511..704594a128 100644 --- a/plugins/modules/vertica_role.py +++ b/plugins/modules/vertica_role.py @@ -15,6 +15,13 @@ module: vertica_role short_description: Adds or removes Vertica database roles and assigns roles to them description: - Adds or removes Vertica database role and, optionally, assign other roles. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: role: description: diff --git a/plugins/modules/vertica_schema.py b/plugins/modules/vertica_schema.py index 3c4071473a..01f8f721e7 100644 --- a/plugins/modules/vertica_schema.py +++ b/plugins/modules/vertica_schema.py @@ -20,6 +20,13 @@ description: - In such a situation, if the module tries to remove the schema it will fail and only remove roles created for the schema if they have no dependencies. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: schema: description: diff --git a/plugins/modules/vertica_user.py b/plugins/modules/vertica_user.py index 89f1cb92a3..a6a5b59516 100644 --- a/plugins/modules/vertica_user.py +++ b/plugins/modules/vertica_user.py @@ -17,6 +17,13 @@ description: - A user will not be removed until all the dependencies have been dropped. - In such a situation, if the module tries to remove the user it will fail and only remove roles granted to the user. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: user: description: From e944a67c182df970f407e272741d46ea0724912f Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Fri, 24 Feb 2023 09:23:28 +0100 Subject: [PATCH 0189/1810] Add attributes to manageiq, udm, utm, and webfaction modules (#5955) Add attributes to manageiq, udm, utm, and webfaction modules. --- plugins/modules/manageiq_alert_profiles.py | 9 ++++++++- plugins/modules/manageiq_alerts.py | 9 ++++++++- plugins/modules/manageiq_group.py | 11 +++++++++-- plugins/modules/manageiq_policies.py | 9 ++++++++- plugins/modules/manageiq_provider.py | 9 ++++++++- plugins/modules/manageiq_tags.py | 9 ++++++++- plugins/modules/manageiq_tenant.py | 10 ++++++++-- plugins/modules/manageiq_user.py | 9 ++++++++- plugins/modules/udm_dns_record.py | 10 ++++++++-- plugins/modules/udm_dns_zone.py | 11 ++++++++--- plugins/modules/udm_group.py | 11 ++++++++--- plugins/modules/udm_share.py | 11 ++++++++--- plugins/modules/udm_user.py | 11 ++++++++--- plugins/modules/utm_aaa_group.py | 6 ++++++ plugins/modules/utm_ca_host_key_cert.py | 6 ++++++ plugins/modules/utm_dns_host.py | 6 ++++++ plugins/modules/utm_network_interface_address.py | 6 ++++++ plugins/modules/utm_proxy_auth_profile.py | 6 ++++++ plugins/modules/utm_proxy_exception.py | 6 ++++++ plugins/modules/utm_proxy_frontend.py | 6 ++++++ plugins/modules/utm_proxy_location.py | 6 ++++++ plugins/modules/webfaction_app.py | 9 +++++++++ plugins/modules/webfaction_db.py | 7 +++++++ plugins/modules/webfaction_domain.py | 9 +++++++++ plugins/modules/webfaction_mailbox.py | 10 ++++++++++ plugins/modules/webfaction_site.py | 9 +++++++++ 26 files changed, 197 insertions(+), 24 deletions(-) diff --git a/plugins/modules/manageiq_alert_profiles.py b/plugins/modules/manageiq_alert_profiles.py index 1ea5c57b09..c6cefad6a8 100644 --- a/plugins/modules/manageiq_alert_profiles.py +++ b/plugins/modules/manageiq_alert_profiles.py @@ -14,12 +14,19 @@ module: manageiq_alert_profiles short_description: Configuration of alert profiles for ManageIQ extends_documentation_fragment: -- community.general.manageiq + - community.general.manageiq + - community.general.attributes author: Elad Alfassa (@elad661) description: - The manageiq_alert_profiles module supports adding, updating and deleting alert profiles in ManageIQ. +attributes: + check_mode: + support: none + diff_mode: + support: none + options: state: type: str diff --git a/plugins/modules/manageiq_alerts.py b/plugins/modules/manageiq_alerts.py index d12ebd6ea6..518b29f1f3 100644 --- a/plugins/modules/manageiq_alerts.py +++ b/plugins/modules/manageiq_alerts.py @@ -14,12 +14,19 @@ module: manageiq_alerts short_description: Configuration of alerts in ManageIQ extends_documentation_fragment: -- community.general.manageiq + - community.general.manageiq + - community.general.attributes author: Elad Alfassa (@elad661) description: - The manageiq_alerts module supports adding, updating and deleting alerts in ManageIQ. +attributes: + check_mode: + support: none + diff_mode: + support: none + options: state: type: str diff --git a/plugins/modules/manageiq_group.py b/plugins/modules/manageiq_group.py index 5772c19a7e..a142a939fe 100644 --- a/plugins/modules/manageiq_group.py +++ b/plugins/modules/manageiq_group.py @@ -14,13 +14,20 @@ module: manageiq_group short_description: Management of groups in ManageIQ extends_documentation_fragment: -- community.general.manageiq + - community.general.manageiq + - community.general.attributes author: Evert Mulder (@evertmulder) description: - The manageiq_group module supports adding, updating and deleting groups in ManageIQ. requirements: -- manageiq-client + - manageiq-client + +attributes: + check_mode: + support: none + diff_mode: + support: none options: state: diff --git a/plugins/modules/manageiq_policies.py b/plugins/modules/manageiq_policies.py index fa96fc950f..7d05f2dfad 100644 --- a/plugins/modules/manageiq_policies.py +++ b/plugins/modules/manageiq_policies.py @@ -15,12 +15,19 @@ module: manageiq_policies short_description: Management of resource policy_profiles in ManageIQ extends_documentation_fragment: -- community.general.manageiq + - community.general.manageiq + - community.general.attributes author: Daniel Korn (@dkorn) description: - The manageiq_policies module supports adding and deleting policy_profiles in ManageIQ. +attributes: + check_mode: + support: none + diff_mode: + support: none + options: state: type: str diff --git a/plugins/modules/manageiq_provider.py b/plugins/modules/manageiq_provider.py index 5eb6d779ac..bbc27214b7 100644 --- a/plugins/modules/manageiq_provider.py +++ b/plugins/modules/manageiq_provider.py @@ -13,12 +13,19 @@ DOCUMENTATION = ''' module: manageiq_provider short_description: Management of provider in ManageIQ extends_documentation_fragment: -- community.general.manageiq + - community.general.manageiq + - community.general.attributes author: Daniel Korn (@dkorn) description: - The manageiq_provider module supports adding, updating, and deleting provider in ManageIQ. +attributes: + check_mode: + support: none + diff_mode: + support: none + options: state: type: str diff --git a/plugins/modules/manageiq_tags.py b/plugins/modules/manageiq_tags.py index 5e6b944533..8631ac46a4 100644 --- a/plugins/modules/manageiq_tags.py +++ b/plugins/modules/manageiq_tags.py @@ -15,12 +15,19 @@ module: manageiq_tags short_description: Management of resource tags in ManageIQ extends_documentation_fragment: -- community.general.manageiq + - community.general.manageiq + - community.general.attributes author: Daniel Korn (@dkorn) description: - The manageiq_tags module supports adding, updating and deleting tags in ManageIQ. +attributes: + check_mode: + support: none + diff_mode: + support: none + options: state: type: str diff --git a/plugins/modules/manageiq_tenant.py b/plugins/modules/manageiq_tenant.py index f3700d2492..d68e26a735 100644 --- a/plugins/modules/manageiq_tenant.py +++ b/plugins/modules/manageiq_tenant.py @@ -14,13 +14,19 @@ module: manageiq_tenant short_description: Management of tenants in ManageIQ extends_documentation_fragment: -- community.general.manageiq + - community.general.manageiq + - community.general.attributes author: Evert Mulder (@evertmulder) description: - The manageiq_tenant module supports adding, updating and deleting tenants in ManageIQ. requirements: -- manageiq-client + - manageiq-client +attributes: + check_mode: + support: none + diff_mode: + support: none options: state: type: str diff --git a/plugins/modules/manageiq_user.py b/plugins/modules/manageiq_user.py index 9910e092e0..0d3d8718b4 100644 --- a/plugins/modules/manageiq_user.py +++ b/plugins/modules/manageiq_user.py @@ -14,12 +14,19 @@ module: manageiq_user short_description: Management of users in ManageIQ extends_documentation_fragment: -- community.general.manageiq + - community.general.manageiq + - community.general.attributes author: Daniel Korn (@dkorn) description: - The manageiq_user module supports adding, updating and deleting users in ManageIQ. +attributes: + check_mode: + support: none + diff_mode: + support: none + options: state: type: str diff --git a/plugins/modules/udm_dns_record.py b/plugins/modules/udm_dns_record.py index 13eb4feed4..458a8e4ba5 100644 --- a/plugins/modules/udm_dns_record.py +++ b/plugins/modules/udm_dns_record.py @@ -14,15 +14,21 @@ DOCUMENTATION = ''' --- module: udm_dns_record author: -- Tobias Rüetschi (@keachi) + - Tobias Rüetschi (@keachi) short_description: Manage dns entries on a univention corporate server description: - "This module allows to manage dns records on a univention corporate server (UCS). It uses the python API of the UCS to create a new object or edit it." requirements: - - Python >= 2.6 - Univention - ipaddress (for I(type=ptr_record)) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: partial options: state: type: str diff --git a/plugins/modules/udm_dns_zone.py b/plugins/modules/udm_dns_zone.py index b75cbe95ac..19f24fa1c2 100644 --- a/plugins/modules/udm_dns_zone.py +++ b/plugins/modules/udm_dns_zone.py @@ -14,13 +14,18 @@ DOCUMENTATION = ''' --- module: udm_dns_zone author: -- Tobias Rüetschi (@keachi) + - Tobias Rüetschi (@keachi) short_description: Manage dns zones on a univention corporate server description: - "This module allows to manage dns zones on a univention corporate server (UCS). It uses the python API of the UCS to create a new object or edit it." -requirements: - - Python >= 2.6 +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: partial options: state: type: str diff --git a/plugins/modules/udm_group.py b/plugins/modules/udm_group.py index 74916cfee2..5fe2422f8b 100644 --- a/plugins/modules/udm_group.py +++ b/plugins/modules/udm_group.py @@ -14,13 +14,18 @@ DOCUMENTATION = ''' --- module: udm_group author: -- Tobias Rüetschi (@keachi) + - Tobias Rüetschi (@keachi) short_description: Manage of the posix group description: - "This module allows to manage user groups on a univention corporate server (UCS). It uses the python API of the UCS to create a new object or edit it." -requirements: - - Python >= 2.6 +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: partial options: state: required: false diff --git a/plugins/modules/udm_share.py b/plugins/modules/udm_share.py index 8120df1b00..2743913351 100644 --- a/plugins/modules/udm_share.py +++ b/plugins/modules/udm_share.py @@ -14,14 +14,19 @@ DOCUMENTATION = ''' --- module: udm_share author: -- Tobias Rüetschi (@keachi) + - Tobias Rüetschi (@keachi) short_description: Manage samba shares on a univention corporate server description: - "This module allows to manage samba shares on a univention corporate server (UCS). It uses the python API of the UCS to create a new object or edit it." -requirements: - - Python >= 2.6 +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: partial options: state: default: "present" diff --git a/plugins/modules/udm_user.py b/plugins/modules/udm_user.py index 96bbdfbc10..05c5ad359d 100644 --- a/plugins/modules/udm_user.py +++ b/plugins/modules/udm_user.py @@ -14,14 +14,19 @@ DOCUMENTATION = r''' --- module: udm_user author: -- Tobias Rüetschi (@keachi) + - Tobias Rüetschi (@keachi) short_description: Manage posix users on a univention corporate server description: - "This module allows to manage posix users on a univention corporate server (UCS). It uses the python API of the UCS to create a new object or edit it." -requirements: - - Python >= 2.6 +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: partial options: state: default: "present" diff --git a/plugins/modules/utm_aaa_group.py b/plugins/modules/utm_aaa_group.py index 3d5cbc2007..9c595284da 100644 --- a/plugins/modules/utm_aaa_group.py +++ b/plugins/modules/utm_aaa_group.py @@ -21,6 +21,11 @@ description: - Create, update or destroy an aaa group object in Sophos UTM. - This module needs to have the REST Ability of the UTM to be activated. +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: @@ -112,6 +117,7 @@ options: extends_documentation_fragment: - community.general.utm +- community.general.attributes ''' diff --git a/plugins/modules/utm_ca_host_key_cert.py b/plugins/modules/utm_ca_host_key_cert.py index 318bc1fd31..b944e83124 100644 --- a/plugins/modules/utm_ca_host_key_cert.py +++ b/plugins/modules/utm_ca_host_key_cert.py @@ -22,6 +22,11 @@ description: - Create, update or destroy a ca host_key_cert entry in SOPHOS UTM. - This module needs to have the REST Ability of the UTM to be activated. +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: @@ -60,6 +65,7 @@ options: extends_documentation_fragment: - community.general.utm +- community.general.attributes ''' diff --git a/plugins/modules/utm_dns_host.py b/plugins/modules/utm_dns_host.py index 3a1744651a..6b3725557b 100644 --- a/plugins/modules/utm_dns_host.py +++ b/plugins/modules/utm_dns_host.py @@ -21,6 +21,11 @@ description: - Create, update or destroy a dns entry in SOPHOS UTM. - This module needs to have the REST Ability of the UTM to be activated. +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: @@ -70,6 +75,7 @@ options: extends_documentation_fragment: - community.general.utm +- community.general.attributes ''' diff --git a/plugins/modules/utm_network_interface_address.py b/plugins/modules/utm_network_interface_address.py index e980a0221b..a85a46aeab 100644 --- a/plugins/modules/utm_network_interface_address.py +++ b/plugins/modules/utm_network_interface_address.py @@ -21,6 +21,11 @@ description: - Create, update or destroy a network/interface_address object in SOPHOS UTM. - This module needs to have the REST Ability of the UTM to be activated. +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: @@ -54,6 +59,7 @@ options: extends_documentation_fragment: - community.general.utm +- community.general.attributes ''' diff --git a/plugins/modules/utm_proxy_auth_profile.py b/plugins/modules/utm_proxy_auth_profile.py index 0c53a92380..ef3fc341a3 100644 --- a/plugins/modules/utm_proxy_auth_profile.py +++ b/plugins/modules/utm_proxy_auth_profile.py @@ -22,6 +22,11 @@ description: - Create, update or destroy a reverse_proxy auth_profile entry in SOPHOS UTM. - This module needs to have the REST Ability of the UTM to be activated. +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: @@ -185,6 +190,7 @@ options: extends_documentation_fragment: - community.general.utm +- community.general.attributes ''' diff --git a/plugins/modules/utm_proxy_exception.py b/plugins/modules/utm_proxy_exception.py index f322bc8216..a0a3f85b5b 100644 --- a/plugins/modules/utm_proxy_exception.py +++ b/plugins/modules/utm_proxy_exception.py @@ -22,6 +22,11 @@ description: - Create, update or destroy a reverse_proxy exception entry in SOPHOS UTM. - This module needs to have the REST Ability of the UTM to be activated. +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: @@ -123,6 +128,7 @@ options: extends_documentation_fragment: - community.general.utm +- community.general.attributes ''' diff --git a/plugins/modules/utm_proxy_frontend.py b/plugins/modules/utm_proxy_frontend.py index 127c7d4d43..22a773fef8 100644 --- a/plugins/modules/utm_proxy_frontend.py +++ b/plugins/modules/utm_proxy_frontend.py @@ -22,6 +22,11 @@ description: - Create, update or destroy a reverse_proxy frontend entry in Sophos UTM. - This module needs to have the REST Ability of the UTM to be activated. +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: @@ -138,6 +143,7 @@ options: extends_documentation_fragment: - community.general.utm +- community.general.attributes ''' diff --git a/plugins/modules/utm_proxy_location.py b/plugins/modules/utm_proxy_location.py index 0efeea5a27..c22de7b927 100644 --- a/plugins/modules/utm_proxy_location.py +++ b/plugins/modules/utm_proxy_location.py @@ -22,6 +22,11 @@ description: - Create, update or destroy a reverse_proxy location entry in SOPHOS UTM. - This module needs to have the REST Ability of the UTM to be activated. +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: @@ -104,6 +109,7 @@ options: extends_documentation_fragment: - community.general.utm +- community.general.attributes ''' diff --git a/plugins/modules/webfaction_app.py b/plugins/modules/webfaction_app.py index b2fe7f892d..7a47026755 100644 --- a/plugins/modules/webfaction_app.py +++ b/plugins/modules/webfaction_app.py @@ -31,6 +31,15 @@ notes: your host, you may want to add C(serial: 1) to the plays. - See `the webfaction API `_ for more info. +extends_documentation_fragment: + - community.general.attributes + +attributes: + check_mode: + support: full + diff_mode: + support: none + options: name: description: diff --git a/plugins/modules/webfaction_db.py b/plugins/modules/webfaction_db.py index 868f1f66a2..c4742cb217 100644 --- a/plugins/modules/webfaction_db.py +++ b/plugins/modules/webfaction_db.py @@ -27,6 +27,13 @@ notes: The location is not important. However, running them on multiple hosts I(simultaneously) is best avoided. If you don't specify I(localhost) as your host, you may want to add C(serial: 1) to the plays. - See `the webfaction API `_ for more info. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: diff --git a/plugins/modules/webfaction_domain.py b/plugins/modules/webfaction_domain.py index 79485d629c..9bffec3cd1 100644 --- a/plugins/modules/webfaction_domain.py +++ b/plugins/modules/webfaction_domain.py @@ -27,6 +27,15 @@ notes: your host, you may want to add C(serial: 1) to the plays. - See `the webfaction API `_ for more info. +extends_documentation_fragment: + - community.general.attributes + +attributes: + check_mode: + support: full + diff_mode: + support: none + options: name: diff --git a/plugins/modules/webfaction_mailbox.py b/plugins/modules/webfaction_mailbox.py index 0df4e8ced0..2b543c5b1d 100644 --- a/plugins/modules/webfaction_mailbox.py +++ b/plugins/modules/webfaction_mailbox.py @@ -24,6 +24,16 @@ notes: The location is not important. However, running them on multiple hosts I(simultaneously) is best avoided. If you don't specify I(localhost) as your host, you may want to add C(serial: 1) to the plays. - See `the webfaction API `_ for more info. + +extends_documentation_fragment: + - community.general.attributes + +attributes: + check_mode: + support: full + diff_mode: + support: none + options: mailbox_name: diff --git a/plugins/modules/webfaction_site.py b/plugins/modules/webfaction_site.py index 4e6f317e87..385f552115 100644 --- a/plugins/modules/webfaction_site.py +++ b/plugins/modules/webfaction_site.py @@ -28,6 +28,15 @@ notes: your host, you may want to add C(serial: 1) to the plays. - See `the webfaction API `_ for more info. +extends_documentation_fragment: + - community.general.attributes + +attributes: + check_mode: + support: full + diff_mode: + support: none + options: name: From bad4b4b086e4a092658830d65c3c1a83d0b274cd Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Fri, 24 Feb 2023 09:23:43 +0100 Subject: [PATCH 0190/1810] Add attributes to source control modules (#5956) Add attributes to source control modules. --- plugins/modules/bitbucket_access_key.py | 6 ++++++ plugins/modules/bitbucket_pipeline_key_pair.py | 6 ++++++ plugins/modules/bitbucket_pipeline_known_host.py | 8 +++++++- plugins/modules/bitbucket_pipeline_variable.py | 6 ++++++ plugins/modules/bzr.py | 7 +++++++ plugins/modules/hg.py | 7 +++++++ 6 files changed, 39 insertions(+), 1 deletion(-) diff --git a/plugins/modules/bitbucket_access_key.py b/plugins/modules/bitbucket_access_key.py index 0708777a0a..5ef199f7a4 100644 --- a/plugins/modules/bitbucket_access_key.py +++ b/plugins/modules/bitbucket_access_key.py @@ -18,6 +18,12 @@ author: - Evgeniy Krysanov (@catcombo) extends_documentation_fragment: - community.general.bitbucket + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: repository: description: diff --git a/plugins/modules/bitbucket_pipeline_key_pair.py b/plugins/modules/bitbucket_pipeline_key_pair.py index db4453d45c..d39c054b11 100644 --- a/plugins/modules/bitbucket_pipeline_key_pair.py +++ b/plugins/modules/bitbucket_pipeline_key_pair.py @@ -18,6 +18,12 @@ author: - Evgeniy Krysanov (@catcombo) extends_documentation_fragment: - community.general.bitbucket + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: repository: description: diff --git a/plugins/modules/bitbucket_pipeline_known_host.py b/plugins/modules/bitbucket_pipeline_known_host.py index e573719362..28ff487398 100644 --- a/plugins/modules/bitbucket_pipeline_known_host.py +++ b/plugins/modules/bitbucket_pipeline_known_host.py @@ -19,8 +19,14 @@ author: - Evgeniy Krysanov (@catcombo) extends_documentation_fragment: - community.general.bitbucket + - community.general.attributes requirements: - - paramiko + - paramiko +attributes: + check_mode: + support: full + diff_mode: + support: none options: repository: description: diff --git a/plugins/modules/bitbucket_pipeline_variable.py b/plugins/modules/bitbucket_pipeline_variable.py index 45661d8dee..eac0d18dda 100644 --- a/plugins/modules/bitbucket_pipeline_variable.py +++ b/plugins/modules/bitbucket_pipeline_variable.py @@ -18,6 +18,12 @@ author: - Evgeniy Krysanov (@catcombo) extends_documentation_fragment: - community.general.bitbucket + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: repository: description: diff --git a/plugins/modules/bzr.py b/plugins/modules/bzr.py index 7832183806..e7aca7c6bb 100644 --- a/plugins/modules/bzr.py +++ b/plugins/modules/bzr.py @@ -17,6 +17,13 @@ author: short_description: Deploy software (or files) from bzr branches description: - Manage I(bzr) branches to deploy files or software. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/hg.py b/plugins/modules/hg.py index 777feaa059..dbbd504b4e 100644 --- a/plugins/modules/hg.py +++ b/plugins/modules/hg.py @@ -16,6 +16,13 @@ short_description: Manages Mercurial (hg) repositories description: - Manages Mercurial (hg) repositories. Supports SSH, HTTP/S and local address. author: "Yeukhon Wong (@yeukhon)" +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: repo: description: From 1f1ae558f9cee4b2984660d70987e1afb3fb8a8d Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Fri, 24 Feb 2023 09:23:56 +0100 Subject: [PATCH 0191/1810] Add attributes to consul, datadog, jenkins, pagerduty, rundeck, and sensu modules (#5957) * Add attributes to consul, datadog, jenkins, pagerduty, rundeck, and sensu modules. * Fix error. --- plugins/modules/consul.py | 7 +++++++ plugins/modules/consul_acl.py | 7 +++++++ plugins/modules/consul_kv.py | 7 +++++++ plugins/modules/consul_session.py | 9 ++++++++- plugins/modules/datadog_downtime.py | 7 +++++++ plugins/modules/datadog_event.py | 15 +++++++++++---- plugins/modules/datadog_monitor.py | 7 +++++++ plugins/modules/jenkins_build.py | 7 +++++++ plugins/modules/jenkins_job.py | 7 +++++++ plugins/modules/jenkins_plugin.py | 11 +++++++++-- plugins/modules/jenkins_script.py | 9 +++++++++ plugins/modules/pagerduty.py | 7 +++++++ plugins/modules/pagerduty_alert.py | 7 +++++++ plugins/modules/pagerduty_change.py | 11 +++++++++-- plugins/modules/pagerduty_user.py | 9 +++++++-- plugins/modules/rundeck_acl_policy.py | 9 ++++++++- plugins/modules/rundeck_job_run.py | 8 +++++++- plugins/modules/rundeck_project.py | 9 ++++++++- plugins/modules/sensu_check.py | 7 +++++++ plugins/modules/sensu_client.py | 7 +++++++ plugins/modules/sensu_handler.py | 7 +++++++ plugins/modules/sensu_silence.py | 7 +++++++ plugins/modules/sensu_subscription.py | 7 +++++++ 23 files changed, 174 insertions(+), 14 deletions(-) diff --git a/plugins/modules/consul.py b/plugins/modules/consul.py index dea853b98e..cc599be36d 100644 --- a/plugins/modules/consul.py +++ b/plugins/modules/consul.py @@ -33,6 +33,13 @@ requirements: - python-consul - requests author: "Steve Gargan (@sgargan)" +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: state: type: str diff --git a/plugins/modules/consul_acl.py b/plugins/modules/consul_acl.py index b9f14db164..91f955228a 100644 --- a/plugins/modules/consul_acl.py +++ b/plugins/modules/consul_acl.py @@ -19,6 +19,13 @@ description: author: - Steve Gargan (@sgargan) - Colin Nolan (@colin-nolan) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: mgmt_token: description: diff --git a/plugins/modules/consul_kv.py b/plugins/modules/consul_kv.py index 3419e3322b..a4457f2445 100644 --- a/plugins/modules/consul_kv.py +++ b/plugins/modules/consul_kv.py @@ -26,6 +26,13 @@ requirements: author: - Steve Gargan (@sgargan) - Colin Nolan (@colin-nolan) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: description: diff --git a/plugins/modules/consul_session.py b/plugins/modules/consul_session.py index 062eb3befe..246d13846f 100644 --- a/plugins/modules/consul_session.py +++ b/plugins/modules/consul_session.py @@ -20,7 +20,14 @@ requirements: - python-consul - requests author: -- Steve Gargan (@sgargan) + - Steve Gargan (@sgargan) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: id: description: diff --git a/plugins/modules/datadog_downtime.py b/plugins/modules/datadog_downtime.py index 8a1acf7e83..fd8421431d 100644 --- a/plugins/modules/datadog_downtime.py +++ b/plugins/modules/datadog_downtime.py @@ -22,6 +22,13 @@ author: requirements: - datadog-api-client - Python 3.6+ +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: api_key: description: diff --git a/plugins/modules/datadog_event.py b/plugins/modules/datadog_event.py index 0a669c4a81..b8161eca64 100644 --- a/plugins/modules/datadog_event.py +++ b/plugins/modules/datadog_event.py @@ -19,11 +19,18 @@ DOCUMENTATION = ''' module: datadog_event short_description: Posts events to Datadog service description: -- "Allows to post events to Datadog (www.datadoghq.com) service." -- "Uses http://docs.datadoghq.com/api/#events API." + - "Allows to post events to Datadog (www.datadoghq.com) service." + - "Uses http://docs.datadoghq.com/api/#events API." author: -- "Artūras 'arturaz' Šlajus (@arturaz)" -- "Naoya Nakazawa (@n0ts)" + - "Artūras 'arturaz' Šlajus (@arturaz)" + - "Naoya Nakazawa (@n0ts)" +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: api_key: type: str diff --git a/plugins/modules/datadog_monitor.py b/plugins/modules/datadog_monitor.py index ef6aa84255..f58df358b7 100644 --- a/plugins/modules/datadog_monitor.py +++ b/plugins/modules/datadog_monitor.py @@ -19,6 +19,13 @@ description: - The type C(event-v2) was added in community.general 4.8.0. author: Sebastian Kornehl (@skornehl) requirements: [datadog] +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: api_key: description: diff --git a/plugins/modules/jenkins_build.py b/plugins/modules/jenkins_build.py index b02027f229..4f95202244 100644 --- a/plugins/modules/jenkins_build.py +++ b/plugins/modules/jenkins_build.py @@ -20,6 +20,13 @@ requirements: author: - Brett Milford (@brettmilford) - Tong He (@unnecessary-username) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: args: description: diff --git a/plugins/modules/jenkins_job.py b/plugins/modules/jenkins_job.py index 0ea52ab36b..09b006448e 100644 --- a/plugins/modules/jenkins_job.py +++ b/plugins/modules/jenkins_job.py @@ -17,6 +17,13 @@ description: requirements: - "python-jenkins >= 0.4.12" author: "Sergio Millan Rodriguez (@sermilrod)" +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: full options: config: type: str diff --git a/plugins/modules/jenkins_plugin.py b/plugins/modules/jenkins_plugin.py index 9c4c42e675..b3ebf3f93c 100644 --- a/plugins/modules/jenkins_plugin.py +++ b/plugins/modules/jenkins_plugin.py @@ -17,6 +17,12 @@ short_description: Add or remove Jenkins plugin description: - Ansible module which helps to manage Jenkins plugins. +attributes: + check_mode: + support: full + diff_mode: + support: none + options: group: type: str @@ -129,8 +135,9 @@ notes: parameter to point to the Jenkins server. The module must be used on the host where Jenkins runs as it needs direct access to the plugin files. extends_documentation_fragment: - - url - - files + - ansible.builtin.url + - ansible.builtin.files + - community.general.attributes ''' EXAMPLES = ''' diff --git a/plugins/modules/jenkins_script.py b/plugins/modules/jenkins_script.py index 58d8e2c642..7f83ebcdbd 100644 --- a/plugins/modules/jenkins_script.py +++ b/plugins/modules/jenkins_script.py @@ -18,6 +18,15 @@ description: - The C(jenkins_script) module takes a script plus a dict of values to use within the script and returns the result of the script being run. +extends_documentation_fragment: + - community.general.attributes + +attributes: + check_mode: + support: none + diff_mode: + support: none + options: script: type: str diff --git a/plugins/modules/pagerduty.py b/plugins/modules/pagerduty.py index 7df9cc1d16..bed3629bef 100644 --- a/plugins/modules/pagerduty.py +++ b/plugins/modules/pagerduty.py @@ -22,6 +22,13 @@ author: - "Bruce Pennypacker (@bpennypacker)" requirements: - PagerDuty API access +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: state: type: str diff --git a/plugins/modules/pagerduty_alert.py b/plugins/modules/pagerduty_alert.py index e6bd7a3c0c..45bec92c6d 100644 --- a/plugins/modules/pagerduty_alert.py +++ b/plugins/modules/pagerduty_alert.py @@ -18,6 +18,13 @@ author: - "Amanpreet Singh (@ApsOps)" requirements: - PagerDuty API access +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: type: str diff --git a/plugins/modules/pagerduty_change.py b/plugins/modules/pagerduty_change.py index 104e76e66a..6af5d58eae 100644 --- a/plugins/modules/pagerduty_change.py +++ b/plugins/modules/pagerduty_change.py @@ -19,6 +19,15 @@ author: - Adam Vaughan (@adamvaughan) requirements: - PagerDuty integration key +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + details: + - Check mode simply does nothing except returning C(changed=true) in case the I(url) seems to be correct. + diff_mode: + support: none options: integration_key: description: @@ -78,8 +87,6 @@ options: required: false default: true type: bool -notes: - - Supports C(check_mode). Note that check mode simply does nothing except returning C(changed=true) in case the I(url) seems to be correct. ''' EXAMPLES = ''' diff --git a/plugins/modules/pagerduty_user.py b/plugins/modules/pagerduty_user.py index e16fe59e76..9c9805bff3 100644 --- a/plugins/modules/pagerduty_user.py +++ b/plugins/modules/pagerduty_user.py @@ -19,6 +19,13 @@ author: Zainab Alsaffar (@zanssa) requirements: - pdpyras python module = 4.1.1 - PagerDuty API Access +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: access_token: description: @@ -56,8 +63,6 @@ options: - Required if I(state=present). type: list elements: str -notes: - - Supports C(check_mode). ''' EXAMPLES = r''' diff --git a/plugins/modules/rundeck_acl_policy.py b/plugins/modules/rundeck_acl_policy.py index 4830c44784..4f7e3ab8dc 100644 --- a/plugins/modules/rundeck_acl_policy.py +++ b/plugins/modules/rundeck_acl_policy.py @@ -19,6 +19,11 @@ short_description: Manage Rundeck ACL policies description: - Create, update and remove Rundeck ACL policies through HTTP API. author: "Loic Blot (@nerzhul)" +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: type: str @@ -76,7 +81,9 @@ options: version_added: '0.2.0' validate_certs: version_added: '0.2.0' -extends_documentation_fragment: url +extends_documentation_fragment: + - ansible.builtin.url + - community.general.attributes ''' EXAMPLES = ''' diff --git a/plugins/modules/rundeck_job_run.py b/plugins/modules/rundeck_job_run.py index 0416d86fa7..894f1bb6f9 100644 --- a/plugins/modules/rundeck_job_run.py +++ b/plugins/modules/rundeck_job_run.py @@ -17,6 +17,11 @@ description: - This module runs a Rundeck job specified by ID. author: "Phillipe Smith (@phsmith)" version_added: 3.8.0 +attributes: + check_mode: + support: none + diff_mode: + support: none options: job_id: type: str @@ -68,7 +73,8 @@ options: default: false extends_documentation_fragment: - community.general.rundeck - - url + - ansible.builtin.url + - community.general.attributes ''' EXAMPLES = ''' diff --git a/plugins/modules/rundeck_project.py b/plugins/modules/rundeck_project.py index 2039a00a02..2065a7d936 100644 --- a/plugins/modules/rundeck_project.py +++ b/plugins/modules/rundeck_project.py @@ -21,6 +21,11 @@ short_description: Manage Rundeck projects description: - Create and remove Rundeck projects through HTTP API. author: "Loic Blot (@nerzhul)" +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: type: str @@ -67,7 +72,9 @@ options: version_added: '0.2.0' validate_certs: version_added: '0.2.0' -extends_documentation_fragment: url +extends_documentation_fragment: + - ansible.builtin.url + - community.general.attributes ''' EXAMPLES = ''' diff --git a/plugins/modules/sensu_check.py b/plugins/modules/sensu_check.py index 07b7a060e1..1ac2316a84 100644 --- a/plugins/modules/sensu_check.py +++ b/plugins/modules/sensu_check.py @@ -18,6 +18,13 @@ description: - Most options do not have a default and will not be added to the check definition unless specified. - All defaults except I(path), I(state), I(backup) and I(metric) are not managed by this module, - they are simply specified for your convenience. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: type: str diff --git a/plugins/modules/sensu_client.py b/plugins/modules/sensu_client.py index ffd1fe9fbd..2e0bd12eec 100644 --- a/plugins/modules/sensu_client.py +++ b/plugins/modules/sensu_client.py @@ -16,6 +16,13 @@ short_description: Manages Sensu client configuration description: - Manages Sensu client configuration. - 'For more information, refer to the Sensu documentation: U(https://sensuapp.org/docs/latest/reference/clients.html)' +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: type: str diff --git a/plugins/modules/sensu_handler.py b/plugins/modules/sensu_handler.py index 15e63e57d3..bbb8dc6129 100644 --- a/plugins/modules/sensu_handler.py +++ b/plugins/modules/sensu_handler.py @@ -16,6 +16,13 @@ short_description: Manages Sensu handler configuration description: - Manages Sensu handler configuration - 'For more information, refer to the Sensu documentation: U(https://sensuapp.org/docs/latest/reference/handlers.html)' +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: type: str diff --git a/plugins/modules/sensu_silence.py b/plugins/modules/sensu_silence.py index c5ed10e36d..14c664755d 100644 --- a/plugins/modules/sensu_silence.py +++ b/plugins/modules/sensu_silence.py @@ -17,6 +17,13 @@ short_description: Manage Sensu silence entries description: - Create and clear (delete) a silence entries via the Sensu API for subscriptions and checks. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: check: type: str diff --git a/plugins/modules/sensu_subscription.py b/plugins/modules/sensu_subscription.py index a84d805221..0077e2ffa6 100644 --- a/plugins/modules/sensu_subscription.py +++ b/plugins/modules/sensu_subscription.py @@ -15,6 +15,13 @@ module: sensu_subscription short_description: Manage Sensu subscriptions description: - Manage which I(sensu channels) a machine should subscribe to +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: type: str From 5b9ee78610bceef072131cd35e990ca3f09dd62e Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Fri, 24 Feb 2023 09:24:13 +0100 Subject: [PATCH 0192/1810] Add attributes to aix and ibm modules (#5959) Add attributes to aix and ibm modules. --- plugins/modules/aix_devices.py | 7 +++++++ plugins/modules/aix_filesystem.py | 7 +++++++ plugins/modules/aix_inittab.py | 9 ++++++++- plugins/modules/aix_lvg.py | 11 +++++++++-- plugins/modules/aix_lvol.py | 7 +++++++ plugins/modules/ibm_sa_domain.py | 10 ++++++++-- plugins/modules/ibm_sa_host.py | 10 ++++++++-- plugins/modules/ibm_sa_host_ports.py | 9 ++++++++- plugins/modules/ibm_sa_pool.py | 10 ++++++++-- plugins/modules/ibm_sa_vol.py | 10 ++++++++-- plugins/modules/ibm_sa_vol_map.py | 10 ++++++++-- 11 files changed, 86 insertions(+), 14 deletions(-) diff --git a/plugins/modules/aix_devices.py b/plugins/modules/aix_devices.py index be23937baa..721c36d6aa 100644 --- a/plugins/modules/aix_devices.py +++ b/plugins/modules/aix_devices.py @@ -16,6 +16,13 @@ module: aix_devices short_description: Manages AIX devices description: - This module discovers, defines, removes and modifies attributes of AIX devices. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: attributes: description: diff --git a/plugins/modules/aix_filesystem.py b/plugins/modules/aix_filesystem.py index 77d065a59a..b1f363a937 100644 --- a/plugins/modules/aix_filesystem.py +++ b/plugins/modules/aix_filesystem.py @@ -19,6 +19,13 @@ description: - This module creates, removes, mount and unmount LVM and NFS file system for AIX using C(/etc/filesystems). - For LVM file systems is possible to resize a file system. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: account_subsystem: description: diff --git a/plugins/modules/aix_inittab.py b/plugins/modules/aix_inittab.py index 57ef4758cb..c2c9681895 100644 --- a/plugins/modules/aix_inittab.py +++ b/plugins/modules/aix_inittab.py @@ -11,11 +11,18 @@ __metaclass__ = type DOCUMENTATION = r''' --- author: -- Joris Weijters (@molekuul) + - Joris Weijters (@molekuul) module: aix_inittab short_description: Manages the inittab on AIX description: - Manages the inittab on AIX. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/aix_lvg.py b/plugins/modules/aix_lvg.py index 44ad631236..d89c43de4b 100644 --- a/plugins/modules/aix_lvg.py +++ b/plugins/modules/aix_lvg.py @@ -11,11 +11,18 @@ __metaclass__ = type DOCUMENTATION = r''' --- author: -- Kairo Araujo (@kairoaraujo) + - Kairo Araujo (@kairoaraujo) module: aix_lvg short_description: Manage LVM volume groups on AIX description: -- This module creates, removes or resize volume groups on AIX LVM. + - This module creates, removes or resize volume groups on AIX LVM. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: force: description: diff --git a/plugins/modules/aix_lvol.py b/plugins/modules/aix_lvol.py index 6219bdb8e3..0a4a6eff53 100644 --- a/plugins/modules/aix_lvol.py +++ b/plugins/modules/aix_lvol.py @@ -17,6 +17,13 @@ module: aix_lvol short_description: Configure AIX LVM logical volumes description: - This module creates, removes or resizes AIX logical volumes. Inspired by lvol module. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: vg: description: diff --git a/plugins/modules/ibm_sa_domain.py b/plugins/modules/ibm_sa_domain.py index 26e4b7e47c..774f29134c 100644 --- a/plugins/modules/ibm_sa_domain.py +++ b/plugins/modules/ibm_sa_domain.py @@ -18,6 +18,12 @@ short_description: Manages domains on IBM Spectrum Accelerate Family storage sys description: - "This module can be used to add domains to or removes them from IBM Spectrum Accelerate Family storage systems." +attributes: + check_mode: + support: none + diff_mode: + support: none + options: domain: description: @@ -82,8 +88,8 @@ options: type: str extends_documentation_fragment: -- community.general.ibm_storage - + - community.general.ibm_storage + - community.general.attributes author: - Tzur Eliyahu (@tzure) diff --git a/plugins/modules/ibm_sa_host.py b/plugins/modules/ibm_sa_host.py index 961e1bba19..614865ae01 100644 --- a/plugins/modules/ibm_sa_host.py +++ b/plugins/modules/ibm_sa_host.py @@ -18,6 +18,12 @@ short_description: Adds hosts to or removes them from IBM Spectrum Accelerate Fa description: - "This module adds hosts to or removes them from IBM Spectrum Accelerate Family storage systems." +attributes: + check_mode: + support: none + diff_mode: + support: none + options: host: description: @@ -56,8 +62,8 @@ options: type: str extends_documentation_fragment: -- community.general.ibm_storage - + - community.general.ibm_storage + - community.general.attributes author: - Tzur Eliyahu (@tzure) diff --git a/plugins/modules/ibm_sa_host_ports.py b/plugins/modules/ibm_sa_host_ports.py index fc543053a7..fdb27f85a2 100644 --- a/plugins/modules/ibm_sa_host_ports.py +++ b/plugins/modules/ibm_sa_host_ports.py @@ -19,6 +19,12 @@ description: - "This module adds ports to or removes them from the hosts on IBM Spectrum Accelerate Family storage systems." +attributes: + check_mode: + support: none + diff_mode: + support: none + options: host: description: @@ -48,7 +54,8 @@ options: type: str extends_documentation_fragment: -- community.general.ibm_storage + - community.general.ibm_storage + - community.general.attributes author: - Tzur Eliyahu (@tzure) diff --git a/plugins/modules/ibm_sa_pool.py b/plugins/modules/ibm_sa_pool.py index 998f3f74be..88065aa4ec 100644 --- a/plugins/modules/ibm_sa_pool.py +++ b/plugins/modules/ibm_sa_pool.py @@ -18,6 +18,12 @@ short_description: Handles pools on IBM Spectrum Accelerate Family storage syste description: - "This module creates or deletes pools to be used on IBM Spectrum Accelerate Family storage systems" +attributes: + check_mode: + support: none + diff_mode: + support: none + options: pool: description: @@ -52,8 +58,8 @@ options: type: str extends_documentation_fragment: -- community.general.ibm_storage - + - community.general.ibm_storage + - community.general.attributes author: - Tzur Eliyahu (@tzure) diff --git a/plugins/modules/ibm_sa_vol.py b/plugins/modules/ibm_sa_vol.py index 115ac9169f..bc5f81b32f 100644 --- a/plugins/modules/ibm_sa_vol.py +++ b/plugins/modules/ibm_sa_vol.py @@ -18,6 +18,12 @@ short_description: Handle volumes on IBM Spectrum Accelerate Family storage syst description: - "This module creates or deletes volumes to be used on IBM Spectrum Accelerate Family storage systems." +attributes: + check_mode: + support: none + diff_mode: + support: none + options: vol: description: @@ -42,8 +48,8 @@ options: type: str extends_documentation_fragment: -- community.general.ibm_storage - + - community.general.ibm_storage + - community.general.attributes author: - Tzur Eliyahu (@tzure) diff --git a/plugins/modules/ibm_sa_vol_map.py b/plugins/modules/ibm_sa_vol_map.py index f493a2d979..ea8b485ef1 100644 --- a/plugins/modules/ibm_sa_vol_map.py +++ b/plugins/modules/ibm_sa_vol_map.py @@ -19,6 +19,12 @@ description: - "This module maps volumes to or unmaps them from the hosts on IBM Spectrum Accelerate Family storage systems." +attributes: + check_mode: + support: none + diff_mode: + support: none + options: vol: description: @@ -55,8 +61,8 @@ options: type: str extends_documentation_fragment: -- community.general.ibm_storage - + - community.general.ibm_storage + - community.general.attributes author: - Tzur Eliyahu (@tzure) From 673c79f6d9744595ddbef21c2754ab88603ab456 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Fri, 24 Feb 2023 09:24:37 +0100 Subject: [PATCH 0193/1810] Add attributes to apache2, cobbler, dimensiondata, icinga2, lxca, pritunl, and spectrum modules (#5963) Add attributes to apache2, cobbler, dimensiondata, icinga2, lxca, pritunl, and spectrum modules. --- plugins/modules/apache2_mod_proxy.py | 7 +++++++ plugins/modules/apache2_module.py | 7 +++++++ plugins/modules/cobbler_sync.py | 9 ++++++++- plugins/modules/cobbler_system.py | 9 ++++++++- plugins/modules/dimensiondata_network.py | 10 ++++++++-- plugins/modules/dimensiondata_vlan.py | 10 ++++++++-- plugins/modules/icinga2_feature.py | 7 +++++++ plugins/modules/icinga2_host.py | 8 +++++++- plugins/modules/lxca_cmms.py | 9 ++++++++- plugins/modules/lxca_nodes.py | 9 ++++++++- plugins/modules/pritunl_org.py | 6 ++++++ plugins/modules/pritunl_user.py | 6 ++++++ plugins/modules/spectrum_device.py | 11 +++++++++-- plugins/modules/spectrum_model_attrs.py | 7 +++++++ 14 files changed, 104 insertions(+), 11 deletions(-) diff --git a/plugins/modules/apache2_mod_proxy.py b/plugins/modules/apache2_mod_proxy.py index 70ab5a42ed..8f561e8ae0 100644 --- a/plugins/modules/apache2_mod_proxy.py +++ b/plugins/modules/apache2_mod_proxy.py @@ -20,6 +20,13 @@ description: status page has to be enabled and accessible, as this module relies on parsing this page. This module supports ansible check_mode, and requires BeautifulSoup python module. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: balancer_url_suffix: type: str diff --git a/plugins/modules/apache2_module.py b/plugins/modules/apache2_module.py index e6998ad3f5..2e2456d741 100644 --- a/plugins/modules/apache2_module.py +++ b/plugins/modules/apache2_module.py @@ -19,6 +19,13 @@ author: short_description: Enables/disables a module of the Apache2 webserver description: - Enables or disables a specified module of the Apache2 webserver. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: type: str diff --git a/plugins/modules/cobbler_sync.py b/plugins/modules/cobbler_sync.py index 5e7082ddf5..d7acf4be6a 100644 --- a/plugins/modules/cobbler_sync.py +++ b/plugins/modules/cobbler_sync.py @@ -13,7 +13,14 @@ DOCUMENTATION = r''' module: cobbler_sync short_description: Sync Cobbler description: -- Sync Cobbler to commit changes. + - Sync Cobbler to commit changes. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: host: description: diff --git a/plugins/modules/cobbler_system.py b/plugins/modules/cobbler_system.py index 973478b627..c30b4f1c12 100644 --- a/plugins/modules/cobbler_system.py +++ b/plugins/modules/cobbler_system.py @@ -13,7 +13,14 @@ DOCUMENTATION = r''' module: cobbler_system short_description: Manage system objects in Cobbler description: -- Add, modify or remove systems in Cobbler + - Add, modify or remove systems in Cobbler +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: full options: host: description: diff --git a/plugins/modules/dimensiondata_network.py b/plugins/modules/dimensiondata_network.py index d88b4a9339..8c1469063c 100644 --- a/plugins/modules/dimensiondata_network.py +++ b/plugins/modules/dimensiondata_network.py @@ -19,12 +19,18 @@ DOCUMENTATION = ''' module: dimensiondata_network short_description: Create, update, and delete MCP 1.0 & 2.0 networks extends_documentation_fragment: -- community.general.dimensiondata -- community.general.dimensiondata_wait + - community.general.dimensiondata + - community.general.dimensiondata_wait + - community.general.attributes description: - Create, update, and delete MCP 1.0 & 2.0 networks author: 'Aimon Bustardo (@aimonb)' +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/dimensiondata_vlan.py b/plugins/modules/dimensiondata_vlan.py index 86db5e5057..7d83ddc696 100644 --- a/plugins/modules/dimensiondata_vlan.py +++ b/plugins/modules/dimensiondata_vlan.py @@ -15,12 +15,18 @@ DOCUMENTATION = ''' module: dimensiondata_vlan short_description: Manage a VLAN in a Cloud Control network domain extends_documentation_fragment: -- community.general.dimensiondata -- community.general.dimensiondata_wait + - community.general.dimensiondata + - community.general.dimensiondata_wait + - community.general.attributes description: - Manage VLANs in Cloud Control network domains. author: 'Adam Friedman (@tintoy)' +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/icinga2_feature.py b/plugins/modules/icinga2_feature.py index 2f1d5629d5..6e6bc54161 100644 --- a/plugins/modules/icinga2_feature.py +++ b/plugins/modules/icinga2_feature.py @@ -21,6 +21,13 @@ short_description: Manage Icinga2 feature description: - This module can be used to enable or disable an Icinga2 feature. author: "Loic Blot (@nerzhul)" +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: type: str diff --git a/plugins/modules/icinga2_host.py b/plugins/modules/icinga2_host.py index 0f4e2b26a0..a740e68754 100644 --- a/plugins/modules/icinga2_host.py +++ b/plugins/modules/icinga2_host.py @@ -19,6 +19,11 @@ description: - "Add or remove a host to Icinga2 through the API." - "See U(https://www.icinga.com/docs/icinga2/latest/doc/12-icinga2-api/)" author: "Jurgen Brand (@t794104)" +attributes: + check_mode: + support: full + diff_mode: + support: none options: url: type: str @@ -107,7 +112,8 @@ options: description: - Dictionary of variables. extends_documentation_fragment: - - url + - ansible.builtin.url + - community.general.attributes ''' EXAMPLES = ''' diff --git a/plugins/modules/lxca_cmms.py b/plugins/modules/lxca_cmms.py index 0941b4521e..1f811a7efa 100644 --- a/plugins/modules/lxca_cmms.py +++ b/plugins/modules/lxca_cmms.py @@ -18,6 +18,12 @@ short_description: Custom module for lxca cmms inventory utility description: - This module returns/displays a inventory details of cmms +attributes: + check_mode: + support: none + diff_mode: + support: none + options: uuid: description: @@ -40,7 +46,8 @@ options: type: str extends_documentation_fragment: -- community.general.lxca_common + - community.general.lxca_common + - community.general.attributes ''' diff --git a/plugins/modules/lxca_nodes.py b/plugins/modules/lxca_nodes.py index b3445b1c0b..3b37322edb 100644 --- a/plugins/modules/lxca_nodes.py +++ b/plugins/modules/lxca_nodes.py @@ -18,6 +18,12 @@ short_description: Custom module for lxca nodes inventory utility description: - This module returns/displays a inventory details of nodes +attributes: + check_mode: + support: none + diff_mode: + support: none + options: uuid: description: @@ -42,7 +48,8 @@ options: type: str extends_documentation_fragment: -- community.general.lxca_common + - community.general.lxca_common + - community.general.attributes ''' diff --git a/plugins/modules/pritunl_org.py b/plugins/modules/pritunl_org.py index 4a6a8a3444..df2df4494d 100644 --- a/plugins/modules/pritunl_org.py +++ b/plugins/modules/pritunl_org.py @@ -18,6 +18,12 @@ description: - A module to manage Pritunl organizations using the Pritunl API. extends_documentation_fragment: - community.general.pritunl + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: type: str diff --git a/plugins/modules/pritunl_user.py b/plugins/modules/pritunl_user.py index f3feb94eed..5aac233930 100644 --- a/plugins/modules/pritunl_user.py +++ b/plugins/modules/pritunl_user.py @@ -18,6 +18,12 @@ description: - A module to manage Pritunl users using the Pritunl API. extends_documentation_fragment: - community.general.pritunl + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: organization: type: str diff --git a/plugins/modules/spectrum_device.py b/plugins/modules/spectrum_device.py index 40093aa3a9..5cfc076641 100644 --- a/plugins/modules/spectrum_device.py +++ b/plugins/modules/spectrum_device.py @@ -14,9 +14,16 @@ DOCUMENTATION = ''' module: spectrum_device short_description: Creates/deletes devices in CA Spectrum description: - - This module allows you to create and delete devices in CA Spectrum U(https://www.ca.com/us/products/ca-spectrum.html). - - Tested on CA Spectrum 9.4.2, 10.1.1 and 10.2.1 + - This module allows you to create and delete devices in CA Spectrum U(https://www.ca.com/us/products/ca-spectrum.html). + - Tested on CA Spectrum 9.4.2, 10.1.1 and 10.2.1 author: "Renato Orgito (@orgito)" +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: device: type: str diff --git a/plugins/modules/spectrum_model_attrs.py b/plugins/modules/spectrum_model_attrs.py index de771b0ad3..028ad7f9f3 100644 --- a/plugins/modules/spectrum_model_attrs.py +++ b/plugins/modules/spectrum_model_attrs.py @@ -23,6 +23,13 @@ notes: - Model creation and deletion are not possible with this module. For that use M(community.general.spectrum_device) instead. requirements: - 'python >= 2.7' +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: url: description: From 51394b55a06a15144b370270afd0f5119b8c1168 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Fri, 24 Feb 2023 09:24:50 +0100 Subject: [PATCH 0194/1810] Add attributes to some messaging modules (#5962) Add attributes to some messaging modules. --- plugins/modules/campfire.py | 7 +++++++ plugins/modules/cisco_webex.py | 8 ++++++++ plugins/modules/discord.py | 7 +++++++ plugins/modules/hipchat.py | 7 +++++++ plugins/modules/irc.py | 9 ++++++++- plugins/modules/jabber.py | 9 ++++++++- plugins/modules/librato_annotation.py | 7 +++++++ plugins/modules/logentries.py | 7 +++++++ plugins/modules/logentries_msg.py | 11 ++++++++--- plugins/modules/mail.py | 7 +++++++ plugins/modules/matrix.py | 7 +++++++ plugins/modules/mattermost.py | 7 +++++++ plugins/modules/rocketchat.py | 7 +++++++ plugins/modules/say.py | 19 +++++++++++++------ plugins/modules/sendgrid.py | 27 +++++++++++++++++---------- plugins/modules/slack.py | 9 ++++++++- plugins/modules/syslogger.py | 7 +++++++ plugins/modules/taiga_issue.py | 7 +++++++ plugins/modules/telegram.py | 7 +++++++ plugins/modules/twilio.py | 23 +++++++++++++++-------- plugins/modules/typetalk.py | 7 +++++++ 21 files changed, 176 insertions(+), 30 deletions(-) diff --git a/plugins/modules/campfire.py b/plugins/modules/campfire.py index dfc9af1ce1..1e0f1ecea4 100644 --- a/plugins/modules/campfire.py +++ b/plugins/modules/campfire.py @@ -16,6 +16,13 @@ short_description: Send a message to Campfire description: - Send a message to Campfire. - Messages with newlines will result in a "Paste" message being sent. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: subscription: type: str diff --git a/plugins/modules/cisco_webex.py b/plugins/modules/cisco_webex.py index 95fcccb7d6..2e5cb50ea0 100644 --- a/plugins/modules/cisco_webex.py +++ b/plugins/modules/cisco_webex.py @@ -20,6 +20,14 @@ notes: - The C(recipient_id) type must be valid for the supplied C(recipient_id). - Full API documentation can be found at U(https://developer.webex.com/docs/api/basics). +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none + options: recipient_type: diff --git a/plugins/modules/discord.py b/plugins/modules/discord.py index 9df00ad7dd..8b5391d44b 100644 --- a/plugins/modules/discord.py +++ b/plugins/modules/discord.py @@ -20,6 +20,13 @@ seealso: - name: API documentation description: Documentation for Discord API link: https://discord.com/developers/docs/resources/webhook#execute-webhook +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: webhook_id: description: diff --git a/plugins/modules/hipchat.py b/plugins/modules/hipchat.py index a5aa150f32..11b5fb7358 100644 --- a/plugins/modules/hipchat.py +++ b/plugins/modules/hipchat.py @@ -15,6 +15,13 @@ module: hipchat short_description: Send a message to Hipchat description: - Send a message to a Hipchat room, with options to control the formatting. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: token: type: str diff --git a/plugins/modules/irc.py b/plugins/modules/irc.py index f45d610da7..6cd7bc1203 100644 --- a/plugins/modules/irc.py +++ b/plugins/modules/irc.py @@ -14,7 +14,14 @@ DOCUMENTATION = ''' module: irc short_description: Send a message to an IRC channel or a nick description: - - Send a message to an IRC channel or a nick. This is a very simplistic implementation. + - Send a message to an IRC channel or a nick. This is a very simplistic implementation. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: server: type: str diff --git a/plugins/modules/jabber.py b/plugins/modules/jabber.py index 110b618d77..650b29957d 100644 --- a/plugins/modules/jabber.py +++ b/plugins/modules/jabber.py @@ -14,7 +14,14 @@ DOCUMENTATION = ''' module: jabber short_description: Send a message to jabber user or chat room description: - - Send a message to jabber + - Send a message to jabber +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: user: type: str diff --git a/plugins/modules/librato_annotation.py b/plugins/modules/librato_annotation.py index 70e17cfef4..ebfb751546 100644 --- a/plugins/modules/librato_annotation.py +++ b/plugins/modules/librato_annotation.py @@ -17,6 +17,13 @@ description: - Create an annotation event on the given annotation stream :name. If the annotation stream does not exist, it will be created automatically author: "Seth Edwards (@Sedward)" requirements: [] +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: user: type: str diff --git a/plugins/modules/logentries.py b/plugins/modules/logentries.py index a605c41316..f177cf4546 100644 --- a/plugins/modules/logentries.py +++ b/plugins/modules/logentries.py @@ -16,6 +16,13 @@ author: "Ivan Vanderbyl (@ivanvanderbyl)" short_description: Module for tracking logs via logentries.com description: - Sends logs to LogEntries in realtime +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: path: type: str diff --git a/plugins/modules/logentries_msg.py b/plugins/modules/logentries_msg.py index 723273165f..03851ad1f4 100644 --- a/plugins/modules/logentries_msg.py +++ b/plugins/modules/logentries_msg.py @@ -14,9 +14,14 @@ DOCUMENTATION = ''' module: logentries_msg short_description: Send a message to logentries description: - - Send a message to logentries -requirements: - - "python >= 2.6" + - Send a message to logentries +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: token: type: str diff --git a/plugins/modules/mail.py b/plugins/modules/mail.py index 9d01fc59a7..feaac69233 100644 --- a/plugins/modules/mail.py +++ b/plugins/modules/mail.py @@ -28,6 +28,13 @@ description: - Of course sending out a mail can be equally useful as a way to notify one or more people in a team that a specific action has been (successfully) taken. +extends_documentation_fragment: +- community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: sender: description: diff --git a/plugins/modules/matrix.py b/plugins/modules/matrix.py index f339e76593..0b419c8d93 100644 --- a/plugins/modules/matrix.py +++ b/plugins/modules/matrix.py @@ -15,6 +15,13 @@ module: matrix short_description: Send notifications to matrix description: - This module sends html formatted notifications to matrix rooms. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: msg_plain: type: str diff --git a/plugins/modules/mattermost.py b/plugins/modules/mattermost.py index b3fe6b5680..29894c3a7c 100644 --- a/plugins/modules/mattermost.py +++ b/plugins/modules/mattermost.py @@ -21,6 +21,13 @@ short_description: Send Mattermost notifications description: - Sends notifications to U(http://your.mattermost.url) via the Incoming WebHook integration. author: "Benjamin Jolivot (@bjolivot)" +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: url: type: str diff --git a/plugins/modules/rocketchat.py b/plugins/modules/rocketchat.py index 02458ed232..23d6d529e7 100644 --- a/plugins/modules/rocketchat.py +++ b/plugins/modules/rocketchat.py @@ -18,6 +18,13 @@ short_description: Send notifications to Rocket Chat description: - The C(rocketchat) module sends notifications to Rocket Chat via the Incoming WebHook integration author: "Ramon de la Fuente (@ramondelafuente)" +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: domain: type: str diff --git a/plugins/modules/say.py b/plugins/modules/say.py index 04b5027cae..175e5feb0b 100644 --- a/plugins/modules/say.py +++ b/plugins/modules/say.py @@ -14,21 +14,28 @@ DOCUMENTATION = ''' module: say short_description: Makes a computer to speak description: - - makes a computer speak! Amuse your friends, annoy your coworkers! + - makes a computer speak! Amuse your friends, annoy your coworkers! notes: - - In 2.5, this module has been renamed from C(osx_say) to M(community.general.say). - - If you like this module, you may also be interested in the osx_say callback plugin. - - A list of available voices, with language, can be found by running C(say -v ?) on a OSX host and C(espeak --voices) on a Linux host. + - In 2.5, this module has been renamed from C(osx_say) to M(community.general.say). + - If you like this module, you may also be interested in the osx_say callback plugin. + - A list of available voices, with language, can be found by running C(say -v ?) on a OSX host and C(espeak --voices) on a Linux host. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: msg: type: str description: - What to say + - What to say. required: true voice: type: str description: - What voice to use + - What voice to use. required: false requirements: [ say or espeak or espeak-ng ] author: diff --git a/plugins/modules/sendgrid.py b/plugins/modules/sendgrid.py index d2a52e5f0e..2c0cc9a5b2 100644 --- a/plugins/modules/sendgrid.py +++ b/plugins/modules/sendgrid.py @@ -14,19 +14,26 @@ DOCUMENTATION = r''' module: sendgrid short_description: Sends an email with the SendGrid API description: - - "Sends an email with a SendGrid account through their API, not through - the SMTP service." + - "Sends an email with a SendGrid account through their API, not through + the SMTP service." notes: - - "This module is non-idempotent because it sends an email through the - external API. It is idempotent only in the case that the module fails." - - "Like the other notification modules, this one requires an external - dependency to work. In this case, you'll need an active SendGrid - account." - - "In order to use api_key, cc, bcc, attachments, from_name, html_body, headers - you must pip install sendgrid" - - "since 2.2 I(username) and I(password) are not required if you supply an I(api_key)" + - "This module is non-idempotent because it sends an email through the + external API. It is idempotent only in the case that the module fails." + - "Like the other notification modules, this one requires an external + dependency to work. In this case, you'll need an active SendGrid + account." + - "In order to use api_key, cc, bcc, attachments, from_name, html_body, headers + you must pip install sendgrid" + - "since 2.2 I(username) and I(password) are not required if you supply an I(api_key)" requirements: - sendgrid Python library 1.6.22 or lower (Sendgrid API V2 supported) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: username: type: str diff --git a/plugins/modules/slack.py b/plugins/modules/slack.py index c1ae865cde..4e26f1973c 100644 --- a/plugins/modules/slack.py +++ b/plugins/modules/slack.py @@ -19,8 +19,15 @@ DOCUMENTATION = """ module: slack short_description: Send Slack notifications description: - - The C(slack) module sends notifications to U(http://slack.com) via the Incoming WebHook integration + - The C(slack) module sends notifications to U(http://slack.com) via the Incoming WebHook integration author: "Ramon de la Fuente (@ramondelafuente)" +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: domain: type: str diff --git a/plugins/modules/syslogger.py b/plugins/modules/syslogger.py index 5fc21a9dc1..3a7abf4fbe 100644 --- a/plugins/modules/syslogger.py +++ b/plugins/modules/syslogger.py @@ -13,6 +13,13 @@ module: syslogger short_description: Log messages in the syslog description: - Uses syslog to add log entries to the host. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: msg: type: str diff --git a/plugins/modules/taiga_issue.py b/plugins/modules/taiga_issue.py index 25f6557ea2..e80ff43b89 100644 --- a/plugins/modules/taiga_issue.py +++ b/plugins/modules/taiga_issue.py @@ -17,6 +17,13 @@ description: - Creates/deletes an issue in a Taiga Project Management Platform (U(https://taiga.io)). - An issue is identified by the combination of project, issue subject and issue type. - This module implements the creation or deletion of issues (not the update). +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: taiga_host: type: str diff --git a/plugins/modules/telegram.py b/plugins/modules/telegram.py index 4e89825120..d13e90fd5c 100644 --- a/plugins/modules/telegram.py +++ b/plugins/modules/telegram.py @@ -23,6 +23,13 @@ description: - Also, the user may try to use any other telegram bot API method, if you specify I(api_method) argument. notes: - You will require a telegram account and create telegram bot to use this module. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: token: type: str diff --git a/plugins/modules/twilio.py b/plugins/modules/twilio.py index 6d22563d1c..270320c465 100644 --- a/plugins/modules/twilio.py +++ b/plugins/modules/twilio.py @@ -21,39 +21,46 @@ notes: - Like the other notification modules, this one requires an external dependency to work. In this case, you'll need a Twilio account with a purchased or verified phone number to send the text message. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: account_sid: type: str description: - user's Twilio account token found on the account page + - User's Twilio account token found on the account page. required: true auth_token: type: str - description: user's Twilio authentication token + description: + - User's Twilio authentication token. required: true msg: type: str description: - the body of the text message + - The body of the text message. required: true to_numbers: type: list elements: str description: - one or more phone numbers to send the text message to, - format +15551112222 + - One or more phone numbers to send the text message to, format C(+15551112222). required: true aliases: [ to_number ] from_number: type: str description: - the Twilio number to send the text message from, format +15551112222 + - The Twilio number to send the text message from, format C(+15551112222). required: true media_url: type: str description: - a URL with a picture, video or sound clip to send with an MMS - (multimedia message) instead of a plain SMS + - A URL with a picture, video or sound clip to send with an MMS + (multimedia message) instead of a plain SMS. required: false author: "Matt Makai (@makaimc)" diff --git a/plugins/modules/typetalk.py b/plugins/modules/typetalk.py index 5fe2baa916..ddf9f35605 100644 --- a/plugins/modules/typetalk.py +++ b/plugins/modules/typetalk.py @@ -15,6 +15,13 @@ module: typetalk short_description: Send a message to typetalk description: - Send a message to typetalk using typetalk API +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: client_id: type: str From 3b97fad577cd3aede773b6c7032e32ea5ea2ca69 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Fri, 24 Feb 2023 09:25:15 +0100 Subject: [PATCH 0195/1810] Add attributes to some filesystem modules (#5960) Add attributes to some filesystem modules. --- plugins/modules/beadm.py | 7 +++++++ plugins/modules/filesize.py | 10 +++++++--- plugins/modules/filesystem.py | 8 +++++++- plugins/modules/lvg.py | 7 +++++++ plugins/modules/lvol.py | 7 +++++++ plugins/modules/parted.py | 7 +++++++ plugins/modules/xfs_quota.py | 9 ++++++++- plugins/modules/zfs.py | 19 +++++++++++++------ plugins/modules/zfs_delegate_admin.py | 7 +++++++ 9 files changed, 70 insertions(+), 11 deletions(-) diff --git a/plugins/modules/beadm.py b/plugins/modules/beadm.py index 7a84997089..8857fd8464 100644 --- a/plugins/modules/beadm.py +++ b/plugins/modules/beadm.py @@ -17,6 +17,13 @@ description: - Create, delete or activate ZFS boot environments. - Mount and unmount ZFS boot environments. author: Adam Števko (@xen0l) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/filesize.py b/plugins/modules/filesize.py index a8c47d70fd..b3eb90d611 100644 --- a/plugins/modules/filesize.py +++ b/plugins/modules/filesize.py @@ -25,6 +25,12 @@ author: version_added: "3.0.0" +attributes: + check_mode: + support: full + diff_mode: + support: full + options: path: description: @@ -93,14 +99,12 @@ options: - This option is silently ignored. This module always modifies file size in-place. -notes: - - This module supports C(check_mode) and C(diff). - requirements: - dd (Data Duplicator) in PATH extends_documentation_fragment: - ansible.builtin.files + - community.general.attributes seealso: - name: dd(1) manpage for Linux diff --git a/plugins/modules/filesystem.py b/plugins/modules/filesystem.py index 4dcfddee23..0e6b815b4e 100644 --- a/plugins/modules/filesystem.py +++ b/plugins/modules/filesystem.py @@ -19,6 +19,13 @@ module: filesystem short_description: Makes a filesystem description: - This module creates a filesystem. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: state: description: @@ -87,7 +94,6 @@ notes: a C(blkid) command that is compatible with this module. However, these packages conflict with each other, and only the C(util-linux) package provides the command required to not fail when I(state=absent). - - This module supports I(check_mode). seealso: - module: community.general.filesize - module: ansible.posix.mount diff --git a/plugins/modules/lvg.py b/plugins/modules/lvg.py index ca38565f4a..60eaaa42b2 100644 --- a/plugins/modules/lvg.py +++ b/plugins/modules/lvg.py @@ -17,6 +17,13 @@ module: lvg short_description: Configure LVM volume groups description: - This module creates, removes or resizes volume groups. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: vg: description: diff --git a/plugins/modules/lvol.py b/plugins/modules/lvol.py index 4489258da5..d193a4e837 100644 --- a/plugins/modules/lvol.py +++ b/plugins/modules/lvol.py @@ -19,6 +19,13 @@ module: lvol short_description: Configure LVM logical volumes description: - This module creates, removes or resizes logical volumes. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: vg: type: str diff --git a/plugins/modules/parted.py b/plugins/modules/parted.py index ae5e7584d1..ec72bd6f00 100644 --- a/plugins/modules/parted.py +++ b/plugins/modules/parted.py @@ -24,6 +24,13 @@ requirements: - align option (except 'undefined') requires parted 2.1 and above - If the version of parted is below 3.1, it requires a Linux version running the sysfs file system C(/sys/). +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: device: description: The block device (disk) where to operate. diff --git a/plugins/modules/xfs_quota.py b/plugins/modules/xfs_quota.py index 5f71334c01..d01f3dc0e6 100644 --- a/plugins/modules/xfs_quota.py +++ b/plugins/modules/xfs_quota.py @@ -19,7 +19,14 @@ description: - Configure quotas on XFS filesystems. - Before using this module /etc/projects and /etc/projid need to be configured. author: -- William Leemans (@bushvin) + - William Leemans (@bushvin) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: type: description: diff --git a/plugins/modules/zfs.py b/plugins/modules/zfs.py index 84e5c05b1f..83b2a6edf8 100644 --- a/plugins/modules/zfs.py +++ b/plugins/modules/zfs.py @@ -15,6 +15,19 @@ module: zfs short_description: Manage zfs description: - Manages ZFS file systems, volumes, clones and snapshots +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: partial + details: + - In certain situations it may report a task as changed that will not be reported + as changed when C(check_mode) is disabled. + - For example, this might occur when the zpool C(altroot) option is set or when + a size is written using human-readable notation, such as C(1M) or C(1024K), + instead of as an unqualified byte count, such as C(1048576). + diff_mode: + support: full options: name: description: @@ -39,12 +52,6 @@ options: - See the zfs(8) man page for more information. type: dict default: {} -notes: - - C(check_mode) is supported, but in certain situations it may report a task - as changed that will not be reported as changed when C(check_mode) is disabled. - For example, this might occur when the zpool C(altroot) option is set or when - a size is written using human-readable notation, such as C(1M) or C(1024K), - instead of as an unqualified byte count, such as C(1048576). author: - Johan Wiren (@johanwiren) ''' diff --git a/plugins/modules/zfs_delegate_admin.py b/plugins/modules/zfs_delegate_admin.py index 36a213a0fe..7891c32672 100644 --- a/plugins/modules/zfs_delegate_admin.py +++ b/plugins/modules/zfs_delegate_admin.py @@ -20,6 +20,13 @@ description: requirements: - "A ZFS/OpenZFS implementation that supports delegation with C(zfs allow), including: Solaris >= 10, illumos (all versions), FreeBSD >= 8.0R, ZFS on Linux >= 0.7.0." +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: description: From 3ec2fde2c6e7d03a2a50f6a004a31e6c532930b1 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Fri, 24 Feb 2023 09:25:20 +0100 Subject: [PATCH 0196/1810] Add attributes to package manager modules (#5954) Add attributes to package manager modules. --- plugins/modules/ansible_galaxy_install.py | 7 ++++++ plugins/modules/apk.py | 7 ++++++ plugins/modules/apt_repo.py | 7 ++++++ plugins/modules/apt_rpm.py | 7 ++++++ plugins/modules/bower.py | 7 ++++++ plugins/modules/bundler.py | 7 ++++++ plugins/modules/cargo.py | 7 ++++++ plugins/modules/composer.py | 7 ++++++ plugins/modules/copr.py | 7 ++++++ plugins/modules/cpanm.py | 7 ++++++ plugins/modules/dnf_versionlock.py | 23 +++++++++++++------- plugins/modules/dpkg_divert.py | 9 ++++++-- plugins/modules/easy_install.py | 9 +++++++- plugins/modules/flatpak.py | 17 ++++++++++----- plugins/modules/flatpak_remote.py | 25 ++++++++++++++-------- plugins/modules/gem.py | 7 ++++++ plugins/modules/homebrew.py | 10 +++++++-- plugins/modules/homebrew_cask.py | 17 +++++++++------ plugins/modules/homebrew_tap.py | 7 ++++++ plugins/modules/installp.py | 9 +++++++- plugins/modules/layman.py | 7 ++++++ plugins/modules/macports.py | 7 ++++++ plugins/modules/npm.py | 7 ++++++ plugins/modules/openbsd_pkg.py | 13 ++++++++---- plugins/modules/opkg.py | 7 ++++++ plugins/modules/pacman.py | 7 ++++++ plugins/modules/pacman_key.py | 26 ++++++++++++++--------- plugins/modules/pear.py | 7 ++++++ plugins/modules/pipx.py | 7 ++++++ plugins/modules/pkg5.py | 7 ++++++ plugins/modules/pkg5_publisher.py | 7 ++++++ plugins/modules/pkgin.py | 7 ++++++ plugins/modules/pkgng.py | 7 ++++++ plugins/modules/pkgutil.py | 11 ++++++++-- plugins/modules/portage.py | 9 ++++++++ plugins/modules/portinstall.py | 7 ++++++ plugins/modules/rpm_ostree_pkg.py | 13 ++++++++---- plugins/modules/slackpkg.py | 7 ++++++ plugins/modules/snap.py | 7 ++++++ plugins/modules/snap_alias.py | 7 ++++++ plugins/modules/svr4pkg.py | 7 ++++++ plugins/modules/syspatch.py | 9 ++++++++ plugins/modules/sysupgrade.py | 7 ++++++ plugins/modules/xbps.py | 7 ++++++ plugins/modules/yarn.py | 7 ++++++ plugins/modules/yum_versionlock.py | 10 +++++++-- plugins/modules/zypper.py | 8 +++++++ plugins/modules/zypper_repository.py | 7 ++++++ 48 files changed, 386 insertions(+), 56 deletions(-) diff --git a/plugins/modules/ansible_galaxy_install.py b/plugins/modules/ansible_galaxy_install.py index 694591d8cb..0f38eabdf6 100644 --- a/plugins/modules/ansible_galaxy_install.py +++ b/plugins/modules/ansible_galaxy_install.py @@ -26,6 +26,13 @@ notes: If that one also fails, the module will fail. requirements: - Ansible 2.9, ansible-base 2.10, or ansible-core 2.11 or newer +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: type: description: diff --git a/plugins/modules/apk.py b/plugins/modules/apk.py index 831ab60749..e56b2165dd 100644 --- a/plugins/modules/apk.py +++ b/plugins/modules/apk.py @@ -19,6 +19,13 @@ short_description: Manages apk packages description: - Manages I(apk) packages for Alpine Linux. author: "Kevin Brebanov (@kbrebanov)" +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: available: description: diff --git a/plugins/modules/apt_repo.py b/plugins/modules/apt_repo.py index 2e9c9b109c..5560390271 100644 --- a/plugins/modules/apt_repo.py +++ b/plugins/modules/apt_repo.py @@ -19,6 +19,13 @@ description: notes: - This module works on ALT based distros. - Does NOT support checkmode, due to a limitation in apt-repo tool. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: repo: description: diff --git a/plugins/modules/apt_rpm.py b/plugins/modules/apt_rpm.py index d949a61e68..24d6fb13d4 100644 --- a/plugins/modules/apt_rpm.py +++ b/plugins/modules/apt_rpm.py @@ -17,6 +17,13 @@ module: apt_rpm short_description: APT-RPM package manager description: - Manages packages with I(apt-rpm). Both low-level (I(rpm)) and high-level (I(apt-get)) package manager binaries required. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: package: description: diff --git a/plugins/modules/bower.py b/plugins/modules/bower.py index 8964bd0434..1824e68bb8 100644 --- a/plugins/modules/bower.py +++ b/plugins/modules/bower.py @@ -16,6 +16,13 @@ short_description: Manage bower packages with bower description: - Manage bower packages with bower author: "Michael Warkentin (@mwarkentin)" +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: type: str diff --git a/plugins/modules/bundler.py b/plugins/modules/bundler.py index 5811fa720c..682dd334ac 100644 --- a/plugins/modules/bundler.py +++ b/plugins/modules/bundler.py @@ -15,6 +15,13 @@ module: bundler short_description: Manage Ruby Gem dependencies with Bundler description: - Manage installation and Gem version dependencies for Ruby using the Bundler gem +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: executable: type: str diff --git a/plugins/modules/cargo.py b/plugins/modules/cargo.py index 787edbd256..24be43741b 100644 --- a/plugins/modules/cargo.py +++ b/plugins/modules/cargo.py @@ -17,6 +17,13 @@ version_added: 4.3.0 description: - Manage Rust packages with cargo. author: "Radek Sprta (@radek-sprta)" +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/composer.py b/plugins/modules/composer.py index 34a15edda5..793abcda18 100644 --- a/plugins/modules/composer.py +++ b/plugins/modules/composer.py @@ -21,6 +21,13 @@ description: Composer is a tool for dependency management in PHP. It allows you to declare the dependent libraries your project needs and it will install them in your project for you. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: command: type: str diff --git a/plugins/modules/copr.py b/plugins/modules/copr.py index 68738a6c98..965c2a935d 100644 --- a/plugins/modules/copr.py +++ b/plugins/modules/copr.py @@ -20,6 +20,13 @@ requirements: - dnf-plugins-core notes: - Supports C(check_mode). +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: host: description: The Copr host to work with. diff --git a/plugins/modules/cpanm.py b/plugins/modules/cpanm.py index 98f37d573e..b3d63e1fb1 100644 --- a/plugins/modules/cpanm.py +++ b/plugins/modules/cpanm.py @@ -16,6 +16,13 @@ module: cpanm short_description: Manages Perl library dependencies description: - Manage Perl library dependencies using cpanminus. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: type: str diff --git a/plugins/modules/dnf_versionlock.py b/plugins/modules/dnf_versionlock.py index a0a440b620..fac3ad78d4 100644 --- a/plugins/modules/dnf_versionlock.py +++ b/plugins/modules/dnf_versionlock.py @@ -18,6 +18,21 @@ description: excludes all other versions of those packages. This allows you to for example protect packages from being updated by newer versions. The state of the plugin that reflects locking of packages is the C(locklist). +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: partial + details: + - The logics of the C(versionlock) plugin for corner cases could be + confusing, so please take in account that this module will do its best to + give a C(check_mode) prediction on what is going to happen. In case of + doubt, check the documentation of the plugin. + - Sometimes the module could predict changes in C(check_mode) that will not + be such because C(versionlock) concludes that there is already a entry in + C(locklist) that already matches. + diff_mode: + support: none options: name: description: @@ -54,19 +69,11 @@ options: type: str default: present notes: - - The logics of the C(versionlock) plugin for corner cases could be - confusing, so please take in account that this module will do its best to - give a C(check_mode) prediction on what is going to happen. In case of - doubt, check the documentation of the plugin. - - Sometimes the module could predict changes in C(check_mode) that will not - be such because C(versionlock) concludes that there is already a entry in - C(locklist) that already matches. - In an ideal world, the C(versionlock) plugin would have a dry-run option to know for sure what is going to happen. So far we have to work with a best guess as close as possible to the behaviour inferred from its code. - For most of cases where you want to lock and unlock specific versions of a package, this works fairly well. - - Supports C(check_mode). requirements: - dnf - dnf-plugin-versionlock diff --git a/plugins/modules/dpkg_divert.py b/plugins/modules/dpkg_divert.py index 52e6c33d0d..4a1651f517 100644 --- a/plugins/modules/dpkg_divert.py +++ b/plugins/modules/dpkg_divert.py @@ -27,6 +27,13 @@ description: C(dpkg-divert) commandline tool. It can either create or remove a diversion for a given file, but also update an existing diversion to modify its I(holder) and/or its I(divert) location. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: full options: path: description: @@ -79,8 +86,6 @@ options: - This parameter is ignored when I(rename=false). type: bool default: false -notes: - - This module supports I(check_mode) and I(diff). requirements: - dpkg-divert >= 1.15.0 (Debian family) ''' diff --git a/plugins/modules/easy_install.py b/plugins/modules/easy_install.py index 0a3158c926..564493180a 100644 --- a/plugins/modules/easy_install.py +++ b/plugins/modules/easy_install.py @@ -14,7 +14,14 @@ DOCUMENTATION = ''' module: easy_install short_description: Installs Python libraries description: - - Installs Python libraries, optionally in a I(virtualenv) + - Installs Python libraries, optionally in a I(virtualenv) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: type: str diff --git a/plugins/modules/flatpak.py b/plugins/modules/flatpak.py index d6264a50d3..feda6ed5b4 100644 --- a/plugins/modules/flatpak.py +++ b/plugins/modules/flatpak.py @@ -15,13 +15,20 @@ DOCUMENTATION = r''' module: flatpak short_description: Manage flatpaks description: -- Allows users to add or remove flatpaks. -- See the M(community.general.flatpak_remote) module for managing flatpak remotes. + - Allows users to add or remove flatpaks. + - See the M(community.general.flatpak_remote) module for managing flatpak remotes. author: -- John Kwiatkoski (@JayKayy) -- Alexander Bethke (@oolongbrothers) + - John Kwiatkoski (@JayKayy) + - Alexander Bethke (@oolongbrothers) requirements: -- flatpak + - flatpak +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: executable: description: diff --git a/plugins/modules/flatpak_remote.py b/plugins/modules/flatpak_remote.py index bc52d5461a..2032e38b9c 100644 --- a/plugins/modules/flatpak_remote.py +++ b/plugins/modules/flatpak_remote.py @@ -15,17 +15,24 @@ DOCUMENTATION = r''' module: flatpak_remote short_description: Manage flatpak repository remotes description: -- Allows users to add or remove flatpak remotes. -- The flatpak remotes concept is comparable to what is called repositories in other packaging - formats. -- Currently, remote addition is only supported via I(flatpakrepo) file URLs. -- Existing remotes will not be updated. -- See the M(community.general.flatpak) module for managing flatpaks. + - Allows users to add or remove flatpak remotes. + - The flatpak remotes concept is comparable to what is called repositories in other packaging + formats. + - Currently, remote addition is only supported via I(flatpakrepo) file URLs. + - Existing remotes will not be updated. + - See the M(community.general.flatpak) module for managing flatpaks. author: -- John Kwiatkoski (@JayKayy) -- Alexander Bethke (@oolongbrothers) + - John Kwiatkoski (@JayKayy) + - Alexander Bethke (@oolongbrothers) requirements: -- flatpak + - flatpak +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: executable: description: diff --git a/plugins/modules/gem.py b/plugins/modules/gem.py index a44683c786..4bc99d39ef 100644 --- a/plugins/modules/gem.py +++ b/plugins/modules/gem.py @@ -15,6 +15,13 @@ module: gem short_description: Manage Ruby gems description: - Manage installation and uninstallation of Ruby gems. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: type: str diff --git a/plugins/modules/homebrew.py b/plugins/modules/homebrew.py index a72d929a81..7592f95a41 100644 --- a/plugins/modules/homebrew.py +++ b/plugins/modules/homebrew.py @@ -22,11 +22,17 @@ author: - "Daniel Jaouen (@danieljaouen)" - "Andrew Dunham (@andrew-d)" requirements: - - "python >= 2.6" - - homebrew must already be installed on the target system + - homebrew must already be installed on the target system short_description: Package manager for Homebrew description: - Manages Homebrew packages +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/homebrew_cask.py b/plugins/modules/homebrew_cask.py index 5937831962..162c184612 100644 --- a/plugins/modules/homebrew_cask.py +++ b/plugins/modules/homebrew_cask.py @@ -15,14 +15,19 @@ DOCUMENTATION = ''' --- module: homebrew_cask author: -- "Indrajit Raychaudhuri (@indrajitr)" -- "Daniel Jaouen (@danieljaouen)" -- "Enric Lluelles (@enriclluelles)" -requirements: -- "python >= 2.6" + - "Indrajit Raychaudhuri (@indrajitr)" + - "Daniel Jaouen (@danieljaouen)" + - "Enric Lluelles (@enriclluelles)" short_description: Install and uninstall homebrew casks description: -- Manages Homebrew casks. + - Manages Homebrew casks. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/homebrew_tap.py b/plugins/modules/homebrew_tap.py index 7099773b21..b230dbb34c 100644 --- a/plugins/modules/homebrew_tap.py +++ b/plugins/modules/homebrew_tap.py @@ -22,6 +22,13 @@ author: short_description: Tap a Homebrew repository description: - Tap external Homebrew repositories. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/installp.py b/plugins/modules/installp.py index f1421bc390..41064363db 100644 --- a/plugins/modules/installp.py +++ b/plugins/modules/installp.py @@ -12,10 +12,17 @@ DOCUMENTATION = r''' --- module: installp author: -- Kairo Araujo (@kairoaraujo) + - Kairo Araujo (@kairoaraujo) short_description: Manage packages on AIX description: - Manage packages using 'installp' on AIX +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: accept_license: description: diff --git a/plugins/modules/layman.py b/plugins/modules/layman.py index b860385969..940ac30d1b 100644 --- a/plugins/modules/layman.py +++ b/plugins/modules/layman.py @@ -21,6 +21,13 @@ description: requirements: - "python >= 2.6" - layman python module +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/macports.py b/plugins/modules/macports.py index 7bf5c4f532..6f40d0938e 100644 --- a/plugins/modules/macports.py +++ b/plugins/modules/macports.py @@ -19,6 +19,13 @@ author: "Jimmy Tang (@jcftang)" short_description: Package manager for MacPorts description: - Manages MacPorts packages (ports) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/npm.py b/plugins/modules/npm.py index 02d97de766..013fd6e570 100644 --- a/plugins/modules/npm.py +++ b/plugins/modules/npm.py @@ -15,6 +15,13 @@ short_description: Manage node.js packages with npm description: - Manage node.js packages with Node Package Manager (npm). author: "Chris Hoffman (@chrishoffman)" +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/openbsd_pkg.py b/plugins/modules/openbsd_pkg.py index f99c5a24d0..62a662c3c4 100644 --- a/plugins/modules/openbsd_pkg.py +++ b/plugins/modules/openbsd_pkg.py @@ -14,12 +14,17 @@ DOCUMENTATION = ''' --- module: openbsd_pkg author: -- Patrik Lundin (@eest) + - Patrik Lundin (@eest) short_description: Manage packages on OpenBSD description: - - Manage packages on OpenBSD using the pkg tools. -requirements: -- python >= 2.5 + - Manage packages on OpenBSD using the pkg tools. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/opkg.py b/plugins/modules/opkg.py index 73c2597de2..360bf453b7 100644 --- a/plugins/modules/opkg.py +++ b/plugins/modules/opkg.py @@ -18,6 +18,13 @@ author: "Patrick Pelletier (@skinp)" short_description: Package manager for OpenWrt and Openembedded/Yocto based Linux distributions description: - Manages ipk packages for OpenWrt and Openembedded/Yocto based Linux distributions +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/pacman.py b/plugins/modules/pacman.py index 1066f10e88..66f58155d3 100644 --- a/plugins/modules/pacman.py +++ b/plugins/modules/pacman.py @@ -23,6 +23,13 @@ author: - Aaron Bull Schaefer (@elasticdog) - Maxime de Roucy (@tchernomax) - Jean Raby (@jraby) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: full options: name: description: diff --git a/plugins/modules/pacman_key.py b/plugins/modules/pacman_key.py index 7fa173ac3b..4d4c4afaca 100644 --- a/plugins/modules/pacman_key.py +++ b/plugins/modules/pacman_key.py @@ -12,21 +12,27 @@ DOCUMENTATION = ''' --- module: pacman_key author: -- George Rawlinson (@grawlinson) + - George Rawlinson (@grawlinson) version_added: "3.2.0" short_description: Manage pacman's list of trusted keys description: -- Add or remove gpg keys from the pacman keyring. + - Add or remove gpg keys from the pacman keyring. notes: -- Use full-length key ID (40 characters). -- Keys will be verified when using I(data), I(file), or I(url) unless I(verify) is overridden. -- Keys will be locally signed after being imported into the keyring. -- If the key ID exists in the keyring, the key will not be added unless I(force_update) is specified. -- I(data), I(file), I(url), and I(keyserver) are mutually exclusive. -- Supports C(check_mode). + - Use full-length key ID (40 characters). + - Keys will be verified when using I(data), I(file), or I(url) unless I(verify) is overridden. + - Keys will be locally signed after being imported into the keyring. + - If the key ID exists in the keyring, the key will not be added unless I(force_update) is specified. + - I(data), I(file), I(url), and I(keyserver) are mutually exclusive. requirements: -- gpg -- pacman-key + - gpg + - pacman-key +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: id: description: diff --git a/plugins/modules/pear.py b/plugins/modules/pear.py index 4e10ca0414..d7cb01b920 100644 --- a/plugins/modules/pear.py +++ b/plugins/modules/pear.py @@ -20,6 +20,13 @@ description: - Manage PHP packages with the pear package manager. author: - Jonathan Lestrelin (@jle64) +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: type: str diff --git a/plugins/modules/pipx.py b/plugins/modules/pipx.py index 773fbef8ea..f3bddef459 100644 --- a/plugins/modules/pipx.py +++ b/plugins/modules/pipx.py @@ -16,6 +16,13 @@ short_description: Manages applications installed with pipx version_added: 3.8.0 description: - Manage Python applications installed in isolated virtualenvs using pipx. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: full options: state: type: str diff --git a/plugins/modules/pkg5.py b/plugins/modules/pkg5.py index f8f6be24b9..f6bc77a713 100644 --- a/plugins/modules/pkg5.py +++ b/plugins/modules/pkg5.py @@ -18,6 +18,13 @@ description: - IPS packages are the native packages in Solaris 11 and higher. notes: - The naming of IPS packages is explained at U(http://www.oracle.com/technetwork/articles/servers-storage-admin/ips-package-versioning-2232906.html). +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/pkg5_publisher.py b/plugins/modules/pkg5_publisher.py index 3ccf3d8ca1..9d1b381385 100644 --- a/plugins/modules/pkg5_publisher.py +++ b/plugins/modules/pkg5_publisher.py @@ -19,6 +19,13 @@ description: - IPS packages are the native packages in Solaris 11 and higher. - This modules will configure which publishers a client will download IPS packages from. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/pkgin.py b/plugins/modules/pkgin.py index 0da06e0502..c08b252187 100644 --- a/plugins/modules/pkgin.py +++ b/plugins/modules/pkgin.py @@ -31,6 +31,13 @@ notes: - "Known bug with pkgin < 0.8.0: if a package is removed and another package depends on it, the other package will be silently removed as well. New to Ansible 1.9: check-mode support." +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/pkgng.py b/plugins/modules/pkgng.py index 6e94dcaee5..b9d4422c06 100644 --- a/plugins/modules/pkgng.py +++ b/plugins/modules/pkgng.py @@ -20,6 +20,13 @@ module: pkgng short_description: Package manager for FreeBSD >= 9.0 description: - Manage binary packages for FreeBSD using 'pkgng' which is available in versions after 9.0. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/pkgutil.py b/plugins/modules/pkgutil.py index d15c9d2726..5af74c1f31 100644 --- a/plugins/modules/pkgutil.py +++ b/plugins/modules/pkgutil.py @@ -23,6 +23,15 @@ description: author: - Alexander Winkler (@dermute) - David Ponessa (@scathatheworm) +extends_documentation_fragment: +- community.general.attributes +attributes: + check_mode: + support: full + details: + - In order to check the availability of packages, the catalog cache under C(/var/opt/csw/pkgutil) may be refreshed even in check mode. + diff_mode: + support: none options: name: description: @@ -57,8 +66,6 @@ options: type: bool default: false version_added: 1.2.0 -notes: -- In order to check the availability of packages, the catalog cache under C(/var/opt/csw/pkgutil) may be refreshed even in check mode. ''' EXAMPLES = r''' diff --git a/plugins/modules/portage.py b/plugins/modules/portage.py index 98791f8477..d33f44d578 100644 --- a/plugins/modules/portage.py +++ b/plugins/modules/portage.py @@ -21,6 +21,15 @@ short_description: Package manager for Gentoo description: - Manages Gentoo packages +extends_documentation_fragment: + - community.general.attributes + +attributes: + check_mode: + support: full + diff_mode: + support: none + options: package: description: diff --git a/plugins/modules/portinstall.py b/plugins/modules/portinstall.py index d044756d9e..e263b71813 100644 --- a/plugins/modules/portinstall.py +++ b/plugins/modules/portinstall.py @@ -18,6 +18,13 @@ module: portinstall short_description: Installing packages from FreeBSD's ports system description: - Manage packages for FreeBSD using 'portinstall'. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/rpm_ostree_pkg.py b/plugins/modules/rpm_ostree_pkg.py index 5f7632b1e1..52219cd1ba 100644 --- a/plugins/modules/rpm_ostree_pkg.py +++ b/plugins/modules/rpm_ostree_pkg.py @@ -17,6 +17,13 @@ short_description: Install or uninstall overlay additional packages version_added: "2.0.0" description: - Install or uninstall overlay additional packages using C(rpm-ostree) command. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: description: @@ -34,10 +41,8 @@ options: default: 'present' type: str author: -- Dusty Mabe (@dustymabe) -- Abhijeet Kasurde (@Akasurde) -notes: -- Does not support C(check_mode). + - Dusty Mabe (@dustymabe) + - Abhijeet Kasurde (@Akasurde) ''' EXAMPLES = r''' diff --git a/plugins/modules/slackpkg.py b/plugins/modules/slackpkg.py index 1a6cdf7705..208061a4cb 100644 --- a/plugins/modules/slackpkg.py +++ b/plugins/modules/slackpkg.py @@ -22,6 +22,13 @@ short_description: Package manager for Slackware >= 12.2 description: - Manage binary packages for Slackware using 'slackpkg' which is available in versions after 12.2. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/snap.py b/plugins/modules/snap.py index 1b5e27071a..4b798d6e2c 100644 --- a/plugins/modules/snap.py +++ b/plugins/modules/snap.py @@ -18,6 +18,13 @@ module: snap short_description: Manages snaps description: - "Manages snaps packages." +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/snap_alias.py b/plugins/modules/snap_alias.py index 1611c06719..71869b6ee0 100644 --- a/plugins/modules/snap_alias.py +++ b/plugins/modules/snap_alias.py @@ -16,6 +16,13 @@ short_description: Manages snap aliases version_added: 4.0.0 description: - "Manages snaps aliases." +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: full options: state: description: diff --git a/plugins/modules/svr4pkg.py b/plugins/modules/svr4pkg.py index 51e43b079f..e8c410482b 100644 --- a/plugins/modules/svr4pkg.py +++ b/plugins/modules/svr4pkg.py @@ -21,6 +21,13 @@ description: - Note that this is a very basic packaging system. It will not enforce dependencies on install or remove. author: "Boyd Adamson (@brontitall)" +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/syspatch.py b/plugins/modules/syspatch.py index 36b934f299..c90ef0d227 100644 --- a/plugins/modules/syspatch.py +++ b/plugins/modules/syspatch.py @@ -18,6 +18,15 @@ short_description: Manage OpenBSD system patches description: - "Manage OpenBSD system patches using syspatch." +extends_documentation_fragment: + - community.general.attributes + +attributes: + check_mode: + support: full + diff_mode: + support: none + options: revert: description: diff --git a/plugins/modules/sysupgrade.py b/plugins/modules/sysupgrade.py index e597db975b..ac80e01965 100644 --- a/plugins/modules/sysupgrade.py +++ b/plugins/modules/sysupgrade.py @@ -15,6 +15,13 @@ short_description: Manage OpenBSD system upgrades version_added: 1.1.0 description: - Manage OpenBSD system upgrades using sysupgrade. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: snapshot: description: diff --git a/plugins/modules/xbps.py b/plugins/modules/xbps.py index aad496238b..1fea5b384a 100644 --- a/plugins/modules/xbps.py +++ b/plugins/modules/xbps.py @@ -19,6 +19,13 @@ description: author: - "Dino Occhialini (@dinoocch)" - "Michael Aldridge (@the-maldridge)" +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: diff --git a/plugins/modules/yarn.py b/plugins/modules/yarn.py index df55925dba..da9f9c79c3 100644 --- a/plugins/modules/yarn.py +++ b/plugins/modules/yarn.py @@ -20,6 +20,13 @@ description: author: - "David Gunter (@verkaufer)" - "Chris Hoffman (@chrishoffman), creator of NPM Ansible module)" +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: type: str diff --git a/plugins/modules/yum_versionlock.py b/plugins/modules/yum_versionlock.py index 4835f6116c..95fd4dd7cf 100644 --- a/plugins/modules/yum_versionlock.py +++ b/plugins/modules/yum_versionlock.py @@ -14,7 +14,14 @@ module: yum_versionlock version_added: 2.0.0 short_description: Locks / unlocks a installed package(s) from being updated by yum package manager description: - - This module adds installed packages to yum versionlock to prevent the package(s) from being updated. + - This module adds installed packages to yum versionlock to prevent the package(s) from being updated. +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: none options: name: description: @@ -31,7 +38,6 @@ options: default: present notes: - Requires yum-plugin-versionlock package on the remote node. - - Supports C(check_mode). requirements: - yum - yum-versionlock diff --git a/plugins/modules/zypper.py b/plugins/modules/zypper.py index c5404975e8..775ff0fd6e 100644 --- a/plugins/modules/zypper.py +++ b/plugins/modules/zypper.py @@ -31,6 +31,14 @@ short_description: Manage packages on SUSE and openSUSE description: - Manage packages on SUSE and openSUSE using the zypper and rpm tools. - Also supports transactional updates, by running zypper inside C(/sbin/transactional-update --continue --drop-if-no-change --quiet run). +extends_documentation_fragment: + - community.general.attributes + - community.general.attributes +attributes: + check_mode: + support: full + diff_mode: + support: full options: name: description: diff --git a/plugins/modules/zypper_repository.py b/plugins/modules/zypper_repository.py index 9a947254c5..cccd9c5795 100644 --- a/plugins/modules/zypper_repository.py +++ b/plugins/modules/zypper_repository.py @@ -18,6 +18,13 @@ author: "Matthias Vogelgesang (@matze)" short_description: Add and remove Zypper repositories description: - Add or remove Zypper repositories on SUSE and openSUSE +extends_documentation_fragment: + - community.general.attributes +attributes: + check_mode: + support: none + diff_mode: + support: none options: name: description: From 18a6bdd6aa09d0b67a9aa562c50402970f6d8c00 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Fri, 24 Feb 2023 09:25:31 +0100 Subject: [PATCH 0197/1810] Add attributes to ipa and keycloak modules (#5950) Add attributes to ipa and keycloak modules. --- plugins/modules/ipa_config.py | 10 ++++++++-- plugins/modules/ipa_dnsrecord.py | 10 ++++++++-- plugins/modules/ipa_dnszone.py | 10 ++++++++-- plugins/modules/ipa_group.py | 10 ++++++++-- plugins/modules/ipa_hbacrule.py | 10 ++++++++-- plugins/modules/ipa_host.py | 10 ++++++++-- plugins/modules/ipa_hostgroup.py | 10 ++++++++-- plugins/modules/ipa_otpconfig.py | 10 ++++++++-- plugins/modules/ipa_otptoken.py | 10 ++++++++-- plugins/modules/ipa_pwpolicy.py | 10 +++++++--- plugins/modules/ipa_role.py | 8 +++++++- plugins/modules/ipa_service.py | 8 +++++++- plugins/modules/ipa_subca.py | 8 +++++++- plugins/modules/ipa_sudocmd.py | 8 +++++++- plugins/modules/ipa_sudocmdgroup.py | 8 +++++++- plugins/modules/ipa_sudorule.py | 8 +++++++- plugins/modules/ipa_user.py | 8 +++++++- plugins/modules/ipa_vault.py | 8 +++++++- plugins/modules/keycloak_authentication.py | 9 ++++++++- plugins/modules/keycloak_client.py | 9 ++++++++- .../modules/keycloak_client_rolemapping.py | 9 +++++++-- plugins/modules/keycloak_clientscope.py | 9 +++++++-- .../keycloak_clientsecret_regenerate.py | 7 +++++++ plugins/modules/keycloak_clienttemplate.py | 20 ++++++++++++------- plugins/modules/keycloak_group.py | 9 +++++++-- plugins/modules/keycloak_identity_provider.py | 8 +++++++- plugins/modules/keycloak_realm.py | 11 +++++++--- plugins/modules/keycloak_role.py | 9 +++++++-- plugins/modules/keycloak_user_federation.py | 8 +++++++- plugins/modules/keycloak_user_rolemapping.py | 9 +++++++-- 30 files changed, 228 insertions(+), 53 deletions(-) diff --git a/plugins/modules/ipa_config.py b/plugins/modules/ipa_config.py index 5847db077a..ec94b58d41 100644 --- a/plugins/modules/ipa_config.py +++ b/plugins/modules/ipa_config.py @@ -13,7 +13,12 @@ module: ipa_config author: Fran Fitzpatrick (@fxfitz) short_description: Manage Global FreeIPA Configuration Settings description: -- Modify global configuration settings of a FreeIPA Server. + - Modify global configuration settings of a FreeIPA Server. +attributes: + check_mode: + support: full + diff_mode: + support: none options: ipaconfigstring: description: Extra hashes to generate in password plug-in. @@ -93,7 +98,8 @@ options: elements: str version_added: '2.5.0' extends_documentation_fragment: -- community.general.ipa.documentation + - community.general.ipa.documentation + - community.general.attributes ''' diff --git a/plugins/modules/ipa_dnsrecord.py b/plugins/modules/ipa_dnsrecord.py index d070e1c69f..398f63f8e4 100644 --- a/plugins/modules/ipa_dnsrecord.py +++ b/plugins/modules/ipa_dnsrecord.py @@ -14,7 +14,12 @@ module: ipa_dnsrecord author: Abhijeet Kasurde (@Akasurde) short_description: Manage FreeIPA DNS records description: -- Add, modify and delete an IPA DNS Record using IPA API. + - Add, modify and delete an IPA DNS Record using IPA API. +attributes: + check_mode: + support: full + diff_mode: + support: none options: zone_name: description: @@ -78,7 +83,8 @@ options: choices: ["absent", "present"] type: str extends_documentation_fragment: -- community.general.ipa.documentation + - community.general.ipa.documentation + - community.general.attributes ''' diff --git a/plugins/modules/ipa_dnszone.py b/plugins/modules/ipa_dnszone.py index 167c49dc80..06c93841ea 100644 --- a/plugins/modules/ipa_dnszone.py +++ b/plugins/modules/ipa_dnszone.py @@ -14,7 +14,12 @@ module: ipa_dnszone author: Fran Fitzpatrick (@fxfitz) short_description: Manage FreeIPA DNS Zones description: -- Add and delete an IPA DNS Zones using IPA API + - Add and delete an IPA DNS Zones using IPA API +attributes: + check_mode: + support: full + diff_mode: + support: none options: zone_name: description: @@ -37,7 +42,8 @@ options: type: bool version_added: 4.3.0 extends_documentation_fragment: -- community.general.ipa.documentation + - community.general.ipa.documentation + - community.general.attributes ''' diff --git a/plugins/modules/ipa_group.py b/plugins/modules/ipa_group.py index 89cc806d2d..87e7f0e66b 100644 --- a/plugins/modules/ipa_group.py +++ b/plugins/modules/ipa_group.py @@ -13,7 +13,12 @@ module: ipa_group author: Thomas Krahn (@Nosmoht) short_description: Manage FreeIPA group description: -- Add, modify and delete group within IPA server + - Add, modify and delete group within IPA server +attributes: + check_mode: + support: full + diff_mode: + support: none options: append: description: @@ -82,7 +87,8 @@ options: choices: ["absent", "present"] type: str extends_documentation_fragment: -- community.general.ipa.documentation + - community.general.ipa.documentation + - community.general.attributes ''' diff --git a/plugins/modules/ipa_hbacrule.py b/plugins/modules/ipa_hbacrule.py index 37f0de8bc1..b7633262b6 100644 --- a/plugins/modules/ipa_hbacrule.py +++ b/plugins/modules/ipa_hbacrule.py @@ -13,7 +13,12 @@ module: ipa_hbacrule author: Thomas Krahn (@Nosmoht) short_description: Manage FreeIPA HBAC rule description: -- Add, modify or delete an IPA HBAC rule using IPA API. + - Add, modify or delete an IPA HBAC rule using IPA API. +attributes: + check_mode: + support: full + diff_mode: + support: none options: cn: description: @@ -104,7 +109,8 @@ options: type: list elements: str extends_documentation_fragment: -- community.general.ipa.documentation + - community.general.ipa.documentation + - community.general.attributes ''' diff --git a/plugins/modules/ipa_host.py b/plugins/modules/ipa_host.py index ad3c37877c..d561401d4d 100644 --- a/plugins/modules/ipa_host.py +++ b/plugins/modules/ipa_host.py @@ -13,7 +13,12 @@ module: ipa_host author: Thomas Krahn (@Nosmoht) short_description: Manage FreeIPA host description: -- Add, modify and delete an IPA host using IPA API. + - Add, modify and delete an IPA host using IPA API. +attributes: + check_mode: + support: full + diff_mode: + support: none options: fqdn: description: @@ -82,7 +87,8 @@ options: description: Generate a random password to be used in bulk enrollment. type: bool extends_documentation_fragment: -- community.general.ipa.documentation + - community.general.ipa.documentation + - community.general.attributes ''' diff --git a/plugins/modules/ipa_hostgroup.py b/plugins/modules/ipa_hostgroup.py index 37a09f7fa2..dcada0380c 100644 --- a/plugins/modules/ipa_hostgroup.py +++ b/plugins/modules/ipa_hostgroup.py @@ -13,7 +13,12 @@ module: ipa_hostgroup author: Thomas Krahn (@Nosmoht) short_description: Manage FreeIPA host-group description: -- Add, modify and delete an IPA host-group using IPA API. + - Add, modify and delete an IPA host-group using IPA API. +attributes: + check_mode: + support: full + diff_mode: + support: none options: cn: description: @@ -49,7 +54,8 @@ options: choices: ["absent", "disabled", "enabled", "present"] type: str extends_documentation_fragment: -- community.general.ipa.documentation + - community.general.ipa.documentation + - community.general.attributes ''' diff --git a/plugins/modules/ipa_otpconfig.py b/plugins/modules/ipa_otpconfig.py index e9bef94a85..e2d8f0cd52 100644 --- a/plugins/modules/ipa_otpconfig.py +++ b/plugins/modules/ipa_otpconfig.py @@ -15,7 +15,12 @@ author: justchris1 (@justchris1) short_description: Manage FreeIPA OTP Configuration Settings version_added: 2.5.0 description: -- Modify global configuration settings of a FreeIPA Server with respect to OTP (One Time Passwords). + - Modify global configuration settings of a FreeIPA Server with respect to OTP (One Time Passwords). +attributes: + check_mode: + support: full + diff_mode: + support: none options: ipatokentotpauthwindow: description: TOTP authentication window in seconds. @@ -34,7 +39,8 @@ options: aliases: ["hotpsyncwindow"] type: int extends_documentation_fragment: -- community.general.ipa.documentation + - community.general.ipa.documentation + - community.general.attributes ''' diff --git a/plugins/modules/ipa_otptoken.py b/plugins/modules/ipa_otptoken.py index 0cc06d7163..f25ab6023f 100644 --- a/plugins/modules/ipa_otptoken.py +++ b/plugins/modules/ipa_otptoken.py @@ -14,7 +14,12 @@ author: justchris1 (@justchris1) short_description: Manage FreeIPA OTPs version_added: 2.5.0 description: -- Add, modify, and delete One Time Passwords in IPA. + - Add, modify, and delete One Time Passwords in IPA. +attributes: + check_mode: + support: full + diff_mode: + support: none options: uniqueid: description: Unique ID of the token in IPA. @@ -100,7 +105,8 @@ options: - "B(Note:) Cannot be modified after OTP is created." type: int extends_documentation_fragment: -- community.general.ipa.documentation + - community.general.ipa.documentation + - community.general.attributes ''' EXAMPLES = r''' diff --git a/plugins/modules/ipa_pwpolicy.py b/plugins/modules/ipa_pwpolicy.py index db75b121c7..6a6c4318ba 100644 --- a/plugins/modules/ipa_pwpolicy.py +++ b/plugins/modules/ipa_pwpolicy.py @@ -15,6 +15,11 @@ short_description: Manage FreeIPA password policies description: - Add, modify, or delete a password policy using the IPA API. version_added: 2.0.0 +attributes: + check_mode: + support: full + diff_mode: + support: none options: group: description: @@ -60,9 +65,8 @@ options: description: Period (in seconds) for which users are locked out. type: str extends_documentation_fragment: -- community.general.ipa.documentation -notes: -- Supports C(check_mode). + - community.general.ipa.documentation + - community.general.attributes ''' EXAMPLES = r''' diff --git a/plugins/modules/ipa_role.py b/plugins/modules/ipa_role.py index 0168343839..fce315b662 100644 --- a/plugins/modules/ipa_role.py +++ b/plugins/modules/ipa_role.py @@ -14,6 +14,11 @@ author: Thomas Krahn (@Nosmoht) short_description: Manage FreeIPA role description: - Add, modify and delete a role within FreeIPA server using FreeIPA API. +attributes: + check_mode: + support: full + diff_mode: + support: none options: cn: description: @@ -79,7 +84,8 @@ options: type: list elements: str extends_documentation_fragment: -- community.general.ipa.documentation + - community.general.ipa.documentation + - community.general.attributes ''' diff --git a/plugins/modules/ipa_service.py b/plugins/modules/ipa_service.py index f0a7daf151..d9541674f2 100644 --- a/plugins/modules/ipa_service.py +++ b/plugins/modules/ipa_service.py @@ -14,6 +14,11 @@ author: Cédric Parent (@cprh) short_description: Manage FreeIPA service description: - Add and delete an IPA service using IPA API. +attributes: + check_mode: + support: full + diff_mode: + support: none options: krbcanonicalname: description: @@ -48,7 +53,8 @@ options: choices: ["absent", "present"] type: str extends_documentation_fragment: -- community.general.ipa.documentation + - community.general.ipa.documentation + - community.general.attributes ''' diff --git a/plugins/modules/ipa_subca.py b/plugins/modules/ipa_subca.py index b470be6aef..882b1ac396 100644 --- a/plugins/modules/ipa_subca.py +++ b/plugins/modules/ipa_subca.py @@ -14,6 +14,11 @@ author: Abhijeet Kasurde (@Akasurde) short_description: Manage FreeIPA Lightweight Sub Certificate Authorities description: - Add, modify, enable, disable and delete an IPA Lightweight Sub Certificate Authorities using IPA API. +attributes: + check_mode: + support: full + diff_mode: + support: none options: subca_name: description: @@ -39,7 +44,8 @@ options: choices: ["absent", "disabled", "enabled", "present"] type: str extends_documentation_fragment: -- community.general.ipa.documentation + - community.general.ipa.documentation + - community.general.attributes ''' diff --git a/plugins/modules/ipa_sudocmd.py b/plugins/modules/ipa_sudocmd.py index 18991ccfd4..d3139ba1c3 100644 --- a/plugins/modules/ipa_sudocmd.py +++ b/plugins/modules/ipa_sudocmd.py @@ -14,6 +14,11 @@ author: Thomas Krahn (@Nosmoht) short_description: Manage FreeIPA sudo command description: - Add, modify or delete sudo command within FreeIPA server using FreeIPA API. +attributes: + check_mode: + support: full + diff_mode: + support: none options: sudocmd: description: @@ -31,7 +36,8 @@ options: choices: ['absent', 'disabled', 'enabled', 'present'] type: str extends_documentation_fragment: -- community.general.ipa.documentation + - community.general.ipa.documentation + - community.general.attributes ''' diff --git a/plugins/modules/ipa_sudocmdgroup.py b/plugins/modules/ipa_sudocmdgroup.py index d9c39a4a3c..a768e74a1a 100644 --- a/plugins/modules/ipa_sudocmdgroup.py +++ b/plugins/modules/ipa_sudocmdgroup.py @@ -14,6 +14,11 @@ author: Thomas Krahn (@Nosmoht) short_description: Manage FreeIPA sudo command group description: - Add, modify or delete sudo command group within IPA server using IPA API. +attributes: + check_mode: + support: full + diff_mode: + support: none options: cn: description: @@ -38,7 +43,8 @@ options: type: list elements: str extends_documentation_fragment: -- community.general.ipa.documentation + - community.general.ipa.documentation + - community.general.attributes ''' diff --git a/plugins/modules/ipa_sudorule.py b/plugins/modules/ipa_sudorule.py index bc5419adba..59b4eb19e2 100644 --- a/plugins/modules/ipa_sudorule.py +++ b/plugins/modules/ipa_sudorule.py @@ -14,6 +14,11 @@ author: Thomas Krahn (@Nosmoht) short_description: Manage FreeIPA sudo rule description: - Add, modify or delete sudo rule within IPA server using IPA API. +attributes: + check_mode: + support: full + diff_mode: + support: none options: cn: description: @@ -115,7 +120,8 @@ options: choices: ['absent', 'disabled', 'enabled', 'present'] type: str extends_documentation_fragment: -- community.general.ipa.documentation + - community.general.ipa.documentation + - community.general.attributes ''' diff --git a/plugins/modules/ipa_user.py b/plugins/modules/ipa_user.py index 4fd96425cf..17b72176ea 100644 --- a/plugins/modules/ipa_user.py +++ b/plugins/modules/ipa_user.py @@ -14,6 +14,11 @@ author: Thomas Krahn (@Nosmoht) short_description: Manage FreeIPA users description: - Add, modify and delete user within IPA server. +attributes: + check_mode: + support: full + diff_mode: + support: none options: displayname: description: Display name. @@ -99,7 +104,8 @@ options: elements: str version_added: '1.2.0' extends_documentation_fragment: -- community.general.ipa.documentation + - community.general.ipa.documentation + - community.general.attributes requirements: - base64 diff --git a/plugins/modules/ipa_vault.py b/plugins/modules/ipa_vault.py index 40f5844cd9..84b72c1abb 100644 --- a/plugins/modules/ipa_vault.py +++ b/plugins/modules/ipa_vault.py @@ -15,6 +15,11 @@ short_description: Manage FreeIPA vaults description: - Add, modify and delete vaults and secret vaults. - KRA service should be enabled to use this module. +attributes: + check_mode: + support: full + diff_mode: + support: none options: cn: description: @@ -74,7 +79,8 @@ options: type: bool default: true extends_documentation_fragment: -- community.general.ipa.documentation + - community.general.ipa.documentation + - community.general.attributes ''' diff --git a/plugins/modules/keycloak_authentication.py b/plugins/modules/keycloak_authentication.py index 5ec53f9d8c..5db9bc9318 100644 --- a/plugins/modules/keycloak_authentication.py +++ b/plugins/modules/keycloak_authentication.py @@ -19,6 +19,12 @@ description: version_added: "3.3.0" +attributes: + check_mode: + support: full + diff_mode: + support: full + options: realm: description: @@ -86,7 +92,8 @@ options: - If C(true), allows to remove the authentication flow and recreate it. extends_documentation_fragment: -- community.general.keycloak + - community.general.keycloak + - community.general.attributes author: - Philippe Gauthier (@elfelip) diff --git a/plugins/modules/keycloak_client.py b/plugins/modules/keycloak_client.py index 51e516221b..ee687fcb43 100644 --- a/plugins/modules/keycloak_client.py +++ b/plugins/modules/keycloak_client.py @@ -30,6 +30,12 @@ description: SAML-specific settings on an OpenID Connect client for instance and vice versa. Be careful. If you do not specify a setting, usually a sensible default is chosen. +attributes: + check_mode: + support: full + diff_mode: + support: full + options: state: description: @@ -539,7 +545,8 @@ options: client and signed by its key, base64-encoded. extends_documentation_fragment: -- community.general.keycloak + - community.general.keycloak + - community.general.attributes author: - Eike Frost (@eikef) diff --git a/plugins/modules/keycloak_client_rolemapping.py b/plugins/modules/keycloak_client_rolemapping.py index efb9e77cf7..57dcac48de 100644 --- a/plugins/modules/keycloak_client_rolemapping.py +++ b/plugins/modules/keycloak_client_rolemapping.py @@ -33,6 +33,11 @@ description: - When updating a client_rolemapping, where possible provide the role ID to the module. This removes a lookup to the API to translate the name into the role ID. +attributes: + check_mode: + support: full + diff_mode: + support: full options: state: @@ -97,8 +102,8 @@ options: providing it will reduce the number of API calls required. extends_documentation_fragment: -- community.general.keycloak - + - community.general.keycloak + - community.general.attributes author: - Gaëtan Daubresse (@Gaetan2907) diff --git a/plugins/modules/keycloak_clientscope.py b/plugins/modules/keycloak_clientscope.py index 1bba8ba77d..a23d92867a 100644 --- a/plugins/modules/keycloak_clientscope.py +++ b/plugins/modules/keycloak_clientscope.py @@ -33,6 +33,11 @@ description: - When updating a client_scope, where possible provide the client_scope ID to the module. This removes a lookup to the API to translate the name into the client_scope ID. +attributes: + check_mode: + support: full + diff_mode: + support: full options: state: @@ -151,8 +156,8 @@ options: - Values may be single values (for example a string) or a list of strings. extends_documentation_fragment: -- community.general.keycloak - + - community.general.keycloak + - community.general.attributes author: - Gaëtan Daubresse (@Gaetan2907) diff --git a/plugins/modules/keycloak_clientsecret_regenerate.py b/plugins/modules/keycloak_clientsecret_regenerate.py index 7a48a25d25..7e8b295433 100644 --- a/plugins/modules/keycloak_clientsecret_regenerate.py +++ b/plugins/modules/keycloak_clientsecret_regenerate.py @@ -32,6 +32,12 @@ description: - "Note that this module returns the client secret. To avoid this showing up in the logs, please add C(no_log: true) to the task." +attributes: + check_mode: + support: full + diff_mode: + support: none + options: realm: type: str @@ -57,6 +63,7 @@ options: extends_documentation_fragment: - community.general.keycloak + - community.general.attributes author: - Fynn Chen (@fynncfchen) diff --git a/plugins/modules/keycloak_clienttemplate.py b/plugins/modules/keycloak_clienttemplate.py index 4b75bad919..d2555afc5b 100644 --- a/plugins/modules/keycloak_clienttemplate.py +++ b/plugins/modules/keycloak_clienttemplate.py @@ -14,7 +14,6 @@ module: keycloak_clienttemplate short_description: Allows administration of Keycloak client templates via Keycloak API - description: - This module allows the administration of Keycloak client templates via the Keycloak REST API. It requires access to the REST API via OpenID Connect; the user connecting and the client being @@ -29,6 +28,12 @@ description: SAML-specific settings on an OpenID Connect client for instance and vice versa. Be careful. If you do not specify a setting, usually a sensible default is chosen. +attributes: + check_mode: + support: full + diff_mode: + support: full + options: state: description: @@ -155,14 +160,15 @@ options: type: dict notes: -- The Keycloak REST API defines further fields (namely I(bearerOnly), I(consentRequired), I(standardFlowEnabled), - I(implicitFlowEnabled), I(directAccessGrantsEnabled), I(serviceAccountsEnabled), I(publicClient), and - I(frontchannelLogout)) which, while available with keycloak_client, do not have any effect on - Keycloak client-templates and are discarded if supplied with an API request changing client-templates. As such, - they are not available through this module. + - The Keycloak REST API defines further fields (namely I(bearerOnly), I(consentRequired), I(standardFlowEnabled), + I(implicitFlowEnabled), I(directAccessGrantsEnabled), I(serviceAccountsEnabled), I(publicClient), and + I(frontchannelLogout)) which, while available with keycloak_client, do not have any effect on + Keycloak client-templates and are discarded if supplied with an API request changing client-templates. As such, + they are not available through this module. extends_documentation_fragment: -- community.general.keycloak + - community.general.keycloak + - community.general.attributes author: - Eike Frost (@eikef) diff --git a/plugins/modules/keycloak_group.py b/plugins/modules/keycloak_group.py index 3df87c8fe5..94d96543c8 100644 --- a/plugins/modules/keycloak_group.py +++ b/plugins/modules/keycloak_group.py @@ -31,6 +31,11 @@ description: - When updating a group, where possible provide the group ID to the module. This removes a lookup to the API to translate the name into the group ID. +attributes: + check_mode: + support: full + diff_mode: + support: full options: state: @@ -74,8 +79,8 @@ notes: are read-only for groups. This limitation will be removed in a later version of this module. extends_documentation_fragment: -- community.general.keycloak - + - community.general.keycloak + - community.general.attributes author: - Adam Goossens (@adamgoossens) diff --git a/plugins/modules/keycloak_identity_provider.py b/plugins/modules/keycloak_identity_provider.py index 5915006d6b..0d12ae03a4 100644 --- a/plugins/modules/keycloak_identity_provider.py +++ b/plugins/modules/keycloak_identity_provider.py @@ -26,6 +26,11 @@ description: - The names of module options are snake_cased versions of the camelCase ones found in the Keycloak API and its documentation at U(https://www.keycloak.org/docs-api/15.0/rest-api/index.html). +attributes: + check_mode: + support: full + diff_mode: + support: full options: state: @@ -270,7 +275,8 @@ options: type: dict extends_documentation_fragment: -- community.general.keycloak + - community.general.keycloak + - community.general.attributes author: - Laurent Paumier (@laurpaum) diff --git a/plugins/modules/keycloak_realm.py b/plugins/modules/keycloak_realm.py index 73a17cf10b..53f81be489 100644 --- a/plugins/modules/keycloak_realm.py +++ b/plugins/modules/keycloak_realm.py @@ -17,7 +17,6 @@ short_description: Allows administration of Keycloak realm via Keycloak API version_added: 3.0.0 - description: - This module allows the administration of Keycloak realm via the Keycloak REST API. It requires access to the REST API via OpenID Connect; the user connecting and the realm being @@ -33,6 +32,12 @@ description: SAML-specific settings on an OpenID Connect client for instance and vice versa. Be careful. If you do not specify a setting, usually a sensible default is chosen. +attributes: + check_mode: + support: full + diff_mode: + support: full + options: state: description: @@ -503,8 +508,8 @@ options: type: int extends_documentation_fragment: -- community.general.keycloak - + - community.general.keycloak + - community.general.attributes author: - Christophe Gilles (@kris2kris) diff --git a/plugins/modules/keycloak_role.py b/plugins/modules/keycloak_role.py index ea6828b38e..bbec5f5919 100644 --- a/plugins/modules/keycloak_role.py +++ b/plugins/modules/keycloak_role.py @@ -30,6 +30,11 @@ description: be returned that way by this module. You may pass single values for attributes when calling the module, and this will be translated into a list suitable for the API. +attributes: + check_mode: + support: full + diff_mode: + support: full options: state: @@ -74,8 +79,8 @@ options: - Values may be single values (e.g. a string) or a list of strings. extends_documentation_fragment: -- community.general.keycloak - + - community.general.keycloak + - community.general.attributes author: - Laurent Paumier (@laurpaum) diff --git a/plugins/modules/keycloak_user_federation.py b/plugins/modules/keycloak_user_federation.py index fbb31e695d..8e1ddb12d9 100644 --- a/plugins/modules/keycloak_user_federation.py +++ b/plugins/modules/keycloak_user_federation.py @@ -26,6 +26,11 @@ description: - The names of module options are snake_cased versions of the camelCase ones found in the Keycloak API and its documentation at U(https://www.keycloak.org/docs-api/20.0.2/rest-api/index.html). +attributes: + check_mode: + support: full + diff_mode: + support: full options: state: @@ -461,7 +466,8 @@ options: type: dict extends_documentation_fragment: -- community.general.keycloak + - community.general.keycloak + - community.general.attributes author: - Laurent Paumier (@laurpaum) diff --git a/plugins/modules/keycloak_user_rolemapping.py b/plugins/modules/keycloak_user_rolemapping.py index 9e909716ac..d754e313a5 100644 --- a/plugins/modules/keycloak_user_rolemapping.py +++ b/plugins/modules/keycloak_user_rolemapping.py @@ -32,6 +32,11 @@ description: - When updating a user_rolemapping, where possible provide the role ID to the module. This removes a lookup to the API to translate the name into the role ID. +attributes: + check_mode: + support: full + diff_mode: + support: full options: state: @@ -104,8 +109,8 @@ options: providing it will reduce the number of API calls required. extends_documentation_fragment: -- community.general.keycloak - + - community.general.keycloak + - community.general.attributes author: - Dušan Marković (@bratwurzt) From 0307fd12eb3c1c2b30255235a69bac64fede8705 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Fri, 24 Feb 2023 11:13:27 +0100 Subject: [PATCH 0198/1810] Add attributes to ocapi_info (#6066) Add attributes to ocapi_info. --- plugins/modules/ocapi_info.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/modules/ocapi_info.py b/plugins/modules/ocapi_info.py index 2cb7a3afca..d7dfdccc7c 100644 --- a/plugins/modules/ocapi_info.py +++ b/plugins/modules/ocapi_info.py @@ -18,6 +18,9 @@ short_description: Manages Out-Of-Band controllers using Open Composable API (OC description: - Builds OCAPI URIs locally and sends them to remote OOB controllers to get information back. +extends_documentation_fragment: + - community.general.attributes + - community.general.attributes.info_module options: category: required: true From b72b7d49363aba4fb3ec44fcbb6032de9e7084ad Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Fri, 24 Feb 2023 11:32:20 +0100 Subject: [PATCH 0199/1810] Run tests with EOL ansible-core versions in GHA (#6044) Run tests with EOL ansible-core versions in GHA. --- .azure-pipelines/azure-pipelines.yml | 74 ---------- .github/workflows/ansible-test.yml | 193 +++++++++++++++++++++++++++ README.md | 1 + tests/utils/shippable/shippable.sh | 6 +- 4 files changed, 195 insertions(+), 79 deletions(-) create mode 100644 .github/workflows/ansible-test.yml diff --git a/.azure-pipelines/azure-pipelines.yml b/.azure-pipelines/azure-pipelines.yml index 3816369497..e3b0e8bdc4 100644 --- a/.azure-pipelines/azure-pipelines.yml +++ b/.azure-pipelines/azure-pipelines.yml @@ -112,19 +112,6 @@ stages: - test: 2 - test: 3 - test: 4 - - stage: Sanity_2_11 - displayName: Sanity 2.11 - dependsOn: [] - jobs: - - template: templates/matrix.yml - parameters: - nameFormat: Test {0} - testFormat: 2.11/sanity/{0} - targets: - - test: 1 - - test: 2 - - test: 3 - - test: 4 ### Units - stage: Units_devel displayName: Units devel @@ -176,17 +163,6 @@ stages: targets: - test: 2.6 - test: 3.8 - - stage: Units_2_11 - displayName: Units 2.11 - dependsOn: [] - jobs: - - template: templates/matrix.yml - parameters: - nameFormat: Python {0} - testFormat: 2.11/units/{0}/1 - targets: - - test: 2.7 - - test: 3.5 ## Remote - stage: Remote_devel_extra_vms @@ -279,22 +255,6 @@ stages: - 1 - 2 - 3 - - stage: Remote_2_11 - displayName: Remote 2.11 - dependsOn: [] - jobs: - - template: templates/matrix.yml - parameters: - testFormat: 2.11/{0} - targets: - - name: RHEL 7.9 - test: rhel/7.9 - - name: RHEL 8.3 - test: rhel/8.3 - groups: - - 1 - - 2 - - 3 ### Docker - stage: Docker_devel @@ -371,24 +331,6 @@ stages: - 1 - 2 - 3 - - stage: Docker_2_11 - displayName: Docker 2.11 - dependsOn: [] - jobs: - - template: templates/matrix.yml - parameters: - testFormat: 2.11/linux/{0} - targets: - - name: Fedora 32 - test: fedora32 - - name: Fedora 33 - test: fedora33 - - name: Alpine 3 - test: alpine3 - groups: - - 1 - - 2 - - 3 ### Community Docker - stage: Docker_community_devel @@ -452,46 +394,30 @@ stages: testFormat: 2.12/generic/{0}/1 targets: - test: 3.8 - - stage: Generic_2_11 - displayName: Generic 2.11 - dependsOn: [] - jobs: - - template: templates/matrix.yml - parameters: - nameFormat: Python {0} - testFormat: 2.11/generic/{0}/1 - targets: - - test: 2.7 - - test: 3.5 - stage: Summary condition: succeededOrFailed() dependsOn: - Sanity_devel - - Sanity_2_11 - Sanity_2_12 - Sanity_2_13 - Sanity_2_14 - Units_devel - - Units_2_11 - Units_2_12 - Units_2_13 - Units_2_14 - Remote_devel_extra_vms - Remote_devel - - Remote_2_11 - Remote_2_12 - Remote_2_13 - Remote_2_14 - Docker_devel - - Docker_2_11 - Docker_2_12 - Docker_2_13 - Docker_2_14 - Docker_community_devel # Right now all generic tests are disabled. Uncomment when at least one of them is re-enabled. # - Generic_devel -# - Generic_2_11 # - Generic_2_12 # - Generic_2_13 # - Generic_2_14 diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml new file mode 100644 index 0000000000..ef170347c3 --- /dev/null +++ b/.github/workflows/ansible-test.yml @@ -0,0 +1,193 @@ +--- +# Copyright (c) Ansible Project +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +# For the comprehensive list of the inputs supported by the ansible-community/ansible-test-gh-action GitHub Action, see +# https://github.com/marketplace/actions/ansible-test + +name: EOL CI +on: + # Run EOL CI against all pushes (direct commits, also merged PRs), Pull Requests + push: + branches: + - main + - stable-* + pull_request: + # Run EOL CI once per day (at 08:00 UTC) + schedule: + - cron: '0 8 * * *' + +concurrency: + # Make sure there is at most one active run per PR, but do not cancel any non-PR runs + group: ${{ github.workflow }}-${{ (github.head_ref && github.event.number) || github.run_id }} + cancel-in-progress: true + +jobs: + sanity: + name: EOL Sanity (Ⓐ${{ matrix.ansible }}) + strategy: + matrix: + ansible: + - '2.11' + # Ansible-test on various stable branches does not yet work well with cgroups v2. + # Since ubuntu-latest now uses Ubuntu 22.04, we need to fall back to the ubuntu-20.04 + # image for these stable branches. The list of branches where this is necessary will + # shrink over time, check out https://github.com/ansible-collections/news-for-maintainers/issues/28 + # for the latest list. + runs-on: >- + ${{ contains(fromJson( + '["2.9", "2.10", "2.11"]' + ), matrix.ansible) && 'ubuntu-20.04' || 'ubuntu-latest' }} + steps: + - name: Perform sanity testing + uses: felixfontein/ansible-test-gh-action@main + with: + ansible-core-github-repository-slug: felixfontein/ansible + ansible-core-version: stable-${{ matrix.ansible }} + coverage: ${{ github.event_name == 'schedule' && 'always' || 'never' }} + pull-request-change-detection: 'true' + testing-type: sanity + + units: + # Ansible-test on various stable branches does not yet work well with cgroups v2. + # Since ubuntu-latest now uses Ubuntu 22.04, we need to fall back to the ubuntu-20.04 + # image for these stable branches. The list of branches where this is necessary will + # shrink over time, check out https://github.com/ansible-collections/news-for-maintainers/issues/28 + # for the latest list. + runs-on: >- + ${{ contains(fromJson( + '["2.9", "2.10", "2.11"]' + ), matrix.ansible) && 'ubuntu-20.04' || 'ubuntu-latest' }} + name: EOL Units (Ⓐ${{ matrix.ansible }}+py${{ matrix.python }}) + strategy: + # As soon as the first unit test fails, cancel the others to free up the CI queue + fail-fast: true + matrix: + ansible: + - '' + python: + - '' + exclude: + - ansible: '' + include: + - ansible: '2.11' + python: '2.7' + - ansible: '2.11' + python: '3.5' + + steps: + - name: >- + Perform unit testing against + Ansible version ${{ matrix.ansible }} + uses: felixfontein/ansible-test-gh-action@main + with: + ansible-core-github-repository-slug: felixfontein/ansible + ansible-core-version: stable-${{ matrix.ansible }} + coverage: ${{ github.event_name == 'schedule' && 'always' || 'never' }} + pre-test-cmd: >- + mkdir -p ../../ansible + ; + git clone --depth=1 --single-branch https://github.com/ansible-collections/community.internal_test_tools.git ../../community/internal_test_tools + pull-request-change-detection: 'true' + target-python-version: ${{ matrix.python }} + testing-type: units + + integration: + # Ansible-test on various stable branches does not yet work well with cgroups v2. + # Since ubuntu-latest now uses Ubuntu 22.04, we need to fall back to the ubuntu-20.04 + # image for these stable branches. The list of branches where this is necessary will + # shrink over time, check out https://github.com/ansible-collections/news-for-maintainers/issues/28 + # for the latest list. + runs-on: >- + ${{ contains(fromJson( + '["2.9", "2.10", "2.11"]' + ), matrix.ansible) && 'ubuntu-20.04' || 'ubuntu-latest' }} + name: EOL I (Ⓐ${{ matrix.ansible }}+${{ matrix.docker }}+py${{ matrix.python }}:${{ matrix.target }}) + strategy: + fail-fast: false + matrix: + ansible: + - '' + docker: + - '' + python: + - '' + target: + - '' + exclude: + - ansible: '' + include: + # 2.11 + - ansible: '2.11' + docker: fedora32 + python: '' + target: azp/posix/1/ + - ansible: '2.11' + docker: fedora32 + python: '' + target: azp/posix/2/ + - ansible: '2.11' + docker: fedora32 + python: '' + target: azp/posix/3/ + - ansible: '2.11' + docker: fedora33 + python: '' + target: azp/posix/1/ + - ansible: '2.11' + docker: fedora33 + python: '' + target: azp/posix/2/ + - ansible: '2.11' + docker: fedora33 + python: '' + target: azp/posix/3/ + - ansible: '2.11' + docker: alpine3 + python: '' + target: azp/posix/1/ + - ansible: '2.11' + docker: alpine3 + python: '' + target: azp/posix/2/ + - ansible: '2.11' + docker: alpine3 + python: '' + target: azp/posix/3/ + # Right now all generic tests are disabled. Uncomment when at least one of them is re-enabled. + # - ansible: '2.11' + # docker: default + # python: '2.7' + # target: azp/generic/1/ + # - ansible: '2.11' + # docker: default + # python: '3.5' + # target: azp/generic/2/ + + steps: + - name: >- + Perform integration testing against + Ansible version ${{ matrix.ansible }} + under Python ${{ matrix.python }} + uses: felixfontein/ansible-test-gh-action@main + with: + ansible-core-github-repository-slug: felixfontein/ansible + ansible-core-version: stable-${{ matrix.ansible }} + coverage: ${{ github.event_name == 'schedule' && 'always' || 'never' }} + docker-image: ${{ matrix.docker }} + integration-continue-on-error: 'false' + integration-diff: 'false' + integration-retry-on-error: 'true' + pre-test-cmd: >- + mkdir -p ../../ansible + ; + git clone --depth=1 --single-branch https://github.com/ansible-collections/ansible.posix.git ../../ansible/posix + ; + git clone --depth=1 --single-branch https://github.com/ansible-collections/community.crypto.git ../../community/crypto + ; + git clone --depth=1 --single-branch https://github.com/ansible-collections/community.internal_test_tools.git ../../community/internal_test_tools + pull-request-change-detection: 'true' + target: ${{ matrix.target }} + target-python-version: ${{ matrix.python }} + testing-type: integration diff --git a/README.md b/README.md index 94d5b506ba..163a7f4ccb 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ SPDX-License-Identifier: GPL-3.0-or-later # Community General Collection [![Build Status](https://dev.azure.com/ansible/community.general/_apis/build/status/CI?branchName=main)](https://dev.azure.com/ansible/community.general/_build?definitionId=31) +[![EOL CI](https://github.com/ansible-collections/community.general/workflows/EOL%20CI/badge.svg?event=push)](https://github.com/ansible-collections/community.general/actions) [![Codecov](https://img.shields.io/codecov/c/github/ansible-collections/community.general)](https://codecov.io/gh/ansible-collections/community.general) This repository contains the `community.general` Ansible Collection. The collection is a part of the Ansible package and includes many modules and plugins supported by Ansible community which are not part of more specialized community collections. diff --git a/tests/utils/shippable/shippable.sh b/tests/utils/shippable/shippable.sh index ba8842d97b..4f97771c28 100755 --- a/tests/utils/shippable/shippable.sh +++ b/tests/utils/shippable/shippable.sh @@ -90,13 +90,9 @@ if [ "${script}" != "sanity" ] || [ "${test}" == "sanity/extra" ]; then fi if [ "${script}" != "sanity" ] && [ "${script}" != "units" ] && [ "${test}" != "sanity/extra" ]; then - CRYPTO_BRANCH=main - if [ "${script}" == "linux" ] && [[ "${test}" =~ "ubuntu1604/" ]]; then - CRYPTO_BRANCH=stable-1 - fi # To prevent Python dependencies on other collections only install other collections for integration tests retry git clone --depth=1 --single-branch https://github.com/ansible-collections/ansible.posix.git "${ANSIBLE_COLLECTIONS_PATHS}/ansible_collections/ansible/posix" - retry git clone --depth=1 --branch "${CRYPTO_BRANCH}" --single-branch https://github.com/ansible-collections/community.crypto.git "${ANSIBLE_COLLECTIONS_PATHS}/ansible_collections/community/crypto" + retry git clone --depth=1 --single-branch https://github.com/ansible-collections/community.crypto.git "${ANSIBLE_COLLECTIONS_PATHS}/ansible_collections/community/crypto" # NOTE: we're installing with git to work around Galaxy being a huge PITA (https://github.com/ansible/galaxy/issues/2429) # retry ansible-galaxy -vvv collection install ansible.posix # retry ansible-galaxy -vvv collection install community.crypto From de1f0ff419a2f2bb86a020cc498f94069524a0a4 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 25 Feb 2023 10:57:48 +0100 Subject: [PATCH 0200/1810] Consolidate onepassword unit tests so that ansible-test will find them when the plugin is modified (#6075) Consolidate onepassword unit tests so that ansible-test will find them when the plugin is modified. --- .../plugins/lookup/onepassword/__init__.py | 0 .../onepassword/test_onepassword_cli_v1.py | 50 ---------- .../onepassword/test_onepassword_cli_v2.py | 52 ----------- .../common.py => onepassword_common.py} | 2 +- .../conftest.py => onepassword_conftest.py} | 0 .../v1_out_01.json | 0 .../v1_out_01.json.license | 0 .../v1_out_02.json | 0 .../v1_out_02.json.license | 0 .../v1_out_03.json | 0 .../v1_out_03.json.license | 0 .../v2_out_01.json | 0 .../v2_out_01.json.license | 0 .../v2_out_02.json | 0 .../v2_out_02.json.license | 0 .../v2_out_03.json | 0 .../v2_out_03.json.license | 0 .../{onepassword => }/test_onepassword.py | 91 ++++++++++++++++++- 18 files changed, 89 insertions(+), 106 deletions(-) delete mode 100644 tests/unit/plugins/lookup/onepassword/__init__.py delete mode 100644 tests/unit/plugins/lookup/onepassword/test_onepassword_cli_v1.py delete mode 100644 tests/unit/plugins/lookup/onepassword/test_onepassword_cli_v2.py rename tests/unit/plugins/lookup/{onepassword/common.py => onepassword_common.py} (96%) rename tests/unit/plugins/lookup/{onepassword/conftest.py => onepassword_conftest.py} (100%) rename tests/unit/plugins/lookup/{onepassword/fixtures => onepassword_fixtures}/v1_out_01.json (100%) rename tests/unit/plugins/lookup/{onepassword/fixtures => onepassword_fixtures}/v1_out_01.json.license (100%) rename tests/unit/plugins/lookup/{onepassword/fixtures => onepassword_fixtures}/v1_out_02.json (100%) rename tests/unit/plugins/lookup/{onepassword/fixtures => onepassword_fixtures}/v1_out_02.json.license (100%) rename tests/unit/plugins/lookup/{onepassword/fixtures => onepassword_fixtures}/v1_out_03.json (100%) rename tests/unit/plugins/lookup/{onepassword/fixtures => onepassword_fixtures}/v1_out_03.json.license (100%) rename tests/unit/plugins/lookup/{onepassword/fixtures => onepassword_fixtures}/v2_out_01.json (100%) rename tests/unit/plugins/lookup/{onepassword/fixtures => onepassword_fixtures}/v2_out_01.json.license (100%) rename tests/unit/plugins/lookup/{onepassword/fixtures => onepassword_fixtures}/v2_out_02.json (100%) rename tests/unit/plugins/lookup/{onepassword/fixtures => onepassword_fixtures}/v2_out_02.json.license (100%) rename tests/unit/plugins/lookup/{onepassword/fixtures => onepassword_fixtures}/v2_out_03.json (100%) rename tests/unit/plugins/lookup/{onepassword/fixtures => onepassword_fixtures}/v2_out_03.json.license (100%) rename tests/unit/plugins/lookup/{onepassword => }/test_onepassword.py (68%) diff --git a/tests/unit/plugins/lookup/onepassword/__init__.py b/tests/unit/plugins/lookup/onepassword/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/unit/plugins/lookup/onepassword/test_onepassword_cli_v1.py b/tests/unit/plugins/lookup/onepassword/test_onepassword_cli_v1.py deleted file mode 100644 index dc9b44af66..0000000000 --- a/tests/unit/plugins/lookup/onepassword/test_onepassword_cli_v1.py +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright (c) 2022 Ansible Project -# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) -# SPDX-License-Identifier: GPL-3.0-or-later - -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -import pytest - - -from ansible_collections.community.general.plugins.lookup.onepassword import OnePassCLIv1 - - -@pytest.mark.parametrize( - ("args", "rc", "expected_call_args", "expected_call_kwargs", "expected"), - ( - ([], 0, ["get", "account"], {"ignore_errors": True}, True,), - ([], 1, ["get", "account"], {"ignore_errors": True}, False,), - (["acme"], 1, ["get", "account", "--account", "acme.1password.com"], {"ignore_errors": True}, False,), - ) -) -def test_assert_logged_in(mocker, args, rc, expected_call_args, expected_call_kwargs, expected): - mocker.patch.object(OnePassCLIv1, "_run", return_value=[rc, "", ""]) - - op_cli = OnePassCLIv1(*args) - result = op_cli.assert_logged_in() - - op_cli._run.assert_called_with(expected_call_args, **expected_call_kwargs) - assert result == expected - - -def test_full_signin(mocker): - mocker.patch.object(OnePassCLIv1, "_run", return_value=[0, "", ""]) - - op_cli = OnePassCLIv1( - subdomain="acme", - username="bob@acme.com", - secret_key="SECRET", - master_password="ONEKEYTORULETHEMALL", - ) - result = op_cli.full_signin() - - op_cli._run.assert_called_with([ - "signin", - "acme.1password.com", - b"bob@acme.com", - b"SECRET", - "--raw", - ], command_input=b"ONEKEYTORULETHEMALL") - assert result == [0, "", ""] diff --git a/tests/unit/plugins/lookup/onepassword/test_onepassword_cli_v2.py b/tests/unit/plugins/lookup/onepassword/test_onepassword_cli_v2.py deleted file mode 100644 index f9c3e48ab6..0000000000 --- a/tests/unit/plugins/lookup/onepassword/test_onepassword_cli_v2.py +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright (c) 2022 Ansible Project -# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) -# SPDX-License-Identifier: GPL-3.0-or-later - -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -import pytest - - -from ansible_collections.community.general.plugins.lookup.onepassword import OnePassCLIv2 - - -@pytest.mark.parametrize( - ("args", "out", "expected_call_args", "expected_call_kwargs", "expected"), - ( - ([], "list of accounts", ["account", "get"], {"ignore_errors": True}, True,), - (["acme"], "list of accounts", ["account", "get", "--account", "acme.1password.com"], {"ignore_errors": True}, True,), - ([], "", ["account", "list"], {}, False,), - ) -) -def test_assert_logged_in(mocker, args, out, expected_call_args, expected_call_kwargs, expected): - mocker.patch.object(OnePassCLIv2, "_run", return_value=[0, out, ""]) - op_cli = OnePassCLIv2(*args) - result = op_cli.assert_logged_in() - - op_cli._run.assert_called_with(expected_call_args, **expected_call_kwargs) - assert result == expected - - -def test_full_signin(mocker): - mocker.patch.object(OnePassCLIv2, "_run", return_value=[0, "", ""]) - - op_cli = OnePassCLIv2( - subdomain="acme", - username="bob@acme.com", - secret_key="SECRET", - master_password="ONEKEYTORULETHEMALL", - ) - result = op_cli.full_signin() - - op_cli._run.assert_called_with( - [ - "account", "add", "--raw", - "--address", "acme.1password.com", - "--email", b"bob@acme.com", - "--signin", - ], - command_input=b"ONEKEYTORULETHEMALL", - environment_update={'OP_SECRET_KEY': 'SECRET'}, - ) - assert result == [0, "", ""] diff --git a/tests/unit/plugins/lookup/onepassword/common.py b/tests/unit/plugins/lookup/onepassword_common.py similarity index 96% rename from tests/unit/plugins/lookup/onepassword/common.py rename to tests/unit/plugins/lookup/onepassword_common.py index 141aea91a3..0929792251 100644 --- a/tests/unit/plugins/lookup/onepassword/common.py +++ b/tests/unit/plugins/lookup/onepassword_common.py @@ -15,7 +15,7 @@ from ansible_collections.community.general.plugins.lookup.onepassword import ( def load_file(file): - with open((os.path.join(os.path.dirname(__file__), "fixtures", file)), "r") as f: + with open((os.path.join(os.path.dirname(__file__), "onepassword_fixtures", file)), "r") as f: return json.loads(f.read()) diff --git a/tests/unit/plugins/lookup/onepassword/conftest.py b/tests/unit/plugins/lookup/onepassword_conftest.py similarity index 100% rename from tests/unit/plugins/lookup/onepassword/conftest.py rename to tests/unit/plugins/lookup/onepassword_conftest.py diff --git a/tests/unit/plugins/lookup/onepassword/fixtures/v1_out_01.json b/tests/unit/plugins/lookup/onepassword_fixtures/v1_out_01.json similarity index 100% rename from tests/unit/plugins/lookup/onepassword/fixtures/v1_out_01.json rename to tests/unit/plugins/lookup/onepassword_fixtures/v1_out_01.json diff --git a/tests/unit/plugins/lookup/onepassword/fixtures/v1_out_01.json.license b/tests/unit/plugins/lookup/onepassword_fixtures/v1_out_01.json.license similarity index 100% rename from tests/unit/plugins/lookup/onepassword/fixtures/v1_out_01.json.license rename to tests/unit/plugins/lookup/onepassword_fixtures/v1_out_01.json.license diff --git a/tests/unit/plugins/lookup/onepassword/fixtures/v1_out_02.json b/tests/unit/plugins/lookup/onepassword_fixtures/v1_out_02.json similarity index 100% rename from tests/unit/plugins/lookup/onepassword/fixtures/v1_out_02.json rename to tests/unit/plugins/lookup/onepassword_fixtures/v1_out_02.json diff --git a/tests/unit/plugins/lookup/onepassword/fixtures/v1_out_02.json.license b/tests/unit/plugins/lookup/onepassword_fixtures/v1_out_02.json.license similarity index 100% rename from tests/unit/plugins/lookup/onepassword/fixtures/v1_out_02.json.license rename to tests/unit/plugins/lookup/onepassword_fixtures/v1_out_02.json.license diff --git a/tests/unit/plugins/lookup/onepassword/fixtures/v1_out_03.json b/tests/unit/plugins/lookup/onepassword_fixtures/v1_out_03.json similarity index 100% rename from tests/unit/plugins/lookup/onepassword/fixtures/v1_out_03.json rename to tests/unit/plugins/lookup/onepassword_fixtures/v1_out_03.json diff --git a/tests/unit/plugins/lookup/onepassword/fixtures/v1_out_03.json.license b/tests/unit/plugins/lookup/onepassword_fixtures/v1_out_03.json.license similarity index 100% rename from tests/unit/plugins/lookup/onepassword/fixtures/v1_out_03.json.license rename to tests/unit/plugins/lookup/onepassword_fixtures/v1_out_03.json.license diff --git a/tests/unit/plugins/lookup/onepassword/fixtures/v2_out_01.json b/tests/unit/plugins/lookup/onepassword_fixtures/v2_out_01.json similarity index 100% rename from tests/unit/plugins/lookup/onepassword/fixtures/v2_out_01.json rename to tests/unit/plugins/lookup/onepassword_fixtures/v2_out_01.json diff --git a/tests/unit/plugins/lookup/onepassword/fixtures/v2_out_01.json.license b/tests/unit/plugins/lookup/onepassword_fixtures/v2_out_01.json.license similarity index 100% rename from tests/unit/plugins/lookup/onepassword/fixtures/v2_out_01.json.license rename to tests/unit/plugins/lookup/onepassword_fixtures/v2_out_01.json.license diff --git a/tests/unit/plugins/lookup/onepassword/fixtures/v2_out_02.json b/tests/unit/plugins/lookup/onepassword_fixtures/v2_out_02.json similarity index 100% rename from tests/unit/plugins/lookup/onepassword/fixtures/v2_out_02.json rename to tests/unit/plugins/lookup/onepassword_fixtures/v2_out_02.json diff --git a/tests/unit/plugins/lookup/onepassword/fixtures/v2_out_02.json.license b/tests/unit/plugins/lookup/onepassword_fixtures/v2_out_02.json.license similarity index 100% rename from tests/unit/plugins/lookup/onepassword/fixtures/v2_out_02.json.license rename to tests/unit/plugins/lookup/onepassword_fixtures/v2_out_02.json.license diff --git a/tests/unit/plugins/lookup/onepassword/fixtures/v2_out_03.json b/tests/unit/plugins/lookup/onepassword_fixtures/v2_out_03.json similarity index 100% rename from tests/unit/plugins/lookup/onepassword/fixtures/v2_out_03.json rename to tests/unit/plugins/lookup/onepassword_fixtures/v2_out_03.json diff --git a/tests/unit/plugins/lookup/onepassword/fixtures/v2_out_03.json.license b/tests/unit/plugins/lookup/onepassword_fixtures/v2_out_03.json.license similarity index 100% rename from tests/unit/plugins/lookup/onepassword/fixtures/v2_out_03.json.license rename to tests/unit/plugins/lookup/onepassword_fixtures/v2_out_03.json.license diff --git a/tests/unit/plugins/lookup/onepassword/test_onepassword.py b/tests/unit/plugins/lookup/test_onepassword.py similarity index 68% rename from tests/unit/plugins/lookup/onepassword/test_onepassword.py rename to tests/unit/plugins/lookup/test_onepassword.py index e9f8f42c96..ab7f3def29 100644 --- a/tests/unit/plugins/lookup/onepassword/test_onepassword.py +++ b/tests/unit/plugins/lookup/test_onepassword.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020 Ansible Project +# Copyright (c) 2022 Ansible Project # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) # SPDX-License-Identifier: GPL-3.0-or-later @@ -10,8 +10,13 @@ import itertools import json import pytest -from .conftest import OP_VERSION_FIXTURES -from .common import MOCK_ENTRIES +from .onepassword_conftest import ( # noqa: F401, pylint: disable=unused-import + OP_VERSION_FIXTURES, + fake_op, + opv1, + opv2, +) +from .onepassword_common import MOCK_ENTRIES from ansible.errors import AnsibleLookupError from ansible.plugins.loader import lookup_loader @@ -21,6 +26,86 @@ from ansible_collections.community.general.plugins.lookup.onepassword import ( ) +@pytest.mark.parametrize( + ("args", "rc", "expected_call_args", "expected_call_kwargs", "expected"), + ( + ([], 0, ["get", "account"], {"ignore_errors": True}, True,), + ([], 1, ["get", "account"], {"ignore_errors": True}, False,), + (["acme"], 1, ["get", "account", "--account", "acme.1password.com"], {"ignore_errors": True}, False,), + ) +) +def test_assert_logged_in_v1(mocker, args, rc, expected_call_args, expected_call_kwargs, expected): + mocker.patch.object(OnePassCLIv1, "_run", return_value=[rc, "", ""]) + + op_cli = OnePassCLIv1(*args) + result = op_cli.assert_logged_in() + + op_cli._run.assert_called_with(expected_call_args, **expected_call_kwargs) + assert result == expected + + +def test_full_signin_v1(mocker): + mocker.patch.object(OnePassCLIv1, "_run", return_value=[0, "", ""]) + + op_cli = OnePassCLIv1( + subdomain="acme", + username="bob@acme.com", + secret_key="SECRET", + master_password="ONEKEYTORULETHEMALL", + ) + result = op_cli.full_signin() + + op_cli._run.assert_called_with([ + "signin", + "acme.1password.com", + b"bob@acme.com", + b"SECRET", + "--raw", + ], command_input=b"ONEKEYTORULETHEMALL") + assert result == [0, "", ""] + + +@pytest.mark.parametrize( + ("args", "out", "expected_call_args", "expected_call_kwargs", "expected"), + ( + ([], "list of accounts", ["account", "get"], {"ignore_errors": True}, True,), + (["acme"], "list of accounts", ["account", "get", "--account", "acme.1password.com"], {"ignore_errors": True}, True,), + ([], "", ["account", "list"], {}, False,), + ) +) +def test_assert_logged_in_v2(mocker, args, out, expected_call_args, expected_call_kwargs, expected): + mocker.patch.object(OnePassCLIv2, "_run", return_value=[0, out, ""]) + op_cli = OnePassCLIv2(*args) + result = op_cli.assert_logged_in() + + op_cli._run.assert_called_with(expected_call_args, **expected_call_kwargs) + assert result == expected + + +def test_full_signin_v2(mocker): + mocker.patch.object(OnePassCLIv2, "_run", return_value=[0, "", ""]) + + op_cli = OnePassCLIv2( + subdomain="acme", + username="bob@acme.com", + secret_key="SECRET", + master_password="ONEKEYTORULETHEMALL", + ) + result = op_cli.full_signin() + + op_cli._run.assert_called_with( + [ + "account", "add", "--raw", + "--address", "acme.1password.com", + "--email", b"bob@acme.com", + "--signin", + ], + command_input=b"ONEKEYTORULETHEMALL", + environment_update={'OP_SECRET_KEY': 'SECRET'}, + ) + assert result == [0, "", ""] + + @pytest.mark.parametrize( ("version", "version_class"), ( From 2c762c475386b0eb322e685716219750e3dc3dd4 Mon Sep 17 00:00:00 2001 From: andre161292 Date: Sat, 25 Feb 2023 10:58:04 +0100 Subject: [PATCH 0201/1810] Added support for openSUSE MicroOS (#5998) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(zypper): Added condition to check for transactional-update binary to support microos closes #5615 * style(changelog): Made zypper-change uppercase Co-authored-by: Felix Fontein * fix(zypper): Removed check for /var/lib/misc/transactional-update.state * feat(zypper): Aligned transactional-update checks with zypper's * refactor(zypper): Removed dependency to psutil and made use of parsing /proc/mount * refactor(zypper): Removed need for regex, plus small refactoring --------- Co-authored-by: André Dörscheln Co-authored-by: Felix Fontein --- .../5615-zypper-transactional-update.yml | 2 ++ plugins/modules/zypper.py | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/5615-zypper-transactional-update.yml diff --git a/changelogs/fragments/5615-zypper-transactional-update.yml b/changelogs/fragments/5615-zypper-transactional-update.yml new file mode 100644 index 0000000000..5eb6bb8405 --- /dev/null +++ b/changelogs/fragments/5615-zypper-transactional-update.yml @@ -0,0 +1,2 @@ +bugfixes: + - "zypper - make package managing work on readonly filesystem of openSUSE MicroOS (https://github.com/ansible-collections/community.general/pull/5615)." diff --git a/plugins/modules/zypper.py b/plugins/modules/zypper.py index 775ff0fd6e..9ba5555e20 100644 --- a/plugins/modules/zypper.py +++ b/plugins/modules/zypper.py @@ -519,8 +519,21 @@ def repo_refresh(m): return retvals +def get_fs_type_and_readonly_state(mount_point): + with open('/proc/mounts', 'r') as file: + for line in file.readlines(): + fields = line.split() + path = fields[1] + if path == mount_point: + fs = fields[2] + opts = fields[3] + return fs, 'ro' in opts.split(',') + return None + + def transactional_updates(): - return os.path.exists('/var/lib/misc/transactional-update.state') + return os.path.exists('/usr/sbin/transactional-update') and get_fs_type_and_readonly_state('/') == ('btrfs', True) + # =========================================== # Main control flow From 95b8afdea3dd76a045ef00e86fbeb64bc8279c10 Mon Sep 17 00:00:00 2001 From: morco Date: Sat, 25 Feb 2023 10:59:18 +0100 Subject: [PATCH 0202/1810] providerType should be defaulted for keycloak_user_federation mappers (#5863) * feat(modules/keycloak_user_federation): mapper ... ... provider type should have a default value * add changelog fragment --------- Co-authored-by: Mirko Wilhelmi --- .../5863-providerType-defaulted-keycloak_userfed-mappers.yml | 2 ++ plugins/modules/keycloak_user_federation.py | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/5863-providerType-defaulted-keycloak_userfed-mappers.yml diff --git a/changelogs/fragments/5863-providerType-defaulted-keycloak_userfed-mappers.yml b/changelogs/fragments/5863-providerType-defaulted-keycloak_userfed-mappers.yml new file mode 100644 index 0000000000..6532ea92d9 --- /dev/null +++ b/changelogs/fragments/5863-providerType-defaulted-keycloak_userfed-mappers.yml @@ -0,0 +1,2 @@ +minor_changes: + - keycloak_user_federation - make ``org.keycloak.storage.ldap.mappers.LDAPStorageMapper`` the default value for mappers ``providerType`` (https://github.com/ansible-collections/community.general/pull/5863). diff --git a/plugins/modules/keycloak_user_federation.py b/plugins/modules/keycloak_user_federation.py index 8e1ddb12d9..c0dc5d271b 100644 --- a/plugins/modules/keycloak_user_federation.py +++ b/plugins/modules/keycloak_user_federation.py @@ -456,8 +456,9 @@ options: providerType: description: - - Component type for this mapper (only supported value is C(org.keycloak.storage.ldap.mappers.LDAPStorageMapper)). + - Component type for this mapper. type: str + default: org.keycloak.storage.ldap.mappers.LDAPStorageMapper config: description: @@ -782,7 +783,7 @@ def main(): name=dict(type='str'), parentId=dict(type='str'), providerId=dict(type='str'), - providerType=dict(type='str'), + providerType=dict(type='str', default='org.keycloak.storage.ldap.mappers.LDAPStorageMapper'), config=dict(type='dict'), ) From 92544993c0b60229e05d69da32e1e687684ceed6 Mon Sep 17 00:00:00 2001 From: Joseph Shanak Date: Sat, 25 Feb 2023 04:00:07 -0600 Subject: [PATCH 0203/1810] community.general.osx_defaults: Include stderr in error messages (#6011) * Update osx_defaults documentation examples * Include stderr in errors from osx_defaults * Add Changelog Fragment * Update changelogs/fragments/6011-osx-defaults-errors.yml Co-authored-by: Felix Fontein * Change format of examples * Update plugins/modules/osx_defaults.py Co-authored-by: Felix Fontein --------- Co-authored-by: Felix Fontein --- .../fragments/6011-osx-defaults-errors.yml | 2 ++ plugins/modules/osx_defaults.py | 33 +++++++++++-------- 2 files changed, 21 insertions(+), 14 deletions(-) create mode 100644 changelogs/fragments/6011-osx-defaults-errors.yml diff --git a/changelogs/fragments/6011-osx-defaults-errors.yml b/changelogs/fragments/6011-osx-defaults-errors.yml new file mode 100644 index 0000000000..49915d51a7 --- /dev/null +++ b/changelogs/fragments/6011-osx-defaults-errors.yml @@ -0,0 +1,2 @@ +minor_changes: + - "osx_defaults - include stderr in error messages (https://github.com/ansible-collections/community.general/pull/6011)." diff --git a/plugins/modules/osx_defaults.py b/plugins/modules/osx_defaults.py index 480f40af56..1615843732 100644 --- a/plugins/modules/osx_defaults.py +++ b/plugins/modules/osx_defaults.py @@ -78,49 +78,54 @@ notes: ''' EXAMPLES = r''' -# TODO: Describe what happens in each example - -- community.general.osx_defaults: +- name: Set boolean valued key for application domain + community.general.osx_defaults: domain: com.apple.Safari key: IncludeInternalDebugMenu type: bool value: true state: present -- community.general.osx_defaults: +- name: Set string valued key for global domain + community.general.osx_defaults: domain: NSGlobalDomain key: AppleMeasurementUnits type: string value: Centimeters state: present -- community.general.osx_defaults: +- name: Set int valued key for arbitrary plist + community.general.osx_defaults: domain: /Library/Preferences/com.apple.SoftwareUpdate key: AutomaticCheckEnabled type: int value: 1 become: true -- community.general.osx_defaults: +- name: Set int valued key only for the current host + community.general.osx_defaults: domain: com.apple.screensaver host: currentHost key: showClock type: int value: 1 -- community.general.osx_defaults: +- name: Defaults to global domain and setting value + community.general.osx_defaults: key: AppleMeasurementUnits type: string value: Centimeters -- community.general.osx_defaults: +- name: Setting an array valued key + community.general.osx_defaults: key: AppleLanguages type: array value: - en - nl -- community.general.osx_defaults: +- name: Removing a key + community.general.osx_defaults: domain: com.geekchimp.macable key: ExampleKeyToRemove state: absent @@ -264,7 +269,7 @@ class OSXDefaults(object): # If the RC is not 0, then terrible happened! Ooooh nooo! if rc != 0: - raise OSXDefaultsException("An error occurred while reading key type from defaults: %s" % out) + raise OSXDefaultsException("An error occurred while reading key type from defaults: %s" % err) # Ok, lets parse the type from output data_type = out.strip().replace('Type is ', '') @@ -275,9 +280,9 @@ class OSXDefaults(object): # Strip output out = out.strip() - # An non zero RC at this point is kinda strange... + # A non zero RC at this point is kinda strange... if rc != 0: - raise OSXDefaultsException("An error occurred while reading key value from defaults: %s" % out) + raise OSXDefaultsException("An error occurred while reading key value from defaults: %s" % err) # Convert string to list when type is array if data_type == "array": @@ -315,13 +320,13 @@ class OSXDefaults(object): expand_user_and_vars=False) if rc != 0: - raise OSXDefaultsException('An error occurred while writing value to defaults: %s' % out) + raise OSXDefaultsException('An error occurred while writing value to defaults: %s' % err) def delete(self): """ Deletes defaults key from domain """ rc, out, err = self.module.run_command(self._base_command() + ['delete', self.domain, self.key]) if rc != 0: - raise OSXDefaultsException("An error occurred while deleting key from defaults: %s" % out) + raise OSXDefaultsException("An error occurred while deleting key from defaults: %s" % err) # /commands ----------------------------------------------------------- }}} From 682c6fc967ffde3c11151972f31083423e3d008c Mon Sep 17 00:00:00 2001 From: Jonathan Kamens Date: Sat, 25 Feb 2023 05:00:43 -0500 Subject: [PATCH 0204/1810] nmcli: Treat order as significant when comparing address lists (#6048) * nmcli: Treat order as significant when comparing address lists Don't sort the old and new values for ipv4.addresses and ipv6.addresses before comparing them, because order matters in these parameters: the first address specified is the default source address for outbound connections. * Changelog fragment for #6048 * Update changelogs/fragments/6048-nmcli-addres-order.yml Co-authored-by: Felix Fontein --------- Co-authored-by: Felix Fontein --- changelogs/fragments/6048-nmcli-addres-order.yml | 2 ++ plugins/modules/nmcli.py | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/6048-nmcli-addres-order.yml diff --git a/changelogs/fragments/6048-nmcli-addres-order.yml b/changelogs/fragments/6048-nmcli-addres-order.yml new file mode 100644 index 0000000000..4de15cf084 --- /dev/null +++ b/changelogs/fragments/6048-nmcli-addres-order.yml @@ -0,0 +1,2 @@ +bugfixes: + - nmcli - order is significant for lists of addresses (https://github.com/ansible-collections/community.general/pull/6048). diff --git a/plugins/modules/nmcli.py b/plugins/modules/nmcli.py index 999e06cc12..61b0325fe9 100644 --- a/plugins/modules/nmcli.py +++ b/plugins/modules/nmcli.py @@ -2144,8 +2144,12 @@ class Nmcli(object): if isinstance(current_value, list) and isinstance(value, list): # compare values between two lists - if sorted(current_value) != sorted(value): - changed = True + if key in ('ipv4.addresses', 'ipv6.addresses'): + # The order of IP addresses matters because the first one + # is the default source address for outbound connections. + changed |= current_value != value + else: + changed |= sorted(current_value) != sorted(value) elif all([key == self.mtu_setting, self.type == 'dummy', current_value is None, value == 'auto', self.mtu is None]): value = None else: From f0529dcb0e8cdc009b349da185d0238a97bfce4b Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 25 Feb 2023 11:01:32 +0100 Subject: [PATCH 0205/1810] lxd plugins and modules: fix TLS/SSL context creation (#6034) Use correct purpose. --- changelogs/fragments/6034-lxd-tls.yml | 2 ++ plugins/module_utils/lxd.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/6034-lxd-tls.yml diff --git a/changelogs/fragments/6034-lxd-tls.yml b/changelogs/fragments/6034-lxd-tls.yml new file mode 100644 index 0000000000..975215f3e5 --- /dev/null +++ b/changelogs/fragments/6034-lxd-tls.yml @@ -0,0 +1,2 @@ +bugfixes: + - "lxd_* modules, lxd inventory plugin - fix TLS/SSL certificate validation problems by using the correct purpose when creating the TLS context (https://github.com/ansible-collections/community.general/issues/5616, https://github.com/ansible-collections/community.general/pull/6034)." diff --git a/plugins/module_utils/lxd.py b/plugins/module_utils/lxd.py index 007de4d8db..7f5362532a 100644 --- a/plugins/module_utils/lxd.py +++ b/plugins/module_utils/lxd.py @@ -60,7 +60,7 @@ class LXDClient(object): self.cert_file = cert_file self.key_file = key_file parts = generic_urlparse(urlparse(self.url)) - ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH) + ctx = ssl.create_default_context(ssl.Purpose.SERVER_AUTH) ctx.load_cert_chain(cert_file, keyfile=key_file) self.connection = HTTPSConnection(parts.get('netloc'), context=ctx) elif url.startswith('unix:'): From 53f729730bcc95c75354b11d6ad5f999f883fe9d Mon Sep 17 00:00:00 2001 From: Phil Kauffman Date: Sat, 25 Feb 2023 03:02:28 -0700 Subject: [PATCH 0206/1810] zfs_delegate_admin: fix: zfs allow cannot parse unknown uid/gid (#5943) When setting allow permissions for particular users or groups there will be circumstances when that user is not known to the host system. In that case the output of `zfs allow ` looks similar to this: $ sudo zfs allow tank/test ---- Permissions on tank/test --------------------------------------- Local+Descendent permissions: user (unknown: 1002) hold user zfsuser receive The fix in this commit removes ' (unknown: '+')' from the output leaving only the uid/gid. This allows the current parser to continue even if the uid/gid is not known. This situation occurs most often when moving a zpool from one system to another that may not have the same users/groups. Simply adding permissions to a user/group and then deleting the user/group from the system will cause this situation to occur. --- ...legate_admin-fix-zfs-allow-cannot-parse-unknown-uid-gid.yml | 2 ++ plugins/modules/zfs_delegate_admin.py | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 changelogs/fragments/5943-zfs_delegate_admin-fix-zfs-allow-cannot-parse-unknown-uid-gid.yml diff --git a/changelogs/fragments/5943-zfs_delegate_admin-fix-zfs-allow-cannot-parse-unknown-uid-gid.yml b/changelogs/fragments/5943-zfs_delegate_admin-fix-zfs-allow-cannot-parse-unknown-uid-gid.yml new file mode 100644 index 0000000000..f07ca8a9a5 --- /dev/null +++ b/changelogs/fragments/5943-zfs_delegate_admin-fix-zfs-allow-cannot-parse-unknown-uid-gid.yml @@ -0,0 +1,2 @@ +bugfixes: + - zfs_delegate_admin - zfs allow output can now be parsed when uids/gids are not known to the host system (https://github.com/ansible-collections/community.general/pull/5943). diff --git a/plugins/modules/zfs_delegate_admin.py b/plugins/modules/zfs_delegate_admin.py index 7891c32672..0536f1a283 100644 --- a/plugins/modules/zfs_delegate_admin.py +++ b/plugins/modules/zfs_delegate_admin.py @@ -184,6 +184,9 @@ class ZfsDelegateAdmin(object): scope = linemap.get(line, scope) if not scope: continue + if ' (unknown: ' in line: + line = line.replace('(unknown: ', '', 1) + line = line.replace(')', '', 1) try: if line.startswith('\tuser ') or line.startswith('\tgroup '): ent_type, ent, cur_perms = line.split() From 1877ef1510175566c5ce08129929c0fe253d67ff Mon Sep 17 00:00:00 2001 From: dima1206 <32818228+dima1206@users.noreply.github.com> Date: Sat, 25 Feb 2023 12:03:13 +0200 Subject: [PATCH 0207/1810] github_webhook: Don't include secret in the config if it's absent (#5994) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * github_webhook: Don't include secret in the config if it's absent * Add changelogs * Fix indentation * Apply suggestion to simplify the check Co-authored-by: Felix Fontein --------- Co-authored-by: dima1206 <–32818228+dima1206@users.noreply.github.com> Co-authored-by: Felix Fontein --- changelogs/fragments/5994-github-webhook-secret.yml | 2 ++ plugins/modules/github_webhook.py | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/5994-github-webhook-secret.yml diff --git a/changelogs/fragments/5994-github-webhook-secret.yml b/changelogs/fragments/5994-github-webhook-secret.yml new file mode 100644 index 0000000000..700703840c --- /dev/null +++ b/changelogs/fragments/5994-github-webhook-secret.yml @@ -0,0 +1,2 @@ +bugfixes: + - github_webhook - fix always changed state when no secret is provided (https://github.com/ansible-collections/community.general/pull/5994). \ No newline at end of file diff --git a/plugins/modules/github_webhook.py b/plugins/modules/github_webhook.py index 71e199adbe..d47b7a82fa 100644 --- a/plugins/modules/github_webhook.py +++ b/plugins/modules/github_webhook.py @@ -161,13 +161,18 @@ from ansible.module_utils.common.text.converters import to_native def _create_hook_config(module): - return { + hook_config = { "url": module.params["url"], "content_type": module.params["content_type"], - "secret": module.params.get("secret"), "insecure_ssl": "1" if module.params["insecure_ssl"] else "0" } + secret = module.params.get("secret") + if secret: + hook_config["secret"] = secret + + return hook_config + def create_hook(repo, module): config = _create_hook_config(module) From 7d3e6d1bb712cb15e62b9e20d16fdfe7e31cb59f Mon Sep 17 00:00:00 2001 From: morco Date: Sat, 25 Feb 2023 11:12:35 +0100 Subject: [PATCH 0208/1810] keycloak_group: support keycloak subgroups (#5814) * feat(module/keycloak_group): add support for ... ... handling subgroups * added changelog fragment and fixing sanity ... ... test issues * more sanity fixes * fix missing version and review issues * added missing licence header * fix docu * fix line beeing too long * replaced suboptimal string type prefixing ... ... with better subdict based approach * fix sanity issues * more sanity fixing * fixed more review issues * fix argument list too long * why is it failing? something wrong with the docu? * is it this line then? * undid group attribute removing, it does not ... ... belong into this PR * fix version_added for parents parameter --------- Co-authored-by: Mirko Wilhelmi --- .../5814-support-keycloak-subgroups.yml | 2 + .../identity/keycloak/keycloak.py | 138 ++++- plugins/modules/keycloak_group.py | 122 ++++- .../targets/keycloak_group/aliases | 5 + .../targets/keycloak_group/readme.adoc | 27 + .../targets/keycloak_group/tasks/main.yml | 501 ++++++++++++++++++ .../targets/keycloak_group/vars/main.yml | 10 + 7 files changed, 796 insertions(+), 9 deletions(-) create mode 100644 changelogs/fragments/5814-support-keycloak-subgroups.yml create mode 100644 tests/integration/targets/keycloak_group/aliases create mode 100644 tests/integration/targets/keycloak_group/readme.adoc create mode 100644 tests/integration/targets/keycloak_group/tasks/main.yml create mode 100644 tests/integration/targets/keycloak_group/vars/main.yml diff --git a/changelogs/fragments/5814-support-keycloak-subgroups.yml b/changelogs/fragments/5814-support-keycloak-subgroups.yml new file mode 100644 index 0000000000..a369db4422 --- /dev/null +++ b/changelogs/fragments/5814-support-keycloak-subgroups.yml @@ -0,0 +1,2 @@ +minor_changes: + - keycloak_group - add new optional module parameter ``parents`` to properly handle keycloak subgroups (https://github.com/ansible-collections/community.general/pull/5814). diff --git a/plugins/module_utils/identity/keycloak/keycloak.py b/plugins/module_utils/identity/keycloak/keycloak.py index 09b22b7561..15b665752d 100644 --- a/plugins/module_utils/identity/keycloak/keycloak.py +++ b/plugins/module_utils/identity/keycloak/keycloak.py @@ -42,6 +42,7 @@ URL_CLIENTTEMPLATE = "{url}/admin/realms/{realm}/client-templates/{id}" URL_CLIENTTEMPLATES = "{url}/admin/realms/{realm}/client-templates" URL_GROUPS = "{url}/admin/realms/{realm}/groups" URL_GROUP = "{url}/admin/realms/{realm}/groups/{groupid}" +URL_GROUP_CHILDREN = "{url}/admin/realms/{realm}/groups/{groupid}/children" URL_CLIENTSCOPES = "{url}/admin/realms/{realm}/client-scopes" URL_CLIENTSCOPE = "{url}/admin/realms/{realm}/client-scopes/{id}" @@ -1249,7 +1250,7 @@ class KeycloakAPI(object): self.module.fail_json(msg="Could not fetch group %s in realm %s: %s" % (gid, realm, str(e))) - def get_group_by_name(self, name, realm="master"): + def get_group_by_name(self, name, realm="master", parents=None): """ Fetch a keycloak group within a realm based on its name. The Keycloak API does not allow filtering of the Groups resource by name. @@ -1259,10 +1260,19 @@ class KeycloakAPI(object): If the group does not exist, None is returned. :param name: Name of the group to fetch. :param realm: Realm in which the group resides; default 'master' + :param parents: Optional list of parents when group to look for is a subgroup """ groups_url = URL_GROUPS.format(url=self.baseurl, realm=realm) try: - all_groups = self.get_groups(realm=realm) + if parents: + parent = self.get_subgroup_direct_parent(parents, realm) + + if not parent: + return None + + all_groups = parent['subGroups'] + else: + all_groups = self.get_groups(realm=realm) for group in all_groups: if group['name'] == name: @@ -1274,6 +1284,102 @@ class KeycloakAPI(object): self.module.fail_json(msg="Could not fetch group %s in realm %s: %s" % (name, realm, str(e))) + def _get_normed_group_parent(self, parent): + """ Converts parent dict information into a more easy to use form. + + :param parent: parent describing dict + """ + if parent['id']: + return (parent['id'], True) + + return (parent['name'], False) + + def get_subgroup_by_chain(self, name_chain, realm="master"): + """ Access a subgroup API object by walking down a given name/id chain. + + Groups can be given either as by name or by ID, the first element + must either be a toplvl group or given as ID, all parents must exist. + + If the group cannot be found, None is returned. + :param name_chain: Topdown ordered list of subgroup parent (ids or names) + its own name at the end + :param realm: Realm in which the group resides; default 'master' + """ + cp = name_chain[0] + + # for 1st parent in chain we must query the server + cp, is_id = self._get_normed_group_parent(cp) + + if is_id: + tmp = self.get_group_by_groupid(cp, realm=realm) + else: + # given as name, assume toplvl group + tmp = self.get_group_by_name(cp, realm=realm) + + if not tmp: + return None + + for p in name_chain[1:]: + for sg in tmp['subGroups']: + pv, is_id = self._get_normed_group_parent(p) + + if is_id: + cmpkey = "id" + else: + cmpkey = "name" + + if pv == sg[cmpkey]: + tmp = sg + break + + if not tmp: + return None + + return tmp + + def get_subgroup_direct_parent(self, parents, realm="master", children_to_resolve=None): + """ Get keycloak direct parent group API object for a given chain of parents. + + To succesfully work the API for subgroups we actually dont need + to "walk the whole tree" for nested groups but only need to know + the ID for the direct predecessor of current subgroup. This + method will guarantee us this information getting there with + as minimal work as possible. + + Note that given parent list can and might be incomplete at the + upper levels as long as it starts with an ID instead of a name + + If the group does not exist, None is returned. + :param parents: Topdown ordered list of subgroup parents + :param realm: Realm in which the group resides; default 'master' + """ + if children_to_resolve is None: + # start recursion by reversing parents (in optimal cases + # we dont need to walk the whole tree upwarts) + parents = list(reversed(parents)) + children_to_resolve = [] + + if not parents: + # walk complete parents list to the top, all names, no id's, + # try to resolve it assuming list is complete and 1st + # element is a toplvl group + return self.get_subgroup_by_chain(list(reversed(children_to_resolve)), realm=realm) + + cp = parents[0] + unused, is_id = self._get_normed_group_parent(cp) + + if is_id: + # current parent is given as ID, we can stop walking + # upwards searching for an entry point + return self.get_subgroup_by_chain([cp] + list(reversed(children_to_resolve)), realm=realm) + else: + # current parent is given as name, it must be resolved + # later, try next parent (recurse) + children_to_resolve.append(cp) + return self.get_subgroup_direct_parent( + parents[1:], + realm=realm, children_to_resolve=children_to_resolve + ) + def create_group(self, grouprep, realm="master"): """ Create a Keycloak group. @@ -1288,6 +1394,34 @@ class KeycloakAPI(object): self.module.fail_json(msg="Could not create group %s in realm %s: %s" % (grouprep['name'], realm, str(e))) + def create_subgroup(self, parents, grouprep, realm="master"): + """ Create a Keycloak subgroup. + + :param parents: list of one or more parent groups + :param grouprep: a GroupRepresentation of the group to be created. Must contain at minimum the field name. + :return: HTTPResponse object on success + """ + parent_id = "---UNDETERMINED---" + try: + parent_id = self.get_subgroup_direct_parent(parents, realm) + + if not parent_id: + raise Exception( + "Could not determine subgroup parent ID for given" + " parent chain {0}. Assure that all parents exist" + " already and the list is complete and properly" + " ordered, starts with an ID or starts at the" + " top level".format(parents) + ) + + parent_id = parent_id["id"] + url = URL_GROUP_CHILDREN.format(url=self.baseurl, realm=realm, groupid=parent_id) + return open_url(url, method='POST', http_agent=self.http_agent, headers=self.restheaders, timeout=self.connection_timeout, + data=json.dumps(grouprep), validate_certs=self.validate_certs) + except Exception as e: + self.module.fail_json(msg="Could not create subgroup %s for parent group %s in realm %s: %s" + % (grouprep['name'], parent_id, realm, str(e))) + def update_group(self, grouprep, realm="master"): """ Update an existing group. diff --git a/plugins/modules/keycloak_group.py b/plugins/modules/keycloak_group.py index 94d96543c8..399bc5b4fa 100644 --- a/plugins/modules/keycloak_group.py +++ b/plugins/modules/keycloak_group.py @@ -22,7 +22,7 @@ description: to your needs and a user having the expected roles. - The names of module options are snake_cased versions of the camelCase ones found in the - Keycloak API and its documentation at U(https://www.keycloak.org/docs-api/8.0/rest-api/index.html). + Keycloak API and its documentation at U(https://www.keycloak.org/docs-api/20.0.2/rest-api/index.html). - Attributes are multi-valued in the Keycloak API. All attributes are lists of individual values and will be returned that way by this module. You may pass single values for attributes when calling the module, @@ -42,7 +42,9 @@ options: description: - State of the group. - On C(present), the group will be created if it does not yet exist, or updated with the parameters you provide. - - On C(absent), the group will be removed if it exists. + - >- + On C(absent), the group will be removed if it exists. Be aware that absenting + a group with subgroups will automatically delete all its subgroups too. default: 'present' type: str choices: @@ -74,6 +76,38 @@ options: - A dict of key/value pairs to set as custom attributes for the group. - Values may be single values (e.g. a string) or a list of strings. + parents: + version_added: "6.4.0" + type: list + description: + - List of parent groups for the group to handle sorted top to bottom. + - >- + Set this to create a group as a subgroup of another group or groups (parents) or + when accessing an existing subgroup by name. + - >- + Not necessary to set when accessing an existing subgroup by its C(ID) because in + that case the group can be directly queried without necessarily knowing its parent(s). + elements: dict + suboptions: + id: + type: str + description: + - Identify parent by ID. + - Needs less API calls than using I(name). + - A deep parent chain can be started at any point when first given parent is given as ID. + - Note that in principle both ID and name can be specified at the same time + but current implementation only always use just one of them, with ID + being preferred. + name: + type: str + description: + - Identify parent by name. + - Needs more internal API calls than using I(id) to map names to ID's under the hood. + - When giving a parent chain with only names it must be complete up to the top. + - Note that in principle both ID and name can be specified at the same time + but current implementation only always use just one of them, with ID + being preferred. + notes: - Presently, the I(realmRoles), I(clientRoles) and I(access) attributes returned by the Keycloak API are read-only for groups. This limitation will be removed in a later version of this module. @@ -97,6 +131,7 @@ EXAMPLES = ''' auth_realm: master auth_username: USERNAME auth_password: PASSWORD + register: result_new_kcgrp delegate_to: localhost - name: Create a Keycloak group, authentication with token @@ -162,6 +197,64 @@ EXAMPLES = ''' - list - items delegate_to: localhost + +- name: Create a Keycloak subgroup of a base group (using parent name) + community.general.keycloak_group: + name: my-new-kc-group-sub + realm: MyCustomRealm + state: present + auth_client_id: admin-cli + auth_keycloak_url: https://auth.example.com/auth + auth_realm: master + auth_username: USERNAME + auth_password: PASSWORD + parents: + - name: my-new-kc-group + register: result_new_kcgrp_sub + delegate_to: localhost + +- name: Create a Keycloak subgroup of a base group (using parent id) + community.general.keycloak_group: + name: my-new-kc-group-sub2 + realm: MyCustomRealm + state: present + auth_client_id: admin-cli + auth_keycloak_url: https://auth.example.com/auth + auth_realm: master + auth_username: USERNAME + auth_password: PASSWORD + parents: + - id: "{{ result_new_kcgrp.end_state.id }}" + delegate_to: localhost + +- name: Create a Keycloak subgroup of a subgroup (using parent names) + community.general.keycloak_group: + name: my-new-kc-group-sub-sub + realm: MyCustomRealm + state: present + auth_client_id: admin-cli + auth_keycloak_url: https://auth.example.com/auth + auth_realm: master + auth_username: USERNAME + auth_password: PASSWORD + parents: + - name: my-new-kc-group + - name: my-new-kc-group-sub + delegate_to: localhost + +- name: Create a Keycloak subgroup of a subgroup (using direct parent id) + community.general.keycloak_group: + name: my-new-kc-group-sub-sub + realm: MyCustomRealm + state: present + auth_client_id: admin-cli + auth_keycloak_url: https://auth.example.com/auth + auth_realm: master + auth_username: USERNAME + auth_password: PASSWORD + parents: + - id: "{{ result_new_kcgrp_sub.end_state.id }}" + delegate_to: localhost ''' RETURN = ''' @@ -240,6 +333,13 @@ def main(): id=dict(type='str'), name=dict(type='str'), attributes=dict(type='dict'), + parents=dict( + type='list', elements='dict', + options=dict( + id=dict(type='str'), + name=dict(type='str') + ), + ), ) argument_spec.update(meta_args) @@ -266,6 +366,8 @@ def main(): name = module.params.get('name') attributes = module.params.get('attributes') + parents = module.params.get('parents') + # attributes in Keycloak have their values returned as lists # via the API. attributes is a dict, so we'll transparently convert # the values to lists. @@ -275,12 +377,12 @@ def main(): # Filter and map the parameters names that apply to the group group_params = [x for x in module.params - if x not in list(keycloak_argument_spec().keys()) + ['state', 'realm'] and + if x not in list(keycloak_argument_spec().keys()) + ['state', 'realm', 'parents'] and module.params.get(x) is not None] # See if it already exists in Keycloak if gid is None: - before_group = kc.get_group_by_name(name, realm=realm) + before_group = kc.get_group_by_name(name, realm=realm, parents=parents) else: before_group = kc.get_group_by_groupid(gid, realm=realm) @@ -323,9 +425,15 @@ def main(): if module.check_mode: module.exit_json(**result) - # create it - kc.create_group(desired_group, realm=realm) - after_group = kc.get_group_by_name(name, realm) + # create it ... + if parents: + # ... as subgroup of another parent group + kc.create_subgroup(parents, desired_group, realm=realm) + else: + # ... as toplvl base group + kc.create_group(desired_group, realm=realm) + + after_group = kc.get_group_by_name(name, realm, parents=parents) result['end_state'] = after_group diff --git a/tests/integration/targets/keycloak_group/aliases b/tests/integration/targets/keycloak_group/aliases new file mode 100644 index 0000000000..bd1f024441 --- /dev/null +++ b/tests/integration/targets/keycloak_group/aliases @@ -0,0 +1,5 @@ +# Copyright (c) Ansible Project +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +unsupported diff --git a/tests/integration/targets/keycloak_group/readme.adoc b/tests/integration/targets/keycloak_group/readme.adoc new file mode 100644 index 0000000000..1941e54efd --- /dev/null +++ b/tests/integration/targets/keycloak_group/readme.adoc @@ -0,0 +1,27 @@ +// Copyright (c) Ansible Project +// GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +// SPDX-License-Identifier: GPL-3.0-or-later + +To be able to run these integration tests a keycloak server must be +reachable under a specific url with a specific admin user and password. +The exact values expected for these parameters can be found in +'vars/main.yml' file. A simple way to do this is to use the official +keycloak docker images like this: + +---- +docker run --name mykeycloak -p 8080:8080 -e KC_HTTP_RELATIVE_PATH= -e KEYCLOAK_ADMIN= -e KEYCLOAK_ADMIN_PASSWORD= quay.io/keycloak/keycloak:20.0.2 start-dev +---- + +Example with concrete values inserted: + +---- +docker run --name mykeycloak -p 8080:8080 -e KC_HTTP_RELATIVE_PATH=/auth -e KEYCLOAK_ADMIN=admin -e KEYCLOAK_ADMIN_PASSWORD=password quay.io/keycloak/keycloak:20.0.2 start-dev +---- + +This test suite can run against a fresh unconfigured server instance +(no preconfiguration required) and cleans up after itself (undoes all +its config changes) as long as it runs through completly. While its active +it changes the server configuration in the following ways: + + * creating, modifying and deleting some keycloak groups + diff --git a/tests/integration/targets/keycloak_group/tasks/main.yml b/tests/integration/targets/keycloak_group/tasks/main.yml new file mode 100644 index 0000000000..50e61bab0f --- /dev/null +++ b/tests/integration/targets/keycloak_group/tasks/main.yml @@ -0,0 +1,501 @@ +--- +# Copyright (c) Ansible Project +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +- name: Create a keycloak group + community.general.keycloak_group: + auth_keycloak_url: "{{ url }}" + auth_realm: "{{ admin_realm }}" + auth_username: "{{ admin_user }}" + auth_password: "{{ admin_password }}" + realm: "{{ realm }}" + name: test-group + state: present + register: result + +- name: Assert group was created + assert: + that: + - result is changed + - result.end_state != {} + - result.end_state.name == "test-group" + - result.end_state.path == "/test-group" + - result.end_state.attributes == {} + - result.end_state.clientRoles == {} + - result.end_state.realmRoles == [] + - result.end_state.subGroups == [] + +- set_fact: + test_group_id: "{{ result.end_state.id }}" + +- name: Group creation rerun (test for idempotency) + community.general.keycloak_group: + auth_keycloak_url: "{{ url }}" + auth_realm: "{{ admin_realm }}" + auth_username: "{{ admin_user }}" + auth_password: "{{ admin_password }}" + realm: "{{ realm }}" + name: test-group + state: present + register: result + +- name: Assert that nothing has changed + assert: + that: + - result is not changed + - result.end_state != {} + - result.end_state.name == "test-group" + - result.end_state.path == "/test-group" + - result.end_state.attributes == {} + - result.end_state.clientRoles == {} + - result.end_state.realmRoles == [] + - result.end_state.subGroups == [] + +- name: Update the name of a keycloak group + community.general.keycloak_group: + auth_keycloak_url: "{{ url }}" + auth_realm: "{{ admin_realm }}" + auth_username: "{{ admin_user }}" + auth_password: "{{ admin_password }}" + realm: "{{ realm }}" + id: "{{ test_group_id }}" + name: new-test-group + state: present + register: result + +- name: Assert that group name was updated + assert: + that: + - result is changed + - result.end_state != {} + - result.end_state.name == "new-test-group" + - result.end_state.path == "/new-test-group" + - result.end_state.attributes == {} + - result.end_state.clientRoles == {} + - result.end_state.realmRoles == [] + - result.end_state.subGroups == [] + +- name: Delete a keycloak group by id + community.general.keycloak_group: + auth_keycloak_url: "{{ url }}" + auth_realm: "{{ admin_realm }}" + auth_username: "{{ admin_user }}" + auth_password: "{{ admin_password }}" + realm: "{{ realm }}" + id: "{{ test_group_id }}" + state: absent + register: result + +- name: Assert that group was deleted + assert: + that: + - result is changed + - result.end_state == {} + +- name: Redo group deletion (check for idempotency) + community.general.keycloak_group: + auth_keycloak_url: "{{ url }}" + auth_realm: "{{ admin_realm }}" + auth_username: "{{ admin_user }}" + auth_password: "{{ admin_password }}" + realm: "{{ realm }}" + id: "{{ test_group_id }}" + state: absent + register: result + +- name: Assert that nothing has changed + assert: + that: + - result is not changed + - result.end_state == {} + +- name: Create a keycloak group with some custom attributes + community.general.keycloak_group: + auth_keycloak_url: "{{ url }}" + auth_realm: "{{ admin_realm }}" + auth_username: "{{ admin_user }}" + auth_password: "{{ admin_password }}" + realm: "{{ realm }}" + name: my-new_group + attributes: + attrib1: value1 + attrib2: value2 + attrib3: + - item1 + - item2 + register: result + +- name: Assert that group was correctly created + assert: + that: + - result is changed + - result.end_state != {} + - result.end_state.name == "my-new_group" + - result.end_state.path == "/my-new_group" + - result.end_state.clientRoles == {} + - result.end_state.realmRoles == [] + - result.end_state.subGroups == [] + - result.end_state.attributes != {} + - result.end_state.attributes.attrib1 == ["value1"] + - result.end_state.attributes.attrib2 == ["value2"] + - result.end_state.attributes.attrib3 == ["item1", "item2"] + +- name: Delete a keycloak group based on name + community.general.keycloak_group: + auth_keycloak_url: "{{ url }}" + auth_realm: "{{ admin_realm }}" + auth_username: "{{ admin_user }}" + auth_password: "{{ admin_password }}" + realm: "{{ realm }}" + name: my-new_group + state: absent + register: result + +- name: Assert that group was deleted + assert: + that: + - result is changed + - result.end_state == {} + +## subgroup tests +## we already testet this so no asserts for this +- name: Create a new base group for subgroup testing (test setup) + community.general.keycloak_group: + auth_keycloak_url: "{{ url }}" + auth_realm: "{{ admin_realm }}" + auth_username: "{{ admin_user }}" + auth_password: "{{ admin_password }}" + realm: "{{ realm }}" + name: rootgrp + register: subgrp_basegrp_result + +- name: Create a subgroup using parent id + community.general.keycloak_group: + auth_keycloak_url: "{{ url }}" + auth_realm: "{{ admin_realm }}" + auth_username: "{{ admin_user }}" + auth_password: "{{ admin_password }}" + realm: "{{ realm }}" + name: subgrp1 + parents: + - id: "{{ subgrp_basegrp_result.end_state.id }}" + register: result + +- name: Assert that subgroup was correctly created + assert: + that: + - result is changed + - result.end_state != {} + - result.end_state.name == "subgrp1" + - result.end_state.path == "/rootgrp/subgrp1" + - result.end_state.attributes == {} + - result.end_state.clientRoles == {} + - result.end_state.realmRoles == [] + - result.end_state.subGroups == [] + +- name: Recreate a subgroup using parent id (test idempotency) + community.general.keycloak_group: + auth_keycloak_url: "{{ url }}" + auth_realm: "{{ admin_realm }}" + auth_username: "{{ admin_user }}" + auth_password: "{{ admin_password }}" + realm: "{{ realm }}" + name: subgrp1 + parents: + - id: "{{ subgrp_basegrp_result.end_state.id }}" + register: result + +- name: Assert that nothing has changed + assert: + that: + - result is not changed + - result.end_state != {} + - result.end_state.name == "subgrp1" + - result.end_state.path == "/rootgrp/subgrp1" + - result.end_state.attributes == {} + - result.end_state.clientRoles == {} + - result.end_state.realmRoles == [] + - result.end_state.subGroups == [] + +- name: Changing name of existing group + community.general.keycloak_group: + auth_keycloak_url: "{{ url }}" + auth_realm: "{{ admin_realm }}" + auth_username: "{{ admin_user }}" + auth_password: "{{ admin_password }}" + realm: "{{ realm }}" + id: "{{ result.end_state.id }}" + name: new-subgrp1 + parents: + - id: "{{ subgrp_basegrp_result.end_state.id }}" + register: result + +- name: Assert that subgroup name has changed correctly + assert: + that: + - result is changed + - result.end_state != {} + - result.end_state.name == "new-subgrp1" + - result.end_state.path == "/rootgrp/new-subgrp1" + - result.end_state.attributes == {} + - result.end_state.clientRoles == {} + - result.end_state.realmRoles == [] + - result.end_state.subGroups == [] + +- name: Create a subgroup using parent name + community.general.keycloak_group: + auth_keycloak_url: "{{ url }}" + auth_realm: "{{ admin_realm }}" + auth_username: "{{ admin_user }}" + auth_password: "{{ admin_password }}" + realm: "{{ realm }}" + name: subgrp2 + parents: + - name: rootgrp + register: result + +- name: Assert that subgroup was correctly created + assert: + that: + - result is changed + - result.end_state != {} + - result.end_state.name == "subgrp2" + - result.end_state.path == "/rootgrp/subgrp2" + - result.end_state.attributes == {} + - result.end_state.clientRoles == {} + - result.end_state.realmRoles == [] + - result.end_state.subGroups == [] + +- name: Recreate a subgroup using parent name (test idempotency) + community.general.keycloak_group: + auth_keycloak_url: "{{ url }}" + auth_realm: "{{ admin_realm }}" + auth_username: "{{ admin_user }}" + auth_password: "{{ admin_password }}" + realm: "{{ realm }}" + name: subgrp2 + parents: + - name: rootgrp + register: result + +- name: Assert that nothing has changed + assert: + that: + - result is not changed + - result.end_state != {} + - result.end_state.name == "subgrp2" + - result.end_state.path == "/rootgrp/subgrp2" + - result.end_state.attributes == {} + - result.end_state.clientRoles == {} + - result.end_state.realmRoles == [] + - result.end_state.subGroups == [] + +## subgroup of subgroup tests +- name: Create a subgroup of a subgroup using parent names (complete parent chain) + community.general.keycloak_group: + auth_keycloak_url: "{{ url }}" + auth_realm: "{{ admin_realm }}" + auth_username: "{{ admin_user }}" + auth_password: "{{ admin_password }}" + realm: "{{ realm }}" + name: subsubgrp + parents: + - name: rootgrp + - name: subgrp2 + register: result + +- name: Assert subgroup of subgroup was created + assert: + that: + - result is changed + - result.end_state != {} + - result.end_state.name == "subsubgrp" + - result.end_state.path == "/rootgrp/subgrp2/subsubgrp" + - result.end_state.attributes == {} + - result.end_state.clientRoles == {} + - result.end_state.realmRoles == [] + - result.end_state.subGroups == [] + +- name: ReCreate a subgroup of a subgroup using parent names (test idempotency) + community.general.keycloak_group: + auth_keycloak_url: "{{ url }}" + auth_realm: "{{ admin_realm }}" + auth_username: "{{ admin_user }}" + auth_password: "{{ admin_password }}" + realm: "{{ realm }}" + name: subsubgrp + parents: + - name: rootgrp + - name: subgrp2 + register: result_subsubgrp + +- name: Assert that nothing has changed + assert: + that: + - result_subsubgrp is not changed + - result_subsubgrp.end_state != {} + - result_subsubgrp.end_state.name == "subsubgrp" + - result_subsubgrp.end_state.path == "/rootgrp/subgrp2/subsubgrp" + - result_subsubgrp.end_state.attributes == {} + - result_subsubgrp.end_state.clientRoles == {} + - result_subsubgrp.end_state.realmRoles == [] + - result_subsubgrp.end_state.subGroups == [] + +- name: Create a subgroup of a subgroup using direct parent id (incomplete parent chain) + community.general.keycloak_group: + auth_keycloak_url: "{{ url }}" + auth_realm: "{{ admin_realm }}" + auth_username: "{{ admin_user }}" + auth_password: "{{ admin_password }}" + realm: "{{ realm }}" + name: subsubsubgrp + parents: + - id: "{{ result_subsubgrp.end_state.id }}" + register: result + +- name: Assert subgroup of subgroup was created + assert: + that: + - result is changed + - result.end_state != {} + - result.end_state.name == "subsubsubgrp" + - result.end_state.path == "/rootgrp/subgrp2/subsubgrp/subsubsubgrp" + - result.end_state.attributes == {} + - result.end_state.clientRoles == {} + - result.end_state.realmRoles == [] + - result.end_state.subGroups == [] + +- name: ReCreate a subgroup of a subgroup using direct parent id (test idempotency) + community.general.keycloak_group: + auth_keycloak_url: "{{ url }}" + auth_realm: "{{ admin_realm }}" + auth_username: "{{ admin_user }}" + auth_password: "{{ admin_password }}" + realm: "{{ realm }}" + name: subsubsubgrp + parents: + - id: "{{ result_subsubgrp.end_state.id }}" + register: result_subsubsubgrp + +- name: Assert that nothing changed + assert: + that: + - result_subsubsubgrp is not changed + - result_subsubsubgrp.end_state != {} + - result_subsubsubgrp.end_state.name == "subsubsubgrp" + - result_subsubsubgrp.end_state.path == "/rootgrp/subgrp2/subsubgrp/subsubsubgrp" + - result_subsubsubgrp.end_state.attributes == {} + - result_subsubsubgrp.end_state.clientRoles == {} + - result_subsubsubgrp.end_state.realmRoles == [] + - result_subsubsubgrp.end_state.subGroups == [] + +## subgroup deletion tests +## note: in principle we already have tested group deletion in general +## enough already, but what makes it interesting here again is to +## see it works also properly for subgroups and groups with subgroups +- name: Deleting a subgroup by id (no parents needed) + community.general.keycloak_group: + auth_keycloak_url: "{{ url }}" + auth_realm: "{{ admin_realm }}" + auth_username: "{{ admin_user }}" + auth_password: "{{ admin_password }}" + realm: "{{ realm }}" + id: "{{ result_subsubsubgrp.end_state.id }}" + state: absent + register: result + +- name: Assert that subgroup was deleted + assert: + that: + - result is changed + - result.end_state == {} + +- name: Redo subgroup deletion (idempotency test) + community.general.keycloak_group: + auth_keycloak_url: "{{ url }}" + auth_realm: "{{ admin_realm }}" + auth_username: "{{ admin_user }}" + auth_password: "{{ admin_password }}" + realm: "{{ realm }}" + id: "{{ result_subsubsubgrp.end_state.id }}" + state: absent + register: result + +- name: Assert that nothing changed + assert: + that: + - result is not changed + - result.end_state == {} + +- name: Deleting a subgroup by name + community.general.keycloak_group: + auth_keycloak_url: "{{ url }}" + auth_realm: "{{ admin_realm }}" + auth_username: "{{ admin_user }}" + auth_password: "{{ admin_password }}" + realm: "{{ realm }}" + name: new-subgrp1 + parents: + - name: rootgrp + state: absent + register: result + +- name: Assert that subgroup was deleted + assert: + that: + - result is changed + - result.end_state == {} + +- name: Redo deleting a subgroup by name (idempotency test) + community.general.keycloak_group: + auth_keycloak_url: "{{ url }}" + auth_realm: "{{ admin_realm }}" + auth_username: "{{ admin_user }}" + auth_password: "{{ admin_password }}" + realm: "{{ realm }}" + name: new-subgrp1 + parents: + - name: rootgrp + state: absent + register: result + +- name: Assert that nothing has changed + assert: + that: + - result is not changed + - result.end_state == {} + +- name: Delete keycloak group which has subgroups + community.general.keycloak_group: + auth_keycloak_url: "{{ url }}" + auth_realm: "{{ admin_realm }}" + auth_username: "{{ admin_user }}" + auth_password: "{{ admin_password }}" + realm: "{{ realm }}" + name: rootgrp + state: absent + register: result + +- name: Assert that group was deleted + assert: + that: + - result is changed + - result.end_state == {} + +- name: Redo delete keycloak group which has subgroups (idempotency test) + community.general.keycloak_group: + auth_keycloak_url: "{{ url }}" + auth_realm: "{{ admin_realm }}" + auth_username: "{{ admin_user }}" + auth_password: "{{ admin_password }}" + realm: "{{ realm }}" + name: rootgrp + state: absent + register: result + +- name: Assert that group was deleted + assert: + that: + - result is not changed + - result.end_state == {} diff --git a/tests/integration/targets/keycloak_group/vars/main.yml b/tests/integration/targets/keycloak_group/vars/main.yml new file mode 100644 index 0000000000..e8aeb4f3fd --- /dev/null +++ b/tests/integration/targets/keycloak_group/vars/main.yml @@ -0,0 +1,10 @@ +--- +# Copyright (c) Ansible Project +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +url: http://localhost:8080/auth +admin_realm: master +admin_user: admin +admin_password: password +realm: master From b64929118ebf276169bd26c81e650579b3c3d207 Mon Sep 17 00:00:00 2001 From: schurzi Date: Sat, 25 Feb 2023 15:29:27 +0100 Subject: [PATCH 0209/1810] stop passing loader/dataloader since it has been deprecated by ansible (#6074) * stop passing loader/dataloader since it has been deprecated by ansible Signed-off-by: Martin Schurz * add changelog fragment Signed-off-by: Martin Schurz * explicitly pass None to keep compatibility to older Ansible versions Signed-off-by: Martin Schurz * use try/except to keep things compatible Signed-off-by: Martin Schurz * Update plugins/lookup/cartesian.py Co-authored-by: Felix Fontein * Update plugins/lookup/flattened.py Co-authored-by: Felix Fontein * Update plugins/lookup/flattened.py Co-authored-by: Felix Fontein * Update plugins/lookup/cartesian.py Co-authored-by: Felix Fontein * Update changelogs/fragments/6074-loader_in_listify.yml.yml Co-authored-by: Felix Fontein --------- Signed-off-by: Martin Schurz Co-authored-by: Felix Fontein --- changelogs/fragments/6074-loader_in_listify.yml.yml | 2 ++ plugins/lookup/cartesian.py | 7 ++++++- plugins/lookup/flattened.py | 7 ++++++- 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/6074-loader_in_listify.yml.yml diff --git a/changelogs/fragments/6074-loader_in_listify.yml.yml b/changelogs/fragments/6074-loader_in_listify.yml.yml new file mode 100644 index 0000000000..3c01cde754 --- /dev/null +++ b/changelogs/fragments/6074-loader_in_listify.yml.yml @@ -0,0 +1,2 @@ +minor_changes: + - cartesian and flattened lookup plugins - adjust to parameter deprecation in ansible-core 2.14's ``listify_lookup_plugin_terms`` helper function (https://github.com/ansible-collections/community.general/pull/6074). diff --git a/plugins/lookup/cartesian.py b/plugins/lookup/cartesian.py index d76e8f532a..d63f3943b0 100644 --- a/plugins/lookup/cartesian.py +++ b/plugins/lookup/cartesian.py @@ -66,7 +66,12 @@ class LookupModule(LookupBase): """ results = [] for x in terms: - intermediate = listify_lookup_plugin_terms(x, templar=self._templar, loader=self._loader) + try: + intermediate = listify_lookup_plugin_terms(x, templar=self._templar) + except TypeError: + # The loader argument is deprecated in ansible-core 2.14+. Fall back to + # pre-2.14 behavior for older ansible-core versions. + intermediate = listify_lookup_plugin_terms(x, templar=self._templar, loader=self._loader) results.append(intermediate) return results diff --git a/plugins/lookup/flattened.py b/plugins/lookup/flattened.py index 0f290e559d..e955b6478e 100644 --- a/plugins/lookup/flattened.py +++ b/plugins/lookup/flattened.py @@ -67,7 +67,12 @@ class LookupModule(LookupBase): if isinstance(term, string_types): # convert a variable to a list - term2 = listify_lookup_plugin_terms(term, templar=self._templar, loader=self._loader) + try: + term2 = listify_lookup_plugin_terms(term, templar=self._templar) + except TypeError: + # The loader argument is deprecated in ansible-core 2.14+. Fall back to + # pre-2.14 behavior for older ansible-core versions. + term2 = listify_lookup_plugin_terms(term, templar=self._templar, loader=self._loader) # but avoid converting a plain string to a list of one string if term2 != [term]: term = term2 From 3db0fcf1bd7ca635711c57ac71395c8c28cedd9e Mon Sep 17 00:00:00 2001 From: Mike Raineri Date: Sat, 25 Feb 2023 09:39:21 -0500 Subject: [PATCH 0210/1810] Adding jyundt to Redfish maintainers (#6072) --- .github/BOTMETA.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/BOTMETA.yml b/.github/BOTMETA.yml index 7a6a1c1eea..41e2e76ccc 100644 --- a/.github/BOTMETA.yml +++ b/.github/BOTMETA.yml @@ -1388,7 +1388,7 @@ macros: team_opennebula: ilicmilan meerkampdvv rsmontero xorel nilsding team_oracle: manojmeda mross22 nalsaber team_purestorage: bannaych dnix101 genegr lionmax opslounge raekins sdodsley sile16 - team_redfish: mraineri tomasg2012 xmadsen renxulei rajeevkallur bhavya06 + team_redfish: mraineri tomasg2012 xmadsen renxulei rajeevkallur bhavya06 jyundt team_rhn: FlossWare alikins barnabycourt vritant team_scaleway: remyleone abarbare team_solaris: bcoca fishman jasperla jpdasma mator scathatheworm troy2914 xen0l From 810f3b50fc288869e5643446e3fbfe97815efa64 Mon Sep 17 00:00:00 2001 From: Yannick Ihmels Date: Sat, 25 Feb 2023 22:40:17 +0100 Subject: [PATCH 0211/1810] Add `enabled` parameter to `flatpak_remote` (#5926) --- .../fragments/5926-flatpak-remote-enabled.yml | 2 + plugins/modules/flatpak_remote.py | 54 +++++++++- .../flatpak_remote/tasks/check_mode.yml | 100 ++++++++++++++++++ .../targets/flatpak_remote/tasks/setup.yml | 13 +++ .../targets/flatpak_remote/tasks/test.yml | 58 ++++++++++ 5 files changed, 226 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/5926-flatpak-remote-enabled.yml diff --git a/changelogs/fragments/5926-flatpak-remote-enabled.yml b/changelogs/fragments/5926-flatpak-remote-enabled.yml new file mode 100644 index 0000000000..95185e613e --- /dev/null +++ b/changelogs/fragments/5926-flatpak-remote-enabled.yml @@ -0,0 +1,2 @@ +minor_changes: + - flatpak_remote - add new boolean option ``enabled``. It controls, whether the remote is enabled or not (https://github.com/ansible-collections/community.general/pull/5926). diff --git a/plugins/modules/flatpak_remote.py b/plugins/modules/flatpak_remote.py index 2032e38b9c..9c097c411f 100644 --- a/plugins/modules/flatpak_remote.py +++ b/plugins/modules/flatpak_remote.py @@ -70,6 +70,12 @@ options: type: str choices: [ absent, present ] default: present + enabled: + description: + - Indicates whether this remote is enabled. + type: bool + default: true + version_added: 6.4.0 ''' EXAMPLES = r''' @@ -96,6 +102,12 @@ EXAMPLES = r''' community.general.flatpak_remote: name: flathub state: absent + +- name: Disable the flathub remote in the system installation + community.general.flatpak_remote: + name: flathub + state: present + enabled: false ''' RETURN = r''' @@ -148,7 +160,7 @@ def remove_remote(module, binary, name, method): def remote_exists(module, binary, name, method): """Check if the remote exists.""" - command = [binary, "remote-list", "-d", "--{0}".format(method)] + command = [binary, "remote-list", "--show-disabled", "--{0}".format(method)] # The query operation for the remote needs to be run even in check mode output = _flatpak_command(module, False, command) for line in output.splitlines(): @@ -160,6 +172,36 @@ def remote_exists(module, binary, name, method): return False +def enable_remote(module, binary, name, method): + """Enable a remote.""" + global result # pylint: disable=global-variable-not-assigned + command = [binary, "remote-modify", "--enable", "--{0}".format(method), name] + _flatpak_command(module, module.check_mode, command) + result['changed'] = True + + +def disable_remote(module, binary, name, method): + """Disable a remote.""" + global result # pylint: disable=global-variable-not-assigned + command = [binary, "remote-modify", "--disable", "--{0}".format(method), name] + _flatpak_command(module, module.check_mode, command) + result['changed'] = True + + +def remote_enabled(module, binary, name, method): + """Check if the remote is enabled.""" + command = [binary, "remote-list", "--show-disabled", "--{0}".format(method)] + # The query operation for the remote needs to be run even in check mode + output = _flatpak_command(module, False, command) + for line in output.splitlines(): + listed_remote = line.split() + if len(listed_remote) == 0: + continue + if listed_remote[0] == to_native(name): + return len(listed_remote) == 1 or "disabled" not in listed_remote[1].split(",") + return False + + def _flatpak_command(module, noop, command): global result # pylint: disable=global-variable-not-assigned result['command'] = ' '.join(command) @@ -182,6 +224,7 @@ def main(): choices=['user', 'system']), state=dict(type='str', default="present", choices=['absent', 'present']), + enabled=dict(type='bool', default=True), executable=dict(type='str', default="flatpak") ), # This module supports check mode @@ -192,6 +235,7 @@ def main(): flatpakrepo_url = module.params['flatpakrepo_url'] method = module.params['method'] state = module.params['state'] + enabled = module.params['enabled'] executable = module.params['executable'] binary = module.get_bin_path(executable, None) @@ -214,6 +258,14 @@ def main(): elif state == 'absent' and remote_already_exists: remove_remote(module, binary, name, method) + if state == 'present': + remote_already_enabled = remote_enabled(module, binary, to_bytes(name), method) + + if enabled and not remote_already_enabled: + enable_remote(module, binary, name, method) + if not enabled and remote_already_enabled: + disable_remote(module, binary, name, method) + module.exit_json(**result) diff --git a/tests/integration/targets/flatpak_remote/tasks/check_mode.yml b/tests/integration/targets/flatpak_remote/tasks/check_mode.yml index 9331531503..86db5bf56c 100644 --- a/tests/integration/targets/flatpak_remote/tasks/check_mode.yml +++ b/tests/integration/targets/flatpak_remote/tasks/check_mode.yml @@ -104,3 +104,103 @@ msg: | Removing a present flatpak remote a second time shall still mark module execution as changed in check mode + + +# - Tests with disabled flatpak remote ------------------------------------------ + +# enabled=true + +- name: Test activation of disabled flatpak remote (check mode) + flatpak_remote: + name: check-mode-disabled-test-remote + enabled: true + register: activation_result + check_mode: true + +- name: Verify activation of disabled flatpak remote test result (check mode) + assert: + that: + - activation_result is changed + msg: "Enabling an disabled flatpak remote shall mark module execution as changed" + +- name: Test non-existent idempotency of activation of disabled flatpak remote (check mode) + flatpak_remote: + name: check-mode-disabled-test-remote + enabled: true + register: double_activation_result + check_mode: true + +- name: > + Verify non-existent idempotency of activation of disabled flatpak remote + test result (check mode) + assert: + that: + - double_activation_result is changed + msg: | + Enabling an disabled flatpak remote a second time shall still mark module execution + as changed in check mode + +# enabled=false + +- name: Test deactivation of disabled flatpak remote not doing anything in check mode + flatpak_remote: + name: check-mode-disabled-test-remote + enabled: false + register: deactivation_result + check_mode: true + +- name: Verify deactivation of disabled flatpak remote test result (check mode) + assert: + that: + - deactivation_result is not changed + msg: "Disabling an disabled flatpak remote shall mark module execution as not changed" + + +# - Tests with enabled flatpak remote ------------------------------------------ + +# enabled=true + +- name: Test activation of enabled flatpak remote (check mode) + flatpak_remote: + name: check-mode-enabled-test-remote + enabled: true + register: activation_result + check_mode: true + +- name: Verify activation of enabled flatpak remote test result (check mode) + assert: + that: + - activation_result is not changed + msg: "Enabling a enabled flatpak remote shall mark module execution as not changed" + +# enabled=false + +- name: Test deactivation of enabled flatpak remote not doing anything in check mode + flatpak_remote: + name: check-mode-enabled-test-remote + enabled: false + register: deactivation_result + check_mode: true + +- name: Verify deactivation of enabled flatpak remote test result (check mode) + assert: + that: + - deactivation_result is changed + msg: "Disabling a enabled flatpak remote shall mark module execution as changed" + +- name: Test non-existent idempotency of deactivation of enabled flatpak remote (check mode) + flatpak_remote: + name: check-mode-enabled-test-remote + enabled: false + register: double_deactivation_result + check_mode: true + +- name: > + Verify non-existent idempotency of deactivation of enabled flatpak remote + test result (check mode) + assert: + that: + - double_deactivation_result is changed + msg: | + "Disabling a enabled flatpak remote a second time shall still mark module execution + as changed in check mode diff --git a/tests/integration/targets/flatpak_remote/tasks/setup.yml b/tests/integration/targets/flatpak_remote/tasks/setup.yml index 83f344cc40..55a14c9724 100644 --- a/tests/integration/targets/flatpak_remote/tasks/setup.yml +++ b/tests/integration/targets/flatpak_remote/tasks/setup.yml @@ -25,3 +25,16 @@ name: check-mode-test-remote flatpakrepo_url: /tmp/flatpak/repo/dummy-repo.flatpakrepo state: present + enabled: true +- name: Install disabled flatpak remote for testing check mode + flatpak_remote: + name: check-mode-disabled-test-remote + flatpakrepo_url: /tmp/flatpak/repo/dummy-repo.flatpakrepo + state: present + enabled: false +- name: Install enabled flatpak remote for testing check mode + flatpak_remote: + name: check-mode-enabled-test-remote + flatpakrepo_url: /tmp/flatpak/repo/dummy-repo.flatpakrepo + state: present + enabled: true diff --git a/tests/integration/targets/flatpak_remote/tasks/test.yml b/tests/integration/targets/flatpak_remote/tasks/test.yml index 134eead173..e847205ff1 100644 --- a/tests/integration/targets/flatpak_remote/tasks/test.yml +++ b/tests/integration/targets/flatpak_remote/tasks/test.yml @@ -48,6 +48,64 @@ msg: "Trying to update the URL of an existing flatpak remote shall not do anything" +# enabled=false + +- name: Test deactivation - {{ method }} + flatpak_remote: + name: flatpak-test + enabled: false + method: "{{ method }}" + register: deactivation_result + +- name: Verify deactivation test result - {{ method }} + assert: + that: + - deactivation_result is changed + msg: "enable=false shall disable flatpak remote when enabled" + +- name: Test idempotency of deactivation - {{ method }} + flatpak_remote: + name: flatpak-test + enabled: false + method: "{{ method }}" + register: double_deactivation_result + +- name: Verify idempotency of deactivation test result - {{ method }} + assert: + that: + - double_deactivation_result is not changed + msg: "enabled=false shall not do anything when flatpak remote is already disabled" + + +# enabled=false + +- name: Test activation - {{ method }} + flatpak_remote: + name: flatpak-test + enabled: true + method: "{{ method }}" + register: activation_result + +- name: Verify activation test result - {{ method }} + assert: + that: + - activation_result is changed + msg: "enable=true shall enable flatpak remote when disabled" + +- name: Test idempotency of activation - {{ method }} + flatpak_remote: + name: flatpak-test + enabled: true + method: "{{ method }}" + register: double_activation_result + +- name: Verify idempotency of activation test result - {{ method }} + assert: + that: + - double_activation_result is not changed + msg: "enabled=true shall not do anything when flatpak remote is already enabled" + + # state=absent - name: Test removal - {{ method }} From 094dc6b69c6ca4f54a261581962cdbf2956c0233 Mon Sep 17 00:00:00 2001 From: Roy Lenferink Date: Sun, 26 Feb 2023 14:03:30 +0100 Subject: [PATCH 0212/1810] cloudflare_dns: Fix setting SRV records with a root level entry (#5972) * cloudflare_dns: Fix setting SRV records with a root level entry * cloudflare_dns: Remove the part which deletes the zone from the SRV record name The cloudflare API accepts the record name + zone name to be sent. Removing that, will guarantee the module to be idempotent even though that line was added ~7 years ago for that specific reason: https://github.com/ansible/ansible-modules-extras/commit/7477fe51418dbb890faba8966282ab83e597e6af It seems the most logical explanition is that Cloudflare changed their API response somewhere over the last 7 years. * cloudflare_dns: Update the changelog fragment --- changelogs/fragments/5972-cloudflare-dns-srv-record.yml | 3 +++ plugins/modules/cloudflare_dns.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/5972-cloudflare-dns-srv-record.yml diff --git a/changelogs/fragments/5972-cloudflare-dns-srv-record.yml b/changelogs/fragments/5972-cloudflare-dns-srv-record.yml new file mode 100644 index 0000000000..a331b49d23 --- /dev/null +++ b/changelogs/fragments/5972-cloudflare-dns-srv-record.yml @@ -0,0 +1,3 @@ +bugfixes: + - "cloudflare_dns - fixed the possiblity of setting a root-level SRV DNS record (https://github.com/ansible-collections/community.general/pull/5972)." + - "cloudflare_dns - fixed the idempotency for SRV DNS records (https://github.com/ansible-collections/community.general/pull/5972)." diff --git a/plugins/modules/cloudflare_dns.py b/plugins/modules/cloudflare_dns.py index a0fa8a38b2..8f45fcef3b 100644 --- a/plugins/modules/cloudflare_dns.py +++ b/plugins/modules/cloudflare_dns.py @@ -694,10 +694,11 @@ class CloudflareAPI(object): "port": params['port'], "weight": params['weight'], "priority": params['priority'], - "name": params['record'][:-len('.' + params['zone'])], + "name": params['record'], "proto": params['proto'], "service": params['service'] } + new_record = {"type": params['type'], "ttl": params['ttl'], 'data': srv_data} search_value = str(params['weight']) + '\t' + str(params['port']) + '\t' + params['value'] search_record = params['service'] + '.' + params['proto'] + '.' + params['record'] From c8a2ac3a475ab490ad00f1db1a6197b108c66413 Mon Sep 17 00:00:00 2001 From: bluikko <14869000+bluikko@users.noreply.github.com> Date: Sun, 26 Feb 2023 20:04:57 +0700 Subject: [PATCH 0213/1810] sefcontext: add support for path substitutions (#5830) * sefcontext: add path substitution support (#1193) First commit for feedback, missing docs and tests. * sefcontext: add documentation * Add changelog fragment * Documentation formatting * Delete extra newline * pep8 fixes Fix indentation * Add version_added to arg docs * Add examples * Don't delete non-matching path substitutions * Add integration tests * Delete only substitutions if such arg passed Don't delete existing regular file context mappings if deletion of a path substitution was requested with the presence of the `equal` arg - delete only path substitutions in such case. Path substitutions and regular mappings may overlap. * Can only add args in minor releases :( * Cleanup before tests * Fix deletion using substitution Was comparing wrong var. * Fix test checking wrong var * Improve args documentation and examples List the default values for selevel, seuser. Add example for deleting path substitutions only. * Add attributes documentation block Not sure if should add become/delegate/async, shouldn't those work just like that without any specific code added for them? * and fix indentation on attribute block * Consistent indentation for attributes Confusing, most plugins indent with 4 spaces. But some use 2 like the rest of the code, so use 2. * Add missing ref for attribute block * Use correct c.g version in doc block Co-authored-by: Felix Fontein * Add full stop to changelog fragment Co-authored-by: Felix Fontein * Streamline documentation Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> * Support limiting deletion to setype Deleting file context mappings may be limited by passing setype or equal, if neither arg is passed then delete either setype/equal mappings that match. * Change arg name, diff mode output fix Change arg name from equal to substitute. Print target = subsitute in diff mode same way as semanage does. Also put back platform attribute, try to improve clumsy language in the substitute arg docs. * Delete even if arg setype not match existing Test 5 indicates that deletion is supposed to not check that the arg setype passed when deleting matches the setype of the mapping to delete. Delete any mapping that matches target, regardless of setype arg value. * Update arg name in tests * Too eager replacing Accidentally replaced seobject function names so fix them back * 4564: Fix invalid setype in doc example Change from httpd_git_rw_content_t which does not exist to httpd_sys_rw_content_t Fixes #4564 * Fix documentation attributes Additional fragment Co-authored-by: Felix Fontein * Update version_added in docs Bumping minor to 6.4.0 since it didn't make 6.3.0. * Add more description to the new arg docs Try to improve discoverability of the new feature and make it easier to understand without deep SELinux understanding. * Update platform to Linux in documentation * Add equal as alias for the new argument Improve discoverability of the new feature by adding an alias to the new module argument. The argument name "equal" will be easy to find for users who are not familiar with SELinux and who just try to match to the CLI tool `semanage`. * And add alias argument properly Previous commit missed actually adding the alias (added to docs only). --------- Co-authored-by: Felix Fontein Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> --- .../fragments/5830-sefcontext-path-subs.yml | 2 + plugins/modules/sefcontext.py | 157 ++++++++++++++---- .../targets/sefcontext/tasks/sefcontext.yml | 131 +++++++++++++++ 3 files changed, 254 insertions(+), 36 deletions(-) create mode 100644 changelogs/fragments/5830-sefcontext-path-subs.yml diff --git a/changelogs/fragments/5830-sefcontext-path-subs.yml b/changelogs/fragments/5830-sefcontext-path-subs.yml new file mode 100644 index 0000000000..51fb554fab --- /dev/null +++ b/changelogs/fragments/5830-sefcontext-path-subs.yml @@ -0,0 +1,2 @@ +minor_changes: + - sefcontext - add support for path substitutions (https://github.com/ansible-collections/community.general/issues/1193). diff --git a/plugins/modules/sefcontext.py b/plugins/modules/sefcontext.py index c2fee45ee2..b2fb367673 100644 --- a/plugins/modules/sefcontext.py +++ b/plugins/modules/sefcontext.py @@ -17,11 +17,14 @@ description: - Similar to the C(semanage fcontext) command. extends_documentation_fragment: - community.general.attributes + - community.general.attributes.platform attributes: check_mode: support: full diff_mode: support: full + platform: + platforms: linux options: target: description: @@ -46,21 +49,30 @@ options: default: a setype: description: - - SELinux type for the specified target. + - SELinux type for the specified I(target). type: str - required: true + substitute: + description: + - Path to use to substitute file context(s) for the specified I(target). The context labeling for the I(target) subtree is made equivalent to this path. + - This is also referred to as SELinux file context equivalence and it implements the C(equal) functionality of the SELinux management tools. + version_added: 6.4.0 + type: str + aliases: [ equal ] seuser: description: - - SELinux user for the specified target. + - SELinux user for the specified I(target). + - Defaults to C(system_u) for new file contexts and to existing value when modifying file contexts. type: str selevel: description: - - SELinux range for the specified target. + - SELinux range for the specified I(target). + - Defaults to C(s0) for new file contexts and to existing value when modifying file contexts. type: str aliases: [ serange ] state: description: - Whether the SELinux file context must be C(absent) or C(present). + - Specifying C(absent) without either I(setype) or I(substitute) deletes both SELinux type or path substitution mappings that match I(target). type: str choices: [ absent, present ] default: present @@ -77,6 +89,8 @@ options: default: false notes: - The changes are persistent across reboots. +- I(setype) and I(substitute) are mutually exclusive. +- If I(state=present) then one of I(setype) or I(substitute) is mandatory. - The M(community.general.sefcontext) module does not modify existing files to the new SELinux context(s), so it is advisable to first create the SELinux file contexts before creating files, or run C(restorecon) manually @@ -96,9 +110,26 @@ EXAMPLES = r''' - name: Allow apache to modify files in /srv/git_repos community.general.sefcontext: target: '/srv/git_repos(/.*)?' - setype: httpd_git_rw_content_t + setype: httpd_sys_rw_content_t state: present +- name: Substitute file contexts for path /srv/containers with /var/lib/containers + community.general.sefcontext: + target: /srv/containers + substitute: /var/lib/containers + state: present + +- name: Delete file context path substitution for /srv/containers + community.general.sefcontext: + target: /srv/containers + substitute: /var/lib/containers + state: absent + +- name: Delete any file context mappings for path /srv/git + community.general.sefcontext: + target: /srv/git + state: absent + - name: Apply new SELinux file context to filesystem ansible.builtin.command: restorecon -irv /srv/git_repos ''' @@ -170,7 +201,13 @@ def semanage_fcontext_exists(sefcontext, target, ftype): return None -def semanage_fcontext_modify(module, result, target, ftype, setype, do_reload, serange, seuser, sestore=''): +def semanage_fcontext_substitute_exists(sefcontext, target): + ''' Get the SELinux file context path substitution definition from policy. Return None if it does not exist. ''' + + return sefcontext.equiv_dist.get(target, sefcontext.equiv.get(target)) + + +def semanage_fcontext_modify(module, result, target, ftype, setype, substitute, do_reload, serange, seuser, sestore=''): ''' Add or modify SELinux file context mapping definition to the policy. ''' changed = False @@ -179,39 +216,63 @@ def semanage_fcontext_modify(module, result, target, ftype, setype, do_reload, s try: sefcontext = seobject.fcontextRecords(sestore) sefcontext.set_reload(do_reload) - exists = semanage_fcontext_exists(sefcontext, target, ftype) - if exists: - # Modify existing entry - orig_seuser, orig_serole, orig_setype, orig_serange = exists + if substitute is None: + exists = semanage_fcontext_exists(sefcontext, target, ftype) + if exists: + # Modify existing entry + orig_seuser, orig_serole, orig_setype, orig_serange = exists - if seuser is None: - seuser = orig_seuser - if serange is None: - serange = orig_serange + if seuser is None: + seuser = orig_seuser + if serange is None: + serange = orig_serange + + if setype != orig_setype or seuser != orig_seuser or serange != orig_serange: + if not module.check_mode: + sefcontext.modify(target, setype, ftype, serange, seuser) + changed = True + + if module._diff: + prepared_diff += '# Change to semanage file context mappings\n' + prepared_diff += '-%s %s %s:%s:%s:%s\n' % (target, ftype, orig_seuser, orig_serole, orig_setype, orig_serange) + prepared_diff += '+%s %s %s:%s:%s:%s\n' % (target, ftype, seuser, orig_serole, setype, serange) + else: + # Add missing entry + if seuser is None: + seuser = 'system_u' + if serange is None: + serange = 's0' - if setype != orig_setype or seuser != orig_seuser or serange != orig_serange: if not module.check_mode: - sefcontext.modify(target, setype, ftype, serange, seuser) + sefcontext.add(target, setype, ftype, serange, seuser) changed = True if module._diff: - prepared_diff += '# Change to semanage file context mappings\n' - prepared_diff += '-%s %s %s:%s:%s:%s\n' % (target, ftype, orig_seuser, orig_serole, orig_setype, orig_serange) - prepared_diff += '+%s %s %s:%s:%s:%s\n' % (target, ftype, seuser, orig_serole, setype, serange) + prepared_diff += '# Addition to semanage file context mappings\n' + prepared_diff += '+%s %s %s:%s:%s:%s\n' % (target, ftype, seuser, 'object_r', setype, serange) else: - # Add missing entry - if seuser is None: - seuser = 'system_u' - if serange is None: - serange = 's0' + exists = semanage_fcontext_substitute_exists(sefcontext, target) + if exists: + # Modify existing path substitution entry + orig_substitute = exists - if not module.check_mode: - sefcontext.add(target, setype, ftype, serange, seuser) - changed = True + if substitute != orig_substitute: + if not module.check_mode: + sefcontext.modify_equal(target, substitute) + changed = True - if module._diff: - prepared_diff += '# Addition to semanage file context mappings\n' - prepared_diff += '+%s %s %s:%s:%s:%s\n' % (target, ftype, seuser, 'object_r', setype, serange) + if module._diff: + prepared_diff += '# Change to semanage file context path substitutions\n' + prepared_diff += '-%s = %s\n' % (target, orig_substitute) + prepared_diff += '+%s = %s\n' % (target, substitute) + else: + # Add missing path substitution entry + if not module.check_mode: + sefcontext.add_equal(target, substitute) + changed = True + if module._diff: + prepared_diff += '# Addition to semanage file context path substitutions\n' + prepared_diff += '+%s = %s\n' % (target, substitute) except Exception as e: module.fail_json(msg="%s: %s\n" % (e.__class__.__name__, to_native(e))) @@ -222,7 +283,7 @@ def semanage_fcontext_modify(module, result, target, ftype, setype, do_reload, s module.exit_json(changed=changed, seuser=seuser, serange=serange, **result) -def semanage_fcontext_delete(module, result, target, ftype, do_reload, sestore=''): +def semanage_fcontext_delete(module, result, target, ftype, setype, substitute, do_reload, sestore=''): ''' Delete SELinux file context mapping definition from the policy. ''' changed = False @@ -232,7 +293,8 @@ def semanage_fcontext_delete(module, result, target, ftype, do_reload, sestore=' sefcontext = seobject.fcontextRecords(sestore) sefcontext.set_reload(do_reload) exists = semanage_fcontext_exists(sefcontext, target, ftype) - if exists: + substitute_exists = semanage_fcontext_substitute_exists(sefcontext, target) + if exists and substitute is None: # Remove existing entry orig_seuser, orig_serole, orig_setype, orig_serange = exists @@ -243,6 +305,17 @@ def semanage_fcontext_delete(module, result, target, ftype, do_reload, sestore=' if module._diff: prepared_diff += '# Deletion to semanage file context mappings\n' prepared_diff += '-%s %s %s:%s:%s:%s\n' % (target, ftype, exists[0], exists[1], exists[2], exists[3]) + if substitute_exists and setype is None and ((substitute is not None and substitute_exists == substitute) or substitute is None): + # Remove existing path substitution entry + orig_substitute = substitute_exists + + if not module.check_mode: + sefcontext.delete(target, orig_substitute) + changed = True + + if module._diff: + prepared_diff += '# Deletion to semanage file context path substitutions\n' + prepared_diff += '-%s = %s\n' % (target, orig_substitute) except Exception as e: module.fail_json(msg="%s: %s\n" % (e.__class__.__name__, to_native(e))) @@ -259,12 +332,23 @@ def main(): ignore_selinux_state=dict(type='bool', default=False), target=dict(type='str', required=True, aliases=['path']), ftype=dict(type='str', default='a', choices=list(option_to_file_type_str.keys())), - setype=dict(type='str', required=True), + setype=dict(type='str'), + substitute=dict(type='str', aliases=['equal']), seuser=dict(type='str'), selevel=dict(type='str', aliases=['serange']), state=dict(type='str', default='present', choices=['absent', 'present']), reload=dict(type='bool', default=True), ), + mutually_exclusive=[ + ('setype', 'substitute'), + ('substitute', 'ftype'), + ('substitute', 'seuser'), + ('substitute', 'selevel'), + ], + required_if=[ + ('state', 'present', ('setype', 'substitute'), True), + ], + supports_check_mode=True, ) if not HAVE_SELINUX: @@ -281,17 +365,18 @@ def main(): target = module.params['target'] ftype = module.params['ftype'] setype = module.params['setype'] + substitute = module.params['substitute'] seuser = module.params['seuser'] serange = module.params['selevel'] state = module.params['state'] do_reload = module.params['reload'] - result = dict(target=target, ftype=ftype, setype=setype, state=state) + result = dict(target=target, ftype=ftype, setype=setype, substitute=substitute, state=state) if state == 'present': - semanage_fcontext_modify(module, result, target, ftype, setype, do_reload, serange, seuser) + semanage_fcontext_modify(module, result, target, ftype, setype, substitute, do_reload, serange, seuser) elif state == 'absent': - semanage_fcontext_delete(module, result, target, ftype, do_reload) + semanage_fcontext_delete(module, result, target, ftype, setype, substitute, do_reload) else: module.fail_json(msg='Invalid value of argument "state": {0}'.format(state)) diff --git a/tests/integration/targets/sefcontext/tasks/sefcontext.yml b/tests/integration/targets/sefcontext/tasks/sefcontext.yml index 8f5039b85a..9d6e7d1f70 100644 --- a/tests/integration/targets/sefcontext/tasks/sefcontext.yml +++ b/tests/integration/targets/sefcontext/tasks/sefcontext.yml @@ -23,6 +23,11 @@ setype: httpd_sys_content_t state: absent +- name: Ensure we start with a clean state + sefcontext: + path: /tmp/foo + state: absent + - name: Set SELinux file context of foo/bar sefcontext: path: '/tmp/foo/bar(/.*)?' @@ -100,3 +105,129 @@ that: - sixth is not changed - sixth.setype == 'unlabeled_t' + +- name: Set SELinux file context path substitution of foo + sefcontext: + path: /tmp/foo + substitute: /home + state: present + reload: no + register: subst_first + +- assert: + that: + - subst_first is changed + - subst_first.substitute == '/home' + +- name: Set SELinux file context path substitution of foo (again) + sefcontext: + path: /tmp/foo + substitute: /home + state: present + reload: no + register: subst_second + +- assert: + that: + - subst_second is not changed + - subst_second.substitute == '/home' + +- name: Change SELinux file context path substitution of foo + sefcontext: + path: /tmp/foo + substitute: /boot + state: present + reload: no + register: subst_third + +- assert: + that: + - subst_third is changed + - subst_third.substitute == '/boot' + +- name: Change SELinux file context path substitution of foo (again) + sefcontext: + path: /tmp/foo + substitute: /boot + state: present + reload: no + register: subst_fourth + +- assert: + that: + - subst_fourth is not changed + - subst_fourth.substitute == '/boot' + +- name: Try to delete non-existing SELinux file context path substitution of foo + sefcontext: + path: /tmp/foo + substitute: /dev + state: absent + reload: no + register: subst_fifth + +- assert: + that: + - subst_fifth is not changed + - subst_fifth.substitute == '/dev' + +- name: Delete SELinux file context path substitution of foo + sefcontext: + path: /tmp/foo + substitute: /boot + state: absent + reload: no + register: subst_sixth + +- assert: + that: + - subst_sixth is changed + - subst_sixth.substitute == '/boot' + +- name: Delete SELinux file context path substitution of foo (again) + sefcontext: + path: /tmp/foo + substitute: /boot + state: absent + reload: no + register: subst_seventh + +- assert: + that: + - subst_seventh is not changed + - subst_seventh.substitute == '/boot' + +- name: Set SELinux file context path substitution of foo + sefcontext: + path: /tmp/foo + substitute: /home + state: present + reload: no + register: subst_eighth + +- assert: + that: + - subst_eighth is changed + - subst_eighth.substitute == '/home' + +- name: Delete SELinux file context path substitution of foo + sefcontext: + path: /tmp/foo + state: absent + reload: no + register: subst_ninth + +- assert: + that: + - subst_ninth is changed + +- name: Delete SELinux file context path substitution of foo (again) + sefcontext: + path: /tmp/foo + state: absent + reload: no + register: subst_tenth + +- assert: + that: + - subst_tenth is not changed From 617be6e124caeb97d27352b199a816bb72afea67 Mon Sep 17 00:00:00 2001 From: Hemant Zope <42613258+zhemant@users.noreply.github.com> Date: Sun, 26 Feb 2023 14:13:22 +0100 Subject: [PATCH 0214/1810] Add new project features to API (#5986) * Add new project features to API * add changelog fragment * remove extra line from changelog * Update changelog formatting Co-authored-by: Felix Fontein --------- Co-authored-by: Felix Fontein --- .../5985-add-new-gitlab-api-features.yml | 2 + plugins/modules/gitlab_project.py | 72 +++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 changelogs/fragments/5985-add-new-gitlab-api-features.yml diff --git a/changelogs/fragments/5985-add-new-gitlab-api-features.yml b/changelogs/fragments/5985-add-new-gitlab-api-features.yml new file mode 100644 index 0000000000..7033a80bec --- /dev/null +++ b/changelogs/fragments/5985-add-new-gitlab-api-features.yml @@ -0,0 +1,2 @@ +minor_changes: + - gitlab_project - add ``releases_access_level``, ``environments_access_level``, ``feature_flags_access_level``, ``infrastructure_access_level``, ``monitor_access_level``, and ``security_and_compliance_access_level`` options (https://github.com/ansible-collections/community.general/pull/5986). diff --git a/plugins/modules/gitlab_project.py b/plugins/modules/gitlab_project.py index cd34db4431..d58ba35975 100644 --- a/plugins/modules/gitlab_project.py +++ b/plugins/modules/gitlab_project.py @@ -203,6 +203,54 @@ options: type: str choices: ["private", "disabled", "enabled"] version_added: "6.2.0" + releases_access_level: + description: + - C(private) means that accessing release is allowed only to project members. + - C(disabled) means that accessing release is disabled. + - C(enabled) means that accessing release is enabled. + type: str + choices: ["private", "disabled", "enabled"] + version_added: "6.4.0" + environments_access_level: + description: + - C(private) means that deployment to environment is allowed only to project members. + - C(disabled) means that deployment to environment is disabled. + - C(enabled) means that deployment to environment is enabled. + type: str + choices: ["private", "disabled", "enabled"] + version_added: "6.4.0" + feature_flags_access_level: + description: + - C(private) means that feature rollout is allowed only to project members. + - C(disabled) means that feature rollout is disabled. + - C(enabled) means that feature rollout is enabled. + type: str + choices: ["private", "disabled", "enabled"] + version_added: "6.4.0" + infrastructure_access_level: + description: + - C(private) means that configuring infrastructure is allowed only to project members. + - C(disabled) means that configuring infrastructure is disabled. + - C(enabled) means that configuring infrastructure is enabled. + type: str + choices: ["private", "disabled", "enabled"] + version_added: "6.4.0" + monitor_access_level: + description: + - C(private) means that monitoring health is allowed only to project members. + - C(disabled) means that monitoring health is disabled. + - C(enabled) means that monitoring health is enabled. + type: str + choices: ["private", "disabled", "enabled"] + version_added: "6.4.0" + security_and_compliance_access_level: + description: + - C(private) means that accessing security and complicance tab is allowed only to project members. + - C(disabled) means that accessing security and complicance tab is disabled. + - C(enabled) means that accessing security and complicance tab is enabled. + type: str + choices: ["private", "disabled", "enabled"] + version_added: "6.4.0" ''' EXAMPLES = r''' @@ -321,6 +369,12 @@ class GitLabProject(object): 'builds_access_level': options['builds_access_level'], 'forking_access_level': options['forking_access_level'], 'container_registry_access_level': options['container_registry_access_level'], + 'releases_access_level': options['releases_access_level'], + 'environments_access_level': options['environments_access_level'], + 'feature_flags_access_level': options['feature_flags_access_level'], + 'infrastructure_access_level': options['infrastructure_access_level'], + 'monitor_access_level': options['monitor_access_level'], + 'security_and_compliance_access_level': options['security_and_compliance_access_level'], } # Because we have already call userExists in main() if self.project_object is None: @@ -454,6 +508,12 @@ def main(): builds_access_level=dict(type='str', choices=['private', 'disabled', 'enabled']), forking_access_level=dict(type='str', choices=['private', 'disabled', 'enabled']), container_registry_access_level=dict(type='str', choices=['private', 'disabled', 'enabled']), + releases_access_level=dict(type='str', choices=['private', 'disabled', 'enabled']), + environments_access_level=dict(type='str', choices=['private', 'disabled', 'enabled']), + feature_flags_access_level=dict(type='str', choices=['private', 'disabled', 'enabled']), + infrastructure_access_level=dict(type='str', choices=['private', 'disabled', 'enabled']), + monitor_access_level=dict(type='str', choices=['private', 'disabled', 'enabled']), + security_and_compliance_access_level=dict(type='str', choices=['private', 'disabled', 'enabled']), )) module = AnsibleModule( @@ -504,6 +564,12 @@ def main(): builds_access_level = module.params['builds_access_level'] forking_access_level = module.params['forking_access_level'] container_registry_access_level = module.params['container_registry_access_level'] + releases_access_level = module.params['releases_access_level'] + environments_access_level = module.params['environments_access_level'] + feature_flags_access_level = module.params['feature_flags_access_level'] + infrastructure_access_level = module.params['infrastructure_access_level'] + monitor_access_level = module.params['monitor_access_level'] + security_and_compliance_access_level = module.params['security_and_compliance_access_level'] if default_branch and not initialize_with_readme: module.fail_json(msg="Param default_branch need param initialize_with_readme set to true") @@ -576,6 +642,12 @@ def main(): "builds_access_level": builds_access_level, "forking_access_level": forking_access_level, "container_registry_access_level": container_registry_access_level, + "releases_access_level": releases_access_level, + "environments_access_level": environments_access_level, + "feature_flags_access_level": feature_flags_access_level, + "infrastructure_access_level": infrastructure_access_level, + "monitor_access_level": monitor_access_level, + "security_and_compliance_access_level": security_and_compliance_access_level, }): module.exit_json(changed=True, msg="Successfully created or updated the project %s" % project_name, project=gitlab_project.project_object._attrs) From 29f5033737a7fd86349ff3daab7d7ee7db66ad00 Mon Sep 17 00:00:00 2001 From: Alex Groshev <38885591+haddystuff@users.noreply.github.com> Date: Sun, 26 Feb 2023 14:58:58 +0100 Subject: [PATCH 0215/1810] add persistent option for modprobe (#5424) * add persistent option for modprobe * add suggested changes + fix broken test * change modprobe module path in tests due to rebase * change persistent option type from bool to str with choices * fix unused import * add example with persistent option * fix some minor issues after review - move regexps compiling to __init__ - move AnsibleModule to build_module function and use this function in tests instead of AnsibleModule - fix terminlogy issue in documentation * fix unused-import --- .../4028-modprobe-persistent-option.yml | 3 + plugins/modules/modprobe.py | 156 +++++++- tests/unit/plugins/modules/test_modprobe.py | 377 ++++++++++++++++-- 3 files changed, 500 insertions(+), 36 deletions(-) create mode 100644 changelogs/fragments/4028-modprobe-persistent-option.yml diff --git a/changelogs/fragments/4028-modprobe-persistent-option.yml b/changelogs/fragments/4028-modprobe-persistent-option.yml new file mode 100644 index 0000000000..78c812bcbd --- /dev/null +++ b/changelogs/fragments/4028-modprobe-persistent-option.yml @@ -0,0 +1,3 @@ +--- +minor_changes: + - modprobe - add ``persistent`` option (https://github.com/ansible-collections/community.general/issues/4028, https://github.com/ansible-collections/community.general/pull/542). diff --git a/plugins/modules/modprobe.py b/plugins/modules/modprobe.py index e386117945..1cfdc3700b 100644 --- a/plugins/modules/modprobe.py +++ b/plugins/modules/modprobe.py @@ -42,6 +42,21 @@ options: description: - Modules parameters. default: '' + persistent: + type: str + choices: [ disabled, absent, present ] + default: disabled + description: + - Persistency between reboots for configured module. + - This option creates files in C(/etc/modules-load.d/) and C(/etc/modprobe.d/) that make your module configuration persistent during reboots. + - If C(present), adds module name to C(/etc/modules-load.d/) and params to C(/etc/modprobe.d/) so the module will be loaded on next reboot. + - If C(absent), will comment out module name from C(/etc/modules-load.d/) and comment out params from C(/etc/modprobe.d/) so the module will not be + loaded on next reboot. + - If C(disabled), will not toch anything and leave C(/etc/modules-load.d/) and C(/etc/modprobe.d/) as it is. + - Note that it is usually a better idea to rely on the automatic module loading by PCI IDs, USB IDs, DMI IDs or similar triggers encoded in the + kernel modules themselves instead of configuration like this. + - In fact, most modern kernel modules are prepared for automatic loading already. + - "B(Note:) This option works only with distributions that use C(systemd) when set to values other than C(disabled)." ''' EXAMPLES = ''' @@ -55,20 +70,31 @@ EXAMPLES = ''' name: dummy state: present params: 'numdummies=2' + +- name: Add the dummy module and make sure it is loaded after reboots + community.general.modprobe: + name: dummy + state: present + params: 'numdummies=2' + persistent: present ''' import os.path import platform import shlex import traceback +import re from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.common.text.converters import to_native RELEASE_VER = platform.release() +MODULES_LOAD_LOCATION = '/etc/modules-load.d' +PARAMETERS_FILES_LOCATION = '/etc/modprobe.d' class Modprobe(object): + def __init__(self, module): self.module = module self.modprobe_bin = module.get_bin_path('modprobe', True) @@ -77,9 +103,14 @@ class Modprobe(object): self.desired_state = module.params['state'] self.name = module.params['name'] self.params = module.params['params'] + self.persistent = module.params['persistent'] self.changed = False + self.re_find_module = re.compile(r'^ *{0} *(?:[#;].*)?\n?\Z'.format(self.name)) + self.re_find_params = re.compile(r'^options {0} \w+=\S+ *(?:[#;].*)?\n?\Z'.format(self.name)) + self.re_get_params_and_values = re.compile(r'^options {0} (\w+=\S+) *(?:[#;].*)?\n?\Z'.format(self.name)) + def load_module(self): command = [self.modprobe_bin] if self.check_mode: @@ -100,6 +131,117 @@ class Modprobe(object): if rc != 0: self.module.warn(stderr) + @property + def module_is_loaded_persistently(self): + for module_file in self.modules_files: + with open(module_file) as file: + for line in file: + if self.re_find_module.match(line): + return True + + return False + + @property + def params_is_set(self): + desired_params = set(self.params.split()) + + return desired_params == self.permanent_params + + @property + def permanent_params(self): + params = set() + + for modprobe_file in self.modprobe_files: + with open(modprobe_file) as file: + for line in file: + match = self.re_get_params_and_values.match(line) + if match: + params.add(match.group(1)) + + return params + + def create_module_file(self): + file_path = os.path.join(MODULES_LOAD_LOCATION, + self.name + '.conf') + with open(file_path, 'w') as file: + file.write(self.name + '\n') + + @property + def module_options_file_content(self): + file_content = ['options {0} {1}'.format(self.name, param) + for param in self.params.split()] + return '\n'.join(file_content) + '\n' + + def create_module_options_file(self): + new_file_path = os.path.join(PARAMETERS_FILES_LOCATION, + self.name + '.conf') + with open(new_file_path, 'w') as file: + file.write(self.module_options_file_content) + + def disable_old_params(self): + + for modprobe_file in self.modprobe_files: + with open(modprobe_file) as file: + file_content = file.readlines() + + content_changed = False + for index, line in enumerate(file_content): + if self.re_find_params.match(line): + file_content[index] = '#' + line + content_changed = True + + if content_changed: + with open(modprobe_file, 'w') as file: + file.write('\n'.join(file_content)) + + def disable_module_permanent(self): + + for module_file in self.modules_files: + with open(module_file) as file: + file_content = file.readlines() + + content_changed = False + for index, line in enumerate(file_content): + if self.re_find_module.match(line): + file_content[index] = '#' + line + content_changed = True + + if content_changed: + with open(module_file, 'w') as file: + file.write('\n'.join(file_content)) + + def load_module_permanent(self): + + if not self.module_is_loaded_persistently: + self.create_module_file() + self.changed = True + + if not self.params_is_set: + self.disable_old_params() + self.create_module_options_file() + self.changed = True + + def unload_module_permanent(self): + if self.module_is_loaded_persistently: + self.disable_module_permanent() + self.changed = True + + if self.permanent_params: + self.disable_old_params() + self.changed = True + + @property + def modules_files(self): + modules_paths = [os.path.join(MODULES_LOAD_LOCATION, path) + for path in os.listdir(MODULES_LOAD_LOCATION)] + return [path for path in modules_paths if os.path.isfile(path)] + + @property + def modprobe_files(self): + modules_paths = [os.path.join(PARAMETERS_FILES_LOCATION, path) + for path in os.listdir(PARAMETERS_FILES_LOCATION)] + return [path for path in modules_paths if os.path.isfile(path)] + def module_loaded(self): is_loaded = False try: @@ -144,16 +286,21 @@ class Modprobe(object): } -def main(): - module = AnsibleModule( +def build_module(): + return AnsibleModule( argument_spec=dict( name=dict(type='str', required=True), state=dict(type='str', default='present', choices=['absent', 'present']), params=dict(type='str', default=''), + persistent=dict(type='str', default='disabled', choices=['disabled', 'present', 'absent']), ), supports_check_mode=True, ) + +def main(): + module = build_module() + modprobe = Modprobe(module) if modprobe.desired_state == 'present' and not modprobe.module_loaded(): @@ -161,6 +308,11 @@ def main(): elif modprobe.desired_state == 'absent' and modprobe.module_loaded(): modprobe.unload_module() + if modprobe.persistent == 'present' and not (modprobe.module_is_loaded_persistently and modprobe.params_is_set): + modprobe.load_module_permanent() + elif modprobe.persistent == 'absent' and (modprobe.module_is_loaded_persistently or modprobe.permanent_params): + modprobe.unload_module_permanent() + module.exit_json(**modprobe.result) diff --git a/tests/unit/plugins/modules/test_modprobe.py b/tests/unit/plugins/modules/test_modprobe.py index cddbb1b5da..18695695a4 100644 --- a/tests/unit/plugins/modules/test_modprobe.py +++ b/tests/unit/plugins/modules/test_modprobe.py @@ -6,11 +6,12 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type +import sys from ansible_collections.community.general.tests.unit.plugins.modules.utils import ModuleTestCase, set_module_args from ansible_collections.community.general.tests.unit.compat.mock import patch from ansible_collections.community.general.tests.unit.compat.mock import Mock -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.community.general.plugins.modules.modprobe import Modprobe +from ansible_collections.community.general.tests.unit.compat.mock import mock_open +from ansible_collections.community.general.plugins.modules.modprobe import Modprobe, build_module class TestLoadModule(ModuleTestCase): @@ -40,14 +41,7 @@ class TestLoadModule(ModuleTestCase): state='present', )) - module = AnsibleModule( - argument_spec=dict( - name=dict(type='str', required=True), - state=dict(type='str', default='present', choices=['absent', 'present']), - params=dict(type='str', default=''), - ), - supports_check_mode=True, - ) + module = build_module() self.get_bin_path.side_effect = ['modprobe'] self.module_loaded.side_effect = [True] @@ -69,14 +63,7 @@ class TestLoadModule(ModuleTestCase): state='present', )) - module = AnsibleModule( - argument_spec=dict( - name=dict(type='str', required=True), - state=dict(type='str', default='present', choices=['absent', 'present']), - params=dict(type='str', default=''), - ), - supports_check_mode=True, - ) + module = build_module() module.warn = Mock() @@ -117,14 +104,7 @@ class TestUnloadModule(ModuleTestCase): state='absent', )) - module = AnsibleModule( - argument_spec=dict( - name=dict(type='str', required=True), - state=dict(type='str', default='present', choices=['absent', 'present']), - params=dict(type='str', default=''), - ), - supports_check_mode=True, - ) + module = build_module() self.get_bin_path.side_effect = ['modprobe'] self.module_loaded.side_effect = [False] @@ -146,14 +126,7 @@ class TestUnloadModule(ModuleTestCase): state='absent', )) - module = AnsibleModule( - argument_spec=dict( - name=dict(type='str', required=True), - state=dict(type='str', default='present', choices=['absent', 'present']), - params=dict(type='str', default=''), - ), - supports_check_mode=True, - ) + module = build_module() module.fail_json = Mock() @@ -174,3 +147,339 @@ class TestUnloadModule(ModuleTestCase): module.fail_json.assert_called_once_with( msg='', rc=1, stdout='', stderr='', **dummy_result ) + + +class TestModuleIsLoadedPersistently(ModuleTestCase): + def setUp(self): + if (sys.version_info[0] == 3 and sys.version_info[1] < 7) or (sys.version_info[0] == 2 and sys.version_info[1] < 7): + self.skipTest('open_mock doesnt support readline in earlier python versions') + + super(TestModuleIsLoadedPersistently, self).setUp() + + self.mock_get_bin_path = patch('ansible.module_utils.basic.AnsibleModule.get_bin_path') + + self.get_bin_path = self.mock_get_bin_path.start() + + def tearDown(self): + """Teardown.""" + super(TestModuleIsLoadedPersistently, self).tearDown() + + self.mock_get_bin_path.stop() + + def test_module_is_loaded(self): + + set_module_args(dict( + name='dummy', + state='present', + persistent='present' + )) + + module = build_module() + + self.get_bin_path.side_effect = ['modprobe'] + + modprobe = Modprobe(module) + with patch('ansible_collections.community.general.plugins.modules.modprobe.open', mock_open(read_data='dummy')) as mocked_file: + with patch('ansible_collections.community.general.plugins.modules.modprobe.Modprobe.modules_files'): + modprobe.modules_files = ['/etc/modules-load.d/dummy.conf'] + + assert modprobe.module_is_loaded_persistently + + mocked_file.assert_called_once_with('/etc/modules-load.d/dummy.conf') + + def test_module_is_not_loaded_empty_file(self): + + set_module_args(dict( + name='dummy', + state='present', + persistent='present' + )) + + module = build_module() + + self.get_bin_path.side_effect = ['modprobe'] + + modprobe = Modprobe(module) + with patch('ansible_collections.community.general.plugins.modules.modprobe.open', mock_open(read_data='')) as mocked_file: + with patch('ansible_collections.community.general.plugins.modules.modprobe.Modprobe.modules_files'): + modprobe.modules_files = ['/etc/modules-load.d/dummy.conf'] + + assert not modprobe.module_is_loaded_persistently + + mocked_file.assert_called_once_with('/etc/modules-load.d/dummy.conf') + + def test_module_is_not_loaded_no_files(self): + + set_module_args(dict( + name='dummy', + state='present', + persistent='present' + )) + + module = build_module() + + self.get_bin_path.side_effect = ['modprobe'] + + modprobe = Modprobe(module) + with patch('ansible_collections.community.general.plugins.modules.modprobe.Modprobe.modules_files'): + modprobe.modules_files = [] + + assert not modprobe.module_is_loaded_persistently + + +class TestPermanentParams(ModuleTestCase): + def setUp(self): + if (sys.version_info[0] == 3 and sys.version_info[1] < 7) or (sys.version_info[0] == 2 and sys.version_info[1] < 7): + self.skipTest('open_mock doesnt support readline in earlier python versions') + super(TestPermanentParams, self).setUp() + + self.mock_get_bin_path = patch('ansible.module_utils.basic.AnsibleModule.get_bin_path') + + self.get_bin_path = self.mock_get_bin_path.start() + + def tearDown(self): + """Teardown.""" + super(TestPermanentParams, self).tearDown() + + self.mock_get_bin_path.stop() + + def test_module_permanent_params_exist(self): + + files_content = [ + 'options dummy numdummies=4\noptions dummy dummy_parameter1=6', + 'options dummy dummy_parameter2=5 #Comment\noptions notdummy notdummy_param=5' + ] + mock_files_content = [mock_open(read_data=content).return_value for content in files_content] + + set_module_args(dict( + name='dummy', + state='present', + persistent='present' + )) + + module = build_module() + + self.get_bin_path.side_effect = ['modprobe'] + + modprobe = Modprobe(module) + + with patch('ansible_collections.community.general.plugins.modules.modprobe.open', mock_open()) as mocked_file: + mocked_file.side_effect = mock_files_content + with patch('ansible_collections.community.general.plugins.modules.modprobe.Modprobe.modprobe_files'): + modprobe.modprobe_files = ['/etc/modprobe.d/dummy1.conf', '/etc/modprobe.d/dummy2.conf'] + + assert modprobe.permanent_params == set(['numdummies=4', 'dummy_parameter1=6', 'dummy_parameter2=5']) + + def test_module_permanent_params_empty(self): + + files_content = [ + '', + '' + ] + mock_files_content = [mock_open(read_data=content).return_value for content in files_content] + + set_module_args(dict( + name='dummy', + state='present', + persistent='present' + )) + + module = build_module() + + self.get_bin_path.side_effect = ['modprobe'] + + modprobe = Modprobe(module) + + with patch('ansible_collections.community.general.plugins.modules.modprobe.open', mock_open(read_data='')) as mocked_file: + mocked_file.side_effect = mock_files_content + with patch('ansible_collections.community.general.plugins.modules.modprobe.Modprobe.modprobe_files'): + modprobe.modprobe_files = ['/etc/modprobe.d/dummy1.conf', '/etc/modprobe.d/dummy2.conf'] + + assert modprobe.permanent_params == set() + + +class TestCreateModuleFIle(ModuleTestCase): + def setUp(self): + super(TestCreateModuleFIle, self).setUp() + + self.mock_get_bin_path = patch('ansible.module_utils.basic.AnsibleModule.get_bin_path') + + self.get_bin_path = self.mock_get_bin_path.start() + + def tearDown(self): + """Teardown.""" + super(TestCreateModuleFIle, self).tearDown() + + self.mock_get_bin_path.stop() + + def test_create_file(self): + + set_module_args(dict( + name='dummy', + state='present', + persistent='present' + )) + + module = build_module() + + self.get_bin_path.side_effect = ['modprobe'] + + modprobe = Modprobe(module) + + with patch('ansible_collections.community.general.plugins.modules.modprobe.open', mock_open()) as mocked_file: + modprobe.create_module_file() + mocked_file.assert_called_once_with('/etc/modules-load.d/dummy.conf', 'w') + mocked_file().write.assert_called_once_with('dummy\n') + + +class TestCreateModuleOptionsFIle(ModuleTestCase): + def setUp(self): + super(TestCreateModuleOptionsFIle, self).setUp() + + self.mock_get_bin_path = patch('ansible.module_utils.basic.AnsibleModule.get_bin_path') + + self.get_bin_path = self.mock_get_bin_path.start() + + def tearDown(self): + """Teardown.""" + super(TestCreateModuleOptionsFIle, self).tearDown() + + self.mock_get_bin_path.stop() + + def test_create_file(self): + + set_module_args(dict( + name='dummy', + state='present', + params='numdummies=4', + persistent='present' + )) + + module = build_module() + + self.get_bin_path.side_effect = ['modprobe'] + + modprobe = Modprobe(module) + + with patch('ansible_collections.community.general.plugins.modules.modprobe.open', mock_open()) as mocked_file: + modprobe.create_module_options_file() + mocked_file.assert_called_once_with('/etc/modprobe.d/dummy.conf', 'w') + mocked_file().write.assert_called_once_with('options dummy numdummies=4\n') + + +class TestDisableOldParams(ModuleTestCase): + def setUp(self): + super(TestDisableOldParams, self).setUp() + + self.mock_get_bin_path = patch('ansible.module_utils.basic.AnsibleModule.get_bin_path') + + self.get_bin_path = self.mock_get_bin_path.start() + + def tearDown(self): + """Teardown.""" + super(TestDisableOldParams, self).tearDown() + + self.mock_get_bin_path.stop() + + def test_disable_old_params_file_changed(self): + mock_data = 'options dummy numdummies=4' + + set_module_args(dict( + name='dummy', + state='present', + params='numdummies=4', + persistent='present' + )) + + module = build_module() + + self.get_bin_path.side_effect = ['modprobe'] + + modprobe = Modprobe(module) + + with patch('ansible_collections.community.general.plugins.modules.modprobe.open', mock_open(read_data=mock_data)) as mocked_file: + with patch('ansible_collections.community.general.plugins.modules.modprobe.Modprobe.modprobe_files'): + modprobe.modprobe_files = ['/etc/modprobe.d/dummy1.conf'] + modprobe.disable_old_params() + mocked_file.assert_called_with('/etc/modprobe.d/dummy1.conf', 'w') + mocked_file().write.assert_called_once_with('#options dummy numdummies=4') + + def test_disable_old_params_file_unchanged(self): + mock_data = 'options notdummy numdummies=4' + + set_module_args(dict( + name='dummy', + state='present', + params='numdummies=4', + persistent='present' + )) + + module = build_module() + + self.get_bin_path.side_effect = ['modprobe'] + + modprobe = Modprobe(module) + + with patch('ansible_collections.community.general.plugins.modules.modprobe.open', mock_open(read_data=mock_data)) as mocked_file: + with patch('ansible_collections.community.general.plugins.modules.modprobe.Modprobe.modprobe_files'): + modprobe.modprobe_files = ['/etc/modprobe.d/dummy1.conf'] + modprobe.disable_old_params() + mocked_file.assert_called_once_with('/etc/modprobe.d/dummy1.conf') + + +class TestDisableModulePermanent(ModuleTestCase): + def setUp(self): + super(TestDisableModulePermanent, self).setUp() + + self.mock_get_bin_path = patch('ansible.module_utils.basic.AnsibleModule.get_bin_path') + + self.get_bin_path = self.mock_get_bin_path.start() + + def tearDown(self): + """Teardown.""" + super(TestDisableModulePermanent, self).tearDown() + + self.mock_get_bin_path.stop() + + def test_disable_module_permanent_file_changed(self): + + set_module_args(dict( + name='dummy', + state='present', + params='numdummies=4', + persistent='present' + )) + + module = build_module() + + self.get_bin_path.side_effect = ['modprobe'] + + modprobe = Modprobe(module) + + with patch('ansible_collections.community.general.plugins.modules.modprobe.open', mock_open(read_data='dummy')) as mocked_file: + with patch('ansible_collections.community.general.plugins.modules.modprobe.Modprobe.modules_files'): + modprobe.modules_files = ['/etc/modules-load.d/dummy.conf'] + modprobe.disable_module_permanent() + mocked_file.assert_called_with('/etc/modules-load.d/dummy.conf', 'w') + mocked_file().write.assert_called_once_with('#dummy') + + def test_disable_module_permanent_file_unchanged(self): + + set_module_args(dict( + name='dummy', + state='present', + params='numdummies=4', + persistent='present' + )) + + module = build_module() + + self.get_bin_path.side_effect = ['modprobe'] + + modprobe = Modprobe(module) + + with patch('ansible_collections.community.general.plugins.modules.modprobe.open', mock_open(read_data='notdummy')) as mocked_file: + with patch('ansible_collections.community.general.plugins.modules.modprobe.Modprobe.modules_files'): + modprobe.modules_files = ['/etc/modules-load.d/dummy.conf'] + modprobe.disable_module_permanent() + mocked_file.assert_called_once_with('/etc/modules-load.d/dummy.conf') From e8bdec27336d8d532b2224233c429d028f502211 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sun, 26 Feb 2023 15:37:16 +0100 Subject: [PATCH 0216/1810] jenkins_plugin: avoid undefined variable when updates file is not downloaded (#6100) Avoid undefined variable when updates file is not downloaded. --- changelogs/fragments/6100-jenkins_plugin.yml | 2 ++ plugins/modules/jenkins_plugin.py | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/6100-jenkins_plugin.yml diff --git a/changelogs/fragments/6100-jenkins_plugin.yml b/changelogs/fragments/6100-jenkins_plugin.yml new file mode 100644 index 0000000000..1f01d26083 --- /dev/null +++ b/changelogs/fragments/6100-jenkins_plugin.yml @@ -0,0 +1,2 @@ +bugfixes: + - "jenkins_plugin - fix error due to undefined variable when updates file is not downloaded (https://github.com/ansible-collections/community.general/pull/6100)." diff --git a/plugins/modules/jenkins_plugin.py b/plugins/modules/jenkins_plugin.py index b3ebf3f93c..2fbc83e03f 100644 --- a/plugins/modules/jenkins_plugin.py +++ b/plugins/modules/jenkins_plugin.py @@ -641,6 +641,8 @@ class JenkinsPlugin(object): self.module.fail_json( msg="Cannot close the tmp updates file %s." % tmp_updates_file, details=to_native(e)) + else: + tmp_updates_file = updates_file # Open the updates file try: @@ -651,15 +653,15 @@ class JenkinsPlugin(object): data = json.loads(f.readline()) except IOError as e: self.module.fail_json( - msg="Cannot open temporal updates file.", + msg="Cannot open%s updates file." % (" temporary" if tmp_updates_file != updates_file else ""), details=to_native(e)) except Exception as e: self.module.fail_json( - msg="Cannot load JSON data from the tmp updates file.", + msg="Cannot load JSON data from the%s updates file." % (" temporary" if tmp_updates_file != updates_file else ""), details=to_native(e)) # Move the updates file to the right place if we could read it - if download_updates: + if tmp_updates_file != updates_file: self.module.atomic_move(tmp_updates_file, updates_file) # Check if we have the plugin data available From 681fad92c2e6a65125b61d1719b0af5211975082 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sun, 26 Feb 2023 16:19:59 +0100 Subject: [PATCH 0217/1810] Fix changelog fragment type. --- changelogs/fragments/6074-loader_in_listify.yml.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/6074-loader_in_listify.yml.yml b/changelogs/fragments/6074-loader_in_listify.yml.yml index 3c01cde754..9a0852a88e 100644 --- a/changelogs/fragments/6074-loader_in_listify.yml.yml +++ b/changelogs/fragments/6074-loader_in_listify.yml.yml @@ -1,2 +1,2 @@ -minor_changes: +bugfixes: - cartesian and flattened lookup plugins - adjust to parameter deprecation in ansible-core 2.14's ``listify_lookup_plugin_terms`` helper function (https://github.com/ansible-collections/community.general/pull/6074). From 38adbec4837de72d08fb57fd7a6bec332eaa1245 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Mon, 27 Feb 2023 20:05:36 +0100 Subject: [PATCH 0218/1810] Next expected release is 6.5.0. --- galaxy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/galaxy.yml b/galaxy.yml index b44b59bf5a..11a63851a6 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -5,7 +5,7 @@ namespace: community name: general -version: 6.4.0 +version: 6.5.0 readme: README.md authors: - Ansible (https://github.com/ansible) From d2094669859fe4b48aa20f1b3ae868b61023b51d Mon Sep 17 00:00:00 2001 From: Reto Kupferschmid Date: Mon, 27 Feb 2023 20:26:01 +0100 Subject: [PATCH 0219/1810] add xorder_discovery parameter (#6109) * add xorder_discovery parameter * fix regex raw string * use dn logic from LdapGeneric * Update documentation. * Update changelog fragment. * Improve if. --------- Co-authored-by: Felix Fontein --- changelogs/fragments/6045-xorder-discovery.yml | 2 ++ plugins/doc_fragments/ldap.py | 11 +++++++++++ plugins/module_utils/ldap.py | 15 +++++++++++++-- plugins/modules/ldap_search.py | 1 - 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/6045-xorder-discovery.yml diff --git a/changelogs/fragments/6045-xorder-discovery.yml b/changelogs/fragments/6045-xorder-discovery.yml new file mode 100644 index 0000000000..5e7fb5a031 --- /dev/null +++ b/changelogs/fragments/6045-xorder-discovery.yml @@ -0,0 +1,2 @@ +minor_changes: + - ldap modules - add ``xorder_discovery`` option (https://github.com/ansible-collections/community.general/issues/6045, https://github.com/ansible-collections/community.general/pull/6109). diff --git a/plugins/doc_fragments/ldap.py b/plugins/doc_fragments/ldap.py index 1f04c0f600..8cbe276945 100644 --- a/plugins/doc_fragments/ldap.py +++ b/plugins/doc_fragments/ldap.py @@ -65,4 +65,15 @@ options: choices: ['external', 'gssapi'] default: external version_added: "2.0.0" + xorder_discovery: + description: + - Set the behavior on how to process Xordered DNs. + - C(enable) will perform a C(ONELEVEL) search below the superior RDN to find the matching DN. + - C(disable) will always use the DN unmodified (as passed by the I(dn) parameter). + - C(auto) will only perform a search if the first RDN does not contain an index number (C({x})). + - Possible choices are C(enable), C(auto), C(disable). + type: str + choices: ['enable', 'auto', 'disable'] + default: auto + version_added: "6.4.0" ''' diff --git a/plugins/module_utils/ldap.py b/plugins/module_utils/ldap.py index 03acaa58c5..cc6a37199b 100644 --- a/plugins/module_utils/ldap.py +++ b/plugins/module_utils/ldap.py @@ -10,6 +10,7 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type +import re import traceback from ansible.module_utils.common.text.converters import to_native @@ -39,6 +40,7 @@ def gen_specs(**specs): 'start_tls': dict(default=False, type='bool'), 'validate_certs': dict(default=True, type='bool'), 'sasl_class': dict(choices=['external', 'gssapi'], default='external', type='str'), + 'xorder_discovery': dict(choices=['enable', 'auto', 'disable'], default='auto', type='str'), }) return specs @@ -55,12 +57,16 @@ class LdapGeneric(object): self.start_tls = self.module.params['start_tls'] self.verify_cert = self.module.params['validate_certs'] self.sasl_class = self.module.params['sasl_class'] + self.xorder_discovery = self.module.params['xorder_discovery'] # Establish connection self.connection = self._connect_to_ldap() - # Try to find the X_ORDERed version of the DN - self.dn = self._find_dn() + if self.xorder_discovery == "enable" or (self.xorder_discovery == "auto" and not self._xorder_dn()): + # Try to find the X_ORDERed version of the DN + self.dn = self._find_dn() + else: + self.dn = self.module.params['dn'] def fail(self, msg, exn): self.module.fail_json( @@ -113,3 +119,8 @@ class LdapGeneric(object): self.fail("Cannot bind to the server.", e) return connection + + def _xorder_dn(self): + # match X_ORDERed DNs + regex = r"\w+=\{\d+\}.+" + return re.match(regex, self.module.params['dn']) is not None diff --git a/plugins/modules/ldap_search.py b/plugins/modules/ldap_search.py index 32efd4edd6..ad79a2d73a 100644 --- a/plugins/modules/ldap_search.py +++ b/plugins/modules/ldap_search.py @@ -135,7 +135,6 @@ class LdapSearch(LdapGeneric): def __init__(self, module): LdapGeneric.__init__(self, module) - self.dn = self.module.params['dn'] self.filterstr = self.module.params['filter'] self.attrlist = [] self._load_scope() From 03084d1133d5cddd2bcc4b234e92f2b0ddee6ac3 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Wed, 1 Mar 2023 21:28:29 +0100 Subject: [PATCH 0220/1810] Remove glitchcrab as maintainer for memset modules and module utils (#6116) Remove glitchcrab as maintainer for memset modules and module utils. --- .github/BOTMETA.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/BOTMETA.yml b/.github/BOTMETA.yml index 41e2e76ccc..ee427f21ac 100644 --- a/.github/BOTMETA.yml +++ b/.github/BOTMETA.yml @@ -294,7 +294,6 @@ files: maintainers: $team_manageiq $module_utils/memset.py: labels: cloud memset - maintainers: glitchcrab $module_utils/mh/: labels: module_helper maintainers: russoz @@ -783,7 +782,7 @@ files: labels: maven_artifact maintainers: tumbl3w33d turb $modules/memset_: - maintainers: glitchcrab + ignore: glitchcrab $modules/mksysb.py: labels: aix mksysb maintainers: $team_aix From 345a69304adb56fd0fdd961583b03e2c3d7ecc30 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Thu, 2 Mar 2023 19:01:15 +1300 Subject: [PATCH 0221/1810] opkg: fix bug when update_cache=true (#6119) * opkg: fix bug when update_cache=true * add changelog fragment --- changelogs/fragments/6119-opkg-update.yaml | 2 + plugins/modules/opkg.py | 17 ++++---- tests/unit/plugins/modules/test_opkg.py | 48 ++++++++++++++++++++++ 3 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 changelogs/fragments/6119-opkg-update.yaml diff --git a/changelogs/fragments/6119-opkg-update.yaml b/changelogs/fragments/6119-opkg-update.yaml new file mode 100644 index 0000000000..b7450074d1 --- /dev/null +++ b/changelogs/fragments/6119-opkg-update.yaml @@ -0,0 +1,2 @@ +bugfixes: + - opkg - fixes bug when using ``update_cache=true`` (https://github.com/ansible-collections/community.general/issues/6004). diff --git a/plugins/modules/opkg.py b/plugins/modules/opkg.py index 360bf453b7..d2ac314d03 100644 --- a/plugins/modules/opkg.py +++ b/plugins/modules/opkg.py @@ -148,6 +148,11 @@ class Opkg(StateModuleHelper): ), ) + if self.vars.update_cache: + rc, dummy, dummy = self.runner("update_cache").run() + if rc != 0: + self.do_raise("could not update package db") + @staticmethod def split_name_and_version(package): """ Split the name and the version when using the NAME=VERSION syntax """ @@ -164,10 +169,6 @@ class Opkg(StateModuleHelper): return want_installed == has_package def state_present(self): - if self.vars.update_cache: - dummy, rc, dummy = self.runner("update_cache").run() - if rc != 0: - self.do_raise("could not update package db") with self.runner("state force package") as ctx: for package in self.vars.name: pkg_name, pkg_version = self.split_name_and_version(package) @@ -176,16 +177,14 @@ class Opkg(StateModuleHelper): if not self._package_in_desired_state(pkg_name, want_installed=True, version=pkg_version): self.do_raise("failed to install %s" % package) self.vars.install_c += 1 + if self.verbosity >= 4: + self.vars.run_info = ctx.run_info if self.vars.install_c > 0: self.vars.msg = "installed %s package(s)" % (self.vars.install_c) else: self.vars.msg = "package(s) already present" def state_absent(self): - if self.vars.update_cache: - dummy, rc, dummy = self.runner("update_cache").run() - if rc != 0: - self.do_raise("could not update package db") with self.runner("state force package") as ctx: for package in self.vars.name: package, dummy = self.split_name_and_version(package) @@ -194,6 +193,8 @@ class Opkg(StateModuleHelper): if not self._package_in_desired_state(package, want_installed=False): self.do_raise("failed to remove %s" % package) self.vars.remove_c += 1 + if self.verbosity >= 4: + self.vars.run_info = ctx.run_info if self.vars.remove_c > 0: self.vars.msg = "removed %s package(s)" % (self.vars.remove_c) else: diff --git a/tests/unit/plugins/modules/test_opkg.py b/tests/unit/plugins/modules/test_opkg.py index f11347facc..8e52368ff9 100644 --- a/tests/unit/plugins/modules/test_opkg.py +++ b/tests/unit/plugins/modules/test_opkg.py @@ -150,6 +150,54 @@ TEST_CASES = [ ), ], ), + ModuleTestCase( + id="install_vim_updatecache", + input={"name": "vim-fuller", "state": "present", "update_cache": True}, + output={ + "msg": "installed 1 package(s)" + }, + run_command_calls=[ + RunCmdCall( + command=["/testbin/opkg", "update"], + environ={'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': False}, + rc=0, + out="", + err="", + ), + RunCmdCall( + command=["/testbin/opkg", "list-installed", "vim-fuller"], + environ={'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': False}, + rc=0, + out="", + err="", + ), + RunCmdCall( + command=["/testbin/opkg", "install", "vim-fuller"], + environ={'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': False}, + rc=0, + out=( + "Multiple packages (libgcc1 and libgcc1) providing same name marked HOLD or PREFER. Using latest.\n" + "Installing vim-fuller (9.0-1) to root...\n" + "Downloading https://downloads.openwrt.org/snapshots/packages/x86_64/packages/vim-fuller_9.0-1_x86_64.ipk\n" + "Installing terminfo (6.4-2) to root...\n" + "Downloading https://downloads.openwrt.org/snapshots/packages/x86_64/base/terminfo_6.4-2_x86_64.ipk\n" + "Installing libncurses6 (6.4-2) to root...\n" + "Downloading https://downloads.openwrt.org/snapshots/packages/x86_64/base/libncurses6_6.4-2_x86_64.ipk\n" + "Configuring terminfo.\n" + "Configuring libncurses6.\n" + "Configuring vim-fuller.\n" + ), + err="", + ), + RunCmdCall( + command=["/testbin/opkg", "list-installed", "vim-fuller"], + environ={'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': False}, + rc=0, + out="vim-fuller - 9.0-1 \n", # This output has the extra space at the end, to satisfy the behaviour of Yocto/OpenEmbedded's opkg + err="", + ), + ], + ), ] TEST_CASES_IDS = [item.id for item in TEST_CASES] From c0cb7958cb510610684088167b8c2e71987a6a17 Mon Sep 17 00:00:00 2001 From: AnatomicJC Date: Thu, 2 Mar 2023 07:14:58 +0100 Subject: [PATCH 0222/1810] Documentation: yum_versionlock typo fix (#6121) ##### SUMMARY Fixing typo in documentation, we need to use name parameter instead of package. ##### ISSUE TYPE - Docs Pull Request +label: docsite_pr --- plugins/modules/yum_versionlock.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/yum_versionlock.py b/plugins/modules/yum_versionlock.py index 95fd4dd7cf..e5d32dc77e 100644 --- a/plugins/modules/yum_versionlock.py +++ b/plugins/modules/yum_versionlock.py @@ -64,7 +64,7 @@ EXAMPLES = r''' - name: Remove lock from Apache / httpd to be updated again community.general.yum_versionlock: state: absent - package: httpd + name: httpd ''' RETURN = r''' From 9a97bc7c1146f612e02268a8b6df92490ad10ec2 Mon Sep 17 00:00:00 2001 From: Giacomo Olgeni Date: Fri, 3 Mar 2023 22:56:24 +0100 Subject: [PATCH 0223/1810] Add 'inventory_hostname' to the jail plugin documentation (#6118) This fixes the following warning on FreeBSD: [WARNING]: The "jail" connection plugin has an improperly configured remote target value, forcing "inventory_hostname" templated value instead of the string --- .../6118-jail-plugin-fix-default-inventory_hostname.yml | 2 ++ plugins/connection/jail.py | 1 + 2 files changed, 3 insertions(+) create mode 100644 changelogs/fragments/6118-jail-plugin-fix-default-inventory_hostname.yml diff --git a/changelogs/fragments/6118-jail-plugin-fix-default-inventory_hostname.yml b/changelogs/fragments/6118-jail-plugin-fix-default-inventory_hostname.yml new file mode 100644 index 0000000000..ac2cb5cf43 --- /dev/null +++ b/changelogs/fragments/6118-jail-plugin-fix-default-inventory_hostname.yml @@ -0,0 +1,2 @@ +bugfixes: + - "jail connection plugin - add ``inventory_hostname`` to vars under ``remote_addr``. This is needed for compatibility with ansible-core 2.13 (https://github.com/ansible-collections/community.general/pull/6118)." diff --git a/plugins/connection/jail.py b/plugins/connection/jail.py index d813780136..3a3edd4b18 100644 --- a/plugins/connection/jail.py +++ b/plugins/connection/jail.py @@ -22,6 +22,7 @@ DOCUMENTATION = ''' - Path to the jail default: inventory_hostname vars: + - name: inventory_hostname - name: ansible_host - name: ansible_jail_host remote_user: From 2dee3464dda014cbd3a5db4a924131c0b3663aaa Mon Sep 17 00:00:00 2001 From: Sam Potekhin <24751685+heaveaxy@users.noreply.github.com> Date: Sat, 4 Mar 2023 16:01:52 +0700 Subject: [PATCH 0224/1810] nmcli: fixed inability to change mtu on vlan connection (#6104) * tests updated Co-authored-by: Sam Potekhin --- changelogs/fragments/4387-nmcli-mtu-for-vlan-connection-fix.yml | 2 ++ plugins/modules/nmcli.py | 1 + tests/unit/plugins/modules/test_nmcli.py | 1 + 3 files changed, 4 insertions(+) create mode 100644 changelogs/fragments/4387-nmcli-mtu-for-vlan-connection-fix.yml diff --git a/changelogs/fragments/4387-nmcli-mtu-for-vlan-connection-fix.yml b/changelogs/fragments/4387-nmcli-mtu-for-vlan-connection-fix.yml new file mode 100644 index 0000000000..e867135b2a --- /dev/null +++ b/changelogs/fragments/4387-nmcli-mtu-for-vlan-connection-fix.yml @@ -0,0 +1,2 @@ +bugfixes: + - nmcli - implemented changing mtu value on vlan interfaces (https://github.com/ansible-collections/community.general/issues/4387). diff --git a/plugins/modules/nmcli.py b/plugins/modules/nmcli.py index 61b0325fe9..383e51a2c2 100644 --- a/plugins/modules/nmcli.py +++ b/plugins/modules/nmcli.py @@ -1772,6 +1772,7 @@ class Nmcli(object): 'dummy', 'ethernet', 'team-slave', + 'vlan', ) @property diff --git a/tests/unit/plugins/modules/test_nmcli.py b/tests/unit/plugins/modules/test_nmcli.py index c7e0baf7e5..86c34df443 100644 --- a/tests/unit/plugins/modules/test_nmcli.py +++ b/tests/unit/plugins/modules/test_nmcli.py @@ -663,6 +663,7 @@ ipv6.method: auto ipv6.ignore-auto-dns: no ipv6.ignore-auto-routes: no vlan.id: 10 +802-3-ethernet.mtu: auto """ TESTCASE_VXLAN = [ From 3d67f51824c65035083e995206738166bb3a0de0 Mon Sep 17 00:00:00 2001 From: Sargun Vohra Date: Sat, 4 Mar 2023 01:09:14 -0800 Subject: [PATCH 0225/1810] Fix Yarn global not working without explicit executable path (#6138) * Fix Yarn global not working without explicit executable path * changelog fragment * fix formatting and add test * oops --- changelogs/fragments/6138-fix-yarn-global.yml | 2 ++ plugins/modules/yarn.py | 14 +++++++------- tests/integration/targets/yarn/tasks/run.yml | 9 +++++++++ 3 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 changelogs/fragments/6138-fix-yarn-global.yml diff --git a/changelogs/fragments/6138-fix-yarn-global.yml b/changelogs/fragments/6138-fix-yarn-global.yml new file mode 100644 index 0000000000..30203ead6c --- /dev/null +++ b/changelogs/fragments/6138-fix-yarn-global.yml @@ -0,0 +1,2 @@ +bugfixes: + - yarn - fix ``global=true`` to not fail when `executable` wasn't specified (https://github.com/ansible-collections/community.general/pull/6132) diff --git a/plugins/modules/yarn.py b/plugins/modules/yarn.py index da9f9c79c3..02cfc4f8be 100644 --- a/plugins/modules/yarn.py +++ b/plugins/modules/yarn.py @@ -179,15 +179,11 @@ class Yarn(object): self.registry = kwargs['registry'] self.production = kwargs['production'] self.ignore_scripts = kwargs['ignore_scripts'] + self.executable = kwargs['executable'] # Specify a version of package if version arg passed in self.name_version = None - if kwargs['executable']: - self.executable = kwargs['executable'].split(' ') - else: - self.executable = [module.get_bin_path('yarn', True)] - if kwargs['version'] and self.name is not None: self.name_version = self.name + '@' + str(self.version) elif self.name is not None: @@ -328,7 +324,6 @@ def main(): version = module.params['version'] globally = module.params['global'] production = module.params['production'] - executable = module.params['executable'] registry = module.params['registry'] state = module.params['state'] ignore_scripts = module.params['ignore_scripts'] @@ -345,9 +340,14 @@ def main(): if state == 'latest': version = 'latest' + if module.params['executable']: + executable = module.params['executable'].split(' ') + else: + executable = [module.get_bin_path('yarn', True)] + # When installing globally, use the defined path for global node_modules if globally: - _rc, out, _err = module.run_command([executable, 'global', 'dir'], check_rc=True) + _rc, out, _err = module.run_command(executable + ['global', 'dir'], check_rc=True) path = out.strip() yarn = Yarn(module, diff --git a/tests/integration/targets/yarn/tasks/run.yml b/tests/integration/targets/yarn/tasks/run.yml index 93a3d5bb55..0d7d6fb421 100644 --- a/tests/integration/targets/yarn/tasks/run.yml +++ b/tests/integration/targets/yarn/tasks/run.yml @@ -108,6 +108,15 @@ that: - yarn_install_old_package is changed + - name: 'Again but without explicit executable path' + yarn: + path: '{{ remote_tmp_dir }}' + name: left-pad + version: 1.1.0 + state: present + environment: + PATH: '{{ yarn_bin_path }}:{{ node_bin_path }}:{{ ansible_env.PATH }}' + - name: 'Upgrade old package' yarn: path: '{{ remote_tmp_dir }}' From c077818c5dfd70ccda3b9d09fa5a8c9bf62f2938 Mon Sep 17 00:00:00 2001 From: cfiehe Date: Sat, 4 Mar 2023 10:14:58 +0100 Subject: [PATCH 0226/1810] Fixes #6112: community.general.gitlab_runner KeyError: 'access_level' (#6130) The fix ensures that no 'KeyError' is raised, when 'access_level' is not provided as module parameter or when 'access_level_on_creation' is false. Signed-off-by: Christoph Fiehe Co-authored-by: Christoph Fiehe --- .../6112-fix_key_error_in_gitlab_runner_creation_update.yml | 2 ++ plugins/modules/gitlab_runner.py | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/6112-fix_key_error_in_gitlab_runner_creation_update.yml diff --git a/changelogs/fragments/6112-fix_key_error_in_gitlab_runner_creation_update.yml b/changelogs/fragments/6112-fix_key_error_in_gitlab_runner_creation_update.yml new file mode 100644 index 0000000000..d752aed347 --- /dev/null +++ b/changelogs/fragments/6112-fix_key_error_in_gitlab_runner_creation_update.yml @@ -0,0 +1,2 @@ +bugfixes: + - gitlab_runner - fix ``KeyError`` on runner creation and update (https://github.com/ansible-collections/community.general/issues/6112). diff --git a/plugins/modules/gitlab_runner.py b/plugins/modules/gitlab_runner.py index f0da30e8f2..22d210b6c2 100644 --- a/plugins/modules/gitlab_runner.py +++ b/plugins/modules/gitlab_runner.py @@ -234,9 +234,8 @@ class GitLabRunner(object): 'maximum_timeout': options['maximum_timeout'], 'tag_list': options['tag_list'], } - if arguments['access_level'] is not None: + if options.get('access_level') is not None: arguments['access_level'] = options['access_level'] - # Because we have already call userExists in main() if self.runner_object is None: arguments['description'] = description @@ -251,7 +250,7 @@ class GitLabRunner(object): access_level_on_creation = False if not access_level_on_creation: - del arguments['access_level'] + arguments.pop('access_level', None) runner = self.create_runner(arguments) changed = True From 733e31c85f1015852e9ea44b35f1b16f35cd549d Mon Sep 17 00:00:00 2001 From: Chris Hoffman <99742+chrishoffman@users.noreply.github.com> Date: Sat, 4 Mar 2023 14:47:13 -0500 Subject: [PATCH 0227/1810] Remove chrishoffman as maintainer for yarn (#6143) Ignore chrishoffman from yarn --- .github/BOTMETA.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/BOTMETA.yml b/.github/BOTMETA.yml index ee427f21ac..c8de2cd2b0 100644 --- a/.github/BOTMETA.yml +++ b/.github/BOTMETA.yml @@ -1313,7 +1313,8 @@ files: labels: m:xml xml maintainers: dagwieers magnus919 tbielawa cmprescott sm4rk0 $modules/yarn.py: - maintainers: chrishoffman verkaufer + maintainers: verkaufer + ignore: chrishoffman $modules/yum_versionlock.py: maintainers: gyptazy aminvakil $modules/zfs: From 627371e2d8cfdd9be43a00e697a0d631036bcb10 Mon Sep 17 00:00:00 2001 From: Jonathan Kamens Date: Sat, 4 Mar 2023 14:51:50 -0500 Subject: [PATCH 0228/1810] dconf: Check for changes properly despite style of quotes used by user (#6049) dconf: parse GVariant values to check for equality whenever possible Direct string comparisons are an inaccurate way to compare two GVariant representations. For example, 'foo' and "foo" (including the quote marks, which are part of the representation) are equal GVariants but if you just do a string compare (remember, including the quotes) they'll be interpreted. We therefore want to use the `gi.repository` Python library to parse GVariant representations before comparing them whenever possible. However, we don't want to assume that this library will always be available or require it for Ansible to function, so we use a straight string comparison as a fallback when the library isn't available. This may result in some false positives, i.e., Ansible thinking a value is changing when it actually isn't, but will not result in incorrect values being written into `dconf`. Co-authored-by: Jonathan Kamens --- changelogs/fragments/6049-dconf-strings.yml | 2 + plugins/modules/dconf.py | 45 ++++++++++++++++++++- tests/unit/plugins/modules/test_dconf.py | 44 ++++++++++++++++++++ 3 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/6049-dconf-strings.yml create mode 100644 tests/unit/plugins/modules/test_dconf.py diff --git a/changelogs/fragments/6049-dconf-strings.yml b/changelogs/fragments/6049-dconf-strings.yml new file mode 100644 index 0000000000..1d194b3389 --- /dev/null +++ b/changelogs/fragments/6049-dconf-strings.yml @@ -0,0 +1,2 @@ +minor_changes: + - dconf - parse GVariants for equality comparison when the Python module ``gi.repository`` is available (https://github.com/ansible-collections/community.general/pull/6049). diff --git a/plugins/modules/dconf.py b/plugins/modules/dconf.py index 4d7ed34bf9..b5ece96ec1 100644 --- a/plugins/modules/dconf.py +++ b/plugins/modules/dconf.py @@ -21,11 +21,23 @@ description: - Since C(dconf) requires a running D-Bus session to change values, the module will try to detect an existing session and reuse it, or run the tool via C(dbus-run-session). +requirements: + - Optionally the C(gi.repository) Python library (usually included in the OS + on hosts which have C(dconf)); this will become a non-optional requirement + in a future major release of community.general. notes: - This module depends on C(psutil) Python library (version 4.0.0 and upwards), C(dconf), C(dbus-send), and C(dbus-run-session) binaries. Depending on distribution you are using, you may need to install additional packages to have these available. + - This module uses the C(gi.repository) Python library when available for + accurate comparison of values in C(dconf) to values specified in Ansible + code. C(gi.repository) is likely to be present on most systems which have + C(dconf) but may not be present everywhere. When it is missing, a simple + string comparison between values is used, and there may be false positives, + that is, Ansible may think that a value is being changed when it is not. + This fallback will be removed in a future version of this module, at which + point the module will stop working on hosts without C(gi.repository). - Detection of existing, running D-Bus session, required to change settings via C(dconf), is not 100% reliable due to implementation details of D-Bus daemon itself. This might lead to running applications not picking-up @@ -128,6 +140,12 @@ EXAMPLES = r""" import os import traceback +try: + from gi.repository.GLib import Variant, GError +except ImportError: + Variant = None + GError = AttributeError + PSUTIL_IMP_ERR = None try: import psutil @@ -258,6 +276,25 @@ class DconfPreference(object): # Check if dconf binary exists self.dconf_bin = self.module.get_bin_path('dconf', required=True) + @staticmethod + def variants_are_equal(canonical_value, user_value): + """Compare two string GVariant representations for equality. + + Assumes `canonical_value` is "canonical" in the sense that the type of + the variant is specified explicitly if it cannot be inferred; this is + true for textual representations of variants generated by the `dconf` + command. The type of `canonical_value` is used to parse `user_value`, + so the latter does not need to be explicitly typed. + + Returns True if the two values are equal. + """ + try: + variant1 = Variant.parse(None, canonical_value) + variant2 = Variant.parse(variant1.get_type(), user_value) + return variant1 == variant2 + except GError: + return canonical_value == user_value + def read(self, key): """ Retrieves current value associated with the dconf key. @@ -298,7 +335,7 @@ class DconfPreference(object): """ # If no change is needed (or won't be done due to check_mode), notify # caller straight away. - if value == self.read(key): + if self.variants_are_equal(self.read(key), value): return False elif self.check_mode: return True @@ -369,6 +406,12 @@ def main(): supports_check_mode=True ) + if Variant is None: + module.warn( + 'WARNING: The gi.repository Python library is not available; ' + 'using string comparison to check value equality. This fallback ' + 'will be deprecated in a future version of community.general.') + if not HAS_PSUTIL: module.fail_json(msg=missing_required_lib("psutil"), exception=PSUTIL_IMP_ERR) diff --git a/tests/unit/plugins/modules/test_dconf.py b/tests/unit/plugins/modules/test_dconf.py new file mode 100644 index 0000000000..e0ea8195a1 --- /dev/null +++ b/tests/unit/plugins/modules/test_dconf.py @@ -0,0 +1,44 @@ +# Copyright (c) 2023 Ansible Project +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or +# https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import pytest + +from ansible_collections.community.general.plugins.modules import dconf + +try: + from gi.repository.GLib import Variant +except ImportError: + Variant = None + +DconfPreference = dconf.DconfPreference + + +@pytest.mark.parametrize( + "v1,v2,expected,fallback_expected", + (("'foo'", "'foo'", True, True), + ('"foo"', "'foo'", True, False), + ("'foo'", '"foo"', True, False), + ("'foo'", '"bar"', False, False), + ("[1, 2, 3]", "[1, 2, 3]", True, True), + ("[1, 2, 3]", "[3, 2, 1]", False, False), + ('1234', '1234', True, True), + ('1234', '1235', False, False), + ('1.0', '1.0', True, True), + ('1.000', '1.0', True, False), + ('2.0', '4.0', False, False), + # GVariants with different types aren't equal! + ('1', '1.0', False, False), + # Explicit types + ('@as []', '[]', True, False), + )) +def test_gvariant_equality(mocker, v1, v2, expected, fallback_expected): + assert DconfPreference.variants_are_equal(v1, v2) is \ + (expected if Variant else fallback_expected) + mocker.patch.object(dconf, 'Variant', None) + mocker.patch.object(dconf, "GError", AttributeError) + assert DconfPreference.variants_are_equal(v1, v2) is fallback_expected From 11c7611ced8f9398a0fbd76a3bb93dc35f0cb909 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Mon, 6 Mar 2023 23:02:24 +0100 Subject: [PATCH 0229/1810] More true/false normalization (#6152) * More true/false normalization. * Boolean do not need explicit choices. * One more. * Fix type argument. --- plugins/modules/aix_devices.py | 2 +- plugins/modules/ipmi_power.py | 10 ++--- plugins/modules/nmcli.py | 1 - plugins/modules/utm_proxy_auth_profile.py | 25 +++-------- plugins/modules/zfs.py | 2 +- .../targets/aix_devices/tasks/main.yml | 2 +- .../targets/alternatives/tasks/main.yml | 8 ++-- .../alternatives/tasks/path_is_checked.yml | 2 +- .../alternatives/tasks/subcommands.yml | 4 +- .../apache2_module/tasks/actualtest.yml | 14 +++--- .../targets/archive/tasks/main.yml | 2 +- .../targets/consul/tasks/consul_session.yml | 10 ++--- .../targets/filesystem/defaults/main.yml | 26 +++++------ .../filesystem/tasks/overwrite_another_fs.yml | 2 +- .../targets/filter_from_csv/tasks/main.yml | 2 +- tests/integration/targets/gem/tasks/main.yml | 4 +- .../targets/github_issue/tasks/main.yml | 2 +- .../targets/gitlab_branch/tasks/main.yml | 6 +-- .../targets/gitlab_deploy_key/tasks/main.yml | 2 +- .../gitlab_group_variable/tasks/main.yml | 44 +++++++++---------- .../targets/gitlab_hook/tasks/main.yml | 2 +- .../targets/gitlab_project/tasks/main.yml | 8 ++-- .../gitlab_project_badge/tasks/main.yml | 24 +++++----- .../gitlab_project_variable/tasks/main.yml | 44 +++++++++---------- .../targets/gitlab_runner/tasks/main.yml | 2 +- .../targets/gitlab_user/tasks/main.yml | 26 +++++------ .../targets/hwc_vpc_eip/tasks/main.yml | 4 +- .../targets/hwc_vpc_port/tasks/main.yml | 4 +- .../targets/hwc_vpc_private_ip/tasks/main.yml | 4 +- .../targets/hwc_vpc_subnet/tasks/main.yml | 18 ++++---- .../targets/iso_create/tasks/main.yml | 2 +- .../targets/iso_customize/tasks/main.yml | 2 +- .../targets/iso_extract/tasks/7zip.yml | 2 +- .../keycloak_user_rolemapping/tasks/main.yml | 2 +- .../targets/locale_gen/tasks/locale_gen.yml | 12 ++--- .../lookup_passwordstore/tasks/package.yml | 2 +- tests/integration/targets/odbc/tasks/main.yml | 10 ++--- .../targets/odbc/tasks/negative_tests.yml | 2 +- .../targets/odbc/tasks/no_pyodbc.yml | 2 +- .../targets/osx_defaults/tasks/main.yml | 4 +- .../targets/pacman/tasks/package_urls.yml | 8 ++-- .../targets/pacman/tasks/reason.yml | 2 +- .../targets/proxmox/tasks/main.yml | 2 +- .../targets/rundeck/tasks/main.yml | 2 +- .../targets/sefcontext/tasks/sefcontext.yml | 20 ++++----- .../targets/setup_openldap/tasks/main.yml | 16 +++---- .../targets/setup_openssl/tasks/main.yml | 6 +-- .../targets/zypper/tasks/zypper.yml | 20 ++++----- 48 files changed, 203 insertions(+), 219 deletions(-) diff --git a/plugins/modules/aix_devices.py b/plugins/modules/aix_devices.py index 721c36d6aa..ef4ed49612 100644 --- a/plugins/modules/aix_devices.py +++ b/plugins/modules/aix_devices.py @@ -108,7 +108,7 @@ EXAMPLES = r''' device: en1 attributes: mtu: 900 - arp: off + arp: 'off' state: available - name: Configure IP, netmask and set en1 up. diff --git a/plugins/modules/ipmi_power.py b/plugins/modules/ipmi_power.py index c5ec27a480..e152f35eb4 100644 --- a/plugins/modules/ipmi_power.py +++ b/plugins/modules/ipmi_power.py @@ -100,7 +100,7 @@ powerstate: description: The current power state of the machine. returned: success and I(machine) is not provided type: str - sample: on + sample: 'on' status: description: The current power state of the machine when the machine option is set. returned: success and I(machine) is provided @@ -132,14 +132,14 @@ EXAMPLES = ''' name: test.testdomain.com user: admin password: password - state: on + state: 'on' - name: Ensure machines of which remote target address is 48 and 50 are powered off community.general.ipmi_power: name: test.testdomain.com user: admin password: password - state: off + state: 'off' machine: - targetAddress: 48 - targetAddress: 50 @@ -151,9 +151,9 @@ EXAMPLES = ''' password: password machine: - targetAddress: 48 - state: on + state: 'on' - targetAddress: 50 - state: off + state: 'off' ''' import traceback diff --git a/plugins/modules/nmcli.py b/plugins/modules/nmcli.py index 383e51a2c2..cc4c527608 100644 --- a/plugins/modules/nmcli.py +++ b/plugins/modules/nmcli.py @@ -968,7 +968,6 @@ options: - Enable or disable IPSec tunnel to L2TP host. - This option is need when C(service-type) is C(org.freedesktop.NetworkManager.l2tp). type: bool - choices: [ yes, no ] ipsec-psk: description: - The pre-shared key in base64 encoding. diff --git a/plugins/modules/utm_proxy_auth_profile.py b/plugins/modules/utm_proxy_auth_profile.py index ef3fc341a3..3b482483bf 100644 --- a/plugins/modules/utm_proxy_auth_profile.py +++ b/plugins/modules/utm_proxy_auth_profile.py @@ -58,9 +58,6 @@ options: - Should the login data be stripped when proxying the request to the backend host type: bool default: true - choices: - - True - - False backend_user_prefix: type: str description: @@ -118,9 +115,6 @@ options: - Allow session persistency type: bool default: false - choices: - - True - - False frontend_session_lifetime: type: int description: @@ -131,9 +125,6 @@ options: - Specifies if limitation of session lifetime is active type: bool default: true - choices: - - True - - False frontend_session_lifetime_scope: type: str description: @@ -153,9 +144,6 @@ options: - Specifies if session timeout is active type: bool default: true - choices: - - True - - False frontend_session_timeout_scope: type: str description: @@ -184,9 +172,6 @@ options: - Should a redirect to the requested URL be made type: bool default: false - choices: - - True - - False extends_documentation_fragment: - community.general.utm @@ -336,7 +321,7 @@ def main(): aaa=dict(type='list', elements='str', required=True), basic_prompt=dict(type='str', required=True), backend_mode=dict(type='str', required=False, default="None", choices=['Basic', 'None']), - backend_strip_basic_auth=dict(type='bool', required=False, default=True, choices=[True, False]), + backend_strip_basic_auth=dict(type='bool', required=False, default=True), backend_user_prefix=dict(type='str', required=False, default=""), backend_user_suffix=dict(type='str', required=False, default=""), comment=dict(type='str', required=False, default=""), @@ -348,16 +333,16 @@ def main(): frontend_logout=dict(type='str', required=False), frontend_mode=dict(type='str', required=False, default="Basic", choices=['Basic', 'Form']), frontend_realm=dict(type='str', required=False), - frontend_session_allow_persistency=dict(type='bool', required=False, default=False, choices=[True, False]), + frontend_session_allow_persistency=dict(type='bool', required=False, default=False), frontend_session_lifetime=dict(type='int', required=True), - frontend_session_lifetime_limited=dict(type='bool', required=False, default=True, choices=[True, False]), + frontend_session_lifetime_limited=dict(type='bool', required=False, default=True), frontend_session_lifetime_scope=dict(type='str', required=False, default="hours", choices=['days', 'hours', 'minutes']), frontend_session_timeout=dict(type='int', required=True), - frontend_session_timeout_enabled=dict(type='bool', required=False, default=True, choices=[True, False]), + frontend_session_timeout_enabled=dict(type='bool', required=False, default=True), frontend_session_timeout_scope=dict(type='str', required=False, default="minutes", choices=['days', 'hours', 'minutes']), logout_delegation_urls=dict(type='list', elements='str', required=False, default=[]), logout_mode=dict(type='str', required=False, default="None", choices=['None', 'Delegation']), - redirect_to_requested_url=dict(type='bool', required=False, default=False, choices=[True, False]) + redirect_to_requested_url=dict(type='bool', required=False, default=False) ) ) try: diff --git a/plugins/modules/zfs.py b/plugins/modules/zfs.py index 83b2a6edf8..4cd79c36e2 100644 --- a/plugins/modules/zfs.py +++ b/plugins/modules/zfs.py @@ -62,7 +62,7 @@ EXAMPLES = ''' name: rpool/myfs state: present extra_zfs_properties: - setuid: off + setuid: 'off' - name: Create a new volume called myvol in pool rpool. community.general.zfs: diff --git a/tests/integration/targets/aix_devices/tasks/main.yml b/tests/integration/targets/aix_devices/tasks/main.yml index c2b829d42f..284f46c33b 100644 --- a/tests/integration/targets/aix_devices/tasks/main.yml +++ b/tests/integration/targets/aix_devices/tasks/main.yml @@ -61,7 +61,7 @@ device: en1 attributes: mtu: 900 - arp: off + arp: 'off' state: present - name: Configure IP, netmask and set en1 up. diff --git a/tests/integration/targets/alternatives/tasks/main.yml b/tests/integration/targets/alternatives/tasks/main.yml index eac512aa45..81d6a7b0df 100644 --- a/tests/integration/targets/alternatives/tasks/main.yml +++ b/tests/integration/targets/alternatives/tasks/main.yml @@ -19,8 +19,8 @@ - include_tasks: tests.yml with_nested: - - [ True, False ] # with_link - - [ True, False ] # with_alternatives + - [ true, false ] # with_link + - [ true, false ] # with_alternatives - [ 'auto', 'manual' ] # mode loop_control: loop_var: test_conf @@ -34,7 +34,7 @@ - include_tasks: tests_set_priority.yml with_sequence: start=3 end=4 vars: - with_alternatives: True + with_alternatives: true mode: auto - block: @@ -44,7 +44,7 @@ - include_tasks: tests_set_priority.yml with_sequence: start=3 end=4 vars: - with_alternatives: False + with_alternatives: false mode: auto # Test that path is checked: alternatives must fail when path is nonexistent diff --git a/tests/integration/targets/alternatives/tasks/path_is_checked.yml b/tests/integration/targets/alternatives/tasks/path_is_checked.yml index 47ce1a54ef..0bc435889e 100644 --- a/tests/integration/targets/alternatives/tasks/path_is_checked.yml +++ b/tests/integration/targets/alternatives/tasks/path_is_checked.yml @@ -8,7 +8,7 @@ name: dummy path: '/non/existent/path/there' link: '/usr/bin/dummy' - ignore_errors: True + ignore_errors: true register: alternative - name: Check previous task failed diff --git a/tests/integration/targets/alternatives/tasks/subcommands.yml b/tests/integration/targets/alternatives/tasks/subcommands.yml index e83fd6db3c..678bbe68f4 100644 --- a/tests/integration/targets/alternatives/tasks/subcommands.yml +++ b/tests/integration/targets/alternatives/tasks/subcommands.yml @@ -83,7 +83,7 @@ - name: Execute the current dummysubcmd command command: dummysubcmd register: cmd - ignore_errors: True + ignore_errors: true - name: Ensure that the subcommand is gone assert: @@ -166,7 +166,7 @@ - name: Execute the current dummysubcmd command command: dummysubcmd register: cmd - ignore_errors: True + ignore_errors: true - name: Ensure that the subcommand is gone assert: diff --git a/tests/integration/targets/apache2_module/tasks/actualtest.yml b/tests/integration/targets/apache2_module/tasks/actualtest.yml index 1902cac5ee..3301a16b15 100644 --- a/tests/integration/targets/apache2_module/tasks/actualtest.yml +++ b/tests/integration/targets/apache2_module/tasks/actualtest.yml @@ -71,7 +71,7 @@ community.general.apache2_module: name: autoindex state: absent - force: True + force: true - name: reenable autoindex community.general.apache2_module: @@ -93,7 +93,7 @@ community.general.apache2_module: name: dump_io state: present - ignore_errors: True + ignore_errors: true register: enable_dumpio_wrong - name: disable dump_io @@ -132,7 +132,7 @@ community.general.apache2_module: name: "{{ item }}" state: absent - ignore_configcheck: True + ignore_configcheck: true with_items: - mpm_worker - mpm_event @@ -142,7 +142,7 @@ community.general.apache2_module: name: mpm_event state: present - ignore_configcheck: True + ignore_configcheck: true register: enabledmpmevent - name: ensure changed mpm_event @@ -154,7 +154,7 @@ community.general.apache2_module: name: "{{ item.name }}" state: "{{ item.state }}" - ignore_configcheck: True + ignore_configcheck: true with_items: - name: mpm_event state: absent @@ -193,7 +193,7 @@ community.general.apache2_module: name: "{{item}}" state: absent - ignore_configcheck: True + ignore_configcheck: true with_items: - mpm_worker - mpm_event @@ -203,5 +203,5 @@ community.general.apache2_module: name: mpm_event state: present - ignore_configcheck: True + ignore_configcheck: true register: enabledmpmevent diff --git a/tests/integration/targets/archive/tasks/main.yml b/tests/integration/targets/archive/tasks/main.yml index afe278bcf4..4ca41e254e 100644 --- a/tests/integration/targets/archive/tasks/main.yml +++ b/tests/integration/targets/archive/tasks/main.yml @@ -84,7 +84,7 @@ # Newer versions of brew want to compile a package which takes a long time. Do not upgrade homebrew until a # proper solution can be found environment: - HOMEBREW_NO_AUTO_UPDATE: True + HOMEBREW_NO_AUTO_UPDATE: "True" when: - ansible_python_version.split('.')[0] == '2' - ansible_os_family == 'Darwin' diff --git a/tests/integration/targets/consul/tasks/consul_session.yml b/tests/integration/targets/consul/tasks/consul_session.yml index 059e0a584a..5436689646 100644 --- a/tests/integration/targets/consul/tasks/consul_session.yml +++ b/tests/integration/targets/consul/tasks/consul_session.yml @@ -45,7 +45,7 @@ - name: search created session set_fact: - test_session_found: True + test_session_found: true loop: "{{ result['sessions'] }}" when: "item.get('ID') == session_id and item.get('Name') == 'testsession'" @@ -69,7 +69,7 @@ state: info name: test register: result - ignore_errors: True + ignore_errors: true - assert: that: @@ -81,7 +81,7 @@ id: '{{ session_id }}' scheme: non_existent register: result - ignore_errors: True + ignore_errors: true - assert: that: @@ -94,7 +94,7 @@ port: 8501 scheme: https register: result - ignore_errors: True + ignore_errors: true - name: previous task should fail since certificate is not known assert: @@ -108,7 +108,7 @@ id: '{{ session_id }}' port: 8501 scheme: https - validate_certs: False + validate_certs: false register: result - name: previous task should succeed since certificate isn't checked diff --git a/tests/integration/targets/filesystem/defaults/main.yml b/tests/integration/targets/filesystem/defaults/main.yml index 947d4a1648..0448d8602b 100644 --- a/tests/integration/targets/filesystem/defaults/main.yml +++ b/tests/integration/targets/filesystem/defaults/main.yml @@ -6,7 +6,7 @@ tested_filesystems: # key: fstype # fssize: size (Mo) - # grow: True if resizefs is supported + # grow: true if resizefs is supported # Other minimal sizes: # - XFS: 20Mo # - Btrfs: 150Mo (50Mo when "--metadata single" is used and 100Mb when on newer Fedora versions) @@ -15,19 +15,19 @@ tested_filesystems: # - 1.7.0 requires at least 30Mo # - 1.10.0 requires at least 38Mo # - resizefs asserts when initial fs is smaller than 60Mo and seems to require 1.10.0 - ext4: {fssize: 10, grow: True} - ext4dev: {fssize: 10, grow: True} - ext3: {fssize: 10, grow: True} - ext2: {fssize: 10, grow: True} - xfs: {fssize: 300, grow: False} # grow requires a mounted filesystem - btrfs: {fssize: 150, grow: False} # grow requires a mounted filesystem - reiserfs: {fssize: 33, grow: False} # grow not implemented - vfat: {fssize: 20, grow: True} - ocfs2: {fssize: '{{ ocfs2_fssize }}', grow: False} # grow not implemented + ext4: {fssize: 10, grow: true} + ext4dev: {fssize: 10, grow: true} + ext3: {fssize: 10, grow: true} + ext2: {fssize: 10, grow: true} + xfs: {fssize: 300, grow: false} # grow requires a mounted filesystem + btrfs: {fssize: 150, grow: false} # grow requires a mounted filesystem + reiserfs: {fssize: 33, grow: false} # grow not implemented + vfat: {fssize: 20, grow: true} + ocfs2: {fssize: '{{ ocfs2_fssize }}', grow: false} # grow not implemented f2fs: {fssize: '{{ f2fs_fssize|default(60) }}', grow: 'f2fs_version is version("1.10.0", ">=")'} - lvm: {fssize: 20, grow: True} - swap: {fssize: 10, grow: False} # grow not implemented - ufs: {fssize: 10, grow: True} + lvm: {fssize: 20, grow: true} + swap: {fssize: 10, grow: false} # grow not implemented + ufs: {fssize: 10, grow: true} get_uuid_any: "blkid -c /dev/null -o value -s UUID {{ dev }}" diff --git a/tests/integration/targets/filesystem/tasks/overwrite_another_fs.yml b/tests/integration/targets/filesystem/tasks/overwrite_another_fs.yml index de0ad4d66b..69418b22f8 100644 --- a/tests/integration/targets/filesystem/tasks/overwrite_another_fs.yml +++ b/tests/integration/targets/filesystem/tasks/overwrite_another_fs.yml @@ -24,7 +24,7 @@ dev: '{{ dev }}' fstype: '{{ fstype }}' register: fs_result - ignore_errors: True + ignore_errors: true - name: 'Get UUID of the filesystem' ansible.builtin.shell: diff --git a/tests/integration/targets/filter_from_csv/tasks/main.yml b/tests/integration/targets/filter_from_csv/tasks/main.yml index f82e7d6069..5c58f85d47 100644 --- a/tests/integration/targets/filter_from_csv/tasks/main.yml +++ b/tests/integration/targets/filter_from_csv/tasks/main.yml @@ -45,7 +45,7 @@ debug: var: "invalid_comma_separated | community.general.from_csv(strict=True)" register: _invalid_csv_strict_true - ignore_errors: True + ignore_errors: true - name: Test invalid csv input when strict=True is failed assert: diff --git a/tests/integration/targets/gem/tasks/main.yml b/tests/integration/targets/gem/tasks/main.yml index 7b975f0351..362c126bfd 100644 --- a/tests/integration/targets/gem/tasks/main.yml +++ b/tests/integration/targets/gem/tasks/main.yml @@ -178,7 +178,7 @@ state: present bindir: "{{ remote_tmp_dir }}/custom_bindir" norc: true - user_install: no # Avoid conflicts between --install-dir and --user-install when running as root on CentOS / Fedora / RHEL + user_install: false # Avoid conflicts between --install-dir and --user-install when running as root on CentOS / Fedora / RHEL register: install_gem_result - name: Get stats of gem executable @@ -198,7 +198,7 @@ state: absent bindir: "{{ remote_tmp_dir }}/custom_bindir" norc: true - user_install: no # Avoid conflicts between --install-dir and --user-install when running as root on CentOS / Fedora / RHEL + user_install: false # Avoid conflicts between --install-dir and --user-install when running as root on CentOS / Fedora / RHEL register: install_gem_result - name: Get stats of gem executable diff --git a/tests/integration/targets/github_issue/tasks/main.yml b/tests/integration/targets/github_issue/tasks/main.yml index bb315bf9fb..a7e43c171e 100644 --- a/tests/integration/targets/github_issue/tasks/main.yml +++ b/tests/integration/targets/github_issue/tasks/main.yml @@ -29,7 +29,7 @@ issue: "{{ non_existent_issue }}" action: get_status register: get_status_0003 - ignore_errors: True + ignore_errors: true - assert: that: diff --git a/tests/integration/targets/gitlab_branch/tasks/main.yml b/tests/integration/targets/gitlab_branch/tasks/main.yml index e9b64fc3a3..19d90e15cf 100644 --- a/tests/integration/targets/gitlab_branch/tasks/main.yml +++ b/tests/integration/targets/gitlab_branch/tasks/main.yml @@ -16,10 +16,10 @@ - name: Create {{ gitlab_project_name }} gitlab_project: server_url: "{{ gitlab_host }}" - validate_certs: False + validate_certs: false login_token: "{{ gitlab_login_token }}" name: "{{ gitlab_project_name }}" - initialize_with_readme: True + initialize_with_readme: true state: present - name: Create branch {{ gitlab_branch }} @@ -63,7 +63,7 @@ - name: Clean up {{ gitlab_project_name }} gitlab_project: server_url: "{{ gitlab_host }}" - validate_certs: False + validate_certs: false login_token: "{{ gitlab_login_token }}" name: "{{ gitlab_project_name }}" state: absent diff --git a/tests/integration/targets/gitlab_deploy_key/tasks/main.yml b/tests/integration/targets/gitlab_deploy_key/tasks/main.yml index 4330eb674c..c345c24678 100644 --- a/tests/integration/targets/gitlab_deploy_key/tasks/main.yml +++ b/tests/integration/targets/gitlab_deploy_key/tasks/main.yml @@ -16,7 +16,7 @@ - name: Create {{ gitlab_project_name }} gitlab_project: server_url: "{{ gitlab_host }}" - validate_certs: False + validate_certs: false login_token: "{{ gitlab_login_token }}" name: "{{ gitlab_project_name }}" state: present diff --git a/tests/integration/targets/gitlab_group_variable/tasks/main.yml b/tests/integration/targets/gitlab_group_variable/tasks/main.yml index 3ba0a176cd..39a3a5df8d 100644 --- a/tests/integration/targets/gitlab_group_variable/tasks/main.yml +++ b/tests/integration/targets/gitlab_group_variable/tasks/main.yml @@ -18,7 +18,7 @@ api_url: "{{ gitlab_host }}" api_token: "{{ gitlab_login_token }}" group: "{{ gitlab_group_name }}" - purge: True + purge: true - name: add a variable value in check_mode gitlab_group_variable: @@ -73,7 +73,7 @@ vars: ACCESS_KEY_ID: value: checkmode - protected: True + protected: true register: gitlab_group_variable_state - name: state must be changed @@ -89,7 +89,7 @@ vars: ACCESS_KEY_ID: value: checkmode - protected: False + protected: false register: gitlab_group_variable_state - name: state must be changed @@ -105,7 +105,7 @@ vars: ACCESS_KEY_ID: value: checkmode - masked: True + masked: true register: gitlab_group_variable_state - name: state must be changed @@ -151,8 +151,8 @@ vars: ACCESS_KEY_ID: value: checkmode - masked: True - protected: True + masked: true + protected: true variable_type: env_var register: gitlab_group_variable_state @@ -169,8 +169,8 @@ vars: ACCESS_KEY_ID: value: checkmode - masked: True - protected: True + masked: true + protected: true variable_type: env_var register: gitlab_group_variable_state @@ -187,7 +187,7 @@ vars: ACCESS_KEY_ID: value: checkmode - protected: False + protected: false register: gitlab_group_variable_state - name: state must be changed @@ -265,7 +265,7 @@ api_url: "{{ gitlab_host }}" api_token: "{{ gitlab_login_token }}" group: "{{ gitlab_group_name }}" - purge: True + purge: true - name: set two test variables gitlab_group_variable: @@ -312,7 +312,7 @@ group: "{{ gitlab_group_name }}" vars: ACCESS_KEY_ID: changed - purge: False + purge: false register: gitlab_group_variable_state - name: edit one variable state must be changed @@ -332,7 +332,7 @@ group: "{{ gitlab_group_name }}" vars: some: value - purge: False + purge: false register: gitlab_group_variable_state - name: append one variable state must be changed @@ -372,7 +372,7 @@ group: "{{ gitlab_group_name }}" vars: some: value - purge: True + purge: true register: gitlab_group_variable_state - name: set one variables and purge all others state must be changed @@ -391,7 +391,7 @@ group: "{{ gitlab_group_name }}" vars: some: value - purge: False + purge: false register: gitlab_group_variable_state - name: only one variable is left state must not be changed @@ -411,7 +411,7 @@ group: "{{ gitlab_group_name }}" vars: some: 42 - purge: False + purge: false register: gitlab_group_variable_state - name: only one variable is left state must be changed @@ -430,7 +430,7 @@ group: "{{ gitlab_group_name }}" vars: some: 42.23 - purge: False + purge: false register: gitlab_group_variable_state - name: only one variable is left state must be changed @@ -471,7 +471,7 @@ - name: my_test_var value: my_test_value variable_type: file - purge: False + purge: false register: gitlab_group_variable_state - name: append one variable state must be changed @@ -562,7 +562,7 @@ page1_var18: value page1_var19: value page1_var20: value - purge: True + purge: true register: gitlab_group_variable_state - name: complete page added state must be changed @@ -598,7 +598,7 @@ page2_var18: value page2_var19: value page2_var20: value - purge: False + purge: false register: gitlab_group_variable_state - name: existing page untouched state must be changed @@ -613,7 +613,7 @@ api_url: "{{ gitlab_host }}" api_token: "{{ gitlab_login_token }}" group: "{{ gitlab_group_name }}" - purge: True + purge: true register: gitlab_group_variable_state - name: check that no variables are untouched state must be changed @@ -630,7 +630,7 @@ api_url: "{{ gitlab_host }}" api_token: "{{ gitlab_login_token }}" group: "{{ gitlab_group_name }}" - purge: True + purge: true variables: - name: SECRET_ACCESS_KEY value: 3214cbad @@ -678,7 +678,7 @@ api_url: "{{ gitlab_host }}" api_token: "{{ gitlab_login_token }}" group: "{{ gitlab_group_name }}" - purge: True + purge: true variables: - name: delete_me value: ansible diff --git a/tests/integration/targets/gitlab_hook/tasks/main.yml b/tests/integration/targets/gitlab_hook/tasks/main.yml index 410af63e9f..aa06f6c815 100644 --- a/tests/integration/targets/gitlab_hook/tasks/main.yml +++ b/tests/integration/targets/gitlab_hook/tasks/main.yml @@ -16,7 +16,7 @@ - name: Create {{ gitlab_project_name }} gitlab_project: server_url: "{{ gitlab_host }}" - validate_certs: False + validate_certs: false login_token: "{{ gitlab_login_token }}" name: "{{ gitlab_project_name }}" state: present diff --git a/tests/integration/targets/gitlab_project/tasks/main.yml b/tests/integration/targets/gitlab_project/tasks/main.yml index 611d6548f6..0a9e47188b 100644 --- a/tests/integration/targets/gitlab_project/tasks/main.yml +++ b/tests/integration/targets/gitlab_project/tasks/main.yml @@ -16,7 +16,7 @@ - name: Clean up {{ gitlab_project_name }} gitlab_project: server_url: "{{ gitlab_host }}" - validate_certs: False + validate_certs: false login_token: "{{ gitlab_login_token }}" name: "{{ gitlab_project_name }}" state: absent @@ -24,10 +24,10 @@ - name: Create {{ gitlab_project_name }} gitlab_project: server_url: "{{ gitlab_host }}" - validate_certs: False + validate_certs: false login_token: "{{ gitlab_login_token }}" name: "{{ gitlab_project_name }}" - initialize_with_readme: True + initialize_with_readme: true state: present register: gitlab_project_state @@ -38,7 +38,7 @@ - name: Create {{ gitlab_project_name }} (Test idempotency) gitlab_project: server_url: "{{ gitlab_host }}" - validate_certs: False + validate_certs: false login_token: "{{ gitlab_login_token }}" name: "{{ gitlab_project_name }}" state: present diff --git a/tests/integration/targets/gitlab_project_badge/tasks/main.yml b/tests/integration/targets/gitlab_project_badge/tasks/main.yml index dfd0bee75b..efc090ef7d 100644 --- a/tests/integration/targets/gitlab_project_badge/tasks/main.yml +++ b/tests/integration/targets/gitlab_project_badge/tasks/main.yml @@ -16,17 +16,17 @@ - name: Create {{ gitlab_project_name }} gitlab_project: api_url: "{{ gitlab_api_url }}" - validate_certs: False + validate_certs: false api_token: "{{ gitlab_api_token }}" name: "{{ gitlab_project_name }}" - initialize_with_readme: True + initialize_with_readme: true state: present - name: Create Badge (check) check_mode: true gitlab_project_badge: api_url: "{{ gitlab_api_url }}" - validate_certs: False + validate_certs: false api_token: "{{ gitlab_api_token }}" project: "{{ gitlab_project_name }}" state: present @@ -46,7 +46,7 @@ - name: Create Badge gitlab_project_badge: api_url: "{{ gitlab_api_url }}" - validate_certs: False + validate_certs: false api_token: "{{ gitlab_api_token }}" project: "{{ gitlab_project_name }}" state: present @@ -66,7 +66,7 @@ - name: Create Badge (confirmation) gitlab_project_badge: api_url: "{{ gitlab_api_url }}" - validate_certs: False + validate_certs: false api_token: "{{ gitlab_api_token }}" project: "{{ gitlab_project_name }}" state: present @@ -87,7 +87,7 @@ check_mode: true gitlab_project_badge: api_url: "{{ gitlab_api_url }}" - validate_certs: False + validate_certs: false api_token: "{{ gitlab_api_token }}" project: "{{ gitlab_project_name }}" state: present @@ -107,7 +107,7 @@ - name: Update Badge gitlab_project_badge: api_url: "{{ gitlab_api_url }}" - validate_certs: False + validate_certs: false api_token: "{{ gitlab_api_token }}" project: "{{ gitlab_project_name }}" state: present @@ -127,7 +127,7 @@ - name: Update Badge (confirmation) gitlab_project_badge: api_url: "{{ gitlab_api_url }}" - validate_certs: False + validate_certs: false api_token: "{{ gitlab_api_token }}" project: "{{ gitlab_project_name }}" state: present @@ -148,7 +148,7 @@ check_mode: true gitlab_project_badge: api_url: "{{ gitlab_api_url }}" - validate_certs: False + validate_certs: false api_token: "{{ gitlab_api_token }}" project: "{{ gitlab_project_name }}" state: absent @@ -168,7 +168,7 @@ - name: Delete Badge gitlab_project_badge: api_url: "{{ gitlab_api_url }}" - validate_certs: False + validate_certs: false api_token: "{{ gitlab_api_token }}" project: "{{ gitlab_project_name }}" state: absent @@ -188,7 +188,7 @@ - name: Delete Badge (confirmation) gitlab_project_badge: api_url: "{{ gitlab_api_url }}" - validate_certs: False + validate_certs: false api_token: "{{ gitlab_api_token }}" project: "{{ gitlab_project_name }}" state: absent @@ -208,7 +208,7 @@ - name: Clean up {{ gitlab_project_name }} gitlab_project: api_url: "{{ gitlab_api_url }}" - validate_certs: False + validate_certs: false api_token: "{{ gitlab_api_token }}" name: "{{ gitlab_project_name }}" state: absent diff --git a/tests/integration/targets/gitlab_project_variable/tasks/main.yml b/tests/integration/targets/gitlab_project_variable/tasks/main.yml index c82671aeae..0645da0fd1 100644 --- a/tests/integration/targets/gitlab_project_variable/tasks/main.yml +++ b/tests/integration/targets/gitlab_project_variable/tasks/main.yml @@ -18,7 +18,7 @@ api_url: "{{ gitlab_host }}" api_token: "{{ gitlab_login_token }}" project: "{{ gitlab_project_name }}" - purge: True + purge: true - name: add a variable value in check_mode gitlab_project_variable: @@ -73,7 +73,7 @@ vars: ACCESS_KEY_ID: value: checkmode - protected: True + protected: true register: gitlab_project_variable_state - name: state must be changed @@ -89,7 +89,7 @@ vars: ACCESS_KEY_ID: value: checkmode - protected: False + protected: false register: gitlab_project_variable_state - name: state must be changed @@ -105,7 +105,7 @@ vars: ACCESS_KEY_ID: value: checkmode - masked: True + masked: true register: gitlab_project_variable_state - name: state must be changed @@ -151,8 +151,8 @@ vars: ACCESS_KEY_ID: value: checkmode - masked: True - protected: True + masked: true + protected: true variable_type: env_var register: gitlab_project_variable_state @@ -169,8 +169,8 @@ vars: ACCESS_KEY_ID: value: checkmode - masked: True - protected: True + masked: true + protected: true variable_type: env_var register: gitlab_project_variable_state @@ -187,7 +187,7 @@ vars: ACCESS_KEY_ID: value: checkmode - protected: False + protected: false register: gitlab_project_variable_state - name: state must be changed @@ -261,7 +261,7 @@ api_url: "{{ gitlab_host }}" api_token: "{{ gitlab_login_token }}" project: "{{ gitlab_project_name }}" - purge: True + purge: true - name: set two test variables gitlab_project_variable: @@ -308,7 +308,7 @@ project: "{{ gitlab_project_name }}" vars: ACCESS_KEY_ID: changed - purge: False + purge: false register: gitlab_project_variable_state - name: edit one variable state must be changed @@ -328,7 +328,7 @@ project: "{{ gitlab_project_name }}" vars: some: value - purge: False + purge: false register: gitlab_project_variable_state - name: append one variable state must be changed @@ -368,7 +368,7 @@ project: "{{ gitlab_project_name }}" vars: some: value - purge: True + purge: true register: gitlab_project_variable_state - name: set one variables and purge all others state must be changed @@ -387,7 +387,7 @@ project: "{{ gitlab_project_name }}" vars: some: value - purge: False + purge: false register: gitlab_project_variable_state - name: only one variable is left state must not be changed @@ -407,7 +407,7 @@ project: "{{ gitlab_project_name }}" vars: some: 42 - purge: False + purge: false register: gitlab_project_variable_state - name: only one variable is left state must be changed @@ -426,7 +426,7 @@ project: "{{ gitlab_project_name }}" vars: some: 42.23 - purge: False + purge: false register: gitlab_project_variable_state - name: only one variable is left state must be changed @@ -467,7 +467,7 @@ - name: my_test_var value: my_test_value variable_type: file - purge: False + purge: false register: gitlab_project_variable_state - name: append one variable state must be changed @@ -559,7 +559,7 @@ page1_var18: value page1_var19: value page1_var20: value - purge: True + purge: true register: gitlab_project_variable_state - name: complete page added state must be changed @@ -595,7 +595,7 @@ page2_var18: value page2_var19: value page2_var20: value - purge: False + purge: false register: gitlab_project_variable_state - name: existing page untouched state must be changed @@ -610,7 +610,7 @@ api_url: "{{ gitlab_host }}" api_token: "{{ gitlab_login_token }}" project: "{{ gitlab_project_name }}" - purge: True + purge: true register: gitlab_project_variable_state - name: check that no variables are untouched state must be changed @@ -627,7 +627,7 @@ api_url: "{{ gitlab_host }}" api_token: "{{ gitlab_login_token }}" project: "{{ gitlab_project_name }}" - purge: True + purge: true variables: - name: SECRET_ACCESS_KEY value: 3214cbad @@ -673,7 +673,7 @@ api_url: "{{ gitlab_host }}" api_token: "{{ gitlab_login_token }}" project: "{{ gitlab_project_name }}" - purge: True + purge: true variables: - name: delete_me value: ansible diff --git a/tests/integration/targets/gitlab_runner/tasks/main.yml b/tests/integration/targets/gitlab_runner/tasks/main.yml index e4529f8ffc..467e918c24 100644 --- a/tests/integration/targets/gitlab_runner/tasks/main.yml +++ b/tests/integration/targets/gitlab_runner/tasks/main.yml @@ -16,7 +16,7 @@ - name: Create {{ gitlab_project_name }} gitlab_project: server_url: "{{ gitlab_host }}" - validate_certs: False + validate_certs: false login_token: "{{ gitlab_login_token }}" name: "{{ gitlab_project_name }}" state: present diff --git a/tests/integration/targets/gitlab_user/tasks/main.yml b/tests/integration/targets/gitlab_user/tasks/main.yml index 1f16074f70..e8c1ec360a 100644 --- a/tests/integration/targets/gitlab_user/tasks/main.yml +++ b/tests/integration/targets/gitlab_user/tasks/main.yml @@ -32,7 +32,7 @@ name: "{{ gitlab_user }}" username: "{{ gitlab_user }}" password: "{{ gitlab_user_pass }}" - validate_certs: False + validate_certs: false api_token: "{{ gitlab_login_token }}" state: present register: gitlab_user_state @@ -49,7 +49,7 @@ name: ansible_test_user username: ansible_test_user password: Secr3tPassw00rd - validate_certs: False + validate_certs: false api_token: "{{ gitlab_login_token }}" state: present register: gitlab_user_state_again @@ -68,7 +68,7 @@ name: "{{ gitlab_user }}" username: "{{ gitlab_user }}" isadmin: true - validate_certs: False + validate_certs: false api_token: "{{ gitlab_login_token }}" state: present register: gitlab_user_state @@ -86,7 +86,7 @@ name: "{{ gitlab_user }}" username: "{{ gitlab_user }}" isadmin: true - validate_certs: False + validate_certs: false api_token: "{{ gitlab_login_token }}" state: present register: gitlab_user_state @@ -104,7 +104,7 @@ name: "{{ gitlab_user }}" username: "{{ gitlab_user }}" isadmin: false - validate_certs: False + validate_certs: false api_token: "{{ gitlab_login_token }}" state: present register: gitlab_user_state @@ -122,8 +122,8 @@ email: foo@bar.baz name: "{{ gitlab_user }}" username: "{{ gitlab_user }}" - confirm: True - validate_certs: False + confirm: true + validate_certs: false api_token: "{{ gitlab_login_token }}" state: present register: gitlab_user_state @@ -141,7 +141,7 @@ name: "{{ gitlab_user }}" username: "{{ gitlab_user }}" confirm: false - validate_certs: False + validate_certs: false api_token: "{{ gitlab_login_token }}" state: present register: gitlab_user_state @@ -159,7 +159,7 @@ name: "{{ gitlab_user }}" username: "{{ gitlab_user }}" confirm: false - validate_certs: False + validate_certs: false api_token: "{{ gitlab_login_token }}" state: present register: gitlab_user_state @@ -177,7 +177,7 @@ name: "{{ gitlab_user }}" username: "{{ gitlab_user }}" confirm: false - validate_certs: False + validate_certs: false api_token: "{{ gitlab_login_token }}" state: present register: gitlab_user_state @@ -192,7 +192,7 @@ - name: Update User Test => Change User Password gitlab_user: api_url: "{{ gitlab_host }}" - validate_certs: False + validate_certs: false # note: the only way to check if a password really is what it is expected # to be is to use it for login, so we use it here instead of the @@ -218,7 +218,7 @@ - name: Update User Test => Reset User Password gitlab_user: api_url: "{{ gitlab_host }}" - validate_certs: False + validate_certs: false api_username: "{{ gitlab_user }}" api_password: new-super-password @@ -238,7 +238,7 @@ - name: Update User Test => Check that password was reset gitlab_user: api_url: "{{ gitlab_host }}" - validate_certs: False + validate_certs: false api_username: "{{ gitlab_user }}" api_password: "{{ gitlab_user_pass }}" diff --git a/tests/integration/targets/hwc_vpc_eip/tasks/main.yml b/tests/integration/targets/hwc_vpc_eip/tasks/main.yml index bbcefcaa62..f830f951f8 100644 --- a/tests/integration/targets/hwc_vpc_eip/tasks/main.yml +++ b/tests/integration/targets/hwc_vpc_eip/tasks/main.yml @@ -19,7 +19,7 @@ hwc_vpc_subnet: gateway_ip: "192.168.100.32" name: "ansible_network_subnet_test" - dhcp_enable: True + dhcp_enable: true vpc_id: "{{ vpc.id }}" cidr: "192.168.100.0/26" state: present @@ -177,7 +177,7 @@ hwc_vpc_subnet: gateway_ip: "192.168.100.32" name: "ansible_network_subnet_test" - dhcp_enable: True + dhcp_enable: true vpc_id: "{{ vpc.id }}" cidr: "192.168.100.0/26" state: absent diff --git a/tests/integration/targets/hwc_vpc_port/tasks/main.yml b/tests/integration/targets/hwc_vpc_port/tasks/main.yml index bb8cf81b0b..93b17398f5 100644 --- a/tests/integration/targets/hwc_vpc_port/tasks/main.yml +++ b/tests/integration/targets/hwc_vpc_port/tasks/main.yml @@ -19,7 +19,7 @@ hwc_vpc_subnet: gateway_ip: "192.168.100.32" name: "ansible_network_subnet_test" - dhcp_enable: True + dhcp_enable: true vpc_id: "{{ vpc.id }}" cidr: "192.168.100.0/26" state: present @@ -128,7 +128,7 @@ hwc_vpc_subnet: gateway_ip: "192.168.100.32" name: "ansible_network_subnet_test" - dhcp_enable: True + dhcp_enable: true vpc_id: "{{ vpc.id }}" cidr: "192.168.100.0/26" state: absent diff --git a/tests/integration/targets/hwc_vpc_private_ip/tasks/main.yml b/tests/integration/targets/hwc_vpc_private_ip/tasks/main.yml index 25972d7e9f..6accdb8550 100644 --- a/tests/integration/targets/hwc_vpc_private_ip/tasks/main.yml +++ b/tests/integration/targets/hwc_vpc_private_ip/tasks/main.yml @@ -19,7 +19,7 @@ hwc_vpc_subnet: gateway_ip: "192.168.100.32" name: "ansible_network_subnet_test" - dhcp_enable: True + dhcp_enable: true vpc_id: "{{ vpc.id }}" cidr: "192.168.100.0/26" state: present @@ -129,7 +129,7 @@ hwc_vpc_subnet: gateway_ip: "192.168.100.32" name: "ansible_network_subnet_test" - dhcp_enable: True + dhcp_enable: true vpc_id: "{{ vpc.id }}" cidr: "192.168.100.0/26" state: absent diff --git a/tests/integration/targets/hwc_vpc_subnet/tasks/main.yml b/tests/integration/targets/hwc_vpc_subnet/tasks/main.yml index 2eb7980b34..522ffb6011 100644 --- a/tests/integration/targets/hwc_vpc_subnet/tasks/main.yml +++ b/tests/integration/targets/hwc_vpc_subnet/tasks/main.yml @@ -21,7 +21,7 @@ cidr: "192.168.100.0/26" gateway_ip: "192.168.100.32" name: "ansible_network_subnet_test" - dhcp_enable: True + dhcp_enable: true state: absent #---------------------------------------------------------- - name: create a subnet (check mode) @@ -30,7 +30,7 @@ cidr: "192.168.100.0/26" gateway_ip: "192.168.100.32" name: "ansible_network_subnet_test" - dhcp_enable: True + dhcp_enable: true state: present check_mode: true register: result @@ -46,7 +46,7 @@ cidr: "192.168.100.0/26" gateway_ip: "192.168.100.32" name: "ansible_network_subnet_test" - dhcp_enable: True + dhcp_enable: true state: present register: result - name: assert changed is true @@ -60,7 +60,7 @@ cidr: "192.168.100.0/26" gateway_ip: "192.168.100.32" name: "ansible_network_subnet_test" - dhcp_enable: True + dhcp_enable: true state: present check_mode: true register: result @@ -75,7 +75,7 @@ cidr: "192.168.100.0/26" gateway_ip: "192.168.100.32" name: "ansible_network_subnet_test" - dhcp_enable: True + dhcp_enable: true state: present register: result - name: assert changed is false @@ -90,7 +90,7 @@ cidr: "192.168.100.0/26" gateway_ip: "192.168.100.32" name: "ansible_network_subnet_test" - dhcp_enable: True + dhcp_enable: true state: absent check_mode: true register: result @@ -105,7 +105,7 @@ cidr: "192.168.100.0/26" gateway_ip: "192.168.100.32" name: "ansible_network_subnet_test" - dhcp_enable: True + dhcp_enable: true state: absent register: result - name: assert changed is true @@ -119,7 +119,7 @@ cidr: "192.168.100.0/26" gateway_ip: "192.168.100.32" name: "ansible_network_subnet_test" - dhcp_enable: True + dhcp_enable: true state: absent check_mode: true register: result @@ -134,7 +134,7 @@ cidr: "192.168.100.0/26" gateway_ip: "192.168.100.32" name: "ansible_network_subnet_test" - dhcp_enable: True + dhcp_enable: true state: absent register: result - name: assert changed is false diff --git a/tests/integration/targets/iso_create/tasks/main.yml b/tests/integration/targets/iso_create/tasks/main.yml index a719e91d8e..b6bd930354 100644 --- a/tests/integration/targets/iso_create/tasks/main.yml +++ b/tests/integration/targets/iso_create/tasks/main.yml @@ -149,7 +149,7 @@ src_files: - "{{ remote_tmp_dir }}/test1.cfg" dest_iso: "{{ output_test_dir }}/test5.iso" - udf: True + udf: true register: iso_result - debug: var=iso_result diff --git a/tests/integration/targets/iso_customize/tasks/main.yml b/tests/integration/targets/iso_customize/tasks/main.yml index 5745b1a8ad..dafd84dd54 100644 --- a/tests/integration/targets/iso_customize/tasks/main.yml +++ b/tests/integration/targets/iso_customize/tasks/main.yml @@ -61,7 +61,7 @@ - "{{ test_dir }}/test01.cfg" - "{{ test_dir }}/test02.cfg" dest_iso: "{{ test_dir }}/test.iso" - udf: True + udf: true - include_tasks: iso_customize.yml vars: diff --git a/tests/integration/targets/iso_extract/tasks/7zip.yml b/tests/integration/targets/iso_extract/tasks/7zip.yml index b16f202398..e0f1586ce1 100644 --- a/tests/integration/targets/iso_extract/tasks/7zip.yml +++ b/tests/integration/targets/iso_extract/tasks/7zip.yml @@ -51,4 +51,4 @@ # Newer versions of brew want to compile a package which takes a long time. Do not upgrade homebrew until a # proper solution can be found environment: - HOMEBREW_NO_AUTO_UPDATE: True + HOMEBREW_NO_AUTO_UPDATE: "True" diff --git a/tests/integration/targets/keycloak_user_rolemapping/tasks/main.yml b/tests/integration/targets/keycloak_user_rolemapping/tasks/main.yml index e4625cb06e..1a897ad9af 100644 --- a/tests/integration/targets/keycloak_user_rolemapping/tasks/main.yml +++ b/tests/integration/targets/keycloak_user_rolemapping/tasks/main.yml @@ -20,7 +20,7 @@ auth_password: "{{ admin_password }}" realm: "{{ realm }}" client_id: "{{ client_id }}" - service_accounts_enabled: True + service_accounts_enabled: true state: present register: client diff --git a/tests/integration/targets/locale_gen/tasks/locale_gen.yml b/tests/integration/targets/locale_gen/tasks/locale_gen.yml index ea042796f7..c6bdcc046b 100644 --- a/tests/integration/targets/locale_gen/tasks/locale_gen.yml +++ b/tests/integration/targets/locale_gen/tasks/locale_gen.yml @@ -6,7 +6,7 @@ - name: Is the locale we're going to test against installed? shell: locale -a | grep pt_BR register: initial_state - ignore_errors: True + ignore_errors: true - name: Make sure the locale is not installed locale_gen: @@ -16,7 +16,7 @@ - name: Is the locale present? shell: locale -a | grep pt_BR register: cleaned - ignore_errors: True + ignore_errors: true - name: Make sure the locale is not present assert: @@ -32,7 +32,7 @@ - name: Is the locale present? shell: locale -a | grep pt_BR register: post_check_output - ignore_errors: True + ignore_errors: true - name: Make sure the locale is present and we say we installed it assert: @@ -49,7 +49,7 @@ - name: Is the locale present? shell: locale -a | grep pt_BR register: post_check_output - ignore_errors: True + ignore_errors: true - name: Make sure the locale is present and we reported no change assert: @@ -66,7 +66,7 @@ - name: Is the locale present? shell: locale -a | grep pt_BR register: post_check_output - ignore_errors: True + ignore_errors: true - name: Make sure the locale is absent and we reported a change assert: @@ -83,7 +83,7 @@ - name: Is the locale present? shell: locale -a | grep pt_BR register: post_check_output - ignore_errors: True + ignore_errors: true - name: Make sure the locale is absent and we reported no change assert: diff --git a/tests/integration/targets/lookup_passwordstore/tasks/package.yml b/tests/integration/targets/lookup_passwordstore/tasks/package.yml index 3623101c86..e5ccd5677d 100644 --- a/tests/integration/targets/lookup_passwordstore/tasks/package.yml +++ b/tests/integration/targets/lookup_passwordstore/tasks/package.yml @@ -81,4 +81,4 @@ # Newer versions of brew want to compile a package which takes a long time. Do not upgrade homebrew until a # proper solution can be found environment: - HOMEBREW_NO_AUTO_UPDATE: True + HOMEBREW_NO_AUTO_UPDATE: "True" diff --git a/tests/integration/targets/odbc/tasks/main.yml b/tests/integration/targets/odbc/tasks/main.yml index cdc925df69..ce55ea8aa2 100644 --- a/tests/integration/targets/odbc/tasks/main.yml +++ b/tests/integration/targets/odbc/tasks/main.yml @@ -53,7 +53,7 @@ - name: Create a user to run the tests with shell: echo "CREATE USER {{ my_user }} SUPERUSER PASSWORD '{{ my_pass }}'" | psql postgres become_user: "{{ pg_user }}" - become: True + become: true - name: Create a table odbc: @@ -68,7 +68,7 @@ len interval hour to minute ); become_user: "{{ pg_user }}" - become: True + become: true register: results - assert: @@ -83,7 +83,7 @@ dsn: "{{ dsn }}" query: "INSERT INTO films (code, title, did, date_prod, kind, len) VALUES ('asdfg', 'My First Movie', 1, '2019-01-12', 'SyFi', '02:00')" become_user: "{{ pg_user }}" - become: True + become: true register: results - assert: @@ -102,7 +102,7 @@ - 'Comedy' - '01:30' become_user: "{{ pg_user }}" - become: True + become: true register: results - assert: @@ -135,7 +135,7 @@ - 'asdfg' - 'qwert' register: results - changed_when: False + changed_when: false - assert: that: diff --git a/tests/integration/targets/odbc/tasks/negative_tests.yml b/tests/integration/targets/odbc/tasks/negative_tests.yml index 56b7a9b824..f779e6a53a 100644 --- a/tests/integration/targets/odbc/tasks/negative_tests.yml +++ b/tests/integration/targets/odbc/tasks/negative_tests.yml @@ -16,7 +16,7 @@ dsn: "t1" query: "SELECT * FROM nothing" register: results - ignore_errors: True + ignore_errors: true - assert: that: diff --git a/tests/integration/targets/odbc/tasks/no_pyodbc.yml b/tests/integration/targets/odbc/tasks/no_pyodbc.yml index 417549b63f..3a52d85a10 100644 --- a/tests/integration/targets/odbc/tasks/no_pyodbc.yml +++ b/tests/integration/targets/odbc/tasks/no_pyodbc.yml @@ -7,7 +7,7 @@ odbc: dsn: "Test" query: "SELECT * FROM nothing" - ignore_errors: True + ignore_errors: true register: results - assert: diff --git a/tests/integration/targets/osx_defaults/tasks/main.yml b/tests/integration/targets/osx_defaults/tasks/main.yml index c3cb09d394..f7bcb89446 100644 --- a/tests/integration/targets/osx_defaults/tasks/main.yml +++ b/tests/integration/targets/osx_defaults/tasks/main.yml @@ -185,8 +185,8 @@ - { type: 'int', value: 1, key: 'sample_int'} - { type: 'integer', value: 1, key: 'sample_int_2'} - { type: 'integer', value: -1, key: 'negative_int'} - - { type: 'bool', value: True, key: 'sample_bool'} - - { type: 'boolean', value: True, key: 'sample_bool_2'} + - { type: 'bool', value: true, key: 'sample_bool'} + - { type: 'boolean', value: true, key: 'sample_bool_2'} - { type: 'date', value: "2019-02-19 10:10:10", key: 'sample_date'} - { type: 'float', value: 1.2, key: 'sample_float'} - { type: 'string', value: 'sample', key: 'sample_string'} diff --git a/tests/integration/targets/pacman/tasks/package_urls.yml b/tests/integration/targets/pacman/tasks/package_urls.yml index 8cd4ddc01d..4df5312855 100644 --- a/tests/integration/targets/pacman/tasks/package_urls.yml +++ b/tests/integration/targets/pacman/tasks/package_urls.yml @@ -66,14 +66,14 @@ - '{{reg_pkg}}' - '{{url_pkg_url}}' - '{{file_pkg_path}}' - check_mode: True + check_mode: true register: install_1 - name: Install packages from url (check mode, cached) pacman: name: - '{{url_pkg_url}}' - check_mode: True + check_mode: true register: install_1c - name: Delete cached {{url_pkg}} file: @@ -141,14 +141,14 @@ - '{{reg_pkg}}' - '{{url_pkg_url}}' - '{{file_pkg_path}}' - check_mode: True + check_mode: true register: uninstall_1 - name: Uninstall packages - url (check mode, cached) pacman: state: absent name: - '{{url_pkg_url}}' - check_mode: True + check_mode: true register: uninstall_1c - name: Delete cached {{url_pkg}} file: diff --git a/tests/integration/targets/pacman/tasks/reason.yml b/tests/integration/targets/pacman/tasks/reason.yml index 3e7f2e11e4..5a26e3e100 100644 --- a/tests/integration/targets/pacman/tasks/reason.yml +++ b/tests/integration/targets/pacman/tasks/reason.yml @@ -41,7 +41,7 @@ - '{{url_pkg_url.stdout}}' - '{{file_pkg_path}}' reason: dependency - check_mode: True + check_mode: true register: install_1 - name: Install packages from mixed sources as explicit diff --git a/tests/integration/targets/proxmox/tasks/main.yml b/tests/integration/targets/proxmox/tasks/main.yml index 437ccad60e..22d7fcd294 100644 --- a/tests/integration/targets/proxmox/tasks/main.yml +++ b/tests/integration/targets/proxmox/tasks/main.yml @@ -285,7 +285,7 @@ interface: net5 bridge: vmbr0 tag: 24 - firewall: True + firewall: true register: results - assert: diff --git a/tests/integration/targets/rundeck/tasks/main.yml b/tests/integration/targets/rundeck/tasks/main.yml index 0c7e5bd09d..e42780b9b7 100644 --- a/tests/integration/targets/rundeck/tasks/main.yml +++ b/tests/integration/targets/rundeck/tasks/main.yml @@ -105,7 +105,7 @@ job_id: "{{ rundeck_job_id }}" job_options: sleep: "5" - wait_execution: False + wait_execution: false register: rundeck_job_run_forget - name: Assert that Rundeck job test_job is running diff --git a/tests/integration/targets/sefcontext/tasks/sefcontext.yml b/tests/integration/targets/sefcontext/tasks/sefcontext.yml index 9d6e7d1f70..258f1ace91 100644 --- a/tests/integration/targets/sefcontext/tasks/sefcontext.yml +++ b/tests/integration/targets/sefcontext/tasks/sefcontext.yml @@ -111,7 +111,7 @@ path: /tmp/foo substitute: /home state: present - reload: no + reload: false register: subst_first - assert: @@ -124,7 +124,7 @@ path: /tmp/foo substitute: /home state: present - reload: no + reload: false register: subst_second - assert: @@ -137,7 +137,7 @@ path: /tmp/foo substitute: /boot state: present - reload: no + reload: false register: subst_third - assert: @@ -150,7 +150,7 @@ path: /tmp/foo substitute: /boot state: present - reload: no + reload: false register: subst_fourth - assert: @@ -163,7 +163,7 @@ path: /tmp/foo substitute: /dev state: absent - reload: no + reload: false register: subst_fifth - assert: @@ -176,7 +176,7 @@ path: /tmp/foo substitute: /boot state: absent - reload: no + reload: false register: subst_sixth - assert: @@ -189,7 +189,7 @@ path: /tmp/foo substitute: /boot state: absent - reload: no + reload: false register: subst_seventh - assert: @@ -202,7 +202,7 @@ path: /tmp/foo substitute: /home state: present - reload: no + reload: false register: subst_eighth - assert: @@ -214,7 +214,7 @@ sefcontext: path: /tmp/foo state: absent - reload: no + reload: false register: subst_ninth - assert: @@ -225,7 +225,7 @@ sefcontext: path: /tmp/foo state: absent - reload: no + reload: false register: subst_tenth - assert: diff --git a/tests/integration/targets/setup_openldap/tasks/main.yml b/tests/integration/targets/setup_openldap/tasks/main.yml index 67f6d5c9c2..25077de166 100644 --- a/tests/integration/targets/setup_openldap/tasks/main.yml +++ b/tests/integration/targets/setup_openldap/tasks/main.yml @@ -14,25 +14,25 @@ include_vars: '{{ ansible_os_family }}.yml' - name: Install OpenLDAP server and tools - become: True + become: true package: name: '{{ item }}' loop: '{{ openldap_packages_name }}' - name: Install python-ldap (Python 3) - become: True + become: true package: name: '{{ python_ldap_package_name_python3 }}' when: ansible_python_version is version('3.0', '>=') - name: Install python-ldap (Python 2) - become: True + become: true package: name: '{{ python_ldap_package_name }}' when: ansible_python_version is version('3.0', '<') - name: Make sure OpenLDAP service is stopped - become: True + become: true shell: 'cat /var/run/slapd/slapd.pid | xargs -r kill -9 ' - name: Debconf @@ -45,14 +45,14 @@ creates: "/root/slapd_configured" - name: Start OpenLDAP service - become: True + become: true service: name: '{{ openldap_service_name }}' - enabled: True + enabled: true state: started - name: Copy initial config ldif file - become: True + become: true copy: src: 'files/{{ item }}' dest: '/tmp/{{ item }}' @@ -67,6 +67,6 @@ shell: "ldapmodify -Y EXTERNAL -H ldapi:/// -f /tmp/rootpw_cnconfig.ldif" - name: Add initial config - become: True + become: true shell: 'ldapadd -H ldapi:/// -x -D "cn=admin,dc=example,dc=com" -w Test1234! -f /tmp/initial_config.ldif' when: ansible_os_family in ['Ubuntu', 'Debian'] diff --git a/tests/integration/targets/setup_openssl/tasks/main.yml b/tests/integration/targets/setup_openssl/tasks/main.yml index 2ce926ba54..b8e003710a 100644 --- a/tests/integration/targets/setup_openssl/tasks/main.yml +++ b/tests/integration/targets/setup_openssl/tasks/main.yml @@ -22,7 +22,7 @@ - vars - name: Install OpenSSL - become: True + become: true package: name: '{{ openssl_package_name }}' when: not ansible_os_family == 'Darwin' @@ -49,13 +49,13 @@ when: cryptography_from_pip - name: Install pyOpenSSL (Python 3) - become: True + become: true package: name: '{{ pyopenssl_package_name_python3 }}' when: pyopenssl_package_name_python3 is defined and ansible_python_version is version('3.0', '>=') - name: Install pyOpenSSL (Python 2) - become: True + become: true package: name: '{{ pyopenssl_package_name }}' when: pyopenssl_package_name is defined and ansible_python_version is version('3.0', '<') diff --git a/tests/integration/targets/zypper/tasks/zypper.yml b/tests/integration/targets/zypper/tasks/zypper.yml index 9e840676e9..3eefddbdfc 100644 --- a/tests/integration/targets/zypper/tasks/zypper.yml +++ b/tests/integration/targets/zypper/tasks/zypper.yml @@ -22,7 +22,7 @@ - name: check hello with rpm shell: rpm -q hello - failed_when: False + failed_when: false register: rpm_result - debug: var=zypper_result @@ -55,7 +55,7 @@ - name: check hello with rpm shell: rpm -q hello - failed_when: False + failed_when: false register: rpm_result - debug: var=zypper_result @@ -91,12 +91,12 @@ - name: check hello with rpm shell: rpm -q hello - failed_when: False + failed_when: false register: rpm_hello_result - name: check metamail with rpm shell: rpm -q metamail - failed_when: False + failed_when: false register: rpm_metamail_result - name: verify packages uninstalled @@ -115,12 +115,12 @@ - name: check hello with rpm shell: rpm -q hello - failed_when: False + failed_when: false register: rpm_hello_result - name: check metamail with rpm shell: rpm -q metamail - failed_when: False + failed_when: false register: rpm_metamail_result - name: verify packages installed @@ -224,7 +224,7 @@ - name: check empty with rpm shell: rpm -q empty - failed_when: False + failed_when: false register: rpm_result - name: verify installation of empty @@ -406,15 +406,15 @@ zypper: name: hello state: present - update_cache: True + update_cache: true register: zypper_result_update_cache - name: run updatecache in check mode zypper: name: hello state: present - update_cache: True - check_mode: True + update_cache: true + check_mode: true register: zypper_result_update_cache_check From 6cf674485ff85c46ce7fd1464ac4f71a22e93aa0 Mon Sep 17 00:00:00 2001 From: Daniel Patrick Date: Wed, 8 Mar 2023 07:54:36 +0100 Subject: [PATCH 0230/1810] memset*.py: Fixed URLError handling (#6114) * memset.py: Added URLError exception and stderr to Response() object * memset_*.py: Check response.status_code and response.stderr * Added changelog fragment * memset.py: Fixed pep8 * Renamed changelog fragment with .yml file extension --- changelogs/fragments/6114-memset-add-url-error-handling.yml | 2 ++ plugins/module_utils/memset.py | 5 +++++ plugins/modules/memset_dns_reload.py | 5 ++++- plugins/modules/memset_memstore_info.py | 5 ++++- plugins/modules/memset_server_info.py | 5 ++++- plugins/modules/memset_zone.py | 3 +++ plugins/modules/memset_zone_domain.py | 5 ++++- plugins/modules/memset_zone_record.py | 5 ++++- 8 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/6114-memset-add-url-error-handling.yml diff --git a/changelogs/fragments/6114-memset-add-url-error-handling.yml b/changelogs/fragments/6114-memset-add-url-error-handling.yml new file mode 100644 index 0000000000..25dd869d19 --- /dev/null +++ b/changelogs/fragments/6114-memset-add-url-error-handling.yml @@ -0,0 +1,2 @@ +bugfixes: + - "memset - fix memset urlerror handling (https://github.com/ansible-collections/community.general/pull/6114)." diff --git a/plugins/module_utils/memset.py b/plugins/module_utils/memset.py index 671a8de308..374b40ff44 100644 --- a/plugins/module_utils/memset.py +++ b/plugins/module_utils/memset.py @@ -26,6 +26,7 @@ class Response(object): def __init__(self): self.content = None self.status_code = None + self.stderr = None def json(self): return json.loads(self.content) @@ -75,6 +76,10 @@ def memset_api_call(api_key, api_method, payload=None): msg = "Memset API returned a {0} response ({1}, {2})." . format(response.status_code, response.json()['error_type'], response.json()['error']) else: msg = "Memset API returned an error ({0}, {1})." . format(response.json()['error_type'], response.json()['error']) + except urllib_error.URLError as e: + has_failed = True + msg = "An URLError occured ({0})." . format(type(e)) + response.stderr = "{0}" . format(e) if msg is None: msg = response.json() diff --git a/plugins/modules/memset_dns_reload.py b/plugins/modules/memset_dns_reload.py index c69df6d783..a1168724f5 100644 --- a/plugins/modules/memset_dns_reload.py +++ b/plugins/modules/memset_dns_reload.py @@ -139,7 +139,10 @@ def reload_dns(args=None): # manifest themselves at this point so we need to ensure the user is # informed of the reason. retvals['failed'] = has_failed - retvals['memset_api'] = response.json() + if response.status_code is not None: + retvals['memset_api'] = response.json() + else: + retvals['stderr'] = response.stderr retvals['msg'] = msg return retvals diff --git a/plugins/modules/memset_memstore_info.py b/plugins/modules/memset_memstore_info.py index 4ee7cfc2a5..5fc9d79e1f 100644 --- a/plugins/modules/memset_memstore_info.py +++ b/plugins/modules/memset_memstore_info.py @@ -134,7 +134,10 @@ def get_facts(args=None): # informed of the reason. retvals['failed'] = has_failed retvals['msg'] = msg - retvals['stderr'] = "API returned an error: {0}" . format(response.status_code) + if response.status_code is not None: + retvals['stderr'] = "API returned an error: {0}" . format(response.status_code) + else: + retvals['stderr'] = "{0}" . format(response.stderr) return retvals # we don't want to return the same thing twice diff --git a/plugins/modules/memset_server_info.py b/plugins/modules/memset_server_info.py index 9023c0f8f0..ecc0375eb1 100644 --- a/plugins/modules/memset_server_info.py +++ b/plugins/modules/memset_server_info.py @@ -259,7 +259,10 @@ def get_facts(args=None): # informed of the reason. retvals['failed'] = has_failed retvals['msg'] = msg - retvals['stderr'] = "API returned an error: {0}" . format(response.status_code) + if response.status_code is not None: + retvals['stderr'] = "API returned an error: {0}" . format(response.status_code) + else: + retvals['stderr'] = "{0}" . format(response.stderr) return retvals # we don't want to return the same thing twice diff --git a/plugins/modules/memset_zone.py b/plugins/modules/memset_zone.py index 738d9e16ba..e17472e395 100644 --- a/plugins/modules/memset_zone.py +++ b/plugins/modules/memset_zone.py @@ -264,6 +264,9 @@ def create_or_delete(args=None): retvals['failed'] = _has_failed retvals['msg'] = _msg + if response.stderr is not None: + retvals['stderr'] = response.stderr + return retvals zone_exists, _msg, counter, _zone_id = get_zone_id(zone_name=args['name'], current_zones=response.json()) diff --git a/plugins/modules/memset_zone_domain.py b/plugins/modules/memset_zone_domain.py index 26276f68a5..172a48be25 100644 --- a/plugins/modules/memset_zone_domain.py +++ b/plugins/modules/memset_zone_domain.py @@ -195,7 +195,10 @@ def create_or_delete_domain(args=None): # informed of the reason. retvals['failed'] = has_failed retvals['msg'] = msg - retvals['stderr'] = "API returned an error: {0}" . format(response.status_code) + if response.status_code is not None: + retvals['stderr'] = "API returned an error: {0}" . format(response.status_code) + else: + retvals['stderr'] = response.stderr return retvals zone_exists, msg, counter, zone_id = get_zone_id(zone_name=args['zone'], current_zones=response.json()) diff --git a/plugins/modules/memset_zone_record.py b/plugins/modules/memset_zone_record.py index 021ad461d2..4e56a11caf 100644 --- a/plugins/modules/memset_zone_record.py +++ b/plugins/modules/memset_zone_record.py @@ -313,7 +313,10 @@ def create_or_delete(args=None): # informed of the reason. retvals['failed'] = _has_failed retvals['msg'] = msg - retvals['stderr'] = "API returned an error: {0}" . format(response.status_code) + if response.status_code is not None: + retvals['stderr'] = "API returned an error: {0}" . format(response.status_code) + else: + retvals['stderr'] = response.stderr return retvals zone_exists, _msg, counter, zone_id = get_zone_id(zone_name=args['zone'], current_zones=response.json()) From 6d003ca7fcb0bca3cddb93d80de9cced26452803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Jeanneret?= <39397510+cjeanner@users.noreply.github.com> Date: Wed, 8 Mar 2023 14:16:45 +0100 Subject: [PATCH 0231/1810] [make] Improve module doc (#6161) This change reorder the parameters so that we get the mandatory one at the top, then alphabetically order the other bellow. It also adds the returned values. --- plugins/modules/make.py | 56 ++++++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/plugins/modules/make.py b/plugins/modules/make.py index be2a32bd45..ec19b367c3 100644 --- a/plugins/modules/make.py +++ b/plugins/modules/make.py @@ -25,15 +25,6 @@ attributes: diff_mode: support: none options: - target: - description: - - The target to run. - - Typically this would be something like C(install),C(test) or C(all)." - type: str - params: - description: - - Any extra parameters to pass to make. - type: dict chdir: description: - Change to this directory before running make. @@ -43,11 +34,6 @@ options: description: - Use a custom Makefile. type: path - make: - description: - - Use a specific make binary. - type: path - version_added: '0.2.0' jobs: description: - Set the number of make jobs to run concurrently. @@ -55,6 +41,20 @@ options: - This is not supported by all make implementations. type: int version_added: 2.0.0 + make: + description: + - Use a specific make binary. + type: path + version_added: '0.2.0' + params: + description: + - Any extra parameters to pass to make. + type: dict + target: + description: + - The target to run. + - Typically this would be something like C(install), C(test), or C(all). + type: str ''' EXAMPLES = r''' @@ -83,7 +83,33 @@ EXAMPLES = r''' file: /some-project/Makefile ''' -RETURN = r'''# ''' +RETURN = r''' +chdir: + description: + - The value of the module parameter I(chdir). + type: str + returned: success +file: + description: + - The value of the module parameter I(file). + type: str + returned: success +jobs: + description: + - The value of the module parameter I(jobs) + type: int + returned: success +params: + description: + - The value of the module parameter I(params) + type: dict + returned: success +target: + description: + - The value of the module parameter I(target) + type: str + returned: success +''' from ansible.module_utils.six import iteritems from ansible.module_utils.basic import AnsibleModule From 6b8a1cd8e68ea3571f973eed6f87a968d8217420 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Wed, 8 Mar 2023 22:46:09 +0100 Subject: [PATCH 0232/1810] Add macOS 13.2 to CI (#6166) Add macOS 13.2 to CI. --- .azure-pipelines/azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.azure-pipelines/azure-pipelines.yml b/.azure-pipelines/azure-pipelines.yml index e3b0e8bdc4..fe31f4d650 100644 --- a/.azure-pipelines/azure-pipelines.yml +++ b/.azure-pipelines/azure-pipelines.yml @@ -191,8 +191,8 @@ stages: parameters: testFormat: devel/{0} targets: - - name: macOS 12.0 - test: macos/12.0 + - name: macOS 13.2 + test: macos/13.2 - name: RHEL 7.9 test: rhel/7.9 - name: RHEL 9.1 From abcba9dbbec79374dc0cdb9978f0622e74a60e48 Mon Sep 17 00:00:00 2001 From: Roman Belyakovsky Date: Thu, 9 Mar 2023 21:09:13 +0200 Subject: [PATCH 0233/1810] Interfaces file spaces fix (#6131) * interfaces_file: added test case for #6120 * interfaces_file: reverted code to #fafabed * interfaces_file: added changelog fragment * interfaces_file: added missing licenses * interfaces_file: improved test coverage * interfaces_file: fixed retrieving option values * Update plugins/modules/interfaces_file.py Co-authored-by: Felix Fontein * Update plugins/modules/interfaces_file.py Co-authored-by: Felix Fontein * Update tests/unit/plugins/modules/interfaces_file/test_interfaces_file.py Co-authored-by: Felix Fontein * Update plugins/modules/interfaces_file.py Co-authored-by: Felix Fontein * Update plugins/modules/interfaces_file.py Co-authored-by: Felix Fontein * Update plugins/modules/interfaces_file.py Co-authored-by: Felix Fontein * Update plugins/modules/interfaces_file.py Co-authored-by: Felix Fontein * Update plugins/modules/interfaces_file.py Co-authored-by: Felix Fontein * Update plugins/modules/interfaces_file.py Co-authored-by: Felix Fontein * Update tests/unit/plugins/modules/interfaces_file/test_interfaces_file.py Co-authored-by: Felix Fontein * interfaces_file: spacing fix --------- Co-authored-by: Felix Fontein --- ...-interfaces_file-for-no-leading-spaces.yml | 2 + plugins/modules/interfaces_file.py | 154 ++++++++----- .../no_leading_spaces.test_no_changes | 8 + .../no_leading_spaces.test_no_changes.json | 21 ++ ...eading_spaces.test_no_changes.json.license | 3 + .../no_leading_spaces.test_no_changes.license | 3 + .../no_leading_spaces_add_aggi_up | 8 + ..._leading_spaces_add_aggi_up.exceptions.txt | 8 + ..._spaces_add_aggi_up.exceptions.txt.license | 3 + .../no_leading_spaces_add_aggi_up.json | 21 ++ ...no_leading_spaces_add_aggi_up.json.license | 3 + .../no_leading_spaces_add_aggi_up.license | 3 + .../no_leading_spaces_add_aggi_up_twice | 8 + ...ng_spaces_add_aggi_up_twice.exceptions.txt | 17 ++ ...s_add_aggi_up_twice.exceptions.txt.license | 3 + .../no_leading_spaces_add_aggi_up_twice.json | 21 ++ ...ding_spaces_add_aggi_up_twice.json.license | 3 + ...o_leading_spaces_add_aggi_up_twice.license | 3 + .../no_leading_spaces_add_and_delete_aggi_up | 8 + ...aces_add_and_delete_aggi_up.exceptions.txt | 17 ++ ..._and_delete_aggi_up.exceptions.txt.license | 3 + ...leading_spaces_add_and_delete_aggi_up.json | 21 ++ ...spaces_add_and_delete_aggi_up.json.license | 3 + ...ding_spaces_add_and_delete_aggi_up.license | 3 + .../no_leading_spaces_aggi_remove_dup | 8 + ...ding_spaces_aggi_remove_dup.exceptions.txt | 17 ++ ...ces_aggi_remove_dup.exceptions.txt.license | 3 + .../no_leading_spaces_aggi_remove_dup.json | 21 ++ ...eading_spaces_aggi_remove_dup.json.license | 3 + .../no_leading_spaces_aggi_remove_dup.license | 3 + .../no_leading_spaces_change_ipv4 | 8 + ..._leading_spaces_change_ipv4.exceptions.txt | 0 ..._spaces_change_ipv4.exceptions.txt.license | 3 + .../no_leading_spaces_change_ipv4.json | 21 ++ ...no_leading_spaces_change_ipv4.json.license | 3 + .../no_leading_spaces_change_ipv4.license | 3 + .../no_leading_spaces_change_ipv4_post_up | 9 + ..._spaces_change_ipv4_post_up.exceptions.txt | 0 ...change_ipv4_post_up.exceptions.txt.license | 3 + ...no_leading_spaces_change_ipv4_post_up.json | 21 ++ ...ng_spaces_change_ipv4_post_up.json.license | 3 + ...leading_spaces_change_ipv4_post_up.license | 3 + .../no_leading_spaces_change_ipv4_pre_up | 9 + ...g_spaces_change_ipv4_pre_up.exceptions.txt | 0 ..._change_ipv4_pre_up.exceptions.txt.license | 3 + .../no_leading_spaces_change_ipv4_pre_up.json | 21 ++ ...ing_spaces_change_ipv4_pre_up.json.license | 3 + ..._leading_spaces_change_ipv4_pre_up.license | 3 + .../no_leading_spaces_change_ipv6 | 8 + ..._leading_spaces_change_ipv6.exceptions.txt | 9 + ..._spaces_change_ipv6.exceptions.txt.license | 3 + .../no_leading_spaces_change_ipv6.json | 21 ++ ...no_leading_spaces_change_ipv6.json.license | 3 + .../no_leading_spaces_change_ipv6.license | 3 + .../no_leading_spaces_change_ipv6_post_up | 8 + ..._spaces_change_ipv6_post_up.exceptions.txt | 9 + ...change_ipv6_post_up.exceptions.txt.license | 3 + ...no_leading_spaces_change_ipv6_post_up.json | 21 ++ ...ng_spaces_change_ipv6_post_up.json.license | 3 + ...leading_spaces_change_ipv6_post_up.license | 3 + .../no_leading_spaces_change_ipv6_pre_up | 8 + ...g_spaces_change_ipv6_pre_up.exceptions.txt | 9 + ..._change_ipv6_pre_up.exceptions.txt.license | 3 + .../no_leading_spaces_change_ipv6_pre_up.json | 21 ++ ...ing_spaces_change_ipv6_pre_up.json.license | 3 + ..._leading_spaces_change_ipv6_pre_up.license | 3 + .../no_leading_spaces_change_method | 8 + ...eading_spaces_change_method.exceptions.txt | 8 + ...paces_change_method.exceptions.txt.license | 3 + .../no_leading_spaces_change_method.json | 21 ++ ..._leading_spaces_change_method.json.license | 3 + .../no_leading_spaces_change_method.license | 3 + .../golden_output/no_leading_spaces_revert | 7 + .../no_leading_spaces_revert.exceptions.txt | 0 ...ading_spaces_revert.exceptions.txt.license | 3 + .../no_leading_spaces_revert.json | 21 ++ .../no_leading_spaces_revert.json.license | 3 + .../no_leading_spaces_revert.license | 3 + .../no_leading_spaces_set_aggi_and_eth0_mtu | 8 + ...paces_set_aggi_and_eth0_mtu.exceptions.txt | 8 + ...t_aggi_and_eth0_mtu.exceptions.txt.license | 3 + ..._leading_spaces_set_aggi_and_eth0_mtu.json | 21 ++ ..._spaces_set_aggi_and_eth0_mtu.json.license | 3 + ...ading_spaces_set_aggi_and_eth0_mtu.license | 3 + .../no_leading_spaces_set_aggi_slaves | 8 + ...ding_spaces_set_aggi_slaves.exceptions.txt | 8 + ...ces_set_aggi_slaves.exceptions.txt.license | 3 + .../no_leading_spaces_set_aggi_slaves.json | 21 ++ ...eading_spaces_set_aggi_slaves.json.license | 3 + .../no_leading_spaces_set_aggi_slaves.license | 3 + .../input/no_leading_spaces | 8 + .../input/no_leading_spaces.license | 3 + .../interfaces_file/test_interfaces_file.py | 213 +++++++++++++++++- 93 files changed, 995 insertions(+), 63 deletions(-) create mode 100644 changelogs/fragments/6131-fix-interfaces_file-for-no-leading-spaces.yml create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces.test_no_changes create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces.test_no_changes.json create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces.test_no_changes.json.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces.test_no_changes.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_add_aggi_up create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_add_aggi_up.exceptions.txt create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_add_aggi_up.exceptions.txt.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_add_aggi_up.json create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_add_aggi_up.json.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_add_aggi_up.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_add_aggi_up_twice create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_add_aggi_up_twice.exceptions.txt create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_add_aggi_up_twice.exceptions.txt.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_add_aggi_up_twice.json create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_add_aggi_up_twice.json.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_add_aggi_up_twice.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_add_and_delete_aggi_up create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_add_and_delete_aggi_up.exceptions.txt create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_add_and_delete_aggi_up.exceptions.txt.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_add_and_delete_aggi_up.json create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_add_and_delete_aggi_up.json.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_add_and_delete_aggi_up.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_aggi_remove_dup create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_aggi_remove_dup.exceptions.txt create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_aggi_remove_dup.exceptions.txt.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_aggi_remove_dup.json create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_aggi_remove_dup.json.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_aggi_remove_dup.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv4 create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv4.exceptions.txt create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv4.exceptions.txt.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv4.json create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv4.json.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv4.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv4_post_up create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv4_post_up.exceptions.txt create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv4_post_up.exceptions.txt.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv4_post_up.json create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv4_post_up.json.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv4_post_up.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv4_pre_up create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv4_pre_up.exceptions.txt create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv4_pre_up.exceptions.txt.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv4_pre_up.json create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv4_pre_up.json.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv4_pre_up.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv6 create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv6.exceptions.txt create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv6.exceptions.txt.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv6.json create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv6.json.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv6.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv6_post_up create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv6_post_up.exceptions.txt create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv6_post_up.exceptions.txt.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv6_post_up.json create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv6_post_up.json.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv6_post_up.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv6_pre_up create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv6_pre_up.exceptions.txt create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv6_pre_up.exceptions.txt.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv6_pre_up.json create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv6_pre_up.json.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_ipv6_pre_up.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_method create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_method.exceptions.txt create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_method.exceptions.txt.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_method.json create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_method.json.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_change_method.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_revert create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_revert.exceptions.txt create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_revert.exceptions.txt.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_revert.json create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_revert.json.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_revert.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_set_aggi_and_eth0_mtu create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_set_aggi_and_eth0_mtu.exceptions.txt create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_set_aggi_and_eth0_mtu.exceptions.txt.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_set_aggi_and_eth0_mtu.json create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_set_aggi_and_eth0_mtu.json.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_set_aggi_and_eth0_mtu.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_set_aggi_slaves create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_set_aggi_slaves.exceptions.txt create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_set_aggi_slaves.exceptions.txt.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_set_aggi_slaves.json create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_set_aggi_slaves.json.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/golden_output/no_leading_spaces_set_aggi_slaves.license create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/input/no_leading_spaces create mode 100644 tests/unit/plugins/modules/interfaces_file/interfaces_file_fixtures/input/no_leading_spaces.license diff --git a/changelogs/fragments/6131-fix-interfaces_file-for-no-leading-spaces.yml b/changelogs/fragments/6131-fix-interfaces_file-for-no-leading-spaces.yml new file mode 100644 index 0000000000..c975d4e624 --- /dev/null +++ b/changelogs/fragments/6131-fix-interfaces_file-for-no-leading-spaces.yml @@ -0,0 +1,2 @@ +bugfixes: + - interfaces_file - fix reading options in lines not starting with a space (https://github.com/ansible-collections/community.general/issues/6120). diff --git a/plugins/modules/interfaces_file.py b/plugins/modules/interfaces_file.py index 8e643fb797..f19c019f4e 100644 --- a/plugins/modules/interfaces_file.py +++ b/plugins/modules/interfaces_file.py @@ -156,20 +156,22 @@ from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.common.text.converters import to_bytes -def line_dict(line): +def lineDict(line): return {'line': line, 'line_type': 'unknown'} -def make_option_dict(line, iface, option, value, address_family): +def optionDict(line, iface, option, value, address_family): return {'line': line, 'iface': iface, 'option': option, 'value': value, 'line_type': 'option', 'address_family': address_family} -def get_option_value(line): - patt = re.compile(r'^\s+(?P