mirror of
https://github.com/ansible-collections/ansible.posix.git
synced 2026-01-11 07:05:27 +01:00
Fix sanity test for modules
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
20f70caa1f
commit
ea8fc70373
20 changed files with 73 additions and 86 deletions
2
changelogs/fragments/misc_fix.yml
Normal file
2
changelogs/fragments/misc_fix.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
minor_changes:
|
||||
- fix sanity test for various modules.
|
||||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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) <goozbach@friocorte.com>
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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) <david.chanial@gmail.com>"
|
||||
author:
|
||||
- David CHANIAL (@davixx)
|
||||
'''
|
||||
|
||||
EXAMPLES = r'''
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
import io
|
||||
import yaml
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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']"]),
|
||||
|
|
|
|||
Loading…
Reference in a new issue