Commit graph

2144 commits

Author SHA1 Message Date
Jordan Borean
1c885cb848 Added fix for win_file with broken symlinks (#19146) 2017-02-08 18:49:49 -08:00
Matt Clay
91526cd9f2 Enable process isolation for unit tests. 2017-02-08 14:36:42 -08:00
Jordan Borean
1ce5fcf061 Added win_find module (#19144) 2017-02-08 22:19:08 +00:00
Matt Clay
57a5490c41 Fix test which fails on some python 2.6 installs. 2017-02-08 14:06:40 -08:00
s-hertel
65815c3875 Refactoring Galaxy unit tests for uniformity (#20828)
* Making tests more uniform

Removing unnecessary GalaxyCLI arguments/patching of the command line since parsing of the CLI args has been modified.

Run GalaxyCLI.parse() without saving the returned value to be uniform with the rest of the code.

Fix test_execute_remove to use the correct path

Use GalaxyCLI.run() instead of super(GalaxyCLI, gc).run() and GalaxyCLI.api = ansible.galaxy.api.GalaxyAPI(gc.galaxy).

* Refactor so one unit test checks one thing instead of multiple.

Improve readability by using a dict instead of lots of elifs

* Removing import used for debugging

* Fixing PEP 8 issues.

* Fix PEP 8 issues
2017-02-08 16:35:06 -05:00
Adrian Likins
df3e4cd7f4 Don't check for var._obj in template._clean_data (#20868)
* Don't check for var._obj in template._clean_data

AnsibleUnsafe or other unsafe vars used to have a
'_obj' slot but no longer do. This was causing attribute
errors if a object was 'unsafe' but not a string.

Add tests for AnsibleUnsafe, lookups, and AnsibleContext
2017-02-08 16:09:34 -05:00
Adrian Likins
e511326222 Fix 'yum skips updates' bug (#21113)
* Fix 'yum skips updates' bug

When the 'yum check-update' output is parsed, the regex used
to stitch wrapped lines together would fail on the first package.

It would fail because there is an empty line before the first
package, and this triggered the regex. To avoid a more complicated
regex, preprocess the check-update output to strip out any
empty lines.

The regex is also updated to include a group on the non whitespace
match to be used in the sub.

Add test cases based on info provided in the bug reports.

Fixes #20608
2017-02-08 16:07:43 -05:00
Matt Clay
1293ec85dd Convert unit test yield to pytest parametrize. 2017-02-08 12:56:23 -08:00
Matt Clay
46f9648aa1 Fix type() usage check in validate-modules.
This avoids false positives when 'if' or 'or' are in a string
preceding the use of type() on the same line.
2017-02-08 12:17:10 -08:00
Marius Gedminas
2efb692cc4 known_hosts: support --diff (#20349)
* known_hosts: support --diff

* known_hosts: support --diff also without --check

* Add unit tests and fix incorrect diff in one corner case

Tests are good!

* Refactor for readability

* Python 3 compat

* More Python 3 compat

* Add an integration test for known_hosts

* Handle ssh-keygen -HF returning non-zero exit code

AFAICT this is a bug in ssh-keygen in some newer OpenSSH versions
(>= 6.4 probably; see commit dd9d5cc670):
when you invoke ssh-keygen with -H and -F <host> options, it always
returns exit code 1.  This is because in ssh-keygen.c there's a function
do_known_hosts() which calls

  exit (find_host && !ctx.found_key);

at the end, and find_host is 1 (because we passed -F on the command line),
but ctx.found_key is always 0.  Why is found_key always 0?  Because the
callback passed to hostkeys_foreach(), which is known_hosts_hash(),
never bothers to set found_key to 1.

* This test does not need root

* Avoid ssh-ed25519 keys in sample known_hosts file

Older versions of OpenSSH do not like them and ssh-keygen -HF
aborts with an error when it sees such keys:

  line 5 invalid key: example.net...
  /root/ansible_testing/known_hosts is not a valid known_hosts file.

* Fix Python 3 errors

Specifically, the default mode of tempfile.NamedTemporaryFile is 'w+b',
which means Python 3 wants us to write bytes objects to it -- but the
keys we have are all unicode strings.
2017-02-08 09:56:03 -05:00
Gaurav Rastogi
798972c72a Avi Networks Ansible modules. (#20415)
* Avi Networks Ansible modules.
Avi Version: 16.3.4

* Fixed Review comments
1. Changed description to be full sentences
2. Fixed Pep8 warnings.
3. Fixed comments and descriptions.

* 1. Fixed descriptions and messages as per review comments.
2. Added descriptions for the missing parameters.

* Fixed the shippable break due to the incorrect description format

* Removed the extra modules so that there is a single module for the first commit

* Updated license to BSD based on review comments

* updated comments based on review feedback

* Refactored code to handle POST and PUT scenarios where playbook does not need to check whether object is present.
Moved ansible helper utilities to module_utils as now roles can be patched with module_utils as well.

* fixed pep8 warnings
2017-02-08 09:47:18 -05:00
Matt Clay
f16ee2841b Add retries to Shippable CI scripts. (#21108)
* Add retry.py for auto-retry in CI scripts.
* Add retries to other and units CI scripts.
2017-02-07 16:33:45 -08:00
Matt Clay
189fee4853 Fix vyos unit tests. 2017-02-07 15:21:34 -08:00
Ricardo Carrillo Cruz
0adca6b7d4 Set block indentation to 1 on iosxr templates (#21105)
Network devices in the lab have by default an indentation of 1 for
sub-sections, and so does the netcfg.NetworkConfig constructor
indent param.
This will fix reported issue 21055, and make the integration tests
to pass.

Fixes #21055
2017-02-07 21:13:20 +01:00
Adrian Likins
174961b945 Fix action test (#21102)
* update _parse_returned_data for no _ansible_parsed

_parse_returned_data no longer adds _ansible_parsed

* pep8 cleanups
2017-02-07 13:35:51 -05:00
Adrian Likins
7278308ca2 Redhat subscription (#20729)
* Make unused redhat_subscriptions do something

rhsm_baseurl/server_insecure were module params that were
never used previously. Hook them up for register options.

* pep8/style cleanups
* Set a module scope SUBMAN_CMD before we ref it as a global
* move ansible imports to top, remove '*' imports
* remove redhat_subscriptions from pep8 legacy
2017-02-07 12:07:01 -05:00
Nathaniel Case
530701b398 Vyos system module (#21060)
* vyos_system tests

* Merge vyos_system fixture with vyos_config fixture
2017-02-07 12:04:14 -05:00
Adrian Likins
5766689dd5 More unit tests for plugins/action/ (#20887) 2017-02-07 11:42:03 -05:00
Matt Martz
5942de603d Legacy pep8 clean fixes for contrib and hacking (#21081) 2017-02-07 09:49:55 -06:00
Brian Coca
c86a17b7a0 refactoring async
- centralized skipping
- also fixed module name broken by previous refactor
- let action modules handle async processing
- moved async into base action class's module exec
- action plugins can now run final action as async
- actually skip copy if base skips
- fixed normal for new paths
- ensure internal stat is never async
- default poll to 10 as per docs
- added hint for callback fix on poll
- restructured late tmp, now a pipeline query
- moving action handler to connection as networking does
- fixed network assumption invocation is always passed
- centralized key cleanup, normalized internal var
- _supress_tmpdir_delete now in _ansible_xxx and gets removed from results
- delay internal key removal till after we use em
- nicer tmp removing, using existing methods
- moved cleanup tmp flag to mking tmp func
2017-02-06 19:32:00 -05:00
Matt Clay
bce5fc7d96 Use us-east-2 for Windows CI on Shippable. 2017-02-06 15:01:20 -08:00
Ricardo Carrillo Cruz
375846d764 Refactor iosxr_facts to use network_cli plugin (#20857) 2017-02-06 22:23:17 +01:00
Loïc Blot
b55d039f67 New modules: vmware_guest_facts & vmware_guest_snapshot (#20971)
* Move gather_facts action outside of vmware_guest module
* Move facts gathering method to vmware.py library
* vmware_guest use some vmware.py library methods
* vmware.py lib: fix some PEP 8 issues
* Move snapshot actions to vmware_guest_snapshot
* Move common snapshot facts to vmware.py library
2017-02-06 11:52:17 -05:00
John R Barker
25e144db4a Update legacy-files.txt 2017-02-06 16:05:06 +00:00
John R Barker
0ea3911d47 module_utils/vmware.py is now clean 2017-02-06 16:01:10 +00:00
Matt Clay
272ff10fa1 Fix @contextmanager leak on exception. (#21031)
* Fix @contextmanager leak on exception.
* Fix test leaks of global module args cache.
2017-02-03 17:19:59 -08:00
Matt Clay
ccb1b742f5 Fix win_stat test for changes from PR #20876
The changes to win_file in that PR resulted in changes to file
sizes and file hashes expected by the win_stat tests.
2017-02-03 12:58:11 -08:00
Brian Coca
a2c38c47aa added docs for vault and made trigger shorter: !vault (#20985)
* added docs for vault and made trigger shorter: !vault

* added single var valuting

* Update playbooks_vault.rst

Edit pass for spelling and grammar. Ship it!

* Update playbooks_vault.rst

Typo fixes.
2017-02-03 15:28:50 -05:00
Toshio Kuratomi
d1a6b07fe1 Move ssh and local connection plugins from using raw select to selectors
At the moment, this change will use EPoll on Linux, KQueue on *BSDs,
etc, so it should alleviate problems with too many open file
descriptors.

* Bundle a copy of selectors2 so that we have the selectors API everywhere.
* Add licensing information to selectors2 file so it's clear what the
  licensing terms and conditions are.
* Exclude the bundled copy of selectors2 from our boilerplate code-smell test
* Rewrite ssh_run tests to attempt to work around problem with mocking
  select on shippable

Fixes #14143
2017-02-03 08:23:50 -08:00
jhawkesworth
2c70450e23 Fix 'touch' mode so it creates zero size files. (#20876) 2017-02-03 13:36:47 +01:00
Peter Sprygada
d226f31a0f fixes ios and eos command modules (#20989)
* returns support for prompt/response over cli
* now sends native dict instead of str command
* fixes issue with run_commands() in ios to jsonify request
* updates unit test cases
2017-02-02 22:10:14 -05:00
Toshio Kuratomi
1df7d95cec Module utils default path (#20913)
* Make the module_utils path configurable
* Add a config value to define the path site module_utils files
* Handle module_utils that do not have source as an error
* Make an integration test for module_utils envvar working
* Add documentation for the ANSIBLE_MODULE_UTILS config option/envvar
* Add it to the sample ansible.cfg
* Add it to intro_configuration.
* Also modify intro_configuration to place envvars on equal footing with
  the config options (will need to document the envvar names in the
  future)
* Also add the ANSIBLE_LIBRARY use case from
  https://github.com/ansible/ansible/issues/15432 so we can close out
  that bug.
2017-02-02 17:48:53 -08:00
Matt Clay
6580fb2cd1 Fix exception in module validator. 2017-02-02 17:38:16 -08:00
Matt Martz
829c0b8f62 Update validate-modules (#20932)
* Update validate-modules

* Validates ANSIBLE_METADATA
* Ensures imports happen after documentation vars
* Some pep8 cleanup

* Clean up some left over unneeded code

* Update modules for new module guidelines and validate-modules checks

* Update imports for ec2_vpc_route_table and ec2_vpc_nat_gateway
2017-02-02 11:45:22 -08:00
Nathaniel Case
1718719d77 vyos_facts 2.3 (#20939)
* Update vyos_facts documentation

* Replace runner for run_commands

* vyos_facts tests

* Update documentation

* vyos_facts is supported by core
2017-02-02 14:45:06 -05:00
Brian Coca
6ca5fb49c3 allow debug to be 'changed' (#20957)
* allow debug to be 'changed'

fixes #14430

* removed test that checked against this
2017-02-02 13:46:16 -05:00
Nathaniel Case
d87fc9605f vyos_config 2.3 (#20577)
* Rename vyos2 over vyos

* Update vyos_config to LocalAnsibleModule

Change result key 'updates' -> 'commands'

vyos_config is supported by core

* vyos_config tests

* Enable bracket config use

* Sanitize config before use
2017-02-02 13:12:26 -05:00
Stephane Maarek
c33812450e fixed type mapper and added tests (#20963) 2017-02-02 09:46:17 -05:00
Dag Wieers
3dbce15ccb win_shortcut: Add missing $check_mode definition + bugfix + tests (#20911)
* win_shortcut: Add missing $check_mode definition

For some reason this entry was missing, possible a merge-conflict gone
wrong :-(

* Added integration tests and bugfix

Add missing changes.
2017-02-02 10:29:56 +01:00
Matt Clay
309a37de86 Add --debug option to ansible-test. 2017-02-01 16:05:03 -08:00
Matt Clay
64f98f855d Update PEP 8 legacy files list. 2017-02-01 13:22:07 -08:00
Dag Wieers
bbe2903d63 Fix broken Shippable 2017-01-31 16:47:16 -08:00
John R Barker
553b6151ad iosxr tests: Initial work for 2.3 (#20883)
Ensure a loopback device exists for testing
Remove provider:
Default is to run task on Network, device, use delegate_to: localhost for local tasks.
2017-01-31 19:10:14 +00:00
Vlad Glagolev
039d207d24 Add Source Mage GNU/Linux facts (#19671)
* Add Source Mage GNU/Linux facts

* Add unit test for OS-detection
2017-01-31 13:25:36 -05:00
Toshio Kuratomi
5c38f3cea2 Combine jimi-c and bcoca's ideas and work on hooking module-utils into PluginLoader.
This version just gets the relevant paths from PluginLoader and then
uses the existing imp.find_plugin() calls in the AnsiballZ code to load
the proper module_utils.

Modify PluginLoader to optionally omit subdirectories (module_utils
needs to operate on top level dirs, not on subdirs because it has
a hierarchical namespace whereas all other plugins use a flat
namespace).

Rename snippet* variables to module_utils*

Add a small number of unittests for recursive_finder

Add a larger number of integration tests to demonstrate that
module_utils is working.

Whitelist module-style shebang in test target library dirs

Prefix module_data variable with b_ to be clear that it holds bytes data
2017-01-31 09:41:24 -08:00
sebastianneubauer
3f14061584 s3 module: fix urlparse invocation and netloc mixup on Python 3 (#20836) 2017-01-31 11:54:29 -05:00
Matt Clay
503e85ed0e PEP 8 E111 cleanup. 2017-01-30 20:33:31 -08:00
Matt Clay
f80224f828 PEP 8 E111 cleanup. 2017-01-30 20:18:50 -08:00
Matt Clay
85300883ef PEP 8 E111 cleanup. 2017-01-30 20:17:35 -08:00
Matt Clay
23f2efbc8d PEP 8 E111 cleanup. (#20841) 2017-01-30 18:03:13 -08:00
Matt Clay
462ab6b1db PEP 8 E111 cleanup for nxos modules. 2017-01-30 15:45:05 -08:00
Matt Clay
cb76200c7d PEP 8 E111 & E114 cleanup. (#20838) 2017-01-30 15:01:47 -08:00
Toshio Kuratomi
1609afbd12 Unittests for some of module_common.py (#20812)
* Unittests for some of module_common.py
* Port test_run_command to use pytest-mock

The use of addCleanup(patch.stopall) from the unittest idiom was
conflicting with the pytest-mock idiom of closing all patches
automatically.  Switching to pytest-mock ensures that the patches are
closed and removing the stopall stops the conflict.
2017-01-30 13:51:27 -08:00
Wayne Witzel III
0e72f3bd71 Ansible Tower organization module (#20355)
* add Ansible Tower organization module

* skip Python 2.4 check for ansible_tower module

* make spec and doc match, extract tower auth helper method

* added auth params at module level

* support check mode

* extract check mode check to ansible_tower utils, add utils to 2.4 skip

* update interpreter shebang

* remove colon from docs

* no log for password, verify_ssl default to true
2017-01-30 13:42:32 -05:00
Ricardo Carrillo Cruz
e70bc06ea1 Refactor iosxr_command to make use of network_connection plugin (#20772) 2017-01-30 17:52:19 +01:00
Peter Sprygada
a4a5db56f6 updates python2.4-skip
* adds module_utils/netconf.py
* adds module_utils/junos.py
2017-01-30 10:54:25 -05:00
Matt Clay
10d9318de7 PEP 8 indent cleanup. (#20800)
* PEP 8 E121 cleanup.

* PEP 8 E126 cleanup.

* PEP 8 E122 cleanup.
2017-01-29 07:28:53 +00:00
Peter Sprygada
85d78390f9 adds new module eos_system (#20797)
* provides declarative resource for configuring eos system parameters
* supports network_cli connection plugin only
* adds unit tests for module using mock interfaces
2017-01-28 11:07:51 -05:00
Peter Sprygada
d2dd2fbe49 adds module eos_banner (#20796)
* new module allows for configuration of eos multiline banners
* adds unit test cases for module
2017-01-28 10:32:04 -05:00
Matt Clay
e2c0b375d3 PEP 8 cleanup. (#20790)
* PEP 8 E115 cleanup.
* PEP 8 E131 cleanup.
2017-01-28 01:39:40 -08:00
Matt Clay
d0d1158c5e PEP 8 cleanup. (#20789)
* PEP 8 E703 cleanup.
* PEP 8 E701 cleanup.
* PEP 8 E711 cleanup.
* PEP 8 W191 and E101 cleanup.
2017-01-28 00:12:11 -08:00
Matt Clay
d913f69ba1 PEP 8 W291 whitespace cleanup. 2017-01-27 17:08:02 -08:00
Matt Clay
95789f3949 PEP 8 whitespace cleanup. (#20783)
* PEP 8 E271 whitespace cleanup.
* PEP 8 W293 whitespace cleanup.
* Fix whitespace issue from recent PR.
2017-01-27 15:45:23 -08:00
Jordan Borean
971783a7fd Feature/win stat extra info (#19148)
* Added more return results to win_stat

* Changed Win2012 methods to support older versions in setup

* staging of the tests to work with older servers
2017-01-27 14:51:12 -08:00
Matt Clay
63b1e0c277 Fix infrequent PEP 8 issues. 2017-01-27 14:06:21 -08:00
Peter Sprygada
6c89c587cc refactors eos_config module to use network_cli (#20741)
* update eos_config to use eapi exclusively and remove cli transport
* add unit test cases for eos_config
* updates action plugin to handle both eapi and network_cli connections
2017-01-27 16:23:18 -05:00
Matt Clay
6ef1a6aeb6 Add pep8 to ansible-test. (#20745)
The rule sets and legacy file list are a first draft.
It is likely that they will need to be revised.
2017-01-27 12:34:00 -08:00
Dag Wieers
3a0a74dc18 Make test/runner less verbose when spawning instances
As discussed on IRC
2017-01-27 12:27:46 -08:00
Matt Clay
f42fa8879b Temporarily remove Windows Server 2016 from CI. 2017-01-27 11:56:50 -08:00
Peter Sprygada
271c0c4574 new module eos_user (#20759)
* adds new module for managing local user accounts on eos devices
* adds unit test cases for module

This module only supports network_cli
2017-01-27 14:12:36 -05:00
Trond Hindenes
679a3cb1cc Merge pull request #20599 from dagwieers/win_regedit-cleanup
win_regedit: Cleanup, check/diff mode support, HKCC fix
2017-01-27 18:09:27 +01:00
Peter Sprygada
c8dcc7f5d6 refactors eos_command module (#20739)
* eos_command now uses network_cli connection plugin
* adds unit test cases for eos_command module
2017-01-27 08:45:13 -05:00
Peter Sprygada
57660abf33 refactor eos_eapi module (#20740)
* eos_eapi module now requires network_cli plugin
* adds unit test cases for eos_eapi module
2017-01-27 08:44:57 -05:00
Peter Sprygada
ad83756b48 updates eos shared modules (#20738)
* eos module now uses network_cli connection plugin
* adds unit tests for eos module
* eapi support now provided by eapi module
* updates doc fragment for eapi common properties
2017-01-26 23:33:07 -05:00
Matt Clay
5503b89831 Run fewer tests for winrm config script changes. 2017-01-26 15:54:01 -08:00
Tom Melendez
c2edc8a264 [GCE] Google Cloud Pubsub Module (#19091)
* Google Cloud Pubsub Module

The Google Cloud Pubsub module allows the Ansible user to:
* Create/Delete Topics
* Create/Delete Subscriptions
* Change subscription from pull to push (and configure endpoint)
* Publish messages to a topic
* Pull messages from a Subscription

An accessory module, gcpubsub_facts, has been added to list topics and subscriptions.

* Added docs for state field to DOCUMENTATION and RETURN blocks.
2017-01-26 16:16:52 -05:00
Dag Wieers
0e80ba1867 Fix the integration test to comply recent changes 2017-01-26 20:06:46 +01:00
Matt Clay
76d563af79 Temporarily switch Windows tests to us-east-1.
Will switch back to us-east-2 after AWS limit increase is done.
2017-01-26 07:37:14 -08:00
Matt Clay
31d6b6ef67 Run postgresql tests on FreeBSD. (#20676)
* Use vars for user, group and locale suffix.
* Switch tests from `es_MX` to `es_ES`.
* Enable postgresql tests on freebsd.
* Work-arounds for service restart on freebsd.
2017-01-25 18:45:28 -08:00
Matt Clay
5d5e5e25a2 Only set git config during test if unset.
This makes the git test less destructive.
2017-01-25 18:05:17 -08:00
Ganesh Nalawade
b67f50570e Add unit testcase for junos_command module (#20034)
* Add unit testcase for junos_command module
* Mock third party module import
* Remove third party module requirements
2017-01-25 10:31:28 -05:00
Peter Sprygada
8ddffcb1a6 new connection plugin netconf (#20636)
* adds connection plugin for creating modules that use netconf
* adds basic unit test cases for connection plugin
2017-01-25 10:15:26 -05:00
Patrick Ogenstad
ac527ef86f Check for removal not allowed errors (#19251) 2017-01-25 13:05:44 +00:00
Ricardo Carrillo Cruz
b44505e281 Merge pull request #20559 from rcarrillocruz/refactor_ios_config_network_connection
Refactor iosxr_config to make use of network_connection plugin
2017-01-25 13:26:13 +01:00
Matt Clay
d8b18d79fa Disable assertions that fail on WS 2016. 2017-01-24 20:08:50 -08:00
Matt Clay
d6cdd91511 Remove win_fetch from CI due to instability. 2017-01-24 17:33:11 -08:00
Ricardo Carrillo Cruz
a8cfe4a5d7 Refactor iosxr_config to make use of network_connection plugin 2017-01-24 23:24:06 +01:00
Ansible Test Runner
ff1a732ffd Increase timeout for http server in uri test. 2017-01-24 14:20:19 -08:00
Matt Clay
fa7f84217b Add startup checks to ansible-test. 2017-01-24 13:08:04 -08:00
Ricardo Carrillo Cruz
034330e52f Fix typo on test_ios_config_before_after_no_change test (#20565) 2017-01-24 11:16:16 -05:00
Matt Clay
836e0b59d2 Fix git remote url change detection. (#20587)
* Fix git remote url change detection.

When comparing paths, unfrackgitpath must be called on both sides
of the comparison. Otherwise comparisons involving symlinks will
return incorrect results.

* Re-enable git test on OS X.

* Return None from unfrackgitpath when path is None.
2017-01-23 16:09:42 -08:00
Nathaniel Case
b3662fdad1 vyos_command 2.3 (#18994)
* Peter's new module_utils/vyos
* Update vyos_command
* Restore `set terminal length $ANSIBLE_VYOS_TERMINAL_LENGTH` in vyos
* vyos_command tests
* Remove provider mentions from vyos_command
* Extend get_config to take (and cache) various `show configuration` commands
2017-01-23 15:30:19 -05:00
Matt Clay
61e6e7868c Improve jinja2 test coverage. (#20533)
* Run `template` test on latest jinja2 version.
* Update jinja2 install for groupby_filter.
* Clean test output dir for each test.
2017-01-20 16:38:52 -08:00
Matt Clay
d87ee022bb Enable more ios tests on Shippable. 2017-01-20 13:26:59 -08:00
John R Barker
11c15bbbaf Disable IOS tests for the moment (#20524) 2017-01-20 20:24:54 +00:00
John R Barker
a12033a6e0 integration/targets/ios_* work to support IOS (#20414)
* WIP

* Don't set connection: network_cli in the playbook

* ios_config tests now passing

* Create test loopback device

* delete

* ios_* pass (apart from ios_facts)

* Remove provider lines
2017-01-20 20:18:12 +00:00
John R Barker
7330ab8062 Correctly call get_config (#20452)
* Correctly call get_config

* remove debug

* Check for empty flags and LocalAnsibleModule

* Peter's feedback
2017-01-20 20:17:35 +00:00
James Cammarata
188c3c608a Don't restrict local jinja2 variables to those that start with l_
Per a change in jinja2 2.9, local variables no longer are prefixed
with l_, so this updates AnsibleJ2Vars to pull in all locals (while
excluding some) regardless of name.

Fixes #20063

(cherry picked from commit 4d49b317929b86e1fc1b0cbace825ff73b372dc7)
2017-01-20 07:15:51 -06:00
Matt Clay
9213d0c5b0 Fix and enable more tests for osx and freebsd. (#20482)
* Fix `iterators` test for osx.
* Enable `git` test for osx.
* Enable `get_url` test for osx and freebsd.
* Remove unused SNI_URI from uri test.
* Use ansible hosted SNI host oustside docker.
* Enable `uri` test for osx and freebsd.
* Enable `gathering_facts` test for osx.
* Skip single task on osx until test is fixed.
2017-01-19 17:10:33 -08:00
Matt Martz
537b3b75a6 Add jinja2 groupby filter override to cast namedtuple to tuple. Fixes #20098 (#20362)
* Add jinja2 groupby filter override to cast namedtuple to tuple. Fixes #20098

* Address some of the requested changes

* Quoting

* Print the python path and version

* Be less explicitly verbose, rely on implicit verbosity
2017-01-19 11:39:59 -08:00
Matt Clay
a8fb6f0958 Use jinja2 import instead of pip to get version.
This resolves issues with older versions of pip.
2017-01-19 11:06:47 -08:00
Andrew Gaffney
ac51266e8f Add pipeline-ish method using dd for file transfer over SSH (#18642) 2017-01-19 12:31:14 -05:00
James Cammarata
9d549c3498 Fixing iterator bug related to reworking of end-of-role detection
Bug was introduced in cae682607
2017-01-19 10:10:07 -06:00
Matt Clay
7ed67746cf Enable Windows 2016 on Shippable.
Also launch Windows instances on us-east-2 and all others on us-east-1.
2017-01-18 18:37:42 -08:00
Matt Clay
4ba9f63afe Use multiple AWS regions in ansible-test. (#20429)
* Move ansible-test EnvironmentConfig to util.
* Use multiple AWS regions in ansible-test.
2017-01-18 16:31:34 -08:00
James Cammarata
cae682607c Reworking the way end of role detection is done
Rather than trying to enumerate tasks or track an ever changing cur_role
flag in PlayIterator, this change simply sets a flag on the last block in
the list of blocks returned by Role.compile(). The PlayIterator then checks
for that flag when the cur_block number is incremented, and marks the role
as complete if the given host had any tasks run in that role.

Fixes #20224
2017-01-18 17:29:52 -06:00
Matt Clay
4673a9c9c2 Generate ssh key once for network tests. 2017-01-18 13:33:12 -08:00
Matt Clay
4c97bad28e Update ansible-test network change classification. 2017-01-18 12:19:31 -08:00
Matt Davis
b2a16379c8 new module: win_path (#20073) 2017-01-17 20:21:04 -08:00
Matt Clay
89898ed734 Update coverage constraints for ansible-test. 2017-01-17 17:24:54 -08:00
Matt Clay
3c51ce56fd Enable more network support in ansible-test. (#20372)
* Only start platform instances with tests selected.
* Enable ios on Shippable.
* Show inventory in explain mode.
* Fix indentation of generated network inventory.
* Update classification of network module_utils.
2017-01-17 16:24:05 -08:00
gaudenz
08e08ac775 new module cloudscale_server (#20175) 2017-01-17 23:15:20 +01:00
Ricardo Carrillo Cruz
825456f279 Merge pull request #20363 from rcarrillocruz/iosxr_template_network_cli
Refactor iosxr_template to network_cli plugin
2017-01-17 20:57:30 +01:00
David M. Lee
fde551fa2a Adding support for Amazon ECR (#19306)
* Adding support for Amazon ECR

This patch adds a new module named ecr, which can create, update or
destroy Amazon EC2 Container Registries. It also handles the management
of ECR policies.

* ecs_ecr: addressed review feeback

 * Renaming ecr to ecs_ecr
 * Fixed docs
   * Removed bad doc about empty string handling
   * Added example of `delete_policy`
 * Removed `policy_text` option; switched policy to `json` type so
   it can accept string or dict
 * Added support for specifying registry_id
 * Added explicit else after returned if clauses
 * Added `force_set_policy` option
 * Improved `set_repository_policy` error handling
 * Fixed policy comparisons when AWS doesn't keep the ordering stable
 * Moved `boto_exception` into the module
2017-01-17 14:45:43 -05:00
Ricardo Carrillo Cruz
ae630fff56 Refactor iosxr_template to network_cli plugin 2017-01-17 20:01:56 +01:00
John R Barker
64432c8f7c WIP: net_command: Initial tests for VyOS (#20147)
* Conditional include on ansible_network_os

* copy & paste error

* More tests

* More tests

* junos tests (based on vyos)

* remove excessive whitespace

* Pass in ansible_network_os

* net_command for ios

* consistent debug

* wrapp line

* ansible-test changes made in another PR

* ansible-test changes made in another PR
2017-01-17 11:06:34 +00:00
Matt Clay
893e2e0d35 Use ansible-test in integration test README. 2017-01-16 19:01:59 -08:00
Matt Clay
dbb89549ff Improve ansible-test error handling and timeouts. (#20328)
* Eliminate warning/retry on old instance check.
* Increase instance start timeout for windows.
2017-01-16 18:59:44 -08:00
Matt Clay
55b9a11468 Require coverage < 4.3.2 to avoid bugs. 2017-01-16 18:00:55 -08:00
Matt Clay
34bca6fb55 Use distro packaged jinja2 instead of pip version. 2017-01-16 15:52:43 -08:00
Matt Clay
b5d5888b6e Add support for ios to ansible-test. 2017-01-16 15:05:56 -08:00
Matt Clay
ad65274643 Only test map on jinja2 >= 2.7 2017-01-16 13:41:42 -08:00
Toshio Kuratomi
32fbd4ba24 Test the extract filter without the map filter.
map + extract is the usual way to use it but map isn't available on
older versions of jinja2 that we still work with.  Test extract even on
those versions.
2017-01-16 13:13:34 -08:00
Matt Clay
e2bd71ac02 Clean up inventory generation in ansible-test. (#20313) 2017-01-16 12:31:17 -08:00
Matt Clay
a59ce3a7f9 Add retry on failure to get instance. 2017-01-13 18:35:28 -08:00
Matt Clay
f3130898bb Retry instance start on error. 2017-01-13 16:49:30 -08:00
Matt Clay
203e375449 Fix python 3.6 install. 2017-01-13 15:30:27 -08:00
Matt Martz
d25a70846f Only add Content-Type if not specified in headers. Fixes #20046 (#20234)
* Only add Content-Type if not specified in headers. Fixes #20046

* Update documentation to indicate body_format will not override Content-Type if specified in headers
2017-01-13 13:19:38 -05:00
Matt Clay
f534573dcf Enable first network tests on Shippable. (#20208) 2017-01-12 18:23:53 -08:00
berenddeschouwer
b1c57ea443 Installroot OS version check fix (#20180)
Cast to int before checking the OS version.
This prevents the DNF tests from running on
Fedora < 23
2017-01-12 18:02:35 -08:00
Matt Clay
d8733a5455 Complete initial network-integration support. 2017-01-12 12:39:00 -08:00
Alvaro Aleman
1b2ad94496 Configurable fact path (#18147)
* Make fact_path configurable

* Add docs for fact_path

* Add tests for localfacts

* Default fact gathering settings in PlayContext
2017-01-12 10:49:04 -05:00
Peter Sprygada
4cdb266dac adds iosxr_system declarative module (#20134)
* adds new module iosxr_system
* adds unit test cases for module
2017-01-11 17:17:37 -05:00
Matt Clay
cd3fdca540 Switch tests to pytest and ansible-test.
- Replace nose usage with pytest.
- Remove legacy Shippable integration.sh.
- Update Makefile to use pytest and ansible-test.
- Convert most yield unit tests to pytest parametrize.
2017-01-11 12:34:59 -08:00
Robin Roth
4976429e42 Zypper: Fix update_cache in checkmode (#20143)
Fixes #20139

Refresh does not support dry-run, so don't run it in check mode.
Also add a test for this case.
2017-01-11 18:47:16 +00:00
Matt Clay
300181cfd3 Send current winrm config to ansible-core-ci. 2017-01-10 20:05:47 -08:00
Matt Clay
f340b8d14f Add test support for python 3.6. 2017-01-10 14:34:42 -08:00
John R Barker
ec36b4968c Junos aws (#20083)
* junos Use inventory_hostname_short
* Basic Test for validating VyOS bringup in AWS
2017-01-10 11:11:00 -08:00
Matt Clay
cc3d131f50 Fix group_by test to work with jinja2 >= 2.9. 2017-01-09 15:20:34 -08:00
Marius Gedminas
d9b89ca577 Fix a test failure on Python 3.6 (#20030)
* Fix a test failure on Python 3.6

tox -e py36 failed with

    ======================================================================
    ERROR: test_action_base__execute_module (units.plugins.action.test_action.TestActionBase)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/mg/src/ansible/test/units/plugins/action/test_action.py", line 507, in test_action_base__execute_module
        self.assertEqual(action_base._execute_module(), dict(_ansible_parsed=True, rc=0, stdout="ok", stdout_lines=['ok']))
      File "/home/mg/src/ansible/lib/ansible/plugins/action/__init__.py", line 596, in _execute_module
        remote_module_path = self._connection._shell.join_path(tmp, remote_module_filename)
      File "/home/mg/opt/python36/lib/python3.6/unittest/mock.py", line 939, in __call__
        return _mock_self._mock_call(*args, **kwargs)
      File "/home/mg/opt/python36/lib/python3.6/unittest/mock.py", line 1005, in _mock_call
        ret_val = effect(*args, **kwargs)
      File "/home/mg/src/ansible/.tox/py36/lib/python3.6/posixpath.py", line 92, in join
        genericpath._check_arg_types('join', a, *p)
      File "/home/mg/src/ansible/.tox/py36/lib/python3.6/genericpath.py", line 149, in _check_arg_types
        (funcname, s.__class__.__name__)) from None
    TypeError: join() argument must be str or bytes, not 'MagicMock'

because os.path.join() now checks argument types since Python 3.6 (due
to pathlib support, I expect).

* Use a more realistic module name in test
2017-01-09 12:42:30 -08:00
John R Barker
b8ee80ac4e junos Use inventory_hostname_short (#20061)
Don't use hardcoded hostnames
2017-01-09 20:15:16 +00:00
Steve Bussetti
8a8090e658 test related to pulls: #19257 / #19057 (#19346) 2017-01-09 12:08:56 -08:00
Ganesh Nalawade
0305da6d6a Fix ios_command unit testcase (#20031) 2017-01-09 12:28:32 -05:00
John R Barker
fb3bef7f46 Use inventory_hostname_short (#20054)
When using AWS we have to use the full domain name in the inventory file, which
we rather than the short name. This change avoids that ending up being
set in the tests.
2017-01-09 17:21:04 +00:00
Marius Gedminas
0a7f2c202b Improve --diff output when files lack trailing newlines
The behavior now matches GNU diff.

Fixes #14094.

Example of output before this change:

    TASK [healthchecks.io : hourly healthchecks.io ping] ***************************
    changed: [ranka]
    --- before: /etc/cron.hourly/mg-healthchecks-dot-io
    +++ after: /tmp/tmpOTvXTw
    @@ -1,2 +1,2 @@
     #!/bin/sh
    -curl -sS https://hchk.io/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx > /dev/null+curl -sS https://hchk.io/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx > /dev/null

after this change:

    TASK [healthchecks.io : hourly healthchecks.io ping] ***************************
    changed: [ranka]
    --- before: /etc/cron.hourly/mg-healthchecks-dot-io
    +++ after: /tmp/tmpOTvXTw
    @@ -1,2 +1,2 @@
     #!/bin/sh
    -curl -sS https://hchk.io/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx > /dev/null
    \ No newline at end of file
    +curl -sS https://hchk.io/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx > /dev/null

The added unit tests contain more examples.

This commit also takes care to avoid "no newline at EOF" warnings when
no_log is in effect, and also when modules return dicts rather than
strings.  (It also removes trailing whitespace from using json
serialization when diffing dicts, because I hate trailing whitespace in
Python source files, even if they're test files.)
2017-01-09 11:49:03 -05:00
Peter Sprygada
258c6ada52 refactors ios_config to use network_cli plugin (#20042)
* updates the ios_config module to use the network_cli plugin
* updates the local action plugin to derive from network
* add unit test cases for ios_config
2017-01-09 11:19:25 -05:00
Peter Sprygada
63fbc1a764 adds missing __init__ to ios unit test 2017-01-08 23:07:30 -05:00
Matt Clay
7ba47bfd2d Correct test constraints and add sanity check. 2017-01-08 16:44:31 -08:00
Matt Clay
07c68571b6 Require jinja2 < 2.9 until tests pass on 2.9. 2017-01-08 00:59:56 -08:00
Matt Clay
3ec7243918 Run all win tests for winrm config script changes. 2017-01-08 00:57:51 -08:00