Commit graph

41689 commits

Author SHA1 Message Date
Toshio Kuratomi
bd072fe83a
Make the timeout decorator raise an exception out of the function's scope (#49921)
* Revert "allow caller to deal with timeout (#49449)"

This reverts commit 63279823a7.

Flawed on many levels

* Adds poor API to a public function
* Papers over the fact that the public function is doing something bad
  by catching exceptions it cannot handle in the first place
* Papers over the real cause of the issue which is a bug in the timeout
  decorator
* Doesn't reraise properly
* Catches the wrong exception

Fixes #49824
Fixes #49817

* Make the timeout decorator properly raise an exception outside of the function's scope

signal handlers which raise exceptions will never work well because the
exception can be raised anywhere in the called code.  This leads to
exception race conditions where the exceptions could end up being
hanlded by unintended pieces of the called code.

The timeout decorator was using just that idiom.  It was especially bad
because the decorator syntactically occurs outside of the called code
but because of the signal handler, the exception was being raised inside
of the called code.

This change uses a thread instead of a signal to manage the timeout in
parallel to the execution of the decorated function.  Since raising of
the exception happens inside of the decorator, now, instead of inside of
a signal handler, the timeout exception is raised from outside of the
called code as expected which makes reasoning about where exceptions are
to be expected intuitive again.

Fixes #43884

* Add a common case test.

Adding an integration test driven from our unittests.  Most of the time
we'll timeout in run_command which is running things in a subprocess.
Create a test for that specific case in case anything funky comes up
between threading and execve.

* Don't use OSError-based TimeoutError as a base class

Unlike most standard exceptions, OSError has a specific parameter list
with specific meanings.  Instead follow the example of other stdlib
functions, concurrent.futures and multiprocessing and define a separate
TimeoutException.

* Add comment and docstring to point out that this is not hte Python3 TimeoutError
2018-12-18 18:01:46 -08:00
Tom Dietrich
2b48c0187c Warn of standard behavior of 'default' key store (#49903)
* Warn of standard behavior of 'default' key store 

The default key store typically results in the key being stored as user. In instances where we're trying to install a cert to enable SSL binding in IIS, this will result in an unbind-able cert, as the IIS APPPOOL identity will not be able to read the private key, and presents a very cryptic error of 'A specified logon session does not exist'.


+label: docsite_pr

* fix trailing whitespace

* Use C(user) reference

* specify what's required for successful iis import

- store_location's default value is currently 'LocalMachine' but if this changes it could result in the documentation being inaccurate
- key_exportable is not required for a successful IIS import

* remove stray =

dang cat

Co-Authored-By: tdietrich513 <tom.dietrich@gmail.com>
2018-12-19 11:13:31 +10:00
Toshio Kuratomi
947c4300ee Fix return types
We're now stricter on naming the return types.  Replace string with str.
2018-12-18 15:14:08 -08:00
Dag Wieers
05c6ff79f9 Convert to reduced list of known types (#50010) 2018-12-19 07:25:30 +10:00
Toshio Kuratomi
fcd1486b51 VALID_ACTIONS for cli subcommands will now be a frozenset (#50058) 2018-12-19 07:03:22 +10:00
Martin Krizek
545edc9114 facts: detect FreeBSD KVM guests (#50030)
Fixes: #49158
2018-12-19 06:57:53 +10:00
Martin Krizek
29c3bb48e9 facts: correctly detect multiple ipv6 addresses per device (#50020)
Fixes #49473
2018-12-19 06:49:28 +10:00
Yannig Perré
6b41588e93 Fix with_ini example and unittest
* Fix example in ini.py
* Fix unittest in test_ini.py to pass CI as latest ansible returns list in
  different order. To prevent such issues in future results are sorted
* PEP8 E501 styling improvements

Co-Authored-By: Sergii Golovatiuk <sgolovat@redhat.com>
2018-12-18 12:25:02 -08:00
Abhijeet Kasurde
1e4ab5a038 Return correct error message to user
botocore.exceptions.ClientError does not have message, which
fails fail_json.

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2018-12-18 12:23:18 -08:00
Abhijeet Kasurde
139e3477a7 Review comments
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2018-12-18 12:20:35 -08:00
Abhijeet Kasurde
44bd8fc0a8 Update unit tests for configmanager
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2018-12-18 12:20:35 -08:00
Jordan Borean
efda3eaf1c
win_lineinfile - fix malformed returned json (#50066) 2018-12-19 05:39:25 +10:00
Dag Wieers
7fb1a71a2c
no-smart-quotes: Skip files by path in code-smell (#45881)
* no-smart-quotes: Skip files by path in code-smell

This is to ensure the generated docs do not trigger code-smell issues on
contributor systems.

* Implement feedback from review
2018-12-18 20:33:18 +01:00
Michaël de Groot
13f2b29305 Small documentation update: Clarify daemon-reload always executing. (#49889)
* Small documentation update
* shortens and clarifies line
2018-12-18 12:22:57 -06:00
Michael Scherer
2734895c48 Do switch to apt if aptitude is not installed (#30738)
Trying to use the apt module on a freshly install 16.04 Ubuntu VM with
"ansible -m apt -a 'name=* state=latest' all" fail with this backtrace:

  Traceback (most recent call last):
    File \"/tmp/ansible_2inxygge/ansible_module_apt.py\", line 1055, in <module>
      main()
    File \"/tmp/ansible_2inxygge/ansible_module_apt.py\", line 998, in main
      upgrade(module, 'yes', force_yes, p['default_release'], use_apt_get, dpkg_options)
    File \"/tmp/ansible_2inxygge/ansible_module_apt.py\", line 759, in upgrade
      apt_cmd_path = m.get_bin_path(apt_cmd, required=True)
    File \"/tmp/ansible_2inxygge/ansible_modlib.zip/ansible/module_utils/basic.py\", line 2182, in get_bin_path
    File \"/usr/lib/python3.5/posixpath.py\", line 89, in join
      genericpath._check_arg_types('join', a, *p)
    File \"/usr/lib/python3.5/genericpath.py\", line 143, in _check_arg_types
      (funcname, s.__class__.__name__)) from None
    TypeError: join() argument must be str or bytes, not 'NoneType'

It seems that since aptitude is not installed on Xenial, so APTITUDE_CMD is None
and we later hit the bug in the upgrade function since it assume APTITUDE_CMD
is set.
2018-12-18 12:48:11 -05:00
Matt Martz
6025990fe9
Remove the use of mock from validate-modules (#50098)
* Remove the use of mock from validate-modules

* Monkeypatch AnsibleModule.__init__ not AnsibleModule
2018-12-18 11:44:17 -06:00
Dag Wieers
ee29ba5d4f plugin_formatter.py: Improve the output when processing docs (#46541)
* Improve the output when processing files

* Update docs/bin/plugin_formatter.py

Co-Authored-By: dagwieers <dag@wieers.com>

* Show progress indicator.

* Don't pp.pformat() huge structures when they aren't used anyway.

This saves ~10 seconds on my machine.

* Only show ASCII spinner if stdout is a TTY.

* Fix: E722 do not use bare 'except'
2018-12-18 11:23:49 -06:00
Toshio Kuratomi
40144c7486 Remove dead code in ansible-inventory
This piece of code is only needed with ansible < 2.3.x (which is now EOL)
2018-12-18 08:58:38 -08:00
Dag Wieers
9bc401a272 Remove older version_added information from docs (#50097) 2018-12-18 10:50:07 -06:00
Brian Coca
88c87a3583
added handlers_from (#49220)
* added handlers_from

fixes #46769
2018-12-18 11:28:24 -05:00
Xander Madsen
1e415899ad GetManagerNicInventory (#49961)
* Add GetManagerNicInventory command for Manager category, and tweak redfish_utils' get_nic_inventory to accommodate manager nic interfaces

* Remove get_manager_nic_inventory, since it is unnecessary while using get_manager in get_nic_inventory

* Rework get_nic_inventory() to take a resource_type as a string, which will be just the category parameter from redfish_facts, making it clearer

* remove extraneous blank line to conform with pep8

* Add GetManagerNicInventory example task to EXAMPLES docstring
2018-12-18 09:58:17 -06:00
Dag Wieers
15d39f9108 Sanity fixes in various modules (#50080) 2018-12-18 09:53:46 -06:00
Nathaniel Case
6caed0c38b
ios retry config if section filter fails (#49485)
* Attempt to work around devices that don't understand | section

* Fix case of no flags
2018-12-18 10:34:32 -05:00
Sviatoslav Sydorenko
625a2d1470
Upgrade README to have 4k+ contributors listed (#50093) 2018-12-18 15:50:19 +01:00
rajaspachipulusu17
d28e700a22 Pluribus networks admin session timeout module with unit tests (#50012)
* Pluribus networks admin session timeout module with unit tests
* Doc fix
* Removed unused imports
* Removed unwanted global variable
2018-12-18 17:23:45 +05:30
Christian Kotte
f123f894df Improve module vmware_local_role_manager (#47870)
* add check mode support
* improve output
2018-12-18 17:10:10 +05:30
Christian Kotte
e65b721283 VMware: new module vmware_host_ad_auth (#47901) 2018-12-18 16:34:11 +05:30
Ondra Machacek
e733d6e557 Fix activate of the disks in ovirt_vm and ovirt_disk modules (#49762)
* ovirt_disk: Add activate parameter

* ovirt_vm: Fix waiting on lun disks

Signed-off-by: Ondra Machacek <omachace@redhat.com>
2018-12-18 05:54:27 -05:00
Christian Kotte
f431e5b0e2 VMware: new module vmware_dvswitch_uplink_pg (#48846) 2018-12-18 16:14:18 +05:30
Felix Fontein
92ef500185 openssl_privatekey: add ECC support (#49416)
* Add cryptography backend for openssl_privatekey.

* Adding ECC support.

No support for X25519 and X449, since they don't support serialization.

* Improve finterprint calculation to work with Python 3.

* Add fingerprint check.

* Fix typo.

* Use separate curve option for elliptic curves, and use type 'ECC'.

* Using curve names as defined in IANA registry.

* Bump minimal supported cryptography version. Older versions might work as well, but I couldn't test them.

* Improve documentation.
2018-12-18 09:07:36 +00:00
Zim Kalinowski
6d952e4124 fixing vm state change when vm created with attached disk (#50071)
* fixing vm state change when vm created with attached disk

* minor fixes

* fixing hanging indent
2018-12-18 03:49:31 -05:00
Dag Wieers
c1ac87794e
ACI: Fix module parameters (#50051)
* Fix parameter type of private_key

* Fix parameters of various ACI modules
2018-12-18 09:30:28 +01:00
rajaspachipulusu17
cf00880ab3 Pluribus Networks dscp map module with unit tests (#49849)
* Pluribus Networks dscp map module with unit tests
* Doc string fix
2018-12-18 12:50:16 +05:30
rajaspachipulusu17
4d88cdd83a Pluribus Networks cpu class module with unit tests (#49847)
* Pluribus Networks cpu class module with unit tests
* Doc string fixes
2018-12-18 12:42:33 +05:30
Ganesh Nalawade
3163780829
Add force_host and issu options support in junos_package module (#50018)
Fixes #48171
Fixes #33742

Add force_host and issu options support in junos_package module
*  Add force_host option to ignore warnings while installing package
*  Add issu option to enable issu feature from Ansible
2018-12-18 10:51:29 +05:30
Matt Clay
61b5adcf31 Add OverlayFS work-around for CloudStack tests. 2018-12-17 15:45:31 -08:00
Sandra McCann
b873f34ea3 link to KB article -certified modules (#50050) 2018-12-17 16:27:28 -06:00
Dag Wieers
5739ccb6c3 PSRP: Add support for reconnection retries (#49772)
* PSRP: Add support for reconnection retries

This adds support for reconnection retries to overcome sudden Connection
Refused or other recoverable states. (Either because WinRM is (re)started,
or firewall changes make it briefly unavailable)

* Fixes from review comments
2018-12-18 08:20:53 +10:00
Dag Wieers
244c4c893d Add types to files fragment (#49996) 2018-12-17 17:16:35 -05:00
Gregory Storme
f461025dbb fix facts memtotal_mb rounding on VMWare and swaptotal_mb conversion from KB to MB (#49940) 2018-12-18 08:09:19 +10:00
Jérémy Lecour
2fb9b46752 Lineinfile must not insert lines multiples times with insertbefore/insertafter (#49409)
* Change test suite to fit expected behaviour

This reverts some changes from ansible/ansible@723daf3
If a line is found in the file, exactly or via regexp matching, it must 
not be added again.
insertafter/insertbefore options are used only when a line is to be 
inserted, to specify where it must be added.

* Implement the change in behaviour mentioned in the previous commit

* Fix comment to reflect what the code does

* Set the correct return message.

In these cases, the lines are added, not replaced.

* Add a changelog
2018-12-17 16:42:24 -05:00
Matt Martz
7eb1ab45a7
Allow tags to be templated from a variable (#49833)
* Allow tags to be templated from a variable. Fixes #49825

* Restore _load_tags to ensure we do csv tag splitting

* Add tests for csv tags and templated tags

* evaluate_tags doesn't need to accept strings, because _load_tags handles this
2018-12-17 15:40:26 -06:00
Matt Martz
a0d71e7735
Fix reverse_inventory order to work on python3 (#49895) 2018-12-17 15:39:29 -06:00
Aleksander Kovtunenko
ba562043e1 changed if logic Type to boolean (#49628)
* changed Type to boolean

* fix after review

* created fragment
2018-12-17 16:21:36 -05:00
Matt Clay
0ccd231afd
Fix MySQL tests when running under Docker. (#50047) 2018-12-17 12:59:40 -08:00
Dag Wieers
a8292778f0 Fix GitHub handle, use keachi (#50043)
* Fix GitHub handle, use keachi

* Add UTF8 name
2018-12-17 19:35:49 +00:00
Toshio Kuratomi
61b1daa65f Port from plaform.dist to ansible.module_utils.distro.linux_distribution
ci_complete
2018-12-17 11:01:01 -08:00
Adrian Likins
be65d9cfe5 Skip sanity tests that don't apply to bundled code
* add distro to pep8 skip tests
* Skip no-assert test for distro
* Add bundled distro to the empty-init skip list
2018-12-17 11:01:01 -08:00
Adrian Likins
e872811b8d WIP: add tests to compare to platform.*dist
Can be removed once everything is ported.
2018-12-17 11:01:01 -08:00
Adrian Likins
78a8d09082 Changes to bundled distro to be Python-2.6 compatible
* Port bundled distro to use optparse instead of argparse (py2.6)
* Use an absolute import to satisfy the current import testing harness
* Port from subprocess.check_output to subprocess.Popen.communicate() (py2.6)
* Add license location

The changes have been proposed upstream here:
https://github.com/nir0s/distro/pull/232

Upstream is contemplating a branch where everyone wanting python-2.6
support can collaborate without it becoming part of the regularly
supported releases.
2018-12-17 11:01:01 -08:00