Commit graph

17001 commits

Author SHA1 Message Date
Toshio Kuratomi
59fa35446b Fix undefined vars in cnos module_utils
Fixing undefined vars across the codebase so that we can have pylint
catch them on every commit.

Some of the changes to this module_utils file are Python3 related => The
identifiers exist on python2 but not on Python3.  The changes should be
portable to both py2 (2.6+) and py3.

References #27193
2017-07-24 15:00:49 -07:00
Toshio Kuratomi
84285a741c Various fixes to ec2_vpc_dhcp_options module
* Stringify exception with a nicer error and include traceback
* Give a nice message if boto is not installed
* Fix undefined vars.  Cleaning up all undefined variables so that we
  can run static analysis on new commits.

  References #27193
2017-07-24 14:59:19 -07:00
bfloyd89
1f637f06a5 Make lambda_event.py python 2.6 compatible (#27241)
"Changed in version 2.7: The positional argument specifiers can be omitted, so '{} {}' is equivalent to '{0} {1}'."
2017-07-24 17:01:19 -04:00
Brian Coca
96d577c4c9 endswith supports tuples, nicer 2017-07-24 16:49:01 -04:00
Brian Coca
c7e841e0e4 better reading of 'facts' 2017-07-24 16:35:24 -04:00
Rob
3401a4b330 Rename classic elb modules to match new names applied to application LB modules (#25745) 2017-07-24 16:28:02 -04:00
Toshio Kuratomi
f22c04fa1e leftover from porting become to v2 that's unused
The set_become_default() function is not needed.  All this time, if it
was called it would try to set a value on a passed by value variable
(meaning that it had no effect after returning to the caller).  Since
become has been working in v2, this code is not needed.  Removing.
2017-07-24 10:12:17 -07:00
Toshio Kuratomi
6220c4aea1 Some enhancements to the symbolic_modes change
* Mark _symbolic_mode_to_octal and helper functions as classmethod and staticmethod
  These helpers should be made toplevel functions in their own module.
  For now, make them staticmethod/classmethod so that they can be used
  (and tested) without instantiating an AnsibleModule.
* Move regex compilation out of loops
* Get rid of python-2.4 compat
2017-07-24 10:08:51 -07:00
Dag Wieers
a5eea9042e vmware_host: Small fixes and docs updates (#25144)
* vmware_host: Small fixes and docs updates

This PR includes:
- A fix to no longer require a datacenter folder for adding a host
- Documentation improvements
- Ensure imports are specific

* Update vmware_host

Fix adds following:
* Update logic in vmware_host
* Update example documentation
* Added test case for vmware_host

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2017-07-24 13:02:58 -04:00
Abhijeet Kasurde
9649195c26 Refactor getvm method (#27188)
Fix refactors getvm method and modules which are using it.

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2017-07-24 12:51:26 -04:00
Toshio Kuratomi
fc5d71de0d 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
2017-07-24 09:19:04 -07:00
Toshio Kuratomi
aa9941aaf7 Fix legacy su handling (bad conditional would not fire at the right time) 2017-07-24 10:49:41 -04:00
Toshio Kuratomi
06617548ed Fix undefined vars in network module_utils
References #27193
2017-07-24 07:49:26 -07:00
Ton Kersten
134852e686 #14634: symbolic permissions error (#14994)
This fixes the symbolic notation of the chmod modes, as stated in the man page of chmod (in Linux). This also takes into account that chmod a+x is different from chmod +x. As the second one should take the current umask into account.

Fixes #14634
2017-07-24 06:33:56 -07:00
Ganesh Nalawade
ad4ecf2a64 Fix EntityCollection stacktrace (#27217) 2017-07-24 09:57:52 +05:30
Dag Wieers
be1c517f4d Add example of templating inline using copy module (#19752)
* Add example of templating inline using copy module

The **copy** module documentation implies that `content:` only works
for 'simple values' and for complex stuff you need the **template**
module, but that is an understatement. You can use **copy** to template
anything you desire.

So I changed the wording, added an example, and also added a note
to the template module that the **copy** module could be used for
'inline templating'.

This fixes #19741.
2017-07-22 22:12:31 -07:00
Toshio Kuratomi
4e8b28e404 Switch from map and filter to list comprehensions and generator expressions (#27198)
One of the complex map + filter + lambda combinations here was causing
pylint to have a rare false positive detecting undefined variables.

Switch to list comprehensions and generator expressions which are
easi(er) to read for humans and do not confuse pylint.

References #27193
2017-07-22 19:12:35 -07:00
Sam Doran
1c40631382 Use atomic_move rather than writing in place in redhat_subscription (#27132)
* Use atomic_move rather than writing in place in redhat_subscription and redhat utils

* Change status to curated

* Put curated in the proper field

* Add RETURN doc section

* Disable yum plugins when unregistering

* Change back to community supported

* Alphabetize imports
2017-07-21 18:22:58 -04:00
Evan Kaufman
e8a396be16 cron - validate filename portion of cron_file param (#19185)
* Validated filename from `cron_file` param, updated docs

Fixes ansible/ansible-modules-core#4795, moved from ansible/ansible-modules-core#5361

* Broke long warning message over multiple lines

See: https://github.com/ansible/ansible/pull/19185#issuecomment-302961152
2017-07-21 23:51:34 +02:00
Thomas Krahn
141c6d0d9d ipa_sudorule: Fix bug: get_sudorule_diff() takes exactly 2 arguments (3 given) (#21150) 2017-07-21 23:39:43 +02:00
Andrea Scarpino
4fb5221b5f timezone: Assuming UTC when no /etc/localtime exists (#27131) 2017-07-21 23:15:06 +02:00
Michael Scherer
e2d6ecfa40 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
2017-07-21 10:14:22 -07:00
Abhijeet Kasurde
ede82e2130 Implement vmware_argument_spec for required params (#25731)
Without the fix hostname, username and password params
used to skip required check.

Fixes #25696

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2017-07-21 12:12:43 -04:00
Toshio Kuratomi
007a3b9c9b Don't need to convert cmd to bytes as it is already an array of bytes
Fixes #27016
2017-07-21 11:55:43 -04:00
Yanis Guenane
70f52e3043 crypto: Build a base object for openssl modules (#26945)
More openssl modules are about to be made, each of them rewriting
some pieces of code that can be refactored and used via a common
library.

This commit aims to create this "base" object and the common functions
one might want to reuse in order to avoid duplication.
2017-07-21 11:54:04 -04:00
David Newswanger
fd771e580f replace str with to_native (#27135) 2017-07-21 09:32:57 -06:00
Anil Kumar Muraleedharan
08327fa459 Changing new Device name from <Device Name>_cnos to <Device Name> (#27025) 2017-07-21 11:18:59 +01:00
McBadass
0229476c44 Added ability to specify destination OU when joining a domain (#22393)
* Added ability to specify destination OU when joining a domain

* Updated win_domain_membership documentation to include OU destination option.

* Updated python to include version

* Additional info in the docs
2017-07-21 10:50:54 +10:00
Brian Coca
899527f3cb make yaml extensions configurable
fixes #25419
2017-07-20 20:29:09 -04:00
Brian Coca
aca11a28a2 allow for null values in yaml inventory (#26765)
* allow for null values in yaml inventory

* 3 dad3 dad3 dad3 dad3 dad3 dad3 dad3 dad
2017-07-20 20:28:09 -04:00
Jordan Borean
5c6e5d4841 win_domain_group: new module (#26682)
* win_domain_group: new module
2017-07-20 17:08:08 -07:00
Dag Wieers
18d9c34e9d win_command, win_shell: Use Fail-Json on failure (#26512)
Two reasons to do this:
- It provides a proper error message indicating why it failed
- It conforms to what is being done in the command and shell modules
2017-07-21 07:34:48 +10:00
Toshio Kuratomi
3a2afc7825 Allow copy to writable files in unwritable dirs (#23509)
unsafe_writes currently allows updating a file that can be updated but
not removed (for instance, when docker mounted).  This change also
allows unsafe_writes to write to writable files in unwritable dirs. For
instance, if a system has made a single file inside of /etc/ writable to
a specific normal user.

Fixes #14961
2017-07-20 12:41:57 -07:00
Andreas Olsson
063f5d0ca8 Set default user-agent for module_utils.urls fetch_url (#27095)
The HTTP User-Agent "ansible-httpget" is already kind of the default,
it being the default value provided by the `url_argument_spec` helper
method. Yet, it may not be practical for all modules to get their
argument_spec that way.

Without a default User-Agent we fall back on the library
User-Agent. That being something like "Python-urllib/2.7".

While I'm no big fan of web servers making decisions based on the
provided User-Agent I still think that part of being a well-behaved
HTTP client is to provide an informative User-Agent. Not to mention
that it's a good thing for Ansible to behave consistently.

Indirectly fixes #26239
2017-07-20 12:34:41 -07:00
Anil Kumar Muraleedharan
7c65272e2d Removing _cnos from all new devices added (#27101) 2017-07-20 12:34:08 -07:00
Ricardo Carrillo Cruz
857726e6b1 Make the 'not found' regex case sensitive (#27100)
Turns out in some commands, like 'sh bgp summary' a line containing
'Not found' can be shown as a column.
This causes those commands to error out with RC=1 .

Fixes #26577
2017-07-20 12:33:18 -07:00
Nathaniel Case
85e7e342b0 nxos_bgp_af correct parents (#26996)
* move config location

* client-to-client is inverse of BOOL_PARAMS
2017-07-20 13:42:26 -04:00
James Cammarata
640d057f3f Don't use _raw_params for IncludeRole objects (#26601)
IncludeRole objects don't use _raw_params for the name/etc. of roles
like regular incudes, but the code for finding relative includes assumed
that all includes had a _raw_params field. This fixes that by correctly
checking the parent object type and using the appropriate field.

Fixes #26525
2017-07-20 12:32:06 -05:00
Thomas Stringer
bf63301b34 Fix bug that was uncovered by comparing the port range which is inherently a string but ansible passes the param in as an implied int if the range does not contain a non-numeric char (#27017) 2017-07-20 11:47:43 -04:00
Gabor Lekeny
7eab802669 SSH fails with '"parsed": false' error message
Fixes: #15436
2017-07-20 08:09:42 -07:00
Brian Coca
8e0b89bdbf corrected precedence, added comments to each entry 2017-07-20 11:07:06 -04:00
Toshio Kuratomi
f86ce0975d Add a directory walker to copy
* We need a directory walker that can handle symlinks, empty directories,
  and some other odd needs.  This commit contains a directory walker that
  can do all that.  The walker returns information about the files in the
  directories that we can then use to implement different strategies for
  copying the files to the remote machines.
* Add local_follow parameter to copy that follows local symlinks (follow
  is for remote symlinks)
* Refactor the copying of files out of run into its own method
* Add new integration tests for copy

Fixes #24949
Fixes #21513
2017-07-20 08:01:29 -07:00
Toshio Kuratomi
753a3a03d0 Revert "Fix for recursive copy slowness"
This reverts commit 78ced5318f.

The fix for copy slowness did not handle circular symlinks.
2017-07-20 08:01:29 -07:00
Pilou
556a1daa33 fix searched paths in DataLoader.path_dwim_relative (avoid AnsibleFileNotFound) (#26729)
* add unit test: nested dynamic includes

* nested dynamic includes: avoid AnsibleFileNotFound error

Error was:
Unable to retrieve file contents
Could not find or access 'include2.yml'

Before 8f758204cf, at the end of
'path_dwim_relative' method, the 'search' variable contained amongst
others paths:
'/tmp/roles/testrole/tasks/tasks/included.yml' and
'/tmp/roles/testrole/tasks/included.yml'.
The commit mentioned before removed the last one despite the method
docstrings specify 'with or without explicitly named dirname subdirs'.

* add integration test: nested includes
2017-07-20 10:26:13 -04:00
Jack Price
aed35aba70 Always set result variable in cloudflare_dns module (#23683)
Fixes #23682
2017-07-20 14:16:37 +02:00
Ganesh Nalawade
5ab8d30d10 Add net_vrf implementation for junos (#27055)
*  junos_vrf implementation
*  junos_vrf integration test
*  net_vrf integration test for junos
2017-07-20 11:20:18 +05:30
Yanis Guenane
f40db199aa openssl_*: Allow user to specify privatekey passphrase
Allow a user to specify the privatekey passphrase when dealing with
openssl modules.
2017-07-19 18:21:30 -07:00
Jordan Borean
a260063ffd Added function to convert camelCase to snake_case for powershell (#26203)
* Added camel case to snake case converters

* removed uneeded shebang

* renamed util to remove PowerShell from the name
2017-07-19 16:57:05 -07:00
David Newswanger
9f64e446c6 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
2017-07-19 15:06:11 -07:00
David Newswanger
0b5b5ec50a fix unicode errors in iosxr 2017-07-19 14:51:35 -07:00