Compare commits

...

644 commits

Author SHA1 Message Date
Jean-Philippe Evrard
b20520f500 Adds the non-deprecated ansible_host var (#34452)
OpenStack dynamic inventory is still using the deprecated
ansible_ssh_host. This patch adds ansible_host until such
time as ansible_ssh_host is removed

This is a backport from [1].

[1]: https://github.com/ansible/ansible/pull/23153
2018-05-22 16:40:44 -05:00
Matt Clay
fde8c9b4ef Pin httptester SHA.
(cherry picked from commit 8232c95f42)
2018-03-20 07:14:54 -07:00
Matt Clay
02f3eed0e9 Fix uri test on Python 2.6.
(cherry picked from commit 1fd9a616a4)
2018-03-19 23:15:16 -07:00
James Cammarata
aea7abcb15 New release v2.3.4.0-0.1.rc1 2018-02-28 12:51:06 -06:00
Matt Clay
0db22a8b29 Temporarily disable subversion test on osx.
(cherry picked from commit f283edcb19)
2018-02-26 13:27:43 -08:00
Matt Clay
52f6b03a11 Fix rst link syntax.
(cherry picked from commit 1f43d5fc75)
2018-02-26 11:34:55 -08:00
ademmers
fca0cccebf system/service module initctl location usage (#19712)
* Call initctl version based on initctl's retrieved location

* Remove the use of start/stop/restart in favor of initctl

* Provide correct argument order for initctl usage
2018-02-26 11:38:04 -06:00
Toshio Kuratomi
c0d3915bd2 Add https retrieval via TLSv1.2 to changelog 2018-02-23 11:07:27 -08:00
Toshio Kuratomi
6020c0d4f6 Prefer the stdlib SSLContext over urllib3 context
We do not go through the effort of finding the right PROTOCOL setting if
we have SSLContext in the stdlib.  So we do not want to hit the code
that uses PROTOCOL to set the urllib3-provided ssl context when
SSLContext is available.  Also, the urllib3 implementation appears to
have a bug in some recent versions.  Preferring the stdlib version will
work around that for those with Python-2.7.9+ as well.

Fixes #26235
Fixes #25402
Fixes #31998

(cherry picked from commit 725ae96e1b)
2018-02-23 11:05:43 -08:00
Matt Clay
bc9b44d907 Fix pip integration test.
(cherry picked from commit ea70b49b11)
2018-01-31 23:28:24 -08:00
Matt Clay
fb14b36f7f Remove EOL openSUSE Leap 42.2 from CI.
(cherry picked from commit abbc1ed4e6)
2018-01-31 21:53:23 -08:00
s-hertel
857f959135 loop doesn't exist in 2.4
(cherry picked from commit 6a6ae0cede)
2018-01-24 08:51:05 -08:00
Toshio Kuratomi
5bd16d438d Add environment in loop fix to changelog 2018-01-24 08:51:05 -08:00
Sloane Hertel
deaa9a21f9 Fix using loops with environment and add tests (#32796)
(cherry picked from commit 7bb35e8781)
2018-01-24 08:51:05 -08:00
Toshio Kuratomi
6233daaa44 Add ssh flush() fix to changelog 2018-01-18 09:34:57 -08:00
Matt Martz
f0cae29d57 Ensure that the become password is written on py3 in the ssh connection plugin. Fixes #34727
(cherry picked from commit 29c1d5cb5d)
2018-01-18 09:33:24 -08:00
Adam Miller
2c116617de
Fix Linux blockdevice size computation (#34645)
Linux' sysfs _always_ reports device size in 512b sector units,
regardless of the device's actual, physical blocksize.

Backport of PR#34475 originally written by jtru

Original Commit ID: 603d31685c01caa62db137d8aab1a54180e3373d

Signed-off-by: Adam Miller <admiller@redhat.com>
2018-01-10 06:27:22 -08:00
Matt Clay
204d0f7bea Make xattr test conditional on feature support.
(cherry picked from commit 77726b471f)
2018-01-08 23:58:30 -08:00
Matt Davis
fcba7a086a avoid use of Write-Host in config script
(cherry picked from commit 82996d5b267994d9806bbba62ceee2cd6613e9da)
2017-12-20 22:52:24 -08:00
Matt Davis
a787488990 add GlobalHttpFirewallAccess arg
(cherry picked from commit a9ca0389b6cdf2992b04d6bafbd2cb3feb861d12)
2017-12-20 21:35:20 -08:00
James Cammarata
0255ab2e27 New release v2.3.3.0-1 2017-12-20 11:49:41 -06:00
Matt Clay
797d999513 Update FreeBSD completion for ansible-test.
(cherry picked from commit 73132d3906)
2017-12-05 22:34:30 -08:00
Matt Clay
3a963a68c2 Limit pytest < 3.3.0 for python 2.6.
(cherry picked from commit 58286ef93b)
2017-12-05 22:32:45 -08:00
Matt Clay
6e1f29cde2 Limit paramiko to < 2.4.0 for python 2.6.
(cherry picked from commit 5f5e150771)
2017-12-05 22:32:37 -08:00
Matt Clay
30b0103ceb Update FreeBSD versions used in CI. 2017-12-05 21:21:01 -08:00
Matt Clay
218103d540 Update vyos completion in network.txt.
(cherry picked from commit 3a6fad38fa)
2017-11-22 10:17:35 -08:00
Matt Clay
f0f2031eaf Use vyos/1.1.8 in CI.
(cherry picked from commit 887f227994)
2017-11-22 10:16:13 -08:00
Matt Clay
b123fa4d6f Fix and re-enable zypper* integration tests in CI.
(cherry picked from commit 781219bcfd)
2017-11-17 15:54:23 -08:00
Matt Clay
7256dd17ae
Pin Shippable build image to v5.4.1. (#32988)
* Pin Shippable build image to v5.4.1.
* Remove `pre_ci` to eliminate extra git sync.
2017-11-16 11:34:40 -08:00
James Cammarata
54cfb022c2 New release v2.3.3.0-0.3.rc3 2017-11-10 16:00:14 -06:00
Toshio Kuratomi
012998c5f7 Revert "Add template lookup fix to changelog"
This reverts commit 994ed2c443.
2017-11-09 10:24:43 -08:00
Toshio Kuratomi
6eb485c136 Revert "Do not escape backslashes when using the template lookup plugin"
This reverts commit 2b40463a48.

Decided that this change was too big for a bugfix release.  Make it
2.4.x only.
2017-11-09 10:24:43 -08:00
Matt Clay
49f3dda7f6
WIP: Resolve CI issues for stable-2.3. (#32605)
* Revert "If pip install requirements.txt fails, upgrade pip (#32399)"

This reverts commit 2fb4f547a9.

* Avoid pep8 user warning in 1.7.1.
* Limit cryptography version for Windows tests.
* Upgrade pip in virtualenv for pip test.
* Upgrade pip in virtualenv for groupby_filter test.
* Upgrade pip in virtualenv for template_jinja2_latest test.
2017-11-06 17:32:47 -08:00
Toshio Kuratomi
b77de1bd5d If we can't find a .py file for the system six, use our bundled copy instead.
Fixes #32567
2017-11-06 11:22:54 -08:00
John R Barker
2fb4f547a9
If pip install requirements.txt fails, upgrade pip (#32399)
* If pip install requirements.txt fails, upgrade pip

* Use pycodestyle instead of pep8 (#25947)

(cherry picked from commit 4b3d6dfa8a)

* Ignore more

* pylint lint fixes

* Ignore more
2017-11-06 15:54:37 +00:00
Ganesh Nalawade
eaa2fcc73f Fix password leak in logs for provider argument (#32215)
* Fix password leak in logs for provider argument

Since provider argument is not validated against a spec
the `no_log` arguments are not handled leading to password
leaking to syslogs.
To fix this:
*  Mask password and other `no_log` provider arguments in action plugin
*  In case of eapi and nxapi as the password is used in module code,
*  copy the provider password to top-level password argument which
*  handles `no_log` correctly. This will, however, throw a deprecation
*  warning message for password arg even if it is not given as a
*  top-level argument.

* Remove auth details from provider args in action plugin

* Update CHANGELOG
2017-11-03 11:27:14 -05:00
Matt Martz
4c6612eeba Fix patching to epel package
(cherry picked from commit be9cc70b74)
2017-10-30 14:41:30 -07:00
Toshio Kuratomi
c4085eb07c Add hostname fix for rhel7 2017-10-18 16:30:18 -07:00
Martin Krizek
b27e86ac07 hostname: fix for a new version of rhel (#31839)
Fixes #31811
(cherry picked from commit efec43dd1e)
2017-10-18 16:29:33 -07:00
James Cammarata
9e116c1b65 New release v2.3.3.0-0.2.rc2 2017-10-17 11:39:33 -05:00
Matt Clay
4cddc2e7c9 Backport ansible-test updates from devel.
The primary change is use of the new servers for
provisioning remote OS X instances for use in CI.
2017-10-12 21:52:17 -07:00
Brian Coca
03a0ea682b restored 2.4/2.5 compat 2017-10-12 12:58:25 -04:00
sethp-nr
152c895b1f wait_for: treat broken connections as "unready" (#28839)
* wait_for: treat broken connections as "unready"

We have observed the following condition while waiting for hosts:

```
Traceback (most recent call last):
  File "/var/folders/f8/23xp00654plcv2b2tcc028680000gn/T/ansible_8hxm4_/ansible_module_wait_for.py", line 585, in <module>
    main()
  File "/var/folders/f8/23xp00654plcv2b2tcc028680000gn/T/ansible_8hxm4_/ansible_module_wait_for.py", line 535, in main
    s.shutdown(socket.SHUT_RDWR)
  File "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 228, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 57] Socket is not connected
```

This appears to happen while the host is still starting; we believe something is
accepting our connection but immediately resetting it. In these cases, we'd
prefer to continue waiting instead of immediately failing the play.

This patch has been applied locally for some time, and we have seen no adverse
effects.

* wait_for: fixup change

We were missing an import and a space after the `#`

(cherry picked from commit 402b095841)
2017-10-12 11:40:42 -04:00
James Cammarata
60d9513efb New release v2.3.3.0-0.1.rc1 2017-09-30 12:17:08 -05:00
Brian Coca
4eea3e91ad restored 'static' which is still used in 2.3 2017-09-30 12:17:08 -05:00
Brian Coca
a9e8f38342 validate include_role args (#28077)
* validate include_role args
* removed unused static

(cherry picked from commit d89dd75769)
2017-09-29 10:52:46 -04:00
Toshio Kuratomi
fd37f27d2b Add jenkins_plugin CVE fix to changelog 2017-09-26 11:25:20 -07:00
Toshio Kuratomi
4d5b9ae803 Remove example of using params for the url_password
params could be logged so never use it for passwords.

Also add code to raise an error if passwords are used in that field.

References #30874

(cherry picked from commit 863fcb5ace)
2017-09-25 18:34:53 -07:00
Brian Coca
43e0a0369b fix for yaml inventory in not likeing 'none' 2017-09-20 16:55:36 -04:00
jborean93
82754c7a31 revert win_file headers back to original format so cherry picking works 2017-09-19 07:15:35 +10:00
jborean93
a606321975 Updated changelog to for win_file check mode fix 2017-09-19 06:50:16 +10:00
Dag Wieers
f1f8d0319f win_file: Fix check-mode issue removing dirs (#30475)
This fixed #30442

(cherry picked from commit 229a86c952)
2017-09-19 06:49:45 +10:00
Ganesh Nalawade
4f5bf2e08f Use safe_load to load yaml (#30408)
Replace `yaml.load` with `yaml.safe_load`

(cherry picked from commit 8c3bf20a13)
2017-09-15 14:39:16 +05:30
Toshio Kuratomi
b4004e5046 Document boolean default value treatment (#30062)
* Consistency and document treatment of default bool values

* Document that default bool values can be any Ansible recognized bool.
  choose the one that reads better in context
* For fragments used by the copy module, make bool types use type=bool and not choices

* Edit for clarity

(cherry picked from commit 8a2f069468)
2017-09-14 13:29:25 -07:00
Rene Moser
48d821e611 update changelog for Tower module_utils SSL fix 2017-09-14 09:26:59 -07:00
ethackal
4a58187103 Fixes verify_ssl option when False in ansible_tower module util (#30308)
* Fixes verify_ssl option when False in ansible_tower module util

* fixed comparison to None per PEP-8 standards

(cherry picked from commit 4980ebf064)
2017-09-14 09:26:59 -07:00
Sloane Hertel
e8e2c5a9f7 [cloud] update the local variable route_table with the latest tag changes (#23136) (#29989) 2017-09-14 12:30:09 +10:00
jborean93
01cbdb9878 Update changelog to show windows become fix on output streams 2017-09-14 07:06:15 +10:00
Jordan Borean
4f049ab74e fixed become to show the stdout and stderr streams instead of the StreamReader (#30254)
(cherry picked from commit 77b2aca5a2)
2017-09-14 07:03:49 +10:00
Toshio Kuratomi
a859c8bba5 Add vars_prompt fix to changelog 2017-09-13 10:53:27 -07:00
Andrea Tartaglia
48dd3be986 Updated Display.do_var_prompt to use to_native on prompt ( Fixes #30265 ) (#30285)
* Updated Display.prompt to use the normalized prompt message.

(cherry picked from commit ea8af15dfe)
2017-09-13 10:42:02 -07:00
Brian Coca
4114a4cfc5 removed orig_exec as that is 2.4 feature 2017-09-12 17:21:22 -04:00
Andrea Tosatto
ba4f0e9228 make os_security_group_rule idempotent (#23707)
* Fix issue #19610
(cherry picked from commit 6b6e5665aa)
2017-09-12 07:24:54 -07:00
Matt Martz
b8e02b0dc1 Create a new pipe for sshpass on retries. Fixes #29095
(cherry picked from commit d043ba2673)
2017-09-11 08:49:56 -07:00
Matt Clay
09d38049eb Fix wheel dependency on python 2.6. (#29388)
* Fix wheel dependency on python 2.6.
* Limit wheel version for tox on python 2.6.

(cherry picked from commit 50ae33d3c1)
2017-09-11 00:06:30 -07:00
Toshio Kuratomi
c22f8a4ae4 Add blockinfile fix to changelog 2017-09-09 12:50:51 -07:00
Anton Baklanov
4367a45668 Fixes #26793: convert insert regex to_bytes before searching
(cherry picked from commit fcad4f38b4)
2017-09-09 12:49:44 -07:00
Toshio Kuratomi
afa71ace67 Add py3 jail fix to changelog 2017-09-09 11:56:20 -07:00
Pierre Guinoiseau
4bb52d52b9 Fix py3 string issue in jail connection plugin (take 2) (#28374)
* Fix py3 string issue in jail connection plugin

(cherry picked from commit 436b173b24)
2017-09-09 11:54:53 -07:00
Toshio Kuratomi
5fbe1e2798 Add cloudtrail profile fix to changelog 2017-09-09 10:09:42 -07:00
s-hertel
a4edac599a Fix connection credentials for cloudtrail module in stable 2.3. Fixes #28821. 2017-09-09 10:07:28 -07:00
Matt Clay
d31ba7240f Revert "Temporarily disable failing opensuse test jobs."
This reverts commit 31d2eb0828.

(cherry picked from commit 67c7bd8745)
2017-09-07 11:49:19 -07:00
Brian Coca
2c2ca9b34e updated chlog 2017-09-06 23:27:10 -04:00
Brian Coca
54ad5b5f49 fix check mode for solaris enable/disable (#29049)
(cherry picked from commit 7804049592)
2017-09-06 23:26:44 -04:00
Matt Clay
aa6f3f91ba Temporarily disable failing opensuse test jobs.
(cherry picked from commit 31d2eb0828)
2017-09-06 19:51:29 -07:00
Brian Coca
7787ed26bf less confusing 'args' message (#29053)
* less confusing 'args' message
* fix test

(cherry picked from commit fe3b4325c2)
2017-09-06 19:50:07 -04:00
Ganesh Nalawade
64db935b25 Ensure proper conversion while backing up of junos config (#28958) (#28992)
* Ensure proper conversion while backing up of junos config

* Minor changes

* Fix review comment

*  Open config backup file in binary mode

(cherry picked from commit cc9ed352dd)
2017-09-04 20:48:35 +05:30
Toshio Kuratomi
46934c195c Add filetree non-ascii fix to changelog 2017-09-01 08:35:01 -07:00
Sergey Scherbakov
0ba2fb1b47 Fix encoding error on grp.gr_name, which can contain non-ascii chars at domain PCs (#25804)
* Fix encoding errors on grp.gr_name, which can contain non-ascii character at LDAP/AD domain workstations

* fix: utils.to_text() is now used instead of py3-incompatible unicode() method

(cherry picked from commit c16d258a27)
2017-09-01 08:34:22 -07:00
Ganesh Nalawade
20e47b6132 Junos_config unicode (#23369) (#28913)
* Try to handle unicode output more sensibly

* Appears I'm getting latin1 instead

Ugh.

(cherry picked from commit 689b93bf14)
2017-09-01 15:42:16 +05:30
Scott Butler
9dc41ae578 CSS for versioned docs TOC header. 2017-08-31 21:04:22 -07:00
Scott Butler
368130f131 Updated CSS for versioned docs - back ported from level. 2017-08-31 17:42:31 -07:00
Scott Butler
37523edaf7 Fixed index so TOC points to new community landing page. 2017-08-31 16:46:36 -07:00
John R Barker
578255dd4b Bulk rst/community backport (#28896) 2017-08-31 15:43:08 -04:00
Abhijeet Kasurde
c4984a4c4c Handle AttributeError in vmware module_utils
When vm has no MAC address assigned to it. Fix handles
attribute error if MAC address is not set.

Fixes: #28471

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2017-08-31 13:43:19 +02:00
Alex Shteinikov
11346284b1 [cloud] Backport handling of CloudFormation failure state - fixes #24596 #24596 #26603 (#28713) 2017-08-30 16:31:55 -04:00
Matt Clay
051bcb2c6f Replace opensuse42.1 with opensuse42.3 in CI.
(cherry picked from commit af9b0ba47b)
2017-08-30 11:11:15 -07:00
anarcat
8bb12fba3d fix two broken absolute links (#28766)
* fix two broken absolute links

instead of using absolute links, we use normal Sphinx mechanics to make sure those links work portably in the future

* reformat list so paragraphs are properly indented
2017-08-30 15:57:10 +01:00
Jordan Borean
4b7e4cfa2b updated changelog for win-get-url TLS backport 2017-08-30 16:53:34 +10:00
Dave
8db83172d3 win_get_url.ps1 - enable TLS1.1/TLS1.2 if they're available but disabled (#26833)
(cherry picked from commit 4cec83471c)
2017-08-30 16:51:16 +10:00
Brian Coca
c3917f395a updated with cp 2017-08-29 09:50:57 -04:00
Brian Coca
0777565a29 allow pesky 'bridge' facts to bypass facts filter (#28401)
* allow pesky 'bridge' facts to bypass facts filter

fixes #27729, #23577

* I ate pepe

(cherry picked from commit c06f8a3f9b)
2017-08-29 09:50:10 -04:00
Brian Coca
3adb5a62e0 updated changelog as per backport 2017-08-25 22:15:54 -04:00
Abhijeet Kasurde
f5af666164 Update connection logic in vmware module_utils
Fix updates logic of connection in vmware module_utils.

Fixes: #28577

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2017-08-25 22:15:19 -04:00
Toshio Kuratomi
abfada309c Add efs py3 fix to changelog 2017-08-23 11:47:32 -07:00
Patrick Murray
fe8d1fbf8d Fixing Issue #27270 - EFS TypeError (#27318)
* Fixing Issue #27270 regarding a TypeError invoked by the addition of a Filter type and List type.

* Fix SecurityGroup from always being reported as changed on PY3

On Python3, filter returns a generator.  This causes us to report that
security groups are always defined on Python3 even when there are none.

Also change filter() calls into list comprehensions.

(cherry picked from commit b828b5d33b)
2017-08-23 11:45:51 -07:00
Rene Moser
275676f2cf update changelog, add fix for exoscale auth 2017-08-22 15:21:44 +02:00
Rene Moser
d60b61ed04 exoscale: fix api_key param auth typo
(cherry picked from commit 58cd107166)
2017-08-22 15:19:17 +02:00
Toshio Kuratomi
9e37d827d4 Add user module fix to changelog 2017-08-19 13:17:34 -07:00
Mike
75facf5324 fixed #28183 - user module shadowfile update on SunOS (#28276)
* fixed #28183 - user module shadowfile update on SunOS
(cherry picked from commit b5a00d05d3)
2017-08-19 13:15:55 -07:00
Toshio Kuratomi
bb4283edc4 Add zip filter py3 fix to changelog 2017-08-17 10:37:22 -07:00
Brian Coca
1e3231c967 removing tests cause they rely on 2.4 semantics 2017-08-16 13:53:53 -04:00
Matt Clay
a0c3182f2e Fix PEP 8 issues. 2017-08-16 09:09:04 -07:00
Brian Coca
b544df3425 fixed changelog and added alternatives backport 2017-08-16 10:38:52 -04:00
Pilou
873f023b13 alternatives: handle absent link, add integration tests (#27967)
* alternatives: add integration tests

* alternatives: handle absent link (fix AttributeError)

Error occurred at least on Debian Stretch and OpenSuse 42.2:
Traceback (most recent call last):
  File "/tmp/ansible_RY6X41/ansible_module_alternatives.py", line 161, in <module>
    main()
  File "/tmp/ansible_RY6X41/ansible_module_alternatives.py", line 113, in main
    current_path = current_path_regex.search(display_output).group(1)
AttributeError: 'NoneType' object has no attribute 'group'

update-alternatives stdout sample:
dummy - manual mode
  link best version is /usr/bin/dummy1
  link currently absent
  link dummy is /usr/bin/dummy

* alternatives: PEP 8 fixes

* alternatives: fix copyright in integration tests

* alternatives: nested loops handle more than 2 items

Thanks to Michael Scherer (@mscherer) for pointing that.

* alternatives: enable integration tests

(cherry picked from commit 016cd0691c)
2017-08-16 10:36:39 -04:00
Andreas Olsson
ee116637d1 Fix zip filter for Python3
Using the now bundled six library.

Fixes #28117

(cherry picked from commit c9cdc3a259)
2017-08-14 23:04:32 -07:00
Toshio Kuratomi
457f0bdc74 Add ssh smart transport mode (for sftp/scp/piped) to the changelog 2017-08-14 08:14:25 -07:00
Toshio Kuratomi
78d153d5a0 the smart transport is broken by ssh retry code
1fe67f9 introduced retries to the ssh connection put file and fetch
file.  Unfortunately, that change broke the smart transport because it
started raising exceptions instead of returning from _run().  This
breakage is documented in #23711.

An attempt to fix it was made at #23717 but the first attempt was
objected to as needing to touch too much code.  The second attmept was
objected to as smart was forced to encapsulate retries (thus retrying
a sftp "rety" times before trying scp "retry" times and then finally
moving onto piped).  This third attempt has retries encapsulate smart.
So each sub-transport is tried once and if all three fail, another retry
attempt is made which tries each of the three again.

Fixes #23711
Fixes #23717

(cherry picked from commit 3edac559d3)
2017-08-14 08:12:41 -07:00
David Newswanger
99fcf6d824 fixed a syntax problem that was preventing a warning box from being displayed
(cherry picked from commit ebb1d75ee0)
2017-08-10 12:38:08 -07:00
Ritesh Khadgaray
8348890d7f rhn+register: do not pass username/passwd for registration if none is specified. (#24244) 2017-08-10 10:01:26 -04:00
schwatvogel
5b6b402755 Fixes #23558 rpm key ids (#27847)
* Changed rpm-keyid extraction and verification method
* minor style fixes
* fixed rpm key deletion,added integration test for mono key,fixed wording in integration tests

(cherry picked from commit b8d371ca8b)
2017-08-09 07:33:25 -07:00
David Newswanger
e471fb3a94 added integration tests for rpm_key (#26134)
(cherry picked from commit 5242ff1b59)
2017-08-09 07:33:10 -07:00
Toshio Kuratomi
26e6b0c639 iAdd file env var fix to changelog 2017-08-08 09:17:21 -07:00
Andreas Olsson
caaebec7f0 Don't do additional path expand in file module
Since the module's path parameter is of the AnsibleModule type path
it's already being expanded. Hence no need to have the
set_fs_attributes_if_different method do its own expand.

This additional expand is an actual problem when the file module runs
recursively, as real existing file names can be mistakenly expanded to
something completely wrong and non-existing.

Fixes #25005
Fixes #25639

(cherry picked from commit ccc68f7157)
2017-08-08 09:14:07 -07:00
Toshio Kuratomi
e024cc8470 Fix rabbitmq modules for python3 import
Also get rid of unnecessary capture of exception into a variable for
python-2.4 compat.

(cherry picked from commit 8894c57753)
2017-08-07 19:45:07 -07:00
Toshio Kuratomi
d6d795cef0 Fix ROADMAP rst format 2017-08-07 18:45:32 -07:00
Toshio Kuratomi
33c3a3459a Add changelog entry for yum and rabbitmq fixes 2017-08-07 17:29:04 -07:00
Nicolas Porcel
d4d6b17228 Clean downloaded rpm files after install (#20594)
(cherry picked from commit 616d5ddc93)
2017-08-07 17:29:04 -07:00
Nicolas Porcel
d36a651588 Fix yum with rpm file or url when state=latest (#27775)
(cherry picked from commit fa6ce54011)
2017-08-07 17:29:04 -07:00
Jordan Borean
278d450329 Added missing return info for win_stat (#27736) 2017-08-07 17:29:04 -07:00
Abhijeet Kasurde
6b8bd1ec09 Add check for requests module
Fix adds check for requests Python module and suggests user to install,
if no requests module installation found.

Fixes: #27643

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
(cherry picked from commit 748fa5db35)
2017-08-07 17:29:04 -07:00
John R Barker
95dbb735f1 2.3portingguide (#27671)
* Docs porting guides 2.0 &  2.3 (#27632)

* Create new "Porting Guide" section

Create new landing page
Add porting_guide_2.3

* correct CHANGELOG

* Document blocks

* Document named blocks

* OpenBSD & async action plugins

* OpenBSD & async action plugins

* versioadded for name

* review comments

(cherry picked from commit df58d943d3)

* Correct merge
2017-08-07 17:29:04 -07:00
Toshio Kuratomi
a92e08c39e Add python3 fix in digital_ocean_tag 2017-08-07 17:29:03 -07:00
Abhijeet Kasurde
33e0e5d4fe Fix JSON parsing for Python3
Fix corrects the parsing of JSON output in Python 3
environment by using to_text API.

Fixes: #26489

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
(cherry picked from commit b266204afa)
2017-08-07 17:29:03 -07:00
acrewdson
566299dd31 'Response' makes more sense here than 'request'
(cherry picked from commit 0f2b3d55b4)
2017-08-07 17:27:28 -07:00
Brian Coca
62106d5dcf corrected with_dict example
fixes #17636

(cherry picked from commit 001be55ef0)
2017-08-07 17:27:28 -07:00
Toshio Kuratomi
da332138dd Fixes to pip with git install instructions
* use git+https:// in the example url because not everyone will have ssh
  keys registered on github
* Remove the link to the github tarballs as they do not work.  users can
  use releases.ansible.com instead.

(cherry picked from commit bf42f94021)
2017-08-07 17:27:28 -07:00
Rene Moser
cb1bd058ad changelog: add fixes to be in 2.3.3 2017-08-07 17:27:28 -07:00
Rene Moser
1244624d7c Fix for check_mode in archive (#26788)
Fix adds check_mode fix for archive module.

Fixes: #26750

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
(cherry picked from commit 156b29b26b)
2017-08-07 17:27:28 -07:00
David Moreau-Simard
b5c51c4c56 Improve release and development cycle documentation
This commit:
- Adds a table highlighting the status of each version and provides
  a link to each major release's changelog
- Re-inforces how stable versions are maintained and for how long
- Moves this documentation out of the developer tree (this is
  interesting for users too!) while keeping a link there.

(cherry picked from commit e2d874c744)
2017-08-07 17:27:28 -07:00
Arthur Burkart
53a53ebf73 Updates docs to match module behavior (#26658)
* Updates docs to match module behavior

* Updates docs to match module behavior

Updated using advice from jimi-c

* Removes snippet about git module before v1.8.3

At suggestion of robinro

(cherry picked from commit 90a42d1e53)
2017-08-07 17:27:28 -07:00
Toshio Kuratomi
5d6da688ed Add changelog entry for the seboolean module fix 2017-08-07 17:27:28 -07:00
Toshio Kuratomi
3aca12b451 Import to_native 2017-08-07 17:27:28 -07:00
David Newswanger
49a27da0b2 added unicode iosxr fix to changelog 2017-08-07 17:27:28 -07:00
David Newswanger
5c97a27d20 fix unicode errors in iosxr
(cherry picked from commit 0b5b5ec50a)
2017-08-07 17:27:28 -07:00
Toshio Kuratomi
2d9cbdc107 Add changelog for ios_config change 2017-08-07 17:27:28 -07:00
David Newswanger
60b3c2ad9c Fix #26918: IOS TypeError (#26999)
Fix IOS TypeError

* if flags are None, then ' '.join(flags) fails
* fixed get_defaults_flag so that it returns a list, and ignores lines with white space

Fixes #26918
(cherry picked from commit 9f64e446c6)
2017-08-07 17:27:28 -07:00
Toshio Kuratomi
8e949c616e Add module_utils example next to library examples (#25390)
(cherry picked from commit 37e757286d)
2017-08-07 17:27:28 -07:00
Toshio Kuratomi
95ac4c4a96 Add changelog for docker_login py3 fix 2017-08-07 17:27:27 -07:00
Will Medlar
4251db2345 [Fixes #26690] Supports Python 3 handling of base64 encoding (#26876)
* [Fixes #26690] Supports Python 3 handling of base64 encoding

* Set text auth to separate variable for reuse

(cherry picked from commit 3f67d167fe)
2017-08-07 17:27:27 -07:00
Rene Moser
927548e2f6 cloudstack: cs_role: fix UnboundLocalError in check mode
(cherry picked from commit 6d81c9670f)
2017-08-07 17:27:27 -07:00
ioggstream
ad61c12b06 known_hosts: always use lowercase hostnames for host keys (#26850)
(cherry picked from commit dc408f9035)
2017-08-07 17:27:27 -07:00
Toshio Kuratomi
80ae8e9b29 Add py3 fix for AnsibleModule.run_command to changelog 2017-08-07 17:27:27 -07:00
Toshio Kuratomi
fdc8a75218 Need regex and string types to match when cleaning arguments for logging
Fixes #25078

(cherry picked from commit b49be56c5b)
2017-08-07 17:27:27 -07:00
Toshio Kuratomi
81278323f3 Add hacking/env-setup python3 fixes to the changelog 2017-08-07 17:27:27 -07:00
Sloane Hertel
896becab34 hacking/test-module: fix for python3 (#26194)
* make hacking/test-module compatible with python3
(cherry picked from commit 113f92548a)
2017-08-07 17:27:27 -07:00
Jordan
db3ae98233 changelog: added entry for win_acl fix 2017-08-07 17:27:27 -07:00
Jordan Borean
c55b078d92 win_acl: registry support for special service accounts (#26629)
* Fixes #22968
* `APPLICATION PACKAGE AUTHORITY` ACLs also apply to the registry

* fixed nested for loop

(cherry picked from commit 81c22522a5)
2017-08-07 17:27:27 -07:00
Toshio Kuratomi
d038997d5c Add fix for postgres_user to changelog 2017-08-07 17:27:27 -07:00
Toshio Kuratomi
3d0462b456 Add pause module py3 fix to changelog 2017-08-07 17:27:27 -07:00
Toshio Kuratomi
30f813d716 Fix the pause module for python3
* On python3, stdin goes through a buffer that translates from raw bytes
  to text.  this interferes with pause as it (1) performs universal
  newline conversion and therefore '\r' is turned into '\n' and (2) the
  buffering prevents us from getting the typed characters immediately
  (possibly a python3 bug?)  Using the raw byte stream that's behind the
  text decoder fixes these problems.

Unrelated cleanups:
* Use to_text instead of str for conversion into strings to avoid possible tracebacks
* Use either \r or \n as the end of a line.

Fixes #26278
Resolves #26446

(cherry picked from commit 5ceabe939d)
2017-08-07 17:27:27 -07:00
Toshio Kuratomi
994ed2c443 Add template lookup fix to changelog 2017-08-07 17:27:27 -07:00
Toshio Kuratomi
2b40463a48 Do not escape backslashes when using the template lookup plugin
This brings the lookup plugin inline with what the template module does.

Fixes #26397

(cherry picked from commit cf5fb0acdf)
2017-08-07 17:27:27 -07:00
Toshio Kuratomi
743b396e5e Add azure py3 fixes to changelog 2017-08-07 17:27:27 -07:00
Raja
6e34fd16d5 Fix Python3 Errors in Azure Cloud Module
When using Python3, the exec_module function errors out with a
unsupported operand type(s) for +: 'dict_keys' and 'list'
error when adding the .keys() to a static list. Use the explicit
list function to make a list of keys and then add to the ['tags'] list.

(cherry picked from commit 171d903d04)
2017-08-07 17:27:27 -07:00
Toshio Kuratomi
f00d44e0b4 CHANGELOG entry for synchronize fix 2017-08-07 17:27:27 -07:00
Toshio Kuratomi
ac8598f1db Fix synchronize setting user variable
The user variable stores whether we need to set user@ in our connection
string.  It's now being used at the toplevel of the run() method so the
default needs to be calculated further up the stack

Fixes #24910

(cherry picked from commit 6908038036)
2017-08-07 17:27:27 -07:00
Matt Davis
584af4e9f8 2.3.2 CHANGELOG update for win_updates and non-pipelined fixes 2017-08-07 17:27:27 -07:00
Jordan Borean
392d268809 win_find: fix for empty nested directories (#26164)
(cherry picked from commit 98fc54f02d)
2017-08-07 17:27:27 -07:00
Michael De La Rue
a8afa6b96c Fix hacking/test-module to allow running modules with pdb (#23339)
* Fix hacking/test-module to allow running modules with pdb

* add emacs autosave files to gitignore

(cherry picked from commit 56d33a2967)
2017-08-07 17:27:27 -07:00
James Cammarata
c7052b42c7 New release v2.3.2.0-1 2017-08-04 15:24:09 -05:00
James Cammarata
611048c6ba Finalizing date for 2.3.2 final release in CHANGELOG 2017-08-04 15:18:06 -05:00
bobsaintcool
435cdcf84a <doc/dev/modules: Fix an RST typo into external link> (#27615)
Make a link a valid external hyperlink targets.
2017-08-03 14:28:24 -07:00
Matt Clay
c869423e0c Use python-crypto instead of python2-cryptography. 2017-08-03 12:39:25 -07:00
Matt Clay
96dd226235 Update RPM spec and make targets. (#27712)
(cherry picked from commit b54d00f2de)
2017-08-03 12:39:25 -07:00
Trishna Guha
eff04e9fa3 modify indent to avoid re-run src template fail (#27689)
Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
2017-08-03 13:50:44 +05:30
Trishna Guha
3d446b2fab fix NameError eos_config (#27684)
Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
2017-08-03 11:39:53 +05:30
syquus
987ad8993c Typo on path return Value : "authorzied" (#27555)
Seen on official documentation: http://docs.ansible.com/ansible/latest/authorized_key_module.html
2017-08-02 22:09:49 +01:00
James Cammarata
76b5b35458 New release v2.3.2.0-0.5.rc5 2017-08-01 18:51:23 -05:00
Toshio Kuratomi
360703234e add changelog 2017-08-01 15:39:34 -07:00
Toshio Kuratomi
25c95a96a8 Fix for ansiballz filenames conflicting with python stdlib modules
The AnsiBallZ wrapper is transferred to the remote machine with
a filename similar to the Ansible-module it runs.  For modules like copy
and tempfile, this can end up conflicting with stdlib modules on the
remote machine depending on how python is setup there.  We have a little
bit of code in the wrapper to deal with this by removing the path that
the ansible module resides in from sys.path.

On MacOSX, that code was having a problem.  The path the module ends up
in included a symlinked directory so we were looking for a path in
sys.path but we had to look for the unsymlinked path instead.

Fix that by using os.path.realpath() instead of os.path.abspath()

(cherry picked from commit 15902f2496)
2017-08-01 15:21:21 -07:00
John R Barker
46846b1973 docs: fix community meetings link (#27264) (#27586)
(cherry picked from commit 9c50933a80)
2017-08-01 17:43:18 +01:00
Abhijeet Kasurde
d0a1679113 [Backport] Multiple fixes for vmware_guest_facts (#27464)
* Updated Folder documentation
* Updated Example
* Updated imports
* Added correct logic to use FindByInventoryPath() API
* Remove get_exception in favor of to_native
* Remove redundant get_obj method

Fixes: #24691

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2017-08-01 09:35:10 -04:00
Abhijeet Kasurde
504558eab3 [Backport] vmware_guest: Fix "KeyError: 'changed'" (#27456)
This is a backport of vmware_guest fix.

Fixes: #27390

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2017-08-01 09:34:43 -04:00
Matt Clay
6698dc00e3 Add potential work-around for expect on macOS.
http://pexpect.readthedocs.io/en/stable/commonissues.html#truncated-output-just-before-child-exits

(cherry picked from commit 0c7602fb59)
2017-07-31 13:22:52 -07:00
Brian Coca
e579afc432 added backports 2017-07-31 13:10:19 -04:00
Brian Coca
96296e8c71 make random_choice more error resilient (#27380)
* make random_choise more error resilient

fixes #27373

(cherry picked from commit b79744f282)
2017-07-31 11:48:26 -04:00
Brian Coca
a53cc97f19 ensure prefix in plugin loading to avoid conflicts
when using 'all' to load all plugins were ending in main namespace
creating conflicts with each other and random modulesr
 i.e. when trying to access json callback we were getting json 'parsing' lib

(cherry picked from commit b93b9e68d7)
2017-07-31 11:48:26 -04:00
Jean-Frédéric
c276466262 Fix error with meta: clear_facts (#26406)
Using `meta: clear_facts` was failing with
`coercing to Unicode: need string or buffer, Host found`

This applies the same fix as 3101e24.

Fixes #26405
(cherry picked from commit 23041c3b6c)
2017-07-28 09:19:09 -05:00
James Cammarata
532b4338f4 New release v2.3.2.0-0.4.rc4 2017-07-26 09:54:02 -05:00
Martin Krizek
7a6c5dd1ab Fix using DNF group upgrade/remove api
(cherry picked from commit 119c9e5d6e)
2017-07-26 07:39:49 -07:00
Brian Coca
8f8d4d103f updated with recent cherry picks 2017-07-26 10:07:25 -04:00
Brian Coca
5b39de5013 better reading of 'facts'
(cherry picked from commit c7e841e0e4)
2017-07-26 09:37:02 -04:00
Toshio Kuratomi
9d435fd47b Add seboolean fix to the changelog 2017-07-25 15:55:48 -07:00
Michael Scherer
1628a25d8d Workaround python-libselinux API change (#25685)
In the past, selinux.security_get_boolean_names did return 'bytes'
on python 3, but this was changed to return string later, cf:
b8711e2eaf

So we have to convert to bytes only if the API return us bytes.

Fix #25651
(cherry picked from commit e2d6ecfa40)
2017-07-25 15:54:54 -07:00
Jason Tibbitts
0a7bad68dc Avoid using deprecated group_install API
DNF's base.group_install() function accepts a string as its first
argument.  Prior to DNF-2, compatibility code existed which allowed this
function to accept a base.comps.Group object instead.  That is no longer
possible.

Pass "group.id" to base.group_install() instead of "group" to work
around this.

(cherry picked from commit ccce74cf7b)
2017-07-25 15:36:58 -07:00
Will Thames
2385e2be27 include_role handlers bug fix (#26335)
* Ensure that include_role properly fires handlers

include_role needs to ensure that any handlers included
with the role are added to the _notified_handler and
_listening_handler lists of the TaskQueueManager, otherwise
it fails when trying to run the handler.

Additionally, the handler needs to be added to the
PlayIterator's `_uuid_cache` or it fails after running
the handler

Add more uuid debug statements - this code was hard
to debug with existing debug statements, so add more
uuid information at little additional output cost.

Fixes #18411

* Add tests for include_role handlers

Tests for #18411

(cherry picked from commit ef8c9798d3)
2017-07-25 16:37:24 -05:00
KeepZero
91f70a4462 Fix performance issue while match pattern in large inventory list 2017-07-25 17:19:48 -04:00
Toshio Kuratomi
28fa228d93 Fix for nonutf8 filenames causing crashes when setting permissions
Fixes #23861

(cherry picked from commit b26ee657b5)
2017-07-25 00:16:57 -07:00
Toshio Kuratomi
795e75433e Expand the result from pwd to make the test more robust
Sometimes MacOSX's pwd doesn't return an expanded path.  Not sure why
but this test is still valid if we expand it via a playbook filter so
go ahead and do that.

(cherry picked from commit 6a41a4f311)
2017-07-24 10:27:46 -07:00
Toshio Kuratomi
ddc124297a Update changelog for utf8 recurse files bug 2017-07-24 09:22:08 -07:00
Toshio Kuratomi
9a05efcab9 Fix for to_text and to_bytes error handlers
* surrogate_then_strict doesn't exist.  Switch to surrogate_or_strict
  instead.
* Found some bugs in the _text.py implementation
  * The composed error handlers (error handlers which are made up of two
    or more python encoding error handlers) had a wrong string in it,
    'surrogate_or_escape' doesn't exist.  Replaced that with
    'surrogate_or_replace' which is the correct handler name.
  * Left comment about the implicit conditions that are part of the
    surrogate_then_replace code path

Fixes #23865
Fixes #23861

(cherry picked from commit fc5d71de0d)
2017-07-24 09:22:08 -07:00
Matt Clay
0e0400b12e Disable zypper* tests which are timing out.
(cherry picked from commit d031ff8aec)
2017-07-24 09:21:00 -07:00
Toshio Kuratomi
8eba034942 Add su_pass fix to changelog 2017-07-24 08:00:59 -07:00
Toshio Kuratomi
13901eeb70 Fix legacy su handling (bad conditional would not fire at the right time)
(cherry picked from commit aa9941aaf7)
2017-07-24 07:59:52 -07:00
John R Barker
668266552e Bulk dev_guide from devel to 2.3 (#27205)
* Bulk dev_guide from devel to 2.3

* Scot's feedback
2017-07-24 09:38:43 +01:00
John R Barker
065f74f0ee Bulk import network doc changes from devel to 2.3 (#27204) 2017-07-23 14:23:30 +01:00
Trishna Guha
b66d9cc14e fix nxos_interface state default (#27108)
Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
2017-07-21 12:56:31 +05:30
James Cammarata
a1c15a9277 New release v2.3.2.0-0.3.rc3 2017-07-20 09:23:52 -05:00
John R Barker
316ef8a069 Add make target for printing version (#26657) (#27030) 2017-07-19 09:04:17 +01:00
Ricardo Carrillo Cruz
a3817721fc Cherry pick EAPI tearup/down tests changes (#26938)
* Replace Ethernet5 for Ethernet2 on eos integration tests (#26674)

In our CI, we only have 3 NICS: Management1, Ethernet1 and
Ethernet2.
(cherry picked from commit 4006b5d18f)

* Add CHANGELOG entry
2017-07-18 11:02:56 +02:00
Ricardo Carrillo Cruz
4490cc9e9e Cherry pick eapi tearup down changes (#26935)
* Remove enable EAPI from prepare_eos_tests (#26910)

Enabling EAPI is not common on CLI *and* EAPI tests, therefore
enabling it should be put at the eapi.yaml task level.
(cherry picked from commit 258d2058cd)

* Add missing provider on disable eapi tasks (#26928)

(cherry picked from commit 4532c791fd)

* Add CHANGELOG entry
2017-07-18 10:33:19 +02:00
Ricardo Carrillo Cruz
32b4342209 Cherry pick 2.4 eos banner fixes (#26904)
* Fix multiple EOS EAPI code and test issues (#26651)

(cherry picked from commit b81209c187)

* Fix eos_banner basic-motd eapi asserts (#23398)

The commands in EAPI does not contain the plain command sent to the
device as a one liner, but it is split in cmd/input keys.
(cherry picked from commit ce9826d76e)

* Add CHANGELOG entry
2017-07-17 17:59:31 +02:00
Trishna Guha
85e9a07117 privilege escalation for eos integration test (#26597)
Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
2017-07-10 19:30:30 +05:30
Toshio Kuratomi
23020bf9d9 Revert "postgresql_user: fix bugs related to 'expires' option (backport #23862) (#26539)"
This reverts commit 5432414c9d.
2017-07-07 10:13:17 -07:00
Pilou
5432414c9d postgresql_user: fix bugs related to 'expires' option (backport #23862) (#26539)
* Change 'valid until' even it's the only updated field

(cherry picked from commit 460d932aa8)

* value is changed when another value is provided

(cherry picked from commit 460d932aa8)

* value isn't returned when unset

(cherry picked from commit 460d932aa8)

* Fix comparison between user input and applied configuration

(cherry picked from commit 460d932aa8)
2017-07-07 10:11:33 -07:00
James Cammarata
022ba4fbea New release v2.3.2.0-0.2.rc2 2017-07-07 11:46:40 -05:00
Matt Clay
71444d0c37 Update CHANGELOG.md to include wait_for fix. 2017-07-05 19:08:49 -07:00
Matt Clay
154b0d2210 Fix wait_for with newer versions of psutil. (#26455)
* Add support for newer psutil versions.

(cherry picked from commit 895e6c5d06)
2017-07-05 19:06:49 -07:00
Ganesh Nalawade
4deb45eff6 Making iosxr check_args call module_util/iosxr check_args. Fixes #25501 (#26261) (#26444)
(cherry picked from commit 1d62283796)
2017-07-06 00:20:08 +05:30
Jordan
b223c7e0a2 changelog: fix for win_chocolatey where it didn't fail if the version did not exist 2017-07-05 08:31:12 +10:00
Dag Wieers
ffadbf680d win_chocolatey: Ensure chocolatey to fail (#26416)
Currently chocolatey is not failing when the user requests version X,
but version X is not available in the repository.

Obviously the module should fail in this case.

This fixes #25393
(cherry picked from commit b9d018885a)
2017-07-05 08:29:54 +10:00
Jordan
29ac96e09e changelog: added fix for win_regedit and idempotency on dwords 2017-07-05 08:26:36 +10:00
Jordan Borean
7f5a0715bf win_regedit: fix for same dword value (#26415)
(cherry picked from commit 8e9d04043a)
2017-07-05 08:24:26 +10:00
Jordan
8ced21101f changelog: added win_chocolatey upgrade of all packages fix 2017-07-05 08:10:23 +10:00
Dag Wieers
69175a5077 win_chocolatey: Fix updating 'all' packages (#26417)
This fixes #15018
(cherry picked from commit 69ade22243)
2017-07-05 08:09:01 +10:00
René Moser
333d177325 changelog: add backported fixes by me (#26403) 2017-07-04 19:07:37 +02:00
René Moser
0c8459b01b cloudstack: cs_instance: fix KeyError: 'sshkeypair' (#26399)
(cherry picked from commit 37b22673fb)
2017-07-04 17:20:10 +02:00
Brian Coca
fa65417ba0 updated with change 2017-07-03 23:07:53 -04:00
R. Soto
144d0b6f9e update auth_flag variable after STARTTLS connection is established, fixes #26376
(cherry picked from commit 5c0c985547)
2017-07-03 23:07:53 -04:00
Matt Davis
8ad00c0128 CHANGELOG update for become/runas fix 2017-07-03 17:48:27 -07:00
Matt Davis
f9f83c5826 converted become runas to explicit CreateProcessWithLogonW
* fixes become_method: runas for unprivileged users
* sets permissions on tempdir appropriately
* allows automatic system environment generation for new token (old Process.Start way prevents this)
* add basic become runas tests

(cherry picked from commit 6d99a0a93469448a2fd23169e31036263102e7e1)
2017-07-03 17:43:50 -07:00
John R Barker
e947321831 Remove trailing newlines (#26350) 2017-07-03 13:58:32 +01:00
John R Barker
9d94a309ca Remove test of openvswitch_db state (#26349)
The `state:` option didn't exist in Ansible 2.3, so don't test it.
2017-07-03 13:18:32 +01:00
Yanis Guenane
1ad1ad6ace Missing prepare_ovs_tests directory (#26337)
openvswitch_db tests have been backported from devel to stable-2.3[1],
but the role to prepare_ovs_tests was missing from the backport, hence
the test, when run complained about missing roles.

This commit aims to bring this directory into stable-2.3 tree.

[1] https://github.com/ansible/ansible/pull/26330
2017-07-03 10:02:07 +02:00
John R Barker
94660f792a Add openvswitch_db tests (#26330)
openvswitch_db tests were added during 2.4 development, though the
module still existed in 2.3, so backport the tests.

This is needed for distributed-ci.
2017-07-02 21:59:07 +01:00
Matt Davis
b1e0f78a07 fix win_updates failure with dict-typed args
Switch to dicts in common code caused silent failures during arg translation, so default values and non-check-mode were always used.
* fixes #23653
* fixes #24062
* fixes #22938
* fixes #25156
(cherry picked from commit e6f364e2d661861939b567a219207fd855966e02)

(cherry picked from commit 95fead611cccdd432122168fa300002e10f01037)
2017-06-30 17:20:28 -07:00
Matt Davis
888096ec4c 2.3.2 CHANGELOG update for win_updates and non-pipelined fixes
(cherry picked from commit 2a6e5eedb758ec6480f6b31bfa79124de2e758df)
2017-06-30 17:20:19 -07:00
René Moser
0c31f31385 cloudstack: cs_template: default is_routing=None, fixes template upload for users (#26248)
(cherry picked from commit 363761fc16)
2017-06-29 17:46:10 +02:00
Matt Clay
e36f568194 Limit yamllint version on python 2.6.
(cherry picked from commit 55aec8ebc9)
2017-06-29 08:35:32 -07:00
Julien Vey
6ad5a31437 parted: Add missing LC_TYPE override for env vars (#26242)
(cherry picked from commit 7f6c7c6334)
2017-06-29 15:57:03 +02:00
Trishna Guha
269550993d fix nxos_feature (#26132)
Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
2017-06-29 11:05:02 +05:30
Virgil Dupras
e943505ab2 letsencrypt: FIX CN parsing to work with OpenSSL 1.1 (#25935)
As we can see in
9537453586
:

CN used to be without whitespaces around the `=` but OpenSSL 1.1 introduced
whitespaces:
1.0.1: subject=/CN=example.com
1.1.0: subject=CN = example.com

This commit makes them optional.

OpenSSL 1.1 is present on the newly-released Debian Stretch, so absence
of this fix makes us not being able to use this module on this distro.
(cherry picked from commit 9474f20f2d)
2017-06-28 09:21:21 +02:00
James Cammarata
7424e1c417 New release v2.3.2.0-0.1.rc1 2017-06-27 11:33:22 -05:00
Matt Davis
6cca156fde re-enable non-pipelined mode for Powershell (#26124)
* fixes #23986
* fixes 3rd-party Windows connection plugins that don't support pipelining (eg awsrun)

(cherry picked from commit 6677559c698f15c582fba80d866f46458848f974)
2017-06-26 22:57:59 -07:00
Matt Clay
940a78c5ba Update FreeBSD pg test to use postgresql95-server.
The py-psycopg2 package now requires postgresql95-server instead of
postgresql93-server. Installing py-psycopg2 will automatically remove
postgresql93-server if it is installed, breaking integration tests.

(cherry picked from commit 15beaed6bc)
2017-06-26 13:54:40 -07:00
Brian Coca
1731962155 updated changelog 2017-06-26 16:01:20 -04:00
Eugen C
44b3d67ef3 Fix ansible ad-hoc to respect ANSIBLE_STDOUT_CALLBACK (#26098)
* Fix ansible ad-hoc to respect ANSIBLE_STDOUT_CALLBACK

* Ansible ad-hoc 'stdout_callback' should work only with 'bin_ansible_callbacks'

(cherry picked from commit 6d59160744)
2017-06-26 16:01:01 -04:00
John R Barker
ba453452f0 Missing Else statement (#25457) (#26113)
Missing the final Else statement in the conditional statement
(cherry picked from commit e391206acc)
2017-06-26 19:26:39 +01:00
Rene Moser
4b49b96ca1 cloudstack: cs_host: revamp fixes several issues
(cherry picked from commit 1f5839777b)
2017-06-26 14:41:48 +02:00
loqutus
7c38f7cdfa fix networkdid->networkid in cs_nic.py (#25914)
(cherry picked from commit f6e4019804)
2017-06-24 09:49:58 +02:00
James Cammarata
eeaa676577 Don't include dependent roles in the dep chain for include_role
The dependency chain should not include roles below the parent, as it
can introduce very weird things like conditionals from child deps impacting
non-related roles.

Fixes #25136

(cherry picked from commit 020317b21bf54f49db56b95893be5e63a17ea4f8)
2017-06-22 13:22:31 +01:00
Brian Coca
5512c94017 correctly set delegated host name in results
(cherry picked from commit a457c2af59)
2017-06-20 15:00:06 -04:00
John R Barker
cac3cfa9eb MySQL Password updates (#25825)
* MySQL Password updates

* Disable user_password_update_test

(cherry picked from commit 448efdb9e5)
2017-06-19 16:22:37 -07:00
Brian Coca
bf34bdb32c updated changelog with backport 2017-06-19 19:11:51 -04:00
Brian Coca
3a25aca272 fixed danlging version_info 2017-06-19 19:10:41 -04:00
Matt Clay
73aa4c930d Revert "add a any() to wait_for for python 2.4 compatibility (#25876)"
This reverts commit 7fbd7fc4f8.
2017-06-19 15:46:19 -07:00
Brian Coca
ec26494167 backported delegation/facts fix, see #25880 2017-06-19 18:09:15 -04:00
loqutus
7fbd7fc4f8 add a any() to wait_for for python 2.4 compatibility (#25876) 2017-06-19 15:48:02 -04:00
John R Barker
e998b7e40f 2.3bug25844flowdock (#25873)
* Correct failure message in flowdock (#25844)

As per documentation and code, external_user_name is
required parameter is case of type 'chat'.
Fix corrects error message displayed to user.

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
(cherry picked from commit a4ebde1516)

* Fix for flowdock error message when external_user_name is missing
2017-06-19 17:23:29 +01:00
John R Barker
2bfdb77ed4 2.3bug20202 (#25864)
* htpasswd: fix passlib module version comparison (#20202)

Previously, we used StrictVersion which failed to parse some passlib
version strings. For example, Debian currently ship passlib with a
__version__ of '1.7.0.post20161128115349'

StrictVersion throws an exception when parsing this version string.

Change to using LooseVersion which successfully parses version strings
such as this.

Fixes #20199
(cherry picked from commit 0be0aa5f10)

* htpasswd: fix passlib module version comparison
2017-06-19 14:00:27 +01:00
John R Barker
8813b4f03d Update docs based on 23946 (#25860)
* Update docs based on 23946

Original PR https://github.com/ansible/ansible/pull/23946

* files/copy.py is now clean
2017-06-19 11:59:40 +01:00
Abhijeet Kasurde
e1dbb02b66 Fix module params assignment in jabber module (#25850)
Fix corrects variable assignment from module params

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
(cherry picked from commit 561d678f52)
2017-06-19 10:08:51 +02:00
John R Barker
a40b1c455d Use stronger password for MySQL (#25821) (#25822)
Previously we were getting "Your password does not satisfy the current policy requirements"
Possibly caused by a software update on Fedora
(cherry picked from commit 7ee7fa7332)
2017-06-17 13:12:30 +01:00
Trishna Guha
b5c2f2dc71 fix KeyError on eAPI transport for use_ssl and validate_certs (#25788)
Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
2017-06-16 16:26:00 +05:30
Trishna Guha
dddcf0f6ad fix deprecation for transport param when not used (#25782)
Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
2017-06-16 14:56:40 +05:30
James Cammarata
8c2e9257d4 Do not set default value for any_errors_fatal in Base
Setting default values for FieldAttribute values created in the Base class
prevents the _get_parent_attribute() code from working correctly, as the value
is always non-None.

Related to #22924

(cherry picked from commit c5b8196ff1)
2017-06-16 01:56:39 -05:00
Brian Coca
ff578cc1b3 updated clog with vault view patch 2017-06-15 11:32:34 -04:00
Brian Coca
419d21c509 pager should not log
fixes #25719

(cherry picked from commit df2fcecd62)
2017-06-15 11:32:13 -04:00
netservers
5605091dc1 Have cs_host search both name and ipaddress fields when fetching the host from listHosts. (#25628)
Make ip_address an alias of name to allow playbooks to more clearly make
use of IP addreses.
(cherry picked from commit d5becd728e)
2017-06-14 09:19:53 +02:00
Sloane Hertel
6cb0666d0a [cloud] ASGRetry - add retry on throttling and add backoff to calls in ec2_asg (#24339)
* Use AWSRetry decorator in ec2_asg

* Rebased on stable-2.3

Added tries, delay, and backoff

Adding throttling to the list of errors for AWSRetry

* Create custom retry class for ec2_asg while it still uses boto

* remove changes to ec2.py

* BotoServerError exception has error_code attribute

* add info to the changelog
2017-06-13 15:55:57 -04:00
Brian Coca
08f3b83812 clog update 2017-06-13 10:38:51 -04:00
Brian Coca
ae5c9f93b7 add validation to fetch for source/dest
also added missing display

(cherry picked from commit c4169d93e8)
2017-06-13 10:38:18 -04:00
Brian Coca
19cf1b2281 Updated changelog with last 2 cps 2017-06-12 10:26:52 -04:00
Alan Loi
68d21e6729 Fix hash_key_name to be optional for delete (#25009)
(cherry picked from commit 3ac9273507)
2017-06-12 10:26:02 -04:00
Abhijeet Kasurde
09635b8460 Correct fail_json call in rpm_key
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
(cherry picked from commit e160bcf237)
2017-06-12 09:11:09 -04:00
Toshio Kuratomi
ebf7c6c37b Add docker connection plugin py3 fix to the changelog 2017-06-10 07:12:48 -07:00
Matt Martz
ccd170cbdd Convert docker cmd output to native, early
(cherry picked from commit 23eebb62e6)
2017-06-10 07:11:39 -07:00
Rene Moser
be0b86ce81 cloudstack: cs_zone: fix missing type bool for params
(cherry picked from commit f8e3540e9f2ba2da48d5e9a4bcef1769d34bd3fd)
2017-06-09 18:11:37 +02:00
Ondra Machacek
603d52f8fe cloud: ovirt: Fix upgraded state of the ovirt_hosts module (#25535) 2017-06-09 11:45:19 -04:00
Phil Nelson
a1ceb1c404 Template parent include path before finding its dirname (#23202)
Given parent include path "{{ var | default('path/file.yml') }}"
os.path.dirname(parent_include_path) yields {{ var | default('path/
which is incorrect in itself but also causes templating errors
due to unbalanced quotes. Fix both problems by templating
parent include path before finding its dirname.
2017-06-08 23:48:20 -05:00
John R Barker
b6e4266aa5 2.3bug25396 2 (#25486)
Don't fail when creating a Foreman organization fixes(#25299)
2017-06-08 12:55:25 +01:00
John R Barker
9aa1a2b871 Fix for RabbitMQ 3.6.7 endpoint return code (#25485)
https://github.com/ansible/ansible/pull/22715
2017-06-08 12:40:30 +01:00
John R Barker
c5971f018f RabbitMQ 3.6.7 changed a couple of response codes (#22715) (#25484)
(cherry picked from commit 6bd1681203)
2017-06-08 12:36:06 +01:00
Toshio Kuratomi
8455251bec Document ansible-galaxy fix 2017-06-07 07:40:01 -07:00
Michael Scherer
e4fae653da Fix --force for unversionned requirements (#23391)
In current stable (2.2), ansible galaxy install --force do erase
a role, even if the version is not set. This commit should restore
that specific behavior, in accordance to people reports:
  https://github.com/ansible/ansible/issues/11266#issuecomment-273801480

It was also the behavior planned in the initial discussion:
"if you're not fixing versions in your roles file, then it's fine
to expect that the role will be reinstalled each time you run
ansible-galaxy install.", cf https://github.com/ansible/ansible/pull/12904
(cherry picked from commit 78836ec0b9)
2017-06-07 07:38:24 -07:00
Toshio Kuratomi
ba6276a4b1 Add AnsiBallZ low disk space error to changelog 2017-06-07 06:40:51 -07:00
Toshio Kuratomi
ef5e9806dd When cleaning up the AnsiBallZ tempdir we need to not fail if the tempdir wasn't created
If the temp directory creation failed in mkdtemp then temp_path is never
given a value.  This would lead to a NameError exception which would
obfuscate the original error (out of disk space being a common one).  By
catching NameError, python will raise the original exception as we want.

Fixes #17215

(cherry picked from commit 80c1765653)
2017-06-07 06:39:47 -07:00
Ondra Machacek
1b00e43d2a cloud: ovirt: Fix searching of network in datacenter (#25248)
(cherry picked from commit bcc5bffd8e)
2017-06-07 00:28:53 +02:00
Toshio Kuratomi
9954077a0a Changelog entry for pip virtualenv fix 2017-06-05 17:05:08 -07:00
Ramon
c37aca62ef fix proposal for issue #25151: [python3] pip failed to create virtual env when using custom command (pyvenv) (#25241)
* Fix proposal for bug 25151

* Fix proposal for bug 25151 - pip module, pyvenv validation

* Graceful fail when virtualenv_python is defined and virtualenv_command uses the venv module

* Making sure that venv is being used as a modue "-m venv"

* Updating syntax in validations

* Updating syntax in validations - fixing stupid typo "[)"

* Raising an error if virtualenv_command is pyvenv or venv and virtualenv_python is used

* trailing whitespace gone, pyvenv, venv validation and docs update

* cleaning whitespaces from blank lines

(cherry picked from commit bc4a8dbaa4)
2017-06-05 17:03:54 -07:00
Robin Roth
5ebaaf26bb Reenable git tests (#25341)
* Revert "Temporarily disable failing git test."
* Use correct hash for depth=1 test

(cherry picked from commit 8f7c8ef3a5)
2017-06-05 12:21:53 +08:00
Matt Clay
dd5dde6c0e Temporarily disable failing git test.
(cherry picked from commit dab1b1fe5b)
2017-06-04 20:42:20 +08:00
Toshio Kuratomi
767f0e5d3f Changelog entry for digital_ocean dyn inventory py3 fix 2017-06-03 13:57:34 -07:00
James Elford
db121421a6 python 3 compatibility: import guard around ConfigParser
In python3 `ConfigParser` has become `configparser`. Added
an import guard that aliases it back to the old name.

(cherry picked from commit bc9dbf38b0)
2017-06-03 13:56:45 -07:00
Ricardo Carrillo Cruz
8bfc36db6e Add missing provider on basic-motd IOS test (#25307)
Without this it fails, as it needs elevated privs.
(cherry picked from commit ffc74fdca2)
2017-06-02 17:07:06 +02:00
Brian Coca
58d23ba378 added chnlog for towerjob fix 2017-06-02 10:17:42 -04:00
Bill Nottingham
a09fbb4b15 Fix handling of extra_vars_path parameter. (#25272)
tower-cli process_extra_vars takes a list.
(cherry picked from commit d0cc980223)
2017-06-02 10:17:42 -04:00
Brian Coca
cb8517ba0a added parted i18n fix 2017-06-02 10:17:42 -04:00
Fabrizio Colonna
5512e7a27c Fixes parted i18n issues (#24991)
* Fixed issue 24969

* Used C locale and global env update.

(cherry picked from commit f364d7af8e)
2017-06-02 10:17:42 -04:00
Ganesh Nalawade
5d6fd93474 Add support to fetch old style junos facts (#25250) (#25292)
* Add support to fetch old style junos facts

Fixes #25050

Add support to fetch old style facts supported in Ansible <= 2.2
To fetch old style facts value `gather_subset` value shoule be `all`
and `junos-eznc` is required to be installed on control node as a
prerequisite.

* Remove unwanted import

(cherry picked from commit 85219dfdf3)
2017-06-02 16:29:42 +05:30
Toshio Kuratomi
c5aec5703a Add ec2 policy sorting python3 fix 2017-06-01 11:30:39 -07:00
mechaxl
33b88e9770 Fixing policy sorting for Python 3
(cherry picked from commit 3c3e9c3b36)
2017-06-01 11:29:25 -07:00
MechaXL
25ff5bd353 Convert basestring to string_types (#25228)
(cherry picked from commit c1f0260ae3)
2017-06-01 10:25:00 -07:00
John R Barker
0fefd8493b Adds documentation of implicit regex match removal (#24934) (#25255)
regex_replace has a implicit parameter for `replacement` and thus can remove the matched string
(cherry picked from commit aa9ea3d43a)
2017-06-01 12:14:24 -05:00
Matt Clay
da8963d788 Temporary work-around for setuptools 36.0.0 bug. (#25243)
* Temporary work-around for setuptools 36.0.0 bug.
* Use older setuptools for pip integration test.
* Limit isort version to avoid new test failures.

(cherry picked from commit 9d8aa43c67)
2017-06-01 12:14:24 -05:00
John R Barker
250a1cfeca Update facts module to support the new OS10 10.3 release (#25090) (#25223)
* Update facts module to support the new OS10 10.3 release

* Address PEP8 issues reported by ansibot

(cherry picked from commit e0db5d23cc)
2017-06-01 12:14:24 -05:00
Benjamin Curtis
cedd0f5da2 Fix return code (#23592)
The Honeybadger API returns 201 for success, not 200.
(cherry picked from commit 16c2207d21)
2017-06-01 12:14:24 -05:00
Ricardo Carrillo Cruz
ec545d7b42 Add provider param to prepare_iosxr_tests role tasks (#25163)
This will avoid passing -u -k to ansible-playbook
(cherry picked from commit 69efb61008)
2017-06-01 12:14:23 -05:00
Abhijeet Kasurde
9d4875a727 Misc typo fix in fleet inventory (#25174)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>(cherry picked from commit 3a82246d82)
2017-06-01 12:14:23 -05:00
John R Barker
23277a622c aos_login change default port and add version check (#24752) (#25171)
* Change default port for aos_login and force type to Integer

* Add check to make sure aos-pyez is present and has the right version

* Update min version requirement in doc

* Change default port in documentation as well

(cherry picked from commit 6dd1fc6f34)
2017-06-01 12:14:23 -05:00
John R Barker
d07ab49904 Update main.yml 2017-06-01 12:14:23 -05:00
Ganesh Nalawade
3932c53328 Fix IndexError when junos_config contains multiple delete lines (#25139) (#25148)
* Prevent IndexError when deleting multiple lines

The old code will raise `IndexError: list assignment index out of range` when deleting multiple lines because the indexes of the original and the copy get out of sync. Solved by deleting from the high indexes first so the lower ones remain stable.

* Don't load configuration if nothing to load

Instead of sending an empty candidate config (for example because the candidate only consisted of `delete` lines, and all of them were filtered out by `filter_delete_statements`) just return. JunOS seems to get confused by empty changes, and if the candidate config is empty then it's a no-op anyway.

(cherry picked from commit 06f76a2741)
2017-06-01 12:14:23 -05:00
Evan Kaufman
d7ce5e68ea Fixed backup file behavior in check mode (#24899)
Fixes ansible/ansible#21523
(cherry picked from commit ce584571e8)
2017-06-01 12:14:23 -05:00
Daniel Wright
748b7c423f [cloud] Backport handling of CloudFormation int parameter values - fixes #23593 (#25051) 2017-06-01 12:14:23 -05:00
Abhijeet Kasurde
2eb727f1fe [cloud] Bugfix: Make wait_timeout integer type in redshift module (#25063)
Fix stricts datatype of wait_timeout to int as module
is using it as integer.

Fixes #25056

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2017-06-01 12:14:23 -05:00
Toshio Kuratomi
31b531ad65 add empty links in docker_container fix to changelog 2017-06-01 12:14:23 -05:00
louis
704c6f09c7 fixes #19550 (docker_container with empty links list always restarts)
(cherry picked from commit 7363776174)
2017-06-01 12:14:23 -05:00
Toshio Kuratomi
70328b18d4 Update changelog with more fixes 2017-06-01 12:14:23 -05:00
Konrad Klimaszewski
2e5b4a9b2c Docker does not output Status after pull anymore.
- Docker 1.12 on CemtoOS7 does not output status line anymore.
- Do not rely on Docker output to verify if the image was the latest.

(cherry picked from commit 5f3c887c38)
2017-06-01 12:14:23 -05:00
Konrad Klimaszewski
b05b5b9347 Properly handle Docker image comparison for published_ports defined as IP::PORT
- Published port defined as IP::PORT where parsed in expected.parameters
  as 0.0.0.0::PORT leading to changed==True on every playbook run.

(cherry picked from commit 64f63a3cac)
2017-06-01 12:14:22 -05:00
Nikolay Murga
4978566117 Fixed #21464 - docker_network: TypeError with existing network (#24266)
Fixed #22530 - docker_network Failed but Overlay network created successfully on Docker swarm mode
(cherry picked from commit 3610a2457f)
2017-06-01 12:14:22 -05:00
Toshio Kuratomi
121941635d Add docker fixes 2017-06-01 12:14:22 -05:00
bengerman
bf94109ade rebuild docker containers if there are less ports exposed
(cherry picked from commit cb3026f769)
2017-06-01 12:14:22 -05:00
Toshio Kuratomi
e42b4a266b Add os_user fix to changelog 2017-06-01 12:14:22 -05:00
Guillaume Coré
93fed65ea2 os_user: fix module undefined
module variable in the function is undefined. Pass it.

fix "NameError: name 'module' is not defined"

(cherry picked from commit a5c70dc672)
2017-06-01 12:14:22 -05:00
Brian Coca
095be9c904 updated changelog service fix 2017-06-01 12:14:22 -05:00
Brian Coca
dfb00f4c5f fixes for insserv on SLES11
fixes #23700, seems SLES11 has diff behaviour of insserv
these changes are compatible with debian/ubuntu.

(cherry picked from commit a86878c425)
2017-06-01 12:14:22 -05:00
Toshio Kuratomi
0d57e17d67 Add docker_container fix to changelog 2017-06-01 12:14:22 -05:00
bengerman
c3d5e2da91 typo in security opts
(cherry picked from commit fab2dfd1c6)
2017-06-01 12:14:22 -05:00
Brian Coca
af0583d8b6 updated chlog 2017-06-01 12:14:22 -05:00
Brian Coca
718554a39e updated with solaris fact backport fix 2017-06-01 12:14:22 -05:00
Brian Coca
20008be317 Solaris fact fix (#24793)
* ensure locale for solaris fact gathering

fixes issue with locale interfering with proper reading of decimals
fixes #24542

* fixed typoe

(cherry picked from commit e558ec19cd)
2017-06-01 12:14:22 -05:00
bengerman13
f9d781bcab add xattr integration tests to ci (#24950)
* add xattr integration tests to ci

* fix package syntax

* remove unnecessary become, disable xattr for bsd and osx

(cherry picked from commit 4b6db5db7c)
2017-06-01 12:14:21 -05:00
bengerman13
081e98739e add integration tests for xattr module (#24947)
* add integration tests for xattr module

* fix whitespace

(cherry picked from commit 25aac6151f)
2017-06-01 12:14:21 -05:00
kkjang
dd20427db9 Fix expect for python 3 (#24912)
* Fix expect for python 3

- Change generator next to python 3 compatible
- Added tests for expect

* Add pexpect to integration.txt

- add pexpect library to requirements for integration tests

* Use ansible_python_interpreter in integration tests for expect

* Use double-quotes for expect integration tests

* Cast user input to string for expect integration tests

* Cast user input to string earlier in expect integration tests

* Use ansible.module_utils.six.moves input for expect integration tests

* Fix yamllint errors in the expect test

* Use cat to trigger timeout for expect integration tests

* Use realpath filter in expect integration tests

(cherry picked from commit daada2000c)
2017-06-01 12:14:21 -05:00
Toshio Kuratomi
c57e5e1305 Remove vertica_schema from the pep8 legacy files 2017-06-01 12:14:21 -05:00
Toshio Kuratomi
1eef136c7c Fix bad merge of vertica_user 2017-06-01 12:14:21 -05:00
kgottholm
091a379da1 Vertica schema fix (#24915)
* replace deprecated cmp() with custom conditional
cmp is not present in Python3 but several modules use it
Reference 24756
(cherry picked from commit 5240e5a230)
2017-06-01 12:14:21 -05:00
Brendan Almonte
ef40b0085b Read directory_mode as 'raw' type
Reads the directory_mode param as 'raw' type to mirror the same behavior as mode.
This'll cause non-quoted values to be represented as an int, rather than a str.

Covered by 'assert recursive copied directories mode' test.

Fixes #24202

(cherry picked from commit 8d8cfb5fcd)
2017-06-01 12:14:21 -05:00
cheko
f82e80dac6 Bugfix: Directories in /etc/skel will get users ownership when home dir is created (#24943)
* Bugfix: Directories in /etc/skel will get users ownership when home dir is created
* Bugfix: Chmod works now recursive for the home dir

(cherry picked from commit 0dc5e8bf71)
2017-06-01 12:14:21 -05:00
Toshio Kuratomi
cd659994bd Remove empty file that didn't exist in 2.3.0 2017-06-01 12:14:21 -05:00
kgottholm
0ace2b4332 Os port fix (#24913)
* replace deprecated cmp() with custom conditional
cmp is not present in Python3 but several modules use it
Reference 24756
(cherry picked from commit 1e4b227e6f)
2017-06-01 12:13:39 -05:00
James Cammarata
ecb38fdf73 New release v2.3.1.0-1 2017-06-01 10:57:37 -05:00
James Cammarata
87578049a0 Updating CHANGELOG for final release 2017-06-01 10:52:39 -05:00
James Cammarata
fb636cb6f0 New release v2.3.1.0-0.2.rc2 2017-05-23 13:55:45 -05:00
James Cammarata
f67a59bce6 Also check the iterator for failed host status in linear strategy
When only looking at the failed state of the TaskResult, certain failures
cause the linear strategy to fail out sooner than it should and not execute
the always portion of blocks.

Fixes #24301

(cherry picked from commit f217dae938)
2017-05-23 13:17:40 -05:00
jhawkesworth
8d0ea29df0 Added win_copy recursive integration test with trailing path separator. (#24523)
This is a reproducer for https://github.com/ansible/ansible/issues/23559

Tests will fail until https://github.com/ansible/ansible/pull/23581 is merged

Note that I believe another commit is also needed for this to work,
specifically the change from: https://github.com/ansible/ansible/pull/23326
(cherry picked from commit b46c098581)
2017-05-23 11:05:41 -07:00
Dag Wieers
1a8d6fb4cb win_copy: Fix recursive copy (#23581)
This fixes #23559.

This should be backported to v2.3 branch too.
(cherry picked from commit 9cd6f1bf91)
2017-05-23 11:05:28 -07:00
Brian Coca
598b34a326 updated changelog with backported fixes 2017-05-23 10:38:18 -04:00
Abhijeet Kasurde
bffa355c6c Include error exception in AnsibleError
- Use to_native instead of str

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
(cherry picked from commit f9b836a901)
2017-05-23 10:20:02 -04:00
jctanner
a5e6639739 sysctl: switch basestring to string_types (#24277)
(cherry picked from commit 08a3ea2221)
2017-05-22 16:05:13 -07:00
pdasilva
daf2b5e5fb Changed assemble_from_fragments to use os.path.join (#24909)
Fixes #19437
(cherry picked from commit f8e47e2204)
2017-05-22 15:42:17 -07:00
Anton Kasimov
3ad37b320f Bugfix for setting user groups on OpenBSD
(cherry picked from commit 2e392f47c8)
2017-05-22 18:16:31 -04:00
kgottholm
1cd78b91d9 Letsencrypt fix (#24906)
* Replaced deprecated cmp with custom condition

References  #24756

* Fix PEP 08 indention

(cherry picked from commit 16d522cf2c)
2017-05-22 14:59:05 -07:00
pdasilva
74f6c46e46 Converted the response from _get_url_data using to_native (#24901)
Updated the exception message to no longer use e.message.
Fixes #24526
(cherry picked from commit 45e4b8f97a)
2017-05-22 14:27:47 -07:00
Trishna Guha
97da8e161b Remove deprecation for username/password eos_user, nxos_user and Doc update (#24880) (#24893)
Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
(cherry picked from commit 9fb9c00092)
2017-05-22 22:05:44 +05:30
Phil Huang
e5f4d2b9c2 Fixed wrong variable in cumulus network module (#23950)
Signed-off-by: Phil Huang <phil_huang@edge-core.com>(cherry picked from commit 98a8b967d2)
2017-05-19 12:49:40 -04:00
mattwwarren
b99f4892d7 remove self from function outside of class (#24017)
* remove self from function outside of class

* fix indentation

(cherry picked from commit 45ac28ba04)
2017-05-19 11:49:28 -04:00
Matt Martz
7849e595b1 Base changes required to allow winrm to work on py3 (#24744)
(cherry picked from commit e7d8ebf080)
2017-05-18 16:11:04 -07:00
Matt Martz
4542e83fa0 Convert some more base64 strings to text for winrm, to support async and become (#24796)
(cherry picked from commit 1eed6c5b3d)
2017-05-18 16:09:42 -07:00
Matt Davis
c7b3e420b7 add segfault detection to TQM
* prevents indefinite hangs when a worker segfaults
(cherry picked from commit 569377e951)
2017-05-18 14:59:31 -04:00
Dylan Silva
ac8cb2a106 Downgraded more modules from Curated to Community (#24751) (#24784) 2017-05-18 11:13:47 -07:00
Trishna Guha
af417120e1 Fix transport getting set to None when not set explicitly (#24769) (#24773)
Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
(cherry picked from commit feafae70b5)
2017-05-18 15:48:55 +05:30
Ganesh Nalawade
3b82490c6f Save commit_timeout as string in junos_config (#24761) (#24764)
Fix converts commit_timeout to string as
Elementree.SubElement requires text as string.

Fixes #24611

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
(cherry picked from commit 2f955e7da8)
2017-05-18 13:36:08 +05:30
Adam DeConinck
c5067cff6b Fix for ansible/ansible-modules-core#1568
When checksums of local and remote files match, and when follow = True,
determine if remote destination is a symlink. If so, de-reference it and
pass the link target to the file module as 'dest'.

This change fixes an edge case in file copy behavior when:

- 'dest' is a symlink to some other file ('realdest')
- follow = True
- the checksums of the source file, 'src', and the symlink target, 'realdest',
  match.

Because the checksums match, the copy module is skipped and the file module
is invoked directly with 'dest' = the symlink, and 'src' = the source of the
copy module, whether that source is present on the target machine or not.

When 'src' doesn't exist on the target machine, this leads to an error that
looks like this because it can't change the target of the symlink:

TASK [copy] ********************************************************************
fatal: [192.168.56.101]: FAILED! => {"changed": false, "checksum": "f572d396fae9206628714fb2ce00f72e94f2258f", "failed": true, "gid": 1000, "group": "ajdecon", "mode": "0777", "msg": "src file does not exist, use \"force=yes\" if you really want to create the link: /tmp/issue1568/dest_dir/source", "owner": "ajdecon", "path": "/tmp/issue1568/dest_dir/dest", "size": 8, "src": "source", "state": "link", "uid": 1000}

When the path 'src' *does* exist on the target machine, the file module makes
this the symlink "dest -> src" instead of "dest -> realdest"... even if the
checksum of 'src' on the target machine is different from the checksum of 'src'
on the machine where Ansible is running.

(cherry picked from commit 2f74f6738d)
2017-05-18 02:32:02 -05:00
James Cammarata
180ce9ffe6 Avoid default serialization of classes in dump_attrs
For playbook base objects, when dumping attributes via dump_attrs() an
attribute like loop_control is a class. Using the default serialization
for these is slow and consumes a lot of memory. Since LoopControl is also
based on the Base class, we can use serialize() instead and save a lot of
resources.

This also adds a from_attrs() complimentary method to nicely turn the
dumped attrs back into proper field attributes.

Fixes #23579

(cherry picked from commit 78478e80ea)
2017-05-17 06:57:11 -05:00
Matt Clay
3a6fd9448e Limit sphinx version on python 2.6. (#24678)
* Limit sphinx version on python 2.6.
* Fix issues identified by rstcheck.

(cherry picked from commit 9178e176b5)
2017-05-17 01:07:41 +08:00
James Cammarata
7e605f4e84 Use delegated vars for the delegated host name
In _process_pending_results (strategy/__init__.py), we were using the delegate_to
field directly from the original task, which was not being templated correctly.
As an alternate to #23599, this patch instead pulls the host name out of the delegated
vars passed back in the task result dictionary to avoid having to re-template things.

Fixes #23599
Fixes #20508

(cherry picked from commit e5cd675b38)
2017-05-16 10:46:40 -05:00
Brian Coca
f7318ec891 updated changelog with bugfix 2017-05-15 09:32:58 -04:00
Abhijeet Kasurde
4506da6a6f Fix UnboundLocalError in basic.py
* Fix for UnboundLocalError while accessing deprecations
  in result
* Add Unit test

Fixes #24592

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
(cherry picked from commit 764b4b20ec)
2017-05-15 09:32:35 -04:00
Mohammed Naser
a43374ed32 Set facts type to dict
With newer versions of ansible, module arguments are assumed to
be strings unless otherwise specified.  Our 'facts' argument is
expected to be a dictionary, so tell ansible that.

Without this, the argument will arrive as a string and be written
to the facter file inside string quotes.  Facter will produce the
following error:

  undefined method `each' for #<String:0x000000016ee640>

This was originally fixed and found in the Ansible Puppet role which
is maintained by the OpenStack infrastructure team.

8d0f0bfd0a
2017-05-14 14:10:21 -04:00
Ganesh Nalawade
cc18296cc5 Fix timeout issue in ansible-connection (#24556) (#24579)
Fixes #24520 ansible-connection needs
to wait on timeout value of play-context
instead of ssh default timeout
(cherry picked from commit 5ec7f40196)
2017-05-13 18:35:13 +05:30
Eric Beahan
d94ac763b6 removing folded style formatting for synopsis (#22746)
(cherry picked from commit e539726543)
2017-05-12 12:02:07 -04:00
Toshio Kuratomi
40ea76cf5a Add bugfixes to changelog 2017-05-12 05:44:28 -07:00
Toshio Kuratomi
cdd6ab000b Fix template not showing a diff with a directory
Template can take a directory as the destination.  When that's the case,
we need to diff between the source and the file inside of the directory.
That happened when the directory was specified with a trailing slash but
not when it was specified on its own.  This change fixes that.

Fixes #24413

(cherry picked from commit 548cacdf6a)
2017-05-11 20:37:55 -07:00
Toshio Kuratomi
58438762a1 Fix import of shlex_quote
the backport here 1f3f4cf702 forgot that
in ansible-2.3, the six library in ansible.module_utils is only 1.4.
1.4 doesn't have shlex_quote.  Importing it from ansible.compat works
for ansible-2.3.
2017-05-11 17:30:11 -07:00
Toshio Kuratomi
41e3027fda Fix pam_limits writing text to a file opened in binary mode
Fixes #24392

(cherry picked from commit 16325f6f15)
2017-05-11 17:17:53 -07:00
Dylan Silva
6f92ca058a Downgrading module from core to community (#24463) (#24512) 2017-05-11 13:10:19 -07:00
Brian Coca
5a47644dc6 added bugfix to changelog 2017-05-11 15:48:19 -04:00
Brian Coca
1f3f4cf702 deal with null/none connections
fixes #23621
pushed 'connection resolution' to play_context
override fieldattribute getter

(cherry picked from commit c50cf22d52)
2017-05-11 15:47:09 -04:00
Matt Davis
5f0be9dcd0 slightly increase win_async_wrapper fire and forget sleeptime
* should fix Shippable timeouts when AWS CPU credits are low- right on the bubble of failure w/ 5s execution
(cherry picked from commit ead23783be)
2017-05-09 11:23:05 -07:00
James Cammarata
5a3f52d988 New release v2.3.1.0-0.1.rc1 2017-05-09 08:47:02 -05:00
John R Barker
15f635f7c3 Reference correct variable and key for role expiry (#23397) (#24405)
Previously, this module could throw the following error message:
    NameError: global name 'current_roles_attrs' is not defined

The referencing key should also match the name of the column, which is
rolvaliduntil, not rol_valid_until
(cherry picked from commit c5adf08c40)
2017-05-09 14:06:28 +01:00
John R Barker
b87ffb2082 Check if api_key and app_key before proceeding (#24336) (#24403)
Fix adds check if app_key and api_key provided by
user is correct or not. If this combination is wrong
then fail with appropriate error message given by
Datadog server

Fixes https://github.com/ansible/ansible/issues/24325

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
(cherry picked from commit e342b281d8)
2017-05-09 13:27:30 +01:00
Matt Davis
787303284f fix spurious warnings with ansible_winrm_kinit_X args (#24380)
* added to pywinrm arg whitelist
* clarified error text on kinit_mode error
* fixes #23822
(cherry picked from commit 98ff93b2db)
2017-05-08 11:31:03 -07:00
James Cammarata
a1886911fc Fixing security issue with lookup returns not tainting the jinja2 environment
CVE-2017-7481

Lookup returns wrap the result in unsafe, however when used through the
standard templar engine, this does not result in the jinja2 environment being
marked as unsafe as a whole. This means the lookup result looses the unsafe
protection and may become simple unicode strings, which can result in bad
things being re-templated.

This also adds a global lookup param and cfg options for lookups to allow
unsafe returns, so users can force the previous (insecure) behavior.

(cherry picked from commit 72dfb1570d22ac519350a8c09e76c458789120ed)
2017-05-08 11:11:47 -05:00
Martin Kopta
ab399146b4 fixed yum.parse_check_update regex (#24331)
Output of `yum check-update` can contain lines with long package names and long
repository label names, which will be broken into multiple lines, which need to
be sanitized. The solution to this has been fixed and refactored in 2.3 in form
of parse_check_update(), but it still contains subtle bug, which makes such
multi-lines invisible to later logic (such packages aren't included in
parse_check_update()) output. The problem is caused by using '\1' in re.sub(),
instead of proper r'\1', which literally puts unicode symbol \1 into resulting
output.
(cherry picked from commit c4ad0f86c7)
2017-05-08 10:53:08 -04:00
Adrian Likins
572c07ddb3 Fix vaulted vars templating
Use the default repr of AnsibleVaultEncryptedUnicode.data instead
of a custom one, since jinja templating ends up using the repr()
results.

Fixes #23846, #24175

(cherry picked from commit 7fe2064162f0cd34b68814ecff1fd276ac24740c)
2017-05-08 10:16:35 -04:00
Toshio Kuratomi
2cab2118a1 Give user whatever information we have from ssh-keyscan
ssh-keyscan isn't very verbose about errors.  Give the user whatever
information we have available even if it isn't much.  At least they will
know how we were running ssh-keyscan and why there's an error now.

Fixes #19440

(cherry picked from commit 4bf8071889)
2017-05-05 08:35:36 -07:00
Dane Summers
f57d7bb016 Fixes #23285 (#24291)
Makes subversion module --check fail when modified files are in
repository.
(cherry picked from commit 4bd04c299b)
2017-05-04 10:09:16 -07:00
Joris (J.J.M.) Weijters
4a7230aa3c adjusted descriptions in DOCUMENTATION, and fixed type in RETURN
(cherry picked from commit 2a7ce1059d)
2017-05-04 07:39:06 -07:00
Matt Martz
228553f931 Switch last remaining decode to to_text (#24269) 2017-05-03 16:51:51 -05:00
Brian Coca
77fa3f1598 include_vars to delegated only if delegate_facts (#24259)
* include_vars to delegated only if delegate_facts

fixes #24172

* since code is now same, simplified

(cherry picked from commit b731c2d809)
2017-05-03 16:30:25 -04:00
Raúl Cuza
5c8e11ac9f Add ansible-vault encrypt_string doc (#24147)
* Add documentation on 'ansible-vault encrypt_string'
2017-05-03 12:20:39 -04:00
Ganesh Nalawade
c249662e10 Fix junos_rpc and junos_user broken issues (#24238) (#24246)
* Fix junos_rpc and junos_user broken issues

Add persistent connection related changes.

* Fix CI issues

(cherry picked from commit a42b892f70)
2017-05-03 19:58:24 +05:30
Ganesh Nalawade
ec3a5b0e17 Fix netconf port validation and minor doc change (#24210) (#24239)
* Fix netconf port validation and minor doc change

Add check to confirm if `validate_*` funcion is
callable.

Add `config_format` in `junos_facts` documentation

* Fix review comments

(cherry picked from commit 73c24001d9)
2017-05-03 16:02:21 +05:30
Toshio Kuratomi
af018b75f0 Add integration test that modules are loaded from the expected locations (#24170)
* Add integration test that modules are loaded from the expected locations
* Fix ping module to pass PEP8

(cherry picked from commit 3428f42120)
2017-05-01 08:57:31 -07:00
Matt Martz
778173ec07 Fix password prompt matching (#24081)
* Fix password prompt matching

* Add some tests for check_password_prompt

* Prevent pep8 line ends with a space error

(cherry picked from commit 040fb4435a)
2017-05-01 11:18:38 -04:00
Brian Coca
8a604185fd make 2.4 compatible
fixes #24148
2017-05-01 11:18:38 -04:00
Toshio Kuratomi
98d223a51b Facts Timeout was not settable via ansible.cfg
The timeout for gathering facts needs to be settable from three places
(highest precedence to lowest):

* programmatically
* ansible.cfg (equivalent to the user specifying it explicitly when
  calling setup)
* from the default value

The code was changed in b4bd6c80de to
allow programmatically and the default value to work correctly but
setting via ansible.cfg/parameter was broken.

This change should fix setting via ansible.cfg and adds unittests for
all three cases

Fixes #23753

(cherry picked from commit d088030fa6)
2017-05-01 08:00:11 -07:00
Nathaniel Case
0467017a70 Remove provider requirement from nxos_vrf (#24118)
Fixes #23920
(cherry picked from commit dce2d5eea9)
2017-05-01 09:33:32 -04:00
Alberto Murillo Silva
776551afa5 Fix ClearLinux pretty name
ClearLinux has changed its pretty name in os-release file
from: 'Clear Linux Software for Intel Architecture'
to: 'Clear Linux OS for Intel Architecture'

This patch makes the SEARCH_STRING 'Clear Linux' rather than
the full name to make it compatible with the old and new name.

Signed-off-by: Alberto Murillo Silva <alberto.murillo.silva@intel.com>
(cherry picked from commit bb234b9206)
2017-05-01 08:53:23 -04:00
Nick Piper
cf224ab31b Minor typo correction varibles -> variables
No impact as variable wasn't used.
(cherry picked from commit 403c142750)
2017-05-01 08:45:01 -04:00
Nathaniel Case
41a70bf9ca Print specific error for BadHostKeyException (#24120)
(cherry picked from commit f9ec06d1dc)
2017-04-28 14:00:53 -04:00
Ganesh Nalawade
6915e026ed Fix exception in junos_package (#24107) (#24116)
(cherry picked from commit 06732acd4c)
2017-04-28 19:49:00 +05:30
Alex Willmer
20c5aee565 Rename fact returned by docker_network to avoid restricted prefix (#23919)
This fixes #23918
2017-04-28 08:47:07 -05:00
Trishna Guha
e509122aad Remove idle ShellError exception and get_exception() method from nxos modules (#24091)
Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
(cherry picked from commit aa1f922606bd7b884c8920e4b402788665bc4116)
2017-04-28 10:50:38 +05:30
Ganesh Nalawade
ab79e96c3c Fix exception issue in junos_config (#24066)
ParseError execption is added to ElementTree
in py2.7. Prior to py2.7 need catch ExpatError
execption
(cherry picked from commit 7d710882a8)

* Fix python version check issue (#24063)

Fix python version check issue
(cherry picked from commit 1f7c2c63c2)
2017-04-27 20:52:26 +05:30
Nathaniel Case
b4380432f6 Run save inside config mode. (#23977)
* Run `save` before exiting config mode.

* Fix unit tests for `save`

* Allow `save` to be on its own again and introspect success

* Introspecting `compare running` makes this a lot harder.

Move `save` tests to integration tests

(cherry picked from commit fc0bf87c20)
2017-04-27 11:09:38 -04:00
Matt Clay
126878488f Fix bugs in ansible-test units command. (#24044)
* Handle old versions of coverage.
* Handle old versions of setuptools.
* Detect python version for docker/remote units.
* Add sanity override for test constraints.

(cherry picked from commit d662f6f0db)
2017-04-27 11:22:44 +08:00
Toshio Kuratomi
4b2d80f662 Add changelog entry for fetch parameter change 2017-04-26 09:28:29 -07:00
KeepZero
9b00648f21 Set validate_checksum default yes of fetch to match the doc
(cherry picked from commit 98e7d4b49d)
2017-04-26 09:27:34 -07:00
Patrick Ogenstad
456ec66b0a asa_command: set default_output to text (#23979)
(cherry picked from commit 9a0a7f78d7)
2017-04-26 09:47:35 -04:00
Matt Clay
19c4e1a992 Use Shippable image: drydock/u16pytall:master
* Use Shippable image: drydock/u16pytall:master
* Do not install python 3.6 on Shippable.
2017-04-26 15:49:21 +08:00
Brian-Williams
c60b3166b1 Change wait_for time to utc (#23987)
(cherry picked from commit 8466c808d9)
2017-04-25 18:05:10 -04:00
Brian Coca
d1c14e8aa4 moved to exceptions for basic skip/fails
better handling of checkmode and async
fix test to follow new flow control

(cherry picked from commit e29dc49a49)
2017-04-25 14:51:22 -04:00
Ganesh Nalawade
6ada5cc074 Fixes #23960 junos_config fail with config in xml (#23962) (#23978)
If config is in xml format append it to <configuration>
tag as a instance of Element class.
(cherry picked from commit 15c19367d6)
2017-04-25 22:50:35 +05:30
René Moser
f20cd780a4 exoscale: fix TXT type records handling (#23956)
(cherry picked from commit 3959597f7d)
2017-04-25 13:08:02 +02:00
Trishna Guha
107308f6df Set terminal width for network *_command modules to avoid paging (#23728) (#23952)
Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
(cherry picked from commit f354bd1eab)
2017-04-25 14:33:59 +05:30
Indrajit Raychaudhuri
8c6a2a848c pacman: Fail fast when 'rc != 0'
We fail-fast and display 'stderr' in case 'pacman' returns with 'rc != 0'.
There is no point computing 'module._diff' in such case anyway.

Fixes #23910
2017-04-25 02:07:06 +02:00
Kai
58666c0ca4 Fix systemd in chroot (#23904)
* Fix systemd in chroot

The 'request ignored' message is in stderr, not stdout.

* Check both stdout and stderr for systemd message

Some versions of systemd report to stderr, others to stdout. Also check
whether output could be a valid normal response to avoid false positives.

(cherry picked from commit cb13aea88b)
2017-04-24 19:54:50 -04:00
Brian Coca
476e8c7136 avoid hosts 'pre templated warnings' (#23878)
* avoid hosts 'pre templated warnings'

fixed is_template failing on undefined
fixes #23057

* py3 compat

(cherry picked from commit a108f0fcd3)
2017-04-24 15:19:50 -04:00
Adrian Likins
2ca4155f23 Use sys.stdout.buffer to write vault bytes to stdout on py3 (#23760)
* Use sys.stdout.buffer to write vault bytes to stdout on py3

We need sys.stdout.buffer on py3 so we can write bytes to it since the plaintext
of the vaulted object could be anything/binary/etc

Before, attempting to write bytes to stdout on py3 would cause:

  TypeError: write() argument must be str, not bytes

(cherry picked from commit e0a7105c2d)
2017-04-24 10:13:22 -04:00
Brian Coca
4b5553c97f fix environment populated detection
fixes #23764

(cherry picked from commit 27185f44b0)
2017-04-21 18:21:17 -04:00
Brian Coca
0878f45a6c keep unsafe .. unsafe (#23742)
* keep unsafe .. unsafe

fixes #23734, which was broken in previous fix that allowed non string types to be templated
use new 'is_template' function vs bastardizing others
refactored clean_data to allow for arbitrary data structures to clean
fixed/removed some tests

(cherry picked from commit 4594bee65a)
2017-04-21 16:09:48 -04:00
Ganesh Nalawade
a71b6041f6 Fix display argument defualt value (#23859) (#23860)
(cherry picked from commit 04ae977f39)
2017-04-21 19:16:13 +05:30
Ricardo Carrillo Cruz
ee19b19984 Remove catch-all regex on IOS terminal plugin (#23858)
We have a list of specific messages that we scree-scrape and flag
them as legit errors.
However, we also have a catch-all regex that matches everything
starting with %.
That can cause issues on commands that return lines with that
character, like for example the 'crypto key generate'.

Fixes #23770
(cherry picked from commit 8517fbf936)
2017-04-21 15:31:17 +02:00
Ricardo Carrillo Cruz
a1c0c1582b Add assertion on test_iosxr_facts (#23852)
We hit bug #23737 due to bad coverage on test_iosxr_facts, we
were not checking memory facts at all.
(cherry picked from commit 60de93c31d)
2017-04-21 11:21:40 +02:00
Ricardo Carrillo Cruz
283f7f9e24 Fix the iosxr_facts mem gathering (#23850)
We were not calling match.group, plus we were lacking a ':' from
the expected output of 'show memory summary'.

Fixes #23737
(cherry picked from commit d0fd8cefaa)
2017-04-21 10:45:18 +02:00
Trishna Guha
1ea67950e1 Add eos_user module to users parameter (#23847) (#23849)
Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
(cherry picked from commit 8ec4882ba0)
2017-04-21 13:36:21 +05:30
Ganesh Nalawade
0d2d9f897c Add doc for display argument of junos_command (#23804)
(cherry picked from commit 01afe12cba)
2017-04-21 02:32:29 -04:00
Matt Davis
a021b4bd8b template hostvars for set_host_overrides (#23839)
* fixes #23586
* temporary solution until connection-specific vars are handled by play_context
(cherry picked from commit 02ed223d49)
2017-04-20 20:34:32 -07:00
Brian Coca
c05aa93739 Revert "fixes play context connection user (#21776)" (#23830)
* Revert "fixes play context connection user (#21776)"

This reverts commit 58ee661437.
fixes #23530

* preserve original in copy

updated comment to clarify wtf is going on here

(cherry picked from commit eb887b8062)
2017-04-20 18:03:21 -04:00
Brian Coca
62811bf134 also skip polling when async failed
(cherry picked from commit 94f0a4edd5dad15f720ec087f04f20bcbef1b97b)
2017-04-20 18:03:21 -04:00
Brian Coca
68fff4a4b5 script fails on async
(cherry picked from commit fe9af903f3)
2017-04-20 18:03:21 -04:00
Brian Coca
4567527249 fix vars file selection
fixes #17382
alternate to #22979

deal with cases in which group/host have . in name
updated as per feedbck
only be strict about extension when doing dirs
also avoid ~ endings

(cherry picked from commit 602a2bca1b)
2017-04-20 18:03:21 -04:00
Brian Coca
1fdeef511c finer grained failed/skipped on async for actions
fixes #23729

(cherry picked from commit 3965689328)
2017-04-20 18:03:21 -04:00
Brian Coca
bc990004e1 fix hashing when path is symlink
(cherry picked from commit 631a10745d)
2017-04-20 18:03:21 -04:00
Nathaniel Case
c9b0026cd0 Eos port default values (#23829)
* Hook port back up for eos cli transport

* The default values have moved

* Why not have conditional defaults?
2017-04-20 16:04:47 -04:00
Nathaniel Case
0609b9ded0 EOS default transport (#23824)
* Give a default to eos transport
2017-04-20 16:04:47 -04:00
Logan Attwood
d74509a235 Use isfile check on package manager paths
(cherry picked from commit 5bbf0d9cb6)
2017-04-20 07:43:25 -07:00
John R Barker
c84a332531 Add guide for Packet host (#21346) (#23807)
* Add guide for Packet host

* incorporate feedback from Packet

* Format headings according to Python doc guide

* fixed rstcheck issues in packet guide

(cherry picked from commit 0b585ec4fd)
2017-04-20 15:01:21 +01:00
Trishna Guha
cc59d89538 Add eos_banner as module to banner param (#23789) (#23798)
Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
(cherry picked from commit b2129a7d3a)
2017-04-20 16:34:40 +05:30
John R Barker
b7ba7d40ae Show UUID instead of name when using UUID to select snapshot (#23787) (#23794)
(cherry picked from commit 504a768636)
2017-04-20 11:12:58 +01:00
John R Barker
0347dcda05 Minor typo in vmware_guest_facts (#23791) (#23793)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
(cherry picked from commit cc745b0224)
2017-04-20 11:07:16 +01:00
Ricardo Carrillo Cruz
81efc176f4 Add missing provider to eos_banner basic-motd eapi test (#23396)
Otherwise this stalls and timeouts, it doesn't have creds to run.
(cherry picked from commit 2cc2b8fb4d)
2017-04-20 10:57:54 +02:00
Ricardo Carrillo Cruz
79492a9d2d Check for proper response key on eos_banner map_config_to_obj (#23399)
If we run the task with 'login' banner, the 'show banner' command
will return a dict containing key 'loginBanner'.
However for motd, it will just return 'motd'.
Yay naming consistency!
(cherry picked from commit ba7ba7adc3)
2017-04-20 10:57:22 +02:00
Ricardo Carrillo Cruz
a769f0b0f4 Do not assert session name on idempotent eos banner (#23402)
* Check for proper response key on eos_banner map_config_to_obj

If we run the task with 'login' banner, the 'show banner' command
will return a dict containing key 'loginBanner'.
However for motd, it will just return 'motd'.
Yay naming consistency!

* Do not assert session exists on eos_banner response not changing device

(cherry picked from commit 13b2f11139)
2017-04-20 10:57:05 +02:00
Timo Benk
b9ee0c5477 fix ansible galaxy file mangling (#23703)
without this patch, ansible-galaxy will mangle files containing
the archive parent directory name, eg 'owncloud/files/owncloud.cron'
will become 'owncloud/files/.cron'.

The previous code could affect the entire path and even filenames.
If a file path has the top level dir name as a substring, galaxy
replaces it with ''. In one example, the archive top level dir
is 'go', so 'files/go-bin.sh' becomes 'files/-bin.sh'.

Fixes #22572, #23694, #23623
(cherry picked from commit 79943b86a1)
2017-04-19 14:17:18 -04:00
Alexander Gubin
d7c8d8ab4d Fix example fact(ansible_default_ipv4.address) for delegated_facts
(cherry picked from commit d04a5246de)
2017-04-19 11:00:40 -07:00
Bart van Bragt
898650d6bc Remove whitespace from unix group names
(cherry picked from commit d0e3d75381)
2017-04-19 09:43:34 -07:00
John R Barker
27073dd9bd Fix for setting values using gconftool-2 (#23713) (#23740)
Miscallenous fixes added to make gconftool-2 work.

Fixes https://github.com/ansible/ansible/issues/23670

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
(cherry picked from commit 27f776f97d)
2017-04-19 14:25:32 +01:00
Ganesh Nalawade
c92765e26e Make warning logs consistent (#23666) (#23716)
* Make warning logs consistent

Arguments outside provider with default
value should not log as warning in case
it is not mentioned in play.

* Make nxos timeout default consistent and add comments

* Make comments more verbose

(cherry picked from commit bf1a543f06)
2017-04-18 22:57:22 +05:30
Ganesh Nalawade
db738e0a2d Remove Warning for provider (#23652) (#23714)
(cherry picked from commit b8507b676b)
2017-04-18 22:49:23 +05:30
Adrian Likins
32be9a9273 Fix vault reading from stdin (avoid realpath() on non-links) (#23583)
* Fix vault reading from stdin (avoid realpath() on non-links)

os.path.realpath() is used to find the target of file paths that
are symlinks so vault operations happen directly on the target.

However, in addition to resolving symlinks, realpath() also returns
a full path. when reading from stdin, vault cli uses '-' as a special
file path so VaultEditor() will replace with stdin.
realpath() was expanding '-' with the CWD to something like
'/home/user/playbooks/-' causing errors like:

        ERROR! [Errno 2] No such file or directory: u'/home/user/ansible/-'

Fix is to specialcase '-' to not use realpath()

Fixes #23567

* to_text decrypt output when writing to stdout

(cherry picked from commit ae3d7fb29e)
2017-04-18 13:08:59 -04:00
Matt Martz
8e1b422e4a When become_method is su, self._play_context.prompt is a function. Fixes #23689
(cherry picked from commit f82d95ae28)
2017-04-18 13:02:12 -04:00
Nathaniel Case
82dcaa725f pep8 fix for Shippable 2017-04-18 11:45:43 -04:00
Brian Coca
7cd2b8d7a0 tolerate 'batch' systems that mess with stdin (#23596)
* tolerate 'batch' systems taht mess with stdin

fixes #23541

* have pause on windows tolerate devnull

* tuplie

(cherry picked from commit 586fcae398)
2017-04-18 11:39:55 -04:00
Nathaniel Case
c4b6b87344 nxos_vlan tweaks (#23194)
* Remove commented code

Remove a lot of unnecessary output

* Tests

* Sort vlan ids _after_ running set operations, so order is not lost
(cherry picked from commit 0b4cebfb8b)
2017-04-18 10:52:56 -04:00
Daniel
f66852f1ef Nxos vxlan vtep vni netcfg fix (#23620)
* Code cleanup
Removed 'add' method from CustomNetworkConfig.  It is identical
to the one inherited from NetworkConfig

* Removed unused CustomNetworkConfig import

* Replaced
```
def get_existing(module, args):
    existing = {}
    netcfg = get_config(module)
    config = netcfg.get_section(parents)
```
with
```
netcfg = CustomNetworkConfig(indent=2, contents=get_config(module))
```
get_config returns a string, not an object in 2.3.

* Removed non-functioning get_object method in CustomNetworkConfig in favor of the
inherited method.

Added child_objs property so that expand_selection would work.  The original
verion never worked correctly as it compared NetworkConfig obj's and str's.

* Removed ShellError method in favor or new load_config method.

* Removed ShellError method in favor or new load_config method.
fixes #20260

* nxos requires a "no" statement to change mcase group.  Corrected.
Corrected changed logic.

* Corrected deleted CustomNetworkConfig import
2017-04-17 12:39:21 -04:00
Nathaniel Case
d1d0f382a2 Clean up import statements for nxos_rollback (#23540)
* Clean up import statements for nxos_rollback

* Don't try to deal with pre-2.3 logic
(cherry picked from commit e518b6f5b4)
2017-04-17 08:55:47 -04:00
Ganesh Nalawade
39c2e4c28b Make logging consistent for network platforms (#23605) (#23648)
(cherry picked from commit 89752cc34f)
2017-04-16 23:38:48 +05:30
John R Barker
b721fa2ef5 Fix documented defaults in the nsupdate module (#23532) (#23637)
Let the documentation reflect what the module actually implements.
(cherry picked from commit 40f9f98f7c)
2017-04-15 17:12:38 +01:00
Manuel Sousa
b8400cd897 Fix #23338 - rabbitmq_queue message ttl can't be 0 (#23448)
(cherry picked from commit 8b4f5ba064)
2017-04-15 00:56:57 +02:00
Ganesh Nalawade
8b5267f09f fixes issue where network modules would ignore provider host value (#23589) (#23608)
This addresses a problem where the action plugin would ignore the
remote_addr value for the host.  In this case, only the inventory values
for the hostname would be considered and populate the remote host
remote_addr value for the connection plugin.
(cherry picked from commit c2370f14dd)
2017-04-14 17:59:13 +05:30
Matt Clay
06be3c56a9 Add rstcheck to ansible-test and correct issues. (#23550)
* Add rstcheck to ansible-test.
* Fix rst code-block languages and syntax errors.
* Fix rst inline literals.
* Update python 2 code block to pass tests on py 3.

(cherry picked from commit cb1f57d4e5)
2017-04-13 13:18:53 -07:00
Matt Clay
92bdd13bb1 Fix var precedence check to support python 3. (#23552)
* Fix var precedence check to support python 3.
* Run CI sanity tests using python 3.5.
* Disable pylint non-iterator-returned test to pass on python 3.5.

(cherry picked from commit e7bb508ad6)
2017-04-13 13:15:43 -07:00
Matt Clay
69562c5d20 Fix module validator blacklist handling.
Process the blacklist before creating a validator instance.

(cherry picked from commit 442768c45e)
2017-04-13 13:15:36 -07:00
Lumír 'Frenzy' Balhar
4452429b45 Add Python 3 support for validate-modules test. (#21195)
* Improve PEP8 compatibility

* Fix Python 3 incompatibility

Is prohibited to mutate OrderedDict during iteration through it so
is better to add records with error or warning to empty dictionary
instead of delete records from copy of dictionary during iterating.

* Decode output of subprocess from bytes to unicode.

* Add Python 3 support for validate-modules test.

Fix #18367

(cherry picked from commit 9d41aefd71)
2017-04-13 13:15:29 -07:00
Ryan Brown
a256745eae fix validate-module sanity error per https://app.shippable.com/github/ansible/ansible/runs/16493/1/console (#22711)
(cherry picked from commit d791665559)
2017-04-13 13:15:21 -07:00
Matt Clay
345749884d Fix module validation without base branch.
(cherry picked from commit 672e9a2f61)
2017-04-13 13:15:13 -07:00
Matt Clay
5667fe6746 Support module alias and rename validation. (#22675)
Cache git ls-tree output to speed up validation.
(cherry picked from commit 1f337b6421)
2017-04-13 13:14:58 -07:00
Brian Coca
c9de302fc6 removed debug print
(cherry picked from commit 313591f8b8)
2017-04-13 15:12:53 -04:00
Matt Clay
6883cad07e Temporarily cap pylint version < 1.7.0 in tests.
(cherry picked from commit 4ee96b20a3)
2017-04-13 11:27:30 -07:00
John R Barker
85fa2a9dd4 Make it easier to find network modules (#23576) (#23584)
* Make it easier to find network modules

Feedback has been it's difficult (via Google or directly) to find
modules as some people search for the company name vs product name,
therefore specify both.

* "IOS XR" (not "IOS-XR")

(cherry picked from commit 92a425a532)
2017-04-13 11:27:30 -07:00
John R Barker
5865356e92 network_cli modules don't always return stdout or stdout_lines (#23573) (#23582)
It's possible that if the module has a low-level failure, such as
"unable to open shell", or something else in the action plugin that
stdout and stdout_lines will not be returned.

Update the documentation to clarify this point.
(cherry picked from commit 2bb25d031b)
2017-04-13 11:27:30 -07:00
John R Barker
bc43de7b21 Error string:Regular expression updates (#23426) (#23569)
(cherry picked from commit c86feeaed9)
2017-04-13 11:27:30 -07:00
John R Barker
a574dc7bf1 [WIP] Network return docs (#23441) (#23535)
Network return docs
(cherry picked from commit 902bc58509)
2017-04-13 11:27:30 -07:00
Colin Nolan
c5fcae130f Add checks to confirm that the output from xfs_info has the expected format.
(cherry picked from commit 57c67f0c08)
2017-04-13 11:27:30 -07:00
Matt Clay
45c2887b19 Fix ansible-test handling of import/syntax errors.
(cherry picked from commit 0cf1e8e061)
2017-04-13 11:27:30 -07:00
Matt Clay
84d5e6e645 Fix errors reported by pylint. (#23282)
* Fix pylint misplaced-bare-raise errors.
* Fix pylint return-in-init error.
* Fix pylint bad-format-character error.
* Fix pylint too-many-format-args errors.
* Fix pylint too-few-format-args errors.
* Fix pylint truncated-format-string error.

(cherry picked from commit 48eeab8a53)
2017-04-13 11:27:30 -07:00
Matt Clay
92c4a3319c Initial pylint support for ansible-test sanity.
(cherry picked from commit 1daa69d685)
2017-04-13 11:27:30 -07:00
Albert Casademont
1a30df265d Fix Postgres user module always reporting changes (#23488)
(cherry picked from commit 54316f7da0)
2017-04-13 11:27:30 -07:00
Toshio Kuratomi
ee69fd140b When apt errors, include it's exit code
We invoke /usr/bin/apt inside of the ansible module.  When that command
exits, it doesn't always include a helpful error message.  Include the
exit code so that user's have all the information we can gice them as to
why apt failed.

Addresses #19128

(cherry picked from commit b4f976e9b9)
2017-04-13 11:27:30 -07:00
Matt Clay
f57d0bab32 Set IO encoding for ansible-test on Shippable.
(cherry picked from commit eec01e2137)
2017-04-13 11:27:30 -07:00
Matt Clay
a491adc425 Fix ansible-test empty diff handling on Shippable.
(cherry picked from commit 92ad9a19b6)
2017-04-13 11:27:30 -07:00
Lucas Alvares Gomes
5f53a159a0 rpm_key: Decode bytes to string to work with Python 3 (Fixes #20326) (#20385)
* rpm_key: Decode bytes to string to work with Python 3 (#20326)

The read() method will return bytes we need to then decode() those bytes
to a string before trying to match() it using the re module.

* Make the rpm_key pgp regex more robust on both py2 and py3

(cherry picked from commit cee8cc2a52)
2017-04-13 11:27:30 -07:00
cclauss
f2cf1dba92 Update the comments around Python 3
[Enterprise Linux 5 is at the end of "End of Production 3 phase"](https://en.wikipedia.org/wiki/Red_Hat_Enterprise_Linux#Product_life_cycle) so that is no longer a reasonable reason to wait.  Also removed the comments about [Python 3 not being mainstream](http://python3wos.mybluemix.net/201).  Perhaps a link to https://docs.ansible.com/ansible/python_3_support.html would also be a useful addition to this question.
(cherry picked from commit 6314169afd)
2017-04-13 11:27:30 -07:00
Karl Bergström
561d424a0e Open unarchive file in binary mode
Recent Python3 versions require open() to specify binary mode if the data is anything other than text.

Python3: Use int() instead of long() in unarchive

Changes long() to int() for CRC values in the unarchive module. Affects unarchiving of zip files. Since CRC values in zipfile are 32 bits the behaviour should be unchanged even in Python 2.
2017-04-13 11:27:30 -07:00
Paul Montero
ba977b7cd7 Open file in binary mode for python3
(cherry picked from commit 1963e506ec)
2017-04-13 11:27:30 -07:00
Toshio Kuratomi
53b19611e1 Fix a traceback with python3 and diff output
When retrieving file contents for diffing we need to get the contents as
binary.  Otherwise python3 will try to convert the file to text and fail
with non-decodable contents.

Fixes #23171

(cherry picked from commit 2fdb8e7f90)
2017-04-13 11:27:30 -07:00
Ganesh Nalawade
b8d6f23fb7 Fix a10 pylint issues (#23410) (#23413)
* Fix a10 pylint issues
* Moving imports to standard location

(cherry picked from commit 3934513121)
2017-04-13 11:27:30 -07:00
Matt Martz
b96407be86 Extra deps needed for building cryptography
(cherry picked from commit ac61f09203)
2017-04-13 11:27:30 -07:00
Matt Martz
bdf46e928f Fallback to old ssl_wrap_socket
(cherry picked from commit 13ac993d25)
2017-04-13 11:27:30 -07:00
Matt Martz
9acba3fa68 Update install deps for SNI tests
(cherry picked from commit b4b76bab14)
2017-04-13 11:27:30 -07:00
Matt Martz
71e8c841ce Use PyOpenSSLContext instead of deprecated wrap_ssl_context from urllib3.contrib.pyopenssl. Fixes #18528
(cherry picked from commit 33f7a27cba)
2017-04-13 11:27:30 -07:00
Strahinja Kustudić
701a47c850 Ignores ControlPersist broken pipe errors. Fixes #16731
Ansible will now automatically retry a connection if SSH returns an error:

mux_client_hello_exchange: write packet: Broken pipe

This is probably a bug in SSH, but because it's safe to retry this
connection there is no need for Ansible to fail because of it.

(cherry picked from commit 9f0be5a556)
2017-04-13 11:27:30 -07:00
Matt Parkes
ffde769567 ini_file 'create' parameter default value should be True
Updated create default value to True to match documentation (and common sense).
2017-04-13 11:08:35 -04:00
Brian Coca
3b5a758525 centralize ansible_managed and other template vars
now template lookup supports these again.

(cherry picked from commit 5b7e8a7bd6)
2017-04-13 11:05:19 -04:00
Brian Coca
4b10f3c13c removed extra 'changed' from debug output
(cherry picked from commit f7566ef1f1)
2017-04-13 11:03:21 -04:00
Brian Coca
e1c1c19a9b added test emulating #23180 use case
(cherry picked from commit 8382ed7200)
2017-04-13 11:01:34 -04:00
Brian Coca
690a793aae fix environment validation, make setup exception
removed bare vars
now environment inheritance correclty prepends
this allows more local to override more general

fixes #23180

(cherry picked from commit df5895e585)
2017-04-13 11:01:34 -04:00
Brian Coca
d392c493b9 removed unused and erroring cmp import 2017-04-13 11:01:34 -04:00
Brian Coca
6799b21124 correctly get all hosts in 'all'
(cherry picked from commit 0d5d5f2bf6)
2017-04-13 11:01:34 -04:00
Pierre-Alexandre
cac25fa7b0 BUGFIX : using yaml hosts inventory, hosts in groups weren't added to the group 'all'
(cherry picked from commit 283a88444f)
2017-04-13 11:01:34 -04:00
Matt Clay
74b6dd7799 Include .yamllint in manifest so yamllint works.
(cherry picked from commit 38eed2dab0)
2017-04-12 11:00:35 -07:00
Toshio Kuratomi
6b74dca0ff Add .coveragerc to the tarball so unittests will run from the tarball
(cherry picked from commit 0d2d17ade5)
2017-04-12 08:08:30 -07:00
James Cammarata
d56ba0945d New release v2.3.0.0-1 2017-04-12 08:56:33 -05:00
James Cammarata
8f6c284ccf Updating CHANGELOG with release date for 2.3 2017-04-12 08:52:52 -05:00
James Cammarata
9818ca366d New release v2.3.0.0-0.6.rc6 2017-04-10 10:13:54 -05:00
Toshio Kuratomi
856edfe80c Revert "pacman: Fix package matching pattern in upgraded package list (#23433)"
Not a critical blocker so we'll push this to 2.3.1 instead of trying to
get it into 2.3.0 (Just too late in the development cycle to push it out
now).

This reverts commit 9a850db605.
2017-04-10 07:04:17 -07:00
Indrajit Raychaudhuri
9a850db605 pacman: Fix package matching pattern in upgraded package list (#23433) 2017-04-09 11:21:55 +02:00
Nathaniel Case
bb5202fa7e Redo #23418 (#23425)
* Check for provider values inside check_args of respective network code

* Partial revert of b9ee5aa

The no_log change is okay, but take out the action result munging

(cherry picked from commit 86c714548f)
2017-04-08 10:56:27 -04:00
James Cammarata
d72dbffa23 New release v2.3.0.0-0.5.rc5 2017-04-07 16:13:18 -05:00
Chris Alfonso
b9ee5aae81 Fixes #23388 Network provider masks too much (#23418) (#23424)
* Fixes #23388 Network provider masks too much

* Fix trailing whitespace
2017-04-07 14:39:09 -06:00
James Cammarata
0fe53eda86 New release v2.3.0.0-0.4.rc4 2017-04-06 14:10:42 -05:00
Guillaume Coré
c02b89759c fix incorrect parsing of xfs_info
when device name ends with 'data' line matches in :
-                if 'data ' in line:

closes #23352

(cherry picked from commit 3c75808c5c)
2017-04-06 11:11:34 -07:00
Peter Sprygada
69e5f2ae67 fixes return data structure (#22830)
The return was being re-written instead of updated so warnings were
lost.  This patch now updates the result instead of replacing it.
(cherry picked from commit d6787632c9)
2017-04-06 14:01:58 -04:00
Ganesh Nalawade
3cd89bd8a4 Fix #23360 junos_config set format issue (#23365) (#23373)
(cherry picked from commit 990ba90380)
2017-04-06 23:14:50 +05:30
Ricardo Carrillo Cruz
4f56567963 Unhardcode the port and protocol on eos EAPI (#23350)
We were hard-coding the protocol, port and validate_certs on
eos EAPI via the action plugin.
Put defaults on the eos_argument_spec and pull those values from it.
(cherry picked from commit 3537b24742)
2017-04-06 19:19:22 +02:00
Chris Alfonso
292ee29275 Fixes loginBanner plucking over eapi transport when loginBanner isn't set. (#23368) 2017-04-06 11:02:01 -06:00
Ganesh Nalawade
ede49d9115 Fix #22880 junos_config update issue (#23333)
For update parameter add 'override' as acceptable value.
'override' name is in sync with junos naming convention.
(cherry picked from commit 0cd50f0706)
2017-04-06 13:00:55 -04:00
Nathaniel Case
e2a1ea09dc Attempt to clear up nxos_mtu tests and documentation (#23361)
nxos_system wasn't added until 2.3, so nxos_mtu should have been deprecated
then.
(cherry picked from commit 98c23a3342)
2017-04-06 12:27:06 -04:00
nerzhul
1a45463725 Nsupdate idempotency fix
(cherry picked from commit 637e9942ff)
2017-04-06 09:20:45 -07:00
John R Barker
c6e9039b23 fix iosxr commands to encode json (#23346) (#23355)
the command dict in the iosxr module_utils wasn't encoding the request
to json.  this patch will fix that problem
(cherry picked from commit f0008248d4)
2017-04-06 16:18:58 +01:00
John R Barker
0da250c9f1 More network_debug_troubleshooting.html (#23335) (#23341)
More "unable to open shell" -> network_debug_troubleshooting.html
(cherry picked from commit 13dc02d49d)
2017-04-06 12:44:24 +01:00
John R Barker
84d09cdf32 ecs_taskdefinition module : Convert environment variables to string (#23297) (#23337)
Before modification, it fails unless it is a string type
(cherry picked from commit dff35bc205)
2017-04-06 11:19:42 +01:00
John R Barker
d6a8f10a70 Pass CSRF token along with Jenkins POST requests (#23250) (#23330)
(cherry picked from commit 4540853a50)
2017-04-06 10:15:20 +01:00
John R Barker
c3e3580baf 'unable to open shell' -> direct to web help (#23267) (#23331)
* 'unable to open shell' -> direct to web help

The "unable to open shell" error is returned for a number of different,
direct people to online docs (we we can update out of band of releases)
to guide them though the various solutions.

* fix pep8 errors

(cherry picked from commit 529df8640b)
2017-04-06 10:14:42 +01:00
Matt Davis
beb40dd10e Cleanse CLIXML from win_shell stderr (#23329)
prunes all but Error stream values

cherry-picked from b71b157fb3 (plus fixed merge conflicts due to devel cleanup)
2017-04-06 01:45:04 -07:00
Matt Davis
efb717fe73 improve become_method: runas error handling (#23328)
Prescriptive errors for username/password issues and NTLM/Kerb auth failures, cleans up exception noise.
(cherry picked from commit 8d291f91ee)
2017-04-06 01:35:31 -07:00
Ricardo Carrillo Cruz
bfb50df9a7 Check text key exists on eos_banner absent case (#23319)
This can fail if we don't check the key exists.
(cherry picked from commit b9b4e68206)
2017-04-05 21:08:03 +02:00
Ricardo Carrillo Cruz
5e09ddb6a4 Fix eapi basic-login asserts (#23318)
The asserts where not checking the commands sent to the device
(cherry picked from commit 4571ff0b52)
2017-04-05 20:39:59 +02:00
Ganesh Nalawade
3ba95b8ef7 Fix junos pylint issues (#23292)
* Fix junos rollback id validate issue (#23283)

(cherry picked from commit 0b8ca98c48)

* Fix various junos errors (#23278)

(cherry picked from commit e8538213fa)
2017-04-05 23:39:16 +05:30
Chris Alfonso
55583c71ff Fixes #23308 ios_banner: KeyError: 'text' on state: absen (#23313) (#23314) 2017-04-05 12:06:07 -06:00
Ricardo Carrillo Cruz
ebda0bebfc Fix basic-login eapi tests for eos_banner (#23304)
We should be passing the provider dict, not the transport.
(cherry picked from commit d268471739)
2017-04-05 20:02:37 +02:00
Ricardo Carrillo Cruz
6969bef70a Fix asserts on ios_banner tests (#23315)
The contain assert was broken.
(cherry picked from commit cf30f0f27d)
2017-04-05 20:02:24 +02:00
John R Barker
7941f1ede7 enable ios_facts tests again (#23310) (#23312)
(cherry picked from commit f22702eee2)
2017-04-05 17:58:44 +01:00
John R Barker
fc09da86e1 eapi & nxapi: Document validate_certs (#23305) (#23307)
* Document validate_certs for eapu & nxapi

* formatting

(cherry picked from commit 485affeb12)
2017-04-05 16:51:59 +01:00
Nathaniel Case
50500332ae Fix nxos_facts for nxapi transport (#23302)
* Partial revert of 2e476e64cd

This broke handling of nxos_facts over nxapi

* Fix nxos_facts tests not run in isolation

(cherry picked from commit d890167575)
2017-04-05 11:48:28 -04:00
John R Barker
ac9bb4df8e Fixes pylint errors (#23279) (#23295)
Reported by gundalow, this fixes pylint errors in F5 modules
(cherry picked from commit 780b2f2c84)
2017-04-05 14:49:01 +01:00
John R Barker
dbe83cc099 fortios_ipv4_policy.py state=absent Fix 23239 (#23242) (#23290)
* Resolve #23239:
  - path is missing when state=absent
  - update doc for unclear policy ID
  - required params based on state

* Fix pep8 + doc

* Fix doc

* Another doc problem...

* doc

* Update doc fot policy ID

* Fix doc string

* fix required in doc

* fix required in doc Required when I(state=present).

(cherry picked from commit f74a9abbda)
2017-04-05 13:56:40 +01:00
James Cammarata
dc99a7dac2 Only insert notified host if it's not already notified for certain cases
Fixes #18178

(cherry picked from commit a567c5de65)
2017-04-04 16:39:45 -05:00
Toshio Kuratomi
ac1cb3257f Update the metadata of the proxysql modules to 1.0 final format
(cherry picked from commit 572e9a8959)
2017-04-04 14:20:42 -07:00
Toshio Kuratomi
5e3979c25d Add proxysql modules to changelog 2017-04-04 13:50:02 -07:00
bmildren
d6fb616e54 Adding support for ProxySQL (#19872)
* Adding support for ProxySQL
(cherry picked from commit 21ab4343e3)
2017-04-04 13:47:58 -07:00
Nathaniel Case
bf805d1453 junos_config: Remove reliance on ability to output configuration in set format (#23225)
* Remove reliance on ability to output configuration in `set` format
* Support multiple warnings per rpc-reply
2017-04-04 15:01:36 -04:00
Dag Wieers
ec0cbfac4b win_chocolatey: Perform exact presence check (#23098)
The current implementation matches libreoffice-oldstable when testing for libreoffice.
So uninstalling libreoffice fails when libreoffice-oldstable is installed.

```
PS C:\WINDOWS\system32> choco list --local-only libreoffice
Chocolatey v0.10.3
libreoffice-oldstable 5.2.6
1 packages installed.
PS C:\WINDOWS\system32> choco list --local-only --exact libreoffice
Chocolatey v0.10.3
0 packages installed.
```

The solution is easy, just add `--exact`.
(cherry picked from commit 0715430829)
2017-04-04 09:40:06 -07:00
Ricardo Carrillo Cruz
f0e19d8334 Pull filesystems from dict in case is not string on eos_facts (#23254)
Apparently in some devices the filesystems gathering command can return
a dict containing a 'messages' key with the filesystems, instead of a
plain string.

Fixes #23217
2017-04-04 16:04:45 +02:00
Matt Clay
08be1ae562 Fix integration aliases.
(cherry picked from commit b7cc4616b1)
2017-04-03 17:50:18 -07:00
Matt Clay
179f6c8f23 Fix deploy_helper join exception on no release.
(cherry picked from commit 64458bc9a1)
2017-04-03 16:55:31 -07:00
Ricardo Carrillo Cruz
d1124359f5 Remove dupe supports_session method from eos module_utils (#23240)
Fixes #23237
2017-04-04 00:47:39 +02:00
Matt Davis
5545532328 mark runas become method experimental (#23235)
Due to the number of "real world" caveats in the current runas become method, it was agreed that we'd warn that it's experimental on use. A potential future version based on LogonUser/CreateProcessAsUser will have very different requirements and limitations.
(cherry picked from commit d85f4a443f)
2017-04-03 13:47:30 -07:00
Jordan Borean
45b56cb081 win_find fix up age parameter (#23195)
(cherry picked from commit 3e1a16c574)
2017-04-03 13:24:33 -07:00
Jordan Borean
401f6d68d6 win_stat change return islink to islnk to match stat (#23196)
(cherry picked from commit 4d1b97d1ae)
2017-04-03 11:39:33 -07:00
John R Barker
f0cbd32dd1 Update fortios_config.py (#23230) (#23232)
(cherry picked from commit 5918bebd6e)
2017-04-03 19:25:01 +01:00
Strahinja Kustudić
0dc890fbac Fixes ignoreerrors not working with sysctl_set
(cherry picked from commit 7358bf88e2)
2017-04-03 06:37:42 -07:00
James Cammarata
f15e1f25ae New release v2.3.0.0-0.3.rc3 2017-03-31 13:50:42 -05:00
John R Barker
f8cef96c2c Updated the Regex for promt matching (#23186) (#23188)
(cherry picked from commit 632270b913)
2017-03-31 18:38:57 +01:00
John R Barker
1b2411c6d2 Fixes generators and other misc fixes (#22887) (#23172)
fixed itertools.imap busting several things that used to be lists,
profiles not being set correctly, upon create, when it was a separate
method, allowed port having the wrong lowest port (zero is allowed),
empty port value should just be interpreted as None.
(cherry picked from commit 2a576a1999)
2017-03-31 10:39:59 +01:00
Erwin Lang
131729726f synchronize: Exclude ssh_args from quoting
Makes it possible again to pass more than one argument via ssh_args to the synchronize module.

(cherry picked from commit 3efb11e225)
2017-03-30 19:41:18 -07:00
Ricardo Carrillo Cruz
5744abfe4e Fix eos_banner cli basic_motd integration test (#23158)
A task was lacking the provider variable, causing the test to fail.

Fixes #23130
2017-03-31 00:28:37 +02:00
Alex Willmer
07ea6a6adf Include '/' & '.' when password_hash generates a new salt
The password_hash filter will generate a salt value if none is supplied.
The character set used by Ansible

(upper & lowercase letters, digits)

did not match that used by libc crypt

(upper & lowercase letters, digits, full stop, forward slash).

This resulted in a slightly smaller key space, and hence hashes would be
slightly easier to attack (e.g. by dictionary, brute force).

(cherry picked from commit f5aa9df1fd)
2017-03-30 12:47:34 -07:00
John R Barker
1ba7e6b6f6 Ansible 2.3 feature support for dellos6. (#23084) (#23147)
* Ansible 2.3 feature support for dellos6.

- With the new Ansible 2.3 infra changes, the dellos modules doesn't work
  (the new infra changes are not backward compatible), so added the below
  changes support it.
- Added the new terminal plugin for DellOS6
- Added the new action plugin for DellOS6
- Modified the modules to work with the new infra.
- with that it adds support for DellOS6 Persistent Connection support.

* Remove pep8 confirming files from dellos6.py and dellos6_config legacy-files

(cherry picked from commit a0344acd78)
2017-03-30 17:42:11 +01:00
Peter Sprygada
7afc9ac899 fixes error parsing lldp neighbors when running nxos_facts (#23134)
(cherry picked from commit 2e476e64cd)
2017-03-30 11:31:53 -04:00
John R Barker
1b188c1fb9 updates log messages in ansible-connection (#23076) (#23125)
(cherry picked from commit 53c52cf65f)
2017-03-30 13:24:47 +01:00
Ricardo Carrillo Cruz
af83d4d4df Fix ios_config return on python 2.4 (#23094) 2017-03-30 00:22:33 +02:00
Ricardo Carrillo Cruz
18dedd985a Do not re.search show configuration stdout if empty (#23087)
If the banner is not set, the stdout of 'show configuration | begin banner <banner>'
returns empty string thus the re.search raises an exception.

Fixes #22216
2017-03-29 23:02:46 +02:00
Ricardo Carrillo Cruz
664b27aaf0 Introspect flag to use on 'show run' when using defaults in ios_config (#22903)
When the ios_config module has 'defaults' param it runs in the device the command
'show running-config all' but 'all' may not be available in older devices.
This change makes introspection by using the help command and run 'full' in case
'all' is not available.

Fixes #22747
2017-03-29 22:53:14 +02:00
Ricardo Carrillo Cruz
3859551eb3 Fall-back to show configuration on old IOSXR devices (#22900)
In old IOSXR versions, 'show commit changes diff' does not work.
Fall-back to 'show configuration' if that command fails so execution
can move forward.

Fixes #22235
2017-03-29 22:52:00 +02:00
Peter Sprygada
53934702ce restores pre 2.3 behavior with respects to keys (#23083)
This removes the requirement to configure look_for_keys=False and
restores the behavior to disable key lookup if no key was provided.
(cherry picked from commit 88ce6fd273)
2017-03-29 15:13:33 -04:00
Toshio Kuratomi
4a9c5d9574 Split on newlines when searching for become prompt
The fix for leading junk in sudo output: fee6e29 causes problems with
ssh + sudo.  On the initial connection using ControlPersist, the output
that we scan for the prompt contains both the command we're sending to
configure the prompt and the prompt itself.  The code in fee6e29 ends up
sending the password when it sees the line configuring the prompt which
is too early.

Switch to a version that splits on lines and then checks whether the
first or last line starts with the prompt to decide if it's time to send
the password.

Fixes #23054
References #20858

(cherry picked from commit 6f77498700)
2017-03-29 12:11:57 -07:00
jhawkesworth
c528d8b17d changed parameter name from forest_root_dns_domain to dns_domain_name (to match documentation and other win_domain* modules) and fix example which has win_domain_controller instead of win_domain for module name. (#23081)
(cherry picked from commit 4eba248a8e)
2017-03-29 11:35:23 -07:00
jhawkesworth
c8dc993fb4 correct examples to match correct _password module parameter names (#23067)
(cherry picked from commit a3e2280e62)
2017-03-29 11:32:59 -07:00
Artem Zinenko
7c84593eb0 Fix #22126 (#22128)
(cherry picked from commit a5da638d34)
2017-03-29 11:30:58 -07:00
Pavel Glushchak
657fd1dfd1 Added Virtuozzo distribution support
Virtuozzo Linux is based on CentOS sources. Thus OS family
should be recognized as 'RedHat'.

Signed-off-by: Pavel Glushchak <pglushchak@virtuozzo.com>
(cherry picked from commit 097173c6f5)
2017-03-29 08:47:48 -07:00
Fabrizio Colonna
4465171e89 Fixed issue #22996 and issue #22955. 2017-03-29 08:29:10 -07:00
Victor Perron
9ee2065477 paramiko_ssh: fix crash upon pass prompt in py3
The pass prompt expects an answer and compares a `str` to a binary buffer, thus crashing.

It's an obvious fix to help transitioning towards Python3 and hopes it does not need a specific test.
(cherry picked from commit bc44175d8d)
2017-03-29 07:47:48 -07:00
Jeremy L. Gaddis
ca497b43e4 Update requirements for seboolean module (fixes #23028)
(cherry picked from commit b52dbddc17)
2017-03-29 07:25:27 -07:00
Toshio Kuratomi
bb0b90783c Fix for tests run with no .ssh user dir
When building in automated build systems, there are sometimes cases
where the user doing the building does not have a .ssh directory.  In
this case, we need to mock out some os.path functions so that the
add_host_key() function we're testing won't complain or try to create
one.

(cherry picked from commit ade3fc2893)
2017-03-28 19:28:15 -07:00
Dag Wieers
d9a6714cb9 win_chocolatey: Fix state=latest when absent (#23041)
When using state=latest with the package not being installled, Ansible complains that the package is not installed and fails the task.
Whereas the expected behaviour is to install the package when it is missing.

This PR fixes this behaviour.
(cherry picked from commit 521fa9b458)
2017-03-28 17:50:17 -07:00
Toshio Kuratomi
9785d5b2fb Fix synchronize tests for the updated quoting change between action and module
(cherry picked from commit b0d75a0ecb)
2017-03-28 14:15:42 -07:00
Toshio Kuratomi
da10768b10 Fix a couple issues in synchronize with docker (#23047)
* Fix a couple issues in synchronize with docker

* Make the rsync_opts parse as a list using the same criteria as
  module_utils argumentspec parsing
* Do not quote arguments in the action plugin.  The module will quote as
  it knows whether it will invoke rsync with a shell or via exec.

Fixes #23046
(cherry picked from commit d3a1aea7c5)
2017-03-28 11:39:18 -07:00
John R Barker
48f6af4907 updates sample ansible.cfg (#23045) (#23050)
* adds host_key_auto_add to paramiko section
* adds look_for_keys to paramiko section
* adds terminal_plugins to defaults section
* adds persistent_connection section and key/value enteries
(cherry picked from commit ccfa464464)
2017-03-28 19:08:32 +01:00
Peter Sprygada
0c0d949c47 minor updates to network connection plugins (#23043)
* removes unused log() function in network_cli
* adds method comments to terminal plugin base
(cherry picked from commit 768cb437ab)
2017-03-28 13:00:09 -04:00
Evgeni Golov
7c9c8396d1 cron: don't force changed=True when old crontab was empty
The cron module forces changed=True when there was no real change,
but the original crontab did not contain a final newline, which is
mandatory.

When the user has no crontab or the user does not exist at all,
crontab -l exits with 1 and the cron module correctly interprets
this as "no crontab" and stores the old crontab as "".

However this triggers changed=True, even if we're not going to
change anything, e.g. when removing a crontab entry from a user
who has no crontabs at all.

Let's special-case the fact that the old crontab is empty and not
force changed=True in that case.

(cherry picked from commit 61579aebb2)
2017-03-28 07:45:45 -07:00
James Cammarata
f001646f2c New release v2.3.0.0-0.2.rc2 2017-03-27 16:25:02 -05:00
John R Barker
f3c839b35f Ansible 2.3 feature support for dellos9 and dellos10 (#23010) 2017-03-27 20:32:18 +01:00
John R Barker
80c4a02c5f Network module docs 2.3 (#22454) (#22995)
Network module docs 2.3 (#22454)
Cherry pick of https://github.com/ansible/ansible/pull/22454 into stable-2.3

* Tidy up docs for network 2.3 modules

* Use suboptions

* Correct indentation

* more tidyup

* bulk updates

* more tidyup

* Bulk changes

* nxos_mtu is dead

* revert

* NXOS_mtu is dead, also better layout

* rebase

* rebase

(cherry picked from commit f82239e1f7)

* metadata_version - merge error
2017-03-27 13:18:36 +01:00
Peter Sprygada
01abc097ee removes unused code in eos action plugin (#22986)
(cherry picked from commit ab4b8cb104)
2017-03-27 00:51:57 -04:00
Peter Sprygada
63812b0a2c roll up of fixes for sros modules (#22972)
* fixes action handlers for sros
* fixes sros_config module execution to use AnsibleModule
* fixes sros_command module to use socket connection
* adds sros to constants

(cherry picked from commit 3169cbd493)
2017-03-25 10:40:23 -04:00
Peter Sprygada
ba49443532 fixes junos_package module to use junos_pyez (#22973)
This allows junos_package to use junos_pyez directly instead of the
persistent connection.  This is a workaround fix for 2.3
(cherry picked from commit 33624fe96f)
2017-03-25 10:22:59 -04:00
Gabriele
66481d3d2f Fixing module behavior when route_target_both is used (#20076)
(cherry picked from commit 9b2bdf2df6)
2017-03-25 08:02:58 -04:00
Peter Sprygada
d1ed72ad37 fixes issue where nxos module will fail due to KeyError (#22966)
Updates nxos action handler to handle deleting provider key if exists or
silently continuing if a  KeyError is raised.
(cherry picked from commit 6a414371a1)
2017-03-25 07:45:59 -04:00
Peter Sprygada
75d19442e3 fixes log message in junos action handler (#22965)
(cherry picked from commit e93cdecef1)
2017-03-25 00:39:29 -04:00
Peter Sprygada
f0bd79d41b fixes ansible-connection working directory (#22964)
When ansible-connection forks the process, it changed the working
directory to /.  This patch will prevent ansible-connection from
changing the working directory in the forked process.
(cherry picked from commit 77ce83fe22)
2017-03-25 00:36:00 -04:00
Matt Clay
15695ea3bc Associate systemd module with service test. (#22847)
(cherry picked from commit 318445fe19)
2017-03-24 13:30:12 -07:00
Toshio Kuratomi
58f002d8f0 Handle the case where HTTPError.info() returns an object that aren't (#22894)
dict-like enough (can't be used with **).

This should give a better error message for #22872
(cherry picked from commit 29f623571e)
2017-03-24 12:25:45 -07:00
Erwin Lang
c16622b072 synchronize: Convert cmd to list and fix handling of the copy_links argument (#22573)
* synchronize: Convert cmd to list and fix handling of the copy_links argument

Converting cmd from str to list stops the pain of argument quoting/escaping.

* synchronize: Update imports according to #pullrequestreview-28758614

(cherry picked from commit f7c9f44aab)
2017-03-24 09:26:11 -07:00
Toshio Kuratomi
422baea136 base64 functions must be given byte strings
The base64 stdlib functions require byte strings.  So we have to
transform the strings into bytes before handing to the stdlib and then
transform them back into text before handing back to ansible.

Fixes #22873

(cherry picked from commit 589e217278)
2017-03-24 09:23:25 -07:00
Matt Davis
631eaccc64 force Windows to always use preamble-free UTF8 input encoding (#22934)
* fixes #15770
* When running under the UTF-8 codepage, Powershell subprocesses will fail (eg, Start-Job, others) if the input encoding is using the default BOM preamble. This fix forces it to use no preamble in leaf_exec and win_shell, and includes tests to verify that Start-Job works.
(cherry picked from commit e084e8809e)
2017-03-24 00:03:16 -07:00
Dhivyap
43310bb7b7 Fixes#21557-Handled dellos9_facts crash with IPV6 configs (#21652)
(cherry picked from commit cd662efd2b)
2017-03-23 23:07:58 -04:00
Artem Zinenko
7f1a7a4372 win_firewall_rule doesn't fail when profile is "any" or remoteip is IPv4 and the task runs more than once. (#22555)
* Fixed #22554

* Wrote tests for win_firewall_rule module

* Fixed #22786

* Fixed review comments

* Fixed #22799

* Added test when RemoteIP containt a netmask

* Revert comment

(cherry picked from commit f4b34a4c3b)
2017-03-23 20:02:16 -07:00
Peter Sprygada
2cfe8b95de fixes a number of issues with nxos_facts (#22923)
* updates command runs to return warning if command fails
* fixes variable issues from recent refactoring
* removes provider from return of module
(cherry picked from commit 866f67e213)
2017-03-23 22:58:57 -04:00
Gabriele
30734d178c Fixing nxos_vrf_interface when interface name is not full (#22769)
(cherry picked from commit d7d76f3aaf)
2017-03-23 22:58:38 -04:00
Dag Wieers
8b9ccc15f7 win_scheduled_tasks: Improve example test framework (#22833)
Updated as discussed in previous Test Working Group.
(cherry picked from commit ef36d7de68)
2017-03-23 19:44:02 -07:00
Matt Davis
9154981684 fix Windows env handling
* fixes #22441
* fixes #22655
* moves all env handling into the exec wrapper; this should work for everything but raw, which is consistent with non-Windows.

(cherry picked from commit cc6821261275be59e6092f3e651a1e79f39de9cc)
2017-03-23 17:48:55 -07:00
Peter Sprygada
6201f9eb14 fixes issue when host is defined in provider for junos (#22918)
The junos action handler was not honoring the host value in the provider
argument.  This patch will now use the provider host entry if it exists
and falls back to the inventory hostname
(cherry picked from commit cda3e001c6)
2017-03-23 19:05:29 -04:00
Jordan Borean
5eae522d94 win_reg_stat change the module parameters for standardisation (#22732)
(cherry picked from commit f1ab879bb6)
2017-03-23 15:16:11 -07:00
Jordan Borean
4d3e5a14e6 win_share: tweaks after the caching mode changes (#22763)
* win_share: tweaks after the caching mode changes

* Re-added the Unknown option back in

(cherry picked from commit 89b78cb5e8)
2017-03-23 15:10:03 -07:00
Toshio Kuratomi
0edc943c68 Make yum's state=list obey disablerepo and enablerepo
Fixes #22876

(cherry picked from commit d0712b1ec7)
2017-03-23 12:12:51 -07:00
Dustin Spicuzza
2551b53a9a win_iis_webapppool: Use Get-AnsibleParam to retrieve parameter
- Fixes #22805

(cherry picked from commit 78de05e58d)
2017-03-23 07:43:09 -07:00
Matt Clay
7d79105cf4 Overhaul ansible-test import analysis. (#22888)
- Add support for module_utils packages for better organization.
- Add support for "virtual" module_utils packages such as `six`.

(cherry picked from commit 4fdeade389)
2017-03-22 23:02:44 -07:00
Evgeni Golov
aafb5bb168 synchronize: explicitly set the executable for localhost
Otherwise the executable for the destination is also used on the local
machine and this might not exist.

Fixes: #22867
(cherry picked from commit 7a00f28804)
2017-03-22 21:28:17 -07:00
Glen Maetzig
223fc34ab9 Import camel_dict_to_snake_dict method to fix error when executing get_nat_gateways() method 2017-03-22 16:25:48 -07:00
Shaun Brady
dc61ea999a Missing purge_subnets parameter on function call
purge_subnets|routes were introduced recently.
ensure_subnet_associations now takes purge_subnets as a parameter.  A
call to this function was missed when introducing this feature.  With
out, results in a "got 5 expected 6" error.

(cherry picked from commit cd24bbbc9c)
2017-03-22 16:24:06 -07:00
Brian Coca
2152bd8da2 fix for loosing ungrouped hosts in ini
fixes #22861

(cherry picked from commit 052be86605)
2017-03-22 12:48:17 -04:00
Brian Coca
4e6cdf8989 better handling of parsed
updated tests to match new result output

(cherry picked from commit 5e98be2e62)
2017-03-22 12:03:34 -04:00
Brian Coca
4f8a2d3806 prevent failure for meta: reset_connection
now plugins that don't explicitly support it give a warning.

(cherry picked from commit 9ad62a48ab)
2017-03-22 11:00:45 -04:00
Ricardo Carrillo Cruz
3db0bbe76c Fallback to show-run on ios_banner for devices where show banner does not work (#22793)
On switches 'show banner' command doesn't work, fallback to show run|begin banner
and extract the banner text in case that fails.
2017-03-22 11:07:49 +01:00
Ted Timmons
9bafde67a8 Fix stderr false return value (#22845)
* ensure exit_json does not fail from stderr=False

- do a little bit of safety-checking in exit_json to not try to .splitlines() on a boolean
- remove the stderr=boolean from uri.py, this is the only spot that uses it (at least so obviously)
- add unit tests that call exit_json. These are useless because the stderr parsing is in _execute_module and is difficult to mock; deleting these tests after the commit.

* remove added unit tests per prev commit

exit_json doesn't do the param parsing, that is buried deep inside _execute_module.

(cherry picked from commit 887456ab8e)
2017-03-21 18:11:08 -04:00
Brian Coca
566ef91e26 fixed passwordstore lookup examples
plugin was renamed before acceptance, but examples kept original name
fixes #22735

(cherry picked from commit 6a2985dd3cdbc967ff7d7e9625af1d517a425a33)
2017-03-21 15:42:09 -04:00
Peter Sprygada
8f6fd60fe2 fixes exception raised from ansible-connection logging (#22836)
updates ansible-connection logging functions to use display instead of
log.
(cherry picked from commit 4a8f2dde20)
2017-03-21 12:16:07 -04:00
Sloane Hertel
116ba9196d Fix get_s3_connection (fixes #22317) (#22318) (#22831)
* Fix get_s3_connection (fixes #22317)

Override aws_connect_kwargs rather than prepending to them. Should fix an issue in which `calling_format` is set twice in the kwargs passed to `boto.connect_s3` or `S3Connection` if a bucket name contains a `.`

* Revert "Fix get_s3_connection (fixes #22317)"

This reverts commit 7f61b8bebd2929940495204f1a98d660a55985d8.

* implements alternative way of fixing issue with aws_connect_kwargs for rgw and fakes3 (fixes 22317)

* add comment to explain why the keys are being removed from aws_connect_kwargs

* remove trailing whitespace on comment line
2017-03-21 10:09:24 -04:00
Ricardo Carrillo Cruz
89a2d1d6ad Add ios_banner module (#22687)
With unit and integration tests.
2017-03-21 12:29:45 +01:00
Peter Sprygada
e4f052c1a9 replaces logging with display for network connection plugins (#22819)
* updates network_cli and netconf connection plugins
* updates ansible-connection
(cherry picked from commit e20ed8bc0c)
2017-03-20 23:08:49 -04:00
Peter Sprygada
c093d14697 implements python logging for network connection plugin (#22817)
* enables logging for network_cli and paramiko
* enables logging for ansible-connection
* enabled logging for netconf connection
(cherry picked from commit ed7cace425)
2017-03-20 22:32:25 -04:00
Dylan Silva
acd9303b7b cherry pick changes to modules and docs for 2.3 rc (#22815)
* Dropped openwrt module from curated to community (#22657)

* changed supported_by from curated to community (#22656)

* Changed supported_by from curated to community (#22654)

* Updates to docs for metadata. (#22667)

* Updates to docs for metadata.

* Update developing_modules_documenting.rst
2017-03-20 19:21:26 -07:00
Matt Clay
0c2c19edb4 Fix metadata handling for shell command. (#22801)
(cherry picked from commit 042e387f27)
2017-03-20 15:32:35 -07:00
Matt Clay
3f8e8a3390 Add missing needs/root alias to file test. (#22800)
(cherry picked from commit 3585d3d368)
2017-03-20 14:14:16 -07:00
Joseph Price
115d91069c CLI: unfrack --private-key path
Relative paths can break the synchronize plugin when the playbook
is not in the current working directory.

Fixes: ansible/ansible#22695
(cherry picked from commit ed15ba1b3c)
2017-03-20 11:41:00 -07:00
Matt Clay
b73a1be03a Disable failing MySQL tests on FreeBSD. (#22798)
(cherry picked from commit b7c80dbb7e)
2017-03-20 09:54:16 -07:00
Brian Coca
169b5dfaec added 'existing' back
fixes #22785

(cherry picked from commit 07d9366ed8)
2017-03-20 12:29:05 -04:00
Gabriele
8a563047e6 Fixing nxos_facts (#22783) 2017-03-20 06:54:15 -07:00
Rene Moser
1799376ab7 cloudstack: fix load balancer idempotency if no zone given
get_zone() is special, as it always returns a zone (default zone) even
if no zone param is given. This makes sense for many use cases.

(cherry picked from commit d1e8ef79ea2b5f22d875f0e468e6ce0a4e0ab6e8)
2017-03-19 10:09:07 +01:00
Matt Clay
5ae1967aea Fix ansible-test base branch handling on merge. (#22759)
(cherry picked from commit 991bf0a1c3)
2017-03-17 23:34:27 -07:00
Matt Clay
0e864fd81b Fix uri options test to work again.
(cherry picked from commit 93d9b04f1d)
2017-03-17 22:31:22 -07:00
Matt Clay
0ca10bf3d5 Fix ansible-test base branch usage on Shippable.
(cherry picked from commit 47887a2edd)
2017-03-17 17:36:16 -07:00
David Baumann
7ba4f43be4 Add Missing default param for caching_mode (#22753)
Add Missing default param for caching_mode and Usage of new Ansible-Param Commant with default Value
(cherry picked from commit 634d6894e3)
2017-03-17 14:46:32 -07:00
Matt Clay
c935d2f038 Do not run win_chocolatey in CI tests.
The test is failing repeatedly.

(cherry picked from commit 011b324638)
2017-03-17 09:01:31 -07:00
Matt Davis
923c9ef17c Windows CHANGELOG updates
(cherry picked from commit e3dfa62abc)
2017-03-16 15:02:36 -07:00
jralbert
8857a80109 Cast syslogport value from getenv as int (#22664)
SysLogHandler requires an int for port, but getenv produces a string.
Cast return from getenv as int to overcome this mismatch.
(cherry picked from commit 5334814396)
2017-03-16 10:39:51 -07:00
Matt Clay
dc8ad50eaa Fix ansible-test PR diff handling.
Permits use of PRs on branches other than devel.

(cherry picked from commit f7c83ccdc0)
2017-03-16 10:37:10 -07:00
Brian Coca
3f276c5def readded !vault-encrypted for backwards compat
even though this was never documented someone might be using it

(cherry picked from commit 6a4039e169)
2017-03-16 13:24:43 -04:00
Brian Coca
ac92218e38 updated release 2017-03-16 13:24:43 -04:00
Brian Coca
ec05cd6336 better 'role detection' for dwim (#22513)
* better 'role detection' for dwim

possible fix for #21735

* fixed unmatched paren

* pep does not like the denting

(cherry picked from commit 517cdbe22a)
2017-03-16 13:24:43 -04:00
Ilya Simonenko
e9439c54f6 cloud: docker: Fixes #22638 load image to memory when archive_path provided (#22642)
(cherry picked from commit dba8edf735)
2017-03-16 10:07:30 -07:00
Matt Clay
c72ac9b230 Add test verification to ansible-test. (#22636)
* Add unified git diff parser.
* Add metadata and diff handling.
* Add test confidence/verification to bot output.

(cherry picked from commit 869449e288)
2017-03-15 14:48:53 -07:00
James Cammarata
e4494f85b6 New release v2.3.0.0-0.1.rc1 2017-03-15 14:13:52 -05:00
Brian Coca
8283fd51c3 corrected host group ancestor management
(cherry picked from commit 3d5bc49a06e12d3b1ed94e08fb288561833569b1)
2017-03-15 14:58:53 -04:00
Brian Coca
eccfcf020c simplified pattern matching, fixed ungrouped (#22523)
* simplified pattern matching, fixed ungrouped

ungrouped was ignored for patterns, now it is usable again

* even simpler

(cherry picked from commit 273786d0bd)
2017-03-15 14:58:53 -04:00
Matt Clay
c9ea993c88 Verify SHA in Shippable change detection.
(cherry picked from commit 5e9a2b8528)
2017-03-15 11:32:41 -07:00
James Cammarata
d86e2e2aa9 Updating packaging release version yaml 2017-03-15 11:37:59 -05:00
739 changed files with 19149 additions and 5967 deletions

3
.gitignore vendored
View file

@ -2,9 +2,10 @@
*.py[co]
build
AUTHORS.TXT
# Emacs backup files...
# Emacs backup and autosave files...
*~
.\#*
\#*
# RPM stuff...
MANIFEST
dist

View file

@ -1,15 +1,179 @@
Ansible Changes By Release
==========================
## 2.3 TBD - ACTIVE DEVELOPMENT
<a id="2.3.4"></a>
## 2.3.4 "Ramble On" - TBD
* Flush stdin when passing the become password. Fixes some cases of timeout on
Python3 with the ssh connection plugin: https://github.com/ansible/ansible/pull/35049
### Bugfixes
* Fix setting of environment in a task that uses a loop:
https://github.com/ansible/ansible/issues/32685
* Fix https retrieval with TLSv1.2: https://github.com/ansible/ansible/pull/32053
<a id="2.3.3"></a>
## 2.3.3 "Ramble On" - TBD
### Bugfixes
* Security fix for CVE-2017-7550 the jenkins_plugin module was logging the jenkins
server password if the url_password was passed via the params field:
https://github.com/ansible/ansible/pull/30875
* Fix alternatives module handlling of non existing options
* Fix synchronize traceback with the docker connection plugin
* Do not escape backslashes in the template lookup plugin to mirror what the template module does
* Fix the expires option of the postgresq_user module
* Fix for win_acl when settings permissions on registry objects that use `ALL APPLICATION PACKAGES` and `ALL RESTRICTED APPLICATION PACKAGES`
* Python3 fixes
* asorted azure modules
* pause module
* hacking/env-setup script
* Fix traceback when checking for passwords in logged strings when logging executed commands.
* docker_login module
* Workaround python-libselinux API change in the seboolean module
* digital_ocean_tag module
* Fix the zip filter
* Fix user module combining bytes and text
* Fix for security groups in the amazon efs module
* Fix for the jail connection plugin not finding the named jail
* Fix for blockinfile's parameters insertbefore and insertafter
* ios_config: Fix traceback when the efaults parameter is not set
* iosxr_config: Fixed unicode error when UTF-8 characters are in configs
* Fix check mode in archive module
* Fix UnboundLocalError in check mode in cs_role module
* Fix to always use lowercase hostnames for host keys in known_hosts module
* Added missing return results for win_stat
* Fix rabbitmq modules to give a helpful error if requests is not installed
* Fix yum module not deleting rpms that it downloaded
* Fix yum module failing with a URL to an rpm
* Fix file module inappropriately expanding literal dollar signs in a path read
from the filesystem as an environment variable.
* Fix the ssh "smart" transport setting which automatically selects the best means of
transferring files over ssh (sftp, ssh, piped).
* Fix authentication by api_key parameter in exoscale modules.
* vmware module_utils shared code ssl/validate_certs fixes in connection logic
* allow 'bridge' facts to work for certain containers that create conflicting ones with connection plugins
* Fix for win_get_url to use TLS 1.2/1.1 if it is available on the host
* Fix for the filetree lookup with non-ascii group names
* Better message for invalid keywords/options in task due to undefined expressions
* Fixed check mode for enable on Solaris for service module
* Fix cloudtrail module to allow AWS profiles other than the default
* Fix an encoding issue with secret (password) vars_prompts
* Fix for Windows become to show the stdout and stderr strings on a failure
* Fix the issue SSL verification can not be disabled for Tower modules
* Use safe_load instead on load to read a yaml document
* Fix for win_file to respect check mode when deleting directories
* Include_role now complains about invalid arguments
* Added socket conditions to ignore for wait_for, no need to error for closing already closed connection
* Updated hostname module to work on newer RHEL7 releases
* Security fix to avoid provider password leaking in logs for network modules
<a id="2.3.2"></a>
* Python3 fixes for azure modules
## 2.3.2 "Ramble On" - 2017-08-04
### Bugfixes
* Fix partend i18n issues
* fixed handling of extra vars for tower_job_template (#25272)
* Python3 bugfixes
* Fix sorting of ec2 policies
* Fix digital_ocean dynamic inventory script
* Fix for the docker connection plugin
* Fix pip module when using python3's pyvenv and python3 -m venv to create virtualenvs
* Fix for the AnsiBallZ wrapper so that it gives a better error message when
there's not enough disk space to create its tempdir.
* Fix so ansilbe-galaxy install --force with unversioned roles will once again
overwrite old versions.
* Fix for RabbitMQ 3.6.7 endpoint return code changing.
* Fix for Foreman organization creation
* fixed incorrect fail_json ref in rpm_key
* Corrected requried on hash_name for dynamodb_table
* Fix for fetch action plugin not validating correctly
* Avoid vault view writing display to logs
* htpasswd: fix passlib module version comparison
* Fix for flowdock error message when external_user_name is missing
* fixed corner case for delegate_to, loops and delegate_facts
* fixed wait_for python2.4/2.5 compatibility (this is last version this is needed)
* fix for adhoc not obeying callback options
* fix for win_find where it fails to recursively scan empty nested directories
* fix non-pipelined code paths for Windows (eg, ANSIBLE_KEEP_REMOTE_FILES, non-pipelined connection plugins)
* fix for win_updates where args and check mode were ignored due to common code change
* fix for unprivileged users to Windows runas become method
* fix starttls code path for mail module
* fix missing LC_TYPE in parted module
* fix CN parsing with OpenSSL 1.1 in letsencrypt module
* fix params assignment in jabber module
* fix TXT record type handling in exo_dns_record module
* fix message queue message ttl can't be 0 in rabbitmq_queue module
* CloudStack bugfixes:
* fix template upload for users in cs_template module, change default to is_routing=None
* several fixes in cs_host module fixes hypervisor handling
* fix network param ignored due typo in cs_nic module
* fix missing type bool in module cs_zone
* fix KeyError: 'sshkeypair' in cs_instance module for CloudStack v4.5 and before
* fix for win_chocolatey where trying to upgrade all the packages as per the example docs fails
* fix for win_chocolatey where it did not fail if the version set did not exist
* fix for win_regedit always changing a reg key if the dword values set is a hex
* fix for wait_for on non-Linux systems with newer versions of psutil
* fix eos_banner code and test issues
* run tearup and teardown of EAPI service only on EAPI tests
* fix eos_config tests so only Eth1 and Eth2 are used
* Fix for potential bug when using legacy inventory vars for configuring the su password.
* Fix crash in file module when directories contain non-utf8 filenames
* Fix for dnf groupinstall with dnf-2.x
* Fix seboolean module for incompatibility in newer Python3 selinux bindings
* Optimization for inventory, no need to dedup at every stage, its redundant and slow
* Fix fact gathering for package and service action plugins
* make random_choice more error resilient (#27380)
* ensure prefix in plugin loading to avoid conflicts
* fix for a small number of modules (tempfile, possibly copy) which could fail
if the tempdir on the remote box was a symlink
+ fix non-pipelined code paths for Windows (eg, ANSIBLE_KEEP_REMOTE_FILES, non-pipelined connection plugins)
* fix for win_updates where args and check mode were ignored due to common code change
<a id="2.3.1"></a>
## 2.3.1 "Ramble On" - 2017-06-01
### Bugfixes
* Security fix for CVE-2017-7481 - data for lookup plugins used as variables was not being correctly marked as "unsafe".
* Fix default value of fetch module's validate_checksum to be True
* Added fix for "meta: refresh_connection" not working with default 'smart' connection.
* Fix template so that the --diff command line option works when the destination is a directory
* Fix python3 bugs in pam_limits
* Fix unbound error when using module deprecation as a single string
* Several places in which error handling was broken due to bad conversions or just typos
* Fix to user module for appending/setting groups on OpenBSD (flags were reversed)
* assemble fix to use safer os.join.path, avoids charset issues
* fixed issue with solaris facts and i18n
* added python2.4 compatiblity fix to sysctl module
* Fix comparison of exisiting container security opts in the docker_container module
* fixed service module invocation of insserv on certain platforms
* Fix traceback in os_user in an error case.
* Fix docker container to restart a container when changing to fewer exposed ports
* Fix tracebacks in docker_network
* Fixes to detection of updated docker images
* Handle detection of docker image changes when published ports is changed
* Fix for docker_container restarting images when links list is empty.
<a id="2.3"></a>
## 2.3 "Ramble On" - 2017-04-12
Moving to Ansible 2.3 guide http://docs.ansible.com/ansible/porting_guide_2.3.html
### Major Changes
* Documented and renamed the previously released 'single var vaulting' feature, allowing user to use vault encryption for single variables in a normal YAML vars file.
* Allow module_utils for custom modules to be placed in site-specific directories and shipped in roles
* On platforms that support it, use more modern system polling API instead of select in the ssh connection plugin.
This removes one limitation on how many parallel forks are feasible on these systems.
* Windows supports become method "runas" to run modules as a different user, and to transparently access network resources.
* Windows now uses pipelining when executing modules, resulting in significantly faster execution for small tasks.
* Windows/WinRM supports (experimental) become method "runas" to run modules and scripts as a different user, and to transparently access network resources.
* The WinRM connection plugin now uses pipelining when executing modules, resulting in significantly faster execution for small tasks.
* The WinRM connection plugin can now manage Kerberos tickets automatically when `ansible_winrm_transport=kerberos` and `ansible_user`/`ansible_password` are specified.
* Refactored/standardized most Windows modules, adding check-mode and diff support where possible.
* Extended Windows module API with parameter-type support, helper functions. (i.e. Expand-Environment, Add-Warning, Add-DeprecatationWarning)
* restructured how async works to allow it to apply to action plugins that choose to support it.
@ -31,6 +195,7 @@ Ansible Changes By Release
* 'service' tasks can now use async again, we had lost this capability when changed into an action plugin.
* made any_errors_fatal inheritable from play to task and all other objects in between.
* many small performance improvements in inventory and variable handling and in task execution.
* Added a retry class to the ec2_asg module since customers were running into throttling errors (AWSRetry is a solution for modules using boto3 which isn't applicable here).
### Deprecations
* Specifying --tags (or --skip-tags) multiple times on the command line
@ -165,6 +330,7 @@ Ansible Changes By Release
* ipa_user
- ipinfoio_facts
- ios:
* ios_banner
* ios_system
* ios_vrf
- iosxr_system
@ -258,6 +424,14 @@ Ansible Changes By Release
* panos_service
- postgresql_schema
- proxmox_kvm
- proxysql:
* proxysql_backend_servers
* proxysql_global_variables
* proxysql_manage_config
* proxysql_mysql_users
* proxysql_query_rules
* proxysql_replication_hostgroups
* proxysql_scheduler
- pubnub_blocks
- pulp_repo
- runit
@ -311,6 +485,7 @@ Ansible Changes By Release
* zfs_facts
* zpool_facts
<a id="2.2.1"></a>
## 2.2.1 "The Battle of Evermore" - 2017-01-16
@ -337,10 +512,11 @@ Ansible Changes By Release
* Improvements and fixes to OpenBSD fact gathering.
* Updated `make deb` to use pbuilder. Use `make local_deb` for the previous non-pbuilder build.
* Fixed Windows async to avoid blocking due to handle inheritance.
* Fixed bugs in the mount module on older Linux kernels and *BSDs
* Fixed bugs in the mount module on older Linux kernels and BSDs
* Various minor fixes for Python 3
* Inserted some checks for jinja2-2.9, which can cause some issues with Ansible currently.
<a id="2.2"></a>
## 2.2 "The Battle of Evermore" - 2016-11-01
@ -655,12 +831,16 @@ Notice given that the following will be removed in Ansible 2.4:
* nxos_template
* ops_template
<a id="2.1.4"></a>
## 2.1.4 "The Song Remains the Same" - 2017-01-16
* Security fix for CVE-2016-9587 - An attacker with control over a client system being managed by Ansible and the ability to send facts back to the Ansible server could use this flaw to execute arbitrary code on the Ansible server as the user and group Ansible is running as.
* Fixed a bug with conditionals in loops, where undefined variables and other errors will defer raising the error until the conditional has been evaluated.
* Added a version check for jinja2-2.9, which does not fully work with Ansible currently.
<a id="2.1.3"></a>
## 2.1.3 "The Song Remains the Same" - 2016-11-04
* Security fix for CVE-2016-8628 - Command injection by compromised server via fact variables. In some situations, facts returned by modules could overwrite connection-based facts or some other special variables, leading to injected commands running on the Ansible controller as the user running Ansible (or via escalated permissions).
@ -673,11 +853,13 @@ Notice given that the following will be removed in Ansible 2.4:
login_password as no_log so the password is obscured when logging.
* Fixed several bugs related to locating files relative to role/playbook directories.
* Fixed a bug in the way hosts were tested for failed states, resulting in incorrectly skipped block sessions.
* Fixed a bug in the way our custom JSON encoder is used for the to_json* filters.
* Fixed a bug in the way our custom JSON encoder is used for the `to_json*` filters.
* Fixed some bugs related to the use of non-ascii characters in become passwords.
* Fixed a bug with Azure modules which may be using the latest rc6 library.
* Backported some docker_common fixes.
<a id="2.1.2"></a>
## 2.1.2 "The Song Remains the Same" - 2016-09-29
### Minor Changes
@ -740,6 +922,8 @@ Module fixes:
Use `_fixup_perms2` if support for previous releases is not required.
Otherwise use `_fixup_perms` with `recursive=False`.
<a id="2.1"></a>
## 2.1 "The Song Remains the Same"
###Major Changes:
@ -927,6 +1111,8 @@ Module fixes:
completely in 2.3, after which time it will be an error.
* play_hosts magic variable, use ansible_play_batch or ansible_play_hosts instead.
<a id="2.0.2"></a>
## 2.0.2 "Over the Hills and Far Away"
* Backport of the 2.1 feature to ensure per-item callbacks are sent as they occur,
@ -968,10 +1154,12 @@ Module fixes:
permissions on the temporary file too leniently on a temporary file that was
executed as a script. Addresses CVE-2016-3096
* Fix a bug in the uri module where setting headers via module params that
start with HEADER_ were causing a traceback.
start with `HEADER_` were causing a traceback.
* Fix bug in the free strategy that was causing it to synchronize its workers
after every task (making it a lot more like linear than it should have been).
<a id="2.0.1"></a>
## 2.0.1 "Over the Hills and Far Away"
* Fixes a major compatibility break in the synchronize module shipped with
@ -1013,6 +1201,8 @@ Module fixes:
this might cause an error if settings environment on play depending on 'ansible_env'
which was previouslly ignored
<a id="2.0"></a>
## 2.0 "Over the Hills and Far Away" - Jan 12, 2016
###Major Changes:

View file

@ -2,6 +2,8 @@ prune ticket_stubs
prune hacking
include README.md COPYING
include requirements.txt
include .coveragerc
include .yamllint
include examples/hosts
include examples/ansible.cfg
include lib/ansible/module_utils/powershell.ps1

View file

@ -92,6 +92,10 @@ RPMRELEASE = $(RELEASE)
ifneq ($(OFFICIAL),yes)
RPMRELEASE = 100.git$(DATE)$(GITINFO)
endif
ifeq ($(PUBLISH),nightly)
# https://fedoraproject.org/wiki/Packaging:Versioning#Snapshots
RPMRELEASE = $(RELEASE).$(DATE)git.$(GIT_HASH)
endif
RPMNVR = "$(NAME)-$(VERSION)-$(RPMRELEASE)$(RPMDIST)"
# MOCK build parameters
@ -193,17 +197,17 @@ sdist_upload: clean docs
rpmcommon: $(MANPAGES) sdist
@mkdir -p rpm-build
@cp dist/*.gz rpm-build/
@sed -e 's#^Version:.*#Version: $(VERSION)#' -e 's#^Release:.*#Release: $(RPMRELEASE)%{?dist}#' $(RPMSPEC) >rpm-build/$(NAME).spec
@sed -e 's#^Version:.*#Version: $(VERSION)#' -e 's#^Release:.*#Release: $(RPMRELEASE)%{?dist}$(REPOTAG)#' $(RPMSPEC) >rpm-build/$(NAME).spec
mock-srpm: /etc/mock/$(MOCK_CFG).cfg rpmcommon
$(MOCK_BIN) -r $(MOCK_CFG) --resultdir rpm-build/ --buildsrpm --spec rpm-build/$(NAME).spec --sources rpm-build/
$(MOCK_BIN) -r $(MOCK_CFG) $(MOCK_ARGS) --resultdir rpm-build/ --buildsrpm --spec rpm-build/$(NAME).spec --sources rpm-build/
@echo "#############################################"
@echo "Ansible SRPM is built:"
@echo rpm-build/*.src.rpm
@echo "#############################################"
mock-rpm: /etc/mock/$(MOCK_CFG).cfg mock-srpm
$(MOCK_BIN) -r $(MOCK_CFG) --resultdir rpm-build/ --rebuild rpm-build/$(NAME)-*.src.rpm
$(MOCK_BIN) -r $(MOCK_CFG) $(MOCK_ARGS) --resultdir rpm-build/ --rebuild rpm-build/$(NAME)-*.src.rpm
@echo "#############################################"
@echo "Ansible RPM is built:"
@echo rpm-build/*.noarch.rpm
@ -303,3 +307,7 @@ webdocs:
docs: $(MANPAGES)
alldocs: docs webdocs
version:
@echo $(VERSION)

View file

@ -1,81 +1,88 @@
Ansible Releases at a Glance
============================
For more info http://docs.ansible.com/ansible/dev_guide/developing_releases.html
Active Development
++++++++++++++++++
2.3 TBD - in progress
2.2 "The Battle of Evermore" - maintenance
Released
++++++++
2.2.0 "The Battle of Evermore" 11-01-2016
2.1.3 "The Song Remains the Same" 11-04-2016
2.1.2 "The Song Remains the Same" 10-29-2016
2.1.1 "The Song Remains the Same" 07-28-2016
2.1.0 "The Song Remains the Same" 05-25-2016
2.0.2 "Over the Hills and Far Away" 04-19-2016
2.0.1 "Over the Hills and Far Away" 02-24-2016
2.0.0 "Over the Hills and Far Away" 01-12-2016
1.9.6 "Dancing In the Streets" 04-15-2016
1.9.5 "Dancing In the Streets" 03-21-2016
1.9.4 "Dancing In the Streets" 10-09-2015
1.9.3 "Dancing In the Streets" 09-03-2015
1.9.2 "Dancing In the Streets" 06-24-2015
1.9.1 "Dancing In the Streets" 04-27-2015
1.9.0 "Dancing In the Streets" 03-25-2015
1.8.4 "You Really Got Me" ---- 02-19-2015
1.8.3 "You Really Got Me" ---- 02-17-2015
1.8.2 "You Really Got Me" ---- 12-04-2014
1.8.1 "You Really Got Me" ---- 11-26-2014
1.7.2 "Summer Nights" -------- 09-24-2014
1.7.1 "Summer Nights" -------- 08-14-2014
1.7 "Summer Nights" -------- 08-06-2014
1.6.10 "The Cradle Will Rock" - 07-25-2014
1.6.9 "The Cradle Will Rock" - 07-24-2014
1.6.8 "The Cradle Will Rock" - 07-22-2014
1.6.7 "The Cradle Will Rock" - 07-21-2014
1.6.6 "The Cradle Will Rock" - 07-01-2014
1.6.5 "The Cradle Will Rock" - 06-25-2014
1.6.4 "The Cradle Will Rock" - 06-25-2014
1.6.3 "The Cradle Will Rock" - 06-09-2014
1.6.2 "The Cradle Will Rock" - 05-23-2014
1.6.1 "The Cradle Will Rock" - 05-07-2014
1.6 "The Cradle Will Rock" - 05-05-2014
1.5.5 "Love Walks In" -------- 04-18-2014
1.5.4 "Love Walks In" -------- 04-01-2014
1.5.3 "Love Walks In" -------- 03-13-2014
1.5.2 "Love Walks In" -------- 03-11-2014
1.5.1 "Love Walks In" -------- 03-10-2014
1.5 "Love Walks In" -------- 02-28-2014
1.4.5 "Could This Be Magic?" - 02-12-2014
1.4.4 "Could This Be Magic?" - 01-06-2014
1.4.3 "Could This Be Magic?" - 12-20-2013
1.4.2 "Could This Be Magic?" - 12-18-2013
1.4.1 "Could This Be Magic?" - 11-27-2013
1.4 "Could This Be Magic?" - 11-21-2013
1.3.4 "Top of the World" ----- 10-29-2013
1.3.3 "Top of the World" ----- 10-09-2013
1.3.2 "Top of the World" ----- 09-19-2013
1.3.1 "Top of the World" ----- 09-16-2013
1.3 "Top of the World" ----- 09-13-2013
1.2.3 "Hear About It Later" -- 08-21-2013
1.2.2 "Hear About It Later" -- 07-05-2013
1.2.1 "Hear About It Later" -- 07-04-2013
1.2 "Right Now" ------------ 06-10-2013
1.1 "Mean Street" ---------- 04-02-2013
1.0 "Eruption" ------------- 02-01-2013
0.9 "Dreams" --------------- 11-30-2012
0.8 "Cathedral" ------------ 10-19-2012
0.7 "Panama" --------------- 09-06-2012
0.6 "Cabo" ----------------- 08-06-2012
0.5 "Amsterdam" ------------ 07-04-2012
0.4 "Unchained" ------------ 05-23-2012
0.3 "Baluchitherium" ------- 04-23-2012
0.0.2 Untitled
0.0.1 Untitled
VERSION RELEASE CODE NAME
++++++++++++++++++++++++++++++
2.5.0 TBD "Kashmir"
2.4.2 11-29-2017 "Dancing Days"
2.4.1 10-25-2017 "Dancing Days"
2.4.0 09-19-2017 "Dancing Days"
2.3.3 12-20-2017 "Ramble On"
2.3.2 08-04-2017 "Ramble On"
2.3.1 06-01-2017 "Ramble On"
2.3.0 04-12-2017 "Ramble On"
2.2.3 05-09-2017 "The Battle of Evermore"
2.2.2 03-27-2017 "The Battle of Evermore"
2.2.1 01-16-2017 "The Battle of Evermore"
2.2.0 11-01-2016 "The Battle of Evermore"
2.1.6 06-01-2017 "The Song Remains the Same"
2.1.5 03-27-2017 "The Song Remains the Same"
2.1.4 01-16-2017 "The Song Remains the Same"
2.1.3 11-04-2016 "The Song Remains the Same"
2.1.2 09-29-2016 "The Song Remains the Same"
2.1.1 07-28-2016 "The Song Remains the Same"
2.1.0 05-25-2016 "The Song Remains the Same"
2.0.2 04-19-2016 "Over the Hills and Far Away"
2.0.1 02-24-2016 "Over the Hills and Far Away"
2.0.0 01-12-2016 "Over the Hills and Far Away"
1.9.6 04-15-2016 "Dancing In the Streets"
1.9.5 03-21-2016 "Dancing In the Streets"
1.9.4 10-09-2015 "Dancing In the Streets"
1.9.3 09-03-2015 "Dancing In the Streets"
1.9.2 06-24-2015 "Dancing In the Streets"
1.9.1 04-27-2015 "Dancing In the Streets"
1.9.0 03-25-2015 "Dancing In the Streets"
1.8.4 02-19-2015 "You Really Got Me"
1.8.3 02-17-2015 "You Really Got Me"
1.8.2 12-04-2014 "You Really Got Me"
1.8.1 11-26-2014 "You Really Got Me"
1.8.0 11-25-2014 "You Really Got Me"
1.7.2 09-24-2014 "Summer Nights"
1.7.1 08-14-2014 "Summer Nights"
1.7.0 08-06-2014 "Summer Nights"
1.6.10 07-25-2014 "The Cradle Will Rock"
1.6.9 07-24-2014 "The Cradle Will Rock"
1.6.8 07-22-2014 "The Cradle Will Rock"
1.6.7 07-21-2014 "The Cradle Will Rock"
1.6.6 07-01-2014 "The Cradle Will Rock"
1.6.5 06-25-2014 "The Cradle Will Rock"
1.6.4 06-25-2014 "The Cradle Will Rock"
1.6.3 06-09-2014 "The Cradle Will Rock"
1.6.2 05-23-2014 "The Cradle Will Rock"
1.6.1 05-07-2014 "The Cradle Will Rock"
1.6.0 05-05-2014 "The Cradle Will Rock"
1.5.5 04-18-2014 "Love Walks In"
1.5.4 04-01-2014 "Love Walks In"
1.5.3 03-13-2014 "Love Walks In"
1.5.2 03-11-2014 "Love Walks In"
1.5.1 03-10-2014 "Love Walks In"
1.5.0 02-28-2014 "Love Walks In"
1.4.5 02-12-2014 "Could This Be Magic?"
1.4.4 01-06-2014 "Could This Be Magic?"
1.4.3 12-20-2013 "Could This Be Magic?"
1.4.2 12-18-2013 "Could This Be Magic?"
1.4.1 11-27-2013 "Could This Be Magic?"
1.4.0 11-21-2013 "Could This Be Magic?"
1.3.4 10-29-2013 "Top of the World"
1.3.3 10-09-2013 "Top of the World"
1.3.2 09-19-2013 "Top of the World"
1.3.1 09-16-2013 "Top of the World"
1.3.0 09-13-2013 "Top of the World"
1.2.3 08-21-2013 "Right Now"
1.2.2 07-05-2013 "Right Now"
1.2.1 07-04-2013 "Right Now"
1.2.0 06-10-2013 "Right Now"
1.1.0 04-02-2013 "Mean Street"
1.0.0 02-01-2013 "Eruption"
0.9.0 11-30-2012 "Dreams"
0.8.0 10-19-2012 "Cathedral"
0.7.0 09-06-2012 "Panama"
0.6.0 08-06-2012 "Cabo"
0.5.0 07-04-2012 "Amsterdam"
0.4.0 05-23-2012 "Unchained"
0.3.0 04-23-2012 "Baluchitherium"
0.2.0 ? "Untitled"
0.1.0 ? "Untitled"
0.0.2 ? "Untitled"
0.0.1 ? "Untitled"

View file

@ -9,7 +9,7 @@ The roadmap will be updated by version. Based on team and community feedback, an
These roadmaps are the team's *best guess* roadmaps based on the Ansible team's experience and are also based on requests and feedback from the community. There are things that may not make it on due to time constraints, lack of community maintainers, etc. And there may be things that got missed, so each roadmap is published both as an idea of what is upcoming in Ansible, and as a medium for seeking further feedback from the community. Here are the good places for you to submit feedback:
- Add to the agenda of a `Core IRC Meetings <https://github.com/ansible/community/blob/master/MEETINGS.md>`_ (preferred)
- Add to the agenda of a `Core IRC Meetings <https://github.com/ansible/community/blob/master/meetings/README.md>`_ (preferred)
- Ansible's google-group: ansible-devel
- AnsibleFest conferences.
- IRC freenode channel: #ansible-devel (this one may have things lost in lots of conversation, so a caution).

View file

@ -1 +1 @@
2.3.0 0.0.devel
2.3.4.0 0.1.rc1

View file

@ -39,6 +39,7 @@ import time
import traceback
import syslog
import datetime
import logging
from io import BytesIO
@ -62,7 +63,7 @@ def do_fork():
if pid > 0:
return pid
os.chdir("/")
#os.chdir("/")
os.setsid()
os.umask(0)
@ -109,25 +110,34 @@ def recv_data(s):
data += d
return data
class Server():
def __init__(self, path, play_context):
display.vvvv("starting new persistent socket with path %s" % path, play_context.remote_addr)
self.path = path
self.play_context = play_context
display.display(
'creating new control socket for host %s:%s as user %s' %
(play_context.remote_addr, play_context.port, play_context.remote_user),
log_only=True
)
display.display('control socket path is %s' % path, log_only=True)
display.display('current working directory is %s' % os.getcwd(), log_only=True)
self._start_time = datetime.datetime.now()
display.vvv("using connection plugin %s" % self.play_context.connection, play_context.remote_addr)
display.display("using connection plugin %s" % self.play_context.connection, log_only=True)
self.conn = connection_loader.get(play_context.connection, play_context, sys.stdin)
self.conn._connect()
if not self.conn.connected:
raise AnsibleConnectionFailure('unable to connect to remote host')
raise AnsibleConnectionFailure('unable to connect to remote host %s' % self._play_context.remote_addr)
connection_time = datetime.datetime.now() - self._start_time
display.vvvv('connection established in %s' % connection_time, play_context.remote_addr)
display.display('connection established to %s in %s' % (play_context.remote_addr, connection_time), log_only=True)
self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
self.socket.bind(path)
@ -165,7 +175,7 @@ class Server():
signal.alarm(C.PERSISTENT_CONNECT_TIMEOUT)
try:
(s, addr) = self.socket.accept()
display.vvvv('incoming request accepted on persistent socket', self.play_context.remote_addr)
display.display('incoming request accepted on persistent socket', log_only=True)
# clear the alarm
# FIXME: potential race condition here between the accept and
# time to this call.
@ -177,14 +187,13 @@ class Server():
data = recv_data(s)
if not data:
break
display.vvvv("received data on socket with len %s" % len(data), self.play_context.remote_addr)
signal.alarm(C.DEFAULT_TIMEOUT)
signal.alarm(self.play_context.timeout)
rc = 255
try:
if data.startswith(b'EXEC: '):
display.vvvv("socket operation is EXEC", self.play_context.remote_addr)
display.display("socket operation is EXEC", log_only=True)
cmd = data.split(b'EXEC: ')[1]
(rc, stdout, stderr) = self.conn.exec_command(cmd)
elif data.startswith(b'PUT: ') or data.startswith(b'FETCH: '):
@ -192,16 +201,16 @@ class Server():
stdout = stderr = ''
try:
if op == 'FETCH:':
display.vvvv("socket operation is FETCH", self.play_context.remote_addr)
display.display("socket operation is FETCH", log_only=True)
self.conn.fetch_file(src, dst)
elif op == 'PUT:':
display.vvvv("socket operation is PUT", self.play_context.remote_addr)
display.display("socket operation is PUT", log_only=True)
self.conn.put_file(src, dst)
rc = 0
except:
pass
elif data.startswith(b'CONTEXT: '):
display.vvvv("socket operation is CONTEXT", self.play_context.remote_addr)
display.display("socket operation is CONTEXT", log_only=True)
pc_data = data.split(b'CONTEXT: ')[1]
src = StringIO(pc_data)
@ -214,7 +223,7 @@ class Server():
self.dispatch(self.conn, 'update_play_context', pc)
continue
else:
display.vvvv("socket operation is UNKNOWN", self.play_context.remote_addr)
display.display("socket operation is UNKNOWN", log_only=True)
stdout = ''
stderr = 'Invalid action specified'
except:
@ -223,20 +232,20 @@ class Server():
signal.alarm(0)
display.vvvv("socket operation completed with rc %s" % rc, self.play_context.remote_addr)
display.display("socket operation completed with rc %s" % rc, log_only=True)
send_data(s, to_bytes(str(rc)))
send_data(s, to_bytes(stdout))
send_data(s, to_bytes(stderr))
s.close()
except Exception as e:
display.vvvv(traceback.format_exc())
display.display(traceback.format_exec(), log_only=True)
finally:
# when done, close the connection properly and cleanup
# the socket file so it can be recreated
end_time = datetime.datetime.now()
delta = end_time - self._start_time
display.v('shutting down control socket, connection was active for %s secs' % delta, self.play_context.remote_addr)
display.display('shutting down control socket, connection was active for %s secs' % delta, log_only=True)
try:
self.conn.close()
self.socket.close()
@ -268,8 +277,6 @@ def main():
sys.stderr.write(traceback.format_exc())
sys.exit("FAIL: %s" % e)
display.verbosity = pc.verbosity
ssh = connection_loader.get('ssh', class_only=True)
m = ssh._create_control_path(pc.remote_addr, pc.port, pc.remote_user)
@ -290,16 +297,20 @@ def main():
try:
server = Server(sf_path, pc)
except AnsibleConnectionFailure as exc:
display.vvv(str(exc), pc.remote_addr)
display.display('connecting to host %s returned an error' % pc.remote_addr, log_only=True)
display.display(str(exc), log_only=True)
rc = 1
except Exception as exc:
display.vvv(traceback.format_exc(), pc.remote_addr)
display.display('failed to create control socket for host %s' % pc.remote_addr, log_only=True)
display.display(traceback.format_exc(), log_only=True)
rc = 1
fcntl.lockf(lock_fd, fcntl.LOCK_UN)
os.close(lock_fd)
if rc == 0:
server.run()
sys.exit(rc)
else:
display.display('re-using existing socket for %s@%s:%s' % (pc.remote_user, pc.remote_addr, pc.port), log_only=True)
fcntl.lockf(lock_fd, fcntl.LOCK_UN)
os.close(lock_fd)
@ -324,8 +335,8 @@ def main():
time.sleep(C.PERSISTENT_CONNECT_INTERVAL)
attempts += 1
if attempts > C.PERSISTENT_CONNECT_RETRIES:
display.vvvv('number of connection attempts exceeded, unable to connect to control socket')
display.vvvv('persistent_connect_interval=%s, persistent_connect_retries=%s' % (C.PERSISTENT_CONNECT_INTERVAL, C.PERSISTENT_CONNECT_RETRIES))
display.display('number of connection attempts exceeded, unable to connect to control socket', pc.remote_addr, pc.remote_user, log_only=True)
display.display('persistent_connect_interval=%s, persistent_connect_retries=%s' % (C.PERSISTENT_CONNECT_INTERVAL, C.PERSISTENT_CONNECT_RETRIES), pc.remote_addr, pc.remote_user, log_only=True)
sys.stderr.write('failed to connect to control socket')
sys.exit(255)

View file

@ -138,9 +138,13 @@ import sys
import re
import argparse
from time import time
import ConfigParser
import ast
try:
import ConfigParser
except ImportError:
import configparser as ConfigParser
try:
import json
except ImportError:

View file

@ -525,7 +525,7 @@ class AnsibleDockerClient(Client):
msg = "You asked for verification that Docker host name matches %s. The actual hostname is %s. " \
"Most likely you need to set DOCKER_TLS_HOSTNAME or pass tls_hostname with a value of %s. " \
"You may also use TLS without verification by setting the tls parameter to true." \
% (self.auth_params['tls_hostname'], match.group(1))
% (self.auth_params['tls_hostname'], match.group(1), match.group(1))
self.fail(msg)
self.fail("SSL Exception: %s" % (error))

View file

@ -94,7 +94,6 @@ elif options.host:
if len(details) > 0:
#pass through the port, in case it's non standard.
result = details[0]
result
print(json.dumps(result))
sys.exit(1)

View file

@ -197,7 +197,7 @@ class LinodeInventory(object):
try:
return Linode.find(api_id=linode_id)
except chube_api.linode_api.ApiError as e:
sys.exit("Looks like Linode's API is down:\n%" % e)
sys.exit("Looks like Linode's API is down:\n%s" % e)
def populate_datacenter_cache(self):
"""Creates self._datacenter_cache, containing all Datacenters indexed by ID."""

View file

@ -121,6 +121,7 @@ def get_host_groups(inventory, refresh=False):
def append_hostvars(hostvars, groups, key, server, namegroup=False):
hostvars[key] = dict(
ansible_ssh_host=server['interface_ip'],
ansible_host=server['interface_ip'],
openstack=server)
for group in get_groups_from_server(server, namegroup=namegroup):
groups[group].append(key)

View file

@ -14,6 +14,8 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src="//www.redhat.com/dtm.js"></script>
<!-- Google Tag Manager Data Layer -->
<script>
dataLayer = [];
@ -149,18 +151,23 @@
<div class="wy-grid-for-nav">
{# SIDE NAV, TOGGLES ON MOBILE #}
{# SIDE NAV TOGGLES ON MOBILE #}
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div style="background-color:#5bbdbf;height=80px;margin:'auto auto auto auto'">
<a class="DocSiteProduct-header DocSiteProduct-header--core"
href="http://docs.ansible.com/ansible/">
<div class="DocSiteProduct-productName">
<div class="DocSiteProduct-logoText">
ANSIBLE
<a class="DocSiteProduct-header DocSiteProduct-header--core" href="http://docs.ansible.com">
<div class="DocSiteProduct-productName">
<div class="DocSiteProduct-logoText">
Ansible Core
<div class="DocSiteProduct-CurrentVersion" align="right">
v2.3
</div>
</div>
</div>
</div>
</a>
<div class="DocSiteProduct-CheckVersionPara">For previous versions, see the <a class="DocSiteProduct-versionheader" href="http://docs.ansible.com/">documentation archive.</a></div>
</div>
<div id="menu-id" class="wy-menu wy-menu-vertical" data-spy="affix">
@ -246,6 +253,10 @@ _hsq.push(["setContentType", "standard-page"]);
})(document, "script", "hs-analytics",300000);
</script>
<!-- end analytics -->
<script type="text/javascript">
if (("undefined" !== typeof _satellite) && ("function" === typeof _satellite.pageBottom)) {
_satellite.pageBottom();
}
</script>
</body>
</html>

View file

@ -4715,6 +4715,13 @@ span[id*='MathJax-Span'] {
font-size: 20px;
}
.DocSiteProduct-CheckVersionPara {
padding-bottom: 20px;
margin-left: 10px;
margin-right: 10px;
}
.wy-menu-vertical a {
padding: 0;
}

View file

@ -29,8 +29,8 @@ We recommend using Google search to see if a topic has been answered recently, b
Before you post, be sure you are running the latest stable version of Ansible. You can check this by comparing the output of ``ansible --version`` with the version indicated on `PyPi <https://pypi.python.org/pypi/ansible>`_.
Alternatively, you can also join our IRC channel - #ansible on irc.freenode.net. It's a very high traffic channel as well, if you don't get an answer you like, please stop by our mailing list, which is more likely
to get attention of core developers since it's asynchronous.
Alternatively, you can also join our IRC channel - ``#ansible`` on irc.freenode.net. It's a very high traffic channel as well, so if you don't get an answer you like, please stop by our mailing list, which is more likely
to get the attention of core developers since it's asynchronous.
I'd Like To Keep Up With Release Announcements
----------------------------------------------
@ -102,7 +102,9 @@ documenting a new feature, submit a GitHub pull request to the code that
lives in the ``docsite/rst`` subdirectory of the project for most pages, and there is an "Edit on GitHub"
link up on those.
Module documentation is generated from a DOCUMENTATION structure embedded in the source code of each module, which is in `/lib/ansible/modules/ <https://github.com/ansible/ansible/tree/devel/lib/ansible/modules/>`_.
Module documentation is generated from a ``DOCUMENTATION`` structure embedded in the source code of each module, which is in `/lib/ansible/modules/ <https://github.com/ansible/ansible/tree/devel/lib/ansible/modules/>`_.
For more information on module documentation see `How to document modules <http://docs.ansible.com/ansible/dev_guide/developing_modules_documenting.html>`_.
Aside from modules, the main docs are in restructured text
format.
@ -110,7 +112,7 @@ format.
If you arent comfortable with restructured text, you can also open a ticket on
GitHub about any errors you spot or sections you would like to see added. For more information
on creating pull requests, please refer to the
`github help guide <https://help.github.com/articles/using-pull-requests>`_.
`GitHub help guide <https://help.github.com/articles/using-pull-requests>`_.
For Current and Prospective Developers
=======================================
@ -141,14 +143,9 @@ Note that we do keep Ansible to a particular aesthetic, so if you are unclear ab
is a good fit or not, having the discussion on the development list is often a lot easier than having
to modify a pull request later.
New module developers should read through `developing modules <http://docs.ansible.com/ansible/dev_guide/developing_modules.html>`_ for helpful pointers
and information about running adhoc tests `testing modules <http://docs.ansible.com/ansible/dev_guide/developing_modules.html#testing-modules>`_.
New module developers should read through `developing modules <http://docs.ansible.com/ansible/dev_guide/developing_modules.html>`_.
When submitting patches, be sure to run the unit tests first ``make tests`` and always use, these are the same basic
tests that will automatically run on Shippable when creating the PR. There are more in depth tests in the ``tests/integration``
directory, classified as destructive and non_destructive, run these if they pertain to your modification. They are set up
with tags so you can run subsets, some of the tests require cloud credentials and will only run if they are provided.
When adding new features or fixing bugs it would be nice to add new tests to avoid regressions. For more information about testing see `test/README.md <https://github.com/ansible/ansible/blob/devel/test/README.md>`_.
For more information about testing see `testing <http://docs.ansible.com/ansible/dev_guide/testing.html>`_.
In order to keep the history clean and better audit incoming code, we will require resubmission of pull requests that
contain merge commits. Use ``git pull --rebase`` (rather than ``git pull``) and ``git rebase`` (rather than ``git merge``). Also be sure to use topic
@ -174,11 +171,15 @@ Contributions can be for new features like modules, or to fix bugs you or others
are interested in writing new modules to be included in the core Ansible distribution, please refer
to the `module development documentation <http://docs.ansible.com/developing_modules.html>`_.
Ansible's aesthetic encourages simple, readable code and consistent, conservatively extending,
backwards-compatible improvements. Code developed for Ansible needs to support Python 2.6+,
while code in modules must run under Python 2.4 or higher. Please also use a 4-space indent
and no tabs, we do not enforce 80 column lines, we are fine with 120-140. We do not take 'style only'
requests unless the code is nearly unreadable, we are "PEP8ish", but not strictly compliant.
Ansible's aesthetic encourages simple, readable code and consistent,
conservatively extending, backwards-compatible improvements. When contributing code to Ansible,
please observe the following guidelines:
- Code developed for Ansible needs to support Python2-2.6 or higher and Python3-3.5 or higher.
- Use a 4-space indent, not tabs.
- We do not enforce 80 column lines; up to 160 columns are acceptable.
- We do not accept 'style only' pull requests unless the code is nearly unreadable.
- We are "PEP8ish", but not strictly compliant, see :doc:`testing_pep8` for more information.
You can also contribute by testing and revising other requests, especially if it is one you are interested
in using. Please keep your comments clear and to the point, courteous and constructive, tickets are not a
@ -228,7 +229,7 @@ IRC Meetings
------------
The Ansible community holds regular IRC meetings on various topics, and anyone who is interested is invited to
participate. For more information about Ansible meetings, consult the `meeting schedule and agenda page <https://github.com/ansible/community/blob/master/MEETINGS.md>`_.
participate. For more information about Ansible meetings, consult the `meeting schedule and agenda page <https://github.com/ansible/community/blob/master/meetings/README.md>`_.
Release Numbering
-----------------
@ -256,42 +257,39 @@ IRC Channel
Ansible has several IRC channels on Freenode (irc.freenode.net):
- #ansible - For general use questions and support.
- #ansible-devel - For discussions on developer topics and code related to features/bugs.
- #ansible-meeting - For public community meetings. We will generally announce these on one or more of the above mailing lists. See the `meeting schedule and agenda page <https://github.com/ansible/community/blob/master/MEETINGS.md>`_
- #ansible-notices - Mostly bot output from things like Github, etc.
- ``#ansible`` - For general use questions and support.
- ``#ansible-devel`` - For discussions on developer topics and code related to features/bugs.
- ``#ansible-aws`` - For discussions on Amazon Web Services.
- ``#ansible-container`` - For discussions on Ansible Container.
- ``#ansible-vmware`` - For discussions on Ansible & VMware.
- ``#ansible-windows`` - For discussions on Ansible & Windows.
- ``#ansible-meeting`` - For public community meetings. We will generally announce these on one or more of the above mailing lists. See the `meeting schedule and agenda page <https://github.com/ansible/community/blob/master/meetings/README.md>`_
- ``#ansible-notices`` - Mostly bot output from things like Github, etc.
Notes on Priority Flags
-----------------------
Ansible was one of the top 5 projects with the most OSS contributors on GitHub in 2013, and has over 1400 contributors
to the project to date, not to mention a very large user community that has downloaded the application well over a million
times.
As a result, we have a LOT of incoming activity to process.
times. As a result, we have a LOT of incoming activity to process.
In the interest of transparency, we're telling you how we sort incoming requests.
In our bug tracker you'll notice some labels - P1, P2, P3, P4, and P5. These are our internal
In our bug tracker you'll notice some labels - P1 and P2. These are the internal
priority orders that we use to sort tickets.
With some exceptions for easy merges (like documentation typos for instance),
we're going to spend most of our time working on P1 and P2 items first, including pull requests.
These usually relate to important bugs or features affecting large segments of the userbase. So if you see something categorized
"P3 or P4", and it's not appearing to get a lot of immediate attention, this is why.
These usually relate to important bugs or features affecting large segments of the userbase. If you see something categorized without P1 or P2, and it's not appearing to get a lot of immediate attention, this is why.
These labels don't really have definition - they are a simple ordering. However something
These labels don't really have a definition - they are a simple ordering. However something
affecting a major module (yum, apt, etc) is likely to be prioritized higher than a module
affecting a smaller number of users.
Since we place a strong emphasis on testing and code review, it may take a few months for a minor feature to get merged.
Since we place a strong emphasis on testing and code review, it may take a few months for a minor feature to get merged. This doesn't mean that we'll be exhausting all of the higher-priority queues before getting to your ticket; we will also take periodic sweeps through the lower priority queues and give them some attention as well, particularly in the area of new module changes.
Don't worry though -- we'll also take periodic sweeps through the lower priority queues and give
them some attention as well, particularly in the area of new module changes. So it doesn't necessarily
mean that we'll be exhausting all of the higher-priority queues before getting to your ticket.
Every bit of effort helps - if you're wishing to expedite the inclusion of a P3 feature pull request for instance, the best thing you can do
is help close P2 bug reports.
Every bit of effort helps - if you're wishing to expedite the inclusion of a P3 feature pull request for instance, the best thing you can do is help close P2 bug reports.
Community Code of Conduct
=========================
@ -419,7 +417,7 @@ of our community members and want everyone to feel welcome at our events, both o
offline.
We expect all participants, organizers, speakers, and attendees to follow these policies at
our all of our event venues and event-related social events.
all of our event venues and event-related social events.
The Ansible Community Code of Conduct is licensed under the Creative Commons
Attribution-Share Alike 3.0 license. Our Code of Conduct was adapted from Codes of Conduct

View file

@ -0,0 +1,144 @@
*************************
Community Code of Conduct
*************************
.. contents:: Topics
Every community can be strengthened by a diverse variety of viewpoints, insights,
opinions, skillsets, and skill levels. However, with diversity comes the potential for
disagreement and miscommunication. The purpose of this Code of Conduct is to ensure that
disagreements and differences of opinion are conducted respectfully and on their own
merits, without personal attacks or other behavior that might create an unsafe or
unwelcoming environment.
These policies are not designed to be a comprehensive set of Things You Cannot Do. We ask
that you treat your fellow community members with respect and courtesy, and in general,
Don't Be A Jerk. This Code of Conduct is meant to be followed in spirit as much as in
letter and is not exhaustive.
All Ansible events and participants therein are governed by this Code of Conduct and
anti-harassment policy. We expect organizers to enforce these guidelines throughout all events,
and we expect attendees, speakers, sponsors, and volunteers to help ensure a safe
environment for our whole community. Specifically, this Code of Conduct covers
participation in all Ansible-related forums and mailing lists, code and documentation
contributions, public IRC channels, private correspondence, and public meetings.
Ansible community members are...
**Considerate**
Contributions of every kind have far-ranging consequences. Just as your work depends on
the work of others, decisions you make surrounding your contributions to the Ansible
community will affect your fellow community members. You are strongly encouraged to take
those consequences into account while making decisions.
**Patient**
Asynchronous communication can come with its own frustrations, even in the most responsive
of communities. Please remember that our community is largely built on volunteered time,
and that questions, contributions, and requests for support may take some time to receive
a response. Repeated "bumps" or "reminders" in rapid succession are not good displays of
patience. Additionally, it is considered poor manners to ping a specific person with
general questions. Pose your question to the community as a whole, and wait patiently for
a response.
**Respectful**
Every community inevitably has disagreements, but remember that it is
possible to disagree respectfully and courteously. Disagreements are never an excuse for
rudeness, hostility, threatening behavior, abuse (verbal or physical), or personal attacks.
**Kind**
Everyone should feel welcome in the Ansible community, regardless of their background.
Please be courteous, respectful and polite to fellow community members. Do not make or
post offensive comments related to skill level, gender, gender identity or expression,
sexual orientation, disability, physical appearance, body size, race, or religion.
Sexualized images or imagery, real or implied violence, intimidation, oppression,
stalking, sustained disruption of activities, publishing the personal information of
others without explicit permission to do so, unwanted physical contact, and unwelcome
sexual attention are all strictly prohibited. Additionally, you are encouraged not to
make assumptions about the background or identity of your fellow community members.
**Inquisitive**
The only stupid question is the one that does not get asked. We
encourage our users to ask early and ask often. Rather than asking whether you can ask a
question (the answer is always yes!), instead, simply ask your question. You are
encouraged to provide as many specifics as possible. Code snippets in the form of Gists or
other paste site links are almost always needed in order to get the most helpful answers.
Refrain from pasting multiple lines of code directly into the IRC channels - instead use
gist.github.com or another paste site to provide code snippets.
**Helpful**
The Ansible community is committed to being a welcoming environment for all users,
regardless of skill level. We were all beginners once upon a time, and our community
cannot grow without an environment where new users feel safe and comfortable asking questions.
It can become frustrating to answer the same questions repeatedly; however, community
members are expected to remain courteous and helpful to all users equally, regardless of
skill or knowledge level. Avoid providing responses that prioritize snideness and snark over
useful information. At the same time, everyone is expected to read the provided
documentation thoroughly. We are happy to answer questions, provide strategic guidance,
and suggest effective workflows, but we are not here to do your job for you.
Anti-harassment policy
======================
Harassment includes (but is not limited to) all of the following behaviors:
- Offensive comments related to gender (including gender expression and identity), age, sexual orientation, disability, physical appearance, body size, race, and religion
- Derogatory terminology including words commonly known to be slurs
- Posting sexualized images or imagery in public spaces
- Deliberate intimidation
- Stalking
- Posting others' personal information without explicit permission
- Sustained disruption of talks or other events
- Inappropriate physical contact
- Unwelcome sexual attention
Participants asked to stop any harassing behavior are expected to comply immediately.
Sponsors are also subject to the anti-harassment policy. In particular, sponsors should
not use sexualized images, activities, or other material. Meetup organizing staff and
other volunteer organizers should not use sexualized attire or otherwise create a
sexualized environment at community events.
In addition to the behaviors outlined above, continuing to behave a certain way after you
have been asked to stop also constitutes harassment, even if that behavior is not
specifically outlined in this policy. It is considerate and respectful to stop doing
something after you have been asked to stop, and all community members are expected to
comply with such requests immediately.
Policy violations
=================
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by
contacting `codeofconduct@ansible.com <mailto:codeofconduct@ansible.com>`_, to any channel
operator in the community IRC channels, or to the local organizers of an event. Meetup
organizers are encouraged to prominently display points of contact for reporting unacceptable
behavior at local events.
If a participant engages in harassing behavior, the meetup organizers may take any action
they deem appropriate. These actions may include but are not limited to warning the
offender, expelling the offender from the event, and barring the offender from future
community events.
Organizers will be happy to help participants contact security or local law enforcement,
provide escorts to an alternate location, or otherwise assist those experiencing
harassment to feel safe for the duration of the meetup. We value the safety and well-being
of our community members and want everyone to feel welcome at our events, both online and
offline.
We expect all participants, organizers, speakers, and attendees to follow these policies at
all of our event venues and event-related social events.
The Ansible Community Code of Conduct is licensed under the Creative Commons
Attribution-Share Alike 3.0 license. Our Code of Conduct was adapted from Codes of Conduct
of other open source projects, including:
* Contributor Covenant
* Elastic
* The Fedora Project
* OpenStack
* Puppet Labs
* Ubuntu

View file

@ -0,0 +1,68 @@
*************
Communicating
*************
.. contents:: Topics
Mailing List Information
========================
Ansible has several mailing lists. Your first post to the mailing list will be moderated (to reduce spam), so please allow up to a day or so for your first post to appear.
`Ansible Project List <https://groups.google.com/forum/#!forum/ansible-project>`_ is for sharing Ansible tips, answering questions, and general user discussion.
`Ansible Development List <https://groups.google.com/forum/#!forum/ansible-devel>`_ is for learning how to develop on Ansible, asking about prospective feature design, or discussions about extending ansible or features in progress.
`Ansible Announce list <https://groups.google.com/forum/#!forum/ansible-announce>`_ is a read-only list that shares information about new releases of Ansible, and also rare infrequent event information, such as announcements about an upcoming AnsibleFest, which is our official conference series.
`Ansible Container List <https://groups.google.com/forum/#!forum/ansible-container>`_ is for users and developers of the Ansible Container project.
`Ansible Lockdown List <https://groups.google.com/forum/#!forum/ansible-lockdown>`_ is for all things related to Ansible Lockdown projects, including DISA STIG automation and CIS Benchmarks.
To subscribe to a group from a non-Google account, you can send an email to the subscription address requesting the subscription. For example: `ansible-devel+subscribe@googlegroups.com`
IRC Channel
===========
Ansible has several IRC channels on Freenode (irc.freenode.net).
General Channels
----------------
- ``#ansible`` - For general use questions and support.
- ``#ansible-devel`` - For discussions on developer topics and code related to features/bugs.
- ``#ansible-meeting`` - For public community meetings. We will generally announce these on one or more of the above mailing lists. See the `meeting schedule and agenda page <https://github.com/ansible/community/blob/master/meetings/README.md>`_
- ``#ansible-notices`` - Mostly bot output from things like GitHub, etc.
Working Group
-------------
- ``#ansible-aws`` - For discussions on Amazon Web Services.
- ``#ansible-community`` - Channel for discussing Ansible Community related things.
- ``#ansible-container`` - For discussions on Ansible Container.
- ``#ansible-jboss`` - Channel for discussing JBoss and Ansible related things.
- ``#ansible-network`` - Channel for discussing Network and Ansible related things.
- ``#ansible-news`` - Channel for discussing Ansible Communication & News related things.
- ``#ansible-vmware`` - For discussions on Ansible & VMware.
- ``#ansible-windows`` - For discussions on Ansible & Windows.
Language specific channels
--------------------------
- ``#ansible-es`` - Channel for Spanish speaking Ansible community.
- ``#ansible-fr`` - Channel for French speaking Ansible community.
IRC Meetings
------------
The Ansible community holds regular IRC meetings on various topics, and anyone who is interested is invited to
participate. For more information about Ansible meetings, consult the `meeting schedule and agenda page <https://github.com/ansible/community/blob/master/meetings/README.md>`_.
Tower Support Questions
========================
Ansible `Tower <https://ansible.com/tower>`_ is a UI, Server, and REST endpoint for Ansible.
If you have a question about Ansible Tower, visit `Red Hat support <https://access.redhat.com/products/ansible-tower-red-hat/>`_ rather than using the IRC channel or the general project mailing list.

View file

@ -0,0 +1,113 @@
The Ansible Development Process
===============================
.. contents:: Topics
This section discusses how the Ansible development and triage process works.
Road Maps
=========
The Ansible Core team provides a road map for each upcoming release. These road maps can be found `here <http://docs.ansible.com/ansible/latest/roadmap/>`_.
Pull Requests
=============
Ansible accepts code via **pull requests** ("PRs" for short). GitHub provides a great overview of `how the pull request process works <https://help.github.com/articles/about-pull-requests/>`_ in general.
Because Ansible receives many pull requests, we use an automated process to help us through the process of reviewing and merging pull requests. That process is managed by **Ansibullbot**.
Ansibullbot
===========
Overview
--------
`Ansibullbot`_ serves many functions:
- Responds quickly to PR submitters to thank them for submitting their PR
- Identifies the community maintainer responsible for reviewing PRs for any files affected
- Tracks the current status of PRs
- Pings responsible parties to remind them of any PR actions for which they may be responsible
- Provides maintainers with the ability to move PRs through the workflow
- Identifies PRs abandoned by their submitters so that we can close them
- Identifies modules abandoned by their maintainers so that we can find new maintainers
Community Maintainers
---------------------
Each module has at least one assigned maintainer, listed in a `maintainer's file`_:
.. _Ansibullbot: https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md
.. _maintainer's file: https://github.com/ansible/ansible/blob/devel/.github/BOTMETA.yml
Some modules have no community maintainers assigned. In this case, the maintainer is listed as ``$team_ansible``. Ultimately, its our goal to have at least one community maintainer for every module.
The maintainers job is to review PRs and decide whether that PR should be merged (``shipit``) or revised (``needs_revision``).
The ultimate goal of any pull request is to reach **shipit** status, where the Core team then decides whether the PR is ready to be merged. Not every PR that reaches the **shipit** label is actually ready to be merged, but the better our reviewers are, and the better our guidelines are, the more likely it will be that a PR that reaches **shipit** will be mergeable.
Workflow
--------
Ansibullbot runs continuously. You can generally expect to see changes to your issue or pull request within thirty minutes. Ansibullbot examines every open pull request in the repositories, and enforces state roughly according to the following workflow:
- If a pull request has no workflow labels, its considered **new**. Files in the pull request are identified, and the maintainers of those files are pinged by the bot, along with instructions on how to review the pull request. (Note: sometimes we strip labels from a pull request to “reboot” this process.)
- If the module maintainer is not ``$team_ansible``, the pull request then goes into the **community_review** state.
- If the module maintainer is ``$team_ansible``, the pull request then goes into the **core_review** state (and probably sits for a while).
- If the pull request is in **community_review** and has received comments from the maintainer:
- If the maintainer says ``shipit``, the pull request is labeled **shipit**, whereupon the Core team assesses it for final merge.
- If the maintainer says ``needs_info``, the pull request is labeled **needs_info** and the submitter is asked for more info.
- If the maintainer says **needs_revision**, the pull request is labeled **needs_revision** and the submitter is asked to fix some things.
- If the submitter says ``ready_for_review``, the pull request is put back into **community_review** or **core_review** and the maintainer is notified that the pull request is ready to be reviewed again.
- If the pull request is labeled **needs_revision** or **needs_info** and the submitter has not responded lately:
- The submitter is first politely pinged after two weeks, pinged again after two more weeks and labeled **pending action**, and the issue or pull request will be closed two weeks after that.
- If the submitter responds at all, the clock is reset.
- If the pull request is labeled **community_review** and the reviewer has not responded lately:
- The reviewer is first politely pinged after two weeks, pinged again after two more weeks and labeled **pending_action**, and then may be reassigned to ``$team_ansible`` or labeled **core_review**, or often the submitter of the pull request is asked to step up as a maintainer.
- If Shippable tests fail, or if the code is not able to be merged, the pull request is automatically put into **needs_revision** along with a message to the submitter explaining why.
There are corner cases and frequent refinements, but this is the workflow in general.
PR Labels
---------
There are two types of PR Labels generally: *workflow labels* and *information labels*.
Workflow Labels
~~~~~~~~~~~~~~~
- **community_review**: Pull requests for modules that are currently awaiting review by their maintainers in the Ansible community.
- **core_review**: Pull requests for modules that are currently awaiting review by their maintainers on the Ansible Core team.
- **needs_info**: Waiting on info from the submitter.
- **needs_rebase**: Waiting on the submitter to rebase. (Note: no longer used by the bot.)
- **needs_revision**: Waiting on the submitter to make changes.
- **shipit**: Waiting for final review by the core team for potential merge.
Informational Labels
~~~~~~~~~~~~~~~~~~~~
- **backport**: this is applied automatically if the PR is requested against any branch that is not devel. The bot immediately assigns the labels backport and ``core_review``.
- **bugfix_pull_request**: applied by the bot based on the templatized description of the PR.
- **cloud**: applied by the bot based on the paths of the modified files.
- **docs_pull_request**: applied by the bot based on the templatized description of the PR.
- **easyfix**: applied manually, inconsistently used but sometimes useful.
- **feature_pull_request**: applied by the bot based on the templatized description of the PR.
- **networking**: applied by the bot based on the paths of the modified files.
- **owner_pr**: largely deprecated. Formerly workflow, now informational. Originally, PRs submitted by the maintainer would automatically go to **shipit** based on this label. If the submitter is also a maintainer, we notify the other maintainers and still require one of the maintainers (including the submitter) to give a **shipit**.
- **pending_action**: applied by the bot to PRs that are not moving. Reviewed every couple of weeks by the community team, who tries to figure out the appropriate action (closure, asking for new maintainers, etc).
Special Labels
~~~~~~~~~~~~~~
- **new_plugin**: this is for new modules or plugins that are not yet in Ansible.
**Note:** `new_plugin` kicks off a completely separate process, and frankly it doesnt work very well at present. Were working our best to improve this process.

View file

@ -0,0 +1,71 @@
How To Help
===========
.. contents:: Topics
There are many ways to help the Ansible project.
Become a power user
-------------------
A great way to help the Ansible project is to become a power user:
* Use Ansible everywhere you can
* Take tutorials and classes
* Read the `official documentation <http://docs.ansible.com/ansible/latest/index.html>`_
* Study some of the `many excellent books <https://www.amazon.com/s/ref=nb_sb_ss_c_2_7?url=search-alias%3Dstripbooks&field-keywords=ansible&sprefix=ansible%2Caps%2C260>`_ about Ansible
* `Get certified <https://www.ansible.com/training-certification>`_.
When you become a power user, your ability and opportunities to help the Ansible project in other ways will multiply quickly.
Ask and answer questions online
-------------------------------
There are many forums online where Ansible users ask and answer questions. Reach out and communicate with your fellow Ansible users.
You can find the official :ref:`Ansible communication channels <communication>`.
Participate in your local meetup
--------------------------------
There are Ansible meetups `all over the world <https://www.meetup.com/topics/ansible/>`_. Join your local meetup. Attend regularly. Ask good questions. Volunteer to give a presentation about how you use Ansible.
If there isn't a meetup near you, we'll be happy to help you `start one <https://www.ansible.com/ansible-meetup-organizer>`_.
File and verify issues
----------------------
All software has bugs, and Ansible is no exception. When you find a bug, you can help tremendously by :ref:`telling us about it <reporting_bugs_and_features>`.
If you should discover that the bug you're trying to file already exists in an issue, you can help by verifying the behavior of the reported bug with a comment in that issue, or by reporting any additional information.
Review and submit pull requests
-------------------------------
As you become more familiar with how Ansible works, you may be able to fix issues or develop new features yourself. If you think you've got a solution to a bug you've found in Ansible, or if you've got a new feature that you've written and would like to share with millions of Ansible users, read all about the `Ansible development process <http://docs.ansible.com/ansible/latest/community/development_process.rst>` to learn how to get your code accepted into Ansible.
Another good way to help is to review pull requests that other Ansible users have submitted. The Ansible community keeps a full list of `open pull requests by file <https://ansible.sivel.net/byfile.html>`_, so if there's a particular module or plug-in that particularly interests you, you can easily keep track of all the relevant new pull requests and provide testing or feedback.
Become a module maintainer
--------------------------
Once you've learned about the development process and have contributed code to a particular module, we encourage you to become a maintainer of that module. There are hundreds of different modules in Ansible, and the vast majority of them are written and maintained entirely by members of the Ansible community.
To learn more about the responsibilities of being an Ansible module maintainer, please read our :ref:`module maintainer guidelines <maintainers>`.
Join a working group
--------------------
Working groups are a way for Ansible community members to self-organize around particular topics of interest. We have working groups around various topics. To join or create a working group, please read the `Ansible working group guidelines <https://github.com/ansible/community/blob/master/WORKING-GROUPS.md>`_.
Teach Ansible to others
-----------------------
We're working on a standardized Ansible workshop called `Lightbulb <https://github.com/ansible/lightbulb>`_ that can provide a good hands-on introduction to Ansible usage and concepts.
Social media
------------
If you like Ansible and just want to spread the good word, feel free to share on your social media platform of choice, and let us know by using ``@ansible`` or ``#ansible``. We'll be looking for you.

View file

@ -0,0 +1,26 @@
*********************
Community Information
*********************
Ansible Community Guide
=======================
Welcome to the Ansible Community Guide!
The purpose of this guide is to teach you everything you need to know about being a contributing member of the Ansible community.
To get started, select one of the following topics.
.. toctree::
:maxdepth: 1
development_process
reporting_bugs_and_features
how_can_I_help
maintainers
communication
other_tools_and_programs

View file

@ -0,0 +1,71 @@
****************************
Module Maintainer Guidelines
****************************
.. contents:: Topics
Thank you for being a maintainer of one Ansible's community modules! This guide provides module maintainers an overview of their responsibilities, resources for additional information, and links to helpful tools.
In addition to the information below, module maintainers should be familiar with:
* :ref:`General Ansible community development practices <../community>`
* Documentation on :ref:`module development <developing_modules.html>`
Maintainer Responsibilities
===========================
When you contribute a new module to the `ansible/ansible <https://github.com/ansible/ansible>`_ repository, you become the maintainer for that module once it has been merged. Maintainership empowers you with the authority to accept, reject, or request revisions to pull requests on your module -- but as they say, "with great power comes great responsibility."
Maintainers of Ansible modules are expected to provide feedback, responses, or actions on pull requests or issues to the module(s) they maintain in a reasonably timely manner.
It is also recommended that you occasionally revisit the `contribution guidelines <https://github.com/ansible/ansible/blob/devel/CONTRIBUTING.md>`_, as they are continually refined. Occasionally, you may be requested to update your module to move it closer to the general accepted standard requirements. We hope for this to be infrequent, and will always be a request with a fair amount of lead time (ie: not by tomorrow!).
Finally, following the `ansible-devel <https://groups.google.com/forum/#!forum/ansible-devel>`_ mailing list can be a great way to participate in the broader Ansible community, and a place where you can influence the overall direction, quality, and goals of Ansible and its modules. If you're not on this relatively low-volume list, please join us here: https://groups.google.com/forum/#!forum/ansible-devel
The Ansible community hopes that you will find that maintaining your module is as rewarding for you as having the module is for the wider community.
Pull Requests, Issues, and Workflow
===================================
Pull Requests
-------------
Module pull requests are located in the `main Ansible repository <https://github.com/ansible/ansible/pulls>`_.
Because of the high volume of pull requests, notification of PRs to specific modules are routed by an automated bot to the appropriate maintainer for handling. It is recommended that you set an appropriate notification process to receive notifications which mention your GitHub ID.
Issues
------
Issues for modules, including bug reports, documentation bug reports, and feature requests, are tracked in the `ansible repository <https://github.com/ansible/ansible/issues>`_.
Issues for modules are routed to their maintainers via an automated process. This process is still being refined, and currently depends upon the issue creator to provide adequate details (specifically, providing the proper module name) in order to route it correctly. If you are a maintainer of a specific module, it is recommended that you periodically search module issues for issues which mention your module's name (or some variation on that name), as well as setting an appropriate notification process for receiving notification of mentions of your GitHub ID.
PR Workflow
-----------
Automated routing of pull requests is handled by a tool called `Ansibot <https://github.com/ansible/ansibullbot>`_.
Being moderately familiar with how the workflow behind the bot operates can be helpful to you, and -- should things go awry -- your feedback can be helpful to the folks that continually help Ansibullbot to evolve.
A detailed explanation of the PR workflow can be seen here: https://github.com/ansible/community/blob/master/PR-FLOW.md
Extras maintainers list
-----------------------
The full list of maintainers for modules is located here: https://github.com/ansible/ansibullbot/blob/master/MAINTAINERS.txt
Changing Maintainership
-----------------------
Communities change over time, and no one maintains a module forever. If you'd like to propose an additional maintainer for your module, please submit a PR to the maintainers file with the Github username of the new maintainer.
If you'd like to step down as a maintainer, please submit a PR to the maintainers file removing your Github ID from the module in question. If that would leave the module with no maintainers, put "ansible" as the maintainer. This will indicate that the module is temporarily without a maintainer, and the Ansible community team will search for a new maintainer.
Tools and other Resources
-------------------------
* https://ansible.sivel.net/pr/byfile.html -- a full list of all open Pull Requests, organized by file.
* Ansibullbot: https://github.com/ansible/ansibullbot
* Triage / pull request workflow and information, including definitions for Labels in GitHub: https://github.com/ansible/community/blob/master/PR-FLOW.md

View file

@ -0,0 +1,18 @@
************************
Other Tools And Programs
************************
The Ansible community provides several useful tools for working with the Ansible project. This is a list
of some of the most popular of these tools.
- `PR by File <https://ansible.sivel.net/pr/byfile.html>`_ shows a current list of all open pull requests by individual file. An essential tool for Ansible module maintainers.
- `Ansible Lint <https://github.com/willthames/ansible-lint>`_ is a widely used, highly configurable best-practices linter for Ansible playbooks.
- `Ansible Review <http://willthames.github.io/2016/06/28/announcing-ansible-review.html>`_ is an extension of Ansible Lint designed for code review.
- `jctanner's Ansible Tools <https://github.com/jctanner/ansible-tools>`_ is a miscellaneous collection of useful helper scripts for Ansible development.
- `Ansigenome <https://github.com/nickjj/ansigenome>`_ is a command line tool designed to help you manage your Ansible roles.
- `Awesome Ansible <https://github.com/jdauphant/awesome-ansible>`_ is a collaboratively curated list of awesome Ansible resources.

View file

@ -0,0 +1,35 @@
**************************************
Reporting Bugs And Requesting Features
**************************************
.. contents:: Topics
Reporting A Bug
===============
Ansible practices responsible disclosure - if this is a security related bug, email `security@ansible.com <mailto:security@ansible.com>`_ instead of filing a ticket or posting to the Google Group and you will receive a prompt response.
Ansible bugs should be reported to `github.com/ansible/ansible/issues <https://github.com/ansible/ansible/issues>`_ after
signing up for a free GitHub account. Before reporting a bug, please use the bug/issue search
to see if the issue has already been reported. This is listed on the bottom of the docs page for any module.
Knowing your Ansible version and the exact commands you are running, and what you expect, saves time and helps us help everyone with their issues more quickly. For that reason, we provide an issue template; please fill it out as completely and as accurately as possible.
Do not use the issue tracker for "how do I do this" type questions. These are great candidates for IRC or the mailing list instead where things are likely to be more of a discussion.
To be respectful of reviewers' time and allow us to help everyone efficiently, please provide minimal well-reduced and well-commented examples versus sharing your entire production playbook. Include playbook snippets and output where possible.
When sharing YAML in playbooks, formatting can be preserved by using `code blocks <https://help.github.com/articles/creating-and-highlighting-code-blocks/>`_.
For multiple-file content, we encourage use of gist.github.com. Online pastebin content can expire, so it's nice to have things around for a longer term if they are referenced in a ticket.
If you are not sure if something is a bug yet, you are welcome to ask about something on the mailing list or IRC first.
As we are a very high volume project, if you determine that you do have a bug, please be sure to open the issue yourself to ensure we have a record of it. Dont rely on someone else in the community to file the bug report for you.
Requesting a feature
====================
The best way to get a feature into Ansible is to submit a pull request.
The next best way of getting a feature into Ansible is to submit a proposal through the `Ansible proposal process <https://github.com/ansible/proposals>` .

View file

@ -0,0 +1,8 @@
**************
Triage Process
**************
The issue and PR triage processes are driven by the `Ansibot <https://github.com/ansible/ansibullbot>`. Whenever an issue or PR is filed, the Ansibot examines the issue to ensure that all relevant data is present, and handles the routing of the issue as it works its way to eventual completion.
For details on how Ansibot manages the triage process, please consult the `Ansibot
Issue Guide <https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md>`.

View file

@ -19,22 +19,22 @@ Script Conventions
When the external node script is called with the single argument ``--list``, the script must output a JSON encoded hash/dictionary of all the groups to be managed to stdout. Each group's value should be either a hash/dictionary containing a list of each host/IP, potential child groups, and potential group variables, or simply a list of host/IP addresses, like so::
{
"databases" : {
"hosts" : [ "host1.example.com", "host2.example.com" ],
"vars" : {
"a" : true
"databases": {
"hosts": ["host1.example.com", "host2.example.com"],
"vars": {
"a": true
}
},
"webservers" : [ "host2.example.com", "host3.example.com" ],
"atlanta" : {
"hosts" : [ "host1.example.com", "host4.example.com", "host5.example.com" ],
"vars" : {
"b" : false
"webservers": ["host2.example.com", "host3.example.com"],
"atlanta": {
"hosts": ["host1.example.com", "host4.example.com", "host5.example.com"],
"vars": {
"b": false
},
"children": [ "marietta", "5points" ]
"children": ["marietta", "5points"]
},
"marietta" : [ "host6.example.com" ],
"5points" : [ "host7.example.com" ]
"marietta": ["host6.example.com"],
"5points": ["host7.example.com"]
}
.. versionadded:: 1.0
@ -46,9 +46,9 @@ hash/dictionary, or a hash/dictionary of variables to make available to template
if the script does not wish to do this, printing an empty hash/dictionary is the way to go::
{
"favcolor" : "red",
"ntpserver" : "wolf.example.com",
"monitoring" : "pack.example.com"
"favcolor": "red",
"ntpserver": "wolf.example.com",
"monitoring": "pack.example.com"
}
.. _inventory_script_tuning:
@ -74,13 +74,28 @@ The data to be added to the top level JSON dictionary looks like this::
# results of inventory script as above go here
# ...
"_meta" : {
"hostvars" : {
"moocow.example.com" : { "asdf" : 1234 },
"llama.example.com" : { "asdf" : 5678 }
}
"_meta": {
"hostvars": {
"moocow.example.com": {
"asdf" : 1234
},
"llama.example.com": {
"asdf": 5678
}
}
}
}
To satisfy the requirements of using ``_meta``, to prevent ansible from calling your inventory with ``--host`` you must at least populate ``_meta`` with an empty ``hostvars`` dictionary, such as::
{
# results of inventory script as above go here
# ...
"_meta": {
"hostvars": {}
}
}
.. seealso::

View file

@ -36,12 +36,12 @@ The following is a list of module_utils files and a general description. The mod
- openstack.py - Utilities for modules that work with Openstack instances.
- openswitch.py - Definitions and helper functions for modules that manage OpenSwitch devices
- powershell.ps1 - Utilities for working with Microsoft Windows clients
- pycompat24.py - Exception workaround for python 2.4
- pycompat24.py - Exception workaround for Python 2.4
- rax.py - Definitions and helper functions for modules that work with Rackspace resources.
- redhat.py - Functions for modules that manage Red Hat Network registration and subscriptions
- service.py - Contains utilities to enable modules to work with Linux services (placeholder, not in use).
- shell.py - Functions to allow modules to create shells and work with shell commands
- six.py - Module utils for working with the Six python 2 and 3 compatibility library
- six.py - Module utils for working with the Six Python 2 and 3 compatibility library
- splitter.py - String splitting and manipulation utilities for working with Jinja2 templates
- urls.py - Utilities for working with http and https requests
- vca.py - Contains utilities for modules that work with VMware vCloud Air

View file

@ -13,14 +13,14 @@ This section discusses how to develop, debug, review, and test modules.
Ansible modules are reusable, standalone scripts that can be used by the Ansible API,
or by the :command:`ansible` or :command:`ansible-playbook` programs. They
return information to ansible by printing a JSON string to stdout before
exiting. They take arguments in in one of several ways which we'll go into
exiting. They take arguments in one of several ways which we'll go into
as we work through this tutorial.
See :doc:`../modules` for a list of existing modules.
Modules can be written in any language and are found in the path specified
by :envvar:`ANSIBLE_LIBRARY` or the ``--module-path`` command line option or
in the `library section of the Ansible configration file <http://docs.ansible.com/ansible/intro_configuration.html#library>`_.
in the :ref:`library section of the Ansible configuration file <library>`.
.. _module_dev_should_you:
@ -31,18 +31,28 @@ develop a module. Ask the following questions:
1. Does a similar module already exist?
There are a lot of existing modules available, and more that are in development. You should check out the list of existing modules at :doc:`../modules` or look at the `module PRs <https://github.com/ansible/ansible/labels/module>`_ for the ansible repository on Github to see if a module that does what you want exists or is in development.
There are a lot of existing modules available. You should check out the list of existing modules at :doc:`../modules`
2. Should you use or develop an action plugin instead?
2. Has someone already worked on a similar pull request?
Action plugins get run on the master instead of on the target. For modules like file/copy/template, some of the work needs to be done on the master before the module executes on the target. Action plugins execute first on the master and can then execute the normal module on the target if necessary.
It's possible that someone has already started developing a similar PR. There are a few ways to find open module pull requests:
For more information about action plugins, go `here <https://docs.ansible.com/ansible/dev_guide/developing_plugins.html>`_.
* `GitHub new module PRs <https://github.com/ansible/ansible/labels/new_module>`_
* `All updates to modules <https://github.com/ansible/ansible/labels/module>`_
* `New module PRs listed by directory <https://ansible.sivel.net/pr/byfile.html>`_ search for `lib/ansible/modules/`
3. Should you use a role instead?
If you find an existing PR that looks like it addresses the issue you are trying to solve, please provide feedback on the PR - this will speed up getting the PR merged.
Check out the roles documentation `here <http://docs.ansible.com/ansible/playbooks_roles.html#roles>`_.
3. Should you use or develop an action plugin instead?
Action plugins get run on the master instead of on the target. For modules like file/copy/template, some of the work needs to be done on the master before the module executes on the target. Action plugins execute first on the master and can then execute the normal module on the target if necessary.
For more information about action plugins, :doc:`read the action
plugins documentation here <developing_plugins>`.
4. Should you use a role instead?
Check out the :ref:`roles` documentation for details.
.. _developing_modules_all:
@ -59,8 +69,10 @@ The following topics will discuss how to develop and work with modules:
Best practices, recommendations, and things to avoid.
:doc:`developing_modules_checklist`
Checklist for contributing your module to Ansible.
:doc:`developing_modules_python3`
Adding Python 3 support to modules (all new modules must be py2.4 and py3 compatible).
:doc:`testing`
Developing unit and integration tests.
:doc:`developing_python3`
Adding Python 3 support to modules (all new modules must be Python-2.6 and Python-3.5 compatible).
:doc:`developing_modules_in_groups`
A guide for partners wanting to submit multiple modules.

View file

@ -18,7 +18,7 @@ and guidelines:
* If packaging modules in an RPM, they only need to be installed on the control machine and should be dropped into /usr/share/ansible. This is entirely optional and up to you.
* Modules must output valid JSON only. The toplevel return type must be a hash (dictionary) although they can be nested. Lists or simple scalar values are not supported, though they can be trivially contained inside a dictionary.
* Modules must output valid JSON only. The top level return type must be a hash (dictionary) although they can be nested. Lists or simple scalar values are not supported, though they can be trivially contained inside a dictionary.
* In the event of failure, a key of 'failed' should be included, along with a string explanation in 'msg'. Modules that raise tracebacks (stacktraces) are generally considered 'poor' modules, though Ansible can deal with these returns and will automatically convert anything unparseable into a failed result. If you are using the AnsibleModule common Python code, the 'failed' element will be included for you automatically when you call 'fail_json'.
@ -72,7 +72,7 @@ your debugging session will start:
Setting :envvar:`ANSIBLE_KEEP_REMOTE_FILES` to ``1`` tells Ansible to keep the
remote module files instead of deleting them after the module finishes
executing. Giving Ansible the ``-vvv`` optin makes Ansible more verbose.
executing. Giving Ansible the ``-vvv`` option makes Ansible more verbose.
That way it prints the file name of the temporary module file for you to see.
If you want to examine the wrapper file you can. It will show a small python
@ -103,13 +103,13 @@ When you look into the debug_dir you'll see a directory structure like this::
* The :file:`args` file contains a JSON string. The string is a dictionary
containing the module arguments and other variables that Ansible passes into
the module to change it's behaviour. If you want to modify the parameters
the module to change its behaviour. If you want to modify the parameters
that are passed to the module, this is the file to do it in.
* The :file:`ansible` directory contains code from
:mod:`ansible.module_utils` that is used by the module. Ansible includes
files for any :`module:`ansible.module_utils` imports in the module but not
no files from any other module. So if your module uses
any files from any other module. So if your module uses
:mod:`ansible.module_utils.url` Ansible will include it for you, but if
your module includes :mod:`requests` then you'll have to make sure that
the python requests library is installed on the system before running the
@ -171,7 +171,7 @@ You should never do this in a module:
.. code-block:: python
print "some status message"
print("some status message")
Because the output is supposed to be valid JSON.
@ -183,7 +183,7 @@ how the command module is implemented.
If a module returns stderr or otherwise fails to produce valid JSON, the actual output
will still be shown in Ansible, but the command will not succeed.
Don't write to files directly; use a temporary file and then use the `atomic_move` function from `ansibile.module_utils.basic` to move the updated temporary file into place. This prevents data corruption and ensures that the correct context for the file is kept.
Don't write to files directly; use a temporary file and then use the `atomic_move` function from `ansible.module_utils.basic` to move the updated temporary file into place. This prevents data corruption and ensures that the correct context for the file is kept.
Avoid creating a module that does the work of other modules; this leads to code duplication and divergence, and makes things less uniform, unpredictable and harder to maintain. Modules should be the building blocks. Instead of creating a module that does the work of other modules, use Plays and Roles instead.

View file

@ -22,8 +22,8 @@ Contributing Modules Checklist
The following checklist items are important guidelines for people who want to contribute to the development of modules to Ansible on GitHub. Please read the guidelines before you submit your PR/proposal.
* The shebang must always be ``#!/usr/bin/python``. This allows ``ansible_python_interpreter`` to work
* Modules must be written to support Python 2.4. If this is not possible, required minimum python version and rationale should be explained in the requirements section in ``DOCUMENTATION``. This minimum requirement will be advanced to Python-2.6 in Ansible-2.4.
* Modules must be written to use proper Python-3 syntax. At some point in the future we'll come up with rules for running on Python-3 but we're not there yet. See :doc:`developing_modules_python3` for help on how to do this.
* Modules must be written to support Python 2.6. If this is not possible, required minimum Python version and rationale should be explained in the requirements section in ``DOCUMENTATION``. In Ansible-2.3 the minimum requirement for modules was Python-2.4.
* Modules must be written to use proper Python-3 syntax. At some point in the future we'll come up with rules for running on Python-3 but we're not there yet. See :doc:`developing_python3` for help on how to do this.
* Modules must have a metadata section. For the vast majority of new modules,
the metadata should look exactly like this:
@ -33,7 +33,7 @@ The following checklist items are important guidelines for people who want to c
'supported_by': 'community',
'metadata_version': '1.0'}
The complete module metadata specification is here: https://docs.ansible.com/ansible/dev_guide/developing_modules_documenting.html#ansible-metadata-block
The complete module metadata specification is here: `Ansible metadata block <https://docs.ansible.com/ansible/dev_guide/developing_modules_documenting.html#ansible-metadata-block>`_
* Documentation: Make sure it exists
* Module documentation should briefly and accurately define what each module and option does, and how it works with others in the underlying system. Documentation should be written for broad audience--readable both by experts and non-experts. This documentation is not meant to teach a total novice, but it also should not be reserved for the Illuminati (hard balance).
@ -76,7 +76,7 @@ The complete module metadata specification is here: https://docs.ansible.com/ans
* Avoid catchall exceptions, they are not very useful unless the underlying API gives very good error messages pertaining the attempted action.
* Module-dependent guidelines: Additional module guidelines may exist for certain families of modules.
* Be sure to check out the modules themselves for additional information.
* Amazon: https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/cloud/amazon/GUIDELINES.md
* `Amazon <https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/cloud/amazon/GUIDELINES.md>`_
* Modules should make use of the "extends_documentation_fragment" to ensure documentation available. For example, the AWS module should include::
extends_documentation_fragment:
@ -108,7 +108,7 @@ The complete module metadata specification is here: https://docs.ansible.com/ans
main()
* Try to normalize parameters with other modules, you can have aliases for when user is more familiar with underlying API name for the option
* Being pep8 compliant is nice, but not a requirement. Specifically, the 80 column limit now hinders readability more that it improves it
* Being `PEP 8 <https://www.python.org/dev/peps/pep-0008/>`_ compliant is a requirement. See :doc:`testing_pep8` for more information.
* Avoid '`action`/`command`', they are imperative and not declarative, there are other ways to express the same thing
* Do not add `list` or `info` state options to an existing module - create a new `_facts` module.
* If you are asking 'how can I have a module execute other modules' ... you want to write a role

View file

@ -14,15 +14,16 @@ syntax highlighting before you include it in your Python file.
All modules must have the following sections defined in this order:
1. ANSIBLE_METADATA
2. DOCUMENTATION
3. EXAMPLES
4. RETURNS
5. Python imports
1. Copyright
2. ANSIBLE_METADATA
3. DOCUMENTATION
4. EXAMPLES
5. RETURNS
6. Python imports
.. note:: Why don't the imports go first?
Keen Python programmers may notice that contrary to PEP8's advice we don't put ``imports`` at the top of the file. This is because the ``ANSIBLE_METADATA`` through ``RETURNS`` sections are not used by the module code itself; they are essentially extra docstrings for the file. The imports are placed after these special variables for the same reason as PEP8 puts the imports after the introductory comments and docstrings. This keeps the active parts of the code together and the pieces which are purely informational apart. The decision to exclude E402 is based on readability (which is what PEP8 is about). Documentation strings in a module are much more similar to module level docstrings, than code, and are never utilized by the module itself. Placing the imports below this documentation and closer to the code, consolidates and groups all related code in a congruent manner to improve readability, debugging and understanding.
Keen Python programmers may notice that contrary to PEP 8's advice we don't put ``imports`` at the top of the file. This is because the ``ANSIBLE_METADATA`` through ``RETURNS`` sections are not used by the module code itself; they are essentially extra docstrings for the file. The imports are placed after these special variables for the same reason as PEP 8 puts the imports after the introductory comments and docstrings. This keeps the active parts of the code together and the pieces which are purely informational apart. The decision to exclude E402 is based on readability (which is what PEP 8 is about). Documentation strings in a module are much more similar to module level docstrings, than code, and are never utilized by the module itself. Placing the imports below this documentation and closer to the code, consolidates and groups all related code in a congruent manner to improve readability, debugging and understanding.
.. warning:: Why do some modules have imports at the bottom of the file?
@ -30,6 +31,41 @@ All modules must have the following sections defined in this order:
Copyright
----------------------
The beginning of every module should look about the same. After the shebang,
there should be at least two lines covering copyright and licensing of the
code.
.. code-block:: python
#!/usr/bin/python
# Copyright (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
Every file should have a copyright line with the original copyright holder.
Major additions to the module (for instance, rewrites) may add additional
copyright lines. Code from the Ansible community should typically be assigned
as "Copyright (c) 2017 Ansible Project" which covers all contributors. Any
legal questions need to review the source control history, so an exhaustive
copyright header is not necessary.
The license declaration should be ONLY one line, not the full GPL prefix. If
you notice a module with the full prefix, feel free to switch it to the
one-line declaration instead.
When adding a copyright line after completing a significant feature or rewrite,
add the newer line above the older one, like so:
.. code-block:: python
#!/usr/bin/python
# Copyright (c) 2017 [New Contributor(s)]
# Copyright (c) 2015 [Original Contributor(s)]
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
ANSIBLE_METADATA Block
----------------------
@ -82,14 +118,12 @@ Fields
:supported_by: This field records who supports the module.
Default value is ``community``. Values are:
:core: Maintained by the Ansible core team. Core team will fix
bugs, add new features, and review PRs.
:community: This module is maintained by the community at large,
which is responsible for fixing bugs, adding new features, and
reviewing changes.
:curated: The Ansible Core Team is the gatekeeper for this module. They
will review PRs from the community before merging but might not generate
fixes and code for new features on their own.
:core:
:curated:
:community:
For information on what the support level values entail, please see
`Modules Support <http://docs.ansible.com/ansible/modules_support.html>`_.
:status: This field records information about the module that is
important to the end user. Its a list of strings. The default value
@ -118,7 +152,8 @@ Include it in your module file like this:
.. code-block:: python
#!/usr/bin/python
# Copyright header....
# Copyright (c) 2017 [REPLACE THIS]
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
DOCUMENTATION = '''
---
@ -170,6 +205,8 @@ The following fields can be used and are all required unless specified otherwise
* If `required` is false/missing, `default` may be specified (assumed 'null' if missing).
* Ensure that the default parameter in the docs matches the default parameter in the code.
* The default option must not be listed as part of the description.
* If the option is a boolean value, you can use any of the boolean values recognized by Ansible:
(such as true/false or yes/no). Choose the one that reads better in the context of the option.
:choices:
List of option values. Should be absent if empty.
:type:
@ -221,7 +258,7 @@ RETURN Block
The RETURN section documents what the module returns, and is required for all new modules.
For each value returned, provide a ``description``, in what circumstances the value is ``returned``,
the ``type`` of the value and a ``sample``. For example, from the ``copy`` module::
the ``type`` of the value and a ``sample``. For example, from the ``copy`` module:
The following fields can be used and are all required unless specified otherwise.

View file

@ -33,9 +33,9 @@ Ok, let's get going with an example. We'll use Python. For starters, save this
import json
date = str(datetime.datetime.now())
print json.dumps({
print(json.dumps({
"time" : date
})
}))
.. _module_testing:
@ -146,10 +146,10 @@ a lot shorter than this:
# can be added.
if rc != 0:
print json.dumps({
print(json.dumps({
"failed" : True,
"msg" : "failed setting the time"
})
}))
sys.exit(1)
# when things do not fail, we do not
@ -160,10 +160,10 @@ a lot shorter than this:
# notifiers to be used in playbooks.
date = str(datetime.datetime.now())
print json.dumps({
print(json.dumps({
"time" : date,
"changed" : True
})
}))
sys.exit(0)
# if no parameters are sent, the module may or
@ -171,9 +171,9 @@ a lot shorter than this:
# return the time
date = str(datetime.datetime.now())
print json.dumps({
print(json.dumps({
"time" : date
})
}))
Let's test that module::
@ -311,7 +311,7 @@ Supporting Check Mode
`````````````````````
.. versionadded:: 1.1
Modules may optionally support `check mode <http://docs.ansible.com/ansible/playbooks_checkmode.html>`. If the user runs Ansible in check mode, a module should try to predict and report whether changes will occur but not actually make any changes (modules that do not support check mode will also take no action, but just will not report what changes they might have made).
Modules may optionally support `check mode <http://docs.ansible.com/ansible/playbooks_checkmode.html>`_. If the user runs Ansible in check mode, a module should try to predict and report whether changes will occur but not actually make any changes (modules that do not support check mode will also take no action, but just will not report what changes they might have made).
For your module to support check mode, you must pass ``supports_check_mode=True`` when instantiating the AnsibleModule object. The AnsibleModule.check_mode attribute will evaluate to True when check mode is enabled. For example:

View file

@ -19,14 +19,16 @@ Before you start coding
Although it's tempting to get straight into coding, there are a few things to be aware of first. This list of prerequisites is designed to help ensure that you develop high-quality modules that flow easily through the review process and get into Ansible more quickly.
* Read though all the pages linked off :doc:`developing_modules`; paying particular focus to the :doc:`developing_modules_checklist`.
* For new modules going into Ansible 2.4 we are raising the bar so they must pass ``pep8 --ignore=E402 --max-line-length=160`` cleanly.
* For new modules going into Ansible 2.4 we are raising the bar so they must be PEP 8 compliant. See :doc:`testing_pep8` for more information.
* Starting with Ansible version 2.4, all new modules must support Python 2.6 and Python 3.5+. If this is an issue, please contact us (see the "Speak to us" section later in this document to learn how).
* All modules shipped with Ansible must be done so under the GPLv3 license. Files under the ``lib/ansible/module_utils/`` directory should be done so under the BSD license.
* Have a look at the existing modules and how they've been named in the :doc:`../list_of_all_modules`, especially in the same functional area (such as cloud, networking, databases).
* Shared code can be placed into ``lib/ansible/module_utils/``
* Shared documentation (for example describing common arguments) can be placed in ``lib/ansible/utils/module_docs_fragments/``.
* With great power comes great responsiblity: Ansible module maintainers have a duty to help keep modules up to date. As with all successful community projects, module maintainers should keep a watchful eye for reported issues and contributions.
* Although not required, unit and/or integration tests are strongly recomended. Unit tests are especially valuable when external resources (such as cloud or network devices) are required. For more information see ``test/`` and the `Testing Working Group <https://github.com/ansible/community/blob/master/MEETINGS.md>`_.
* With great power comes great responsibility: Ansible module maintainers have a duty to help keep modules up to date. As with all successful community projects, module maintainers should keep a watchful eye for reported issues and contributions.
* Although not required, unit and/or integration tests are strongly recommended. Unit tests are especially valuable when external resources (such as cloud or network devices) are required. For more information see :doc:`testing` and the `Testing Working Group <https://github.com/ansible/community/blob/master/meetings/README.md>`_.
* Starting with Ansible 2.4 all :doc:`../list_of_network_modules` MUST have unit tests.
Naming Convention
`````````````````
@ -63,7 +65,7 @@ On :doc:`../community` you can find how to:
* Subscribe to the Mailing Lists - We suggest "Ansible Development List" (for codefreeze info) and "Ansible Announce list"
* ``#ansible-devel`` - We have found that IRC ``#ansible-devel`` on FreeNodes IRC network works best for module developers so we can have an interactive dialogue.
* IRC meetings - Join the various weekly IRC meetings `meeting schedule and agenda page <https://github.com/ansible/community/blob/master/MEETINGS.md>`_
* IRC meetings - Join the various weekly IRC meetings `meeting schedule and agenda page <https://github.com/ansible/community/blob/master/meetings/README.md>`_
Your First Pull Request
@ -91,12 +93,12 @@ And that's it.
Before pushing your PR to GitHub it's a good idea to review the :doc:`developing_modules_checklist` again.
After publishing your PR to https://github.com/ansible/ansible, a Shippable CI test should run within a few minutes. Check the results (at the end of the PR page) to ensure that it's passing (green). If it's not passing, inspect each of the results. Most of the errors should be self-explanatory and are often related to badly formatted documentation (see :doc:`../YAMLSyntax`) or code that isn't valid Python 2.4 & Python 2.6 (see :doc:`developing_modules_python3`). If you aren't sure what a Shippable test message means, copy it into the PR along with a comment and we will review.
After publishing your PR to https://github.com/ansible/ansible, a Shippable CI test should run within a few minutes. Check the results (at the end of the PR page) to ensure that it's passing (green). If it's not passing, inspect each of the results. Most of the errors should be self-explanatory and are often related to badly formatted documentation (see :doc:`../YAMLSyntax`) or code that isn't valid Python 2.6 or valid Python 3.5 (see :doc:`developing_python3`). If you aren't sure what a Shippable test message means, copy it into the PR along with a comment and we will review.
If you need further advice, consider join the ``#ansible-devel`` IRC channel (see how in the "Where to get support").
We have a "ansibot" helper that comments on GitHub Issues and PRs which should highlight important information.
We have a ``ansibullbot`` helper that comments on GitHub Issues and PRs which should highlight important information.
Subsequent PRs
@ -141,9 +143,8 @@ We realise this may be your first use of Git or GitHub. The following guides may
* `How to sync (update) your fork <https://help.github.com/articles/syncing-a-fork/>`_
* `How to create a Pull Request (PR) <https://help.github.com/articles/about-pull-requests/>`_
Please note that in the Ansible Git Repo the main branch is called ``devel`` rather than ``master``, which is used in the offical GitHub documentation
Please note that in the Ansible Git Repo the main branch is called ``devel`` rather than ``master``, which is used in the official GitHub documentation
After your first PR has been merged ensure you "sync your fork" with ``ansible/ansible`` to ensure you've pulled in the directory structure and and shared code or documentation previously created.
As stated in the GitHub documentation, always use feature branches for your PRs, never commit directly into `devel`.

View file

@ -124,6 +124,7 @@ to yield text but instead do the conversion explicitly ourselves. For example::
# Handle the exception gracefully -- usually by displaying a good
# user-centric error message that can be traced back to this piece
# of code.
pass
.. note:: Much of Ansible assumes that all encoded text is UTF-8. At some
point, if there is demand for other encodings we may change that, but for
@ -285,7 +286,6 @@ For modules which also run on Python-2.4, we have to use an uglier
construction to make this work under both Python-2.4 and Python-3::
from ansible.module_utils.pycompat24 import get_exception
[...]
try:
a = 2/0

View file

@ -84,6 +84,7 @@ Callback plugins are created by creating a new class with the Base(Callbacks) cl
from ansible import constants as C
class CallbackModule(CallbackBase):
pass
From there, override the specific methods from the CallbackBase that you want to provide a callback for. For plugins intended for use with Ansible version 2.0 and later, you should only override methods that start with `v2`. For a complete list of methods that you can override, please see ``__init__.py`` in the `lib/ansible/plugins/callback <https://github.com/ansible/ansible/tree/devel/lib/ansible/plugins/callback>`_ directory.

View file

@ -0,0 +1,447 @@
====================
Ansible and Python 3
====================
Ansible is pursuing a strategy of having one code base that runs on both
Python-2 and Python-3 because we want Ansible to be able to manage a wide
variety of machines. Contributors to Ansible should be aware of the tips in
this document so that they can write code that will run on the same versions
of Python as the rest of Ansible.
Ansible can be divided into three overlapping pieces for the purposes of
porting:
1. Controller-side code. This is the code which runs on the machine where you
invoke :command:`/usr/bin/ansible`
2. Modules. This is the code which Ansible transmits over the wire and
invokes on the managed machine.
3. module_utils code. This is code whose primary purpose is to be used by the
modules to perform tasks. However, some controller-side code might use
generic functions from here.
Much of the knowledge of porting code will be usable on all three of these
pieces but there are some special considerations for some of it as well.
Information that is generally applicable to all three places is located in the
controller-side section.
--------------------------------------------
Minimum Version of Python-3.x and Python-2.x
--------------------------------------------
In both controller side and module code, we support Python-3.5 or greater and Python-2.6 or
greater. Python-3.5 was chosen as a minimum because it is the earliest Python-3 version
adopted as the default Python by a Long Term Support (LTS) Linux distribution (in this case, Ubuntu-16.04).
Previous LTS Linux distributions shipped with a Python-2 version which users can rely upon instead of the
Python-3 version.
For Python-2, the default is for modules to run on at least Python-2.6. This allows
users with older distributions that are stuck on Python-2.6 to manage their
machines. Modules are allowed to drop support for Python-2.6 when one of
their dependent libraries requires a higher version of Python. This is not an
invitation to add unnecessary dependent libraries in order to force your
module to be usable only with a newer version of Python; instead it is an
acknowledgment that some libraries (for instance, boto3 and docker-py) will
only function with a newer version of Python.
.. note:: Python-2.4 Module-side Support:
Support for Python-2.4 and Python-2.5 was dropped in Ansible-2.4. RHEL-5
(and its rebuilds like CentOS-5) were supported until April of 2017.
Ansible-2.3 was released in April of 2017 and was the last Ansible release
to support Python-2.4 on the module-side.
-----------------------------------
Porting Controller Code to Python 3
-----------------------------------
Most of the general tips for porting code to be used on both Python-2 and
Python-3 applies to porting controller code. The best place to start learning
to port code is `Lennart Regebro's book: Porting to Python 3 <http://python3porting.com/>`_.
The book describes several strategies for porting to Python 3. The one we're
using is `to support Python-2 and Python-3 from a single code base
<http://python3porting.com/strategies.html#python-2-and-python-3-without-conversion>`_
Controller String Strategy
==========================
Background
----------
One of the most essential things to decide upon for porting code to Python-3
is what string model to use. Strings can be an array of bytes (like in C) or
they can be an array of text. Text is what we think of as letters, digits,
numbers, other printable symbols, and a small number of unprintable "symbols"
(control codes).
In Python-2, the two types for these (:class:`str` for bytes and
:class:`unicode` for text) are often used interchangeably. When dealing only
with ASCII characters, the strings can be combined, compared, and converted
from one type to another automatically. When non-ASCII characters are
introduced, Python starts throwing exceptions due to not knowing what encoding
the non-ASCII characters should be in.
Python-3 changes this behavior by making the separation between bytes (:class:`bytes`)
and text (:class:`str`) more strict. Python will throw an exception when
trying to combine and compare the two types. The programmer has to explicitly
convert from one type to the other to mix values from each.
This change makes it immediately apparent to the programmer when code is
mixing the types inappropriately, rather than working until one of their users
causes an exception by entering non-ASCII input. However, it forces the
programmer to proactively define a strategy for working with strings in their
program so that they don't mix text and byte strings unintentionally.
Unicode Sandwich
----------------
In controller-side code we use a strategy known as the Unicode Sandwich (named
after Python-2's :class:`unicode` text type). For Unicode Sandwich we know that
at the border of our code and the outside world (for example, file and network IO,
environment variables, and some library calls) we are going to receive bytes.
We need to transform these bytes into text and use that throughout the
internal portions of our code. When we have to send those strings back out to
the outside world we first convert the text back into bytes.
To visualize this, imagine a 'sandwich' consisting of a top and bottom layer
of bytes, a layer of conversion between, and all text type in the center.
Common Borders
--------------
This is a partial list of places where we have to convert to and from bytes.
It's not exhaustive but gives you an idea of where to watch for problems.
Reading and writing to files
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In Python-2, reading from files yields bytes. In Python-3, it can yield text.
To make code that's portable to both we don't make use of Python-3's ability
to yield text but instead do the conversion explicitly ourselves. For example:
.. code-block:: python
from ansible.module_utils._text import to_text
with open('filename-with-utf8-data.txt', 'rb') as my_file:
b_data = my_file.read()
try:
data = to_text(b_data, errors='surrogate_or_strict')
except UnicodeError:
# Handle the exception gracefully -- usually by displaying a good
# user-centric error message that can be traced back to this piece
# of code.
pass
.. note:: Much of Ansible assumes that all encoded text is UTF-8. At some
point, if there is demand for other encodings we may change that, but for
now it is safe to assume that bytes are UTF-8.
Writing to files is the opposite process:
.. code-block:: python
from ansible.module_utils._text import to_bytes
with open('filename.txt', 'wb') as my_file:
my_file.write(to_bytes(some_text_string))
Note that we don't have to catch :exc:`UnicodeError` here because we're
transforming to UTF-8 and all text strings in Python can be transformed back
to UTF-8.
Filesystem Interaction
~~~~~~~~~~~~~~~~~~~~~~
Dealing with filenames often involves dropping back to bytes because on UNIX-like
systems filenames are bytes. On Python-2, if we pass a text string to these
functions, the text string will be converted to a byte string inside of the
function and a traceback will occur if non-ASCII characters are present. In
Python-3, a traceback will only occur if the text string can't be decoded in
the current locale, but it's still good to be explicit and have code which
works on both versions:
.. code-block:: python
import os.path
from ansible.module_utils._text import to_bytes
filename = u'/var/tmp/くらとみ.txt'
f = open(to_bytes(filename), 'wb')
mtime = os.path.getmtime(to_bytes(filename))
b_filename = os.path.expandvars(to_bytes(filename))
if os.path.exists(to_bytes(filename)):
pass
When you are only manipulating a filename as a string without talking to the
filesystem (or a C library which talks to the filesystem) you can often get
away without converting to bytes:
.. code-block:: python
import os.path
os.path.join(u'/var/tmp/café', u'くらとみ')
os.path.split(u'/var/tmp/café/くらとみ')
On the other hand, if the code needs to manipulate the filename and also talk
to the filesystem, it can be more convenient to transform to bytes right away
and manipulate in bytes.
.. warning:: Make sure all variables passed to a function are the same type.
If you're working with something like :func:`os.path.join` which takes
multiple strings and uses them in combination, you need to make sure that
all the types are the same (either all bytes or all text). Mixing
bytes and text will cause tracebacks.
Interacting with Other Programs
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Interacting with other programs goes through the operating system and
C libraries and operates on things that the UNIX kernel defines. These
interfaces are all byte-oriented so the Python interface is byte oriented as
well. On both Python-2 and Python-3, byte strings should be given to Python's
subprocess library and byte strings should be expected back from it.
One of the main places in Ansible's controller code that we interact with
other programs is the connection plugins' ``exec_command`` methods. These
methods transform any text strings they receive in the command (and arguments
to the command) to execute into bytes and return stdout and stderr as byte strings
Higher level functions (like action plugins' ``_low_level_execute_command``)
transform the output into text strings.
Tips, tricks, and idioms to adopt
=================================
Forwards Compatibility Boilerplate
----------------------------------
Use the following boilerplate code at the top of all controller-side modules
to make certain constructs act the same way on Python-2 and Python-3:
.. code-block:: python
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
``__metaclass__ = type`` makes all classes defined in the file into new-style
classes without explicitly inheriting from :class:`object`.
The ``__future__`` imports do the following:
:absolute_import: Makes imports look in :attr:`sys.path` for the modules being
imported, skipping the directory in which the module doing the importing
lives. If the code wants to use the directory in which the module doing
the importing, there's a new dot notation to do so.
:division: Makes division of integers always return a float. If you need to
find the quotient use ``x // y`` instead of ``x / y``.
:print_function: Changes :func:`print` from a keyword into a function.
.. seealso::
* `PEP 0328: Absolute Imports <https://www.python.org/dev/peps/pep-0328/#guido-s-decision>`_
* `PEP 0238: Division <https://www.python.org/dev/peps/pep-0238>`_
* `PEP 3105: Print function <https://www.python.org/dev/peps/pep-3105>`_
Prefix byte strings with "b\_"
------------------------------
Since mixing text and bytes types leads to tracebacks we want to be clear
about what variables hold text and what variables hold bytes. We do this by
prefixing any variable holding bytes with ``b_``. For instance:
.. code-block:: python
filename = u'/var/tmp/café.txt'
b_filename = to_bytes(filename)
with open(b_filename) as f:
data = f.read()
We do not prefix the text strings instead because we only operate
on byte strings at the borders, so there are fewer variables that need bytes
than text.
Bundled six
-----------
The third-party `python-six <https://pythonhosted.org/six/>`_ library exists
to help projects create code that runs on both Python-2 and Python-3. Ansible
includes a version of the library in module_utils so that other modules can use it
without requiring that it is installed on the remote system. To make use of
it, import it like this:
.. code-block:: python
from ansible.module_utils import six
.. note:: Ansible can also use a system copy of six
Ansible will use a system copy of six if the system copy is a later
version than the one Ansible bundles.
Exceptions
----------
In order for code to function on Python-2.6+ and Python-3, use the
new exception-catching syntax which uses the ``as`` keyword:
.. code-block:: python
try:
a = 2/0
except ValueError as e:
module.fail_json(msg="Tried to divide by zero: %s" % e)
Do **not** use the following syntax as it will fail on every version of Python-3:
.. This code block won't highlight because python2 isn't recognized. This is necessary to pass tests under python 3.
.. code-block:: python2
try:
a = 2/0
except ValueError, e:
module.fail_json(msg="Tried to divide by zero: %s" % e)
Octal numbers
-------------
In Python-2.x, octal literals could be specified as ``0755``. In Python-3,
octals must be specified as ``0o755``.
String formatting
-----------------
str.format() compatibility
~~~~~~~~~~~~~~~~~~~~~~~~~~
Starting in Python-2.6, strings gained a method called ``format()`` to put
strings together. However, one commonly used feature of ``format()`` wasn't
added until Python-2.7, so you need to remember not to use it in Ansible code:
.. code-block:: python
# Does not work in Python-2.6!
new_string = "Dear {}, Welcome to {}".format(username, location)
# Use this instead
new_string = "Dear {0}, Welcome to {1}".format(username, location)
Both of the format strings above map positional arguments of the ``format()``
method into the string. However, the first version doesn't work in
Python-2.6. Always remember to put numbers into the placeholders so the code
is compatible with Python-2.6.
.. seealso::
Python documentation on `format strings <https://docs.python.org/2/library/string.html#formatstrings>`_
Use percent format with byte strings
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In Python-3.x, byte strings do not have a ``format()`` method. However, it
does have support for the older, percent-formatting.
.. code-block:: python
b_command_line = b'ansible-playbook --become-user %s -K %s' % (user, playbook_file)
.. note:: Percent formatting added in Python-3.5
Percent formatting of byte strings was added back into Python3 in 3.5.
This isn't a problem for us because Python-3.5 is our minimum version.
However, if you happen to be testing Ansible code with Python-3.4 or
earlier, you will find that the byte string formatting here won't work.
Upgrade to Python-3.5 to test.
.. seealso::
Python documentation on `percent formatting <https://docs.python.org/2/library/stdtypes.html#string-formatting>`_
---------------------------
Porting Modules to Python 3
---------------------------
Ansible modules are slightly harder to port than normal code from other
projects. A lot of mocking has to go into unit testing an Ansible module so
it's harder to test that your porting has fixed everything or to to make sure
that later commits haven't regressed the Python-3 support.
Module String Strategy
======================
There are a large number of modules in Ansible. Most of those are maintained
by the Ansible community at large, not by a centralized team. To make life
easier on them, it was decided not to break backwards compatibility by
mandating that all strings inside of modules are text and converting between
text and bytes at the borders; instead, we're using a native string strategy
for now.
Native strings refer to the type that Python uses when you specify a bare
string literal:
.. code-block:: python
"This is a native string"
In Python-2, these are byte strings. In Python-3 these are text strings. The
module_utils shipped with Ansible attempts to accept native strings as input
to its functions and emit native strings as their output. Modules should be
coded to expect bytes on Python-2 and text on Python-3.
Tips, tricks, and idioms to adopt
=================================
Python-2.4 Compatible Exception Syntax
--------------------------------------
Until Ansible-2.4, modules needed to be compatible with Python-2.4 as
well. Python-2.4 did not understand the new exception-catching syntax so
we had to write a compatibility function that could work with both
Python-2 and Python-3. You may still see this used in some modules:
.. code-block:: python
from ansible.module_utils.pycompat24 import get_exception
try:
a = 2/0
except ValueError:
e = get_exception()
module.fail_json(msg="Tried to divide by zero: %s" % e)
Unless a change is going to be backported to Ansible-2.3, you should not
have to use this in new code.
Python 2.4 octal workaround
---------------------------
Before Ansible-2.4, modules had to be compatible with Python-2.4.
Python-2.4 did not understand the new syntax for octal literals so we used
the following workaround to specify octal values:
.. code-block:: python
# Can't use 0755 on Python-3 and can't use 0o755 on Python-2.4
EXECUTABLE_PERMS = int('0755', 8)
Unless a change is going to be backported to Ansible-2.3, you should not
have to use this in new code.
-------------------------------------
Porting module_utils code to Python 3
-------------------------------------
module_utils code is largely like module code. However, some pieces of it are
used by the controller as well. Because of this, it needs to be usable with
the controller's assumptions. This is most notable in the string strategy.
Module_utils String Strategy
============================
Module_utils **must** use the Native String Strategy. Functions in
module_utils receive either text strings or byte strings and may emit either
the same type as they were given or the native string for the Python version
they are run on depending on which makes the most sense for that function.
Functions which return strings **must** document whether they return text,
byte, or native strings. Module-utils functions are therefore often very
defensive in nature, converting from potential text or bytes at the
beginning of a function and converting to the native string type at the end.

View file

@ -1,57 +0,0 @@
Releases
========
.. contents:: Topics
:local:
.. _support_life:
Support for older releases
``````````````````````````
Ansible supports the two most recent major, stable releases. Security- and bug-related fixes may be implemented in older versions, but this
support is not guaranteed.
If you are on a release older than the last two major, stable releases, please see our `Porting Guide <http://docs.ansible.com/ansible/porting_guide_2.0.html>`_.
.. _schedule:
Release schedule
````````````````
Ansible is on a 'flexible' 4 month release schedule. Sometimes the release cycle can be extended if there is a major change that requires more time (for example, a core rewrite).
Recently the main Ansible repo `merged <https://docs.ansible.com/ansible/dev_guide/repomerge.html>`_ the separated ansible-modules-core and ansible-modules-extras repos, as such modules get released at the same time as the main Ansible repo.
The major features and bugs fixed in a release should be reflected in the `CHANGELOG.md <https://github.com/ansible/ansible/blob/devel/CHANGELOG.md>`_. Minor features and bug fixes will be shown in the commit history. For example, `issue #19057 <https://github.com/ansible/ansible/pull/19057>`_ is reflected only in the commit history.
When a fix orfeature gets added to the `devel` branch it will be part of the next release. Some bugfixes can be backported to previous releases and will be part of a minor point release if such a release is deemed necessary.
Sometimes a release candidate can be extended by a few days if a bug fix makes a change that can have far-reaching consequences, so users have enough time to find any new issues that may stem from this.
.. _methods:
Release methods
````````````````
Ansible normally goes through a 'release candidate', issuing an RC1 for a release. If no major bugs are discovered in the release candidate after 5 business days, we'll get a final release. Otherwise, fixes will be applied and an RC2 will be provided for testing. If no bugs are discovered in RC2 after 2 days, the final release will be made, iterating this last step and incrementing the candidate number as we find major bugs.
.. _freezing:
Release feature freeze
``````````````````````
During the release candidate process, the focus will be on bugfixes that affect the RC, new features will be delayed while we try to produce a final version. Some bugfixes that are minor or don't affect the RC will also be postponed until after the release is finalized.
.. seealso::
:doc:`developing_api`
Python API to Playbooks and Ad Hoc Task Execution
:doc:`developing_modules`
How to develop modules
:doc:`developing_plugins`
How to develop plugins
`Ansible Tower <https://ansible.com/ansible-tower>`_
REST API endpoint and GUI for Ansible, syncs with dynamic inventory
`Development Mailing List <http://groups.google.com/group/ansible-devel>`_
Mailing list for development topics
`irc.freenode.net <http://irc.freenode.net>`_
#ansible IRC chat channel

View file

@ -180,11 +180,11 @@ If the PR does not resolve the issue, or if you see any failures from the unit/i
|
| When I ran this Ubuntu 16.04 it failed with the following:
|
| ```
| \```
| BLARG
| StrackTrace
| RRRARRGGG
| ```
| \```
When you are done testing a feature branch, you can remove it with the following command:

View file

@ -1,8 +1,9 @@
*********************
Developer Information
=====================
*********************
Ansible Developer Guide
```````````````````````
=======================
Welcome to the Ansible Developer Guide!
@ -16,14 +17,22 @@ To get started, select one of the following topics.
overview_architecture
developing_modules
developing_modules_python3
developing_modules_general
developing_modules_documenting
developing_modules_best_practices
developing_modules_checklist
developing_modules_in_groups
developing_program_flow_modules
developing_module_utilities
developing_plugins
developing_inventory
developing_api
developing_module_utilities
developing_core
developing_python3
developing_api
developing_test_pr
developing_rebasing
testing
repomerge
developing_releases
../release_and_maintenance
../committer_guidelines
./style_guide/index

View file

@ -16,14 +16,14 @@ Ansible works by connecting to your nodes and pushing out small programs, called
Your library of modules can reside on any machine, and there are no servers, daemons, or databases required. Typically you'll work with your favorite terminal program, a text editor, and probably a version control system to keep track of changes to your content.
Plugins
-------
``````````````````
Plugins are pieces of code that augment Ansible's core functionality. Ansible ships with a number of handy plugins, and you can easily write your own.
Inventory
````````````````````
By default, Ansible represents what machines it manages using a very simple INI file that puts all of your managed machines in groups of your own choosing.
By default, Ansible represents what machines it manages using a very simple INI file that puts all of your managed machines in groups of your own choosing.
To add new machines, there is no additional SSL signing server involved, so there's never any hassle deciding why a particular machine didnt get linked up due to obscure NTP or DNS issues.
@ -51,7 +51,7 @@ Playbooks can finely orchestrate multiple slices of your infrastructure topology
Ansible's approach to orchestration is one of finely-tuned simplicity, as we believe your automation code should make perfect sense to you years down the road and there should be very little to remember about special syntax or features.
Here's what a simple playbook looks like::
Here's what a simple playbook looks like::
---
- hosts: webservers
@ -70,6 +70,3 @@ Extending Ansible with Plug-ins and the API
````````````````````````````````````````````
Should you want to write your own, Ansible modules can be written in any language that can return JSON (Ruby, Python, bash, etc). Inventory can also plug in to any datasource by writing a program that speaks to that datasource and returns JSON. There's also various Python APIs for extending Ansibles connection types (SSH is not the only transport possible), callbacks (how Ansible logs, etc), and even for adding new server side behaviors.

View file

@ -0,0 +1,195 @@
***************
Testing Ansible
***************
.. contents:: Topics
Introduction
============
This document describes:
* how Ansible is tested
* how to test Ansible locally
* how to extend the testing capabilities
Types of tests
==============
At a high level we have the following classifications of tests:
:compile:
* :doc:`testing_compile`
* Test python code against a variety of Python versions.
:sanity:
* :doc:`testing_sanity`
* Sanity tests are made up of scripts and tools used to perform static code analysis.
* The primary purpose of these tests is to enforce Ansible coding standards and requirements.
:integration:
* :doc:`testing_integration`
* Functional tests of modules and Ansible core functionality.
:units:
* :doc:`testing_units`
* Tests directly against individual parts of the code base.
If you're a developer, one of the most valuable things you can do is look at the GitHub issues list and help fix bugs. We almost always prioritize bug fixing over feature development, so helping to fix bugs is one of the best things you can do.
Even if you're not a developer, helping to test pull requests for bug fixes and features is still immensely valuable.
Testing within GitHub & Shippable
=================================
Organization
------------
When Pull Requests (PRs) are created they are tested using Shippable, a Continuous Integration (CI) tool. Results are shown at the end of every PR.
When Shippable detects an error and it can be linked back to a file that has been modified in the PR then the relevant lines will be added as a GitHub comment. For example::
The test `ansible-test sanity --test pep8` failed with the following errors:
lib/ansible/modules/network/foo/bar.py:509:17: E265 block comment should start with '# '
The test `ansible-test sanity --test validate-modules` failed with the following errors:
lib/ansible/modules/network/foo/bar.py:0:0: E307 version_added should be 2.4. Currently 2.3
lib/ansible/modules/network/foo/bar.py:0:0: E316 ANSIBLE_METADATA.metadata_version: required key not provided @ data['metadata_version']. Got None
From the above example we can see that ``--test pep8`` and ``--test validate-modules`` have identified issues. The commands given allow you to run the same tests locally to ensure you've fixed the issues without having to push your changed to GitHub and wait for Shippable, for example:
If you haven't already got Ansible available, use the local checkout by running::
source hacking/env-setup
Then run the tests detailed in the GitHub comment::
ansible-test sanity --test pep8
ansible-test sanity --test validate-modules
If there isn't a GitHub comment stating what's failed you can inspect the results by clicking on the "Details" button under the "checks have failed" message at the end of the PR.
Rerunning a failing CI job
--------------------------
Occasionally you may find your PR fails due to a reason unrelated to your change. This could happen for several reasons, including:
* a temporary issue accessing an external resource, such as a yum or git repo
* a timeout creating a virtual machine to run the tests on
If either of these issues appear to be the case, you can rerun the Shippable test by:
* closing and re-opening the PR
* making another change to the PR and pushing to GitHub
If the issue persists, please contact us in ``#ansible-devel`` on Freenode IRC.
How to test a PR
================
If you're a developer, one of the most valuable things you can do is look at the GitHub issues list and help fix bugs. We almost always prioritize bug fixing over feature development, so helping to fix bugs is one of the best things you can do.
Even if you're not a developer, helping to test pull requests for bug fixes and features is still immensely valuable.
Ideally, code should add tests that prove that the code works. That's not always possible and tests are not always comprehensive, especially when a user doesn't have access to a wide variety of platforms, or is using an API or web service. In these cases, live testing against real equipment can be more valuable than automation that runs against simulated interfaces. In any case, things should always be tested manually the first time as well.
Thankfully, helping to test Ansible is pretty straightforward, assuming you are familiar with how Ansible works.
Setup: Checking out a Pull Request
----------------------------------
You can do this by:
* checking out Ansible
* making a test branch off the main branch
* merging a GitHub issue
* testing
* commenting on that particular issue on GitHub
Here's how:
.. warning::
Testing source code from GitHub pull requests sent to us does have some inherent risk, as the source code
sent may have mistakes or malicious code that could have a negative impact on your system. We recommend
doing all testing on a virtual machine, whether a cloud instance, or locally. Some users like Vagrant
or Docker for this, but they are optional. It is also useful to have virtual machines of different Linux or
other flavors, since some features (apt vs. yum, for example) are specific to those OS versions.
Create a fresh area to work::
git clone https://github.com/ansible/ansible.git ansible-pr-testing
cd ansible-pr-testing
Next, find the pull request you'd like to test and make note of the line at the top which describes the source
and destination repositories. It will look something like this::
Someuser wants to merge 1 commit into ansible:devel from someuser:feature_branch_name
.. note:: Only test ``ansible:devel``
It is important that the PR request target be ``ansible:devel``, as we do not accept pull requests into any other branch. Dot releases are cherry-picked manually by Ansible staff.
The username and branch at the end are the important parts, which will be turned into git commands as follows::
git checkout -b testing_PRXXXX devel
git pull https://github.com/someuser/ansible.git feature_branch_name
The first command creates and switches to a new branch named ``testing_PRXXXX``, where the XXXX is the actual issue number associated with the pull request (for example, 1234). This branch is based on the ``devel`` branch. The second command pulls the new code from the users feature branch into the newly created branch.
.. note::
If the GitHub user interface shows that the pull request will not merge cleanly, we do not recommend proceeding if you are not somewhat familiar with git and coding, as you will have to resolve a merge conflict. This is the responsibility of the original pull request contributor.
.. note::
Some users do not create feature branches, which can cause problems when they have multiple, unrelated commits in their version of ``devel``. If the source looks like ``someuser:devel``, make sure there is only one commit listed on the pull request.
The Ansible source includes a script that allows you to use Ansible directly from source without requiring a
full installation that is frequently used by developers on Ansible.
Simply source it (to use the Linux/Unix terminology) to begin using it immediately::
source ./hacking/env-setup
This script modifies the ``PYTHONPATH`` environment variables (along with a few other things), which will be temporarily
set as long as your shell session is open.
Testing the Pull Request
------------------------
At this point, you should be ready to begin testing!
Some ideas of what to test are:
* Create a test Playbook with the examples in and check if they function correctly
* Test to see if any Python backtraces returned (that's a bug)
* Test on different operating systems, or against different library versions
Any potential issues should be added as comments on the pull request (and it's acceptable to comment if the feature works as well), remembering to include the output of ``ansible --version``
Example::
Works for me! Tested on `Ansible 2.3.0`. I verified this on CentOS 6.5 and also Ubuntu 14.04.
If the PR does not resolve the issue, or if you see any failures from the unit/integration tests, just include that output instead:
| This doesn't work for me.
|
| When I ran this Ubuntu 16.04 it failed with the following:
|
| \```
| some output
| StrackTrace
| some other output
| \```
Want to know more about testing?
================================
If you'd like to know more about the plans for improving testing Ansible then why not join the `Testing Working Group <https://github.com/ansible/community/blob/master/meetings/README.md>`_.

View file

@ -0,0 +1,67 @@
*************
Compile Tests
*************
.. contents:: Topics
Overview
========
Compile tests check source files for valid syntax on all supported python versions:
- 2.4 (Ansible 2.3 only)
- 2.6
- 2.7
- 3.5
- 3.6
Running compile tests locally
=============================
Unit tests can be run across the whole code base by doing:
.. code:: shell
cd /path/to/ansible/source
source hacking/env-setup
ansible-test compile
Against a single file by doing:
.. code:: shell
ansible-test compile lineinfile
Or against a specific Python version by doing:
.. code:: shell
ansible-test compile --python 2.7 lineinfile
For advanced usage see the help:
.. code:: shell
ansible-test units --help
Installing dependencies
=======================
``ansible-test`` has a number of dependencies , for ``compile`` tests we suggest running the tests with ``--local``, which is the default
The dependencies can be installed using the ``--requirements`` argument. For example:
.. code:: shell
ansible-test units --requirements lineinfile
The full list of requirements can be found at `test/runner/requirements <https://github.com/ansible/ansible/tree/devel/test/runner/requirements>`_. Requirements files are named after their respective commands. See also the `constraints <https://github.com/ansible/ansible/blob/devel/test/runner/requirements/constraints.txt>`_ applicable to all commands.
Extending compile tests
=======================
If you believe changes are needed to the Compile tests please add a comment on the `Testing Working Group Agenda <https://github.com/ansible/community/blob/master/meetings/README.md>`_ so it can be discussed.

View file

@ -0,0 +1,72 @@
**********
httptester
**********
.. contents:: Topics
Overview
========
``httptester`` is a docker container used to host certain resources required by :doc:`testing_integration`. This is to avoid CI tests requiring external resources (such as git or package repos) which, if temporarily unavailable, would cause tests to fail.
HTTP Testing endpoint which provides the following capabilities:
* httpbin
* nginx
* SSL
* SNI
Source files can be found at `test/utils/docker/httptester/ <https://github.com/ansible/ansible/tree/devel/test/utils/docker/httptester>`_
Building
========
Docker
------
Both ways of building ``docker`` utilize the ``nginx:alpine`` image, but can
be customized for ``Fedora``, ``Red Hat``, ``CentOS``, ``Ubuntu``,
``Debian`` and other variants of ``Alpine``
When utilizing ``packer`` or configuring with ``ansible-playbook``,
the services will not automatically start on launch, and will have to be
manually started using::
cd test/utils/docker/httptester
./services.sh
Such as when starting a docker container::
cd test/utils/docker/httptester
docker run -ti --rm -p 80:80 -p 443:443 --name httptester ansible/ansible:httptester /services.sh
docker build
------------
::
cd test/utils/docker/httptester
docker build -t ansible/ansible:httptester .
packer
------
The ``packer`` build will use ``ansible-playbook`` to perform the
configuration, and will tag the image as ``ansible/ansible:httptester``::
cd test/utils/docker/httptester
packer build packer.json
Ansible
=======
::
cd test/utils/docker/httptester
ansible-playbook -i hosts -v httptester.yml
Extending httptester
====================
If you have sometime to improve ``httptester`` please add a comment on the `Testing Working Group Agenda <https://github.com/ansible/community/blob/master/meetings/README.md>`_ to avoid duplicated effort.

View file

@ -0,0 +1,270 @@
*****************
Integration tests
*****************
.. contents:: Topics
The Ansible integration Test system.
Tests for playbooks, by playbooks.
Some tests may require credentials. Credentials may be specified with `credentials.yml`.
Some tests may require root.
Quick Start
===========
It is highly recommended that you install and activate the ``argcomplete`` python package.
It provides tab completion in ``bash`` for the ``ansible-test`` test runner.
Configuration
=============
Making your own version of ``integration_config.yml`` can allow for setting some
tunable parameters to help run the tests better in your environment. Some
tests (e.g. cloud) will only run when access credentials are provided. For
more information about supported credentials, refer to ``credentials.template``.
Prerequisites
=============
The tests will assume things like hg, svn, and git are installed and in path. Some tests
(such as those for Amazon Web Services) need separate definitions, which will be covered
later in this document.
(Complete list pending)
Non-destructive Tests
=====================
These tests will modify files in subdirectories, but will not do things that install or remove packages or things
outside of those test subdirectories. They will also not reconfigure or bounce system services.
.. note:: Running integration tests within Docker
To protect your system from any potential changes caused by integration tests, and to ensure the a sensible set of dependencies are available we recommend that you always run integration tests with the ``--docker`` option. See the `list of supported docker images <https://github.com/ansible/ansible/blob/devel/test/runner/completion/docker.txt>`_ for options.
.. note:: Avoiding pulling new Docker images
Use the ``--docker-no-pull`` option to avoid pulling the latest container image. This is required when using custom local images that are not available for download.
Run as follows for all POSIX platform tests executed by our CI system::
test/runner/ansible-test integration --docker fedora25 -v posix/ci/
You can select specific tests as well, such as for individual modules::
test/runner/ansible-test integration -v ping
By installing ``argcomplete`` you can obtain a full list by doing::
test/runner/ansible-test integration <tab><tab>
Destructive Tests
=================
These tests are allowed to install and remove some trivial packages. You will likely want to devote these
to a virtual environment, such as Docker. They won't reformat your filesystem::
test/runner/ansible-test integration --docker fedora25 -v destructive/
Windows Tests
=============
These tests exercise the ``winrm`` connection plugin and Windows modules. You'll
need to define an inventory with a remote Windows 2008 or 2012 Server to use
for testing, and enable PowerShell Remoting to continue.
Running these tests may result in changes to your Windows host, so don't run
them against a production/critical Windows environment.
Enable PowerShell Remoting (run on the Windows host via Remote Desktop)::
Enable-PSRemoting -Force
Define Windows inventory::
cp inventory.winrm.template inventory.winrm
${EDITOR:-vi} inventory.winrm
Run the Windows tests executed by our CI system::
test/runner/ansible-test windows-integration -v windows/ci/
Tests in Docker containers
==========================
If you have a Linux system with Docker installed, running integration tests using the same Docker containers used by
the Ansible continuous integration (CI) system is recommended.
.. note:: Docker on non-Linux
Using Docker Engine to run Docker on a non-Linux host (such as macOS) is not recommended.
Some tests may fail, depending on the image used for testing.
Using the ``--docker-privileged`` option may resolve the issue.
Running Integration Tests
-------------------------
To run all CI integration test targets for POSIX platforms in a Ubuntu 16.04 container::
test/runner/ansible-test integration -v posix/ci/ --docker
You can also run specific tests or select a different Linux distribution.
For example, to run tests for the ``ping`` module on a Ubuntu 14.04 container::
test/runner/ansible-test integration -v ping --docker ubuntu1404
Container Images
----------------
Python 2
````````
Most container images are for testing with Python 2:
- centos6
- centos7
- fedora24
- fedora25
- opensuse42.1
- opensuse42.2
- ubuntu1204
- ubuntu1404
- ubuntu1604
Python 3
````````
To test with Python 3 use the following images:
- ubuntu1604py3
Legacy Cloud Tests
==================
Some of the cloud tests run as normal integration tests, and others run as legacy tests; see the
:doc:`testing_integration_legacy` page for more information.
Other configuration for Cloud Tests
===================================
In order to run some tests, you must provide access credentials in a file named
``cloud-config-aws.yml`` or ``cloud-config-cs.ini`` in the test/integration
directory. Corresponding .template files are available for for syntax help. The newer AWS
tests now use the file test/integration/cloud-config-aws.yml
IAM policies for AWS
====================
Ansible needs fairly wide ranging powers to run the tests in an AWS account. This rights can be provided to a dedicated user. These need to be configured before running the test.
testing-iam-policy.json.j2
--------------------------
The testing-iam-policy.json.j2 file contains a policy which can be given to the user
running the tests to minimize the rights of that user. Please note that while this policy does limit the user to one region, this does not fully restrict the user (primarily due to the limitations of the Amazon ARN notation). The user will still have wide privileges for viewing account definitions, and will also able to manage some resources that are not related to testing (for example, AWS lambdas with different names). Tests should not be run in a primary production account in any case.
Other Definitions required
--------------------------
Apart from installing the policy and giving it to the user identity running the tests, a
lambda role `ansible_integration_tests` has to be created which has lambda basic execution
privileges.
Network Tests
=============
This page details the specifics around testing Ansible Networking modules.
.. important:: Network testing requirements for Ansible 2.4
Starting with Ansible 2.4, all network modules MUST include corresponding unit tests to defend functionality.
The unit tests must be added in the same PR that includes the new network module, or extends functionality.
Integration tests, although not required, are a welcome addition.
How to do this is explained in the rest of this document.
Network integration tests can be ran by doing::
cd test/integration
ANSIBLE_ROLES_PATH=targets ansible-playbook network-all.yaml
.. note::
* To run the network tests you will need a number of test machines and suitably configured inventory file. A sample is included in ``test/integration/inventory.network``
* As with the rest of the integration tests, they can be found grouped by module in ``test/integration/targets/MODULENAME/``
To filter a set of test cases set ``limit_to`` to the name of the group, generally this is the name of the module::
ANSIBLE_ROLES_PATH=targets ansible-playbook -i inventory.network network-all.yaml -e "limit_to=eos_command"
To filter a singular test case set the tags options to eapi or cli, set limit_to to the test group,
and test_cases to the name of the test::
ANSIBLE_ROLES_PATH=targets ansible-playbook -i inventory.network network-all.yaml --tags="cli" -e "limit_to=eos_command test_case=notequal"
Writing network integration tests
---------------------------------
Test cases are added to roles based on the module being testing. Test cases
should include both cli and API test cases. Cli test cases should be
added to ``test/integration/targets/modulename/tests/cli`` and API tests should be added to
``test/integration/targets/modulename/tests/eapi``, or ``nxapi``.
In addition to positive testing, negative tests are required to ensure user friendly warnings & errors are generated, rather than backtraces, for example:
.. code-block: yaml
- name: test invalid subset (foobar)
eos_facts:
provider: "{{ cli }}"
gather_subset:
- "foobar"
register: result
ignore_errors: true
- assert:
that:
# Failures shouldn't return changes
- "result.changed == false"
# It's a failure
- "result.failed == true"
# Sensible Failure message
- "'Subset must be one of' in result.msg"
Conventions
```````````
- Each test case should generally follow the pattern:
setup —> test —> assert —> test again (idempotent) —> assert —> teardown (if needed) -> done
This keeps test playbooks from becoming monolithic and difficult to
troubleshoot.
- Include a name for each task that is not an assertion. (It's OK to add names
to assertions too. But to make it easy to identify the broken task within a failed
test, at least provide a helpful name for each task.)
- Files containing test cases must end in `.yaml`
Adding a new Network Platform
`````````````````````````````
A top level playbook is required such as ``ansible/test/integration/eos.yaml`` which needs to be references by ``ansible/test/integration/network-all.yaml``
Where to find out more
======================
If you'd like to know more about the plans for improving testing Ansible then why not join the `Testing Working Group <https://github.com/ansible/community/blob/master/meetings/README.md>`_.

View file

@ -0,0 +1,105 @@
*******************************************
Testing using the Legacy Integration system
*******************************************
.. contents:: Topics
This page details how to run the integration tests that haven't been ported to the new ``ansible-test`` framework.
The following areas are still tested using the legacy ``make tests`` command:
* amazon (some)
* azure
* cloudflare
* cloudscale
* cloudstack
* consul
* exoscale
* gce
* jenkins
* rackspace
Over time the above list will be reduced as tests are ported to the ``ansible-test`` framework.
Running Cloud Tests
====================
Cloud tests exercise capabilities of cloud modules (e.g. ec2_key). These are
not 'tests run in the cloud' so much as tests that leverage the cloud modules
and are organized by cloud provider.
Some AWS tests may use environment variables. It is recommended to either unset any AWS environment variables( such as ``AWS_DEFAULT_PROFILE``, ``AWS_SECRET_ACCESS_KEY``, etc) or be sure that the environment variables match the credentials provided in ``credentials.yml`` to ensure the tests run with consistency to their full capability on the expected account. See `AWS CLI docs <http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html>`_ for information on creating a profile.
Subsets of tests may be run by ``#commenting`` out unnecessary roles in the appropriate playbook, such as ``test/integration/amazon.yml``.
In order to run cloud tests, you must provide access credentials in a file
named ``credentials.yml``. A sample credentials file named
``credentials.template`` is available for syntax help.
Provide cloud credentials::
cp credentials.template credentials.yml
${EDITOR:-vi} credentials.yml
Other configuration
===================
In order to run some tests, you must provide access credentials in a file named
``credentials.yml``. A sample credentials file named ``credentials.template`` is available
for syntax help.
IAM policies for AWS
====================
In order to run the tests in an AWS account ansible needs fairly wide ranging powers which
can be provided to a dedicated user or temporary credentials using a specific policy
configured in the AWS account.
testing-iam-policy.json.j2
--------------------------
The testing-iam-policy.json.j2 file contains a policy which can be given to the user
running the tests to give close to minimum rights required to run the tests. Please note
that this does not fully restrict the user; The user has wide privileges for viewing
account definitions and is also able to manage some resources that are not related to
testing (e.g. AWS lambdas with different names) primarily due to the limitations of the
Amazon ARN notation. At the very least the policy limits the user to one region, however
tests should not be run in a primary production account in any case.
Other Definitions required
--------------------------
Apart from installing the policy and giving it to the user identity running
the tests, a lambda role `ansible_integration_tests` has to be created which
has lambda basic execution privileges.
Running Tests
=============
The tests are invoked via a ``Makefile``.
If you haven't already got Ansible available use the local checkout by doing::
source hacking/env-setup
Run the tests by doing::
cd test/integration/
# TARGET is the name of the test from the list at the top of this page
#make TARGET
# e.g.
make amazon
# To run all cloud tests you can do:
make cloud
.. warning:: Possible cost of running cloud tests
Running cloud integration tests will create and destroy cloud
resources. Running these tests may result in additional fees associated with
your cloud account. Care is taken to ensure that created resources are
removed. However, it is advisable to inspect your AWS console to ensure no
unexpected resources are running.

View file

@ -0,0 +1,55 @@
*****
PEP 8
*****
.. contents:: Topics
`PEP 8`_ style guidelines are enforced by `pycodestyle`_ on all python files in the repository by default.
Current Rule Set
================
By default all files are tested using the current rule set.
All `PEP 8`_ tests are executed, except those listed in the `current ignore list`_.
.. warning: Updating the Rule Set
Changes to the Rule Set need approval from the Core Team, and must be done via the `Testing Working Group <https://github.com/ansible/community/blob/master/meetings/README.md>`_.
Legacy Rule Set
===============
Files which are listed in the `legacy file list`_ are tested using the legacy rule set.
All `PEP 8`_ tests are executed, except those listed in the `current ignore list`_ or `legacy ignore list`_.
Files listed in the legacy file list which pass the current rule set will result in an error.
This is intended to prevent regressions on style guidelines for files which pass the more stringent current rule set.
Skipping Tests
==============
Files listed in the `skip list`_ are not tested by `pycodestyle`_.
Removed Files
=============
Files which have been removed from the repository must be removed from the legacy file list and the skip list.
Running Locally
===============
The `PEP 8`_ check can be run locally with::
./test/runner/ansible-test sanity --test pep8 [file-or-directory-path-to-check] ...
.. _PEP 8: https://www.python.org/dev/peps/pep-0008/
.. _pycodestyle: https://pypi.python.org/pypi/pycodestyle
.. _current ignore list: https://github.com/ansible/ansible/blob/devel/test/sanity/pep8/current-ignore.txt
.. _legacy file list: https://github.com/ansible/ansible/blob/devel/test/sanity/pep8/legacy-files.txt
.. _legacy ignore list: https://github.com/ansible/ansible/blob/devel/test/sanity/pep8/legacy-ignore.txt
.. _skip list: https://github.com/ansible/ansible/blob/devel/test/sanity/pep8/skip.txt

View file

@ -0,0 +1,56 @@
***************
Testing Ansible
***************
.. contents:: Topics
This document describes how to:
* Run tests locally using ``ansible-test``
* Extend
Requirements
============
There are no special requirements for running ``ansible-test`` on Python 2.7 or later.
The ``argparse`` package is required for Python 2.6.
The requirements for each ``ansible-test`` command are covered later.
Test Environments
=================
Most ``ansible-test`` commands support running in one or more isolated test environments to simplify testing.
Remote
------
The ``--remote`` option runs tests in a cloud hosted environment.
An API key is required to use this feature.
Recommended for integration tests.
See the `list of supported platforms and versions <https://github.com/ansible/ansible/blob/devel/test/runner/completion/remote.txt>`_ for additional details.
Interactive Shell
=================
Use the ``ansible-test shell`` command to get an interactive shell in the same environment used to run tests. Examples:
* ``ansible-test shell --docker`` - Open a shell in the default docker container.
* ``ansible-test shell --tox --python 3.6`` - Open a shell in the Python 3.6 ``tox`` environment.
Code Coverage
=============
Add the ``--coverage`` option to any test command to collect code coverage data.
Reports can be generated in several different formats:
* ``ansible-test coverage report`` - Console report.
* ``ansible-test coverage html`` - HTML report.
* ``ansible-test coverage xml`` - XML report.
To clear data between test runs, use the ``ansible-test coverage erase`` command.

View file

@ -0,0 +1,75 @@
************
Sanity Tests
************
.. contents:: Topics
Sanity tests are made up of scripts and tools used to perform static code analysis.
The primary purpose of these tests is to enforce Ansible coding standards and requirements.
Tests are run with ``ansible-test sanity``.
All available tests are run unless the ``--test`` option is used.
Available Tests
===============
Tests can be listed with ``ansible-test sanity --list-tests``.
This list is a combination of two different categories of tests, "Code Smell" and "Built-in".
Code Smell Tests
----------------
Miscellaneous `scripts <https://github.com/ansible/ansible/tree/devel/test/sanity/code-smell/>`_ used for enforcing coding standards and requirements, identifying trip hazards, etc.
These tests are listed and accessed by script name. There is no actual test named ``code-smell``.
All executable scripts added to the ``code-smell`` directory are automatically detected and executed by ``ansible-test``.
Scripts in the directory which fail can be skipped by adding them to `skip.txt <https://github.com/ansible/ansible/blob/devel/test/sanity/code-smell/skip.txt>`_.
This is useful for scripts which identify issues that have not yet been resolved in the code base.
Files tested are specific to the individual test scripts and are not affected by command line arguments.
Built-in Tests
--------------
These tests are integrated directly into ``ansible-test``.
All files relevant to each test are tested unless specific files are specified.
A full list of tests can be obtained by doing ``ansible-test sanity --list-tests``.
ansible-doc
~~~~~~~~~~~
Verifies that ``ansible-doc`` can parse module documentation on all supported python versions.
pep8
~~~~
Python static analysis for PEP 8 style guideline compliance. See :doc:`testing_pep8` for more information.
pylint
~~~~~~
Python static analysis for common programming errors.
rstcheck
~~~~~~~~
Check reStructuredText files for syntax and formatting issues.
shellcheck
~~~~~~~~~~
Static code analysis for shell scripts using the excellent `shellcheck <https://www.shellcheck.net/>`_ tool.
validate-modules
~~~~~~~~~~~~~~~~
Analyze modules for common issues in code and documentation. See :doc:`testing_validate-modules` for more information.
yamllint
~~~~~~~~
Check YAML files for syntax and formatting issues.

View file

@ -0,0 +1,105 @@
**********
Unit Tests
**********
Unit tests are small isolated tests that target a specific library or module.
.. contents:: Topics
Available Tests
===============
Unit tests can be found in `test/units <https://github.com/ansible/ansible/tree/devel/test/units>`_, notice that the directory structure matches that of ``lib/ansible/``
Running Tests
=============
Unit tests can be run across the whole code base by doing:
.. code:: shell
cd /path/to/ansible/source
source hacking/env-setup
ansible-test units --tox
Against a single file by doing:
.. code:: shell
ansible-test units --tox apt
Or against a specific Python version by doing:
.. code:: shell
ansible-test units --tox --python 2.7 apt
For advanced usage see the online help::
ansible-test units --help
Installing dependencies
=======================
``ansible-test`` has a number of dependencies , for ``units`` tests we suggest using ``tox``
The dependencies can be installed using the ``--requirements`` argument, which will install all the required dependencies needed for unit tests. For example:
.. code:: shell
ansible-test units --tox --python 2.7 --requirements apache2_module
.. note:: tox version requirement
When using ``ansible-test`` with ``--tox`` requires tox >= 2.5.0
The full list of requirements can be found at `test/runner/requirements <https://github.com/ansible/ansible/tree/devel/test/runner/requirements>`_. Requirements files are named after their respective commands. See also the `constraints <https://github.com/ansible/ansible/blob/devel/test/runner/requirements/constraints.txt>`_ applicable to all commands.
Extending unit tests
====================
.. warning:: What a unit test isn't
If you start writing a test that requires external services then you may be writing an integration test, rather than a unit test.
Fixtures files
``````````````
To mock out fetching results from devices, you can use ``fixtures`` to read in pre-generated data.
Text files live in ``test/units/modules/network/PLATFORM/fixtures/``
Data is loaded using the ``load_fixture`` method
See `eos_banner test <https://github.com/ansible/ansible/blob/devel/test/units/modules/network/eos/test_eos_banner.py>`_ for a practical example.
Code Coverage
`````````````
Most ``ansible-test`` commands allow you to collect code coverage, this is particularly useful when to indicate where to extend testing.
To collect coverage data add the ``--coverage`` argument to your ``ansible-test`` command line:
.. code:: shell
ansible-test units --coverage apt
ansible-test coverage html
Results will be written to ``test/results/reports/coverage/index.html``
Reports can be generated in several different formats:
* ``ansible-test coverage report`` - Console report.
* ``ansible-test coverage html`` - HTML report.
* ``ansible-test coverage xml`` - XML report.
To clear data between test runs, use the ``ansible-test coverage erase`` command. For a full list of features see the online help::
ansible-test coverage --help

View file

@ -0,0 +1,183 @@
****************
validate-modules
****************
.. contents:: Topics
Python program to help test or validate Ansible modules.
``validate-modules`` is one of the ``ansible-test`` Sanity Tests, see :doc:`testing_sanity` for more information.
Originally developed by Matt Martz (@sivel)
Usage
=====
.. code:: shell
cd /path/to/ansible/source
source hacking/env-setup
ansible-test sanity --test validate-modules
Help
====
.. code:: shell
usage: validate-modules [-h] [-w] [--exclude EXCLUDE] [--arg-spec]
[--base-branch BASE_BRANCH] [--format {json,plain}]
[--output OUTPUT]
modules [modules ...]
positional arguments:
modules Path to module or module directory
optional arguments:
-h, --help show this help message and exit
-w, --warnings Show warnings
--exclude EXCLUDE RegEx exclusion pattern
--arg-spec Analyze module argument spec
--base-branch BASE_BRANCH
Used in determining if new options were added
--format {json,plain}
Output format. Default: "plain"
--output OUTPUT Output location, use "-" for stdout. Default "-"
Extending validate-modules
==========================
The ``validate-modules`` tool has a `schema.py <https://github.com/ansible/ansible/blob/devel/test/sanity/validate-modules/schema.py>`_ that is used to validate the YAML blocks, such as ``DOCUMENTATION`` and ``RETURNS``.
Codes
=====
Errors
------
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| code | sample message |
+=========+============================================================================================================================================+
| **1xx** | **Locations** |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 101 | Interpreter line is not ``#!/usr/bin/python`` |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 102 | Interpreter line is not ``#!powershell`` |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 103 | Did not find a call to ``main()`` |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 104 | Call to ``main()`` not the last line |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 105 | GPLv3 license header not found |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 106 | Import found before documentation variables. All imports must appear below ``DOCUMENTATION``/``EXAMPLES``/``RETURN``/``ANSIBLE_METADATA`` |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 107 | Imports should be directly below ``DOCUMENTATION``/``EXAMPLES``/``RETURN``/``ANSIBLE_METADATA`` |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| **2xx** | **Imports** |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 201 | Did not find a ``module_utils`` import |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 203 | ``requests`` import found, should use ``ansible.module_utils.urls`` instead |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 204 | ``boto`` import found, new modules should use ``boto3`` |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 205 | ``sys.exit()`` call found. Should be ``exit_json``/``fail_json`` |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 206 | ``WANT_JSON`` not found in module |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 207 | ``REPLACER_WINDOWS`` not found in module |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 208 | ``module_utils`` imports should import specific components, not ``*`` |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| **3xx** | **Documentation** |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 301 | No ``DOCUMENTATION`` provided |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 302 | ``DOCUMENTATION`` is not valid YAML |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 303 | ``DOCUMENTATION`` fragment missing |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 304 | Unknown ``DOCUMENTATION`` error |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 305 | Invalid ``DOCUMENTATION`` schema |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 306 | Module level ``version_added`` is not a valid version number |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 307 | Module level ``version_added`` is incorrect |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 308 | ``version_added`` for new option is not a valid version number |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 309 | ``version_added`` for new option is incorrect |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 310 | No ``EXAMPLES`` provided |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 311 | ``EXAMPLES`` is not valid YAML |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 312 | No ``RETURN`` documentation provided |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 313 | ``RETURN`` is not valid YAML |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 314 | No ``ANSIBLE_METADATA`` provided |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 315 | ``ANSIBLE_METADATA`` is not valid YAML |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 316 | Invalid ``ANSIBLE_METADATA`` schema |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 317 | option is marked as required but specifies a default. Arguments with a default should not be marked as required |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 318 | Module deprecated, but DOCUMENTATION.deprecated is missing |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 319 | ``RETURN`` fragments missing or invalid |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| **4xx** | **Syntax** |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 401 | Python ``SyntaxError`` while parsing module |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 402 | Indentation contains tabs |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 403 | Type comparison using ``type()`` found. Use ``isinstance()`` instead |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| **5xx** | **Naming** |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 501 | Official Ansible modules must have a ``.py`` extension for python modules or a ``.ps1`` for powershell modules |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 502 | Ansible module subdirectories must contain an ``__init__.py`` |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 503 | Missing python documentation file |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
Warnings
--------
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| code | sample message |
+=========+============================================================================================================================================+
| **1xx** | **Locations** |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 107 | Imports should be directly below ``DOCUMENTATION``/``EXAMPLES``/``RETURN``/``ANSIBLE_METADATA`` for legacy modules |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| **2xx** | **Imports** |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 208 | ``module_utils`` imports should import specific components for legacy module, not ``*`` |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 291 | Try/Except ``HAS_`` expression missing |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 292 | Did not find ``ansible.module_utils.basic`` import |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| **3xx** | **Documentation** |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 312 | No ``RETURN`` documentation provided for legacy module |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 391 | Unknown pre-existing ``DOCUMENTATION`` error |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+
| 392 | Pre-existing ``DOCUMENTATION`` fragment missing |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------+

View file

@ -119,10 +119,9 @@ used when executing python modules. Thus, you can point to any python you want
system does not point to a Python 2.X interpreter.
Some Linux operating systems, such as Arch, may only have Python 3 installed by default. This is not sufficient and you will
get syntax errors trying to run modules with Python 3. Python 3 is essentially not the same
language as Python 2. Ansible modules currently need to support older Pythons for users that still have Enterprise Linux 5 deployed, so they are not yet ported to run under Python 3.0. This is not a problem though as you can just install Python 2 also on a managed host.
Python 3.0 support will likely be addressed at a later point in time when usage becomes more mainstream.
get syntax errors trying to run modules with Python 3. Python 3 is essentially not the same language as Python 2. Python 3
support is being worked on but some Ansible modules are not yet ported to run under Python 3.0. This is not a problem though
as you can just install Python 2 also on a managed host.
Do not replace the shebang lines of your python modules. Ansible will do this for you automatically at deploy time.

View file

@ -0,0 +1,309 @@
**********************************
Using Ansible with the Packet host
**********************************
Introduction
============
`Packet.net <https://packet.net>`_ is a bare metal infrastructure host that's supported by Ansible (>=2.3) via a dynamic inventory script and two cloud modules. The two modules are:
- packet_sshkey: adds a public SSH key from file or value to the Packet infrastructure. Every subsequently-created device will have this public key installed in .ssh/authorized_keys.
- packet_device: manages servers on Packet. You can use this module to create, restart and delete devices.
Note, this guide assumes you are familiar with Ansible and how it works. If you're not, have a look at their `docs <http://docs.ansible.com/>`_ before getting started.
Requirements
============
The Packet modules and inventory script connect to the Packet API using the packet-python package. You can install it with pip:
.. code-block:: bash
$ pip install packet-python
In order to check the state of devices created by Ansible on Packet, it's a good idea to install one of the `Packet CLI clients <https://www.packet.net/developers/integrations/api-cli/>`_. Otherwise you can check them via the `Packet portal <https://app.packet.net/portal>`_.
To use the modules and inventory script you'll need a Packet API token. You can generate an API token via the Packet portal `here <https://app.packet.net/portal#/api-keys>`__. The simplest way to authenticate yourself is to set the Packet API token in an environment variable:
.. code-block:: bash
$ export PACKET_API_TOKEN=Bfse9F24SFtfs423Gsd3ifGsd43sSdfs
If you're not comfortable exporting your API token, you can pass it as a parameter to the modules.
On Packet, devices and reserved IP addresses belong to `projects <https://www.packet.net/developers/api/projects/>`_. In order to use the packet_device module, you need to specify the UUID of the project in which you want to create or manage devices. You can find a project's UUID in the Packet portal `here <https://app.packet.net/portal#/projects/list/table/>`_ (it's just under the project table) or via one of the available `CLIs <https://www.packet.net/developers/integrations/api-cli/>`_.
If you want to use a new SSH keypair in this tutorial, you can generate it to ``./id_rsa`` and ``./id_rsa.pub`` as:
.. code-block:: bash
$ ssh-keygen -t rsa -f ./id_rsa
If you want to use an existing keypair, just copy the private and public key over to the playbook directory.
Device Creation
===============
The following code block is a simple playbook that creates one `Type 0 <https://www.packet.net/bare-metal/servers/type-0/>`_ server (the 'plan' parameter). You have to supply 'plan' and 'operating_system'. 'location' defaults to 'ewr1' (Parsippany, NJ). You can find all the possible values for the parameters via a `CLI client <https://www.packet.net/developers/integrations/api-cli/>`_.
.. code-block:: yaml
# playbook_create.yml
- name: create ubuntu device
hosts: localhost
tasks:
- packet_sshkey:
key_file: ./id_rsa.pub
label: tutorial key
- packet_device:
project_id: <your_project_id>
hostnames: myserver
operating_system: ubuntu_16_04
plan: baremetal_0
facility: sjc1
After running ``ansible-playbook playbook_create.yml``, you should have a server provisioned on Packet. You can verify via a CLI or in the `Packet portal <https://app.packet.net/portal#/projects/list/table>`__.
If you get an error with the message "failed to set machine state present, error: Error 404: Not Found", please verify your project UUID.
Updating Devices
================
The two parameters used to uniquely identify Packet devices are: "device_ids" and "hostnames". Both parameters accept either a single string (later converted to a one-element list), or a list of strings.
The 'device_ids' and 'hostnames' parameters are mutually exclusive. The following values are all acceptable:
- device_ids: a27b7a83-fc93-435b-a128-47a5b04f2dcf
- hostnames: mydev1
- device_ids: [a27b7a83-fc93-435b-a128-47a5b04f2dcf, 4887130f-0ccd-49a0-99b0-323c1ceb527b]
- hostnames: [mydev1, mydev2]
In addition, hostnames can contain a special '%d' formatter along with a 'count' parameter that lets you easily expand hostnames that follow a simple name and number pattern; i.e. ``hostnames: "mydev%d", count: 2`` will expand to [mydev1, mydev2].
If your playbook acts on existing Packet devices, you can only pass the 'hostname' and 'device_ids' parameters. The following playbook shows how you can reboot a specific Packet device by setting the 'hostname' parameter:
.. code-block:: yaml
# playbook_reboot.yml
- name: reboot myserver
hosts: localhost
tasks:
- packet_device:
project_id: <your_project_id>
hostnames: myserver
state: rebooted
You can also identify specific Packet devices with the 'device_ids' parameter. The device's UUID can be found in the `Packet Portal <https://app.packet.net/portal>`_ or by using a `CLI <https://www.packet.net/developers/integrations/api-cli/>`_. The following playbook removes a Packet device using the 'device_ids' field:
.. code-block:: yaml
# playbook_remove.yml
- name: remove a device
hosts: localhost
tasks:
- packet_device:
project_id: <your_project_id>
device_ids: <myserver_device_id>
state: absent
More Complex Playbooks
======================
In this example, we'll create a CoreOS cluster with `user data <https://support.packet.net/en/support/solutions/articles/22000058261-the-basics-of-cloud-config-and-user-data>`_.
The CoreOS cluster will use `etcd <https://coreos.com/etcd/>`_ for discovery of other servers in the cluster. Before provisioning your servers, you'll need to generate a discovery token for your cluster:
.. code-block:: bash
$ curl -w "\n" 'https://discovery.etcd.io/new?size=3'
The following playbook will create an SSH key, 3 Packet servers, and then wait until SSH is ready (or until 5 minutes passed). Make sure to substitute the discovery token URL in 'user_data', and the 'project_id' before running ``ansible-playbook``. Also, feel free to change 'plan' and 'facility'.
.. code-block:: yaml
# playbook_coreos.yml
- name: Start 3 CoreOS nodes in Packet and wait until SSH is ready
hosts: localhost
tasks:
- packet_sshkey:
key_file: ./id_rsa.pub
label: new
- packet_device:
hostnames: [coreos-one, coreos-two, coreos-three]
operating_system: coreos_beta
plan: baremetal_0
facility: ewr1
project_id: <your_project_id>
wait: true
user_data: |
#cloud-config
coreos:
etcd2:
discovery: https://discovery.etcd.io/<token>
advertise-client-urls: http://$private_ipv4:2379,http://$private_ipv4:4001
initial-advertise-peer-urls: http://$private_ipv4:2380
listen-client-urls: http://0.0.0.0:2379,http://0.0.0.0:4001
listen-peer-urls: http://$private_ipv4:2380
fleet:
public-ip: $private_ipv4
units:
- name: etcd2.service
command: start
- name: fleet.service
command: start
register: newhosts
- name: wait for ssh
wait_for:
delay: 1
host: "{{ item.public_ipv4 }}"
port: 22
state: started
timeout: 500
with_items: "{{ newhosts.devices }}"
As with most Ansible modules, the default states of the Packet modules are idempotent, meaning the resources in your project will remain the same after re-runs of a playbook. Thus, we can keep the ``packet_sshkey`` module call in our playbook. If the public key is already in your Packet account, the call will have no effect.
The second module call provisions 3 Packet Type 0 (specified using the 'plan' parameter) servers in the project identified via the 'project_id' parameter. The servers are all provisioned with CoresOS beta (the 'operating_system' parameter) and are customized with cloud-config user data passed to the 'user_data' parameter.
The ``packet_device`` module has a boolean 'wait' parameter that defaults to 'false'. If set to 'true', Ansible will wait until the GET API call for a device will contain an Internet-routeable IP address. The 'wait' parameter allows us to use the IP address of the device as soon as it's available.
Run the playbook:
.. code-block:: bash
$ ansible-playbook playbook_coreos.yml
Once the playbook quits, your new devices should be reachable via SSH. Try to connect to one and check if etcd has started properly:
.. code-block:: bash
tomk@work $ ssh -i id_rsa core@$one_of_the_servers_ip
core@coreos-one ~ $ etcdctl cluster-health
Once you create a couple of devices, you might appreciate the dynamic inventory script...
Dynamic Inventory Script
========================
The dynamic inventory script queries the Packet API for a list of hosts, and exposes it to Ansible so you can easily identify and act on Packet devices. You can find it in Ansible's git repo at `contrib/inventory/packet_net.py <https://github.com/ansible/ansible/blob/devel/contrib/inventory/packet_net.py>`_.
The inventory script is configurable via a `ini file <https://github.com/ansible/ansible/blob/devel/contrib/inventory/packet_net.ini>`_.
If you want to use the inventory script, you must first export your Packet API token to a PACKET_API_TOKEN environment variable.
You can either copy the inventory and ini config out from the cloned git repo, or you can download it to your working directory like so:
.. code-block:: bash
$ wget https://github.com/ansible/ansible/raw/devel/contrib/inventory/packet_net.py
$ chmod +x packet_net.py
$ wget https://github.com/ansible/ansible/raw/devel/contrib/inventory/packet_net.ini
In order to understand what the inventory script gives to Ansible you can run:
.. code-block:: bash
$ ./packet_net.py --list
It should print a JSON document looking similar to following trimmed dictionary:
.. code-block:: json
{
"_meta": {
"hostvars": {
"147.75.64.169": {
"packet_billing_cycle": "hourly",
"packet_created_at": "2017-02-09T17:11:26Z",
"packet_facility": "ewr1",
"packet_hostname": "coreos-two",
"packet_href": "/devices/d0ab8972-54a8-4bff-832b-28549d1bec96",
"packet_id": "d0ab8972-54a8-4bff-832b-28549d1bec96",
"packet_locked": false,
"packet_operating_system": "coreos_beta",
"packet_plan": "baremetal_0",
"packet_state": "active",
"packet_updated_at": "2017-02-09T17:16:35Z",
"packet_user": "core",
"packet_userdata": "#cloud-config\ncoreos:\n etcd2:\n discovery: https://discovery.etcd.io/e0c8a4a9b8fe61acd51ec599e2a4f68e\n advertise-client-urls: http://$private_ipv4:2379,http://$private_ipv4:4001\n initial-advertise-peer-urls: http://$private_ipv4:2380\n listen-client-urls: http://0.0.0.0:2379,http://0.0.0.0:4001\n listen-peer-urls: http://$private_ipv4:2380\n fleet:\n public-ip: $private_ipv4\n units:\n - name: etcd2.service\n command: start\n - name: fleet.service\n command: start"
}
}
},
"baremetal_0": [
"147.75.202.255",
"147.75.202.251",
"147.75.202.249",
"147.75.64.129",
"147.75.192.51",
"147.75.64.169"
],
"coreos_beta": [
"147.75.202.255",
"147.75.202.251",
"147.75.202.249",
"147.75.64.129",
"147.75.192.51",
"147.75.64.169"
],
"ewr1": [
"147.75.64.129",
"147.75.192.51",
"147.75.64.169"
],
"sjc1": [
"147.75.202.255",
"147.75.202.251",
"147.75.202.249"
],
"coreos-two": [
"147.75.64.169"
],
"d0ab8972-54a8-4bff-832b-28549d1bec96": [
"147.75.64.169"
]
}
In the ``['_meta']['hostvars']`` key, there is a list of devices (uniquely identified by their public IPv4 address) with their parameters. The other keys under ``['_meta']`` are lists of devices grouped by some parameter. Here, it is type (all devices are of type baremetal_0), operating system, and facility (ewr1 and sjc1).
In addition to the parameter groups, there are also one-item groups with the UUID or hostname of the device.
You can now target groups in playbooks! The following playbook will install a role that supplies resources for an Ansible target into all devices in the "coreos_beta" group:
.. code-block:: yaml
# playbook_bootstrap.yml
- hosts: coreos_beta
gather_facts: false
roles:
- defunctzombie.coreos-boostrap
Don't forget to supply the dynamic inventory in the ``-i`` argument!
.. code-block:: bash
$ ansible-playbook -u core -i packet_net.py playbook_bootstrap.yml
If you have any questions or comments let us know! help@packet.net

View file

@ -14,5 +14,6 @@ This section is new and evolving. The idea here is to explore particular use ca
guide_vagrant
guide_rolling_upgrade
guide_docker
guide_packet
Pending topics may include: Docker, Jenkins, Google Compute Engine, Linode/DigitalOcean, Continuous Deployment, and more.

View file

@ -7,7 +7,7 @@ About Ansible
Welcome to the Ansible documentation!
Ansible is an IT automation tool. It can configure systems, deploy software, and orchestrate more advanced IT tasks
such as continuous deployments or zero downtime rolling updates.
such as continuous deployments or zero downtime rolling updates.
Ansible's main goals are simplicity and ease-of-use. It also has a strong focus on security and reliability, featuring a minimum of moving parts, usage of OpenSSH for transport (with an accelerated socket mode and pull modes as alternatives), and a language that is designed around auditability by humans--even those not familiar with the program.
@ -16,7 +16,7 @@ We believe simplicity is relevant to all sizes of environments, so we design for
Ansible manages machines in an agent-less manner. There is never a question of how to
upgrade remote daemons or the problem of not being able to manage systems because daemons are uninstalled. Because OpenSSH is one of the most peer-reviewed open source components, security exposure is greatly reduced. Ansible is decentralized--it relies on your existing OS credentials to control access to remote machines. If needed, Ansible can easily connect with Kerberos, LDAP, and other centralized authentication management systems.
This documentation covers the current released version of Ansible (|version|) and also some development version features (|versiondev|). For recent features, we note in each section the version of Ansible where the feature was added.
This documentation covers the current released version of Ansible (|version|) and also some development version features (|versiondev|). For recent features, we note in each section the version of Ansible where the feature was added.
Ansible, Inc. releases a new major release of Ansible approximately every two months. The core application evolves somewhat conservatively, valuing simplicity in language design and setup. However, the community around new modules and plugins being developed and contributed moves very quickly, typically adding 20 or so new modules in each release.
@ -33,13 +33,13 @@ Ansible, Inc. releases a new major release of Ansible approximately every two mo
modules_by_category
guides
dev_guide/index
community/index
tower
community
galaxy
test_strategies
faq
glossary
YAMLSyntax
porting_guide_2.0
porting_guides
python_3_support
release_and_maintenance

View file

@ -86,6 +86,20 @@ different locations::
Most users will not need to use this feature. See :doc:`dev_guide/developing_plugins` for more details.
.. _allow_unsafe_lookups:
allow_unsafe_lookups
====================
.. versionadded:: 2.2.3, 2.3.1
When enabled, this option allows lookup plugins (whether used in variables as `{{lookup('foo')}}` or as a loop as `with_foo`) to return data that is **not** marked "unsafe". By default, such data is marked as unsafe to prevent the templating engine from evaluating any jinja2 templating language, as this could represent a security risk.
This option is provided to allow for backwards-compatibility, however users should first consider adding `allow_unsafe=True` to any lookups which may be expected to contain data which may be run through the templating engine later. For example::
{{lookup('pipe', '/path/to/some/command', allow_unsafe=True)}}
.. _allow_world_readable_tmpfiles:
allow_world_readable_tmpfiles

View file

@ -270,7 +270,7 @@ Then install Ansible with [1]_::
Or if you are looking for the latest development version::
pip install git+git://github.com/ansible/ansible.git@devel
pip install git+https://github.com/ansible/ansible.git@devel
If you are installing on OS X Mavericks, you may encounter some noise from your compiler. A workaround is to do the following::
@ -285,8 +285,6 @@ Tarballs of Tagged Releases
Packaging Ansible or wanting to build a local package yourself, but don't want to do a git checkout? Tarballs of releases are available on the `Ansible downloads <http://releases.ansible.com/ansible>`_ page.
These releases are also tagged in the `git repository <https://github.com/ansible/ansible/releases>`_ with the release version.
.. _from_source:
Running From Source

View file

@ -169,9 +169,9 @@ Ansible allows you to use conditionals to control the flow of your playbooks. An
* contains - Object contains specified item
Conditional statements evalute the results from the commands that are
Conditional statements evaluate the results from the commands that are
executed remotely on the device. Once the task executes the command
set, the waitfor argument can be used to evalute the results before
set, the wait_for argument can be used to evaluate the results before
returning control to the Ansible playbook.
For example::

View file

@ -107,13 +107,13 @@ Edit your /etc/krb5.conf (which should be installed as a result of installing pa
In the section that starts with
.. code-block:: bash
.. code-block:: ini
[realms]
add the full domain name and the fully qualified domain names of your primary and secondary Active Directory domain controllers. It should look something like this:
.. code-block:: bash
.. code-block:: ini
[realms]
@ -125,7 +125,7 @@ add the full domain name and the fully qualified domain names of your primary an
and in the [domain_realm] section add a line like the following for each domain you want to access:
.. code-block:: bash
.. code-block:: ini
[domain_realm]
.my.domain.com = MY.DOMAIN.COM

View file

@ -26,8 +26,7 @@ Curated
Some examples of Curated modules are submitted by other companies or maintained by the community. Maintainers of these types of modules must watch for any issues reported or pull requests raised against the module.
Core Committers will review all modules becoming Curated or updates to existing Curated modules. Core committers will also ensure that any issues that arise due to Ansible engine changes will be remediated.
Core Committers will review all modules becoming Curated. Core Committers will review proposed changes to existing Curated modules once the community maintainers of the module have approved the changes. Core committers will also ensure that any issues that arise due to Ansible engine changes will be remediated.
Also, it is strongly recommended (but not presently required) for these types of modules to have unit tests.
These modules are currently shipped with Ansible, but might be shipped separately in the future.

View file

@ -0,0 +1,474 @@
.. _network_debug_troubleshooting:
***************************************
Network Debug and Troubleshooting Guide
***************************************
.. contents:: Topics
Introduction
============
Starting with Ansible version 2.1, you can now use the familiar Ansible models of playbook authoring and module development to manage heterogeneous networking devices. Ansible supports a growing number of network devices using both CLI over SSH and API (when available) transports.
This section discusses how to debug and troubleshoot network modules in Ansible 2.3.
How to troubleshoot
===================
This section covers troubleshooting issues with Network Modules.
Errors generally fall into one of the following categories:
:Authentication issues:
* Not correctly specifying credentials
* Remote device (network switch/router) not falling back to other other authentication methods
* SSH key issues
:Timeout issues:
* Can occur when trying to pull a large amount of data
* May actually be masking a authentication issue
:Playbook issues:
* Use of ``delegate_to``, instead of ``ProxyCommand``
* Not using ``connection: local``
.. warning:: ``unable to open shell``
The ``unable to open shell`` message is new in Ansible 2.3, it means that the ``ansible-connection`` daemon has not been able to successfully
talk to the remote network device. This generally means that there is an authentication issue. See the "Authentication and connection issues" section
in this document for more information.
.. _enable_network_logging:
Enabling Networking logging and how to read the logfile
-------------------------------------------------------
**Platforms:** Any
Ansible 2.3 features improved logging to help diagnose and troubleshoot issues regarding Ansible Networking modules.
Because logging is very verbose it is disabled by default. It can be enabled via the ``ANSIBLE_LOG_PATH`` and ``ANISBLE_DEBUG`` options::
# Specify the location for the log file
export ANSIBLE_LOG_PATH=~/ansible.log
# Enable Debug
export ANSIBLE_DEBUG=True
# Run with 4*v for connection level verbosity
ansible-playbook -vvvv ...
After Ansible has finished running you can inspect the log file:
.. code::
2017-03-30 13:19:52,740 p=28990 u=fred | creating new control socket for host veos01:22 as user admin
2017-03-30 13:19:52,741 p=28990 u=fred | control socket path is /home/fred/.ansible/pc/ca5960d27a
2017-03-30 13:19:52,741 p=28990 u=fred | current working directory is /home/fred/ansible/test/integration
2017-03-30 13:19:52,741 p=28990 u=fred | using connection plugin network_cli
...
2017-03-30 13:20:14,771 paramiko.transport userauth is OK
2017-03-30 13:20:15,283 paramiko.transport Authentication (keyboard-interactive) successful!
2017-03-30 13:20:15,302 p=28990 u=fred | ssh connection done, setting terminal
2017-03-30 13:20:15,321 p=28990 u=fred | ssh connection has completed successfully
2017-03-30 13:20:15,322 p=28990 u=fred | connection established to veos01 in 0:00:22.580626
From the log notice:
* ``p=28990`` Is the PID (Process ID) of the ``ansible-connection`` process
* ``u=fred`` Is the user `running` ansible, not the remote-user you are attempting to connect as
* ``creating new control socket for host veos01:22 as user admin`` host:port as user
* ``control socket path is`` location on disk where the persistent connection socket is created
* ``using connection plugin network_cli`` Informs you that persistent connection is being used
* ``connection established to veos01 in 0:00:22.580626`` Time taken to obtain a shell on the remote device
.. note: Port None ``creating new control socket for host veos01:None``
If the log reports the port as ``None`` this means that the default port is being used.
A future Ansible release will improve this message so that the port is always logged.
Because the log files are verbose, you can use grep to look for specific information. For example, once you have identified the ```pid`` from the ``creating new control socket for host`` line you can search for other connection log entries::
grep "p=28990" $ANSIBLE_LOG_PATH
Isolating an error
------------------
**Platforms:** Any
As with any effort to troubleshoot it's important to simplify the test case as much as possible.
For Ansible this can be done by ensuring you are only running against one remote device:
* Using ``ansible-playbook --limit switch1.example.net...``
* Using an ad-hoc ``ansible`` command
`ad-hoc` refers to running Ansible to perform some quick command using ``/usr/bin/ansible``, rather than the orchestration language, which is ``/usr/bin/ansible-playbook``. In this case we can ensure connectivity by attempting to execute a single command on the remote device::
ansible -m eos_command -a 'commands=?' -i inventory switch1.example.net -e 'ansible_connection=local' -u admin -k
In the above example, we:
* connect to ``switch1.example.net`` specified in the inventory file ``inventory``
* use the module ``eos_command``
* run the command ``?``
* connect using the username ``admin``
* inform ansible to prompt for the ssh password by specifying ``-k``
If you have SSH keys configured correctly, you don't need to specify the ``-k`` parameter
If the connection still fails you can combine it with the enable_network_logging parameter. For example::
# Specify the location for the log file
export ANSIBLE_LOG_PATH=~/ansible.log
# Enable Debug
export ANSIBLE_DEBUG=True
# Run with 4*v for connection level verbosity
ansible -m eos_command -a 'commands=?' -i inventory switch1.example.net -e 'ansible_connection=local' -u admin -k
Then review the log file and find the relevant error message in the rest of this document.
.. For details on other ways to authenticate, see LINKTOAUTHHOWTODOCS.
.. _unable_to_open_shell:
Category "Unable to open shell"
===============================
**Platforms:** Any
The ``unable to open shell`` message is new in Ansible 2.3. This message means that the ``ansible-connection`` daemon has not been able to successfully talk to the remote network device. This generally means that there is an authentication issue. It is a "catch all" message, meaning you need to enable ``ANSIBLE_LOG_PATH`` to find the underlying issues.
For example:
.. code-block:: none
TASK [prepare_eos_tests : enable cli on remote device] **************************************************
fatal: [veos01]: FAILED! => {"changed": false, "failed": true, "msg": "unable to open shell"}
or:
.. code-block:: none
TASK [ios_system : configure name_servers] *************************************************************
task path:
fatal: [ios-csr1000v]: FAILED! => {
"changed": false,
"failed": true,
"msg": "unable to open shell",
"rc": 255
}
Suggestions to resolve:
Follow the steps detailed in enable_network_logging_.
Once you've identified the error message from the log file, the specific solution can be found in the rest of this document.
Error: "[Errno -2] Name or service not known"
---------------------------------------------
**Platforms:** Any
Indicates that the remote host you are trying to connect to can not be reached
For example:
.. code-block:: yaml
2017-04-04 11:39:48,147 p=15299 u=fred | control socket path is /home/fred/.ansible/pc/ca5960d27a
2017-04-04 11:39:48,147 p=15299 u=fred | current working directory is /home/fred/git/ansible-inc/stable-2.3/test/integration
2017-04-04 11:39:48,147 p=15299 u=fred | using connection plugin network_cli
2017-04-04 11:39:48,340 p=15299 u=fred | connecting to host veos01 returned an error
2017-04-04 11:39:48,340 p=15299 u=fred | [Errno -2] Name or service not known
Suggestions to resolve:
* If you are using the ``provider:`` options ensure that it's suboption ``host:`` is set correctly.
* If you are not using ``provider:`` nor top-level arguments ensure your inventory file is correct.
Error: "Authentication failed"
------------------------------
**Platforms:** Any
Occurs if the credentials (username, passwords, or ssh keys) passed to ``ansible-connection`` (via ``ansible`` or ``ansible-playbook``) can not be used to connect to the remote device.
For example:
.. code-block:: yaml
<ios01> ESTABLISH CONNECTION FOR USER: cisco on PORT 22 TO ios01
<ios01> Authentication failed.
Suggestions to resolve:
If you are specifying credentials via ``password:`` (either directly or via ``provider:``) or the environment variable ``ANSIBLE_NET_PASSWORD`` it is possible that ``paramiko`` (the Python SSH library that Ansible uses) is using ssh keys, and therefore the credentials you are specifying are being ignored. To find out if this is the case, disable "look for keys". This can be done like this:
.. code-block:: yaml
export ANSIBLE_PARAMIKO_LOOK_FOR_KEYS=False
To make this a permanent change, add the following to your ``ansible.cfg`` file:
.. code-block:: ini
[paramiko_connection]
look_for_keys = False
Error: "connecting to host <hostname> returned an error" or "Bad address"
-------------------------------------------------------------------------
This may occur if the SSH fingerprint hasn't been added to Paramiko's (the Python SSH library) know hosts file.
When using persistent connections with Paramiko, the connection runs in a background process. If the host doesn't already have a valid SSH key, by default Ansible will prompt to add the host key. This will cause connections running in background processes to fail.
For example:
.. code-block:: yaml
2017-04-04 12:06:03,486 p=17981 u=fred | using connection plugin network_cli
2017-04-04 12:06:04,680 p=17981 u=fred | connecting to host veos01 returned an error
2017-04-04 12:06:04,682 p=17981 u=fred | (14, 'Bad address')
2017-04-04 12:06:33,519 p=17981 u=fred | number of connection attempts exceeded, unable to connect to control socket
2017-04-04 12:06:33,520 p=17981 u=fred | persistent_connect_interval=1, persistent_connect_retries=30
Suggestions to resolve:
Use ``ssh-keyscan`` to pre-populate the known_hosts. You need to ensure the keys are correct.
.. code-block:: shell
ssh-keyscan veos01
or
You can tell Ansible to automatically accept the keys
Environment variable method::
export ANSIBLE_PARAMIKO_HOST_KEY_AUTO_ADD=True
ansible-playbook ...
``ansible.cfg`` method:
ansible.cfg
.. code-block: ini
[paramiko_connection]
host_key_auto_add = True
.. warning: Security warning
Care should be taken before accepting keys.
Error: "No authentication methods available"
--------------------------------------------
For example:
.. code-block:: yaml
2017-04-04 12:19:05,670 p=18591 u=fred | creating new control socket for host veos01:None as user admin
2017-04-04 12:19:05,670 p=18591 u=fred | control socket path is /home/fred/.ansible/pc/ca5960d27a
2017-04-04 12:19:05,670 p=18591 u=fred | current working directory is /home/fred/git/ansible-inc/ansible-workspace-2/test/integration
2017-04-04 12:19:05,670 p=18591 u=fred | using connection plugin network_cli
2017-04-04 12:19:06,606 p=18591 u=fred | connecting to host veos01 returned an error
2017-04-04 12:19:06,606 p=18591 u=fred | No authentication methods available
2017-04-04 12:19:35,708 p=18591 u=fred | number of connection attempts exceeded, unable to connect to control socket
2017-04-04 12:19:35,709 p=18591 u=fred | persistent_connect_interval=1, persistent_connect_retries=30
Suggestions to resolve:
No password or SSH key supplied
Clearing Out Persistent Connections
-----------------------------------
**Platforms:** Any
In Ansible 2.3, persistent connection sockets are stored in ``~/.ansible/pc`` for all network devices. When an Ansible playbook runs, the persistent socket connection is displayed when verbose output is specified.
``<switch> socket_path: /home/fred/.ansible/pc/f64ddfa760``
To clear out a persistent connection before it times out (the default timeout is 30 seconds
of inactivity), simple delete the socket file.
Timeout issues
==============
Timeouts
--------
All network modules support a timeout value that can be set on a per task
basis. The timeout value controls the amount of time in seconds before the
task will fail if the command has not returned.
For example:
.. FIXME: Detail error here
Suggestions to resolve:
.. code-block:: yaml
- name: save running-config
ios_command:
commands: copy running-config startup-config
provider: "{{ cli }}"
timeout: 30
Some operations take longer than the default 10 seconds to complete. One good
example is saving the current running config on IOS devices to startup config.
In this case, changing the timeout value form the default 10 seconds to 30
seconds will prevent the task from failing before the command completes
successfully.
Playbook issues
===============
This section details issues are caused by issues with the Playbook itself.
Error: "invalid connection specified, expected connection=local, got ssh"
-------------------------------------------------------------------------
**Platforms:** Any
Network modules require that the connection is set to ``local``. Any other
connection setting will cause the playbook to fail. Ansible will now detect
this condition and return an error message:
.. code-block:: yaml
fatal: [nxos01]: FAILED! => {
"changed": false,
"failed": true,
"msg": "invalid connection specified, expected connection=local, got ssh"
}
To fix this issue, set the connection value to ``local`` using one of the
following methods:
* Set the play to use ``connection: local``
* Set the task to use ``connection: local``
* Run ansible-playbook using the ``-c local`` setting
Error: "Unable to enter configuration mode"
-------------------------------------------
**Platforms:** eos and ios
This occurs when you attempt to run a task that requires privileged mode in a user mode shell.
For example:
.. code-block:: yaml
TASK [ios_system : configure name_servers] *****************************************************************************
task path:
fatal: [ios-csr1000v]: FAILED! => {
"changed": false,
"failed": true,
"msg": "unable to enter configuration mode",
"rc": 255
}
Suggestions to resolve:
Add ``authorize: yes`` to the task. For example:
.. code-block:: yaml
- name: configure hostname
ios_system:
provider:
hostname: foo
authorize: yes
register: result
If the user requires a password to go into privileged mode, this can be specified with ``auth_pass``; if ``auth_pass`` isn't set, the environment variable ``ANSIBLE_NET_AUTHORIZE`` will be used instead.
Add `authorize: yes` to the task. For example:
.. code-block:: yaml
- name: configure hostname
ios_system:
provider:
hostname: foo
authorize: yes
auth_pass: "{{ mypasswordvar }}"
register: result
.. delete_to not honoured
----------------------
FIXME Do we get an error message
FIXME Link to howto
fixmes
======
Error: "number of connection attempts exceeded, unable to connect to control socket"
------------------------------------------------------------------------------------
**Platforms:** Any
This occurs when Ansible wasn't able to connect to the remote device and obtain a shell with the timeout.
This information is available when ``ANSIBLE_LOG_PATH`` is set see (FIXMELINKTOSECTION):
.. code-block:: yaml
less $ANSIBLE_LOG_PATH
2017-03-10 15:32:06,173 p=19677 u=fred | number of connection attempts exceeded, unable to connect to control socket
2017-03-10 15:32:06,174 p=19677 u=fred | persistent_connect_interval=1, persistent_connect_retries=10
2017-03-10 15:32:06,222 p=19669 u=fred | fatal: [veos01]: FAILED! => {
Suggestions to resolve:
Do stuff For example:
.. code-block:: yaml
Example stuff

View file

@ -38,6 +38,7 @@ The top level of the directory would contain files and directories like so::
hostname2 # ""
library/ # if any custom modules, put them here (optional)
module_utils/ # if any custom module_utils to support modules, put them here (optional)
filter_plugins/ # if any custom filter plugins, put them here (optional)
site.yml # master playbook
@ -62,6 +63,7 @@ The top level of the directory would contain files and directories like so::
meta/ #
main.yml # <-- role dependencies
library/ # roles can also include custom modules
module_utils/ # roles can also include custom module_utils
lookup_plugins/ # or other types of plugins, like lookup in this case
webtier/ # same kind of structure as "common" was above, done for the webtier role
@ -97,6 +99,7 @@ Alternatively you can put each inventory file with its ``group_vars``/``host_var
stagehost2 # ""
library/
module_utils/
filter_plugins/
site.yml
@ -422,7 +425,7 @@ This will pull in variables based on the OS name.
Bundling Ansible Modules With Playbooks
+++++++++++++++++++++++++++++++++++++++
If a playbook has a "./library" directory relative to its YAML file, this directory can be used to add ansible modules that will
If a playbook has a :file:`./library` directory relative to its YAML file, this directory can be used to add ansible modules that will
automatically be in the ansible module path. This is a great way to keep modules that go with a playbook together. This is shown
in the directory structure example at the start of this section.

View file

@ -9,20 +9,18 @@ by the tasks enclosed by a block. i.e. a `when` will be applied to the tasks, no
.. code-block:: YAML
:emphasize-lines: 2
:emphasize-lines: 3
:caption: Block example
tasks:
- block:
- name: Install Apache
block:
- yum: name={{ item }} state=installed
with_items:
- httpd
- memcached
- template: src=templates/src.j2 dest=/etc/foo.conf
- service: name=bar state=started enabled=True
when: ansible_distribution == 'CentOS'
become: true
become_user: root
@ -32,6 +30,9 @@ In the example above, each of the 3 tasks will be executed after appending the `
and evaluating it in the task's context. Also they inherit the privilege escalation directives enabling "become to root"
for all the enclosed tasks.
. versionadded:: 2.3
The `name:` keyword for `blocks:` was added in Ansible 2.3.
.. _block_error_handling:
@ -41,20 +42,21 @@ Error Handling
Blocks also introduce the ability to handle errors in a way similar to exceptions in most programming languages.
.. code-block:: YAML
:emphasize-lines: 2,6,10
:emphasize-lines: 3,7,11
:caption: Block error handling example
tasks:
- block:
- debug: msg='i execute normally'
- command: /bin/false
- debug: msg='i never execute, cause ERROR!'
rescue:
- debug: msg='I caught an error'
- command: /bin/false
- debug: msg='I also never execute :-('
always:
- debug: msg="this always executes"
tasks:
- name: Attempt and gracefull roll back demo
block:
- debug: msg='I execute normally'
- command: /bin/false
- debug: msg='I never execute, due to the above task failing'
rescue:
- debug: msg='I caught an error'
- command: /bin/false
- debug: msg='I also never execute :-('
always:
- debug: msg="this always executes"
The tasks in the ``block`` would execute normally, if there is any error the ``rescue`` section would get executed
@ -65,20 +67,21 @@ error did or did not occur in the ``block`` and ``rescue`` sections.
Another example is how to run handlers after an error occurred :
.. code-block:: YAML
:emphasize-lines: 4,8
:emphasize-lines: 5,9
:caption: Block run handlers in error handling
tasks:
- block:
- debug: msg='i execute normally'
notify: run me even after an error
- command: /bin/false
rescue:
- name: make sure all handlers run
meta: flush_handlers
handlers:
- name: run me even after an error
debug: msg='this handler runs even on error'
- name: Attempt and gracefull roll back demo
block:
- debug: msg='I execute normally'
notify: run me even after an error
- command: /bin/false
rescue:
- name: make sure all handlers run
meta: flush_handlers
handlers:
- name: run me even after an error
debug: msg='this handler runs even on error'
.. seealso::
@ -93,4 +96,3 @@ Another example is how to run handlers after an error occurred :

View file

@ -182,7 +182,7 @@ In 2.0, the directive `delegate_facts` may be set to `True` to assign the task's
with_items: "{{groups['dbservers']}}"
The above will gather facts for the machines in the dbservers group and assign the facts to those machines and not to app_servers.
This way you can lookup `hostvars['dbhost1']['default_ipv4_addresses'][0]` even though dbservers were not part of the play, or left out by using `--limit`.
This way you can lookup `hostvars['dbhost1']['default_ipv4']['address']` even though dbservers were not part of the play, or left out by using `--limit`.
.. _run_once:

View file

@ -588,6 +588,9 @@ To replace text in a string with regex, use the "regex_replace" filter::
# convert "localhost:80" to "localhost, 80" using named groups
{{ 'localhost:80' | regex_replace('^(?P<host>.+):(?P<port>\\d+)$', '\\g<host>, \\g<port>') }}
# convert "localhost:80" to "localhost"
{{ 'localhost:80' | regex_replace(':80') }}
.. note:: Prior to ansible 2.0, if "regex_replace" filter was used with variables inside YAML arguments (as opposed to simpler 'key=value' arguments),
then you needed to escape backreferences (e.g. ``\\1``) with 4 backslashes (``\\\\``) instead of 2 (``\\``).

View file

@ -116,27 +116,27 @@ Examples
--------
Basic lookup. Fails if example/test doesn't exist::
password="{{ lookup('pass', 'example/test')}}`
password="{{ lookup('passwordstore', 'example/test')}}`
Create pass with random 16 character password. If password exists just give the password::
password="{{ lookup('pass', 'example/test create=true')}}`
password="{{ lookup('passwordstore', 'example/test create=true')}}`
Different size password::
password="{{ lookup('pass', 'example/test create=true length=42')}}`
password="{{ lookup('passwordstore', 'example/test create=true length=42')}}`
Create password and overwrite the password if it exists. As a bonus, this module includes the old password inside the pass file::
password="{{ lookup('pass', 'example/test create=true overwrite=true')}}`
password="{{ lookup('passwordstore', 'example/test create=true overwrite=true')}}`
Return the value for user in the KV pair user: username::
password="{{ lookup('pass', 'example/test subkey=user')}}`
password="{{ lookup('passwordstore', 'example/test subkey=user')}}`
Return the entire password file content::
password="{{ lookup('pass', 'example/test returnall=true')}}`
password="{{ lookup('passwordstore', 'example/test returnall=true')}}`
The location of the password-store directory can be specified in the following ways:
- Default is ~/.password-store

View file

@ -112,8 +112,7 @@ And you want to print every user's name and phone number. You can loop through
- name: Print phone records
debug:
msg: "User {{ item.key }} is {{ item.value.name }} ({{ item.value.telephone }})"
with_dict:
- "{{ users }}"
with_dict: "{{ users }}"
.. _looping_over_fileglobs:

View file

@ -136,7 +136,26 @@ As of version 2.3, Ansible can now use a vaulted variable that lives in an other
other_plain_text: othervalue
This vaulted variable be decrypted with the supplied vault secret and used as a normal variable. The `ansible-vault` command line supports stdin and stdout for encrypting data on the fly, which can be used from your favorite editor to create these vaulted variables; you just have to be sure to add the `!vault` tag so both Ansible and YAML are aware of the need to decrypt. The `|` is also required, as vault encryption results in a multi-line string.
This vaulted variable be decrypted with the supplied vault secret and used as a normal variable. The `ansible-vault` command line supports `STDIN` and `STDOUT` for encrypting data on the fly, which can be used from your favorite editor to create these vaulted variables; you just have to be sure to add the `!vault` tag so both Ansible and YAML are aware of the need to decrypt. The `|` is also required, as vault encryption results in a multi-line string. The leading spaces will be ignored and some indentation is required for it to be valid YAML.
As of version 2.3, one way to generate the inline secret is to use `ansible-vault encrypt_string` which will output the secret to `STDOUT`::
$ ansible-vault encrypt_string "42"
!vault-encrypted |
$ANSIBLE_VAULT;1.1;AES256
<vault cipher text here>
$ ansible-vault encrypt_string "42" --stdin-name "the_answer"
the_answer: !vault-encrypted |
$ANSIBLE_VAULT;1.1;AES256
<vault cipher text here>
$ echo -n "the plaintext to encrypt" | ansible-vault encrypt_string
!vault-encrypted |
$ANSIBLE_VAULT;1.1;AES256
<vault cipher text here>
Note the use of `echo -n`. If you use just `echo` the encrypted string will have a new line (`\n`) on the end.
.. _speeding_up_vault:

View file

@ -1,14 +1,26 @@
Porting Guide
=============
.. _porting_2.0_guide:
*************************
Ansible 2.0 Porting Guide
*************************
This section discusses the behavioral changes between Ansible 1.x and Ansible 2.0.
It is intended to assist in updating your playbooks, plugins and other parts of your Ansible infrastructure so they will work with this version of Ansible.
We suggest you read this page along with `Ansible Changelog <https://github.com/ansible/ansible/blob/devel/CHANGELOG.md#2.0>`_ to understand what updates you may need to make.
This document is part of a collection on porting. The complete list of porting guides can be found at :ref:`porting guides <porting_guides>`.
.. contents:: Topics
Playbook
--------
========
* backslash escapes When specifying parameters in jinja2 expressions in YAML
dicts, backslashes sometimes needed to be escaped twice. This has been fixed
in 2.0.x so that escaping once works. The following example shows how
playbooks must be modified::
This section discusses any changes you may need to make to your playbooks.
.. code-block:: yaml
# Syntax in 1.9.x
- debug:
@ -88,16 +100,16 @@ uses key=value escaping which has not changed. The other option is to check for
* dnf module has been rewritten. Some minor changes in behavior may be observed.
* win_updates has been rewritten and works as expected now.
* from 2.0.1 onwards, the implicit setup task from gather_facts now correctly inherits everything from play, but this might cause issues for those setting
`environment` at the play level and depending on `ansible_env` existing. Previouslly this was ignored but now might issue an 'Undefined' error.
`environment` at the play level and depending on `ansible_env` existing. Previously this was ignored but now might issue an 'Undefined' error.
Deprecated
~~~~~~~~~~
----------
While all items listed here will show a deprecation warning message, they still work as they did in 1.9.x. Please note that they will be removed in 2.2 (Ansible always waits two major releases to remove a deprecated feature).
* Bare variables in `with_` loops should instead use the “{{var}}” syntax, which helps eliminate ambiguity.
* Bare variables in ``with_`` loops should instead use the ``"{ {var }}"`` syntax, which helps eliminate ambiguity.
* The ansible-galaxy text format requirements file. Users should use the YAML format for requirements instead.
* Undefined variables within a `with_` loops list currently do not interrupt the loop, but they do issue a warning; in the future, they will issue an error.
* Undefined variables within a ``with_`` loops list currently do not interrupt the loop, but they do issue a warning; in the future, they will issue an error.
* Using dictionary variables to set all task parameters is unsafe and will be removed in a future version. For example::
- hosts: localhost
@ -151,9 +163,9 @@ Should now be::
Other caveats
~~~~~~~~~~~~~
-------------
Here are some corner cases encountered when updating, these are mostly caused by the more stringent parser validation and the capture of errors that were previouslly ignored.
Here are some corner cases encountered when updating. These are mostly caused by the more stringent parser validation and the capture of errors that were previously ignored.
* Bad variable composition::
@ -201,32 +213,33 @@ Here are some corner cases encountered when updating, these are mostly caused by
with_items: "{{var1 + var2}}"
The bare feature itself is deprecated as an undefined variable is indistiguishable from a string which makes it difficult to display a proper error.
The bare feature itself is deprecated as an undefined variable is indistinguishable from a string which makes it difficult to display a proper error.
Porting plugins
---------------
===============
In ansible-1.9.x, you would generally copy an existing plugin to create a new one. Simply implementing the methods and attributes that the caller of the plugin expected made it a plugin of that type. In ansible-2.0, most plugins are implemented by subclassing a base class for each plugin type. This way the custom plugin does not need to contain methods which are not customized.
Lookup plugins
~~~~~~~~~~~~~~
--------------
* lookup plugins ; import version
Connection plugins
~~~~~~~~~~~~~~~~~~
------------------
* connection plugins
Action plugins
~~~~~~~~~~~~~~
--------------
* action plugins
Callback plugins
~~~~~~~~~~~~~~~~
----------------
Although Ansible 2.0 provides a new callback API the old one continues to work
for most callback plugins. However, if your callback plugin makes use of
@ -262,15 +275,15 @@ populates the callback with them. Here's a short snippet that shows you how:
Connection plugins
~~~~~~~~~~~~~~~~~~
------------------
* connection plugins
Hybrid plugins
--------------
==============
In specific cases you may want a plugin that supports both ansible-1.9.x *and* ansible-2.0. Much like porting plugins from v1 to v2, you need to understand how plugins work in each version and support both requirements. It may mean playing tricks on Ansible.
In specific cases you may want a plugin that supports both ansible-1.9.x *and* ansible-2.0. Much like porting plugins from v1 to v2, you need to understand how plugins work in each version and support both requirements.
Since the ansible-2.0 plugin system is more advanced, it is easier to adapt your plugin to provide similar pieces (subclasses, methods) for ansible-1.9.x as ansible-2.0 expects. This way your code will look a lot cleaner.
@ -290,8 +303,9 @@ You may find the following tips useful:
Lookup plugins
~~~~~~~~~~~~~~
As a simple example we are going to make a hybrid ``fileglob`` lookup plugin. The ``fileglob`` lookup plugin is pretty simple to understand
--------------
As a simple example we are going to make a hybrid ``fileglob`` lookup plugin.
.. code-block:: python
@ -357,28 +371,28 @@ As a simple example we are going to make a hybrid ``fileglob`` lookup plugin. T
Connection plugins
~~~~~~~~~~~~~~~~~~
------------------
* connection plugins
Action plugins
~~~~~~~~~~~~~~
--------------
* action plugins
Callback plugins
~~~~~~~~~~~~~~~~
----------------
* callback plugins
Connection plugins
~~~~~~~~~~~~~~~~~~
------------------
* connection plugins
Porting custom scripts
----------------------
======================
Custom scripts that used the ``ansible.runner.Runner`` API in 1.x have to be ported in 2.x. Please refer to: :doc:`dev_guide//developing_api`
Custom scripts that used the ``ansible.runner.Runner`` API in 1.x have to be ported in 2.x. Please refer to: :doc:`dev_guide/developing_api`

View file

@ -0,0 +1,246 @@
.. _porting_2.3_guide:
*************************
Ansible 2.3 Porting Guide
*************************
This section discusses the behavioral changes between Ansible 2.2 and Ansible 2.3.
It is intended to assist in updating your playbooks, plugins and other parts of your Ansible infrastructure so they will work with this version of Ansible.
We suggest you read this page along with `Ansible Changelog <https://github.com/ansible/ansible/blob/devel/CHANGELOG.md#2.3>`_ to understand what updates you may need to make.
This document is part of a collection on porting. The complete list of porting guides can be found at :ref:`porting guides <porting_guides>`.
.. contents:: Topics
Playbook
========
Restructued async to work with action plugins
---------------------------------------------
In Ansible 2.2 (and possibly earlier) the `async:` keyword could not be used in conjunction with the action plugins such as `service`. This limitation has been removed in Ansible 2.3
**NEW** In Ansible 2.3:
.. code-block:: yaml
- name: Install nginx asynchronously
service:
name: nginx
state: restarted
async: 45
OpenBSD version facts
---------------------
The `ansible_distribution_release` and `ansible_distribution_version` facts on OpenBSD hosts were reversed in Ansible 2.2 and earlier. This has been changed so that version has the numeric portion and release has the name of the release.
**OLD** In Ansible 2.2 (and earlier)
.. code-block:: yaml
"ansible_distribution": "OpenBSD"
"ansible_distribution_release": "6.0",
"ansible_distribution_version": "release",
**NEW** In Ansible 2.3:
.. code-block:: yaml
"ansible_distribution": "OpenBSD",
"ansible_distribution_release": "release",
"ansible_distribution_version": "6.0",
Names Blocks
------------
Blocks can now have names, this allows you to avoid the ugly `# this block is for...` comments.
**NEW** In Ansible 2.3:
.. code-block:: yaml
- name: Block test case
hosts: localhost
tasks:
- name: Attempt to setup foo
block:
- debug: msg='I execute normally'
- command: /bin/false
- debug: msg='I never execute, cause ERROR!'
rescue:
- debug: msg='I caught an error'
- command: /bin/false
- debug: msg='I also never execute :-('
always:
- debug: msg="this always executes"
Use of multiple tags
--------------------
Specifying ``--tags`` (or ``--skip-tags``) multiple times on the command line currently leads to the last specified tag overriding all the other specified tags. This behaviour is deprecated. In the future, if you specify --tags multiple times the tags will be merged together. From now on, using ``--tags`` multiple times on one command line will emit a deprecation warning. Setting the ``merge_multiple_cli_tags`` option to True in the ``ansible.cfg`` file will enable the new behaviour.
In 2.4, the default will be to merge the tags. You can enable the old overwriting behavior via the config option.
In 2.5, multiple ``--tags`` options will be merged with no way to go back to the old behaviour.
Other caveats
-------------
Here are some rare cases that might be encountered when updating. These are mostly caused by the more stringent parser validation and the capture of errors that were previously ignored.
* Made ``any_errors_fatal`` inheritable from play to task and all other objects in between.
Modules
=======
No major changes in this version.
Modules removed
---------------
No major changes in this version.
Deprecation notices
-------------------
The following modules will be removed in Ansible 2.5. Please update your playbooks accordingly.
* :ref:`ec2_vpc <ec2_vpc>`
* :ref:`cl_bond <cl_bond>`
* :ref:`cl_bridge <cl_bridge>`
* :ref:`cl_img_install <cl_img_install>`
* :ref:`cl_interface <cl_interface>`
* :ref:`cl_interface_policy <cl_interface_policy>`
* :ref:`cl_license <cl_license>`
* :ref:`cl_ports <cl_ports>`
* :ref:`nxos_mtu <nxos_mtu>` use :ref:`nxos_system <nxos_system>` instead
Noteworthy module changes
-------------------------
AWS lambda
^^^^^^^^^^
Previously ignored changes that only affected one parameter. Existing deployments may have outstanding changes that this bug fix will apply.
Mount
^^^^^
Mount: Some fixes so bind mounts are not mounted each time the playbook runs.
Plugins
=======
No major changes in this version.
Porting custom scripts
======================
No major changes in this version.
Networking
==========
There have been a number of changes to number of changes to how Networking Modules operate.
Playbooks should still use ``connection: local``.
The following changes apply to:
* dellos6
* dellos9
* dellos10
* eos
* ios
* iosxr
* junos
* sros
* vyos
Deprecation of top-level connection arguments
---------------------------------------------
**OLD** In Ansible 2.2:
.. code-block:: yaml
- name: example of using top-level options for connection properties
ios_command:
commands: show version
host: "{{ inventory_hostname }}"
username: cisco
password: cisco
authorize: yes
auth_pass: cisco
Will result in:
.. code-block:: yaml
[WARNING]: argument username has been deprecated and will be removed in a future version
[WARNING]: argument host has been deprecated and will be removed in a future version
[WARNING]: argument password has been deprecated and will be removed in a future version
**NEW** In Ansible 2.3:
.. code-block:: yaml
- name: Gather facts
eos_facts:
gather_subset: all
provider:
username: myuser
password: "{{ networkpassword }}"
transport: cli
host: "{{ ansible_host }}"
delegate_to vs ProxyCommand
---------------------------
The new connection framework for Network Modules in Ansible 2.3 no longer supports the use of the
``delegate_to`` directive. In order to use a bastion or intermediate jump host
to connect to network devices, network modules now support the use of
``ProxyCommand``.
To use ``ProxyCommand`` configure the proxy settings in the Ansible inventory
file to specify the proxy host.
.. code-block:: ini
[nxos]
nxos01
nxos02
[nxos:vars]
ansible_ssh_common_args='-o ProxyCommand="ssh -W %h:%p -q bastion01"'
With the configuration above, simply build and run the playbook as normal with
no additional changes necessary. The network module will now connect to the
network device by first connecting to the host specified in
``ansible_ssh_common_args`` which is ``bastion01`` in the above example.
.. notes: Using ``ProxyCommand`` with passwords via variables
It is a feature that SSH doesn't support providing passwords via environment variables.
This is done to prevent secrets from leaking out, for example in ``ps`` output.
We recommend using SSH Keys, and if needed and ssh-agent, rather than passwords, where ever possible.

View file

@ -0,0 +1,12 @@
.. _porting_guides:
**********************
Ansible Porting Guides
**********************
This section lists porting guides that can help you playbooks, plugins and other parts of your Ansible infrastructure from one version of Ansible to the next. Please note that this is not a complete list. If you believe any extra information would be useful in these pages, you can edit by clicking `Edit on GitHub` on the top right, or raising an issue.
* :ref:`Ansible 1.x to 2.0 porting guide <porting_2.0_guide>`
* :ref:`Ansible 2.2 to 2.3 porting guide <porting_2.3_guide>`
* :ref:`Ansible 2.3 to 2.4 porting guide <porting_2.4_guide>`

View file

@ -0,0 +1,137 @@
Release and maintenance
=======================
.. contents:: Topics
:local:
.. _schedule:
Release cycle
`````````````
Ansible is developed and released on a flexible 4 months release cycle.
This cycle can be extended in order to allow for larger changes to be properly
implemented and tested before a new release is made available.
Ansible supports the two most recent major stable releases.
For more information, read about the
`development and stable version maintenance workflow`_.
If you are using a release of Ansible that is no longer supported, we strongly
encourage you to upgrade as soon as possible in order to benefit from the
latest features and security fixes.
Older unsupported versions of Ansible can contain unfixed security
vulnerabilities (*CVE*).
You can refer to the `porting guide`_ for tips on updating your Ansible
playbooks to run on newer versions.
.. _porting guide: https://docs.ansible.com/ansible/porting_guide_2.0.html
Release status
``````````````
+-----------------+----------------------------+----------------------------------------+
| Ansible release | Latest version | Status |
+=================+============================+========================================+
| devel | `2.4`_ (unreleased, trunk) | In development |
+-----------------+----------------------------+----------------------------------------+
| 2.3 | `2.3.1`_ (2017-06-01) | Supported (bug **and** security fixes) |
+-----------------+----------------------------+----------------------------------------+
| 2.2   | `2.2.3`_ (2017-05-09) | Supported (**only** security fixes) |
+-----------------+----------------------------+----------------------------------------+
| 2.1 | `2.1.6`_ (2017-06-01) | Unsupported (end of life) |
+-----------------+----------------------------+----------------------------------------+
| 2.0 | `2.0.2`_ (2016-04-19) | Unsupported (end of life) |
+-----------------+----------------------------+----------------------------------------+
| 1.9 | `1.9.6`_ (2016-04-15) | Unsupported (end of life) |
+-----------------+----------------------------+----------------------------------------+
| <1.9 | n/a | Unsupported (end of life) |
+-----------------+----------------------------+----------------------------------------+
.. _2.4: https://github.com/ansible/ansible/blob/devel/CHANGELOG.md
.. _2.3.1: https://github.com/ansible/ansible/blob/stable-2.3/CHANGELOG.md
.. _2.2.3: https://github.com/ansible/ansible/blob/stable-2.2/CHANGELOG.md
.. _2.1.6: https://github.com/ansible/ansible/blob/stable-2.1/CHANGELOG.md
.. _2.0.2: https://github.com/ansible/ansible/blob/stable-2.0/CHANGELOG.md
.. _1.9.6: https://github.com/ansible/ansible/blob/stable-1.9/CHANGELOG.md
.. _support_life:
.. _methods:
Development and stable version maintenance workflow
```````````````````````````````````````````````````
The Ansible community develops and maintains Ansible on GitHub_.
New modules, plugins, features and bugfixes will always be integrated in what
will become the next major version of Ansible.
This work is tracked on the ``devel`` git branch.
Ansible provides bugfixes and security improvements for the most recent major
release while the previous major release will only receive security patches.
This work is tracked on the ``stable-<version>`` git branches.
The fixes that land in supported stable branches will eventually be released
as a new version when necessary.
For more information on the changes included in each new version, you can refer
to the changelog_, available on GitHub.
Note that while there are no guarantees for providing fixes for unsupported
releases of Ansible, there can sometimes be exceptions for critical issues.
.. _GitHub: https://github.com/ansible/ansible
.. _changelog: https://github.com/ansible/ansible/blob/devel/CHANGELOG.md
Release candidates
~~~~~~~~~~~~~~~~~~
Before a new release or version of Ansible can be done, it will typically go
through a release candidate process.
This provides the Ansible community the opportunity to test Ansible and report
bugs or issues they might come across.
Ansible tags the first release candidate (``RC1``) which is usually scheduled
to last five business days. The final release is done if no major bugs or
issues are identified during this period.
If there are major problems with the first candidate, a second candidate will
be tagged (``RC2``) once the necessary fixes have landed.
This second candidate lasts for a shorter duration than the first.
If no problems have been reported after two business days, the final release is
done.
More release candidates can be tagged as required, so long as there are
bugs that the Ansible core maintainers consider should be fixed before the
final release.
.. _freezing:
Feature freeze
~~~~~~~~~~~~~~
While there is a pending release candidate, the focus of core developers and
maintainers will on fixes towards the release candidate.
Merging new features or fixes that are not related to the release candidate may
be delayed in order to allow the new release to be shipped as soon as possible.
.. seealso::
:doc:`committer_guidelines`
Guidelines for Ansible core contributors and maintainers
:doc:`test_strategies`
Testing strategies
:doc:`community`
Community information and contributing
`Ansible Changelog <https://github.com/ansible/ansible/blob/devel/CHANGELOG.md>`_
Documentation of the improvements for each version of Ansible
`Ansible release tarballs <https://releases.ansible.com/ansible/>`_
Ansible release tarballs
`Development Mailing List <http://groups.google.com/group/ansible-devel>`_
Mailing list for development topics
`irc.freenode.net <http://irc.freenode.net>`_
#ansible IRC chat channel

View file

@ -91,7 +91,7 @@ Target: September 2016
- **Deferred:** (stretch goal) Bird modules
- **Deferred:** (stretch goal) GoBGP modules
- **Implement role revamp proposal to give users more control on role/task execution (Brian) **
- **Implement role revamp proposal to give users more control on role/task execution (Brian)**
- **https://github.com/ansible/proposals/blob/master/roles_revamp.md**

View file

@ -39,11 +39,11 @@ Target: Mid April 2017
- **Windows platform** (nitzmahone)
- Pipelining support **(done)**
- Become support **(done)**
- Become support **(done/experimental)**
- Integrated kerberos ticket management (via ansible_user/ansible_password) **(done)**
- Switch PS input encoding to BOM-less UTF8 **(done)**
- Server 2016 support/testing (now RTMd) **(in progress)**
- Modularize Windows module_utils (allow N files) **(in progress)**
- Server 2016 support/testing (now RTMd) **(partial)**
- Modularize Windows module_utils (allow N files) **(partial)**
- Declarative argspec for PS / .NET **(bumped to 2.4)**
- Kerberos encryption (via notting, pywinrm/requests_kerberos/pykerberos) **(in progress, available in pywinrm post 2.3 release)**
- Fix plugin-specific connection var lookup/delegation (either registered explicitly by plugins or ansible_(plugin)_*) **(bumped to 2.4)**
@ -132,7 +132,7 @@ Target: Mid April 2017
- **Amazon resources** (ryansb)
- Improve ec2.py integration tests **(partial, more to do in 2.4)**
- ELB version 2 **(pushed - needs_revision [PR](https://github.com/ansible/ansible/pull/19491))**
- ELB version 2 **(pushed - needs_revision)** `PR <https://github.com/ansible/ansible/pull/19491>`_
- CloudFormation YAML, cross-stack reference, and roles support **(done)**
- ECS module refactor **(done)**
- AWS module unit testing w/ placebo (boto3 only) **(pushed 2.4)**

View file

@ -12,7 +12,7 @@ ansible-vault - manage encrypted ansible vars files (YAML).
SYNOPSIS
--------
ansible-vault [create|decrypt|edit|encrypt|rekey] [--help] [options] file_name
ansible-vault [create|decrypt|edit|encrypt|encrypt_string|rekey] [--help] [options] file_name
DESCRIPTION
@ -116,6 +116,24 @@ Thus any of the following invocations can be used:
Reading from stdin and writing only encrypted output is a good way to prevent
sensitive data from ever hitting disk (either interactively or from a script).
ENCRYPT_STRING
--------------
*$ ansible-vault encrypt_string [options] "string cheese"*
The *encrypt_string* sub-command is used to encrypt a string supplied as an argument.
The *encrypt_string* command works with *STDIN* and has the additional options
*--name* and *--stdin-name*:
*$ ansible-vault encrypt_string "munster" -name="cheese_du_jour"*
*$ ansible-vault encrypt_string "$@" -stdin-name="cheese_list" < ./cheese_list.txt*
The output will be on *STDOUT*. This command is useful for creating inline
secrets introduced in version 2.3.
DECRYPT
-------

View file

@ -181,6 +181,7 @@
#vars_plugins = /usr/share/ansible/plugins/vars
#filter_plugins = /usr/share/ansible/plugins/filter
#test_plugins = /usr/share/ansible/plugins/test
#terminal_plugins = /usr/share/ansible/plugins/terminal
#strategy_plugins = /usr/share/ansible/plugins/strategy
@ -280,7 +281,7 @@
# Controls showing custom stats at the end, off by default
#show_custom_stats = True
# Controlls which files to ignore when using a directory as inventory with
# Controls which files to ignore when using a directory as inventory with
# possibly multiple sources (both static and dynamic)
#inventory_ignore_extensions = ~, .orig, .bak, .ini, .cfg, .retry, .pyc, .pyo
@ -288,6 +289,12 @@
# only update this setting if you know how this works, otherwise it can break module execution
#network_group_modules=['eos', 'nxos', 'ios', 'iosxr', 'junos', 'vyos']
# When enabled, this option allows lookups (via variables like {{lookup('foo')}} or when used as
# a loop with `with_foo`) to return data that is not marked "unsafe". This means the data may contain
# jinja2 templating language which will be run through the templating engine.
# ENABLING THIS COULD BE A SECURITY RISK
#allow_unsafe_lookups = False
[privilege_escalation]
#become=True
#become_method=sudo
@ -305,6 +312,19 @@
# line to disable this behaviour.
#pty=False
# paramiko will default to looking for SSH keys initially when trying to
# authenticate to remote devices. This is a problem for some network devices
# that close the connection after a key failure. Uncomment this line to
# disable the Paramiko look for keys function
#look_for_keys = False
# When using persistent connections with Paramiko, the connection runs in a
# background process. If the host doesn't already have a valid SSH key, by
# default Ansible will prompt to add the host key. This will cause connections
# running in background processes to fail. Uncomment this line to have
# Paramiko automatically add host keys.
#host_key_auto_add = True
[ssh_connection]
# ssh arguments to use
@ -357,6 +377,26 @@
# only be disabled if your sftp version has problems with batch mode
#sftp_batch_mode = False
[persistent_connection]
# Configures the persistent connection timeout value in seconds. This value is
# how long the persistent connection will remain idle before it is destroyed.
# If the connection doesn't receive a request before the timeout value
# expires, the connection is shutdown. The default value is 30 seconds.
connect_timeout = 30
# Configures the persistent connection retries. This value configures the
# number of attempts the ansible-connection will make when trying to connect
# to the local domain socket. The default value is 30.
connect_retries = 30
# Configures the amount of time in seconds to wait between connection attempts
# to the local unix domain socket. This value works in conjunction with the
# connect_retries value to define how long to try to connect to the local
# domain socket when setting up a persistent connection. The default value is
# 1 second.
connect_interval = 1
[accelerate]
#accelerate_port = 5099
#accelerate_timeout = 30

View file

@ -50,7 +50,8 @@ Param (
[switch]$SkipNetworkProfileCheck,
$CreateSelfSignedCert = $true,
[switch]$ForceNewSSLCert,
[switch]$EnableCredSSP
[switch]$EnableCredSSP,
[switch]$GlobalHttpFirewallAccess
)
Function Write-Log
@ -69,7 +70,7 @@ Function Write-VerboseLog
Function Write-HostLog
{
$Message = $args[0]
Write-Host $Message
Write-Output $Message
Write-Log $Message
}
@ -119,6 +120,60 @@ Function New-LegacySelfSignedCert
return $parsed_cert.Thumbprint
}
Function Enable-GlobalHttpFirewallAccess
{
Write-Verbose "Forcing global HTTP firewall access"
# this is a fairly naive implementation; could be more sophisticated about rule matching/collapsing
$fw = New-Object -ComObject HNetCfg.FWPolicy2
# try to find/enable the default rule first
$add_rule = $false
$matching_rules = $fw.Rules | ? { $_.Name -eq "Windows Remote Management (HTTP-In)" }
$rule = $null
If ($matching_rules) {
If ($matching_rules -isnot [Array]) {
Write-Verbose "Editing existing single HTTP firewall rule"
$rule = $matching_rules
}
Else {
# try to find one with the All or Public profile first
Write-Verbose "Found multiple existing HTTP firewall rules..."
$rule = $matching_rules | % { $_.Profiles -band 4 }[0]
If (-not $rule -or $rule -is [Array]) {
Write-Verbose "Editing an arbitrary single HTTP firewall rule (multiple existed)"
# oh well, just pick the first one
$rule = $matching_rules[0]
}
}
}
If (-not $rule) {
Write-Verbose "Creating a new HTTP firewall rule"
$rule = New-Object -ComObject HNetCfg.FWRule
$rule.Name = "Windows Remote Management (HTTP-In)"
$rule.Description = "Inbound rule for Windows Remote Management via WS-Management. [TCP 5985]"
$add_rule = $true
}
$rule.Profiles = 0x7FFFFFFF
$rule.Protocol = 6
$rule.LocalPorts = 5985
$rule.RemotePorts = "*"
$rule.LocalAddresses = "*"
$rule.RemoteAddresses = "*"
$rule.Enabled = $true
$rule.Direction = 1
$rule.Action = 1
$rule.Grouping = "Windows Remote Management"
If ($add_rule) {
$fw.Rules.Add($rule)
}
Write-Verbose "HTTP firewall rule $($rule.Name) updated"
}
# Setup error handling.
Trap
{
@ -137,8 +192,8 @@ $adminRole=[System.Security.Principal.WindowsBuiltInRole]::Administrator
# Check to see if we are currently running "as Administrator"
if (-Not $myWindowsPrincipal.IsInRole($adminRole))
{
Write-Host "ERROR: You need elevated Administrator privileges in order to run this script."
Write-Host " Start Windows PowerShell by using the Run as Administrator option."
Write-Output "ERROR: You need elevated Administrator privileges in order to run this script."
Write-Output " Start Windows PowerShell by using the Run as Administrator option."
Exit 2
}
@ -275,6 +330,10 @@ If ($EnableCredSSP)
}
}
If ($GlobalHttpFirewallAccess) {
Enable-GlobalHttpFirewallAccess
}
# Configure firewall to allow WinRM HTTPS connections.
$fwtest1 = netsh advfirewall firewall show rule name="Allow WinRM HTTPS"
$fwtest2 = netsh advfirewall firewall show rule name="Allow WinRM HTTPS" profile=any

View file

@ -42,6 +42,7 @@ from ansible.parsing.utils.jsonify import jsonify
from ansible.parsing.splitter import parse_kv
import ansible.executor.module_common as module_common
import ansible.constants as C
from ansible.module_utils._text import to_text
try:
import json
@ -159,7 +160,7 @@ def boilerplate_module(modfile, args, interpreters, check, destfile):
print("* including generated source, if any, saving to: %s" % modfile2_path)
if module_style not in ('ansiballz', 'old'):
print("* this may offset any line numbers in tracebacks/debuggers!")
modfile2 = open(modfile2_path, 'w')
modfile2 = open(modfile2_path, 'wb')
modfile2.write(module_data)
modfile2.close()
modfile = modfile2_path
@ -178,6 +179,7 @@ def ansiballz_setup(modfile, modname, interpreters):
cmd = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = cmd.communicate()
out, err = to_text(out, errors='surrogate_or_strict'), to_text(err)
lines = out.splitlines()
if len(lines) != 2 or 'Module expanded into' not in lines[0]:
print("*" * 35)
@ -209,6 +211,7 @@ def runtest(modfile, argspath, modname, module_style, interpreters):
cmd = subprocess.Popen(invoke, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(out, err) = cmd.communicate()
out, err = to_text(out), to_text(err)
try:
print("*" * 35)
@ -228,11 +231,11 @@ def runtest(modfile, argspath, modname, module_style, interpreters):
print(jsonify(results,format=True))
def rundebug(debugger, modfile, argspath, modname, module_style):
def rundebug(debugger, modfile, argspath, modname, module_style, interpreters):
"""Run interactively with console debugger."""
if module_style == 'ansiballz':
modfile, argspath = ansiballz_setup(modfile, modname)
modfile, argspath = ansiballz_setup(modfile, modname, interpreters)
if argspath is not None:
subprocess.call("%s %s %s" % (debugger, modfile, argspath), shell=True)
@ -257,7 +260,7 @@ def main():
if options.execute:
if options.debugger:
rundebug(options.debugger, modfile, argspath, modname, module_style)
rundebug(options.debugger, modfile, argspath, modname, module_style, interpreters)
else:
runtest(modfile, argspath, modname, module_style, interpreters)

View file

@ -36,6 +36,7 @@ from ansible import constants as C
from ansible.compat.six import with_metaclass
from ansible.errors import AnsibleError, AnsibleOptionsError
from ansible.module_utils._text import to_bytes, to_text
from ansible.utils.path import unfrackpath
try:
from __main__ import display
@ -265,6 +266,10 @@ class CLI(with_metaclass(ABCMeta, object)):
def expand_tilde(option, opt, value, parser):
setattr(parser.values, option.dest, os.path.expanduser(value))
@staticmethod
def unfrack_path(option, opt, value, parser):
setattr(parser.values, option.dest, unfrackpath(value))
@staticmethod
def expand_paths(option, opt, value, parser):
"""optparse action callback to convert a PATH style string arg to a list of path strings.
@ -339,7 +344,8 @@ class CLI(with_metaclass(ABCMeta, object)):
connect_group.add_option('-k', '--ask-pass', default=C.DEFAULT_ASK_PASS, dest='ask_pass', action='store_true',
help='ask for connection password')
connect_group.add_option('--private-key','--key-file', default=C.DEFAULT_PRIVATE_KEY_FILE, dest='private_key_file',
help='use this file to authenticate the connection')
help='use this file to authenticate the connection',
action="callback", callback=CLI.unfrack_path, type=str)
connect_group.add_option('-u', '--user', default=C.DEFAULT_REMOTE_USER, dest='remote_user',
help='connect as this user (default=%s)' % C.DEFAULT_REMOTE_USER)
connect_group.add_option('-c', '--connection', dest='connection', default=C.DEFAULT_TRANSPORT,
@ -574,10 +580,10 @@ class CLI(with_metaclass(ABCMeta, object)):
''' find reasonable way to display text '''
# this is a much simpler form of what is in pydoc.py
if not sys.stdout.isatty():
display.display(text)
display.display(text, screen_only=True)
elif 'PAGER' in os.environ:
if sys.platform == 'win32':
display.display(text)
display.display(text, screen_only=True)
else:
self.pager_pipe(text, os.environ['PAGER'])
else:
@ -586,7 +592,7 @@ class CLI(with_metaclass(ABCMeta, object)):
if p.returncode == 0:
self.pager_pipe(text, 'less')
else:
display.display(text)
display.display(text, screen_only=True)
@staticmethod
def pager_pipe(text, cmd):

View file

@ -174,6 +174,9 @@ class AdHocCLI(CLI):
cb = self.callback
elif self.options.one_line:
cb = 'oneline'
# Respect custom 'stdout_callback' only with enabled 'bin_ansible_callbacks'
elif C.DEFAULT_LOAD_CALLBACK_PLUGINS and C.DEFAULT_STDOUT_CALLBACK != 'default':
cb = C.DEFAULT_STDOUT_CALLBACK
else:
cb = 'minimal'

View file

@ -379,8 +379,9 @@ class GalaxyCLI(CLI):
(role.name, role.install_info['version'], role.version or "unspecified"))
continue
else:
display.display('- %s is already installed, skipping.' % str(role))
continue
if not force:
display.display('- %s is already installed, skipping.' % str(role))
continue
try:
installed = role.install()

View file

@ -50,5 +50,12 @@ if _system_six:
six = _system_six
else:
from . import _six as six
six_py_file = '{0}.py'.format(os.path.splitext(six.__file__)[0])
if not os.path.exists(six_py_file):
# Only the .pyc/.pyo version of six was installed but we need a .py file
# Fallback to the bundled copy
from . import _six as six
six_py_file = '{0}.py'.format(os.path.splitext(six.__file__)[0])
exec(open(six_py_file, 'rb').read())

View file

@ -234,6 +234,7 @@ DEFAULT_FORCE_HANDLERS = get_config(p, DEFAULTS, 'force_handlers', 'ANSIBLE_F
DEFAULT_INVENTORY_IGNORE = get_config(p, DEFAULTS, 'inventory_ignore_extensions', 'ANSIBLE_INVENTORY_IGNORE', ["~", ".orig", ".bak", ".ini", ".cfg", ".retry", ".pyc", ".pyo"], value_type='list')
DEFAULT_VAR_COMPRESSION_LEVEL = get_config(p, DEFAULTS, 'var_compression_level', 'ANSIBLE_VAR_COMPRESSION_LEVEL', 0, value_type='integer')
DEFAULT_INTERNAL_POLL_INTERVAL = get_config(p, DEFAULTS, 'internal_poll_interval', None, 0.001, value_type='float')
DEFAULT_ALLOW_UNSAFE_LOOKUPS = get_config(p, DEFAULTS, 'allow_unsafe_lookups', None, False, value_type='boolean')
ERROR_ON_MISSING_HANDLER = get_config(p, DEFAULTS, 'error_on_missing_handler', 'ANSIBLE_ERROR_ON_MISSING_HANDLER', True, value_type='boolean')
SHOW_CUSTOM_STATS = get_config(p, DEFAULTS, 'show_custom_stats', 'ANSIBLE_SHOW_CUSTOM_STATS', False, value_type='boolean')
@ -299,7 +300,9 @@ DEFAULT_FILTER_PLUGIN_PATH = get_config(p, DEFAULTS, 'filter_plugins', '
DEFAULT_TEST_PLUGIN_PATH = get_config(p, DEFAULTS, 'test_plugins', 'ANSIBLE_TEST_PLUGINS', '~/.ansible/plugins/test:/usr/share/ansible/plugins/test', value_type='pathlist')
DEFAULT_STRATEGY_PLUGIN_PATH = get_config(p, DEFAULTS, 'strategy_plugins', 'ANSIBLE_STRATEGY_PLUGINS', '~/.ansible/plugins/strategy:/usr/share/ansible/plugins/strategy', value_type='pathlist')
NETWORK_GROUP_MODULES = get_config(p, DEFAULTS, 'network_group_modules','NETWORK_GROUP_MODULES', ['eos', 'nxos', 'ios', 'iosxr', 'junos', 'vyos'], value_type='list')
NETWORK_GROUP_MODULES = get_config(p, DEFAULTS, 'network_group_modules','NETWORK_GROUP_MODULES', ['eos', 'nxos', 'ios', 'iosxr', 'junos',
'vyos', 'sros', 'dellos9', 'dellos10', 'dellos6'],
value_type='list')
DEFAULT_STRATEGY = get_config(p, DEFAULTS, 'strategy', 'ANSIBLE_STRATEGY', 'linear')
DEFAULT_STDOUT_CALLBACK = get_config(p, DEFAULTS, 'stdout_callback', 'ANSIBLE_STDOUT_CALLBACK', 'default')

View file

@ -201,3 +201,9 @@ class AnsibleModuleExit(Exception):
''' local module exit '''
def __init__(self, result):
self.result = result
class AnsibleActionSkip(AnsibleRuntimeError):
''' an action runtime skip'''
pass
class AnsibleActionFail(AnsibleRuntimeError):
''' an action runtime failure'''
pass

View file

@ -37,7 +37,7 @@ from ansible import constants as C
from ansible.errors import AnsibleError
from ansible.module_utils._text import to_bytes, to_text
from ansible.plugins import module_utils_loader
from ansible.plugins.shell.powershell import async_watchdog, async_wrapper, become_wrapper, leaf_exec
from ansible.plugins.shell.powershell import async_watchdog, async_wrapper, become_wrapper, leaf_exec, exec_wrapper
# Must import strategy and use write_locks from there
# If we import write_locks directly then we end up binding a
# variable to the object and then it never gets updated.
@ -121,11 +121,11 @@ import __main__
# stdlib module
scriptdir = None
try:
scriptdir = os.path.dirname(os.path.abspath(__main__.__file__))
scriptdir = os.path.dirname(os.path.realpath(__main__.__file__))
except (AttributeError, OSError):
# Some platforms don't set __file__ when reading from stdin
# OSX raises OSError if using abspath() in a directory we don't have
# permission to read.
# permission to read (realpath calls abspath)
pass
if scriptdir is not None:
sys.path = [p for p in sys.path if p != scriptdir]
@ -345,7 +345,7 @@ if __name__ == '__main__':
finally:
try:
shutil.rmtree(temp_path)
except OSError:
except (NameError, OSError):
# tempdir creation probably failed
pass
sys.exit(exitcode)
@ -582,7 +582,8 @@ def _is_binary(b_module_data):
return bool(start.translate(None, textchars))
def _find_module_utils(module_name, b_module_data, module_path, module_args, task_vars, module_compression):
def _find_module_utils(module_name, b_module_data, module_path, module_args, task_vars, module_compression, async_timeout, become,
become_method, become_user, become_password, environment):
"""
Given the source of the module, convert it to a Jinja2 template to insert
module code and return whether it's a new or old style module.
@ -742,8 +743,55 @@ def _find_module_utils(module_name, b_module_data, module_path, module_args, tas
# Windows text editors
shebang = u'#!powershell'
# powershell wrapper build is currently handled in build_windows_module_payload, called in action
# _configure_module after this function returns.
exec_manifest = dict(
module_entry=to_text(base64.b64encode(b_module_data)),
powershell_modules=dict(),
module_args=module_args,
actions=['exec'],
environment=environment
)
exec_manifest['exec'] = to_text(base64.b64encode(to_bytes(leaf_exec)))
if async_timeout > 0:
exec_manifest["actions"].insert(0, 'async_watchdog')
exec_manifest["async_watchdog"] = to_text(base64.b64encode(to_bytes(async_watchdog)))
exec_manifest["actions"].insert(0, 'async_wrapper')
exec_manifest["async_wrapper"] = to_text(base64.b64encode(to_bytes(async_wrapper)))
exec_manifest["async_jid"] = str(random.randint(0, 999999999999))
exec_manifest["async_timeout_sec"] = async_timeout
if become and become_method == 'runas':
exec_manifest["actions"].insert(0, 'become')
exec_manifest["become_user"] = become_user
exec_manifest["become_password"] = become_password
exec_manifest["become"] = to_text(base64.b64encode(to_bytes(become_wrapper)))
lines = b_module_data.split(b'\n')
module_names = set()
requires_module_list = re.compile(r'(?i)^#requires \-module(?:s?) (.+)')
for line in lines:
# legacy, equivalent to #Requires -Modules powershell
if REPLACER_WINDOWS in line:
module_names.add(b'powershell')
# TODO: add #Requires checks for Ansible.ModuleUtils.X
for m in module_names:
m = to_text(m)
exec_manifest["powershell_modules"][m] = to_text(
base64.b64encode(
to_bytes(
_slurp(os.path.join(_MODULE_UTILS_PATH, m + ".ps1"))
)
)
)
# FUTURE: smuggle this back as a dict instead of serializing here; the connection plugin may need to modify it
module_json = json.dumps(exec_manifest)
b_module_data = exec_wrapper.replace(b"$json_raw = ''", b"$json_raw = @'\r\n%s\r\n'@" % to_bytes(module_json))
elif module_substyle == 'jsonargs':
module_args_json = to_bytes(json.dumps(module_args))
@ -767,7 +815,8 @@ def _find_module_utils(module_name, b_module_data, module_path, module_args, tas
return (b_module_data, module_style, shebang)
def modify_module(module_name, module_path, module_args, task_vars=dict(), module_compression='ZIP_STORED'):
def modify_module(module_name, module_path, module_args, task_vars=dict(), module_compression='ZIP_STORED', async_timeout=0, become=False,
become_method=None, become_user=None, become_password=None, environment=dict()):
"""
Used to insert chunks of code into modules before transfer rather than
doing regular python imports. This allows for more efficient transfer in
@ -793,7 +842,10 @@ def modify_module(module_name, module_path, module_args, task_vars=dict(), modul
# read in the module source
b_module_data = f.read()
(b_module_data, module_style, shebang) = _find_module_utils(module_name, b_module_data, module_path, module_args, task_vars, module_compression)
(b_module_data, module_style, shebang) = _find_module_utils(module_name, b_module_data, module_path, module_args, task_vars, module_compression,
async_timeout=async_timeout, become=become, become_method=become_method,
become_user=become_user, become_password=become_password,
environment=environment)
if module_style == 'binary':
return (b_module_data, module_style, to_text(shebang, nonstring='passthru'))
@ -820,47 +872,3 @@ def modify_module(module_name, module_path, module_args, task_vars=dict(), modul
shebang = to_bytes(shebang, errors='surrogate_or_strict')
return (b_module_data, module_style, to_text(shebang, nonstring='passthru'))
def build_windows_module_payload(module_name, module_path, b_module_data, module_args, task_vars, task, play_context):
exec_manifest = dict(
module_entry=base64.b64encode(b_module_data),
powershell_modules=dict(),
module_args=module_args,
actions=['exec']
)
exec_manifest['exec'] = base64.b64encode(to_bytes(leaf_exec))
if task.async > 0:
exec_manifest["actions"].insert(0, 'async_watchdog')
exec_manifest["async_watchdog"] = base64.b64encode(to_bytes(async_watchdog))
exec_manifest["actions"].insert(0, 'async_wrapper')
exec_manifest["async_wrapper"] = base64.b64encode(to_bytes(async_wrapper))
exec_manifest["async_jid"] = str(random.randint(0, 999999999999))
exec_manifest["async_timeout_sec"] = task.async
if play_context.become and play_context.become_method=='runas':
exec_manifest["actions"].insert(0, 'become')
exec_manifest["become_user"] = play_context.become_user
exec_manifest["become_password"] = play_context.become_pass
exec_manifest["become"] = base64.b64encode(to_bytes(become_wrapper))
lines = b_module_data.split(b'\n')
module_names = set()
requires_module_list = re.compile(r'(?i)^#requires \-module(?:s?) (.+)')
for line in lines:
# legacy, equivalent to #Requires -Modules powershell
if REPLACER_WINDOWS in line:
module_names.add(b'powershell')
# TODO: add #Requires checks for Ansible.ModuleUtils.X
for m in module_names:
exec_manifest["powershell_modules"][m] = base64.b64encode(
to_bytes(_slurp(os.path.join(_MODULE_UTILS_PATH, m + ".ps1"))))
# FUTURE: smuggle this back as a dict instead of serializing here; the connection plugin may need to modify it
b_module_data = json.dumps(exec_manifest)
return b_module_data

View file

@ -24,7 +24,6 @@ import fnmatch
from ansible.compat.six import iteritems
from ansible import constants as C
from ansible.errors import AnsibleError
from ansible.module_utils.six import cmp
from ansible.playbook.block import Block
from ansible.playbook.task import Task
from ansible.playbook.role_include import IncludeRole

View file

@ -68,21 +68,25 @@ class WorkerProcess(multiprocessing.Process):
self._variable_manager = variable_manager
self._shared_loader_obj = shared_loader_obj
# dupe stdin, if we have one
self._new_stdin = sys.stdin
try:
fileno = sys.stdin.fileno()
if fileno is not None:
try:
self._new_stdin = os.fdopen(os.dup(fileno))
except OSError:
# couldn't dupe stdin, most likely because it's
# not a valid file descriptor, so we just rely on
# using the one that was passed in
pass
except (AttributeError, ValueError):
# couldn't get stdin's fileno, so we just carry on
pass
if sys.stdin.isatty():
# dupe stdin, if we have one
self._new_stdin = sys.stdin
try:
fileno = sys.stdin.fileno()
if fileno is not None:
try:
self._new_stdin = os.fdopen(os.dup(fileno))
except OSError:
# couldn't dupe stdin, most likely because it's
# not a valid file descriptor, so we just rely on
# using the one that was passed in
pass
except (AttributeError, ValueError):
# couldn't get stdin's fileno, so we just carry on
pass
else:
# set to /dev/null
self._new_stdin = os.devnull
def run(self):
'''
@ -112,7 +116,7 @@ class WorkerProcess(multiprocessing.Process):
self._rslt_q
).run()
display.debug("done running TaskExecutor() for %s/%s" % (self._host, self._task))
display.debug("done running TaskExecutor() for %s/%s [%s]" % (self._host, self._task, self._task._uuid))
self._host.vars = dict()
self._host.groups = []
task_result = TaskResult(
@ -123,9 +127,9 @@ class WorkerProcess(multiprocessing.Process):
)
# put the result on the result queue
display.debug("sending task result")
display.debug("sending task result for task %s" % self._task._uuid)
self._rslt_q.put(task_result)
display.debug("done sending task result")
display.debug("done sending task result for task %s" % self._task._uuid)
except AnsibleConnectionFailure:
self._host.vars = dict()

View file

@ -20,18 +20,18 @@ from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import base64
import sys
import time
import traceback
from ansible.compat.six import iteritems, string_types, binary_type
from ansible import constants as C
from ansible.errors import AnsibleError, AnsibleParserError, AnsibleUndefinedVariable, AnsibleConnectionFailure
from ansible.errors import AnsibleError, AnsibleParserError, AnsibleUndefinedVariable, AnsibleConnectionFailure, AnsibleActionFail, AnsibleActionSkip
from ansible.executor.task_result import TaskResult
from ansible.module_utils._text import to_text
from ansible.playbook.conditional import Conditional
from ansible.playbook.task import Task
from ansible.plugins.connection import ConnectionBase
from ansible.template import Templar
from ansible.utils.encrypt import key_for_hostname
from ansible.utils.listify import listify_lookup_plugin_terms
@ -82,7 +82,7 @@ class TaskExecutor:
returned as a dict.
'''
display.debug("in run()")
display.debug("in run() - task %s" % self._task._uuid)
try:
try:
@ -471,16 +471,17 @@ class TaskExecutor:
if not self._connection or not getattr(self._connection, 'connected', False) or self._play_context.remote_addr != self._connection._play_context.remote_addr:
self._connection = self._get_connection(variables=variables, templar=templar)
hostvars = variables.get('hostvars', None)
if hostvars:
# only template the vars if the connection actually implements set_host_overrides
# NB: this is expensive, and should be removed once connection-specific vars are being handled by play_context
sho_impl = getattr(type(self._connection), 'set_host_overrides', None)
if hostvars and sho_impl and sho_impl != ConnectionBase.set_host_overrides:
try:
target_hostvars = hostvars.raw_get(self._host.name)
target_hostvars = hostvars.get(self._host.name)
except:
# FIXME: this should catch the j2undefined error here
# specifically instead of all exceptions
target_hostvars = dict()
else:
target_hostvars = dict()
self._connection.set_host_overrides(host=self._host, hostvars=target_hostvars)
self._connection.set_host_overrides(host=self._host, hostvars=target_hostvars)
else:
# if connection is reused, its _play_context is no longer valid and needs
# to be replaced with the one templated above, in case other data changed
@ -519,6 +520,10 @@ class TaskExecutor:
display.debug("running the handler")
try:
result = self._handler.run(task_vars=variables)
except AnsibleActionSkip as e:
return dict(skipped=True, msg=to_text(e))
except AnsibleActionFail as e:
return dict(failed=True, msg=to_text(e))
except AnsibleConnectionFailure as e:
return dict(unreachable=True, msg=to_text(e))
display.debug("handler run complete")
@ -532,7 +537,7 @@ class TaskExecutor:
vars_copy[self._task.register] = wrap_var(result.copy())
if self._task.async > 0:
if self._task.poll > 0 and not result.get('skipped'):
if self._task.poll > 0 and not result.get('skipped') and not result.get('failed'):
result = self._poll_async_result(result=result, templar=templar, task_vars=vars_copy)
#FIXME callback 'v2_runner_on_async_poll' here
@ -611,7 +616,7 @@ class TaskExecutor:
# there is another source of truth we can use
delegated_vars = variables.get('ansible_delegated_vars', dict()).get(self._task.delegate_to, dict()).copy()
if len(delegated_vars) > 0:
result["_ansible_delegated_vars"] = dict()
result["_ansible_delegated_vars"] = {'ansible_delegated_host': self._task.delegate_to}
for k in ('ansible_host', ):
result["_ansible_delegated_vars"][k] = delegated_vars.get(k)
@ -704,27 +709,12 @@ class TaskExecutor:
if isinstance(i, string_types) and i.startswith("ansible_") and i.endswith("_interpreter"):
variables[i] = delegated_vars[i]
conn_type = self._play_context.connection
if conn_type == 'smart':
conn_type = 'ssh'
if sys.platform.startswith('darwin') and self._play_context.password:
# due to a current bug in sshpass on OSX, which can trigger
# a kernel panic even for non-privileged users, we revert to
# paramiko on that OS when a SSH password is specified
conn_type = "paramiko"
else:
# see if SSH can support ControlPersist if not use paramiko
if not check_for_controlpersist(self._play_context.ssh_executable):
conn_type = "paramiko"
# if someone did `connection: persistent`, default it to using a persistent paramiko connection to avoid problems
if conn_type == 'persistent':
self._play_context.connection = 'paramiko'
# if using persistent connections (or the action has set the FORCE_PERSISTENT_CONNECTION attribute to True),
# if using persistent paramiko connections (or the action has set the FORCE_PERSISTENT_CONNECTION attribute to True),
# then we use the persistent connection plugion. Otherwise load the requested connection plugin
elif C.USE_PERSISTENT_CONNECTIONS or getattr(self, 'FORCE_PERSISTENT_CONNECTION', False):
if C.USE_PERSISTENT_CONNECTIONS or getattr(self, 'FORCE_PERSISTENT_CONNECTION', False):
conn_type == 'persistent'
else:
conn_type = self._play_context.connection
connection = self._shared_loader_obj.connection_loader.get(conn_type, self._play_context, self._new_stdin)

View file

@ -136,10 +136,13 @@ class TaskQueueManager:
handler_list = []
for handler_block in play.handlers:
handler_list.extend(_process_block(handler_block))
# then initialize it with the given handler list
self.update_handler_list(handler_list)
def update_handler_list(self, handler_list):
for handler in handler_list:
if handler._uuid not in self._notified_handlers:
display.debug("Adding handler %s to notified list" % handler.name)
self._notified_handlers[handler._uuid] = []
if handler.listen:
listeners = handler.listen
@ -148,6 +151,7 @@ class TaskQueueManager:
for listener in listeners:
if listener not in self._listening_handlers:
self._listening_handlers[listener] = []
display.debug("Adding handler %s to listening list" % handler.name)
self._listening_handlers[listener].append(handler._uuid)
def load_callbacks(self):
@ -333,7 +337,7 @@ class TaskQueueManager:
defunct = False
for idx,x in enumerate(self._workers):
if hasattr(x[0], 'exitcode'):
if x[0].exitcode in [-9, -15]:
if x[0].exitcode in [-9, -11, -15]:
defunct = True
return defunct

View file

@ -316,7 +316,7 @@ class GalaxyRole(object):
# bits that might be in the file for security purposes
# and drop any containing directory, as mentioned above
if member.isreg() or member.issym():
parts = member.name.replace(archive_parent_dir, "").split(os.sep)
parts = member.name.replace(archive_parent_dir, "", 1).split(os.sep)
final_parts = []
for part in parts:
if part != '..' and '~' not in part and '$' not in part:

View file

@ -162,6 +162,7 @@ class Inventory(object):
### POST PROCESS groups and hosts after specific parser was invoked
hosts = []
group_names = set()
# set group vars from group_vars/ files and vars plugins
for g in self.groups:
@ -169,10 +170,11 @@ class Inventory(object):
group.vars = combine_vars(group.vars, self.get_group_variables(group.name))
self.get_group_vars(group)
group_names.add(group.name)
hosts.extend(group.get_hosts())
host_names = set()
# get host vars from host_vars/ files and vars plugins
for host in self.get_hosts(ignore_limits=True, ignore_restrictions=True):
for host in hosts:
host.vars = combine_vars(host.vars, self.get_host_variables(host.name))
self.get_host_vars(host)
host_names.add(host.name)
@ -473,30 +475,20 @@ class Inventory(object):
"""
results = []
hostnames = set()
def __append_host_to_results(host):
if host.name not in hostnames:
hostnames.add(host.name)
if not host.implicit:
results.append(host)
groups = self.get_groups()
for group in groups.values():
if pattern == 'all':
if self._match(group.name, pattern):
for host in group.get_hosts():
if host.implicit:
continue
__append_host_to_results(host)
else:
if self._match(group.name, pattern) and group.name not in ('all', 'ungrouped'):
for host in group.get_hosts():
if host.implicit:
continue
__append_host_to_results(host)
else:
matching_hosts = self._match_list(group.get_hosts(), 'name', pattern)
for host in matching_hosts:
__append_host_to_results(host)
matching_hosts = self._match_list(group.get_hosts(), 'name', pattern)
for host in matching_hosts:
__append_host_to_results(host)
if pattern in C.LOCALHOST and len(results) == 0:
new_host = self._create_implicit_localhost(pattern)

View file

@ -96,6 +96,8 @@ class Group:
# isn't already a group with the same name
if self.name not in [g.name for g in group.parent_groups]:
group.parent_groups.append(self)
for h in group.get_hosts():
h.populate_ancestors()
self.clear_hosts_cache()

View file

@ -106,27 +106,42 @@ class Host:
def set_gathered_facts(self, gathered):
self._gathered_facts = gathered
def populate_ancestors(self):
# populate ancestors
for group in self.groups:
self.add_group(group)
def add_group(self, group):
self.groups.append(group)
# populate ancestors
for oldg in group.get_ancestors():
if oldg not in self.groups:
self.add_group(oldg)
if group not in self.groups:
self.groups.append(group)
def remove_group(self, group):
self.groups.remove(group)
if group in self.groups:
self.groups.remove(group)
# remove exclusive ancestors, xcept all!
for oldg in group.get_ancestors():
if oldg.name != 'all':
for childg in self.groups:
if oldg in childg.get_ancestors():
break
else:
self.remove_group(oldg)
def set_variable(self, key, value):
self.vars[key]=value
def get_groups(self):
groups = {}
for g in self.groups:
groups[g.name] = g
ancestors = g.get_ancestors()
for a in ancestors:
groups[a.name] = a
return groups.values()
return self.groups
def get_vars(self):

View file

@ -103,7 +103,6 @@ class InventoryParser(object):
self.lineno += 1
line = line.strip()
# Skip empty lines and comments
if not line or line[0] in self._COMMENT_MARKERS:
continue
@ -156,6 +155,9 @@ class InventoryParser(object):
for h in hosts:
self.groups[groupname].add_host(h)
#FIXME: needed to save hosts to group, find out why
self.groups[groupname].get_hosts()
# [groupname:vars] contains variable definitions that must be
# applied to the current group.
elif state == 'vars':
@ -202,7 +204,7 @@ class InventoryParser(object):
# 'all' at the time it was created.
for group in self.groups.values():
if group.depth == 0 and group.name not in ('all', 'ungrouped'):
if group.depth == 0 and group.name != 'all':
self.groups['all'].add_child_group(group)
def _parse_group_name(self, line):

View file

@ -70,7 +70,7 @@ class InventoryParser(object):
# 'all' at the time it was created.
for group in self.groups.values():
if group.depth == 0 and group.name not in ('all', 'ungrouped'):
self.groups['all'].add_child_group(Group(group_name))
self.groups['all'].add_child_group(group)
def _parse_groups(self, group, group_data):
@ -83,19 +83,19 @@ class InventoryParser(object):
if section in group_data and isinstance(group_data[section], string_types):
group_data[section] = { group_data[section]: None}
if 'vars' in group_data:
if group_data.get('vars', False):
for var in group_data['vars']:
if var != 'ansible_group_priority':
self.groups[group].set_variable(var, group_data['vars'][var])
else:
self.groups[group].set_priority(group_data['vars'][var])
if 'children' in group_data:
if group_data.get('children', False):
for subgroup in group_data['children']:
self._parse_groups(subgroup, group_data['children'][subgroup])
self.groups[group].add_child_group(self.groups[subgroup])
if 'hosts' in group_data:
if group_data.get('hosts', False):
for host_pattern in group_data['hosts']:
hosts = self._parse_host(host_pattern, group_data['hosts'][host_pattern])
for h in hosts:

View file

@ -44,9 +44,9 @@ except LookupError:
HAS_SURROGATEESCAPE = False
_COMPOSED_ERROR_HANDLERS = frozenset((None, 'surrogate_or_escape',
'surrogate_or_strict',
'surrogate_then_replace'))
_COMPOSED_ERROR_HANDLERS = frozenset((None, 'surrogate_or_replace',
'surrogate_or_strict',
'surrogate_then_replace'))
def to_bytes(obj, encoding='utf-8', errors=None, nonstring='simplerepr'):
@ -133,6 +133,9 @@ def to_bytes(obj, encoding='utf-8', errors=None, nonstring='simplerepr'):
return obj.encode(encoding, errors)
except UnicodeEncodeError:
if original_errors in (None, 'surrogate_then_replace'):
# We should only reach this if encoding was non-utf8 original_errors was
# surrogate_then_escape and errors was surrogateescape
# Slow but works
return_string = obj.encode('utf-8', 'surrogateescape')
return_string = return_string.decode('utf-8', 'replace')

View file

@ -62,7 +62,7 @@ def tower_auth_config(module):
if password:
auth_config['password'] = password
verify_ssl = module.params.get('tower_verify_ssl')
if verify_ssl:
if verify_ssl is not None:
auth_config['verify_ssl'] = verify_ssl
return auth_config

View file

@ -135,11 +135,11 @@ def content_to_dict(module, content):
content_dict = yaml.safe_load(content)
if not isinstance(content_dict, dict):
raise
raise Exception()
# Check if dict is empty and return an error if it's
if not content_dict:
raise
raise Exception()
except:
module.fail_json(msg="Unable to convert 'content' to a dict, please check if valid")

View file

@ -53,7 +53,9 @@ class Cli(CliBase):
NET_PASSWD_RE = re.compile(r"[\r\n]?password: $", re.I)
def __init__(self, *args, **kwargs):
super(Cli, self).__init__(*args, **kwargs)
self.default_output = 'text'
def connect(self, params, **kwargs):
super(Cli, self).connect(params, kickstart=False, **kwargs)

View file

@ -903,7 +903,7 @@ class AnsibleModule(object):
return context
def user_and_group(self, path, expand=True):
b_path = to_bytes(path, errors='surrogate_then_strict')
b_path = to_bytes(path, errors='surrogate_or_strict')
if expand:
b_path = os.path.expanduser(os.path.expandvars(b_path))
st = os.lstat(b_path)
@ -989,22 +989,22 @@ class AnsibleModule(object):
return changed
def set_owner_if_different(self, path, owner, changed, diff=None, expand=True):
b_path = to_bytes(path, errors='surrogate_then_strict')
b_path = to_bytes(path, errors='surrogate_or_strict')
if expand:
b_path = os.path.expanduser(os.path.expandvars(b_path))
path = to_text(b_path, errors='surrogate_then_strict')
if owner is None:
return changed
orig_uid, orig_gid = self.user_and_group(path, expand)
orig_uid, orig_gid = self.user_and_group(b_path, expand)
try:
uid = int(owner)
except ValueError:
try:
uid = pwd.getpwnam(owner).pw_uid
except KeyError:
path = to_text(b_path)
self.fail_json(path=path, msg='chown failed: failed to look up user %s' % owner)
if orig_uid != uid:
if orig_uid != uid:
if diff is not None:
if 'before' not in diff:
diff['before'] = {}
@ -1018,15 +1018,15 @@ class AnsibleModule(object):
try:
os.lchown(b_path, uid, -1)
except OSError:
path = to_text(b_path)
self.fail_json(path=path, msg='chown failed')
changed = True
return changed
def set_group_if_different(self, path, group, changed, diff=None, expand=True):
b_path = to_bytes(path, errors='surrogate_then_strict')
b_path = to_bytes(path, errors='surrogate_or_strict')
if expand:
b_path = os.path.expanduser(os.path.expandvars(b_path))
path = to_text(b_path, errors='surrogate_then_strict')
if group is None:
return changed
orig_uid, orig_gid = self.user_and_group(b_path, expand)
@ -1036,9 +1036,10 @@ class AnsibleModule(object):
try:
gid = grp.getgrnam(group).gr_gid
except KeyError:
path = to_text(b_path)
self.fail_json(path=path, msg='chgrp failed: failed to look up group %s' % group)
if orig_gid != gid:
if orig_gid != gid:
if diff is not None:
if 'before' not in diff:
diff['before'] = {}
@ -1052,15 +1053,15 @@ class AnsibleModule(object):
try:
os.lchown(b_path, -1, gid)
except OSError:
path = to_text(b_path)
self.fail_json(path=path, msg='chgrp failed')
changed = True
return changed
def set_mode_if_different(self, path, mode, changed, diff=None, expand=True):
b_path = to_bytes(path, errors='surrogate_then_strict')
b_path = to_bytes(path, errors='surrogate_or_strict')
if expand:
b_path = os.path.expanduser(os.path.expandvars(b_path))
path = to_text(b_path, errors='surrogate_then_strict')
path_stat = os.lstat(b_path)
if mode is None:
@ -1074,12 +1075,14 @@ class AnsibleModule(object):
mode = self._symbolic_mode_to_octal(path_stat, mode)
except Exception:
e = get_exception()
path = to_text(b_path)
self.fail_json(path=path,
msg="mode must be in octal or symbolic form",
details=str(e))
if mode != stat.S_IMODE(mode):
# prevent mode from having extra info orbeing invalid long number
path = to_text(b_path)
self.fail_json(path=path, msg="Invalid mode supplied, only permission info is allowed", details=mode)
prev_mode = stat.S_IMODE(path_stat.st_mode)
@ -1123,6 +1126,7 @@ class AnsibleModule(object):
raise e
except Exception:
e = get_exception()
path = to_text(b_path)
self.fail_json(path=path, msg='chmod failed', details=str(e))
path_stat = os.lstat(b_path)
@ -1137,10 +1141,11 @@ class AnsibleModule(object):
if attributes is None:
return changed
b_path = to_bytes(path, errors='surrogate_then_strict')
b_path = to_bytes(path, errors='surrogate_or_strict')
if expand:
b_path = os.path.expanduser(os.path.expandvars(b_path))
path = to_text(b_path, errors='surrogate_then_strict')
existing = self.get_file_attributes(b_path)
if existing.get('attr_flags','') != attributes:
attrcmd = self.get_bin_path('chattr')
@ -1163,6 +1168,7 @@ class AnsibleModule(object):
raise Exception("Error while setting attributes: %s" % (out + err))
except:
e = get_exception()
path = to_text(b_path)
self.fail_json(path=path, msg='chattr failed', details=str(e))
return changed
@ -1853,7 +1859,7 @@ class AnsibleModule(object):
try:
cwd = os.getcwd()
if not os.access(cwd, os.F_OK|os.R_OK):
raise
raise Exception()
return cwd
except:
# we don't have access to the cwd, probably because of sudo.
@ -1963,7 +1969,7 @@ class AnsibleModule(object):
else:
self.deprecate(d)
else:
self.deprecate(d)
self.deprecate(kwargs['deprecations'])
if self._deprecations:
kwargs['deprecations'] = self._deprecations
@ -2022,7 +2028,7 @@ class AnsibleModule(object):
(filename, algorithm, ', '.join(AVAILABLE_HASH_ALGORITHMS)))
blocksize = 64 * 1024
infile = open(filename, 'rb')
infile = open(os.path.realpath(filename), 'rb')
block = infile.read(blocksize)
while block:
digest_method.update(block)
@ -2358,7 +2364,7 @@ class AnsibleModule(object):
clean_args = []
is_passwd = False
for arg in to_clean_args:
for arg in (to_native(a) for a in to_clean_args):
if is_passwd:
is_passwd = False
clean_args.append('********')

View file

@ -1,5 +1,6 @@
#
# (c) 2015 Peter Sprygada, <psprygada@ansible.com>
# (c) 2017 Red Hat, Inc
#
# Copyright (c) 2016 Dell Inc.
#
@ -28,28 +29,103 @@
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
import re
from ansible.module_utils.network import register_transport, to_list
from ansible.module_utils.shell import CliBase
from ansible.module_utils.netcfg import NetworkConfig, ConfigLine
from ansible.module_utils.basic import env_fallback, return_values
from ansible.module_utils.network_common import to_list, ComplexList
from ansible.module_utils.connection import exec_command
from ansible.module_utils.netcfg import NetworkConfig,ConfigLine
_DEVICE_CONFIGS = {}
WARNING_PROMPTS_RE = [
r"[\r\n]?\[confirm yes/no\]:\s?$",
r"[\r\n]?\[y/n\]:\s?$",
r"[\r\n]?\[yes/no\]:\s?$"
]
dellos10_argument_spec = {
'host': dict(),
'port': dict(type='int'),
'username': dict(fallback=(env_fallback, ['ANSIBLE_NET_USERNAME'])),
'password': dict(fallback=(env_fallback, ['ANSIBLE_NET_PASSWORD']), no_log=True),
'ssh_keyfile': dict(fallback=(env_fallback, ['ANSIBLE_NET_SSH_KEYFILE']), type='path'),
'authorize': dict(fallback=(env_fallback, ['ANSIBLE_NET_AUTHORIZE']), type='bool'),
'auth_pass': dict(fallback=(env_fallback, ['ANSIBLE_NET_AUTH_PASS']), no_log=True),
'timeout': dict(type='int'),
'provider': dict(type='dict'),
}
def check_args(module, warnings):
provider = module.params['provider'] or {}
for key in dellos10_argument_spec:
if key != 'provider' and module.params[key]:
warnings.append('argument %s has been deprecated and will be '
'removed in a future version' % key)
if provider:
for param in ('auth_pass', 'password'):
if provider.get(param):
module.no_log_values.update(return_values(provider[param]))
def get_config(module):
contents = module.params['config']
def get_config(module, flags=[]):
cmd = 'show running-config '
cmd += ' '.join(flags)
cmd = cmd.strip()
if not contents:
contents = module.config.get_config()
module.params['config'] = contents
return NetworkConfig(indent=1, contents=contents[0])
else:
return NetworkConfig(indent=1, contents=contents)
try:
return _DEVICE_CONFIGS[cmd]
except KeyError:
rc, out, err = exec_command(module, cmd)
if rc != 0:
module.fail_json(msg='unable to retrieve current config', stderr=err)
cfg = str(out).strip()
_DEVICE_CONFIGS[cmd] = cfg
return cfg
def to_commands(module, commands):
spec = {
'command': dict(key=True),
'prompt': dict(),
'answer': dict()
}
transform = ComplexList(spec, module)
return transform(commands)
def run_commands(module, commands, check_rc=True):
responses = list()
commands = to_commands(module, to_list(commands))
for cmd in commands:
cmd = module.jsonify(cmd)
rc, out, err = exec_command(module, cmd)
if check_rc and rc != 0:
module.fail_json(msg=err, rc=rc)
responses.append(out)
return responses
def load_config(module, commands):
rc, out, err = exec_command(module, 'configure terminal')
if rc != 0:
module.fail_json(msg='unable to enter configuration mode', err=err)
commands.append('commit')
for command in to_list(commands):
if command == 'end':
continue
cmd = {'command': command, 'prompt': WARNING_PROMPTS_RE, 'answer': 'yes'}
rc, out, err = exec_command(module, module.jsonify(cmd))
if rc != 0:
module.fail_json(msg=err, command=command, rc=rc)
exec_command(module, 'end')
def get_sublevel_config(running_config, module):
contents = list()
current_config_contents = list()
running_config = NetworkConfig(contents=running_config, indent=1)
obj = running_config.get_object(module.params['parents'])
if obj:
contents = obj.children
@ -61,67 +137,8 @@ def get_sublevel_config(running_config, module):
current_config_contents.append(c.rjust(len(c) + indent, ' '))
if isinstance(c, ConfigLine):
current_config_contents.append(c.raw)
indent = indent + 1
indent = 1
sublevel_config = '\n'.join(current_config_contents)
return sublevel_config
class Cli(CliBase):
NET_PASSWD_RE = re.compile(r"[\r\n]?password:\s?$", re.I)
CLI_PROMPTS_RE = [
re.compile(r"[\r\n]?[\w+\-\.:\/\[\]]+(?:\([^\)]+\)){,3}(?:#) ?$"),
re.compile(r"\[\w+\@[\w\-\.]+(?: [^\]])\] ?[>#\$] ?$")
]
CLI_ERRORS_RE = [
re.compile(r"% ?Error"),
re.compile(r"% ?Bad secret"),
re.compile(r"Syntax error:"),
re.compile(r"invalid input", re.I),
re.compile(r"(?:incomplete|ambiguous) command", re.I),
re.compile(r"connection timed out", re.I),
re.compile(r"[^\r\n]+ not found", re.I),
re.compile(r"'[^']' +returned error code: ?\d+"),
]
def connect(self, params, **kwargs):
super(Cli, self).connect(params, kickstart=False, **kwargs)
self.shell.send('terminal length 0')
def configure(self, commands, **kwargs):
cmds = ['configure terminal']
cmds.extend(to_list(commands))
cmds.append('end')
cmds.append('commit')
responses = self.execute(cmds)
responses.pop(0)
return responses
def get_config(self, **kwargs):
return self.execute(['show running-configuration'])
def load_config(self, commands, **kwargs):
return self.configure(commands)
def commit_config(self, **kwargs):
self.execute(['commit'])
def abort_config(self, **kwargs):
self.execute(['discard'])
def save_config(self):
self.execute(['copy running-config startup-config'])
Cli = register_transport('cli', default=True)(Cli)

Some files were not shown because too many files have changed in this diff Show more