Commit graph

8039 commits

Author SHA1 Message Date
Dag Wieers
1ca4add91c Performance improvement using in-operator on dicts
Just a small cleanup for the existing occurrences.

Using the in-operator for hash lookups is faster than using .keys()
http://stackoverflow.com/questions/29314269/why-do-key-in-dict-and-key-in-dict-keys-have-the-same-output
2016-11-17 12:33:04 -05:00
Brian Coca
bb41a005b3 updated to add tailing msg to missing error 2016-11-16 21:29:04 -05:00
Brian Coca
5129e2fe16 added fail_if_missing shared service function 2016-11-16 20:56:40 -05:00
Adrian Likins
c09060e8ff Fix 'ansible-vault edit' crash on changed nonascii
ansible-vault edit was attempting to decode the file contents
and failing.

Fixes #18428
2016-11-16 15:14:07 -05:00
James Cammarata
ca5b361ad8 Reworking iterator logic regarding failed states during always
Previous changes addressed a corner case, which unfortunately introduced
another bug. This patch adds a new flag to the host state (did_rescue) which
is set to true when the rescue portion of a block completes. This flag is
then checked in _check_failed_state() when the fail_state != FAILED_NONE.

This lead to the discovery of another bug - current strategies are not advancing
hosts to ITERATING_COMPLETE after doing a peek at the next task, leaving the
host state in the run_state of the final task. To address this, before gathering
the list of failed hosts in StrategyBase.run(), a final pass through the iterator
for all hosts is done to ensure each host is in its final state. This way, no
strategy derived from StrategyBase has to worry about it and it's handled.

Fixes #17983
2016-11-16 10:21:46 -06:00
Brian Coca
afaec3da82 corrected service filtered option to singular 2016-11-16 10:12:47 -05:00
Gael Pasgrimaud
f94100aa87 make default strategy configurable (#18394) 2016-11-15 15:36:53 -05:00
Brian Coca
bd70397e24 always template when called from template (#18490)
* Have template action plugin call do_template

Avoids all the magic done for 'inline templating' for ansible plays.
renamed _do_template to do_template in templar to make externally accessible.
fixes #18192

* added backwards compat as per feedback
2016-11-15 15:16:46 -05:00
James Cammarata
fcb033b9e4 Add name field for Blocks
Fixes #18420
2016-11-15 11:57:57 -06:00
James Cammarata
57cf5e431c Catch loop eval errors and only raise them again if the task is not skipped
This should help on issues like #16222.
2016-11-15 10:39:10 -06:00
Matt Clay
4981feee99 Update submodule refs. 2016-11-14 20:11:39 -08:00
Brian Coca
c005ae3cd9 removed package from squash actions
fixes https://github.com/ansible/ansible-modules-core/issues/5595
2016-11-14 17:41:14 -05:00
James Cammarata
435ca620b2 Add option to prepend inherited attributes when extending values
Fixes #18483
2016-11-14 16:33:01 -06:00
Brian Coca
11465134fa added alias to argumetns 'args' to blacklist (#18485)
this should fix https://github.com/ansible/ansible-modules-core/issues/5584
2016-11-14 15:18:47 -05:00
Brian Coca
f4391d34e4 added alias to argumetns 'args' to blacklist
this should fix https://github.com/ansible/ansible-modules-core/issues/5584
2016-11-14 14:49:30 -05:00
Adrian Likins
0690a67926 Include missing _text.to_text import
Fixes "global name 'to_text' is not defined" error on
openbsd clients.

Fixes #18473
2016-11-14 11:15:46 -05:00
René Moser
b08ef44da0 cloudstack: extend support for VPC (#18434) 2016-11-14 09:03:46 +01:00
Chris Church
534bd12ae9 Increment changed stat for a failed task if changed. (#18014) 2016-11-14 01:23:02 -06:00
James Cammarata
4f06a86161 Alternately track listening handlers by uuid if no name is set
Fixes #17846
2016-11-13 15:24:44 -06:00
Trond Hindenes
8874c1dc39 Improved Get-PendingRebootStatus 2016-11-11 14:49:01 -08:00
Matt Davis
39dcafe23f bump submodule refs 2016-11-11 10:46:06 -08:00
Brian Coca
3fd03b764b removed core import template 2016-11-11 12:48:45 -05:00
James Cammarata
5b87951d6c Don't copy the parent block of TaskIncludes when loading statically
When loading an include statically, we previously were simply doing a
copy() of the TaskInclude object, which recurses up the parents creating
a new lineage of objects. This caused problems when used inside load_list_of_blocks
as the new parent Block of the new TaskInclude was not actually in the list
of blocks being operated on. In most circumstances, this did not cause a
problem as the new parent block was a proper copy, however when used in
combination with PlaybookInclude (which copies conditionals to the list of
blocks loaded) this untracked parent was not being properly updated, leading
to tasks being run improperly.

Fixes #18206
2016-11-11 08:09:43 -06:00
René Moser
80af461178 cloudstack: add additional CLOUDSTACK_VPC env var (#18467) 2016-11-11 14:03:43 +01:00
Brian Coca
c880c1a78d added sysv functions 2016-11-10 23:58:41 -05:00
Matt Clay
2ab2e709b0 Update submodule refs. 2016-11-10 11:55:37 -08:00
Adrian Likins
51e3ef89a9 Add error info if tabs are found in the yaml (#18343)
If a yaml file fails to load because of tabs being used
for formatting, detect that and show a error message
with more details.
2016-11-08 11:43:08 -05:00
Ievgen Khmelenko
619f2fd210 ansible-logstash-callback (#18282)
* ansible-logstash-callback

* GPL v3 license preamble, ImportError

* Update logstash.py
2016-11-08 11:17:05 -05:00
James Tanner
20fb74b1b1 ini lookup: add 'default' to the list of parsed keys
Fixes #18369
2016-11-08 11:07:33 -05:00
Brian Coca
5dd195b52f restore play_hosts variables to not show removed
Also adds ansible_play_hosts_all with original list of hosts the play targeted
2016-11-08 10:51:27 -05:00
James Cammarata
4794b5da45 Merge class dict with parent dict when creating meta attributes
In some situations, where the Base class defines an Attribute, the
BaseMeta class doesn't properly see the _get_parent_attribute or
_get_attr_<whatever> methods because of multiple layers of subclasses
(ie. Handler, which subclasses Task). This addresses that by merging
the __dict__ of the parent with the current classes __dict__ meaning
all future iterations see available special methods.

Fixes #18378
2016-11-07 21:30:01 -06:00
Matt Clay
8c270ac75f Add empty-init code-smell script. (#18406)
Also removed boilerplate from otherwise empty __init__.py files
which should not contain any code (checked by empty-init script).
2016-11-07 15:02:13 -08:00
Toshio Kuratomi
6a3893c518 Remove direct calls to print and cleanup imports
All display of information should go through display instead of through print.
2016-11-07 17:12:36 -05:00
Brian Coca
a0f27d552c File attributes (#18213)
* added attributes to base file params

* dont change attributes when none

* fixed test to deal with new attributes
2016-11-07 15:48:04 -05:00
Brian Coca
7a33c14782 added 'friendly' name to fact gathering
fixes #18198
2016-11-07 15:40:39 -05:00
Michael Scherer
37de9031c6 Detect virtualisation on netbsd (#18381)
* Refactor OpenBSD sysctl based detection in a separate class

The idea is later to reuse this code for NetBSD and FreeBSD, who
use a different sysctl key for vendor and product.

* Add detection of virtualisation on NetBSD

* Add support to detect running as a Xen guest

tested on NetBSD 7 on Rackspace.
2016-11-07 15:15:15 -05:00
Michael Scherer
ccecbdd78d Add DMI facts on NetBSD and refactor code (#18388)
* Add support for OpenBSD dmi fact gathering

* Refactor get_sysctl in the Hardware class

Due to difference between Darwin/NetBSD and OpenBSD, we
have to change the regexp used split the key/value

* Add support for dmi facts on NetBSD
2016-11-07 15:09:48 -05:00
Toshio Kuratomi
ee14e0cc2a Text's .translate() is easier to use than bytes
Text strings and byte strings both have a translate method but the byte
string version is harder to use.  It requires a mapping of all 256 bytes
to a translation value.  Text strings only require a mapping from the
characters that are changing to the new string.  Switching to text
strings on both py2 and py3 allows us to state what we're getting rid of
simply without having to rely on the maketrans() helper function.
2016-11-07 10:24:19 -08:00
Michael Scherer
fd44917561 Remove duplicate declaration of human_to_bytes
This is already declared in basic.py, in a more complete way.
2016-11-07 12:04:32 -05:00
Michael Scherer
150ea49d8a Add tunnel linux (#18118)
* Refactor the type selection of network device under linux

* Add the tunnel type to the type of net interface under Linux
2016-11-07 12:00:26 -05:00
Michael Scherer
df145df962 Make facts detection work on OpenBSD with Python3
The traceback is the following:

    Traceback (most recent call last):
      File \"/tmp/ansible_8s0bj604/ansible_module_setup.py\", line 134, in <module>
        main()
      File \"/tmp/ansible_8s0bj604/ansible_module_setup.py\", line 126, in main
        data = get_all_facts(module)
      File \"/tmp/ansible_8s0bj604/ansible_modlib.zip/ansible/module_utils/facts.py\", line 3641, in get_all_facts
      File \"/tmp/ansible_8s0bj604/ansible_modlib.zip/ansible/module_utils/facts.py\", line 3584, in ansible_facts
      File \"/tmp/ansible_8s0bj604/ansible_modlib.zip/ansible/module_utils/facts.py\", line 1600, in populate
      File \"/tmp/ansible_8s0bj604/ansible_modlib.zip/ansible/module_utils/facts.py\", line 1649, in get_memory_facts
    TypeError: translate() takes exactly one argument (2 given)

And the swapctl output is this:

    # /sbin/swapctl -sk
    total: 83090 1K-blocks allocated, 0 used, 83090 available

The only use of the code is to remove prefix in case they are present, so just
replacing them with empty space is sufficient.
2016-11-07 11:59:32 -05:00
Michael Scherer
bd6ac784bb Add support for KVM in the Solaris virt detection
smbios -i 256 return:

    # smbios -i 256
    ID    SIZE TYPE
    256   77   SMB_TYPE_SYSTEM (system information)

      Manufacturer: Red Hat
      Product: KVM
      Version: RHEL 6.4.0 PC

      UUID: 8a3b8b1a-ba59-1a4b-5f85-ab53a5a885a9
      Wake-Up Event: 0x6 (power switch)
      SKU Number:
      Family: Red Hat Enterprise Linux
2016-11-07 11:58:47 -05:00
Michael Scherer
12354869b9 Add xen guest detection on FreeBSD 2016-11-07 11:56:24 -05:00
Michael Scherer
bc6c1afb1e Fix media_type detection on NetBSD
On NetBSD 7.0.1, ifconfig return this:
    $ ifconfig
    ne0: flags=8863<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST> mtu 1500
            ec_capabilities=1<VLAN_MTU>
            ec_enabled=0
            address: 00:20:91:45:00:78
            media: Ethernet 10baseT full-duplex
            inet 192.168.156.29 netmask 0xffffff00 broadcast 192.168.156.255

Which result into setup returning this:
    "media_type": "ull-duplex",

So we have to specialise that method, since FreeBSD ifconfig return
something like this:

    ue0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=80009<RXCSUM,VLAN_MTU,LINKSTATE>
        ether 00:20:91:a7:48:45
        inet 192.168.156.11 netmask 0xffffff00 broadcast 192.168.156.255
        media: Ethernet autoselect (100baseTX <full-duplex>)
        status: active
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
2016-11-07 11:55:07 -05:00
Michael Scherer
d393409fed Fix type detection on OpenSolaris for loopback interface
Extract of ifconfig output:

    # ifconfig  -a
    lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
            inet 127.0.0.1 netmask ff000000
    rtls0: flags=1004843<UP,BROADCAST,RUNNING,MULTICAST,DHCP,IPv4> mtu 1500 index 3
            inet 192.168.125.125 netmask ffffff00 broadcast 192.168.125.255
            ether 0:20:91:83:45:82
2016-11-07 11:51:49 -05:00
Adrian Likins
dd0189839e Fix bug (#18355) where encrypted inventories fail 18355 (#18373)
* Fix bug (#18355) where encrypted inventories fail

This is first part of fix for #18355
* Make DataLoader._get_file_contents return bytes

The issue #18355 is caused by a change to inventory to
stop using _get_file_contents so that it can handle text
encoding itself to better protect against harmless text
encoding errors in ini files (invalid unicode text in
comment fields).

So this makes _get_file_contents return bytes so it and other
callers can handle the to_text().

The data returned by _get_file_contents() is now a bytes object
instead of a text object. The callers of _get_file_contents() have
been updated to call to_text() themselves on the results.

Previously, the ini parser attempted to work around
ini files that potentially include non-vailid unicode
in comment lines. To do this, it stopped using
DataLoader._get_file_contents() which does the decryption of
files if vault encrypted. It didn't use that because _get_file_contents
previously did to_text() on the read data itself.

_get_file_contents() returns a bytestring now, so ini.py
can call it and still special case ini file comments when
converting to_text(). That also means encrypted inventory files
are decrypted first.

Fixes #18355
2016-11-07 10:07:26 -05:00
Michael Scherer
5aaf1d1a15 On python 3.5, sys.subversion have been removed
So to get the type of the python interpreter, we need to look at
sys.implementation.name which do not return 'cpython', instead of 'CPython',
but that's upstream breakage, so not much we can do.
2016-11-07 09:24:06 -05:00
Brian Coca
bec9ebbf30 added docs for new arg 2016-11-04 17:11:21 -04:00
Brian Coca
8217c1c39c resolve inventory path on init
This allows meta refresh_inventory to work with relative paths
Added option to unfrackpath to not resolv symlinks
fixes #16857
2016-11-04 17:11:21 -04:00
Toshio Kuratomi
ed134d81f1 Limit how much of the file we read to test if it's an encrypted vault file
Fixes memory errors reported in #16391
2016-11-04 12:30:50 -07:00