Commit Graph

1427 Commits (410c85522a6b082624870b3a307b0bf93ba29407)

Author SHA1 Message Date
Lance Richardson dc08b9a738 new module exos_config (#43902)
- support config operations for EXOS-based platforms
- add regex to detect command failure responses
- add exos action plugin for "backup" operation
- add unit tests for exos_command (currently 94% coverage of
  exos_config.py)
6 years ago
Zhikang Zhang 0971a342d8
Solve race condition in password lookup (#42529)
NOTE:
1. use os.open() with os.O_CREAT|os.O_EXCL to check existence
and create a lock file if not exists, it's an atomic operation
2. the fastest process will create the lock file and others will
wait until the lock file is removed
3. after the writer finished writing to the password file, all the reading
operations use built-in open so processes can read the file parallel
6 years ago
Matt Martz 17c89d1ffa
Remove unused rslt_q, rename the one queue to final_q everywhere (#43894)
* Remove unused rslt_q, rename the one queue to final_q everywhere

* Test update
6 years ago
Lindsay Hill 5981a7489b new nos_command module (#43056) 6 years ago
Matt Martz c1c229c6d4
Remove use of simplejson throughout code base (#43548)
* Remove use of simplejson throughout code base. Fixes #42761

* Address failing tests

* Remove simplejson from contrib and other outlying files

* Add changelog fragment for simplejson removal
6 years ago
Trishna Guha 96346938ee
nxos_vlan refactor to support non structured output (#43805)
* nxos_vlan refactor to support non structured output

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

* unittest fix

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

* minor fixes

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

* use check_rc

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

* address review comment

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

* remove additional return statement

* address Nate's review

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
6 years ago
Ganesh Nalawade d1de1e0449
Update iosxr cliconf plugin (#43837)
* Update iosxr cliconf plugin

Fixes #39056

*  Update iosxr cliconf plugin
*  Modify iosxr module_utils code to support
   refactored cliconf plugin api's
*  Other minor changes

* Fix unit test failure

* Update ios, eos, nxos plugin for diff

* Fix review comment
6 years ago
Deepak Agrawal 8eaebf86b6
openvswitch_db : Handle column value conversion and idempotency in no_key case (#43869)
* change column value to string. handle idempotency in no key case

* fix unit test failures in baseline
6 years ago
Lance Richardson bd4d68c785 network/exos: add exos_facts module (#43210)
Add exos_facts module. Known limitations at this time include:
   - Interface MTU is not reported.
   - Only primary interface IP is reported.

Add basic unit tests for the exos_facts module.

An EXOS CLI prompt can be prefixed with '! ' (shutting down), '* '
(running configuration does not match saved configuration), and
can include various status tokens within parentheses after these
prefixes. Update prompt regex to accept valid CLI prompts.
6 years ago
Lindsay Hill 8429f777da New networking module: voss_command (#43741)
* new voss_command module

* Removed incorrect version_added line
6 years ago
Toshio Kuratomi 30662bedad
Only print warning when ansible.cfg is actually skipped (#43583)
Only print warning when ansible.cfg is actually skipped

* Also add unittests for the find_ini_config_file function
* Add documentation on world writable current working directory
  config files can no longer be loaded from a world writable current
  working directory but the end user is allowed to specify that
  explicitly.  Give appropriate warnings and information on how.

Fixes #42388
6 years ago
Anil Kumar Muraleedharan 119376a685 Refactoring to persistence connection BGP, factory, reload, save, showrun modules (#43534)
* Refactoring to persistence connection BGP, factory, reload, save, showrun modules

* Refactoring methods from Util to module file

* Removing BGP Utility methods

* Adding to errors that need to be ignored
6 years ago
Zhikang Zhang 3a3869f4c8
Clarify usage of encrypt arg (#43330)
According to the do_encrypt interface, encrypt arg should be the hash method name used for encrypting returning password. But in the doc and lookup code it's a boolean flag, correct it to string.
6 years ago
Trishna Guha 09ae1ec308
cliconf refactor eos, nxos fix (#43596)
* cliconf refactor eos and nxos fix

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

* move nxos replace check to plugins

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

* address review comment

* fix shippable
6 years ago
Sumit Jaiswal e96f90b440
Nios integration and unit tests for all remaining nios new modules (#43399)
* new nios module support

* new nios module support

* new nios module support

* new nios module support

* new nios module support

* new nios module support

* new nios module support

* new nios module integration test support

* new nios module integration test support

* new nios module integration test support

* new nios module integration test support

* new nios module integration test support

* new nios module integration test support

* new nios module integration test support

* new nios module integration test support

* new nios module integration test support

* new nios module integration test support

* new nios module integration test support

* new nios module integration test support

* new nios module integration test support

* new nios module integration test support

* new nios module integration test support

* new nios module integration test support

* new nios module integration test support

* new nios module integration test support

* new nios module integration test support

* new nios module integration test support

* new nios module integration test support

* new nios module integration test support

* new nios module integration test support

* new nios module integration test support

* test/integration/targets/nios_naptr_record/tasks/nios_naptr_record_idempotence.yml

new nios module integration test support

* fix pep8 error

* fix pep8 error

* adding newline at end

* adding newline at end

* adding newline at end

* adding newline at end

* adding newline at end

* adding newline at end

* adding newline at end

* adding newline at end

* adding newline at end

* adding newline at end

* adding newline at end

* adding newline at end

* adding newline at end

* adding newline at end
6 years ago
Joren Vrancken b954917761 Surround top-level function and class definitions with two blank lines. 6 years ago
Alex Dukhno dd28be3aab Update pagerduty modules to rest v2 (#42618)
* refactored from procedural to OOP

* updated ongoing maintenance windows to PagerDuty REST API v2

* update create maintenance windows to PagerDuty REST API v2

* update absent maintenance windows to PagerDuty REST API v2

* update pager alert module to PagerDuty REST API v2

* removed basic HTTP authorization
updated parameter description and examples

* fix failed sanity checks

* revised documentation according to review

* make obsolete service key parameter an alias to a new integration key parameter
6 years ago
Egor Zaitsev 249a6aae22 New module: routeros — manage MikroTik RouterOS (#41155)
* Implement initial RouterOS support

* Correct matchers for license prompts

* Documentation updates & mild refactor

* Remove one last Cisco function

* Sanity test fixes

* Move imports to the beginning

* Remove authorize property

* Handle ANSI codes

* Revert to_lines function

* CR fixes

* test(routeros): add unit tests

* Added another test (with ANSI colors and banner in fixture).

* Ignore CRLF line endings in system_package_print file

* fix: review by ganeshrn
6 years ago
tstoner 2c3d418e53 Nxapi ssl (#42905)
* NXAPI ssl ciphers & protocols default values

* TLSv1, TLSv1.1, TLSv1.2 and weak cipher support

* NXOS NXAPI weak/strong cipher & TLSv 1.2, 1.1 & 1.0 support

* Version checking for strong/weak ciphers & TLS 1.2, 1.1 & 1.0 support

* Cleaned up erroneously committed changes.

* Specific NXOS platform checking for nxapi ssl ciphers & protocols

* Fixed ansibot reported errors.

* Resolved ansibot reported error.

* Added network_os_version to mocked up N7K unit test device_info

* Calling get_capabilities() once in main and passing results into methods.

* Removed raising exceptions when platform capabilities return None
per reviewers request. Skipping nxapi ssl options when capabilities
are None and generating a warning when these options are skipped

* Cleaned up explicit checks for None/not None
6 years ago
Anil Kumar Muraleedharan f2c9a6b126 Lenovo port to persistence 1 (#43194)
* CNOS Vlag module is refactored to use persistence connection instead of paramiko.

* Changing interface and port channel modules to persistent connection and adding UT for them.

* Fixing pep8 issues

* Removing trailing new line

* Removing trailing new line

* Removing trailing new line

* Correcting indentation mistake

* Update cnos_vlag.py

* Removing commented examples

They are commented because those configurations are not meant for L2 ports
6 years ago
Ganesh Nalawade af3f510316
nxos cliconf plugin refactor (#43203)
* nxos cliconf plugin refactor

Fixes #39056

*  Refactor nxos cliconf plugin as per new api definition
*  Minor changes in ios, eos, vyos cliconf plugin
*  Change nxos httpapi plugin edit_config method to be in sync with
   nxos cliconf edit_config

* Fix CI failure

* Fix unit test failure and review comment
6 years ago
Toshio Kuratomi 52449cc01a AnsiballZ improvements
Now that we don't need to worry about python-2.4 and 2.5, we can make
some improvements to the way AnsiballZ handles modules.

* Change AnsiballZ wrapper to use import to invoke the module
  We need the module to think of itself as a script because it could be
  coded as:

      main()

  or as:

      if __name__ == '__main__':
          main()

  Or even as:

      if __name__ == '__main__':
          random_function_name()

  A script will invoke all of those.  Prior to this change, we invoked
  a second Python interpreter on the module so that it really was
  a script.  However, this means that we have to run python twice (once
  for the AnsiballZ wrapper and once for the module).  This change makes
  the module think that it is a script (because __name__ in the module ==
  '__main__') but it's actually being invoked by us importing the module
  code.

  There's three ways we've come up to do this.
  * The most elegant is to use zipimporter and tell the import mechanism
    that the module being loaded is __main__:
    * 5959f11c9d/lib/ansible/executor/module_common.py (L175)
    * zipimporter is nice because we do not have to extract the module from
      the zip file and save it to the disk when we do that.  The import
      machinery does it all for us.
    * The drawback is that modules do not have a __file__ which points
      to a real file when they do this.  Modules could be using __file__
      to for a variety of reasons, most of those probably have
      replacements (the most common one is to find a writable directory
      for temporary files.  AnsibleModule.tmpdir should be used instead)
      We can monkeypatch __file__ in fom AnsibleModule initialization
      but that's kind of gross.  There's no way I can see to do this
      from the wrapper.

  * Next, there's imp.load_module():
    * https://github.com/abadger/ansible/blob/340edf7489/lib/ansible/executor/module_common.py#L151
    * imp has the nice property of allowing us to set __name__ to
      __main__ without changing the name of the file itself
    * We also don't have to do anything special to set __file__ for
      backwards compatibility (although the reason for that is the
      drawback):
    * Its drawback is that it requires the file to exist on disk so we
      have to explicitly extract it from the zipfile and save it to
      a temporary file

  * The last choice is to use exec to execute the module:
    * https://github.com/abadger/ansible/blob/f47a4ccc76/lib/ansible/executor/module_common.py#L175
    * The code we would have to maintain for this looks pretty clean.
      In the wrapper we create a ModuleType, set __file__ on it, read
      the module's contents in from the zip file and then exec it.
    * Drawbacks: We still have to explicitly extract the file's contents
      from the zip archive instead of letting python's import mechanism
      handle it.
    * Exec also has hidden performance issues and breaks certain
      assumptions that modules could be making about their own code:
      http://lucumr.pocoo.org/2011/2/1/exec-in-python/

  Our plan is to use imp.load_module() for now, deprecate the use of
  __file__ in modules, and switch to zipimport once the deprecation
  period for __file__ is over (without monkeypatching a fake __file__ in
  via AnsibleModule).

* Rename the name of the AnsiBallZ wrapped module
  This makes it obvious that the wrapped module isn't the module file that
  we distribute.  It's part of trying to mitigate the fact that the module
  is now named __main)).py in tracebacks.

* Shield all wrapper symbols inside of a function
  With the new import code, all symbols in the wrapper become visible in
  the module.  To mitigate the chance of collisions, move most symbols
  into a toplevel function.  The only symbols left in the global namespace
  are now _ANSIBALLZ_WRAPPER and _ansiballz_main.

revised porting guide entry

Integrate code coverage collection into AnsiballZ.

ci_coverage
ci_complete
6 years ago
Toshio Kuratomi 5b4a7cc283 Fix journald unittests
d7df072b96 changed how we call
journal.send() from positional arguments to keyword arguments.  So we
need to update the test to check for the arguments it was called with in
the keyword args, not in the positional args.
6 years ago
Gregory Hellings 6f007c35c1 Improved the documentation of known_hosts
The documentation for the key parameter was lacking in specificity and
also lacking in testing. These parts are both remedied herein.

Fixes #43157
6 years ago
Adam Miller 562ff66a98 Fix pkg_mgr_name fact finding for Fedora (#40922)
* Properly handle default package manager vs apt

For distros where apt might be installed but is not the default
package manager for the distro, properly identify the default distro
package manager during fact finding and re-use fact finding from
DistributionFactCollector and instead of reimplementing small
portions of it in PkgMgrFactCollector

Add unit test to always check the apt + Fedora combination to test
the new code.

Fixes #34014

Signed-off-by: Adam Miller <admiller@redhat.com>

* remove q debugging output I accidentally left behind

Signed-off-by: Adam Miller <admiller@redhat.com>

* add os_family to the conditional so we're only hitting that code path when needed

Signed-off-by: Adam Miller <admiller@redhat.com>

* setup for a _check* pattern for general os_family group pkg_mgr checking

Signed-off-by: Adam Miller <admiller@redhat.com>

* use Mock.patch decorator for os.path.exists in TestPkgMgrFactsAptFedora

Signed-off-by: Adam Miller <admiller@redhat.com>
6 years ago
Andrey Laguta 2e62e36590 Fix multiple var files combining (followup to #36357) 6 years ago
Matej Vadnjal 7c318d4e30 ios_user module - implement sshkey option (#38782)
* ios_user module - add sshkey support

* ios_user - Add version_added to sshkey option

* ios_user - pep8 indentation fixes in unit tests

* ios_user - use b64decode method that works on python 2 and 3
6 years ago
Samer Deeb 3ca4a35334 Add support for global IGMP configuration on onyx switches (#42164)
* Add support for global IGMP configuration on onyx switches

Signed-off-by: Samer Deeb <samerd@mellanox.com>

* Add support for global IGMP configuration on onyx switches

Signed-off-by: Samer Deeb <samerd@mellanox.com>
6 years ago
Anil Kumar Muraleedharan 0897e79bd1 Persistence connection for cnos_vlan (#42500)
* Changing Lenovo Inc to Lenovo and update License file to be consistent.

* Changing cnos_vlan from paramiko to persistence connection of Ansible. Also talking care of CLI changes in CNOS commands with backward compatibility.

* Fixing Validation issues

* Trailing lines removal

* Review comments of Gundalow are getting addressed. He mentioned only at one place for cnos.py. But I have covered the entire file.

* Changes to incorporate Review comments from Qalthos

* Removing configure terminal command from module code

* Aligning with change in run_cnos_commands method changes

* Editing cliconf for latest CNOS CLIs
6 years ago
Sloane Hertel 1fdd84b88c Rename AWS unit tests that are not running when changing the module (#42712)
now can use `ansible-test units module_name` for the aws_s3 and aws_api_gateway modules

changes to modules/cloud/amazon/aws_api_gateway and modules/cloud/amazon/aws_s3 are not triggering the unit tests; also fix aws_s3 from importing non-exist module and skipping tests

changes to module_utils/aws/core.py are only being unit tested on modules that import from the file (if they have a corresponding test) or tests that import from the file themselves.
6 years ago
Ryan Brown 45f5964fed Fix patching of wrong boto3_conn in API Gateway tests (#42700) 6 years ago
Clement Trebuchet 7c97bb5077 Devel ios vrf submode (#41659)
* add submode features ipv4/ipv6

* add tests for submode

* the parameters both_ * were not idempotent, in what is read in the configuration we have a list with 2 entries (import, export) while the input parameter has only one parameter which will be applied twice

* add docstring to the ios_vrf module + provide a fix for: https://github.com/ansible/ansible/issues/41581

* complete tests

* add missing description

* fix KeyError for address-family ipv*

* fix both_* tests

* fix E231, W292, W293

* fix W293

* remove set has it doesn't preserve order of routes

* fix E106

* remove ImportError: cannot import name OrderedDict

* We should be able to mix the parameters for the routes targets , while remaining imdepotent. During the first implementation we did not take this into account, which did not correspond to the reality of the needs in production (to be able to use each parameter indifemently together)

* remove epdb reference

* FIX E111, E106

* FIX E302

* using loop produce a result who  was not imdepotent

* FIX E241

* fix: used pass intead of list
6 years ago
Clement Trebuchet c7981c4cc8 Add the NIOS RECORD PTR Module (#41900)
* Add the NIOS RECORD PTR Module

* FIX E241,E231, E105

* FIX module should not be executable

* FIX module RWX

* Remove change in nios_srv_record

* Remove change in nios_srv_record

* FIX test_nios_ptr_record_update_comment

* ADD: Integration and target tests for the NIOS PTR RECORD module.

* FIX module name in integrations tests

* Update integration

* Refactor nios_ptr_record module

* Refactor the nios_ptr_record_idempotence

* FIX name

* Smoketests for the NIOS modules does not take care of the PTR:RECORD object

* REM the default for view

* Add finals test, after adding the PR (https://github.com/ansible/nios-test-container/pull/1) in order to handle PTR:RECORD

* add the define nios specific constant for PTR:RECORD

* fix: documentation style

* add create an ipv6 ptr record

* rename class name, add ipv6 unittest
6 years ago
Fran Fitzpatrick 5928ec04ca Adds an ipmath filter (#41985) 6 years ago
Will Thames 42eaa00371 Provide kubernetes definition diffs in check_mode (#41471)
Move dict_merge from azure_rm_resource module to
module_utils.common.dict_transformations and add tests.

Use dict_merge to provide a fairly realistic, reliable
diff output when k8s-based modules are run in check_mode.

Rename unit tests so that they actually run and reflect
the module_utils they're based on.
6 years ago
hitsumabushi cf7a42b4f4 allow empty line in src template file (#42493) 6 years ago
Jordan Borean 940d4a0e89
win_reboot: fix 2.6 issues and better handle post reboot reboot (#42330)
* win_reboot: fix 2.6 issues and better handle post reboot reboot

* changed winrm _reset to reset

* Add handler to reset calls when .reset() throws an AnsibleError on older hosts

* Moving back to _reset to get the issue fixed
6 years ago
Zhikang Zhang 70e33ef92c
Make ios_vlan identify vlans starting with 9 (#42247)
* Make ios_vlan identify vlans starting with 9

* Add unit test for vlan id start with 9
6 years ago
Jakub Libosvar 26b0908270 openvswitch_db: Make 'key' parameter optional (#42110)
The OVSDB schema consists of typed columns. The 'key' parameter is
required only for columns with type of a 'map'. This patch makes 'key'
an optional parameter to allow setting values for other column types
like int.

Fixes #42108
6 years ago
Paul Neumann dfb2b3fdd5 ios_facts: Report space of file systems (#41850)
* ios_facts: Report file system space

Parse total and free space from dir output. For this, add a hash
filesystems_info containing the keys spacetotal_kb and spacefree_kb.

* ios_facts: Add unit test for file system space reporting

* ios_facts: Add integration test for file system space reporting
6 years ago
Jordan Borean 8bdd04c147 Fix remote_tmp when become with non admin user (#42396)
* Fix tmpdir on non root become

 - also avoid exception if tmpdir and remote_tmp are None
 - give 'None' on deescalation so tempfile will fallback to it's default behaviour
   and use system dirs
 - fix issue with bad tempdir (not existing/not createable/not writeable)
   i.e nobody and ~/.ansible/tmp
 - added tests for blockfile case

* Revert "Temporarily revert c119d54"

This reverts commit 5c614a59a6.

* changes based on PR feedback and changelog fragment

* changes based on the review

* Fix tmpdir when makedirs failed so we just use the system tmp

* Let missing remote_tmp fail

If remote_tmp is missing then there's something more basic wrong in the
communication from the controller to the module-side.  It's better to
be alerted in this case than to silently ignore it.

jborean and I have independently checked what happens if the user sets
ansible_remote_tmp to empty string and !!null and both cases work fine.
(null is turned into a default value controller-side.  empty string
triggers the warning because it is probably not a directory that the
become user is able to use).
6 years ago
Ganesh Nalawade c068b88b38
Update eos, ios, vyos cliconf plugin (#42300)
* Update eos cliconf plugin methods

*  Refactor eos cliconf plugin
*  Changes in eos module_utils as per cliconf plugin refactor

* Fix unit test and sanity failures

* Fix review comment
6 years ago
hlrichardson 2aa81bf05d add tests for exos_command module (#42268) 6 years ago
Nathaniel Case 5850591d14
Base connection class for network-style connections (#41839)
* Create base class for network-style connections

* clean up some differences

* Move NetworkConnectionBase

* Tweak netconf for tests

* Tweak when network_os is checked to avoid failing tests

* Pull back exec_command
6 years ago
Ganesh Nalawade e41d427d1b
Add run_commands api for ios and vyos cliconf plugin (#42093)
* Add run_commands api for ios and vyos cliconf plugin

*  Add run_commands api to ios and vyos cliconf plugin
*  Refactor ios and vyos module_utils to check return code
   in run_commands

* Fix Ci failures
6 years ago
Yanis Guenane 42c2fd72ae Fix test_create_jks_success failing on SELinux machine (#42001)
Currently TestCreateJavaKeystore::test_create_jks_success is failing on
a machine with SELinux because set_context_if_different is not mocked
and hence tries to access a file that doesn't exist because it has been
mocked previously.

Also, changing path to a path that won't exist for sure.
6 years ago
Eitan Akman fb7882bf86 Issue #39860: Add 'not_contains' method to parsing.py (#39874)
* Issue #39860: Add 'not_contains' method to parsing.py

* Issue #30860 Adds self.negate to Conditional class in lib/ansible/module_utils/network/common/parsing.py

* Issue #39860 Fix singleton-comparison issue per sanity tests

* Issue #39860 'test/integration/targets/nxos_command/tests/cli/not_comparison_operator.yaml' integration test

* Issue #39860 Add unit tests to '../../test/units/module_utils/network/common/test_parsing.py'

* Issue #39860 Fix singleton comparison issue

* Fix E302 expected 2 blank lines, found 1

* Issue #39860 Add license header to unit tests

* Issue #39860 Move integration test to 'test/integration/targets/nxos_command/tests/common/'; remove unnecessary comment from unit test

* Issue #39860 remove unnecessary comment from unit test
6 years ago
Troy Murray 15ce7c5bab change OS X to macOS (#41294)
* change OS X to macOS

<!--- Your description here -->

+label: docsite_pr

* Update all Mac OS X references to be macOS

* Drop extra Mac
6 years ago
Matthew Stone c5c3900c52 Adding slxos_lldp module (#39259)
* Adding slxos_lldp module
6 years ago
Jordan Borean 9b7b564d75
Stop displaying kinit pass input on a failure (#41882)
* Stop displaying kinit pass input on a failure

* Fixed up minor logic info and added tests
6 years ago