Commit Graph

840 Commits (36311633299fe9af67214ff8027f21e63c84467a)

Author SHA1 Message Date
Pilou 556a1daa33 fix searched paths in DataLoader.path_dwim_relative (avoid AnsibleFileNotFound) (#26729)
* add unit test: nested dynamic includes

* nested dynamic includes: avoid AnsibleFileNotFound error

Error was:
Unable to retrieve file contents
Could not find or access 'include2.yml'

Before 8f758204cf, at the end of
'path_dwim_relative' method, the 'search' variable contained amongst
others paths:
'/tmp/roles/testrole/tasks/tasks/included.yml' and
'/tmp/roles/testrole/tasks/included.yml'.
The commit mentioned before removed the last one despite the method
docstrings specify 'with or without explicitly named dirname subdirs'.

* add integration test: nested includes
7 years ago
Nathaniel Case 56a0b988a9 nxos integration fix part 1 (#27069)
* Assorted Python 3 fixes

* Fix `testcase` definition in integration tests

* Fix nxos_acl_interface

* clean up nxapi after nxos_nxapi
7 years ago
James Mighion b8337ee9d3 New module aireos_command (#26769)
* Adding ciscowlc_command module and unit tests.

* Adding __init__.py for unit test.

* Fixing PEP8 W503.

* Renaming module from ciscowlc_command to aire_command.

* Renaming aire_command to aireos_command.
7 years ago
Frederic Lepied 65d093d9a7 Skip f5 tests if f5-sdk is not installed (#27035)
Fixes: bug #27034

Introduced by 278fa552f8
7 years ago
Tim Rupp 09e9b4b4ba Adds refactored bigip_monitor_tcp (#26842)
This module needed to be refactored to use the REST API and
coding conventions for newer modules. This patch adds those changes.
This patch also deprecates params in favor of separate modules. These
deprecated params will be removed in 2.5.

Unit tests are provided. Integration tests can be found here

https://github.com/F5Networks/f5-ansible/blob/devel/test/integration/bigip_monitor_tcp.yaml#L23
https://github.com/F5Networks/f5-ansible/tree/devel/test/integration/targets/bigip_monitor_tcp/tasks
7 years ago
Dag Wieers 2b4a8095e9 Simplify XML error-handling and typo (#26929)
This PR fixes:
- A typo in the aci_login function
- Improve (XML) error-handling
- Rename status_code back to status
7 years ago
James Mighion f682d9bf49 Adding aruba_command module along with unit tests. (#26625)
* Adding aruba_command module along with unit tests.

* Fixing PEP8 E303 too many blank lines.

* Adding default for timeout.

* Removing unused arguments. Moving default for timeout argument. Fixing cliconf to find hostname.

* Fixing PEP8 E302.
7 years ago
Tim Rupp a236d249ae Adds the bigip_configsync_actions module (#26506)
This module is required as part of HA configuration of a set of
BIG-IPs. It is used to initiate and way for configuration syncing
to happen.

Unit tests are provided. Integration tests can be found here

https://github.com/F5Networks/f5-ansible/blob/devel/test/integration/bigip_configsync_actions.yaml#L23
https://github.com/F5Networks/f5-ansible/tree/devel/test/integration/targets/bigip_configsync_actions/tasks
7 years ago
Tim Rupp 75e609c15e adds the bigip_ucs module (#26663)
This module allows you to load existing UCS files onto a BIG-IP
system

Unit tests are provided. Integration tests can be found here

https://github.com/F5Networks/f5-ansible/blob/devel/test/integration/bigip_ucs.yaml#L23
https://github.com/F5Networks/f5-ansible/tree/devel/test/integration/targets/bigip_ucs/tasks
7 years ago
Tim Rupp 72f41148a0 Adds tcp_echo module for bigip (#26844)
This patch is part a refactor of TCP monitors for BIG-IP. This module
may file in testing without the base tcp module merged because it makes
use of similar fixtures.

Unit tests are provided. Integration tests can be found here

https://github.com/F5Networks/f5-ansible/blob/devel/test/integration/bigip_monitor_tcp_echo.yaml#L23
https://github.com/F5Networks/f5-ansible/tree/devel/test/integration/targets/bigip_monitor_tcp_echo/tasks
7 years ago
Tim Rupp 278fa552f8 Adds half-open tcp monitor module (#26920)
This is necessary as a part of refactoring the tcp monitor module.

Unit tests are provided. Integration tests can be found here

https://github.com/F5Networks/f5-ansible/blob/devel/test/integration/bigip_monitor_tcp_half_open.yaml#L23
https://github.com/F5Networks/f5-ansible/tree/devel/test/integration/targets/bigip_monitor_tcp_half_open/tasks
7 years ago
Abhijeet Kasurde f7c8e7bdab Update vmware_inventory (#26308)
Fix adds
* Exception handling
* Unit tests

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
7 years ago
Guillaume Coré 42ca1ef040 Add unit tests for parted module (#24164)
* Add unit tests for parted module

Test the current expected behavior of the module:
- mock parted() and get_device_info()
- Use some of the examples and test the 'script' passed to parted.
- mock check_parted_label() to return false, as if parted version is > 3.1
- assert get_device_info output is correct

Current implementation of the module runs parted several time while going
through all parameters (flags, name, ...). Between calls it uses get_device_info
to update the dictionary. Use check_mode for some of the tests to force module
to go through all the parameters even is dictionary is not updated.

* test_parted.py: add "name" param into expected results

since 78fff751ab, parse_partition_info
fetch the partition name. This commit adds 'name' key and value into
the expected results.
7 years ago
Ivo van Kreveld e976f299f8 Divided test methods of TestExtendValue class (#22574)
Divided the two test methods of the TestExtendValue class into multiple test methods so there is a test method for each compare.
7 years ago
Toshio Kuratomi ff22528b07 Consolidate boolean/mk_boolean conversion functions into a single location
Consolidate the module_utils, constants, and config functions that
convert values into booleans into a single function in module_utils.

Port code to use the module_utils.validate.convert_bool.boolean function
isntead of mk_boolean.
7 years ago
Dag Wieers e970237a2f New module: access Cisco ACI (network/aci/aci_rest) (#26029)
* aci_rest: New module to access Cisco ACI

This PR includes:
- Relicense as GPLv3+
- Check-mode support
- Cosmetic changes to documentation
- Examples in YAML format
- Removal of incorrect requirements (for this module)
- Do not log passwords
- Implement native fetch_url instead of requests
- Use standard hostname, username and password parameters
- Add alias src for parameter config_file
- Add mutual exclusive content option for inline data (and show some inline examples)
- Add timeout parameter
- Add validate_certs parameter
- Handling ACI result output (identical for JSON as XML input)
- Parse/expose ACI error output to user

* Lower case method, add use_ssl, Use python dicts

This commit includes:
- Use lowercase method names
- Add `use_ssl` parameter (not the `protocol` parameter)
- Use a python dict for the request data (not a JSON string)
- Documentation improvements

* Ensure one of 'content' or 'src' is provided

* Fix issue with totalCount being a string in JSON

This fixes the problem with JSON output where totalCount is a string and
not an integer.

This fixes jedelman8/aci-ansible#7

* Improve code documentation

* Improve error handling and module response

* Small typo

* Improve documentation and examples

* Keep protocol parameter, but deprecate it

* Extrude aci functions from module_utils

* aci_rest: Add unit tests
7 years ago
Nathaniel Case 855544604a Fix nxos_bgp_neighbor_af advertise_map and advertise_map_non_exist (#26721) 7 years ago
Nathaniel Case 61249995a1 Update nxos_interface_ospf & add test (#26644)
* Update nxos_interface_ospf & add test
7 years ago
Peter Sprygada 3bbb32cac5 fixes error when trying to run show start over eapi (#26800) 7 years ago
Pilou 2a92120ffa INI inventory plugin: add documentation about variable types (#25798)
* INI inventory: check variable types
* INI inventory: add doc about variable types

Fixes #25784
7 years ago
Nathaniel Case 5cfdd5df0f nxos_pim_interface (#26367)
* Add unit tests to nxos_pim_interface

* Update tests to match module

* Update nxos_pim_interface

* Address pep8 issues
7 years ago
rahushen 74947168e3 Add nxos_command IT and generalize UT (#26617)
* Add nxos_command IT sanity

* generalize nxos_command UT for different NXOS platforms
7 years ago
Ken Celenza 31b6ac896d Kc update ip filter (#26566)
* add first, last and next usable

* add usable ip filters

* add size usable, range usable and wildcard

* add ip prefix and netmask filter

* add network formatting and check if ip in subnet

* clean up order, add comments

* fix pep8

* update format by index

* clean up and updates from jmcgill298
7 years ago
Ganesh Nalawade e14e37ee1e Fix junos unit test failures (#26676)
*  Use lxml api's in unit test to parse xml
*  Remove unwanted import in unit test
*  Add ncclient dependency in unit test requirement
7 years ago
Pilou 2d7e00c670 mock_unfrackpath_noop: handle follow parameter (#26662) 7 years ago
Peter Sprygada 0b6f0e6c0d adds more intelligent save logic and diff to network config modules (#26565)
* adds more intelligent save logic and diff to network config modules

* adds sha1 property to NetworkConfig
* adds new argument save_when to argument_spec
* adds new argument diff_against to argument_spec
* adds new argument intended_config to argument_spec
* renames config argument to running_config with alias to config
* deprecates the use of the save argument
* before and after now work with src argument
* misc module clean

Modules updated
* nxos_config
* ios_config
* eos_config

Most notably this makes the save mechanism more intelligent for config
modules for devices that need to copy the ephemeral config to
non-volatile storage.

The diff_against argument allows the playbook task to control what the
device's running-config is diff'ed against. By default it will return
the diff of the startup-config.

* removes ios_config from pep8/legacy_files.txt

* extends the ignore lines argument to the module

* clean up CI errors

* add missing list brackets

* fixes typo

* fixes unit test cases

* remove last line break when returning config contents

* encode config string to bytes before hashing

* fix typo

* addresses feedback in PR

* update unit test cases
7 years ago
mikedlr 07a4079a81 aws.core in new aws dir in module utils - module with AnsibleAWSModule class and fail_json_aws (#25780)
* aws module utils including AnsibleAWSModule
* fail_json_aws method on AnsibleAWSModule to do fail_json nicely with AWS exceptions
* aws module util - feedback - rename to aws/core.py & improve doc strings
7 years ago
Ricardo Carrillo Cruz b81209c187 Fix multiple EOS EAPI code and test issues (#26651) 7 years ago
Adrian Likins 0fc0b6f059 Mv AnsibleFactCollector back to module_utils (#26150)
It was in lib/ansible/modules/system/setup.py since it
was the only thing using it, but move it back to module_utils
and add a ansible_collector.get_ansible_collector() to build
a facts collector just like the one used by setup.py

mv test_setup.py -> test_ansible_collector.py
All the code it was testing is now in ansible_collector

rm code to create 'ansible_facts' subkey from namespace

Just leave it up to the caller to do, and just return a
flat dictionary from AnsibleFactCollector.collect()
7 years ago
Ganesh Nalawade be89ef3eb6 junos_linkagg implementation and junos modules refactor (#26587)
* junos_linkagg implementation and junos modules refactor

*  junos_linkagg implementation
*  junos_linkagg integration test
*  net_linkagg integration test for junos
*  decouple `load_config` and `commit` operations,
   to allow single commit (in case on confirm commit) and
   to perform batch commit (multiple `load_config` followed by single
   `commit`)
*  Other related refactor

* Fix CI issues

* Fix unit test failure
7 years ago
James Mighion 58ade65ea6 Adding admin option for iosxr_config (#26509)
* Adding admin option for iosxr_config. Adding unit test for new admin option for iosxr_config. Fixes #24308

* Removing space on empty line.
7 years ago
Ken Evensen f31d3ddeb7 Pamd Updates (#25817)
* Fix for #25522
Fix for #25855
Fix for #23963

* Minor fix

* Updates per bcoca.  Fix in regex for silvinux.
7 years ago
Trishna Guha 07498ebed3 fix nxos_overlay_global (#26422)
* fix nxos_overlay_global

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* swap check_mode with candidate

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
7 years ago
Trishna Guha b81882e2a8 vyos_static_route implementation module (#26426)
* vyos_static_route implementation module

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* Add vyos_static_route implementation module

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* unit test

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* modify vyos_static_route

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* integration test vyos_static and net_static_route

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* fix typo integration test

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* modify vyos_static_route

* modify integration test

* vyos_static_route doc build fix

* fix integration test data

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* update net_static_route cli test set

* minor fix
7 years ago
Tim Rupp 37ca55bf71 Adds missing fields for iapp service (#26507)
The iApp service module worked fine previously, but this patch
adds enhancements to it to include more fields that can be
specified when creating iapp services.
7 years ago
Trishna Guha c5fb4bbcc0 Fix nxos_switchport and unit test (#26131)
* fix nxos_switchport

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* nxos_switchport unit test

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* legacy file

* update unit test

* handle exception
7 years ago
Brian Coca 2a041d10d2 better backwards compat handling of status
restored 'rc' inspection but only when failed is not specified
removed redundant changed from basic.py as task_executor already adds
removed redundant filters, they are tests
added aliases to tests removed from filters
fixed test to new rc handling
7 years ago
saichint 5229370364 fix for nxos_acl_interface idempotency (#26156)
* fix for nxos_acl_interface idempotency

* shippable error fix

* fix issues with python3.x
7 years ago
Trishna Guha ad3fe08aae fix vyos_banner multiline string issue (#26383)
Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
7 years ago
Toshio Kuratomi 3ee997b720 metadata and doc generator optimization and fixes
* Fix ansible-doc traceback when a plugin doesn't parse correctly
* Change extract_metadata ivocation to take either an ast or source
  code.  When given source code, it can find file offsets for the start
  and end of dict.  When given the ast, it is quicker as it doesn't have
  to reparse the source.  Requires changing the call to the function to
  use a keyword arg.
* Fix reading of metadata to find the last occurrence of
  ANSIBLE_METADATA instead of the first.
* Add some more unittests to get closer to complete coverage
7 years ago
Trishna Guha 1b427aa419 Fix vyos banner idempotent (#26338)
* fix vyos_banner idempotent

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* fix vyos_banner unit test

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
7 years ago
Trishna Guha 93bbcd8a32 vyos_user fix idempotent (#26289)
Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
7 years ago
Toshio Kuratomi 34589cee6d Unittests for extracting metadata from plugins (#26218)
* Unittests for extracting metadata from plugins
* Port plugin_docs to use the generic extract_metadata function
* Make the helper functions seek_end_of{string,dict} private
7 years ago
Nathaniel Case 3102746ebe nxos_pim_rp_address fixes (#26119)
* nxos_pim_rp_address tests

* nxos_pim_rp_address changes

* Address issues with idempotence
7 years ago
Nathaniel Case ad6c4a544e nxos_pim updates (#26145)
* nxos_pim tests

* Cleanup nxos_pim
7 years ago
Nathaniel Case eea18e9875 nxos_vxlan_vtep_vni fixes (#25913)
* nxos_vxlan_vtep_vni first pass
* nxos_vxlan_vtep_vni tests
7 years ago
Tim Rupp e7402e3d5b Support full path templates (#26121)
This patch allows the iapp service module to support full path
templates instead of only relative templates
7 years ago
Tim Rupp 04ac15f241 Adds bigip_qkview module (#25980)
This module can be used to generate qkviews on a bigip and
save them to a location on the ansible controller.
This module is primarily used for diagnostics.

Unit tests are provided. Integration tests can be found here

https://github.com/F5Networks/f5-ansible/blob/devel/test/integration/bigip_qkview.yaml#L23
https://github.com/F5Networks/f5-ansible/tree/devel/test/integration/targets/bigip_qkview/tasks
7 years ago
Tim Rupp 16bd93a14e Refactors bigip ssl cert module (#25882)
Includes unit tests and a refactor of the module to make code
more easily supported. Also fixes an issue where the extension of
the cert name was not appended if not provided. This problem was
causing certs to not be editable in the UI. Also deprecates params.

Unit tests are provided. Integration tests can be found here

https://github.com/F5Networks/f5-ansible/blob/devel/test/integration/bigip_ssl_certificate.yaml#L23
https://github.com/F5Networks/f5-ansible/tree/devel/test/integration/targets/bigip_ssl_certificate/tasks
7 years ago
George Nikolopoulos 11836a0296 Add module netscaler_cs_action (#26147) 7 years ago
Trishna Guha 34eca3816d fix vyos_user configuration (#26166)
Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
7 years ago
Ganesh Nalawade 3bd8dbb53d Add support for netconf network discovery (#25435)
* Add support for netconf network discovery

* Fix unit test failure
7 years ago
Dag Wieers fceb71128e Return code is not very useful to assume a task failed
So I thought I fixed it before, but there's still one location where
the `rc` value is influential to decide whether a task failed or not.

We already established in #24867 that it is up to the module to decide
what the return code actually means, not the task executor. We modified
the existing modules to move that logic into the module (eg. for
command, shell, etc.)

This relates to the integration tests of win_robocopy, where different
return codes have different meanings:

  - 0  --  No files copied.
  - 1  --  Files copied successfully! (changed)
  - 2  --  Some Extra files or directories were detected. No files were copied. (warning)
  - 3  --  (2+1) Some files were copied. Additional files were present. (changed)
  - 4  --  Some mismatched files or directories were detected. Housekeeping might be required!  (changed + warning)
  - 5  --  (4+1) Some files were copied. Some files were mismatched.  (changed + warning)
  - 6  --  (4+2) Additional files and mismatched files exist.  No files were copied. (warning)
  - 7  --  (4+1+2) Files were copied, a file mismatch was present, and additional files were present. (changed + warning)
  - 8  --  Some files or directories could not be copied! (changed + failed)
  - 9 - 15  --  Fatal error. Check log message! (failed)
  - 16  --  Serious Error! No files were copied! Do you have permissions to access $src and $dest? (failed)

This also fixes #24652
7 years ago
George Nikolopoulos 6bed831f8c Add netscaler_server module (#25537) 7 years ago
Nathaniel Case 3d6d428bbc Test multiple nxos versions at once (#25595)
* Extend tests to have multiple device representations

* Move filepath munging to nxos_module

* Device needs to be kwarg so we can leave it off

* Update other nxos tests

* Update tests that fell through
7 years ago
Toshio Kuratomi e238ae999b Cyptography pr 20566 rebase (#25560)
Make pyca/cryptography the preferred backend for cryptographic needs (mainly vault) falling back to pycrypto

pyca/cryptography is already implicitly a dependency in many cases
through paramiko (2.0+) as well as the new openssl_publickey module,
which requires pyOpenSSL 16.0+. Additionally, pyca/cryptography is
an optional dep for better performance with vault already.

This commit leverages cryptography's padding, constant time comparisons,
and CBC/CTR modes to reduce the amount of code ansible needs to
maintain.

* Handle wrong password given for VaultAES format

* Do not display deprecation warning for cryptography on python-2.6

* Namespace all of the pycrypto imports and always import them

  Makes unittests better and the code less likely to get stupid mistakes
  (like using HMAC from cryptogrpahy when the one from pycrypto is needed)

* Add back in atfork since we need pycrypto to reinitialize its RNG just in case we're being used with old paramiko

* contrib/inventory/gce: Remove spurious require on pycrypto

(cherry picked from commit 9e16b9db275263b3ea8d1b124966fdebfc9ab271)

* Add cryptography to ec2_win_password module requirements
  * Fix python3 bug which would pass text strings to a function which
    requires byte strings.

* Attempt to add pycrypto version to setup deps

* Change hacking README for dual pycrypto/cryptography

* update dependencies for various CI scripts

* additional CI dockerfile/script updates

* add paramiko to the windows and sanity requirement set

  This is needed because ansible lists it as a requirement. Previously
  the missing dep wasn't enforced, but cryptography imports pkg_resources
  so you can't ignore a requirement any more

* Add integration test cases for old vault and for wrong passwords

* helper script for manual testing of pycrypto/cryptography

* Skip the pycrypto tests so that users without it installed can still run the unittests

* Run unittests for vault with both cryptography and pycrypto backend
7 years ago
Matt Davis 36ad934156 re-enable non-pipelined mode for Powershell (#25012)
* fixes #23986
* fixes 3rd-party Windows connection plugins that don't support pipelining (eg awsrun)
7 years ago
George Nikolopoulos 0bf64aa241 Add netscaler_save_config module (#25614) 7 years ago
Peter Sprygada b12ca95824 renames dict_combine to dict_merge in network_common (#26073) 7 years ago
Nathaniel Case 21c7fcf9c0 nxos_vxlan_vtep (#25971)
* nxos_vxlan_vtep tests

* Fix issues with nxos_vxlan_vtep
7 years ago
Trishna Guha 3482a6326b Fixes nxos_vpc_interface (#25907)
* nxos_vpc_interface fix

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* nxos_vpc_interface unit test

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* fix state_present

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* add state_present unit test

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* make ansibot happy

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* teardown get_config

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
7 years ago
Nathaniel Case 0296c2285b nxos_vrf fix (#25812)
* Fixes #25031

* Slight cleanup and add tests
7 years ago
Trishna Guha 947e9aba45 Add vyos_banner implementation module (#25862)
* Add vyos_banner implementation module

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* vyos_banne integration test

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* vyos_banner unit test

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* minor fix on banner text

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
7 years ago
Tim Rupp 0854c0ed88 Adds refactored bigip_hostname (#25841)
This adds a refactored bigip_hostname with unit tests and code
conventions that are common across other modules.

Unit tests are provided. Integration tests can be found here

https://github.com/F5Networks/f5-ansible/blob/devel/test/integration/bigip_hostname.yaml#L23
https://github.com/F5Networks/f5-ansible/tree/devel/test/integration/targets/bigip_hostname/tasks
7 years ago
Tim Rupp 59d470ae84 Adds bigip_iapp_service module (#25808)
This module allows a user to manage the iApp services on a bigip
that they created using the bigip_iapp_template module.

Unit tests are provided. Integration tests can be found here

https://github.com/F5Networks/f5-ansible/blob/devel/test/integration/bigip_iapp_service.yaml#L23
https://github.com/F5Networks/f5-ansible/tree/devel/test/integration/targets/bigip_iapp_service/tasks
7 years ago
Peter Sprygada 3aa41eda0b adds new common functions for declarative intent modules (#25210)
* adds new common functions for declarative intent modules

* adds Entity and EntityCollection
* adds dict_diff and dict_combine

* update for CI  PEP8 compliance

* more CI PEP8 fixes

* more PEP8 CI clean up

* refactors the lambda assignments into top level classes

this is to be in compliant the PEP8 CI sanity checks

* one last pep8 ci fix
7 years ago
Nathaniel Case a38e727380 nxos_nxapi fix (#25306)
* Add nxos_nxapi tests

* Simple changes to nxos_nxapi

* Move validation to check_args

* Don't mark protocol change unless change is requested

* Add different regex to handle HTTP{,S} ports on a different version of nxos
7 years ago
Tim Rupp c51b73d800 Makes all unit tests look the same (#25762)
Just a little cleanup from an earlier patch that makes f5 unit
tests only run if the f5 sdk is installed
7 years ago
Trishna Guha 98269888a9 iosxr_banner Implementation module (#25744)
* Add iosxr_banner implementation module

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* Integration test for iosxr_banner

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* Unit test for iosxr_banner

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* remove blank line pep8

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
7 years ago
Brian Coca fedbf3666b fixed issue with paths separator and others
finished  normalizing of path handling
removed overloaded '-p' from init_paths option, it is for role_paths
removed expand_tilde and get_opt methods as both were redundant, adjusted rest of code
updated tests to match
7 years ago
Trishna Guha 44687bb917 Add iosxr_user implementation module (#25615)
* Add iosxr_user implementation module

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* iosxr_user Integration test

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* iosxr_user Unit test

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* Modify integration test with idempotent case

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
7 years ago
Trishna Guha b3c22a96bd Add vyos_user implementation module (#25677)
* Add vyos_user implementation module

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* Integration test for vyos_user

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* Make state absent work

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* Unit test for vyos_user

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* Standardize user names

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* Modify integration test with idempotent case

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* Add role as alias to level

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
7 years ago
Trishna Guha 9c6ee8d0bb Add nxos_banner implementation module (#25695)
* Add nxos_banner implementation module

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* nxos_banner integration test

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* nxos_banner unit test

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* doc update

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
7 years ago
Brian Coca 342a85d33f fixed again 7 years ago
Brian Coca 83703e3137 skip f5 tests when f5 lib not installed 7 years ago
Tim Rupp 8e3ef4b052 Adds virtual_address module (#25728)
This module lets users manage a number of different config options
for Virtual Addresses on a BIG-IP.

Unit tests are provided. Integration tests can be found here

https://github.com/F5Networks/f5-ansible/blob/devel/test/integration/bigip_virtual_address.yaml#L23
https://github.com/F5Networks/f5-ansible/tree/devel/test/integration/targets/bigip_virtual_address/tasks
7 years ago
Tim Rupp b85785bf07 Refactors irule module to conform to recent standards (#25709)
Also includes unit tests for the code
7 years ago
Tim Rupp ba12ce64b0 Adds the bigip_snmp module (#25668)
This patch adds a module for managing several snmp related settings
on a BIG-IP that are required when configuring the range of SNMP
settings on a device.

Unit tests are provided. Integration tests can be found here

https://github.com/F5Networks/f5-ansible/blob/devel/test/integration/bigip_snmp.yaml#L23
https://github.com/F5Networks/f5-ansible/tree/devel/test/integration/targets/bigip_snmp/tasks
7 years ago
Tim Rupp 478d364f4d Adds bigip_iapp_template module (#25630)
This module can be used to upload and manage TCL iApps on a BIG-IP.
iApps can be added, removed and updated in place as needed. iApp
files should be provided to the module via Ansible lookups.

Unit tests are provided. Integration tests can be found here

https://github.com/F5Networks/f5-ansible/blob/devel/test/integration/bigip_iapp_template.yaml#L23
https://github.com/F5Networks/f5-ansible/tree/devel/test/integration/targets/bigip_iapp_template/tasks
7 years ago
Tim Rupp 0c68e200d5 Adds the bigip_provision module to Ansible (#25558)
This module allows an administrator to provision new module functionality
on a BIG-IP. BIG-IP modules provide enhanced ADC and security features that
are commonly used by customers such as GTM, ASM, and AFM.

Unit tests are provided. Integration tests can be found here

https://github.com/F5Networks/f5-ansible/blob/devel/test/integration/bigip_provision.yaml#L23
https://github.com/F5Networks/f5-ansible/tree/devel/test/integration/targets/bigip_provision/tasks
7 years ago
Brian Coca 74842adc07 1st part of ansible config, adds ansible-config to view/manage configs (#12797)
* Start of ansible config project

moved configuration definitions to external yaml file vs hardcoded
 * updated constants to be a data strcutures that are looped over and also return origin of setting
changed to manager/data scheme for base classes
new cli ansible-config to view/manage ansible configuration settings
 * prints green for default/unchanged and yellow for those that have been overriden
 * added list action to show all configurable settings and their associated ini and env var names
 * allows specifying config file to see what result would look like
 * TBD update, edit and view options

removed test for functions that have been removed

env_Vars are now list of dicts
allows for version_added and deprecation in future
added a couple of descriptions for future doc autogeneration
ensure test does not fail if delete_me exists
normalized 'path expansion'
added yaml config to setup packaging
removed unused imports
better encoding handling

updated as per feedback

* pep8
7 years ago
Nathaniel Case 4344132a7d nxos_vpc updates (#25452)
* Add nxos_vpc tests

* Split execute-show between get_config and run_commands
7 years ago
Adrian Likins 56b7483b85 More statvfs info for mount facts rebase 12073 (#25454)
* Add more mount point statvfs info including sizes

Based on https://github.com/ansible/ansible/pull/12073

facts.utils.get_mount_size() now returns a dict of most
of the posix statvfs data, including block_size and inode
counts.

Update the facts.hardware classes that use get_mount_size() to
use the new info by mount_info.update(mount_statvfs_inof) to merge.

* add back unit tests for LinuxHardware mount/fs facts

* add test cases for facts.utils.get_mount_size
7 years ago
Abhijeet Kasurde b89cb95609 Fix spelling mistakes (comments only) (#25564)
Original Author : klemens <ka7@github.com>

Taking over previous PR as per
https://github.com/ansible/ansible/pull/23644#issuecomment-307334525

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
7 years ago
Tim Rupp 61684f7313 Updates gtm wide ip module to be feature complete (#25502)
This module is used to manage GTM wide ips on a bigip.
Previously, this module only included a small subset of functionality
primarily related to editing a wide ip that already existed. Additionally
it used the SOAP api for its communication. this patch completes the
feature set of wide ips and refactors the code to use the F5 python SDK
and the REST API.

Unit tests are provided. Integration tests can be found here

https://github.com/F5Networks/f5-ansible/blob/devel/test/integration/bigip_gtm_wide_ip.yaml#L23
https://github.com/F5Networks/f5-ansible/tree/devel/test/integration/targets/bigip_gtm_wide_ip/tasks
7 years ago
Trishna Guha 91e5fce90f Add ios_user implementation module (#25413)
* Add ios_user module

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* Integration test for ios_user

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* Add unit test for ios_user

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
7 years ago
Adrian Likins dde3dac9f8 Support NetBSD 7.1+ style ifconfig -a output (#25442)
* Support NetBSD 7.1+ style ifconfig -a output

network facts on NetBSD after 7.1 cvs would fail
because of format changes in 'ifconfig -a' output.

update code to support new and old format.

add unit tests for both based on
examples from Bruce V Chiarelli.

* wrap use of interfaces.keys() in list() for py3 compat
* sort interface ids for stability
7 years ago
Adrian Likins f4128746d3 Cmdline fact uefi 23647 (#25446)
* Fix ansible_cmdline initrd fact for UEFI

UEFI cmdline paths use \ path sep which would
get munged by cmdline fact collection.

* Make CmdLineFactCollector easier to test

extract the parsing of the /proc/cmdline content to
_parse_proc_cmdline()

add a wrapper method for get_file_content _get_proc_cmdline()

Add unit tests of _parse_proc_cmdline based on examples
from issue #23647

Fixes #23647
7 years ago
George Nikolopoulos a00089c341 New module: manage Citrix Netscaler service configuration (network/netscaler/netscaler_service) (#25129)
* netscaler_service initial implementation

* Changes as requested by reviewers

* Skip some tests if under python2.6 and importing requests library

* Change option "operation" to "state"

* Remove print statements from netscaler module utils

* Catch all exceptions during login

* Fix fail message

* Add common option save_config
7 years ago
Brian Coca 745f72916f bigip tests now skipped if missing lib 7 years ago
Tim Rupp 6f2c543a33 Updates and refactors the bigip pool module to use REST (#25234)
This patch updates the bigip_pool module to use F5's REST API
as well as includes unit tests.

Unit tests are provided. Integration tests can be found here

https://github.com/F5Networks/f5-ansible/blob/devel/test/integration/bigip_pool.yaml#L23
https://github.com/F5Networks/f5-ansible/tree/devel/test/integration/targets/bigip_pool/tasks
7 years ago
Tim Rupp 855fd98be6 Adds the bigip_config module to Ansible (#25191)
This patch adds the bigip_config module to Ansible to support
merging SCF files, saving running configs, resetting config
and validating SCF configs
7 years ago
Toshio Kuratomi be4e7a05fa remove_values could hit the recursion limit
When operating on arbitrary return data from modules, it is possible to
hit the recursion limit when cleaning out no_log values from the data.
To fix this, we have to switch from recursion to iteration.

Unittest for remove_values recursion limit

Fixes #24560
7 years ago
Nathaniel Case f52dcef7ba Actually check for equality on empty commands array (#25308) 7 years ago
Tim Rupp 0133a5a763 Adds the bigip_gtm_pool module (#25275)
This module is used to manage GTM(DNS) pools in a BIG-IP.

Unit tests are provided. Integration tests can be found here

https://github.com/F5Networks/f5-ansible/blob/devel/test/integration/bigip_gtm_pool.yaml#L23
https://github.com/F5Networks/f5-ansible/tree/devel/test/integration/targets/bigip_gtm_pool/tasks
7 years ago
Ganesh Nalawade 6215922889 Add support for cliconf and netconf plugin (#25093)
* ansible-connection refactor and action plugin changes
* Add cliconf plugin for eos, ios, iosxr, junos, nxos, vyos
* Add netconf plugin for junos
* Add jsonrpc support
* Modify network_cli and netconf connection plugin
* Fix py3 unit test failure
* Fix review comment
* Minor fixes
* Fix ansible-connection review comments
* Fix CI issue
* platform_agnostic related changes
7 years ago
Michael De La Rue e28845018d [cloud] New module: AWS API Gageway module (#20230)
* Ultra basic api-gateway module based of lambda.py

* Ultra basic deployment added to api-gateway module

* ApiGateway module Allow creation of APIs, more documentation and better return value

* ApiGateway module incorporate review feedback

* ApiGateway module flake8 cleanup

* APIGateway module - more review fixes.

* slightly better messages in api_gateway module

* AWS api_gateway module - try to improve messages in case of exceptions

* rename api_gateway module to aws_api_gateway as discussed in PR 20230

* aws_api_gateway - Allow delivery of swagger either as text or dictionary.

* aws_api_gateway module - introduce 'unit' tests, improve imports using them and small fixes

* aws_api_gateway module - move path expand_user to avoid early typecheck

* aws_api_gateway - version means version of metadata not module - fix to 1.0

* aws_api_gateway module - Rely on module_utils.ec2 for imports & path type for expanduser / cleanups

* aws_api_gateway module - heavy cleanup and refactor of code + cloud retry functionality.

* api_gateway_module - failing test case for handling more than one deployment in succession and API deletion

* add TooManyRequestsException to AWSRetry exception list - makes API deployment work.

* api_gateway_module - Fixes for various review comments + errors from various linters

* api_gateway_module - Fixes for more review comments + linter error

* api_gateway_module - Major refactor into sensible functions - create_response becomes configure_response

* api_gateway_module - should be working under python3; remove test exclusion

* api_gateway_module - finish off remaining review fixes - use ansible defaults and fix mutually exclusive

* api_gateway_module - attempt to improve handling of botocore errors in python3

* api_gateway_module - implement state=absent / API deletion
7 years ago
Adrian Likins 45a9f96774 Facts Refresh (2.4 roadmap) (#23012)
Facts Refresh (2.4 roadmap)

This commit implements most of the 2.4 roadmap 'Facts Refresh'
- move facts.py to facts/__init__.py
- move facts Distribution() to its own class
- add a facts/utils.py
- move get_file_content and get_uname_version to facts/utils.py
- move Facts() class from facts/__init__ to facts/facts.py
- mv get_file_lines to facts/utils.py
- mv Ohai()/Facter() class to facts/ohai.py and facter.py
- Start moving fact Hardware() classes to facts/hardware/*.py
- mv HPUX() hardware class to facts/hardware/hpux.py
- move SunOSHardware() fact class to facts/hardware/sunos.py
- move OpenBSDHardware() class to facts/hardware/openbsd.py
- mv FreeBsdHardware() and DragonFlyHardware() to facts/hardware/
- mv NetBSDHardware() to facts/hardware/netbsd.py
- mv Darwin() hardware class to facts/hardware/darwin.py
- pep8/etc cleanups on facts/hardware/*.py
- Mv network facts classes to facts/network/*.py
- mv Virtual fact classes to facts/virtual
- mv Hardware.get_sysctl to facts/sysctl.py:get_sysctl

- Also mv get_uname_version from facts/utils.py -> distribution.py
  since distribution.py is the only thing using it.

- add collector.py with new BaseFactCollector
- add a subclass for AnsibleFactCollector
- hook up dict key munging FactNamespaces
- add some test cases for testing the names of facts
- mv timeout stuff to facts.timeout

- rm ansible_facts()/get_all_facts() etc

- Instead of calling facts.ansible_facts(), fact collection
  api used by setup.py is now to create an AnsibleFactCollector()
  and call it's collect method.

- replace Facts.get_user_facts with UserFactCollector
- add a 'systems' facts package, mv UserFactCollector there
- mv get_dns_facts to DnsFactCollector
- mv get_env_facts to EnvFactCollector
- include the timeout length in exception message

- modules and module_utils that use AnsibleFactCollector
  can now theoretically set the 'valid_subsets'

  May be useful for network facts module that currently have
  to reimplement a good chunk of facts.py to get gather_subsets
  to work.

- get_local_facts -> system/LocalFactCollector
- get_date_time -> system/date_time.py
- get_fips_facts -> system/fips.py
- get_caps_facts() -> system/caps.py
- get_apparmor_facts -> system/apparmor.py
- get_selinux_facts -> system/selinux.py
- get_lsb_facts -> system/lsb.py
- get_service_mgr_facts -> system/service_mgr.py
- Facts.is_systemd_managed ->  system/service_mgr.py
- get_pkg_mgr_facts -> system/pkg_mgr.py
- Facts()._get_mount_size_facts() -> facts.utils.get_mount_size()

- add unit test for EnvFactCollector
- add a test case for minimal gather_subsets
- add test case for collect_ids
- Make gather_subset match existing behavior or '!all'

    If 'gather_subset' is provided as '!all', the existing behavior
    (in 2.2/2.3) is that means 'dont collect any facts except those
    from the Facts() class'. So 'skip everything except
    'apparmor', 'caps', 'date_time', 'env', 'fips', 'local', 'lsb',
    'pkg_mgr', 'python', 'selinux', 'service_mgr', 'user', 'platform', etc.

    The new facts setup was making '!all' mean no facts at all, since
    it can add/exclude at a finer granularity. Since that makes more
    sense for the ansible collector, and the set of minimal facts to
    collect is really more up to setup.py to decide we do just that.

    So if setup.py needs to always collect some gather_subset, even
    on !all, setup.py needs to have the that subset added to the
    list it passes as minimal_gather_subset.

    This should fix some intg tests that assume '!all' means that
    some facts are still collected (user info and env for example).

    If we want to make setup.py collect a more minimal set, we can do that.

- force facts_dicts.keys() to a list so py3 works
- split fact collector tests to test_collectors.py

- convert Facter(Facts) -> other/facter.py:FacterFactCollector

- add FactCollector.collect_with_namespace()

    regular .collect() will return a dict with the key names
    using the base names ('ip_address', 'service_mgr' etc)

    .collect_with_namespace() will return a dict where the key names
    have been transformed with the collectors namespace, if there is
    one. For most, this means a namespace that adds 'ansible_' to the
    start of the key name.

    For 'FacterFactCollector', the namespace transforms the key to
    'facter_*'.

- add test cases for collect_with_namespace

- move all the concrete 'which facts does setup.py' stuff to setup.py

    The caller of AnsibleFactCollector.from_gather_subset() needs to
    pass in the list of collector classes now.

- update system/setup.py to import all of the fact classes and pass
  in that list.
- split the Distribution fact class up a bit

    extracted the 'distro release' file handling (ie, linux
    boxes with /etc/release, /etc/os-release etc) into its
    own class.
- extract get_cmdline_facts -> cmdline.py
- extract get_public_ssh_host_keys -> system/ssh_pub_keys.py
- extract get_platform_facts -> system/platform.py

  platform.py may be a good candidate for further splitting.

- rm test for plain Facts() base class
- let the base class for Collector unit tests provide collected_facts

    some Collectors and/or their migrated Facts() subsclasses need
    to look at facts collected by other modules ('ansible_architecture'
    the main one...).

    Collector.collect() has the collected_facts arg for this, so add
    a class variable to BaseFactsTest so we can specify it.

- mv Ohai to other/ohai.py and convert to Collector
- update hardware/*.py to return facts (no side effects)

- mv AnsibleFactCollector to setup.py
- extra collector class gathering to module method in
  facts/__init__.py (collector_classes_from_gather_subset)
- add a CollectorMetaDataCollector collector used to provide
  the 'gather_setup' fact
- add unit test module for 'setup' module
  (test/units/modules/system/setup.py)

- Collector init now doesnt need a module, but collect does

    An instance of a FactCollector() isnt tied to a AnsibleModule
    instance, but the collect() method can be, so optionally pass
    in module to FactCollector.collect() (everywhere)

- add a default_collectors for list of default collectors

  import and use it from setup.py module

  eventually, would like to replace this with a plugin loader
  style class finder/loader

- unit tests for module_utils/facts/__init__.py
- add unit tests for ohai facts collector
- remove self.facts side effect on populate() in hardware/sunos.py
- convert OpenBSDHardware() to rm side effects on self.facts
- try to rm some self.facts side effects in Network()

    plumb in collected_facts from populate() where it is needed.

    stop passing collected_facts into Network() [via cached_facts=,
    where it eventually becomes self.facts]

- nothing provides Fact() cached_facts arg now, rm it

    Facts() should be internal only implementation so nothing
    should be using it.

    Of course, now someone will.

- add a Collector.name attr to build a map of name->_fact_ids

    To properly exclude a gather_subset spec like '!hardware', we
    need to know that 'hardware' also means 'devices', 'dmi', etc.
    Before, '!hardware' would remove the 'hardware' collector name
    but not 'devices'. Since both would end up in id_collector_map,
    we would still end up with the HardwareCollector in the collector
    list. End result being that '!hardware' wouldn't stop hardware
    from being collected.

    So we need to be able to build that map, so add the Collector.name
    attribute that is the primary name (like 'hardware') and let
    Collector._fact_ids be the other fact ids that a collector is
    responsible for.

    Construct the aliases_map of Collector.name -> set of _fact_ids
    in fact/__init__.py get_collector_names, and use it when we are
    populating the exclude set.

- refactor of distribution.py

    make the big OS_FAMILY literal a little easier to read
    Also keys can now be any string instead of python literals

    99% sure the test for 'KDE Neon' was wrong
    I don't see how/where it should or could get 'Neon' instead
    of 'KDE Neon' as provided in os-release NAME=

    Use 'distribution' string for key to OS_MAP

    ie, we dont need to make it a valid python label anymore so dont.

    move _has_dist_file to module as _file_exists
    easier to mock without mucking with os.path

    mv platform.system() calls to within get_distribution_facts() instead
    of Distribution() init.

- remove _json compat module

    The code in here was to support:

      -a 'json' python module that was not the standard one included
      with python since 2.6.

      - potentially fallback to simplejson if 'json' was not available.

    'json' is available for all supported python versions now so
    no longer needed.

- mv get_collector_names -> facts.collector
- mv collector_classes_from_gather_subset -> facts.collector
- mv collector tests from test_facts -> test_collector

- Use six's reduce() in sunos/netbsd hardware facts

- rm extraneous get_uname_version in utils

  only system/distribution.py uses it

- Remove Facts() subclass metaclass usage

  - using fact_id and a platform id for matching collectors

    gut most of Facts() subclasses

    rm Facts() subclasses with weird metaclass

    only add collectors that match the fact_ids and the platform_info
    to the list of collectors used.

    atm, a collectors platform_id will default to 'Generic', and
    any platform matches 'Generic'

    goal is to select collector classes including matching the
    systems platform in collector.py, instead of relying on
    metaclasses in hardware/*. To finish this, the various
    Facts() subclasses will need to be replaced entirely with
    Collector() subclasses.

    use collector classmethod platform_match() to match the platform

    This lets the particular class decide if it is compatible with
    a given platform_info. platform_info is a dict like obj, so it could be
    expanded in the future.

    Add a default platform_match to BaseFactCollector that matches
    platform_info['system'] == cls._platform

    They were needed previously to trigger a module
    load on all the collector classes when we import
    facts/hardare so that the Hardware() and related
    classes that used __new__ and find_all_subclasses()
    would work.

    Now that is done in collectors based on platform matching
    at runtime we dont need to do it py module import/parse
    time. So the non empty __init__.pys are no longer needed
    and their is a more flexible mechanism for selection
    platform specific stuff.

    facts/facts.py is no longer used, rm'ed

- if we dont find an implement class for gather spec.. just ignore it.

  Would be useful to add a warn to warn about this case.

- Fix SD-UX typo (should be HP-UX)

- Port fix for #21893 (0 sockets) to this branch

    This readds the change from 8ad182059d
    that got lost in merge/rebase

    Fixes #21893

- port sunos fact locale fix for #24542 to this branch

    based on e558ec19cd

    Fixes #24542

    Solaris fact fix (#24793)

    ensure locale for solaris fact gathering

    fixes issue with locale interfering with proper reading of decimals

- raise exceptions in the air like we just dont care.

    Pretty much ignore any not exit exception in facts
    collection. And add some test cases.

- added new selinux fact to clarify python lib

    the selinux fact is boolean false when the library is not installed,
    a dictionary/hash otherwise, but this is ambigous
    added new fact so we can eventually remove the type dichtomy and normalize it as a dict

    Re-add of devel commit 85c7a7b844 to
    the new code layout, since it got removed in merge/rebase
7 years ago
Trishna Guha 343b83041e nxos_feature fix and unit test (#25200)
* nxos_feature fix

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* nxos_feature unit test

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* remove from pep8/legacy-file

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
7 years ago
Trishna Guha fb87680046 fix state present nxos_evpn_vni (#25212)
Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
7 years ago