Commit graph

7528 commits

Author SHA1 Message Date
Nathaniel Case
f4a6fa1747 Rewrite asa.py for NetworkModule 2016-08-22 18:11:52 -04:00
Toshio Kuratomi
384a01fcff Fix tmpfile misspelled as tmplfile (#17183) 2016-08-22 11:31:42 -07:00
Adrian Likins
a4785c2691 Fix docker connection plugin version tests and py2.6 compat (#16841)
* Rm py2.7+ code in docker connection plugin

The docker connection plugin was using subprocess.check_output
which only exists in python 2.7 and later. Connection plugins
need to support python2.6 so this replaces it with Popen/communicate()

* Handle docker ver errors in docker connection

Add unit tests for DockerConnection

Fixes #16971
2016-08-22 10:39:38 -04:00
Peter Sprygada
7ce4165671 Merge pull request #17173 from privateip/ios
minor update to the ios shared module
2016-08-22 10:35:27 -04:00
Peter Sprygada
301495ddcc Merge pull request #17172 from privateip/nxos
updates nxos shared module refactor
2016-08-22 10:35:17 -04:00
Brian Coca
54c530a3ee more ways to detect lxc
thanks to @wAmpire for new method and pointing out limitations of existing
2016-08-22 08:45:36 -04:00
Peter Sprygada
1015f11428 minor update to the ios shared module
This completes the refactor for the ios shared module to change
the derived class from NetCli to CliBase.
2016-08-21 08:59:59 -04:00
Peter Sprygada
4ab4b6698d updates nxos shared module refactor
This commit updates the nxos transport shared plugins for
2.2.  This includes updates to both Cli and Nxapi.  This commit
also includes the nxos_config action plugin
2016-08-21 08:57:49 -04:00
Peter Sprygada
321d2e8cee Merge pull request #17168 from privateip/clibase
replaces NetCli in network with CliBase in shell
2016-08-20 17:29:53 -04:00
Peter Sprygada
044a0533db replaces NetCli in network with CliBase in shell
This doesn't change any of the behavior but moves NetCli to CliBase and
relcates the object to the shell module
2016-08-20 13:55:07 -04:00
Toshio Kuratomi
171a094805 Cleanup basic.py code now that six is available (#17158)
* Cleanup basic.py code now that six is available

We had some hacks in basic.py to allow us python2 and python3
compatibility.  Those can now be offloaded to the six library that we're
bundling.

* Cleanup basic.py code now that six is available

We had some hacks in basic.py to allow us python2 and python3
compatibility.  Those can now be offloaded to the six library that we're
bundling.
2016-08-20 08:08:59 -07:00
Peter Sprygada
959a5e5fd1 Merge pull request #17166 from privateip/ios
fix import statement in ios shared module
2016-08-20 09:30:06 -04:00
Peter Sprygada
388f98437e Merge pull request #17165 from privateip/network
fix broken import statement from netcli rename
2016-08-20 09:29:55 -04:00
Peter Sprygada
53abcb23fa rename netcmd module to netcli
This is part of the 2.2 refactor to extract the Cli class into a
separate module.  This renames netcmd to netcli which is consistent
with the network shared modules implementations
2016-08-20 08:45:53 -04:00
Peter Sprygada
7cb2c31b1a fix import statement in ios shared module
This fixes the import statement when netcmd was renamed to netcli
2016-08-20 08:22:13 -04:00
Peter Sprygada
ac8b8f0b8b fix broken import statement from netcli rename
The network module needed to be updated with the correct module name
when netcmd was renamed to netcli
2016-08-20 08:19:08 -04:00
Peter Sprygada
f53dbec55a removes Cli and Config objects from network into separate modules
This completes the refactor of Cli and Config moving them into separate
modules netcmd and netcfg respectively.
2016-08-20 07:57:39 -04:00
Peter Sprygada
24c6443557 removes functions from ios module
This removes top level functions from the ios module and moves them
into the specific modules.  This update also includes some clean up
of the Cli transport
2016-08-20 07:27:47 -04:00
Peter Sprygada
90747e6d2f Merge pull request #17161 from privateip/netcmd
moves Cli and Command class from network to netcmd module
2016-08-20 07:25:08 -04:00
Peter Sprygada
7c928e878b moves Cli and Command class from network to netcmd module
This restructure moves the Cli object to netcmd and includes a roll up
of inor bugfix updates to CommandRunner

* CommandRunner now only allows one instance of a command in the stack and
  raise an exception if a duplidate command is detected
* CommandRunner now caches returns based on command and output
* CommandRunner is not responsible for creating Command instances
2016-08-20 06:57:13 -04:00
Adrian Likins
7d41f623dd Move py34 mock_open compat to compat/test/mock (#17157)
test/units/plugins/action/test_action.py had code
for handling a bug in python 3.4's mock_open that
causes errors when reading binary data.

Moved to compat/tests/mock.py so other tests can
use it by default.
2016-08-19 18:11:24 -04:00
Peter Sprygada
fa395bee7b Merge pull request #17149 from privateip/plugin-net-config
action plugin net_config will now remove any private result key
2016-08-19 11:48:00 -04:00
Peter Sprygada
d50ef4446f action plugin net_config will now remove any private result key
This update will now remove any keys from results that are created using
the private names.  Private names are identified as double underscore (__)
on either side of the key name
2016-08-19 11:15:36 -04:00
Peter Sprygada
112f14866a pull Config object out of network and into netcfg
This moves the Config class from network and into netcfg module with
no added features.  This is simply a reorganization of code.
2016-08-19 11:15:01 -04:00
Dusty Mabe
b817f1f3ea actions/unarchive: fix unarchive from remote url (#17126)
* actions/unarchive: fix unarchive from remote url

Currently unarchive from remote url does not work because the core
unarchive module was updated to support 'remote_src' [1], but the
unarchive action plugin was not updated for this. This causes failures
because the action plugin assumes it needs to copy a file to the
remote server, but in the case of downloading a file from a remote
url a local file does not exist, so an error occurs when the file is
not found.

[1] https://github.com/ansible/ansible-modules-core/commit/467516e

* test_unarchive: fix test with wrong remote_src use

The non-ascii filenames test had improperly set remote_src=yes even
though it was actually copying the file from the local machine (i.e.
the file did not already exist remotely). This test was passing
until the remote_src behavior of unarchive was fixed in 276550f.
2016-08-19 08:16:21 -05:00
James Cammarata
890e096b2b Clean up PlaybookExecutor logic for batches and errors
The calculation for max_fail_percentage was moved into the linear
strategy a while back, and works better there in the stategy layer
rather than at the PBE layer. This patch removes it from the PBE layer
and tweaks the logic controlling whether or not the next batch is run.

Fixes #15954
2016-08-18 13:52:34 -05:00
Toshio Kuratomi
cb3653295f Update submodule refs 2016-08-18 07:28:03 -07:00
Brian Coca
4fb09d5693 moved from extras repo where it incorrectly exists (#17124)
* moved from extras repo where it incorrectly exists

* added to sanity exclusion for 2.4

* changed license with author's consent
2016-08-18 09:47:21 -04:00
Toshio Kuratomi
bd31cc096a Fix facts.py for python3 (#17131)
* Fix facts.py for python3

* Update facts unittest to account for filepaths being byte strings
2016-08-18 09:36:03 -04:00
Adrian Likins
7bd57acda4 Linux mount/fs (lsblk) facts fixes and tests. (#17036)
Fixes #10779

Refactor some of the block device, mount point, and
mtab/fstab facts collection for linux for better
performance on systems with lots of block devices.

Instead of invoking 'lsblk' for every entry in mtab,
invoke it once, then map the results to mtab entries.

Change the args used for invoking 'findmnt' since the
previous combination of args conflicts, so this would
always fail on some systems depending on version.

Add test cases for facts Hardware()/Network()/Virtual() classes
__new__ method and verify they create the proper subclass based
on the platform.system() results.

Split out all the 'invoke some command and grab it's output'
bits related to linux mount paths into their own methods so
it is easier to mock them in unit tests.

Fix the DragonFly* classes that did not defined a 'platform'
class attribute. This caused FreeBSD systems to potentially
get the DragonFly* subclasses incorrectly. In practice it
didnt matter much since the DragonFly* subclasses duplicated
the FreeBSD ones. Actual DragonFly systems would end up with
the generic Hardware() etc instead of the DragonFly* classes.

Fix Hardware.__new__() on PY3, passing args to __new__
would cause "object() takes no parameters" errors. So
check for PY3 and just call __new__ without the args

See
https://hg.python.org/cpython/file/44ed0cd3dc6d/Objects/typeobject.c#l2818
for some explaination.
2016-08-17 17:58:51 -07:00
nitzmahone
9fedcdfc47 bump extras submodule ref 2016-08-17 16:42:37 -07:00
nitzmahone
88c36bbc34 bump submodule refs 2016-08-17 15:52:26 -07:00
James Cammarata
b617d62203 Don't use an unset playbook basedir when searching for hostgroup vars
The flag new_pb_basedir is not being utilized in Inventory._get_hostgroup_vars,
leading to the situation where an inventory with no playbook basedir set will
read host/group vars from the $CWD, regardless of the inventory and/or playbook
relative location. This patch corrects that by not using the playbook basedir
if it is unset (None).

This patch also corrects a bug in which the VariableManager would accumulate
host/group vars files, which could lead to incorrect vars files being used when
playbooks are run from different directories containing their own group/host vars
directories.

Fixes #16953
2016-08-17 16:28:48 -05:00
James Cammarata
732d722a7f Catch a missing include_vars filename
Related to ansible/ansible-modules-core#4445
2016-08-17 09:35:37 -05:00
Matt Davis
e0bdb502e3 raw now returns changed: true (#17112)
for consistency w/ shell/command/script "non-idempotent" modules.

Updated tests, changelog.
2016-08-16 20:39:23 -07:00
James Cammarata
f4237b2151 Rework the way params are assigned to TaskIncludes when they're dynamic
Copying the TaskInclude task (which is the parent) before loading the blocks
makes the code much more simple and clean, and fixes a bug introduced during
the performance improvement changes (and specifically the change which moved
things to a single-parent model).

Fixes #17064
2016-08-16 15:45:24 -05:00
Nathaniel Case
cada4fb8d1 Relicense netcfg.py to BSD (#17110)
As with #17025. The caveat regarding machilde's (now obsoleted) commit has been addressed, so netcfg.py is able to be easily relicensed.
2016-08-16 16:32:02 -04:00
Brian Coca
297e2d8266 added bits and bytes arg types (#17102)
* added bits and bytes arg types

* changed function alias method as per feedback

* use enumerate vs managing i myself
2016-08-16 13:45:41 -04:00
Brian Coca
5fe9d3c3d5 make parsed param private and explicit (#17104)
* make parsed param private and explicit

* fixed missed parsed
2016-08-16 11:59:30 -04:00
Ryan S. Brown
30268f6bd0 Pass keyword arguments from modules to _boto3_conn 2016-08-16 07:56:20 -04:00
James Tanner
f62df4e78d Update submodule refs 2016-08-15 20:01:24 -04:00
James Cammarata
f722d41eab Allow notifies to be sent to the top level includes when they were static
Since we introduced static includes in 2.1, this broke the functionality
where a notify could be sent to a named include statement, triggering all
handlers contained within the include. This patch fixes that by adding a
search through the parents of a handler for any TaskIncludes which match.

Fixes #15915
2016-08-15 14:22:35 -05:00
Ryan Brown
c5cc6edb93 Merge pull request #16606 from ryansb/rds-cluster-inventory-aioue
Support RDS clusters in AWS dynamic inventory script
2016-08-15 15:08:55 -04:00
David Shrewsbury
bf8c871801 Fix async logic when parsing fails (#17091)
We want to NOT consider the async task as failed if the result is
not parsed, which was the intent of:

  https://github.com/ansible/ansible/pull/16458

However, the logic doesn't actually do that because we default
the 'parsed' value to True. It should default to False so that
we continue waiting, as intended.
2016-08-15 13:29:06 -04:00
James Tanner
1f5552f586 Update submodule refs 2016-08-15 13:02:07 -04:00
James Cammarata
daf6eb97d3 Make sure includes for handlers in roles look in the correct subdir 2016-08-15 10:08:11 -05:00
Brian Coca
64a8d24b72 slightly better presentation docs
- description items are now separated
- choices/defaults start at their own line
2016-08-15 11:00:29 -04:00
Brian Coca
4c034fd002 updated container detection to new lxc (#17063)
fixes #17030
2016-08-15 09:15:01 -04:00
Peter Sprygada
8620fda947 Merge pull request #17077 from agaffney/junos_doc_fix
Update junos docs fragment to note the default port for transport=netconf
2016-08-15 05:19:22 -04:00
James Cammarata
3c65c03a67 Changing license on module_utils/splitter.py to BSD 2016-08-13 09:56:12 -05:00
Andrew Gaffney
fdabfb6821 Update junos docs fragment to note the default port for transport=netconf 2016-08-13 14:52:06 +00:00
James Cammarata
c669a381d1 Don't immediately return failed for any_errors_fatal tasks
Instead of immediately returning a failed code (indicating a break in
the play execution), we internally 'or' that failure code with the result
(now an integer flag instead of a boolean) so that we can properly handle
the rescue/always portions of blocks and still remember that the break
condition was hit.

Fixes #16937
2016-08-12 14:18:50 -05:00
Dag Wieers
cb5675a29f Remove a useless section, only act on 'shell' (#16205) 2016-08-12 10:13:02 -07:00
Matt Clay
4cee67452b Update submodule refs. 2016-08-12 07:20:01 -07:00
jctanner
da23700b15 Update submodule refs (#17062) 2016-08-12 10:05:06 -04:00
Dag Wieers
56148291e9 Emit warnings when safe_eval() raises a SyntaxError or other Exception (#14304)
This change is related to reported issue #14291 and pull request #14293.

Without the fix from #14293, this change will emit a warning as shown below, on the following playbook:

``yaml
---
- hosts: localhost
  gather_facts: no
  vars:
    works:
      key1: 'string'
      key2: 1234
    fails:
      key1: 'string'
      key2: 1234
      key3: false
  tasks:
  - debug: msg={{ works | to_json }}
  - debug: msg={{ fails | to_json }}
```

On error, this results in a proper warning:

```
[dag@moria ansible.dag]$ ansible-playbook test49.yml

PLAY ***************************************************************************

TASK [debug] *******************************************************************
ok: [localhost] => {
    "msg": {
        "key1": "string",
        "key2": 1234
    }
}

TASK [debug] *******************************************************************
 [WARNING]: Error in expression "{"key3": false, "key2": 1234, "key1": "string"}". (name 'false' is not defined)

ok: [localhost] => {
    "msg": "{\"key3\": false, \"key2\": 1234, \"key1\": \"string\"}"
}

PLAY RECAP *********************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=0
```
2016-08-12 09:29:54 -04:00
Dag Wieers
1268f4778d Introduce new 'filetree' lookup plugin (#14332)
* Introduce new 'filetree' lookup plugin

The new "filetree" lookup plugin makes it possible to recurse over a tree of files within the task loop. This makes it possible to e.g. template a complete tree of files to a target system with little effort while retaining permissions and ownership.

The module supports directories, files and symlinks.

The item dictionary consists of:
 - src
 - root
 - path
 - mode
 - state
 - owner
 - group
 - seuser
 - serole
 - setype
 - selevel
 - uid
 - gid
 - size
 - mtime
 - ctime

EXAMPLES:
Here is an example of how we use with_filetree within a role:

```yaml
 - name: Create directories
   file:
     path: /web/{{ item.path }}
     state: directory
     mode: '{{ item.mode }}'
     owner: '{{ item.owner }}'
     group: '{{ item.group }}'
     force: yes
   with_filetree: web/
   when: item.state == 'directory'

 - name: Template complete tree
   file:
     src: '{{ item.src }}'
     dest: /web/{{ item.path }}
     state: 'link'
     mode: '{{ item.mode }}'
     owner: '{{ item.owner }}'
     group: '{{ item.group }}'
   with_filetree: web/
   when: item.state == 'link'

 - name: Template complete tree
   template:
     src: '{{ item.src }}'
     dest: /web/{{ item.path }}
     mode: '{{ item.mode }}'
     owner: '{{ item.owner }}'
     group: '{{ item.group }}'
     force: yes
   with_filetree: web/
   when: item.state == 'file'
```

SPECIAL USE:
The following properties also have its special use:

 - root: Makes it possible to filter by original location
 - path: Is the relative path to root
 - uid, gid: Makes it possible to force-create by exact id, rather than by name
 - size, mtime, ctime: Makes it possible to filter out files by size, mtime or ctime

TODO:
 - Add snippets to documentation

* Small fixes for Python 3

* Return the portion of the file’s mode that can be set by os.chmod()

And remove the exists=True, which is redundant.

* Use lstat() instead of stat() since we support symlinks

* Avoid a few possible stat() calls

* Bring in line with v1.9 and hybrid plugin

* Remove glob module since we no longer use it

* Included suggestions from @RussellLuo

- Two blank lines will be better. See PEP 8
- I think if props is not None is more conventional 😄

* Support failed pwd/grp lookups

* Implement first-found functionality in the path-order
2016-08-11 23:33:54 -04:00
jctanner
39d764c7ad Restore previous behavior of ignoring missing files via with_fileglob (#17053)
Fixes #16801
2016-08-11 19:55:21 -04:00
James Cammarata
925b0ff9e9 cleaning up some debug statements in _queue_task() 2016-08-11 14:26:28 -05:00
James Cammarata
1c7e0c73c9 Several fixes for includes
* when including statically, make sure that all parents were also included
  statically (issue #16990)
* properly resolve nested static include paths
* print a message when a file is statically included

Fixes #16990
2016-08-11 14:07:49 -05:00
Toshio Kuratomi
854d47826c Fix classes that select a subclass based on platform (#17034)
When unittesting this we found that the platform selecting class
hierarchies weren't working in all cases.  If the subclass was directly
created (ie: LinuxHardware()), then it would use its inherited __new__()
to try to create itself.  The inherited __new__ would look for
subclasses and end up calling its own __new__() again.  This would
recurse endlessly.  The new code detects when we want to find a subclass
to create (when the base class is used, ie: Hardware()) vs when to
create the class itself (when the subclass is used, ie:
LinuxHardware()).
2016-08-11 13:26:17 -04:00
John R Barker
b82d150c42 Add missing version_added (#17050)
A number of new arguments were added in
637bbdadfa (diff-60710cdc60751ecd19968b01b98283a0)
but not documented
2016-08-11 12:58:11 -04:00
James Cammarata
68d44e48ba Remove sleeps and rely on regular queue options to process results 2016-08-11 09:11:32 -05:00
Peter Sprygada
7579df33ce Merge pull request #17032 from Qalthos/net_mod_nxos
Update NXOS to NetworkModule
2016-08-10 15:39:06 -04:00
Nathaniel Case
1ced3bfc25 NXOS changes
This refactors the nxos module to implement the classes from the
network common module.
2016-08-10 15:16:16 -04:00
James Cammarata
47acf55fa9 Cache tasks by uuid in PlayIterator for O(1) lookups
Rather than repeatedly searching for tasks by uuid via iterating over
all known blocks, cache the tasks when they are added to the PlayIterator
so the lookup becomes a simple key check in a dict.
2016-08-10 12:49:19 -05:00
Nathaniel Case
125c53e691 Relicense low-hanging fruit to BSD (#17025) 2016-08-10 10:45:54 -07:00
Victor Volle
c9d2a67ec7 16888: comment module_utils/urls.py (#16987)
* 16888: comment module_utils/urls.py

* improved documentation of module (mentioning ‘requests’)

* remove mentioning of implementation details (urllib)

* improved parameter and return value documentation
2016-08-10 08:39:48 -07:00
James Cammarata
57fca2dde2 Validate new blocks during copy
It is possible that a block is copied prior to validation, in which case
some fields (like when) which should be something other than a string might
not be. Using validate() in copy() is relatively harmless and ensures the
blocks are in the proper structure.

This also cleans up some of the finalized logic from an earlier commit and
adds similar logic for validated.

Fixes #17018
2016-08-10 08:27:59 -05:00
Rene Moser
543f266801 update submodule refs, fixes build in ansible-modules-extras 2016-08-10 13:37:10 +02:00
Brian Coca
47e3366744 fixed indent 2016-08-09 13:16:42 -04:00
Brian Coca
ea033ae2cc removed extraneous test code 2016-08-09 13:00:44 -04:00
Brian Coca
eb0c90ab80 added unsafe_writes as common file feature (#17016) 2016-08-09 12:39:17 -04:00
James Cammarata
7503875ed7 Mark playbook objects as finalized after post_validate
After post_validate() is called on an object, there should be no
need to continue looking up at parent attributes. This patch adds a
new flag (_finalized) which is set to True at the end of post_validate,
and getattr will not look beyond its own attributes from that point on.
2016-08-09 08:57:21 -05:00
Peter Sprygada
375f7c515a Merge pull request #16978 from caphrim007/feature.add-module-doc-fragments-for-f5-modules
Adds module doc fragment for F5 modules
2016-08-09 07:31:59 -04:00
Peter Sprygada
29c76be768 Merge pull request #16999 from Qalthos/net_mod_ops
OpenSwitch to NetworkModule
2016-08-09 07:30:50 -04:00
Peter Sprygada
7720caadde Merge pull request #17006 from Qalthos/net_mod_ios
Clean up module_utils.ios
2016-08-09 07:29:44 -04:00
Dag Wieers
718f431466 Allow to make the jsonfile cache files pretty (indented and sorted) (#17000)
* Allow to make the jsonfile cache files pretty (indented and sorted)

Since the json cache files are condensed, it is not very practical to look for something in them. Having indented/sorted cache files makes debugging and playbook/inventory development a lot easier to do.

I made it configurable in case people would object to the performance hit this would have, but to be honest, then they probably should be looking at other cache plugins instead IMO.

* Removed the config option and documentation changes
2016-08-08 17:15:19 -04:00
James Cammarata
e244895174 Avoid copying task parents in TaskExecutor
As Block.copy() is potentially expensive, avoid copying the parent
structure of tasks in TaskExecutor.
2016-08-08 15:58:46 -05:00
James Cammarata
06d4f4ad0e Move tasks/blocks to a single parent model 2016-08-08 15:58:46 -05:00
James Cammarata
d2b3b2c03e Performance improvements 2016-08-08 15:58:46 -05:00
Brian Coca
ce282e9373 correctly detect action
named matched only cause i set it to the same in my tests
fixes #14857
2016-08-08 14:28:14 -04:00
Toshio Kuratomi
152a2b9b8f Update submodule refs 2016-08-08 11:17:41 -07:00
Nathaniel Case
85706a704c Update IOS with new NetworkModule 2016-08-08 14:15:51 -04:00
Toshio Kuratomi
38ccd11cce Fix from @jimi-c to use task_vars when polling async tasks. (#17003)
This is needed so that async_status can use ansible_python_interpreter
for the host being contacted.

Fixes #14101
2016-08-08 10:53:36 -07:00
Erik Berg
ab678738d6 Add partition uuid to facts for Linux. (#16986)
Works by looking for partition name in /dev/disk/by-uuid
2016-08-08 12:23:19 -04:00
Filipe Niero Felisbino
e54a9d3a51 Add generic data structures querying (#13684)
* Query lookup plugin

* Add license and docstrings

* Add python3-ish imports

* Change query plugin type from lookup to filter

* Switch from dq to jsonpath_rw

* Add integration test for query filter

* Rename query filter to json_query

* Add jsonpath-rw

* Rename query filter to json_query

* Switch query implementation from jsonpath-rw to jmespath
2016-08-08 11:55:59 -04:00
Nathaniel Case
9b4455e33a OpenSwitch Cli & most of Rest 2016-08-08 11:48:47 -04:00
Adrian Likins
f21df311bc Fix hipchat callback "has no attribute display'" (#16998)
Use self._display for access to display object for
the hipchat callback plugin.

Fixes #16946
2016-08-08 11:04:06 -04:00
Matt Clay
72cca01cd4 Use file list, not recursion, in _fixup_perms. (#16924)
Run setfacl/chown/chmod on each temp dir and file.

This fixes temp file permissions handling on platforms such as FreeBSD
which always return success when using find -exec. This is done by
eliminating the use of find when setting up temp files and directories.

Additionally, tests that now pass on FreeBSD have been enabled for CI.
2016-08-05 18:40:28 -07:00
Matt Clay
e07fbba0a5 Add missing boilerplate code. (#16980) 2016-08-05 12:22:52 -07:00
Tim Rupp
5f34206b0a Adds module doc fragment for F5 modules
To reduce documentation duplication, this module fragment is
being created for use in all F5 modules.
2016-08-05 12:21:46 -07:00
Matt Clay
2dc8d80dc5 Update submodule refs. 2016-08-05 11:32:48 -07:00
James Pic
d2438b6b6b Debug output callback (#16839)
* Added debug output callback

* Better import

* Comment on line
2016-08-05 13:57:13 -04:00
Toshio Kuratomi
408664b532 Update submodule refs 2016-08-05 10:26:27 -07:00
James Cammarata
1714279b5e Tweak the way the debug strategy imports the linear strategy parent
Due to the way we load plugins, internally to Python there can be issues when
the debug strategy is loaded after the linear strategy. To work around this,
we're changing the import line for the linear strategy to avoid the problem.

Related to #16825
2016-08-05 10:06:50 -05:00
Toshio Kuratomi
6db6edfc4f YAML treats some unquoted strings as booleans. For instance, (#16961)
uri:
    follow_redirects: no

Will lead yaml to set follow_redirects=False.  This is problematic when
the module parameter is not a boolean value but a string.  For instance:

  follow_redirects = dict(required=False, default='safe', choices=['all', 'safe', 'none', 'yes', 'no']),

Our parameter validation code ends up getting follow_redirects="False"
instead of "no".  The 100% fix is for the user to quote their strings in
playbooks like:
  uri:
    follow_redirects: "no"

But we can fix quite a few common cases by trying to switch "False" back
into the string that it was specified as.  We only do this if there is
only one correct choices value that could have been specified.  In the
follow_redirects example, a value of "True" only maps back to "yes" and
a value of "False" only maps back to "no" so we can do this.  If choices
also contained "on" and "off" then we couldn't map back safely and would
need to force the module author to change the module to handle this
case.

Fixes parts of the following PRs:

* https://github.com/ansible/ansible-modules-core/pull/4220
* https://github.com/ansible/ansible-modules-extras/pull/2593
2016-08-05 06:49:34 -07:00
Toshio Kuratomi
1ecf51d87e * Fix race in creating temp directories pre-fork (#16965)
* These can still race when multiple ansible processes are created at
    the same time.
* Reverse order of expanduser and expandvars in unfrakpath(). So that
  tildes in environment variables will be handled.
2016-08-04 19:35:36 -04:00
Matt Davis
746ea64d30 fix for unspecified retries on until + test (#16963)
fixes #16907
2016-08-04 19:20:45 -04:00
Brian Coca
bced8715cd add transparent vault use to other plugins (#16957)
assemble, script and unarchive (copy already had it).
2016-08-04 18:35:30 -04:00
Will Thames
eb2a3a91a8 task_result _check_key should handle empty results (#16766)
When a task result has an empty results list, the
list should be ignored when determining the results
of `_check_key`. Here the empty list is treated the
same as a non-existent list.

This fixes a bug that manifests itself with squashed
items - namely the task result contains the correct
value for the key, but an empty results list. The
empty results list was treated as zero failures
when deciding which handler to call - so the task
show as a success in the output, but is deemed to
have failed when deciding whether to continue.

This also demonstrates a mismatch between task
result processing and play iteration.

A test is also added for this case, but it would not
have caught the bug - because the bug is really in
the display, and not the success/failure of the
task (visually the test is more accurate).

Fixes ansible/ansible-modules-core#4214
2016-08-04 17:13:33 -05:00
Ryan Brown
4f7996fbc1 Merge pull request #16879 from alikins/gce_module_utils
Fix import of gce/gcdns without a libcloud module
2016-08-04 16:16:01 -04:00
James Cammarata
159aa26b36 FEATURE: adding variable serial batches
This feature changes the scalar value of `serial:` to a list, which
allows users to specify a list of values, so batches can be ramped
up (commonly called "canary" setups):

- hosts: all
  serial: [1, 5, 10, "100%"]
  tasks:
  ...
2016-08-04 15:04:10 -05:00
ovcharenko
f326e49d75 Fix for issue @synchronize doesn't substitute variables properly #16347 (#16349)
* Fix for issue @synchronize doesn't substitute variables properly #16347
2016-08-04 11:27:44 -07:00
Hidetoshi Hirokawa
595946b80e Fix the security rules name duplication of azure_rm_common. (#16897) 2016-08-04 10:43:30 -07:00
victoru
14901b65d9 raise AnsibleError in hashi_vault lookup plugin when hvac module is not installed (#16859) 2016-08-04 10:06:12 -07:00
Brian Coca
7ea56e1c79 optimize booleanifycation 2016-08-04 11:32:26 -04:00
Brian Coca
b0786a1845 actually skip bad/broken module files found 2016-08-04 11:32:08 -04:00
Brian Coca
98c149859a added y/n to list of module booleans 2016-08-04 10:47:05 -04:00
Brian Coca
27691991c3 refactored ethtool data to allow for other callers 2016-08-04 10:41:50 -04:00
Brian Coca
f7570f1dc4 Implicit localhost ondemand (#16900)
* Revert "There can be only one localhost"

This reverts commit 5f1bbb4fcd.
this broke several usages of localhost, see #16882, #16898 and #16886

* ensure there is only 1 localhost

fixes #16886, #16882 and #16898

- make sure localhost exists before returning it
- optimzed host caching
- ensure we always return a host object
2016-08-02 10:39:00 -04:00
Brian Coca
123d54e736 added pid to backup file name to avoid collisions 2016-07-29 23:04:57 -04:00
Adrian Likins
36bf1e6b7e Fix funcd to at least import without errors. (#16288)
This plugin was using very old api, so was
updated to newer api.

Also misc style/pep8 cleanups.
2016-07-29 16:19:38 -04:00
Adrian Likins
fa1d55f683 Fix import of gce/gcdns without a libcloud module
The module level function defs for gcdns_connect() and
gce_connect() provide a default arg for 'provider' that
references into the libcloud module. If the libcloud
modules were not installed, the gce/gcdns python modules
would throw ImportError.

Let the provider arg default to None and if not provided,
set it to the default libcloud.compute.types.Provider.*
value if the modules are installed.
2016-07-29 13:34:09 -04:00
Ryan S. Brown
bed24689ec Fix syntax error in json/jsonarg type parser
The lack of a comma caused the statement to always evaluate as a
`TypeError` when python interpreted `value (list, tuple, dict)` to call
value with the arguments list, tuple, and dict.
2016-07-28 15:54:09 -04:00
William Albert
409d95d67e Refactored gce util module to support other GCP services (#15924)
This is a refactoring of the existing GCE utility module to support other projects on Google Cloud Platform.

The previous gce.py module was hard-coded specifically for GCE, and attempting to use it with other projects in GCP failed.

See https://github.com/ansible/ansible/pull/15918#issuecomment-220165913  for more detail.

This has also been an issue for others in the past, although they've handled it by simply
duplicating some of the logic of gce.py in their own modules.

-   The existing gce.py module was renamed to gcp.py, and modified to remove any 
     imports or other code that refers to libcloud.compute or GCE (the GCE_* params were
     retained for compatibility). I also renamed the gce_connect function to gcp_connect, 
     and modified the function signature to make supplying a provider, driver, and agent 
     information mandatory.

-  A new gce.py module was created to handle connectivity to GCE. It imports the
   appropriate libcloud.compute providers and drivers, and then passes them on
   to gcp_connect in gcp.py. The constants and function signatures are the same
   as the old gce.py, so compatibility with existing modules is retained.

- A new gcdns.py module was created to support PR ansible/ansible-modules-extras#2252
  for two new Google Cloud DNS modules, and to demonstrate support for a non-GCE 
  Google Cloud service. It follows the same basic structure as the new gce.py module,
  but imports from libcloud.dns instead.
2016-07-28 12:54:39 -04:00
Lukas Pirl
a9aea3c6d4 (re)allow ansible_python_interpreter to contain more than 1 arg (#16247) 2016-07-26 07:46:16 -07:00
Brian Coca
92870ee996 jsonarg bikeshed to json, arg type implies 'arg' 2016-07-26 09:50:21 -04:00
Brian Coca
4e14b7b783 warn when searching for an empty string or null 2016-07-26 08:26:07 -04:00
Toshio Kuratomi
04a60a1db4 Update submodule refs 2016-07-26 05:22:59 -07:00
Toshio Kuratomi
7e54c9a468 No longer try to import __version__ from release.py. (#16817)
I'm not sure why that would be desirable -- we really want __version__
to come from the controller whereas importing will come from the client
node.  If it turns out there was a reason to do that, please be sure to
use an exception handler that catches all exceptions instead of only
catching ImportError:

```
try:
    from ansible.release import __version__, __author__
except:
    __version__ = [...]
```

Fixes #16523
2016-07-25 11:16:27 -07:00
Toshio Kuratomi
eb3bdcb9e3 Update submodule refs 2016-07-25 06:32:25 -07:00
Brian Coca
e2f17f8d9b set cwd to task's basedir (#16805)
* switch cwd to basedir of task

This restores previous behaviour in pre 2.0 and allows for 'local type' plugins
and actions to have a more predictable relative path.

fixes #14489

* removed FIXME since prev commit 'fixes' this

* fix tests, now they need a loader (thanks jimi!)
2016-07-25 08:11:45 -04:00
Brian Coca
363596c67f added check and diff mode control to console
also expanded mk_boolean to allow for 'on/off'
fixes #16815
2016-07-25 08:05:56 -04:00
Joe (rook)
2219339dd5 Adding ethtool info to Ansible interface facts (#16513)
This will give the user details on how the interfaces are configured.
They user could query to see if TSO, GSO, etc are enbaled
on an interface.
2016-07-24 21:39:47 -04:00
Brian Coca
7fdbfd490e allow include_vars to namespace imports 2016-07-24 21:31:11 -04:00
James Cammarata
a9ff363ead Merge pull request #16779 from mirskifa/devel
Make returning results after loading vars optional
2016-07-24 08:32:18 -05:00
Matt Martz
4065acc37d indent callback output if using 3verbosity or higher (#16231) 2016-07-23 18:10:53 -04:00
Alexandre Garnier
ba2d1d0bc4 Colorize around text (#16415)
Avoid to colorize separately `lead`, equals sign and `num` and separate
them by coloring characters.
2016-07-23 18:09:20 -04:00
Robin Roth
2b28beb1d7 add check_mode option for tasks (#16056)
* add check_mode option for tasks

includes example testcases for the template module

* extend check_mode option

* replace always_run, see also proposal rename_always_run
* rename always_run where used and add deprecation warning
* add some documentation

* have check_mode overwrite always_run

* use unique template name to prevent conflicts

test_check_mode was right before, but failed due to using the same filename as other roles

* still mention always_run in the docs

* set deprecation of always_run to version 2.4

* fix rst style

* expand documentation on per-task check mode
2016-07-22 20:40:14 -04:00
Brian Coca
71c97685a1 fixes for service module interaction with systemd (#16720)
now systemd will run even if service module is inovked with parameters that it does not support
these will be removed before invoking systemd and issue a warning.

this facility will work for any new service modules.
2016-07-22 20:35:20 -04:00
nyasukun
adea1f2b80 fixed memoryerror when coping huge file (#16392)
* fixed

* support both python 2 and 3
2016-07-22 09:06:06 -04:00
Toshio Kuratomi
84c1697271 Only show the traceback for importing cryptography when in Ansible Debug. (#16795) 2016-07-22 05:40:43 -07:00
Toshio Kuratomi
15cee34f9e Update submodule refs 2016-07-21 11:09:22 -07:00
s-hertel
7e834f4178 Fixes #163 in galaxy-issues 2016-07-21 14:04:17 -04:00
Toshio Kuratomi
48a2773463 Find places where ziploader is used and change them to ansiballz so that people aren't confused when they google for information.information (#16715) 2016-07-21 10:58:24 -07:00
Alex Mirski-Fitton
7dc09adaf4 Make returning results after loading vars optional
Reinstates some functionality removed by commit 0ba9a6a but
makes the expensive operation optional (and default to off)
2016-07-21 14:25:57 +01:00
Shintaro Kaneko
372018dfce Fix typo in lib/ansible/parsing/__init__.py (#16761) 2016-07-20 18:03:50 -04:00
Connor Osborn
b06c61c49b Fix exceptions thrown from cryptography import (#16723)
A simple import of cryptography can throw several types of errors. For example,
if `setuptools` is less than cryptography's minimum requirement of 11.3, then
this import of cryptography will throw a VersionConflict here. An earlier case
threw a DistributionNotFound exception.

An optional dependency should not stop ansible. If the error is more than
an ImportError, log a warning, so that errors can be fixed in ansible or
elsewhere.
2016-07-20 03:32:23 -07:00
James Cammarata
d8a3feb976 Fix bug where getting role vars does not follow the dep chain
This bug was introduced in 3ced6d3, where getting vars from a role
did not follow the dep chain. This was originally hidden by the fact
that we got vars twice (from the block and from the roles directly).

Fixes #16729
2016-07-19 16:59:11 -04:00
Peter Sprygada
e4b3032231 removes methods to write to dest from net_config 2016-07-15 17:34:46 -04:00
Peter Sprygada
c4e2c0f487 Merge pull request #16728 from privateip/netcfg
minor update to the default comment tokens in netcfg
2016-07-15 16:42:51 -04:00
Peter Sprygada
ab3c5a0a17 minor update to the default comment tokens in netcfg
* adds checkout /* and */ as comment delimiters
* now raises exception if invalid output keyword value is used
2016-07-15 16:13:41 -04:00
Peter Sprygada
05ca246ddc adds new function to check config for unsupported commands
Some commands fail when being set so the load_config function will
now filter those commands out and return them in the result key
as filtered.
2016-07-15 16:12:12 -04:00
Peter Sprygada
e560bfeaca Merge pull request #16719 from privateip/action-plugin-vyos
add vyos action plugin for handling local operations
2016-07-15 13:52:45 -04:00
Toshio Kuratomi
9055d3ad5c Update submodule refs 2016-07-15 10:09:39 -07:00
Peter Sprygada
e5e387562d add vyos action plugin for handling local operations
This plugin extends the functions of the net_config plugin to vyos
2016-07-15 08:30:21 -04:00
Peter Sprygada
7ecc75b555 Merge pull request #16718 from privateip/vyos
add common argument save_config to vyos_argument_spec
2016-07-15 05:14:47 -07:00
jctanner
238c6461f6 Add a function to check for killed processes in all strategies (#16684)
* Add a function to check for killed processes so that if any
threads are sigkilled or sigtermed, the entire playbook execution is aborted.
2016-07-14 16:37:35 -04:00
Brian Coca
ae0c1bbc47 ansible-doc now notes when module has action plugin 2016-07-14 15:50:58 -04:00