Fix sanity test for modules

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Abhijeet Kasurde 2021-02-15 13:21:13 +05:30
parent 20f70caa1f
commit ea8fc70373
20 changed files with 73 additions and 86 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- fix sanity test for various modules.

View file

@ -3,6 +3,10 @@
# (c) 2013-2018, Adam Miller (maxamillion@fedoraproject.org) # (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) # 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 # Imports and info for sanity checking
from distutils.version import LooseVersion from distutils.version import LooseVersion

View file

@ -48,6 +48,10 @@
# agrees to be bound by the terms and conditions of this License # agrees to be bound by the terms and conditions of this License
# Agreement. # Agreement.
from __future__ import absolute_import, division, print_function
__metaclass__ = type
import os import os

View file

@ -28,6 +28,7 @@ options:
- The C(query) state gets the current ACL without changing it, for use in C(register) operations. - The C(query) state gets the current ACL without changing it, for use in C(register) operations.
choices: [ absent, present, query ] choices: [ absent, present, query ]
default: query default: query
type: str
follow: follow:
description: description:
- Whether to follow symlinks on the path if a symlink is encountered. - Whether to follow symlinks on the path if a symlink is encountered.
@ -42,13 +43,16 @@ options:
entity: entity:
description: description:
- The actual user or group that the ACL applies to when matching entity types user or group are selected. - The actual user or group that the ACL applies to when matching entity types user or group are selected.
type: str
etype: etype:
description: description:
- The entity type of the ACL to apply, see C(setfacl) documentation for more info. - The entity type of the ACL to apply, see C(setfacl) documentation for more info.
choices: [ group, mask, other, user ] choices: [ group, mask, other, user ]
type: str
permissions: permissions:
description: description:
- The permissions to apply/remove can be any combination of C(r), C(w) and C(x) (read, write and execute respectively) - 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: entry:
description: description:
- DEPRECATED. - DEPRECATED.
@ -57,6 +61,7 @@ options:
- The qualifier may be empty for some types, but the type and perms are always required. - 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. - C(-) can be used as placeholder when you do not care about permissions.
- This is now superseded by entity, type and permissions fields. - This is now superseded by entity, type and permissions fields.
type: str
recursive: recursive:
description: description:
- Recursively sets the specified ACL. - Recursively sets the specified ACL.
@ -75,6 +80,7 @@ options:
- Incompatible with C(state=query). - Incompatible with C(state=query).
choices: [ default, mask, no_mask ] choices: [ default, mask, no_mask ]
default: default default: default
type: str
author: author:
- Brian Coca (@bcoca) - Brian Coca (@bcoca)
- Jérémie Astori (@astorije) - Jérémie Astori (@astorije)

View file

@ -8,7 +8,7 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r'''
--- ---
module: at module: at
short_description: Schedule the execution of a command or script file via the at command short_description: Schedule the execution of a command or script file via the at command
@ -29,12 +29,10 @@ options:
description: description:
- The count of units in the future to execute the command or script file. - The count of units in the future to execute the command or script file.
type: int type: int
required: true
units: units:
description: description:
- The type of units in the future to execute the command or script file. - The type of units in the future to execute the command or script file.
type: str type: str
required: true
choices: [ minutes, hours, days, weeks ] choices: [ minutes, hours, days, weeks ]
state: state:
description: description:

View file

@ -50,6 +50,7 @@ options:
key_options: key_options:
description: description:
- A string of ssh key options to be prepended to the key in the authorized_keys file. - A string of ssh key options to be prepended to the key in the authorized_keys file.
type: str
exclusive: exclusive:
description: description:
- Whether to remove all other non-specified keys from the authorized_keys file. - Whether to remove all other non-specified keys from the authorized_keys file.

View file

@ -7,7 +7,7 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r'''
--- ---
module: seboolean module: seboolean
short_description: Toggles SELinux booleans short_description: Toggles SELinux booleans
@ -19,6 +19,7 @@ options:
description: description:
- Name of the boolean to configure. - Name of the boolean to configure.
required: true required: true
type: str
persistent: persistent:
description: description:
- Set to C(yes) if the boolean setting should survive a reboot. - Set to C(yes) if the boolean setting should survive a reboot.

View file

@ -20,17 +20,20 @@ version_added: "1.0.0"
options: options:
policy: policy:
description: 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: state:
description: description:
- The SELinux mode. - The SELinux mode.
required: true required: true
choices: [ disabled, enforcing, permissive ] choices: [ disabled, enforcing, permissive ]
type: str
configfile: configfile:
description: description:
- The path to the SELinux configuration file, if non-standard. - The path to the SELinux configuration file, if non-standard.
default: /etc/selinux/config default: /etc/selinux/config
aliases: [ conf, file ] aliases: [ conf, file ]
type: str
requirements: [ libselinux-python ] requirements: [ libselinux-python ]
author: author:
- Derek Carter (@goozbach) <goozbach@friocorte.com> - Derek Carter (@goozbach) <goozbach@friocorte.com>
@ -178,7 +181,7 @@ def main():
module = AnsibleModule( module = AnsibleModule(
argument_spec=dict( argument_spec=dict(
policy=dict(type='str'), 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']), configfile=dict(type='str', default='/etc/selinux/config', aliases=['conf', 'file']),
), ),
supports_check_mode=True, supports_check_mode=True,

View file

@ -147,6 +147,7 @@ options:
- Note that an empty string in C(rsync_opts) will end up transfer the current working directory. - Note that an empty string in C(rsync_opts) will end up transfer the current working directory.
type: list type: list
default: default:
elements: str
partial: partial:
description: description:
- Tells rsync to keep the partial file which should make a subsequent transfer of the rest of the file much faster. - 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. - Add a destination to hard link against during the rsync.
type: list type: list
default: default:
elements: str
notes: notes:
- rsync must be installed on both the local and remote host. - 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 - 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'), group=dict(type='bool'),
set_remote_user=dict(type='bool', default=True), set_remote_user=dict(type='bool', default=True),
rsync_timeout=dict(type='int', default=0), 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'), ssh_args=dict(type='str'),
partial=dict(type='bool', default=False), partial=dict(type='bool', default=False),
verify_host=dict(type='bool', default=False), verify_host=dict(type='bool', default=False),
mode=dict(type='str', default='push', choices=['pull', 'push']), 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, supports_check_mode=True,
) )

View file

@ -9,7 +9,7 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r'''
--- ---
module: sysctl module: sysctl
short_description: Manage entries in sysctl.conf. short_description: Manage entries in sysctl.conf.
@ -19,18 +19,21 @@ version_added: "1.0.0"
options: options:
name: name:
description: 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 required: true
aliases: [ 'key' ] aliases: [ 'key' ]
type: str
value: value:
description: description:
- Desired value of the sysctl key. - Desired value of the sysctl key.
aliases: [ 'val' ] aliases: [ 'val' ]
type: str
state: state:
description: description:
- Whether the entry should be present or absent in the sysctl file. - Whether the entry should be present or absent in the sysctl file.
choices: [ "present", "absent" ] choices: [ "present", "absent" ]
default: present default: present
type: str
ignoreerrors: ignoreerrors:
description: description:
- Use this option to ignore errors about unknown keys. - Use this option to ignore errors about unknown keys.
@ -47,12 +50,14 @@ options:
description: description:
- Specifies the absolute path to C(sysctl.conf), if not C(/etc/sysctl.conf). - Specifies the absolute path to C(sysctl.conf), if not C(/etc/sysctl.conf).
default: /etc/sysctl.conf default: /etc/sysctl.conf
type: path
sysctl_set: sysctl_set:
description: description:
- Verify token value with the sysctl command and set with -w if necessary - Verify token value with the sysctl command and set with -w if necessary
type: bool type: bool
default: 'no' default: 'no'
author: "David CHANIAL (@davixx) <david.chanial@gmail.com>" author:
- David CHANIAL (@davixx)
''' '''
EXAMPLES = r''' EXAMPLES = r'''

View file

@ -48,9 +48,17 @@
var: _disable_test1 var: _disable_test1
verbosity: 1 verbosity: 1
- name: Before gathering the fact
debug:
msg: "{{ ansible_selinux }}"
- name: TEST 1 | Re-gather facts - name: TEST 1 | Re-gather facts
setup: 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 - name: TEST 1 | Assert that status was changed, reboot_required is True, a warning was displayed, and SELinux is configured properly
assert: assert:
that: that:
@ -74,7 +82,7 @@
var: _disable_test2 var: _disable_test2
verbosity: 1 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: assert:
that: that:
- _disable_test2 is not changed - _disable_test2 is not changed
@ -147,7 +155,7 @@
var: _state_test2 var: _state_test2
verbosity: 1 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: assert:
that: that:
- _state_test2 is not changed - _state_test2 is not changed
@ -380,7 +388,7 @@
var: _lineinfile_out1 var: _lineinfile_out1
verbosity: 1 verbosity: 1
- name: TEST 5 | Set SELinux to enforcing - name: TEST 5 | Set SELinux to enforcing
selinux: selinux:
state: enforcing state: enforcing
policy: targeted policy: targeted

View file

@ -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 pylint:blacklisted-name
plugins/modules/synchronize.py use-argspec-type-path 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:doc-default-does-not-match-spec
plugins/modules/synchronize.py validate-modules:nonexistent-parameter-documented 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:parameter-type-not-in-doc
plugins/modules/synchronize.py validate-modules:undocumented-parameter 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/check_matrix.py replace-urlopen
tests/utils/shippable/timing.py shebang tests/utils/shippable/timing.py shebang

View file

@ -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 pylint:blacklisted-name
plugins/modules/synchronize.py use-argspec-type-path 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:doc-default-does-not-match-spec
plugins/modules/synchronize.py validate-modules:nonexistent-parameter-documented 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:parameter-type-not-in-doc
plugins/modules/synchronize.py validate-modules:undocumented-parameter 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/check_matrix.py replace-urlopen
tests/utils/shippable/timing.py shebang tests/utils/shippable/timing.py shebang

View file

@ -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 pylint:blacklisted-name
plugins/modules/synchronize.py use-argspec-type-path 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:doc-default-does-not-match-spec
plugins/modules/synchronize.py validate-modules:nonexistent-parameter-documented 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:parameter-type-not-in-doc
plugins/modules/synchronize.py validate-modules:undocumented-parameter 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/check_matrix.py replace-urlopen
tests/utils/shippable/timing.py shebang tests/utils/shippable/timing.py shebang

View file

@ -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_collections.ansible.posix.tests.unit.compat.mock import MagicMock
from ansible.utils.path import unfrackpath from ansible.utils.path import unfrackpath

View file

@ -1,3 +1,7 @@
from __future__ import absolute_import, division, print_function
__metaclass__ = type
import io import io
import yaml import yaml

View file

@ -1,6 +1,10 @@
# Copyright (c) 2017 Ansible Project # Copyright (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # 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 json
import pytest import pytest

View file

@ -1,3 +1,7 @@
from __future__ import absolute_import, division, print_function
__metaclass__ = type
import os import os
import tempfile import tempfile

View file

@ -1,3 +1,7 @@
from __future__ import absolute_import, division, print_function
__metaclass__ = type
import json import json
from ansible_collections.ansible.posix.tests.unit.compat import unittest from ansible_collections.ansible.posix.tests.unit.compat import unittest

View file

@ -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) (Epdb) pprint(DeepDiff(self.final_task_vars, out_task_vars), indent=2)
{ 'dic_item_added': set([u"root['ansible_python_interpreter']"]), { 'dic_item_added': set([u"root['ansible_python_interpreter']"]),