Commit Graph

838 Commits (cd9471ef17c985006c7d77687030890003cf395d)

Author SHA1 Message Date
Dag Wieers cd9471ef17 Introduce new 'required_by' argument_spec option (#28662)
* Introduce new "required_by' argument_spec option

This PR introduces a new **required_by** argument_spec option which allows you to say *"if parameter A is set, parameter B and C are required as well"*.

- The difference with **required_if** is that it can only add dependencies if a parameter is set to a specific value, not when it is just defined.
- The difference with **required_together** is that it has a commutative property, so: *"Parameter A and B are required together, if one of them has been defined"*.

As an example, we need this for the complex options that the xml module provides. One of the issues we often see is that users are not using the correct combination of options, and then are surprised that the module does not perform the requested action(s).

This would be solved by adding the correct dependencies, and mutual exclusives. For us this is important to get this shipped together with the new xml module in Ansible v2.4. (This is related to bugfix https://github.com/ansible/ansible/pull/28657)

```python
    module = AnsibleModule(
        argument_spec=dict(
            path=dict(type='path', aliases=['dest', 'file']),
            xmlstring=dict(type='str'),
            xpath=dict(type='str'),
            namespaces=dict(type='dict', default={}),
            state=dict(type='str', default='present', choices=['absent',
'present'], aliases=['ensure']),
            value=dict(type='raw'),
            attribute=dict(type='raw'),
            add_children=dict(type='list'),
            set_children=dict(type='list'),
            count=dict(type='bool', default=False),
            print_match=dict(type='bool', default=False),
            pretty_print=dict(type='bool', default=False),
            content=dict(type='str', choices=['attribute', 'text']),
            input_type=dict(type='str', default='yaml', choices=['xml',
'yaml']),
            backup=dict(type='bool', default=False),
        ),
        supports_check_mode=True,
        required_by=dict(
            add_children=['xpath'],
            attribute=['value', 'xpath'],
            content=['xpath'],
            set_children=['xpath'],
            value=['xpath'],
        ),
        required_if=[
            ['count', True, ['xpath']],
            ['print_match', True, ['xpath']],
        ],
        required_one_of=[
            ['path', 'xmlstring'],
            ['add_children', 'content', 'count', 'pretty_print', 'print_match', 'set_children', 'value'],
        ],
        mutually_exclusive=[
            ['add_children', 'content', 'count', 'print_match','set_children', 'value'],
            ['path', 'xmlstring'],
        ],
    )
```

* Rebase and fix conflict

* Add modules that use required_by functionality

* Update required_by schema

* Fix rebase issue
5 years ago
Matt Clay 1f3a74c0c8
Improve import sanity test output handling. (#52136)
Handling of unexpected output for the following is improved:

- stdout
- stderr
- warnings
5 years ago
Matt Clay 6cba471958 Remove unnecessary validate-modules ignore entry. 5 years ago
Mariusz Mazur 34671a64b3 k8s_auth: new k8s module for handling auth (#50807)
* k8s*: add a reference to k8s_auth in all the modules' descriptions

* k8s_auth: new k8s module for handling auth

* k8s_auth: ignore E203

Can't use module_utils.urls, since that lacks user CA support, which is
a critical feature of what this module does.
5 years ago
Guillaume Martinez 959939b866 Refactor gitlab modules (#51141)
* gitlab_group: refactor module

* gitlab_user: refactor module

* gitlab_group, gitlab_user; pylint

* gitlab_project: refactor module

* gitlab_group, gitlab_project, gitlab_user: Enchance modules

- Add generic loop to update object
- Enchance return messages
- PyLint

* gitlab_runner: refactor module

* gitlab_hooks: refactor module

* gitlab_deploy_key: refactor module

* gitlab_group: enchance module and documentation

- Enchange function arguments
- Add check_mode break
- Rewrite module documentation

* gitlab_hook: enchance module and documentation

- Rewrite documentation
- Enchance function parameters
- Rename functions

* gitlab_project: enchance module and documentation

- Rewrite documentation
- Enchance function parameters
- Add try/except on project creation

* gitlab_runner: enchance module and documentation

- Rewrite documentation
- Fix Copyright
- Enchance function arguments
- Add check_mode break
- Add missing function: deletion

* gitlab_user: enchance module and documentation

- Rewrite documentation
- Enchance function parameters
- Add check_mode break
- Add try/except on user creation

* gitlab_deploy_key, gitlab_group, gitlab_hooks, gitlab_project,
gitlab_runner, gitlab_user: Fix residual bugs

- Fix Copyright
- Fix result messages
- Add missing check_mode break

* gitlab_deploy_key, gitlab_group, gitlab_hooks, gitlab_project, gitlab_runner, gitlab_user: pylint

* gitlab_runner: Add substitution function for 'cmp' in python3

* unit-test: remove deprecated gitlab module tests

- gitlab_deploy_key
- gitlab_hooks
- gitlab_project

Actually, they can't be reused because of the modification of the way that the module communicate with the Gitlab instance. It doesn't make direct call to the API, now it use a python library that do the job. So using a pytest mocker to test the module won't work.

* gitlab_deploy_key, gitlab_group, gitlab_hooks, gitlab_project, gitlab_runner, gitlab_user: add copyright

* gitlab_deploy_key, gitlab_group, gitlab_hooks, gitlab_project, gitlab_runner, gitlab_user: Support old parameters format

* module_utils Gitlab: Edit copyright

* gitlab_deploy_key, gitlab_group, gitlab_hooks, gitlab_project,
gitlab_runner, gitlab_user: Unifying module inputs

- Rename verify_ssl into validate_certs to match standards
- Remove unused alias parameters
- Unify parameters type and requirement
- Reorder list order

* gitlab_deploy_key, gitlab_group, gitlab_hooks, gitlab_project, gitlab_runner, gitlab_user: Unifying module outputs

- Use standard output parameter "msg" instead of "return"
- Use snail_case for return values instead of camelCase

* validate-module: remove sanity ignore

* BOTMETA: remove gitlab_* test

- This tests need to be completely rewriten because of the refactoring
of these modules
- TodoList Community Wiki was updated

* gitlab_user: Fix group identifier

* gitlab_project: Fix when group was empty

* gitlab_deploy_key: edit return msg

* module_utils gitlab: fall back to user namespace is project not found

* gitlab modules: Add units tests

* unit test: gitlab module fake current user

* gitlab_user: fix access_level verification

* gitlab unit tests: use decoration instead of with statement

* unit tests: gitlab module skip python 2.6

* unit tests: gitlab module skip library import if python 2.6

* gitlab unit tests: use builtin unittest class

* gitlab unit tests: use custom test class

* unit test: gitlab module lint

* unit tests: move gitlab utils

* unit test: gitlab fix imports

* gitlab_module: edit requirement

python-gitlab library require python >= 2.7

* gitlab_module: add myself as author

* gitlab_modules: add python encoding tag

* gitlab_modules: keep consistency between variable name "validate_certs"

* gitlab_modules: enchance documentation

* gitlab_runner: fix syntax error in documentation

* gitlab_module: use basic_auth module_utils and add deprecation warning

* gitlab_module: documentation corrections

* gitlab_module: python lint

* gitlab_module: deprecate options and aliases for ansible 2.10

* gitlab_group: don't use 'local_action' is documentation example

* gitlab_module: correct return messages

* gitlab_module: use module_util 'missing_required_lib' when python library is missing

* gitlab_module: fix typo in function name.

* gitlab_modules: unify return msg on check_mode

* gitlab_modules: don't use deprecated options in examples
5 years ago
Matt Martz dfee94dfc7
Validate modules prevent version change (#51549)
* Add logic to catch version changes in docs

* Add in doc fragments before doing doc comparisons

* Handle new module scenario

* historical is only allowed in alreay present modules

* Don't repr StrictVersion
5 years ago
Toshio Kuratomi 0ec4e0a842 Disable the update-bundled test during normal operation
This is enabled once per release cycle in a PR so that the release
manager can open bugs for the Ansible team to update the bundled code.
5 years ago
Toshio Kuratomi dfd8b659c0 Have update-bundled check for updates to all bundled code
Add a test for whether we have bundled code inside of ansible that needs to be updated
5 years ago
Matt Davis 6654c7aeea
fix string_format sanity check (#51780)
* newer version of Pylint moved the impl; use conditional import to find for new/old
5 years ago
Matt Clay 06d83bae05 Support `ignore_changes` in code-smell tests. 5 years ago
Dennis Lerch e3006e8443 add diff_mode_enabled to documentation
option 'diff_mode_enabled' is not mentioned in documentation

+label: docsite_pr
5 years ago
Jordan Borean f27078df52
win_power_plan: fix for Windows 10 and Server 2008 compatibility (#51471) 6 years ago
Jordan Borean 6a2aac487d
win_stat - add follow option and fix broken tests (#51522)
* win_stat - add follow option and fix broken tests

* fix docs issues
6 years ago
Sebastian 48107ac212 junos_config documentation missing "update" choice (#51299)
* Update junos_config.py

The current junos_config module documentation only lists "merge","override" and "replace" as update parameter choices. Looking into junos_python.py "update" is another option which is really helpful and in my opinion the most needed option.

'''
update=dict(default='merge', choices=['merge', 'override', 'replace', 'update'])
'''

+label: docsite_pr

* Fixup Update junos_config.py

The current junos_config module documentation only lists "merge","override" and "replace" as update parameter choices. Looking into junos_python.py "update" is another option which is really helpful and in my opinion the most needed option.

'''
update=dict(default='merge', choices=['merge', 'override', 'replace', 'update'])
'''

Co-Authored-By: crab86 <sgesenhoff@gmail.com>
6 years ago
Daniel Speichert 1a105a99dc hpilo_boot: fix module doc to match code and logic (#51360)
* hpilo_boot: fix module doc to match code and logic

There is no explicit nor implied value for media.
In fact, not choosing media makes perfect sense.

* Remove ignored sanity test failure
6 years ago
Brian Coca 96b3ef5553
Doc fragments to plugins (#50172)
* promote doc_fragments into actual plugins

  change tests hardcoded path to doc fragments
  avoid sanity in fragments
  avoid improper testing of doc_fragments
  also change runner paths
 fix botmeta
 updated comment for fragments
 updated docs
6 years ago
Felix Fontein d2c4f57f16 docker_service: rename to docker_compose. (#51035)
* Rename docker_service -> docker_compose.

* Added changelog.

* Update scenario guide.

* Clean up module.
6 years ago
Jonathan 20936bbc3d module mongodb_user fix roles default value (#46443) (#46526)
* module mongodb_user fix roles default value (#46443)

* mongodb_user remove ignoring test E324

* mongodb_user add changelog (#464443)

* mongodb_user change doc to set parameter roles as None (#464443)

* mongodb_user fix lint in changelog fragment (#464443)

* mongodb_user : remove E325 exception in test
6 years ago
ABond d55479d063 DigitalOcean module deprecation (#47272) 6 years ago
Dag Wieers 30227ace98
Fix parameter types and other fixes (#50111)
* Fix parameter types and other fixes

* Fix issues after review

* Fix Windows-references in system/files modules

This PR includes:
- Replacing version/v with just Ansible X.Y
- Removing Windows-alternatives from notes

* Update lib/ansible/modules/system/parted.py

Co-Authored-By: dagwieers <dag@wieers.com>

* Update lib/ansible/modules/system/service.py

Co-Authored-By: dagwieers <dag@wieers.com>

* Update lib/ansible/modules/system/service.py

Co-Authored-By: dagwieers <dag@wieers.com>

* Revert type change, move to separate PR

* Update lib/ansible/modules/files/replace.py

Co-Authored-By: dagwieers <dag@wieers.com>

* Update lib/ansible/modules/files/replace.py

Co-Authored-By: dagwieers <dag@wieers.com>

* Update lib/ansible/modules/files/replace.py

Co-Authored-By: dagwieers <dag@wieers.com>

* Update lib/ansible/modules/files/replace.py

Co-Authored-By: dagwieers <dag@wieers.com>

* Update lib/ansible/modules/files/replace.py

Co-Authored-By: dagwieers <dag@wieers.com>

* Update lib/ansible/modules/files/replace.py

Co-Authored-By: dagwieers <dag@wieers.com>
6 years ago
Matt Clay 634533208e Fix integration test shebangs and update tests.
* Integration tests now have their own list of allowed shebangs.
* Use `#!/usr/bin/env bash` instead of `#!/bin/bash`
  since the location is different on various platforms.
6 years ago
Matt Clay 332dc6a93a Fix false positives in no-get-exception test. 6 years ago
Brian Coca 91d8383898 added missing docs for option in acl module (#50775)
* added missing docs for option in acl module
* remove acl from ignore
6 years ago
Matt Clay 7995f69a44 Improve performance of no-tests-as-filters test. 6 years ago
Matt Martz 6918b4e8f4
Add tests for WANT_JSON and old style modules (#50555)
* Add tests for WANT_JSON and old style modules

* quote source path

* Attempt to further appease tests

* Check for file and not just exists

* omg don't be dumb

* moar fixes

* shellcheck is the worst :)

* Test the custom modules for failure without arg files
6 years ago
Matt Martz 9a520b26e3
Make sure to clean up even if an exception occurs (#50620) 6 years ago
Ganesh Nalawade 71113ee291
Fix backup issue in network config modules and network action plugins common code refactor (#50301)
* Fix backup issue in network config modules

*  Fix `get_working_path` not found issue introduced due to
   backup config code refactor (PR #50208)

*  Further refactor config related action plugins to minimize
   duplicate code

*  Remove unwated imports in config action plugins

* Add common network class for action plugin and related code refactor

* Fix review comment
6 years ago
Jordan Borean 7bce6818eb
Added supershipit to botmeta sanity test (#50219) 6 years ago
Matt Clay 4bd60c313b Add retries for Invoke-ScriptAnalyzer in pslint.
Hopefully this will work around the intermittent CI failures due
to NullReferenceException, which then succeed on a retry.
6 years ago
Anil Kumar Muraleedharan eab3b02cb3 Refactoring of cnos_interface module like what followed by other vendors (#49927)
* Refactoring of cnos_interface module like what followed by other vendors

* To remove cnos-interface from E326 validation ignore list

* Effect of default parameters impacted UT
6 years ago
Matt Clay 97de7c133e Fix no metadata traceback in validate-modules. 6 years ago
Dag Wieers 05c6ff79f9 Convert to reduced list of known types (#50010) 6 years ago
Dag Wieers 7fb1a71a2c
no-smart-quotes: Skip files by path in code-smell (#45881)
* no-smart-quotes: Skip files by path in code-smell

This is to ensure the generated docs do not trigger code-smell issues on
contributor systems.

* Implement feedback from review
6 years ago
Matt Martz 6025990fe9
Remove the use of mock from validate-modules (#50098)
* Remove the use of mock from validate-modules

* Monkeypatch AnsibleModule.__init__ not AnsibleModule
6 years ago
Dag Wieers 15d39f9108 Sanity fixes in various modules (#50080) 6 years ago
Adrian Likins be65d9cfe5 Skip sanity tests that don't apply to bundled code
* add distro to pep8 skip tests
* Skip no-assert test for distro
* Add bundled distro to the empty-init skip list
6 years ago
Toshio Kuratomi e09196f760 Fix validate-modules to not complain about sys.exit in comments 6 years ago
Toshio Kuratomi 175f3b51e5 Ensure that current uses of BaseException are required
* In some cases, it appears that Exception should have been used instead
  as there's no need to catch sys.exit KeyboardInterrupt and similar.
* In a few cases, it appears that BaseException is used because
  a library we depend on calls sys.exit() contrary to good coding
  design.  Comment those so that we know that those have been audited
  and found to be correct and change to use (Exception, SystemExit)
  instead.
6 years ago
Toshio Kuratomi 5147e792d3 Enable the bare-except pylint and pep8 checking 6 years ago
Jordan Borean 190d1ed7f1 win become: refactor and add support for passwordless become (#48082)
* win become: refactor and add support for passwordless become

* make tests more stable

* fix up dep message for Load-CommandUtils

* Add further check for System impersonation token

* re-add support for become with accounts that have no password

* doc fixes and slight code improvements

* fix doc sanity issue
6 years ago
Dag Wieers baf0ad2309 Docs: Add a "seealso" section to the module docs (#45949)
* Docs: Add a separate  "seealso" section to the module docs
to list related modules and/or related references. This clears up the notes
section for things that are actual notes.

So you can add a section in your module documentation and four types of
references are possible.

    seealso:

    # Reference by module name
    - module: aci_tenant

    # Reference by module name, including description
    - module: aci_tenant
      description: ACI module to create tenants on a Cisco ACI fabric.

    # Reference by rST documentation anchor
    - ref: aci_guide
      description: Detailed information on how to manage your ACI infrastructure using Ansible.

    # Reference by Internet resource
    - name: APIC Management Information Model reference
      description: Complete reference of the APIC object model.
      link: https://developer.cisco.com/docs/apic-mim-ref/

This PR also includes:

- Implements ansible-doc support
- Implements schema support for the seealso options
- Updates to the development documentation
- Rename filter convert_symbols_to_format to rst_ify, cfr the existing html_ify and tty_ify filters
  - This makes the existing template a lot easier to read and fixes the confusion I had myself rereading the template (again).
- We fixed the possible suboption types (which was limited to 'bool' only)

* Use latest stable instead of devel docs
6 years ago
Rhys Campbell cdc0011333 mongodb_shard module and test exception (#43673)
* mongodb_shard module and test exception

* Update version_added

* Documentation improvements

* Correct yaml errors

* Correct lines over 160 chars

* Correct replicaset

* Minor documentation changes
6 years ago
Abhijeet Kasurde 1763c8123b
AWS: Add support for available db types (#48703)
Add several database types which are supported by AWS in valid engine type.

Fixes: #48623

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
6 years ago
Anil Kumar Muraleedharan 7a81d859c5 Refactoring cnos_vlan in line with ios, eos etc. (#48924)
* Refactoring cnos_vlan in line with ios, eos etc.
6 years ago
Abhijeet Kasurde bc3e7bbeba
E325 Removal - Part II (#49196)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
6 years ago
Abhijeet Kasurde 9b732df436
E325 removal - Part I (#49136)
Remove E325 from Amazon modules

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
6 years ago
Matt Martz 46b465283c
Fix metadata comparison (#49133) 6 years ago
Matt Martz 7287d396e2 Prevent metadata changes in a stable branch (#48994) 6 years ago
Jordan Borean 8e92cca139
win_credential: new module to manage credentials (#48840)
* win_credential_manager: new module to manage credentials

* fix sanity issues and removed CredSSP references

* renamed module to win_credential

* fix typo on test variable

* fix sanity ignore line
6 years ago
John R Barker 75407d3e43
Validate DOCUMENTATION.author (#48993)
* Validate DOCUMENTATION.author

Ensure that author line includes a GitHub account
6 years ago