diff --git a/changelogs/fragments/misc_fix.yml b/changelogs/fragments/misc_fix.yml new file mode 100644 index 0000000..66b7eff --- /dev/null +++ b/changelogs/fragments/misc_fix.yml @@ -0,0 +1,2 @@ +minor_changes: +- fix sanity test for various modules. diff --git a/plugins/module_utils/firewalld.py b/plugins/module_utils/firewalld.py index b44e031..7c34db4 100644 --- a/plugins/module_utils/firewalld.py +++ b/plugins/module_utils/firewalld.py @@ -3,6 +3,10 @@ # (c) 2013-2018, Adam Miller (maxamillion@fedoraproject.org) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + # Imports and info for sanity checking from distutils.version import LooseVersion diff --git a/plugins/module_utils/mount.py b/plugins/module_utils/mount.py index 62feb35..58be0e8 100644 --- a/plugins/module_utils/mount.py +++ b/plugins/module_utils/mount.py @@ -48,6 +48,10 @@ # agrees to be bound by the terms and conditions of this License # Agreement. +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + import os diff --git a/plugins/modules/acl.py b/plugins/modules/acl.py index 38ff294..9e89157 100644 --- a/plugins/modules/acl.py +++ b/plugins/modules/acl.py @@ -28,6 +28,7 @@ options: - The C(query) state gets the current ACL without changing it, for use in C(register) operations. choices: [ absent, present, query ] default: query + type: str follow: description: - Whether to follow symlinks on the path if a symlink is encountered. @@ -42,13 +43,16 @@ options: entity: description: - The actual user or group that the ACL applies to when matching entity types user or group are selected. + type: str etype: description: - The entity type of the ACL to apply, see C(setfacl) documentation for more info. choices: [ group, mask, other, user ] + type: str permissions: description: - The permissions to apply/remove can be any combination of C(r), C(w) and C(x) (read, write and execute respectively) + type: str entry: description: - DEPRECATED. @@ -57,6 +61,7 @@ options: - The qualifier may be empty for some types, but the type and perms are always required. - C(-) can be used as placeholder when you do not care about permissions. - This is now superseded by entity, type and permissions fields. + type: str recursive: description: - Recursively sets the specified ACL. @@ -75,6 +80,7 @@ options: - Incompatible with C(state=query). choices: [ default, mask, no_mask ] default: default + type: str author: - Brian Coca (@bcoca) - Jérémie Astori (@astorije) diff --git a/plugins/modules/at.py b/plugins/modules/at.py index 4cbe0c7..b29b35e 100644 --- a/plugins/modules/at.py +++ b/plugins/modules/at.py @@ -8,7 +8,7 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type -DOCUMENTATION = ''' +DOCUMENTATION = r''' --- module: at short_description: Schedule the execution of a command or script file via the at command @@ -29,12 +29,10 @@ options: description: - The count of units in the future to execute the command or script file. type: int - required: true units: description: - The type of units in the future to execute the command or script file. type: str - required: true choices: [ minutes, hours, days, weeks ] state: description: diff --git a/plugins/modules/authorized_key.py b/plugins/modules/authorized_key.py index 5f7b4b7..d860822 100644 --- a/plugins/modules/authorized_key.py +++ b/plugins/modules/authorized_key.py @@ -50,6 +50,7 @@ options: key_options: description: - A string of ssh key options to be prepended to the key in the authorized_keys file. + type: str exclusive: description: - Whether to remove all other non-specified keys from the authorized_keys file. diff --git a/plugins/modules/seboolean.py b/plugins/modules/seboolean.py index 57889e9..ef1b8c6 100644 --- a/plugins/modules/seboolean.py +++ b/plugins/modules/seboolean.py @@ -7,7 +7,7 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type -DOCUMENTATION = ''' +DOCUMENTATION = r''' --- module: seboolean short_description: Toggles SELinux booleans @@ -19,6 +19,7 @@ options: description: - Name of the boolean to configure. required: true + type: str persistent: description: - Set to C(yes) if the boolean setting should survive a reboot. diff --git a/plugins/modules/selinux.py b/plugins/modules/selinux.py index e32892d..a22c282 100644 --- a/plugins/modules/selinux.py +++ b/plugins/modules/selinux.py @@ -20,17 +20,20 @@ version_added: "1.0.0" options: policy: description: - - The name of the SELinux policy to use (e.g. C(targeted)) will be required if state is not C(disabled). + - The name of the SELinux policy to use (e.g. C(targeted)) will be required if I(state) is not C(disabled). + type: str state: description: - The SELinux mode. required: true choices: [ disabled, enforcing, permissive ] + type: str configfile: description: - The path to the SELinux configuration file, if non-standard. default: /etc/selinux/config aliases: [ conf, file ] + type: str requirements: [ libselinux-python ] author: - Derek Carter (@goozbach) @@ -178,7 +181,7 @@ def main(): module = AnsibleModule( argument_spec=dict( policy=dict(type='str'), - state=dict(type='str', required='True', choices=['enforcing', 'permissive', 'disabled']), + state=dict(type='str', required=True, choices=['enforcing', 'permissive', 'disabled']), configfile=dict(type='str', default='/etc/selinux/config', aliases=['conf', 'file']), ), supports_check_mode=True, diff --git a/plugins/modules/synchronize.py b/plugins/modules/synchronize.py index 6702cc3..8713a77 100644 --- a/plugins/modules/synchronize.py +++ b/plugins/modules/synchronize.py @@ -147,6 +147,7 @@ options: - Note that an empty string in C(rsync_opts) will end up transfer the current working directory. type: list default: + elements: str partial: description: - Tells rsync to keep the partial file which should make a subsequent transfer of the rest of the file much faster. @@ -166,6 +167,8 @@ options: - Add a destination to hard link against during the rsync. type: list default: + elements: str + notes: - rsync must be installed on both the local and remote host. - For the C(synchronize) module, the "local host" is the host `the synchronize task originates on`, and the "destination host" is the host @@ -390,12 +393,12 @@ def main(): group=dict(type='bool'), set_remote_user=dict(type='bool', default=True), rsync_timeout=dict(type='int', default=0), - rsync_opts=dict(type='list', default=[]), + rsync_opts=dict(type='list', default=[], elements='str'), ssh_args=dict(type='str'), partial=dict(type='bool', default=False), verify_host=dict(type='bool', default=False), mode=dict(type='str', default='push', choices=['pull', 'push']), - link_dest=dict(type='list') + link_dest=dict(type='list', elements='str'), ), supports_check_mode=True, ) diff --git a/plugins/modules/sysctl.py b/plugins/modules/sysctl.py index 1654ec6..b82b2e4 100644 --- a/plugins/modules/sysctl.py +++ b/plugins/modules/sysctl.py @@ -9,7 +9,7 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type -DOCUMENTATION = ''' +DOCUMENTATION = r''' --- module: sysctl short_description: Manage entries in sysctl.conf. @@ -19,18 +19,21 @@ version_added: "1.0.0" options: name: description: - - The dot-separated path (aka I(key)) specifying the sysctl variable. + - The dot-separated path (also known as I(key)) specifying the sysctl variable. required: true aliases: [ 'key' ] + type: str value: description: - Desired value of the sysctl key. aliases: [ 'val' ] + type: str state: description: - Whether the entry should be present or absent in the sysctl file. choices: [ "present", "absent" ] default: present + type: str ignoreerrors: description: - Use this option to ignore errors about unknown keys. @@ -47,12 +50,14 @@ options: description: - Specifies the absolute path to C(sysctl.conf), if not C(/etc/sysctl.conf). default: /etc/sysctl.conf + type: path sysctl_set: description: - Verify token value with the sysctl command and set with -w if necessary type: bool default: 'no' -author: "David CHANIAL (@davixx) " +author: +- David CHANIAL (@davixx) ''' EXAMPLES = r''' diff --git a/tests/integration/targets/selinux/tasks/selinux.yml b/tests/integration/targets/selinux/tasks/selinux.yml index 6771f32..a262f8b 100644 --- a/tests/integration/targets/selinux/tasks/selinux.yml +++ b/tests/integration/targets/selinux/tasks/selinux.yml @@ -48,9 +48,17 @@ var: _disable_test1 verbosity: 1 +- name: Before gathering the fact + debug: + msg: "{{ ansible_selinux }}" + - name: TEST 1 | Re-gather facts setup: +- name: After gathering the fact + debug: + msg: "{{ ansible_selinux }}" + - name: TEST 1 | Assert that status was changed, reboot_required is True, a warning was displayed, and SELinux is configured properly assert: that: @@ -74,7 +82,7 @@ var: _disable_test2 verbosity: 1 -- name: TEST 1 | Assert that no change is reported, a warnking was dispalyed, and reboot_required is True +- name: TEST 1 | Assert that no change is reported, a warning was displayed, and reboot_required is True assert: that: - _disable_test2 is not changed @@ -147,7 +155,7 @@ var: _state_test2 verbosity: 1 -- name: TEST 2 | Assert that no change was reported, no warnings were dispalyed, and reboot_required is False +- name: TEST 2 | Assert that no change was reported, no warnings were displayed, and reboot_required is False assert: that: - _state_test2 is not changed @@ -380,7 +388,7 @@ var: _lineinfile_out1 verbosity: 1 -- name: TEST 5 | Set SELinux to enforcing +- name: TEST 5 | Set SELinux to enforcing selinux: state: enforcing policy: targeted diff --git a/tests/sanity/ignore-2.10.txt b/tests/sanity/ignore-2.10.txt index f86017d..013403f 100644 --- a/tests/sanity/ignore-2.10.txt +++ b/tests/sanity/ignore-2.10.txt @@ -1,33 +1,8 @@ -plugins/module_utils/firewalld.py future-import-boilerplate -plugins/module_utils/firewalld.py metaclass-boilerplate -plugins/module_utils/mount.py future-import-boilerplate -plugins/module_utils/mount.py metaclass-boilerplate -plugins/modules/acl.py validate-modules:parameter-type-not-in-doc plugins/modules/synchronize.py pylint:blacklisted-name plugins/modules/synchronize.py use-argspec-type-path plugins/modules/synchronize.py validate-modules:doc-default-does-not-match-spec plugins/modules/synchronize.py validate-modules:nonexistent-parameter-documented -plugins/modules/synchronize.py validate-modules:parameter-list-no-elements plugins/modules/synchronize.py validate-modules:parameter-type-not-in-doc plugins/modules/synchronize.py validate-modules:undocumented-parameter -plugins/modules/at.py validate-modules:doc-required-mismatch -plugins/modules/authorized_key.py validate-modules:parameter-type-not-in-doc -plugins/modules/seboolean.py validate-modules:parameter-type-not-in-doc -plugins/modules/selinux.py validate-modules:invalid-ansiblemodule-schema -plugins/modules/selinux.py validate-modules:parameter-type-not-in-doc -plugins/modules/sysctl.py validate-modules:doc-missing-type -plugins/modules/sysctl.py validate-modules:parameter-type-not-in-doc -tests/unit/mock/path.py future-import-boilerplate -tests/unit/mock/path.py metaclass-boilerplate -tests/unit/mock/yaml_helper.py future-import-boilerplate -tests/unit/mock/yaml_helper.py metaclass-boilerplate -tests/unit/modules/conftest.py future-import-boilerplate -tests/unit/modules/conftest.py metaclass-boilerplate -tests/unit/modules/system/test_mount.py future-import-boilerplate -tests/unit/modules/system/test_mount.py metaclass-boilerplate -tests/unit/modules/utils.py future-import-boilerplate -tests/unit/modules/utils.py metaclass-boilerplate -tests/unit/plugins/action/test_synchronize.py future-import-boilerplate -tests/unit/plugins/action/test_synchronize.py metaclass-boilerplate tests/utils/shippable/check_matrix.py replace-urlopen tests/utils/shippable/timing.py shebang diff --git a/tests/sanity/ignore-2.11.txt b/tests/sanity/ignore-2.11.txt index f86017d..013403f 100644 --- a/tests/sanity/ignore-2.11.txt +++ b/tests/sanity/ignore-2.11.txt @@ -1,33 +1,8 @@ -plugins/module_utils/firewalld.py future-import-boilerplate -plugins/module_utils/firewalld.py metaclass-boilerplate -plugins/module_utils/mount.py future-import-boilerplate -plugins/module_utils/mount.py metaclass-boilerplate -plugins/modules/acl.py validate-modules:parameter-type-not-in-doc plugins/modules/synchronize.py pylint:blacklisted-name plugins/modules/synchronize.py use-argspec-type-path plugins/modules/synchronize.py validate-modules:doc-default-does-not-match-spec plugins/modules/synchronize.py validate-modules:nonexistent-parameter-documented -plugins/modules/synchronize.py validate-modules:parameter-list-no-elements plugins/modules/synchronize.py validate-modules:parameter-type-not-in-doc plugins/modules/synchronize.py validate-modules:undocumented-parameter -plugins/modules/at.py validate-modules:doc-required-mismatch -plugins/modules/authorized_key.py validate-modules:parameter-type-not-in-doc -plugins/modules/seboolean.py validate-modules:parameter-type-not-in-doc -plugins/modules/selinux.py validate-modules:invalid-ansiblemodule-schema -plugins/modules/selinux.py validate-modules:parameter-type-not-in-doc -plugins/modules/sysctl.py validate-modules:doc-missing-type -plugins/modules/sysctl.py validate-modules:parameter-type-not-in-doc -tests/unit/mock/path.py future-import-boilerplate -tests/unit/mock/path.py metaclass-boilerplate -tests/unit/mock/yaml_helper.py future-import-boilerplate -tests/unit/mock/yaml_helper.py metaclass-boilerplate -tests/unit/modules/conftest.py future-import-boilerplate -tests/unit/modules/conftest.py metaclass-boilerplate -tests/unit/modules/system/test_mount.py future-import-boilerplate -tests/unit/modules/system/test_mount.py metaclass-boilerplate -tests/unit/modules/utils.py future-import-boilerplate -tests/unit/modules/utils.py metaclass-boilerplate -tests/unit/plugins/action/test_synchronize.py future-import-boilerplate -tests/unit/plugins/action/test_synchronize.py metaclass-boilerplate tests/utils/shippable/check_matrix.py replace-urlopen tests/utils/shippable/timing.py shebang diff --git a/tests/sanity/ignore-2.9.txt b/tests/sanity/ignore-2.9.txt index eba078e..013403f 100644 --- a/tests/sanity/ignore-2.9.txt +++ b/tests/sanity/ignore-2.9.txt @@ -1,30 +1,8 @@ -plugins/module_utils/firewalld.py future-import-boilerplate -plugins/module_utils/firewalld.py metaclass-boilerplate -plugins/module_utils/mount.py future-import-boilerplate -plugins/module_utils/mount.py metaclass-boilerplate -plugins/modules/acl.py validate-modules:parameter-type-not-in-doc plugins/modules/synchronize.py pylint:blacklisted-name plugins/modules/synchronize.py use-argspec-type-path plugins/modules/synchronize.py validate-modules:doc-default-does-not-match-spec plugins/modules/synchronize.py validate-modules:nonexistent-parameter-documented plugins/modules/synchronize.py validate-modules:parameter-type-not-in-doc plugins/modules/synchronize.py validate-modules:undocumented-parameter -plugins/modules/authorized_key.py validate-modules:parameter-type-not-in-doc -plugins/modules/seboolean.py validate-modules:parameter-type-not-in-doc -plugins/modules/selinux.py validate-modules:parameter-type-not-in-doc -plugins/modules/sysctl.py validate-modules:doc-missing-type -plugins/modules/sysctl.py validate-modules:parameter-type-not-in-doc -tests/unit/mock/path.py future-import-boilerplate -tests/unit/mock/path.py metaclass-boilerplate -tests/unit/mock/yaml_helper.py future-import-boilerplate -tests/unit/mock/yaml_helper.py metaclass-boilerplate -tests/unit/modules/conftest.py future-import-boilerplate -tests/unit/modules/conftest.py metaclass-boilerplate -tests/unit/modules/system/test_mount.py future-import-boilerplate -tests/unit/modules/system/test_mount.py metaclass-boilerplate -tests/unit/modules/utils.py future-import-boilerplate -tests/unit/modules/utils.py metaclass-boilerplate -tests/unit/plugins/action/test_synchronize.py future-import-boilerplate -tests/unit/plugins/action/test_synchronize.py metaclass-boilerplate tests/utils/shippable/check_matrix.py replace-urlopen tests/utils/shippable/timing.py shebang diff --git a/tests/unit/mock/path.py b/tests/unit/mock/path.py index d128b5f..1553008 100644 --- a/tests/unit/mock/path.py +++ b/tests/unit/mock/path.py @@ -1,3 +1,7 @@ +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + from ansible_collections.ansible.posix.tests.unit.compat.mock import MagicMock from ansible.utils.path import unfrackpath diff --git a/tests/unit/mock/yaml_helper.py b/tests/unit/mock/yaml_helper.py index cc095fe..a4c2d6d 100644 --- a/tests/unit/mock/yaml_helper.py +++ b/tests/unit/mock/yaml_helper.py @@ -1,3 +1,7 @@ +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + import io import yaml diff --git a/tests/unit/modules/conftest.py b/tests/unit/modules/conftest.py index 3bbfe0b..6eb5883 100644 --- a/tests/unit/modules/conftest.py +++ b/tests/unit/modules/conftest.py @@ -1,6 +1,10 @@ # Copyright (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + import json import pytest diff --git a/tests/unit/modules/system/test_mount.py b/tests/unit/modules/system/test_mount.py index 893a651..73086cc 100644 --- a/tests/unit/modules/system/test_mount.py +++ b/tests/unit/modules/system/test_mount.py @@ -1,3 +1,7 @@ +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + import os import tempfile diff --git a/tests/unit/modules/utils.py b/tests/unit/modules/utils.py index 322a472..342d528 100644 --- a/tests/unit/modules/utils.py +++ b/tests/unit/modules/utils.py @@ -1,3 +1,7 @@ +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + import json from ansible_collections.ansible.posix.tests.unit.compat import unittest diff --git a/tests/unit/plugins/action/test_synchronize.py b/tests/unit/plugins/action/test_synchronize.py index f8f5f8a..39d9697 100644 --- a/tests/unit/plugins/action/test_synchronize.py +++ b/tests/unit/plugins/action/test_synchronize.py @@ -1,3 +1,7 @@ +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + ''' (Epdb) pprint(DeepDiff(self.final_task_vars, out_task_vars), indent=2) { 'dic_item_added': set([u"root['ansible_python_interpreter']"]),