diff --git a/.azure-pipelines/azure-pipelines.yml b/.azure-pipelines/azure-pipelines.yml index 8ad8b8d..ab7c4ba 100644 --- a/.azure-pipelines/azure-pipelines.yml +++ b/.azure-pipelines/azure-pipelines.yml @@ -36,7 +36,7 @@ variables: resources: containers: - container: default - image: quay.io/ansible/azure-pipelines-test-container:1.7.1 + image: quay.io/ansible/azure-pipelines-test-container:1.8.0 pool: Standard @@ -57,18 +57,18 @@ stages: test: centos7 - name: CentOS 8 test: centos8 - - name: Fedora 30 - test: fedora30 - - name: Fedora 31 - test: fedora31 + - name: Fedora 32 + test: fedora32 + - name: Fedora 33 + test: fedora33 - name: openSUSE 15 py2 test: opensuse15py2 - name: openSUSE 15 py3 test: opensuse15 - - name: Ubuntu 16.04 - test: ubuntu1604 - name: Ubuntu 18.04 test: ubuntu1804 + - name: Ubuntu 20.04 + test: ubuntu2004 - stage: Docker_2_10 displayName: Docker 2.10 dependsOn: [] @@ -131,16 +131,16 @@ stages: parameters: testFormat: devel/{0}/1 targets: - - name: OS X 10.11 - test: osx/10.11 - - name: RHEL 7.6 - test: rhel/7.6 - - name: RHEL 8.1 - test: rhel/8.1 - - name: FreeBSD 11.1 - test: freebsd/11.1 - - name: FreeBSD 12.1 - test: freebsd/12.1 + - name: MacOS 11.1 + test: macos/11.1 + - name: RHEL 7.9 + test: rhel/7.9 + - name: RHEL 8.3 + test: rhel/8.3 + - name: FreeBSD 11.4 + test: freebsd/11.4 + - name: FreeBSD 12.2 + test: freebsd/12.2 - stage: Remote_2_10 displayName: Remote 2.10 dependsOn: [] diff --git a/.azure-pipelines/scripts/aggregate-coverage.sh b/.azure-pipelines/scripts/aggregate-coverage.sh index 2200502..f3113dd 100755 --- a/.azure-pipelines/scripts/aggregate-coverage.sh +++ b/.azure-pipelines/scripts/aggregate-coverage.sh @@ -12,4 +12,9 @@ mkdir "${agent_temp_directory}/coverage/" options=(--venv --venv-system-site-packages --color -v) ansible-test coverage combine --export "${agent_temp_directory}/coverage/" "${options[@]}" -ansible-test coverage analyze targets generate "${agent_temp_directory}/coverage/coverage-analyze-targets.json" "${options[@]}" + +if ansible-test coverage analyze targets generate --help >/dev/null 2>&1; then + # Only analyze coverage if the installed version of ansible-test supports it. + # Doing so allows this script to work unmodified for multiple Ansible versions. + ansible-test coverage analyze targets generate "${agent_temp_directory}/coverage/coverage-analyze-targets.json" "${options[@]}" +fi diff --git a/.azure-pipelines/scripts/report-coverage.sh b/.azure-pipelines/scripts/report-coverage.sh index f154998..1bd91bd 100755 --- a/.azure-pipelines/scripts/report-coverage.sh +++ b/.azure-pipelines/scripts/report-coverage.sh @@ -5,6 +5,11 @@ set -o pipefail -eu PATH="${PWD}/bin:${PATH}" -pip install https://github.com/ansible/ansible/archive/devel.tar.gz --disable-pip-version-check +if ! ansible-test --help >/dev/null 2>&1; then + # Install the devel version of ansible-test for generating code coverage reports. + # This is only used by Ansible Collections, which are typically tested against multiple Ansible versions (in separate jobs). + # Since a version of ansible-test is required that can work the output from multiple older releases, the devel version is used. + pip install https://github.com/ansible/ansible/archive/devel.tar.gz --disable-pip-version-check +fi ansible-test coverage xml --stub --venv --venv-system-site-packages --color -v diff --git a/README.md b/README.md index 19359cd..73d8a05 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ An Ansible Collection of modules and plugins that target POSIX UNIX/Linux and de ## Ansible version compatibility -This collection has been tested against following Ansible versions: **>=2.9,<2.11**. +This collection has been tested against following Ansible versions: **>=2.9**. Plugins and modules within a collection may be tested with only specific Ansible versions. A collection may contain metadata that identifies these versions. diff --git a/changelogs/fragments/.empty b/changelogs/fragments/.empty deleted file mode 100644 index e69de29..0000000 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/meta/runtime.yml b/meta/runtime.yml index b8961b1..43bbe45 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -1,2 +1,2 @@ --- -requires_ansible: '>=2.9,<2.11' +requires_ansible: '>=2.9' 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 c12a18b..c4a5542 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,14 +43,17 @@ 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), C(x) - (read, write and execute respectively), and C(X) (execute permission if the file is a directory or already has execute permission for some user) + type: str entry: description: - DEPRECATED. @@ -58,6 +62,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. @@ -76,6 +81,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 new file mode 100644 index 0000000..013403f --- /dev/null +++ b/tests/sanity/ignore-2.11.txt @@ -0,0 +1,8 @@ +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 +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/sanity/requirements.txt b/tests/sanity/requirements.txt deleted file mode 100644 index 3e3a966..0000000 --- a/tests/sanity/requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -packaging # needed for update-bundled and changelog -sphinx ; python_version >= '3.5' # docs build requires python 3+ -sphinx-notfound-page ; python_version >= '3.5' # docs build requires python 3+ -straight.plugin ; python_version >= '3.5' # needed for hacking/build-ansible.py which will host changelog generation and requires python 3+ 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']"]), diff --git a/tests/utils/shippable/macos.sh b/tests/utils/shippable/macos.sh new file mode 120000 index 0000000..6ddb776 --- /dev/null +++ b/tests/utils/shippable/macos.sh @@ -0,0 +1 @@ +remote.sh \ No newline at end of file