Commit graph

8351 commits

Author SHA1 Message Date
Matt Clay
43714f859a Update submodule refs. 2016-11-24 20:01:59 -08:00
Ondra Machacek
b606078d69 Add param method to oVirt helper module (#18605)
This patch add new param method to fetch parameters
from the Ansible module, so modules don't have to use
the long name `self._module.params.get()`.
2016-11-24 16:03:22 +00:00
Brian Coca
fbe5878919 only access match if we actually match fact
fixes #18601
2016-11-23 19:01:20 -05:00
Brian Coca
778c983ef9 ansible_playbook_python (#18530)
* ansible_playbook_python

fixes #18471

* fix tests

* removed dupe
2016-11-23 16:30:46 -05:00
James Cammarata
4859e0a419 Look for _get_parent_attribute method in both src and dst dict
When determining which getter style to use for the object in question,
the BaseMeta class should look at both dict's to try and locate the method.

Fixes #18522
2016-11-23 12:51:38 -06:00
Brian Coca
4a325b5ea2 fixed issue with when/with error deferment
now it issues correct error (loop) when conditional depends on loop
compliment fixes #16222
2016-11-23 13:43:34 -05:00
Eric Chou
9d0b8c8545 modified POST body in axapi_authenticate_v3() and axapi_call_v3() (#18104) 2016-11-23 11:10:58 -05:00
Toshio Kuratomi
03dd186c63 Update submodule refs 2016-11-23 07:34:18 -08:00
Matt Clay
d61b2ed0a3 Support script interpreters for async_wrapper. (#18592) 2016-11-22 16:50:08 -08:00
Matt Clay
387fca28ab Update submodule refs. 2016-11-22 16:49:26 -08:00
Brian Coca
a715d03a83 dont fail on missing service during check mode 2016-11-22 16:16:55 -05:00
Toshio Kuratomi
255a5b5d75 Fix the Solaris POSIX acl fix
For setfacl on Solaris we need to specify permissions like r-x.
For chmod, we need to specify them as rx (r-x means to make the file
readable and *not* executable)
2016-11-22 12:36:43 -08:00
fallencliff
d5910ebdae update facts.py for solaris and hp-ux
for solaris,  add get_dmi_facts to get product_name fact, and update memtotal_mb to integer for consistency.

for hp-ux,  user machinfo to get product_serial fact
2016-11-22 15:09:00 -05:00
Toshio Kuratomi
bacdbc5f27 Update submodule refs 2016-11-22 11:31:34 -08:00
koralsky
4e194d71bd import reduce from six label:python3 (#18561)
* import 'reduce' from six
* import reduce in facts fix
2016-11-22 11:22:24 -08:00
Michael Noseworthy
bb5d8fb476 Fix unicode handling in fixup_perms2 errorhandling (#18565)
The _fixup_perms2 method checks to see if the user that is being sudo'd
is an unprivileged user or root. If it is an unprivileged user, some
checks are done to see if becoming this user would lock the ssh user out
of temp files, among other things. If this check fails, an error prints
telling the user to check the documentation for becoming an unprivileged
user.

On some systems, the stderr prints out the unprivileged user the ssh
user was trying to become contained in smartquotes. These quotes aren't
in the ASCII range, and so when we're trying to call `str.format()` to
combine the stderr message with the error text we get a
UnicodeEncodeError as python can't coerce the smartquotes using the
system default encoding. By calling `to_native()` on the error message
we can ensure that the error message is a native string for the
`Exception` handling, as `Exception` messages need to be native strings
to avoid errors (byte strings in python2, and text strings in python3)

Fixes: #18444
2016-11-22 11:19:47 -08:00
Nathaniel Case
8d0418f7c1 net_template doesn't need BOOLEANS
Note #17815
2016-11-22 11:49:21 -05:00
Nathaniel Case
3f4ac0b9f7 Fix for whitespace padding on JSON responses
Fixes #17825, closes #17829
2016-11-22 11:06:57 -05:00
James Cammarata
81aa12eb1b Rework how the Conditional class deals with undefined vars
Previously, the Conditional class did a simple check when an
AnsibleUndefinedVariable error was raised to see if certain strings were
present. This patch tries to be smarter by evaluating the variable contained
in the error string and compared to the defined/not defined conditionals in
the conditional string.

This also modifies the UndefinedError message from HostVars slightly to
match the format returned jinja2 in general, making it easier to match the
error message in the Conditional code.

Fixes #18514
2016-11-22 08:29:58 -06:00
Toshio Kuratomi
d90638ad40 Fix setfacl for Solaris with POSIX acl support.
Tested on Linux and freebsd.

Fixes #17919
2016-11-21 13:19:41 -08:00
James Cammarata
7e2305f953 Cache dynamically included blocks for later lookup via uuid
Fixes #18357
2016-11-21 13:02:24 -06:00
James Cammarata
26ec2ecfce Adding a persistent connection utility 2016-11-21 12:35:27 -06:00
Toshio Kuratomi
0b96d61162 Convert playbook basedir into unicode at the borders 2016-11-21 09:24:37 -08:00
James Cammarata
8ee3ef587a Check for negative defined logic in conditionals 2016-11-21 10:39:46 -06:00
James Cammarata
0df3767d4d When iterating over hostvars yield the hostname not the host object
Also fixes HostVars to raise the correct jinja2 error type.

Fixes #16836
2016-11-21 10:39:42 -06:00
Peter Sprygada
69649358b1 fixes issue with setting the terminal length (pager) in vyos (#18546)
`set terminal length 0` actually sets `VYATTA_PAGER=cat`
`set terminal length [some number]` actually sets `stty length [some number]`
2016-11-21 15:47:48 +00:00
Brian Coca
6dece90a57 change to ~ instead of $HOME to avoid undefined (#18551)
fixes #16032
2016-11-21 07:31:50 -08:00
Andrea Tartaglia
62697ad77f Replaced iterkeys with 'for key in dict' for #18507 (#18538) 2016-11-21 07:18:52 -08:00
John R Barker
d27e007fb1 Network docs fragments: fix copy paste errors (#18564) 2016-11-21 11:36:32 +00:00
René Moser
72f75fd9e0 cloudstack: add helpers to distinguish VMs not in VPC (#18560)
VMs in VPC and not in VPC can have an identical name. As a result VMs in a VPC must be sorted out if no VPC is given.
Due the API limitation, the only way is to check if the network of the VM is in a VPC.
2016-11-20 23:51:50 +01:00
Toshio Kuratomi
783a185f1c Update submodule ref for mount fixes 2016-11-19 15:30:53 -08:00
René Moser
ff7051bab4 cloudstack: fix distinguish VPC and other networks (#18515) 2016-11-19 11:50:02 +01:00
James Cammarata
a83b00bbc0 Properly sort groups by name as well as depth when getting vars
Fixes #17243
2016-11-18 22:57:52 -06:00
James Cammarata
f36926f8d3 With role params also keep special params in the ds as well as params
With 2.0, we decided to create a special list of param names which were
taken out of the role data structure and stored as params instead (connection,
port, and remote_user). This causes problems with inheritance of these params,
so we are now deprecating that while also keeping those keys in the ds so they
are brought in as attributes on the Role correctly.

Fixes #17395
2016-11-18 22:15:55 -06:00
Toshio Kuratomi
5984e3ee9b Update submodule refs 2016-11-18 12:48:31 -08:00
Ben Cordero
a9a2f12adb openstack: iterate through nova addresses with six (#18408) 2016-11-18 12:44:16 -08:00
jamessewell
b91d4d884d Moved the _inventory.clear_group_dict_cache() from creating a group w… (#17766)
* Moved the _inventory.clear_group_dict_cache() from creating a group which doesn't exist, to adding members to the group.

* Update __init__.py

Update to use changed: block to catch all changes for cache clear as suggested
2016-11-18 13:27:17 -06:00
Matt Davis
d78ec1e760 bump submodule refs 2016-11-18 09:59:32 -08:00
Andrew Haines
200d6bdb23 Default include_role results to empty list in linear strategy plugin
Fixes #18544.

When a loop is over an empty list, the result is set to

    {'skipped_reason': u'No items in the list', 'skipped': True, 'changed': False}

which means that accessing `hr._result['results']` throws a `KeyError`.
2016-11-18 12:13:53 -05:00
Brian Coca
aff5d9160a disable 'dense' callback in py26 2016-11-18 11:41:56 -05:00
James Cammarata
937d872f4b Return failed instead of raising an error when an include_vars file is missing
Fixes #18508
2016-11-18 09:28:44 -06:00
Dag Wieers
b7425b59ee Adapt callback functions to changes in 13f3cbaf3b 2016-11-17 19:30:42 -05:00
Dag Wieers
0036108c59 Implement destructor to ensure newline and terminal attributes
Also fixed a typo
2016-11-17 19:30:42 -05:00
Dag Wieers
2a8914e496 Reset VT100 attributes in case we get unexpected output 2016-11-17 19:30:42 -05:00
Dag Wieers
cd6f577d91 Rename ansi to the more correct name vt100 2016-11-17 19:30:42 -05:00
Dag Wieers
893dc81b5e Implement our own detailed task output
Also:
- Streamline ANSI calls
- Implement v2_playbook_on_include
2016-11-17 19:30:42 -05:00
Dag Wieers
221a4e7014 Ensure we end with a newline in normal mode 2016-11-17 19:30:42 -05:00
Dag Wieers
7148023f59 Small fix so diff output starts on a new line 2016-11-17 19:30:42 -05:00
Dag Wieers
9a507b1f07 Don't try to be smart with cmd output ! 2016-11-17 19:30:42 -05:00
Dag Wieers
84e0420389 Make everything work magically !
- Support item-loops correctly
- Support notification handlers
2016-11-17 19:30:42 -05:00
Dag Wieers
589953c79b Assorted improvements
- Better switch between *dense* and *default*
- Reimplement C.COLOR* out of necessity (help!)
- Make verbose output more dense (clean up result)
- Implement our own dumper
- Improve delegation support
2016-11-17 19:30:42 -05:00
Dag Wieers
223c0011e0 Assorted fixes
- Implement delegate support
- Implement preliminary handler support
- Implement our own recap/summary (still fails)
2016-11-17 19:30:42 -05:00
Dag Wieers
1bf7e22756 Implement support for itemized tasks 2016-11-17 19:30:42 -05:00
Dag Wieers
14cfb2b230 Preliminary support for items, WIP 2016-11-17 19:30:42 -05:00
Dag Wieers
67c57a9b6b Improve readability 2016-11-17 19:30:42 -05:00
Dag Wieers
326bb24a89 Various improvements, now supports different verbosity levels 2016-11-17 19:30:42 -05:00
Dag Wieers
fe6e4f8286 New "dense" callback plugin
The goal for the "dense" output is to only show changes and failures on-screen (the Unix-way).
However, since we still want to have a sense of progress, we use terminal capabilities to display progress.

 - On screen there should only be relevant stuff
    - How far are we ? (during run, last line)
    - What issues occured
    - What changes occured
    - Diff output

 - If verbosity increases, act as default output
   So that users can easily switch to default for troubleshooting

 - Leave previous task output on screen
   - If we would clear the line at the start of a task, there would often
     be no information at all
   - We use the cursor to indicate where in the task we are.
     Output after the prompt is the output of the previous task
   - Use the same color-conventions of Ansible

This is still a work in progress.
It was released to give a glimpse of what would be possible.

The Ansible callback mechanism currently does not have all the functionality we need to do this efficiently.
2016-11-17 19:30:42 -05:00
Brano Zarnovican
96ddd29c7e random filter: added optional 'seed' parameter
implements #15621
2016-11-17 15:02:06 -08:00
Toshio Kuratomi
ed00741a01 Mcsalgado's change to use shlex.quote instead of pipes.quote (#18534)
* Replace pipes.quote for shlex_quote

* More migration of pipes.quote to shlex_quote

Note that we cannot yet move module code over.  Modules have six-1.4
bundled which does not have shlex_quote.  This shouldn't be a problem as
the function is still importable from pipes.quote.  It's just that this
has become an implementation detail that makes us want to import from
shlex instead.

Once we get rid of the python2.4 dependency we can update to a newer
version of bundled six module-side and then we're free to use
shlex_quote everywhere.
2016-11-17 13:18:29 -08:00
Brian Coca
5d043b65d3 fix for filter fix 2016-11-17 13:41:57 -05:00
Brian Coca
7c960d440f remove rsync path from returned facts 2016-11-17 13:20:46 -05:00
James Cammarata
f7fe6dc19c Don't fail on missing vars files for delegated hosts
Fixes #17965
2016-11-17 11:59:09 -06:00
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
Michael Scherer
57b8acccec Add support for network alias on NetBSD
While testing on netbsd 6.0, ansible setup failed with:

    Traceback (most recent call last):
      File \"/tmp/ansible_m2ieeq/ansible_module_setup.py\", line 134, in <module>
        main()
      File \"/tmp/ansible_m2ieeq/ansible_module_setup.py\", line 126, in main
        data = get_all_facts(module)
      File \"/tmp/ansible_m2ieeq/ansible_modlib.zip/ansible/module_utils/facts.py\", line 3609, in get_all_facts
      File \"/tmp/ansible_m2ieeq/ansible_modlib.zip/ansible/module_utils/facts.py\", line 3552, in ansible_facts
      File \"/tmp/ansible_m2ieeq/ansible_modlib.zip/ansible/module_utils/facts.py\", line 2500, in populate
      File \"/tmp/ansible_m2ieeq/ansible_modlib.zip/ansible/module_utils/facts.py\", line 2584, in get_interfaces_info
      File \"/tmp/ansible_m2ieeq/ansible_modlib.zip/ansible/module_utils/facts.py\", line 2644, in parse_inet_line
    socket.error: illegal IP address string passed to inet_aton

The cause is having aliases on lo like this:

     lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33184
         inet 127.0.0.1 netmask 0xff000000
         inet alias 127.1.1.1 netmask 0xff000000

So if the address is 'alias', we have to skip it.
2016-11-04 13:14:52 -04:00
Jasper Lievisse Adriaanse
c17dad0def Rework how OpenBSD processor facts are resolved 2016-11-04 08:45:34 -07:00
James Tanner
2d43b20eb9 Update submodule refs 2016-11-03 22:08:55 -04:00
Matt Clay
88dbb5a630 Python 3 fixes for ansible-doc. 2016-11-03 16:09:24 -07:00
Andrea Tartaglia
b18263cf36 ANSIBLE_SSH_CONTROL_PATH_DIR option added (#18342)
* ANSIBLE_SSH_CONTROL_PATH_DIR option added

This removes the hardcoded value ( $HOME/.ansible/cp ) from ssh.py.
User is able to change the ControlPath directory ( the one that replaces %(directory)s ).

 Fixes #18325

* Added config option in ansible.cfg
2016-11-03 15:19:59 -07:00
Jasper Lievisse Adriaanse
9547d6b422 Detect vmm virtualization for OpenBSD, both host and guest. 2016-11-03 15:14:01 -07:00
Matt Clay
66a0b1475f Update submodule refs. 2016-11-03 14:31:39 -07:00
Robin Roth
6ca6a9a291 Exclude floppy disks from lsblk call for uuids
Fixes #18326
2016-11-03 10:52:07 -07:00
James Cammarata
7ff9942ec6 Correctly reassign implicit block parents when an include is involved 2016-11-03 11:57:23 -05:00
Brian Coca
32a7b4ce71 only validate extensions when using dir loading
fixes #18223
2016-11-03 07:30:32 -07:00
James Cammarata
d12475c98b Correctly assign parent when squashing adjacent implict Blocks
Related to: #18315
Related to: #18206
Related to: #17810
2016-11-03 09:27:24 -05:00
Matt Clay
368a837481 Update submodule refs. 2016-11-02 22:04:55 -07:00
Jasper Lievisse Adriaanse
4c0188a27b On OpenBSD, swap the values for distribution_version and distribution_release 2016-11-02 17:06:28 -07:00
Matt Clay
0d46805979 Clean up shebangs for various files.
- Remove shebangs from:
  - ini files
  - unit tests
  - module_utils
  - plugins
  - module_docs_fragments
  - non-executable Makefiles
- Change non-modules from '/usr/bin/python' to '/usr/bin/env python'.
- Change '/bin/env' to '/usr/bin/env'.

Also removed main functions from unit tests (since they no longer
have a shebang) and fixed a python 3 compatibility issue with
update_bundled.py so it does not need to specify a python 2 shebang.

A script was added to check for unexpected shebangs in files.
This script is run during CI on Shippable.
2016-11-02 17:00:27 -07:00
Toshio Kuratomi
1ff92e28f9 Update submodule refs to get accurate archive doc 2016-11-02 12:54:26 -07:00
Patrick Uiterwijk
77af3a68de Fix adding the same trusted certificates multiple times (#18296)
If there is an intermittent network failure, we might be trying to reach
an URL multiple times. Without this patch, we would be re-adding the same
certificate to the OpenSSL default context multiple times.
Normally, this is no big issue, as OpenSSL will just silently ignore them,
after registering the error in its own error stack.
However, when python-cryptography initializes, it verifies that the current
error stack of the default OpenSSL context is empty, which it no longer is
due to us adding the certificates multiple times.
This results in cryptography throwing an Unknown OpenSSL Error with details:

OpenSSLErrorWithText(code=185057381L, lib=11, func=124, reason=101,
reason_text='error:0B07C065:x509 certificate routines:X509_STORE_add_cert:cert already in hash table'),

Signed-off-by: Patrick Uiterwijk <puiterwijk@redhat.com>
2016-11-02 10:40:48 -07:00
Matt Clay
275d5f85ec Update submodule refs. 2016-11-02 09:59:10 -07:00
Samuel Boucher
911a602c79 Update syslog_json.py
Add SYSLOG_FACILITY environment variable to set syslog facility
2016-11-02 10:02:56 -04:00
Daniel
b7e6ace4ee Add timeout option for nxapi (#18074)
* Changes to be committed:
	modified:   lib/ansible/module_utils/nxos.py
    - added configurable timeout to module paramaters
	modified:   lib/ansible/utils/module_docs_fragments/nxos.py
    - added documentation for timeout

* Changes to be committed:
    modified:   ansible/module_utils/nxos.py
    - added timeout option for nxapi transport and added documentation
    - option works with CLI or NXAPI transport

*  Changes to be committed:
	modified:   lib/ansible/utils/module_docs_fragments/nxos.py
    - Changed per comments in PR 18074

*  Changes to be committed:
	modified:   lib/ansible/module_utils/nxos.py
    - added try/except block to test for timeout

* Changes to be committed:
modified:   lib/ansible/module_utils/nxos.py
 - tweaked timeout
2016-11-02 13:32:19 +00:00
jctanner
333f6d447b aix network facts: Separate out the uname call to reduce total calls (#18288)
* aix network facts: Separate out the uname call to reduce total calls
* Remove duplicate check

Fixes #11289
2016-11-01 19:34:26 -04:00
Jasper Lievisse Adriaanse
88970bcfb2 Implement basic DMI facts for OpenBSD 2016-11-01 13:50:02 -04:00
Adrian Likins
309f54b709 Fix 'vault rekey' with vault secret env var
if ANSIBLE_VAULT_PASSWORD_FILE is set, 'ansible-vault rekey myvault.yml'
will fail to prompt for the new vault password file, and will use
None.

Fix is to split out 'ask_vault_passwords' into 'ask_vault_passwords'
and 'ask_new_vault_passwords' to make the logic simpler. And then
make sure new_vault_pass is always set for 'rekey', and if not, then
call ask_new_vault_passwords() to set it.

ask_vault_passwords() would return values for vault_pass and new
vault_pass, and vault cli previously would not prompt for new_vault_pass
if there was a vault_pass set via a vault password file.

Fixes #18247
2016-11-01 13:07:48 -04:00
Toshio Kuratomi
557f46658c Update submodule refs 2016-11-01 09:39:32 -07:00
Daniel Menet
19fdb58948 fix iteritems for python 3 2016-11-01 09:38:03 -07:00
Michael Scherer
4c85a1fa05 Refactor code for VirtualFacts (#18122)
The populate method is cut and paste on every subclass,
so we should push it up, and add a default method that is overloaded
2016-11-01 10:07:50 -04:00
Brian Coca
d4ac0bdea9 display fixes
banner now adjusts to screen as does output
output now keeps at least one space to end of screen to allow for better reading.
2016-11-01 09:51:20 -04:00
Matt Clay
b42e42343c Update submodule refs. 2016-10-31 21:25:07 -07:00
jctanner
b494d55bde Cast input role version to string before comparing to available versions (#18269)
* Cast input role version to string before comparing to avaialble versions

Fixes #10262
2016-10-31 21:07:38 -04:00
Matt Clay
e753860cb2 Update submodule refs. 2016-10-31 17:16:53 -07:00
Matt Martz
cb1e3dab0d Add 'type' filter for display the underlying python type of a variable (#18242)
* Add 'type' filter for display the underlying python type of a variable

* Update playbooks_filters.rst

Minor copyedit.
2016-10-31 13:36:24 -07:00
James Tanner
6d9771bbf8 Move the check for playbook files above the password prompting.
Fixes #9904
2016-10-31 12:44:53 -04:00
Toshio Kuratomi
d7207b3910 Update submodule refs 2016-10-31 09:26:23 -07:00
René Moser
44bdc6fb79 cloudstack: implement diff support (#18254) 2016-10-30 17:05:24 +01:00
René Moser
01af859090 cloudstack: add support for defining some args as ENV vars (#17946)
These ENV vars are:
  - CLOUDSTACK_ZONE
  - CLOUDSTACK_DOMAIN
  - CLOUDSTACK_ACCOUNT
  - CLOUDSTACK_PROJECT

help to DRY on every task, args still have precedence.
2016-10-30 12:24:03 +01:00
Matt Clay
37580c7d70 Update submodule refs. 2016-10-29 23:28:23 -07:00
Sijis Aviles
b365f44fa1 Simplify surrogate check in to_text() (#18211)
* Simplify surrogate check in to_text()

* Simplify surrogateescape check even further
2016-10-29 09:12:02 -07:00
Nathaniel Case
4a067c3f50 Exception.message gone in 3.x (#18221)
* Exception.message gone in 3.x
2016-10-28 13:48:16 -04:00
Steve Kuznetsov
0bc35354ce Change v2_playbook_on_start logic to positively detect legacy plugins
In order to support legacy plugins, the following two method signatures
are allowed for `CallbackBase.v2_playbook_on_start`:

def v2_playbook_on_start(self):
def v2_playbook_on_start(self, playbook):

Previously, the logic to handle this divergence checked to see if the
callback plugin being called supported an argument named `playbook`
in its `v2_playbook_on_start` method. This was fragile in a few ways:
 - if a plugin author did not use the literal `playbook` to name their
   method argument, their plugin would not be called correctly
 - if a plugin author wrapped their `v2_playbook_on_start` method and
   by doing so changed the argspec to no longer expose an argument
   with that literal name, their plugin would not be called correctly

In order to continue to support both types of callback for backwards
compatibility while making the call more robust for plugin authors,
the logic can be reversed in order to have a positive check for the old
method signature instead of a positive check for the new one.

Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
2016-10-28 10:05:58 -07:00
Matt Davis
916fc25088 bump submodule refs 2016-10-28 09:45:13 -07:00
Michael Scherer
6052c1294b Cleanup StringIO import for module_utils/shell.py 2016-10-28 08:00:57 -07:00
Toshio Kuratomi
4c06ddced6 Update submodule refs 2016-10-28 07:46:43 -07:00
Chris Houseknecht
dceb2a0393 Remove extra display statements and add docs (#18229)
* Add docs for ansible-galaxy import --role-name option.

* Add docs for ansible-galaxy init --container-enabled option.
2016-10-28 00:38:39 -04:00
Monty Taylor
bd9ca5ef28 Allow setting alternate_role_name for galaxy CLI (#17418)
When using the ansible-galaxy CLI to import roles, it's not possible to
specify an alternate_role_name, even though the REST API seems to allow
such a thing (at least on investigation of the interactions the web app
makes) That makes importing things like:
openstack/openstack-ansible-os_cloudkitty wind up with roles named
"openstack-ansible-os_cloudkitty" instead of "os_cloudkitty".

Also, the web ui is smart and imports
"openstack-infra/ansible-role-puppet" as openstack-infra.puppet ... but
the CLI imports it as openstack-infra.ansible-role-puppet. Add that
filtering as well.

Issue ansible/galaxy-issues:#185
2016-10-27 22:34:59 -04:00
Chris Houseknecht
d60bc492b6 Add --container-enabled option to ansible-galaxy init command. (#18157) 2016-10-27 22:16:22 -04:00
jasdeep-hundal
679da00236 Fix OpenSSH-related ssh process exit race
Mitigate the effects of observing the ssh process still running
after seeing an EOF on stdout when using OpenSSH with
ControlPersist, since it does not close the stderr file descriptor
in this case.
2016-10-27 15:47:24 -07:00
Matt Robinson
4ff8890ec1 Set ansible_os_family correctly under KDE neon
As neon is derived from Ubuntu, ansible_os_family should have the value
"Debian" instead of "Neon".  Add a test case for KDE neon and set
os_family correctly for it.
2016-10-27 20:28:38 +01:00
Andrew Gaffney
e6d9a45cd0 Fix service_mgr detection for OpenWrt 2016-10-27 14:09:26 -04:00
Toshio Kuratomi
fda933723c Add hint that python3 might be too old
This limitation of python-3.4 mkstemp() is the final reason we made
python-3.5 our minimum version.  Since we know about it, give a nice
error to the user with a hint that Python3.4 could be the issue.

Fixes #18160
2016-10-27 07:45:14 -07:00
jctanner
5a0621db55 iterate through task results only if the key is not at the root level (#18214)
Fixes https://github.com/ansible/ansible-modules-core/issues/5396
2016-10-27 09:43:49 -04:00
Brian Coca
680cade77a simplified the code by removing repeats
(cherry picked from commit 84380b0ee4029212fc1637c008e07bb9958305c3)
2016-10-26 20:49:55 -04:00
Rene Moser
3763283d01 tasks_queue_manager: fix fork calculation if serial in % 2016-10-26 15:21:31 -04:00
Toshio Kuratomi
56086f3b9e A few fixes for python3
* socket interfaces take bytes so convert text strings to bytes when
  using them.
* Use b64encode() instead of str.encode('base64')
2016-10-26 11:47:40 -07:00
Matt Davis
f8482e335c bump core submodule ref for win_shell/win_command fix 2016-10-25 17:22:18 -07:00
John R Barker
525b672c0c Docs fragment for common a10 options (#18163) 2016-10-25 16:03:25 +01:00
jctanner
5502da3cf8 copy: Use the local file's mode for the argument if not explicitly given. (#17780)
* Use the local file's mode to for the argument if not explicitly given.

Fixes https://github.com/ansible/ansible-modules-core/issues/1124

* Fix octal mode for py3

* Implement preserve instead of null

* Remove duplicate line

* Update comment

* Use stat module per toshia's suggestion
2016-10-24 23:57:50 -04:00
Will
1f30bc8a6f Fix lxd_container module fails if certificate already in trust store
When the client certificate is already stored, lxd returns a JSON error with message "Certificate already in trust store". This "error" will occur on every task run after the initial run. The cert should be in the trust store after the first run and this error message should really only be viewed as informational as it does not indicate a real problem.

Fixes:
ansible/ansible-modules-extras#2750
2016-10-24 20:40:04 -07:00
Matt Davis
d1e1898b0e fix version check to support >=rc5 2016-10-24 20:01:41 -07:00
Foxlik
8bb01d4c29 Fix #10865
Slightly better handling of http headers from http (CONNECT) proxy. Buffers up to 128KiB of headers and raises exception if this size is exceeded.

This could be optimized further, but for the time being it does the trick.
2016-10-24 18:18:38 -07:00
Toshio Kuratomi
188ae18b1c Add a new potential su prompt
Two parts to this change:
* Add a new string that requests password
* Add a new glyph that can be used to separate the prompt from the
  user's input as it seems it can use fullwidth colon rather than colon.

Fixes #17867
2016-10-24 16:55:54 -07:00
Thomas Quinot
236c923c25 Filter out internal magic and connection variables from facts returns
Fixes #15925
2016-10-24 17:27:43 -05:00
Michael Riss
c05bad9f74 Improved caching for urls
- When there is no file at the destination yet, we have no modification time for the `If-Modified-Since`-Header. In this case trust the cache to make the right decision to either serve a cached version or to refresh from origin. This should help with mass-deployment scenarios where you want to use a local cache to relieve your uplink.
- If you don't trust the cache to make the right decision you can still force it to refresh by providing the `force: yes` option.
2016-10-24 16:13:38 -04:00
Rene Moser
e69d26270f handler: notify a handler by name _and_ listen
Before we only allowed either notify by name or listen and name had precedence.
2016-10-24 10:59:05 -04:00
Toshio Kuratomi
ce4330d986 Update submodule refs 2016-10-24 07:21:29 -07:00
Michael Scherer
6885797b03 Add support for getting network facts on GNU Hurd
Since ifconfig/ip are not present on the system, and there is no /proc
to be parsed, the only way to get information is by looking at the
argument of the pfinet translator, the process in charge of network.

In turn, this is done with fsysopts on the appropriate path, who return
something like this:

    # fsysopts -L /servers/socket/inet
    /hurd/pfinet --interface=/dev/eth0 --address=192.168.122.130
    --netmask=255.255.255.0 --gateway=192.168.122.1 --address6=fe80::5254:12:ced/10
    --address6=fe80::5054:ff:fe12:ced/10 --gateway6=::

So to get the IP addresses, one has to parse that string and fill the appropriate
structure.

More information on the system and on limitation can be found on
- https://www.gnu.org/software/hurd/hurd/translator/pfinet.html
- https://www.gnu.org/software/hurd/hurd/translator/pfinet/implementation.html
- https://www.debian.org/ports/hurd/hurd-install
2016-10-24 09:45:22 -04:00
Michael Scherer
f4593ecac7 Add support for getting hardware facts on GNU Hurd (#18152)
* Fallback to /proc/mounts if /etc/mtab do not exist

On modern system, the file is just a compatibility symlink, and
some system (like GNU Hurd) do not have it, but provides /proc/mounts

* Add support for uptime, memory and mount facts on GNU Hurd
2016-10-24 09:44:52 -04:00
Matt Davis
2708ef99b8 bump core submodule ref for async fix 2016-10-24 00:00:24 -07:00
Toshio Kuratomi
3098cc2eb9 Update submodule refs 2016-10-23 16:55:43 -07:00
Toshio Kuratomi
dcbd64b481 Update submodule refs 2016-10-23 14:47:16 -07:00
Michael Scherer
6a76a9299d Fix 18151, by converting float to int 2016-10-23 14:00:51 -07:00
Adrian Likins
c0331d50dc Remove callback.CallbackBase._copy_result_exclude
Nothing seems to use this now.

Was added originally added in2d11cfab92f9d26448461b4bc81f466d1910a15e
but the code that used it was removed in
e02b98274b
2016-10-23 13:36:20 +02:00
stephane
77868a4104 Set Suse family for openSUSE Tumbleweed & Leap
On openSUSE Tumbleweed, lsb-release -a currently reports
the distributor ID as "openSUSE Tumbleweed". On openSUSE
Leap, the distributor ID is "SUSE LINUX".

Add them to the OS_FAMILY dict as Suse family systems.

Also add an entry to TESTSETS in test_distribution_version.py
for openSUSE Tumbleweed.
2016-10-23 02:04:28 +02:00
Matt Robinson
692bfa872a Make bcrypt + passlib work in password_hash filter
If hashtype for the password_hash filter is 'blowfish' and passlib is
available, hashing fails as the hash function for this is named 'bcrypt'
(and not 'blowfish_crypt').  Special case this so that the correct
function is called.
2016-10-23 01:46:05 +02:00
Toshio Kuratomi
def260b5d1 Update submodule refs to pick up latest py3 fixes (and git dep yaml fix) 2016-10-21 09:01:35 -07:00
Brian Coca
aa5938bf8e updated submodule ref 2016-10-21 11:19:46 -04:00
Ssawa
8e47b9bc70 Handle 'smart' scp_if_ssh option for fetch (#18125) 2016-10-21 09:59:56 -04:00
Toshio Kuratomi
6d9f780937 Now that we convert salt inside of do_encryptas needed, keep salt as text type until then. 2016-10-20 22:49:30 -07:00
Thilo Uttendorfer
cf0da0948d Fix uninitialized variable in deserialize method (#18037)
The bug was introduced with commit 06d4f4ad0e.
Added a simple test.
2016-10-20 22:54:16 -04:00
Dag Wieers
cd784cd345 Remove unnecessary warnings (#18121) 2016-10-20 22:49:49 -04:00
Michael Scherer
492da6ce71 Add support for NetBSD network fact (#18113)
Like hostname, it use the same interface as FreeBSD so
we bascailly reuse the same code. Only tested on NetBSD 7.
2016-10-20 17:50:22 -04:00
Toshio Kuratomi
9a5be38a22 Update submodule refs 2016-10-20 14:04:35 -07:00
Michael Scherer
578da9a615 Enable test for lookups on python 3
Since passlib algo sometime takes a bytes, and sometime
not, depending on a internal variable, we have to convert
bnased on it, or it fail with "TypeError: salt must be bytes,
not str" (or unicode instead of bytes)

However, that's not great to use internal structure for that.
2016-10-20 13:22:59 -07:00
Brian Coca
fbe0e6c9a2 improved error msg 2016-10-20 16:02:06 -04:00
Brian Coca
ea428e716d role now fails if specified file not found
fixes https://github.com/ansible/ansible-modules-core/issues/5166
2016-10-20 14:39:54 -04:00
Brian Coca
432633e4c1 fix for check_mode/async interaction
fixes #18110
2016-10-20 14:38:36 -04:00
Toshio Kuratomi
1d3db8ec5b iUpdate submodule refs 2016-10-20 10:29:57 -07:00
Michael Scherer
4549604cc7 Use six.move for module in module_utils/facts.py 2016-10-19 21:32:28 -07:00
Ryan S. Brown
a4660766f7 Update core submodule ref 2016-10-19 19:07:29 -04:00
Toshio Kuratomi
25e25127b9 Update submodule refs 2016-10-19 08:59:59 -07:00
Toshio Kuratomi
5037dc4e69 Make the default Ansible_managed string static so it doesn't interfere with idempotency 2016-10-18 16:19:17 -04:00
Brian Coca
99220a5f6c properly propagate loop vars
fixes #17966
2016-10-18 15:27:16 -04:00
Toshio Kuratomi
001e2b52e0 Update submodule ref for git fix 2016-10-18 11:54:45 -07:00
Brian Coca
01b75f966b fix include_role dynamic path
fixes #17966
2016-10-18 13:27:38 -04:00
Brian Coca
38d0f77a0f include_role now allows duplicates by default
setting is overridable by user
2016-10-18 11:14:10 -04:00
Toshio Kuratomi
ea479001f0 Update submodule ref 2016-10-18 07:22:31 -07:00
Toshio Kuratomi
60acfd1e87 Fix ansible-pull on python3
On python3, we can't write bytes directly to sys.stdout.
2016-10-17 16:31:08 -07:00
Toshio Kuratomi
2b105ec7ab Update submodule refs 2016-10-17 14:21:31 -07:00
James Cammarata
5be2a3a9e0 Break out of linear strategy if all hosts are failed and the result is not OK
Fixes #18021
2016-10-17 16:00:04 -05:00
Thilo Uttendorfer
5ece97ae5b Fix call of wrong super class
Added a basic test
2016-10-17 14:53:03 -04:00
Aaron Bieber
3fc1b4da53 Remove -b option from pbrun.
The -b option reads as follows:
` The target job is directed to ignore hangup signals. This is particularly
useful for running the target program in the background.`

If needed, '-b' can be added to become_flags

Squashed commit of the following:

commit f2c9f5c011ae8be610301d597a34bfba1a391e08
Author: Aaron Bieber <aaron@bolddaemon.com>
Date:   Mon Oct 17 10:58:14 2016 -0600

    remove pbrun flags

commit f402679ac177c931ad64bd13306f62512a14fcd6
Author: Aaron Bieber <aaron@bolddaemon.com>
Date:   Fri Oct 14 15:29:29 2016 -0600

    use Password: vs assword: for matching pbrun prompt

commit cd2e90cb65854c4cc5dd8773404e520d40f82765
Author: Aaron Bieber <aaron@bolddaemon.com>
Date:   Fri Oct 14 15:28:58 2016 -0600

    move -b to pbrun_flags
2016-10-17 14:40:11 -04:00
Andrew Gaffney
194c9c41eb Fix search path for relative paths in roles (fixes #17877)
(cherry picked from commit 72f0aaf606)
2016-10-17 11:21:46 -04:00
Brian Coca
9bdde13126 fixes to ansible_search_path
now gets basedir (no need to frontload as dwim already does that)
added comment about basedir to search_path usage to avoid dupes
2016-10-17 11:21:46 -04:00
Brian Coca
7d9d009189 avoid errors when dynamic role 2016-10-17 11:21:46 -04:00
Toshio Kuratomi
4ce0cf57b6 Update submodule refs 2016-10-17 08:15:33 -07:00
Robin Roth
3922328954 Allow unicode inventory filename
Fixes #17932
2016-10-15 16:54:51 -07:00
Bill Nottingham
77e7ae6838 Change <support@ansible.com> - it's being retired. 2016-10-15 16:42:13 -07:00
Toshio Kuratomi
f24c10c32b Fixes to handle non-ascii become passwords
Fixes for non-ascii passwords on
* both python2 and python3,
* local and paramiko_ssh (ssh tested working with these changes)
* sudo and su

Fixes #16557
2016-10-15 16:25:19 -07:00
Toshio Kuratomi
efc5dac52c Fix become password using non-ascii for local connection
Fixes #18029
2016-10-15 11:26:17 -07:00
Toshio Kuratomi
e9e7967dd0 Update extras submodule ref to pull in misc's py3 fixes 2016-10-15 09:17:49 -07:00
Toshio Kuratomi
9a49506677 Update submodule refs 2016-10-15 08:24:33 -07:00
James Cammarata
0d5206f90c Don't mark parent role complete for nested include_role calls
The PlayIterator was written without nested roles in mind, but since
include_role can nest them we need to check to see if we've moved into
a new role which is a child via nesting.

Fixes #18026
2016-10-14 14:28:40 -05:00
Matt Clay
7e2fc88218 Fix docs fragment typo. 2016-10-14 09:50:15 -07:00
Brian Coca
ff1e52184f Better error for bad role def 2016-10-14 11:38:09 -04:00
James Cammarata
6bdcb3a392 Make sure free strategy is returning proper TQM constants
Fixes #18023
2016-10-14 09:23:35 -05:00
John R Barker
9183bb6391 docs_fragments formatting and typo improvements (#17981) 2016-10-14 15:13:15 +01:00
Brian Coca
b169a61c20 toggle missing handler errors/warnings via config 2016-10-13 16:54:02 -04:00
Michael Scherer
f6bcd0f9a1 Add support for distribution_major_version on NetBSD. (#15885) 2016-10-13 16:25:55 -04:00
Peter Sprygada
936bca9fc6 fixes issue when checking if sessions are supported (#18013)
the supports_sessions() call was sending the command as a string instead
of a list which is required when transport is eapi.  This fixes that bug
2016-10-13 15:46:39 -04:00
Peter Sprygada
b1666020a9 adds additional exception handling in open() (#18003)
The open() method will now catch a socket.timeout exception and raise
a ShellError.
2016-10-13 15:13:00 -04:00
Peter Sprygada
bce31a11c2 minor fix for checking kwargs in get_config() (#18002)
The get_config() method was checking for a nonexistent kwarg that would
cause an exception.  This fixes that problem.
2016-10-13 15:12:49 -04:00
Brian J. Dowling
2be2f35373 Quick ansible-doc fix -- don't run pager if there was an error (no text) 2016-10-13 15:10:47 -04:00
Brian Coca
cdb5a222c5 restored 'results' filters
tests do not work the same, restoring old filters to keep backwards compat
tests now only implment the new normalized 'tense'
2016-10-13 13:21:40 -04:00
Peter Sprygada
65ea24f4bb adds log message for successful connection and disconnection (#17993)
The network module will now log a message when it connects to a remote host
successfully and specify the transport used.  It will also log a message
when the module discconnect() method is called.
2016-10-12 21:47:58 -04:00
Peter Sprygada
3badb212fb fixes issue in eos shared module for earlier versions of EOS (#17980)
Earlier versions of EOS that do not support config sessions would
create an exception.  This fix will now check if the device supports
sessions and if it doesn't, it will fall back to not using sessions
2016-10-12 20:16:20 -04:00
Toshio Kuratomi
33f5c25f41 Update submodule refs to pickup firewalld fix 2016-10-12 15:16:40 -07:00
Toshio Kuratomi
bf3d546d9a Only dispkay failure to use cryptography at a higher verbosity
Fixes #17982
2016-10-12 10:48:36 -07:00
Toshio Kuratomi
e5478a212f Update submodule refs 2016-10-11 16:13:11 -07:00
stephane
a32e48555d Correct delegated_host_name check
In fb50698da3 a check for delegated_host_name being defined was added. Make this
check safer as it breaks some playbooks.
2016-10-11 11:15:53 -07:00
Bruno Rocha
b06fb2022c Fix unbound method call for JSONEncoder (#17970)
* Fix unbound method call for JSONEncoder

The way it is currently it will lead to unbound method error

```python
In [1]: import json

In [2]: json.JSONEncoder.default('object_here')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-872fdacfda50> in <module>()
----> 1 json.JSONEncoder.default('object_here')

TypeError: unbound method default() must be called with JSONEncoder instance as first argument (got str instance instead)

```

But what is really wanted is to let the json module to raise the "is not serializable error" which demands a bounded instance of `JSONEncoder()`

```python
In [3]: json.JSONEncoder().default('object_here')
---------------------------------------------------------------------------
TypeError: 'object_here' is not JSON serializable 

```


BTW: I think it would try to call `.to_json` of object before raising as it is a common pattern.

* Calling JSONEncoder bounded `default` method using super()
2016-10-11 08:31:53 -07:00
Chris Houseknecht
77de83730d Add warnings when installing container type roles 2016-10-09 14:38:40 -04:00
Toshio Kuratomi
9f6bbf8c2f Switch get_config to use a single value_type parameter to determine type.
This is better API as the booleans could conflict with each other.

If the config value is a string, make sure to return it as a text string
rather than a byte string.
2016-10-07 18:57:39 -04:00
Ryan S. Brown
6444992afb Update submodule ref for devel 2016-10-07 17:18:10 -04:00
Pavlo Shchelokovskyy
aa1ec8af17 Make interprocess polling interval configurable (#16560)
As recently there was back-and-forth with this hardcoded value
(0.001 -> 0.01 -> 0.005), obviousely the optimal value for it depends on
Ansible usage scanario and is better to be configurable.

This patch adds a new config option in DEFAULT section,
`internal_poll_interval`, with default of 0.001 corresponding to the
value hardcoded in Ansible v2.1.
This config option is then used instead of hardcoded values where
needed.

Related GH issue: 14219
2016-10-06 14:30:20 -05:00
Toshio Kuratomi
9f9a960ceb Update submodules 2016-10-06 10:24:30 -07:00
Toshio Kuratomi
1efe782b46 Refactor parsing of CLI args so that we can modify them in the base class
Implement tag and skip_tag handling in the CLI() class.  Change tag and
skip_tag command line options to be accepted multiple times on the CLI
and add them together rather than overwrite.

* Make it configurable whether to merge or overwrite multiple --tags arguments
* Make the base CLI class an abstractbaseclass so we can implement
  functionality in parse() but still make subclasses implement it.
* Deprecate the overwrite feature of --tags with a message that the
  default will change in 2.4 and go away in 2.5.

* Add documentation for merge_multiple_cli_flags
* Fix galaxy search so its tags argument does not conflict with generic tags
* Unit tests and more integration tests for tags
2016-10-06 10:46:58 -04:00
Strahinja Kustudic
9962245b92 Moves 'statically included' messages to -vv verbosity (#17918) 2016-10-06 08:55:24 -05:00
James Cammarata
e26bce5221 Sleep briefly while waiting for pending results to reduce CPU churn 2016-10-06 08:50:17 -05:00
Peter Sprygada
087fb4265f adds new option to get_config to grab config with passwords (#17915)
In order for the config to be returned with vpn passwords, the get_config()
method now supports a keyword arg include=passwords to return the desired
configuration.  This replaces the show_command argument
2016-10-05 22:11:32 -04:00
Adrian Likins
41d6f5c635 out.split('\n') -> out.splitlines() (#17879)
foo.split('\n') is picky about the type of 'foo'.
if 'foo' is a bytes type, then foo.split('\n')
will fail on py3 with:

   TypeError: a bytes-like object is required, not 'str'

The foo.split('\n') change isn't strictly required
when run_command returns native str types, but it
is more idiomatic and conceptually also supports other
line endings.
2016-10-05 18:15:23 -04:00
James Cammarata
0a86ddc251 Move searching for roles in the cur basedir to last
Searching the DEFAULT_ROLES_PATH and the roles basedir should come
before this, and it has been a long standing oversight.

Fixes #17882
2016-10-05 01:25:19 -05:00
Mark Szymanski
3a6743fb54 Allowing hostcolor colours to be set 2016-10-04 20:31:10 -04:00
Brian Coca
d9d7e413a5 fixed storing of cwd 2016-10-04 14:24:45 -04:00
Toshio Kuratomi
23305540b4 Make ini parsing slightly more robust
Prior to this commit, the ini parser would fail if the inventory was
not 100% utf-8.  This commit makes this slightly more robust by
omitting full line comments from that requirement.

Fixes #17593
2016-10-04 11:24:50 -07:00
Brian Coca
74b7590211 better inventory error messages 2016-10-04 07:23:26 -07:00
James Cammarata
d09f57fb3a Check for substates in is_failed before checking main state failure
Fixes #17882
2016-10-04 01:21:07 -05:00
Toshio Kuratomi
08a58ae025 Fix for run_command tests now that it returns native strings 2016-10-03 18:45:28 -07:00
Brian Coca
125a8d3c65 no need for warnings in first_found 2016-10-03 20:23:33 -04:00
Brian Coca
54ce6a9b7a fix for include_role conflating vars/directives 2016-10-03 19:24:37 -04:00
Brian Coca
d4b2ea3ec8 include_role process name from options, not task 2016-10-03 18:29:50 -04:00
Toshio Kuratomi
965dcabed2 Update submodule refs for the command fix with new run_command 2016-10-03 15:06:52 -07:00
Adrian Likins
d0bdfc2abb Specify run_command decode error style as arg (#17886)
* Specify run_command decode error style as arg

Instead of getting the stdout/stderr text from
run_command, and then decoding to utf-8 with a
particular error scheme, use the 'errors' arg
to run_command so it does that itself.

* Use 'surrogate_or_replace' instead of 'replace'

For the text decoding error scheme in run_command calls.

* Let the local_facts run_command use default errors

* fix typo
2016-10-03 14:10:50 -07:00
Adrian Likins
2addc09050 cast/copy keys() to list to avoid py3 errors
In py3, dict.keys() is a view and not a copy of the
dicts keys, so attempting to delete items from the dict
while iterating over the keys results int

RuntimeError: dictionary changed size during iteration

Resolve by casting .keys() to a list() type.
2016-10-03 13:10:00 -07:00
Adrian Likins
9f673e0725 open anziballs payload 'wb' for py3 2016-10-03 13:06:50 -07:00
Toshio Kuratomi
ddd20627a4 Make run_command return native strings
This changes the return value on python3   Return value on python2 was
already byte strings (which is the native str type there.)
2016-10-03 11:48:37 -07:00
Chris Houseknecht
ab93d5aae4 Merge pull request #17873 from chouseknecht/fix_3964
Let docker-py decode pull response
2016-10-03 12:48:48 -04:00
James Cammarata
447ab0ab95 Bumping devel version to 2.3.0 2016-10-03 11:46:31 -05:00
Chris Houseknecht
fa7e572a96
Let docker-py decode pull response 2016-10-03 11:38:12 -04:00
Matt Davis
64d9de6b25 bump core submodule ref 2016-10-03 07:28:19 -07:00
Brian Coca
49ce0c8bac only change dir to playdir if local
fixes #17869
fixes #17770
2016-10-03 08:44:25 -04:00
Toshio Kuratomi
5bc3cb278c Remove unicode escape (#17866)
* Remove unicode-escape which is not present on python3

Alternative fix for #17305

* Enable the assemble test on python3

* Fix other problems with assemble on python3
2016-10-02 22:12:51 -07:00
Toshio Kuratomi
ddb3f91562 Update submodule refs 2016-10-02 21:54:21 -07:00
Guido Günther
14a9bd6a1c Add foreman callback plugin (#17141) 2016-10-03 00:12:12 -04:00
Toshio Kuratomi
f72b123584 On python3, subprocess needs another arg to pass extra file descriptors 2016-10-02 15:29:54 -07:00
Toshio Kuratomi
64c446d9c0 Normalize text and byte type in the ssh plugin helper method that builds up an ssh command (#17860)
Mostly cleanups to make the code more efficient, more pythonic, and obey
the unicode sandwich strategy more but also Fixes #17832
2016-10-02 14:55:55 -07:00
Peter Sprygada
b0cd624aef fixes issue with run_commands raising error (#17861)
The junos run_commands() method should raise an error when an RpcError is
returned but didn't when using display=text.  This fixes that error
2016-10-02 16:47:22 -04:00
Peter Sprygada
50c445c356 switches the kickstart arg from True to False for eos (#17858)
The kickstart kwarg should be set to False for eos based devices and
was set to True.  This change cleans up problems loading json output
from cli commands

All eos_command test cases are now passing successfully

fixes #17441
2016-10-02 15:03:03 -04:00
Peter Sprygada
512ef49c8a adds new exception for adding condition statements to Conditional (#17859)
When adding condition statements, the Conditional instance will now generate
an AddConditionError if is unable to map the condition to a function in the
instance
2016-10-02 14:47:58 -04:00
Matt Davis
a4e5187661 bump core submodule ref for windows async_wrapper bugfix 2016-10-02 08:55:44 -07:00
Matt Davis
aa0ad073b8 bugfixes to JSON junk filter, added unit/integration tests to exercise (#17834) 2016-10-02 08:03:42 -07:00
James Cammarata
657506cddd Ensure the "attempts" key is set in the final result for do/until loops
Fixes #17258
2016-10-02 01:06:13 -05:00
Senthil Kumar Ganesan
7e0074263d Remove the dellosX_template module (#17836) 2016-10-01 14:31:51 -04:00
Matt Davis
60b322e3ca bump core submodule ref for async_wrapper fixes 2016-09-30 16:17:45 -07:00
Indrajit Raychaudhuri
becb4765c3 Add homebrew in squash_actions list (#16966)
`homebrew`, like other package modules in the existing `squash_actions` list can
benefit from `with_items` loops optimization.
2016-09-30 18:07:09 -04:00
Brian Coca
dfff608ceb dzdo prompt fix
fixed tests
dzdo has 2 paths now, with and w/o password
fixes #17838
2016-09-30 17:58:19 -04:00
Brian Coca
6008fbd5cf fix fact gathering flag 2016-09-30 17:58:19 -04:00
Brian Coca
24e81ddd1c add ssh error message to failure 2016-09-30 17:58:19 -04:00
James Cammarata
e4ee9de3f4 Fixing parentage of include_role objects for param inheritance
Fixes #17686
2016-09-30 16:05:43 -05:00
Peter Sprygada
6be2f0bded fixes unicode conversation from junos get_config() method (#17841)
The junos config should convert the returning configuration to unicode
not str.  This fixes that issue.
2016-09-30 16:31:25 -04:00
Peter Sprygada
5b4f3b1eda adds better error handling when conditional fails (#17839)
When the conditional cannot extract a value from the result string,
an unhandled exception would be raised.  This fix now gracefully handles
the exception
2016-09-30 16:25:40 -04:00
Peter Sprygada
9faf56a345 fixes issue when calling save_config() and transport is nxapi (#17835)
An unhandled exeception is raised with using nxapi transport and setting
the save argument to true.  This fix will allow the configuration to be
saved regardless of the transport.

fixes ansible/ansible-modules-core#5094
2016-09-30 15:00:10 -04:00
Trond Hindenes
35fba5718d Bugfix: fixes new-alias bug when debugging powershell (#17816) 2016-09-30 09:46:06 -07:00
Makc
c6fa701ab1 jabber callback (#16981)
* jabber callback

* delete empty lines

* grammar fix

* fix: do not print error when jabber callback disabled

* change callback version 1 -> 2
2016-09-30 12:06:53 -04:00
Chris Houseknecht
e6eed3c3db Merge pull request #17818 from chouseknecht/devel
Parse role dependencies consistently
2016-09-30 10:03:32 -04:00
Chris Houseknecht
8300e67cbe Use new YAML syntax in role dependencies. 2016-09-29 21:57:12 -04:00
jctanner
fff161f2f6 Smart mode for sftp+scp (#17813)
If the sftp fails, roll over to scp by default. This saves users
from having to know about the scp_if_ssh method when sftp is broken
on the remote host.
2016-09-29 17:44:54 -04:00
Toshio Kuratomi
458990084e Update submodule refs 2016-09-28 23:10:23 -07:00
Peter Sprygada
c534f8f9fc fixes conditional processing with junos and xml data structures (#17801)
The conditional processing was failing due for two reasons:

1) The xml to json conversion string was not happening before the runner
   was processing the results
2) The Conditional instance was not parsing conditionals encoded with []

This fix address both issues.
2016-09-28 20:58:43 -04:00
cinerama70
fb50698da3 Graceful error handling when delegate_to host null (#17453) (#17783)
Currently, if the host specified in delegate_to for a task is null,
Ansible will crash with a stack trace. Add a check for this state
and handle the error appropriately.
2016-09-28 19:24:32 -04:00
Brian Coca
3c42651fc7 fixed typo 2016-09-28 18:34:19 -04:00