Commit Graph

632 Commits (e9270fb100f4d550888513b2af37b185d6e7d838)

Author SHA1 Message Date
Kamil Cholewiński ec9582fd83 Fix invocations of module.fail_json with no msg=
Bonus: add missing % in cs_nic.py
2017-03-07 10:17:14 -05:00
John R Barker 284b3e42d1 timezone: Inline emphasis start-string without end-string (#22292)
Fixes
`docs/docsite/rst/timezone_module.rst:20: WARNING: Inline emphasis start-string without end-string.`
2017-03-05 08:29:27 +00:00
Pierre-Louis Bonicoli fb8aa5637a systemd: return an error when systemctl command isn't available 2017-03-02 10:13:24 -05:00
molekuul ef79932d16 added new RETURN block (#22183) 2017-03-02 12:51:31 +00:00
Fabrizio Colonna f0de1e6c85 Added parted module (#20399)
* Added parted module

* Amended documentation

* Improved documentation

* Managed the case of parted not returning device information.

* Fixed Shippable test not passing

* Fixed compatibility with Python 2.4

* Cleanup of the state option, improved flags management, documentation refinements.

* Compacted format function, code style cleanups, amended comments.

* Fixed bug related to parted data parsing.

* Support for check-mode, amended size data type.

* Fixed Shippable test not passing.

* Added full suport for CHS and CYL units, applied suggested changes.
2017-03-01 22:31:04 +01:00
Matt Martz 305c88700d PEP8 E712 fixes (#21916) 2017-02-24 16:49:43 -06:00
John R Barker 1d2349872a RETURN block is broken, so delete it 2017-02-24 20:44:48 +00:00
Adrian Likins 78c4f03e50 Fix firewalld get_masquerade_enabled_permanent error (#21693)
get_masquerade_* functions only take one arg. The action_handler
wrapper function expected a tuple, but was being passed (zone)
instead of (zone,) making for an ambiquous tuple. The
(zone) arg was being treated as a tuple/list of six chars
(the zone name) instead of a tuple of one string.

This would cause errors like:

        get_masquerade_enabled_permanent() takes exactly 1 argument (6 given)

Fixes #21632
2017-02-24 12:32:28 -05:00
molekuul 7734dd5890 Add the aix_inittab module to be able to modify the inittab at AIX systems (#21511)
* Added the aix_inittab module to be able to modify the inittab at AIX systems.

* fixed identation errors

* fixed identations and trailing whitespace
changed if conditions

* repaired tab-identation

* adjusted to long line and identation

* Adjusted the yaml in the example documentation

* Adjusted the documentation yaml

* Repaired return yaml

* repaired typo

* Removed unnecessary parameters from comment
changed action to state, and changed the way to call this module
changed proccessaction to action

* adjusted result['warnings'] to module.warn()

* adjusted the documentation

* changed warning to failed
ran module against autopep8

* added check_mode

* fixed typo

* changed description and short description, to be able to push again after a failure at shippable
2017-02-23 13:36:26 -05:00
Matt Clay 4554e8d769 Remove unnecessary shebangs and execute bits. 2017-02-22 18:13:46 -08:00
Brian Coca b3b76826e5 Revert "allow device to be list for multidev fs" 2017-02-17 17:31:08 -05:00
Matt Martz 7c00346714 Validate EXAMPLES as YAML 2017-02-15 13:01:43 -08:00
Adrian Likins 106439e470 Handle sysctl.conf files that use ';' for comments (#20576)
'#' and ';' are both valid comment chars for sysctl.conf files
according to the 'man sysctl.conf':

  "Lines which begin with a # or ; are considered comments and ignored."

Fixes #20569
2017-02-15 13:37:09 -05:00
Jiri Tyr 9008e8017b Fixing mounting of multiple sources to the same dest (#21413) 2017-02-14 09:09:48 -08:00
Jiri Tyr d94b2d802e Fixing broken bind mount on CentOS 7 (#20703)
* Fixing broken bind mount on CentOS 7
* Fixing remount
2017-02-14 08:17:21 -08:00
Brian Coca 2cb658925b fixed for chrrot as ignore error still has rc=0 2017-02-13 14:47:39 -05:00
Dag Wieers f824b2ce8d Avoid having module documentation links to itself (#21329)
* Avoid having module documentation links to itself

A lot of modules use M(own_module) in their documentation causing a link
in the documentation to itself.

* Make note more clear now
2017-02-13 14:02:34 +00:00
Brian Coca fa93bf7096 allow more than .service, onus on user 2017-02-10 18:12:02 -05:00
Brian Coca 2f0070639f attempt to fix systemd in chroot env
fixes #21026
2017-02-10 18:12:02 -05:00
Brian Coca 74e8aa22af no log passwords (#21229)
* no log passwords

* removed unneeded no_log
2017-02-10 15:13:59 -05:00
Brian Coca 300718e811 use new 'warn' method
this also prevents warnings from being lost
2017-02-08 15:53:58 -05:00
Marius Gedminas 2efb692cc4 known_hosts: support --diff (#20349)
* known_hosts: support --diff

* known_hosts: support --diff also without --check

* Add unit tests and fix incorrect diff in one corner case

Tests are good!

* Refactor for readability

* Python 3 compat

* More Python 3 compat

* Add an integration test for known_hosts

* Handle ssh-keygen -HF returning non-zero exit code

AFAICT this is a bug in ssh-keygen in some newer OpenSSH versions
(>= 6.4 probably; see commit dd9d5cc670):
when you invoke ssh-keygen with -H and -F <host> options, it always
returns exit code 1.  This is because in ssh-keygen.c there's a function
do_known_hosts() which calls

  exit (find_host && !ctx.found_key);

at the end, and find_host is 1 (because we passed -F on the command line),
but ctx.found_key is always 0.  Why is found_key always 0?  Because the
callback passed to hostkeys_foreach(), which is known_hosts_hash(),
never bothers to set found_key to 1.

* This test does not need root

* Avoid ssh-ed25519 keys in sample known_hosts file

Older versions of OpenSSH do not like them and ssh-keygen -HF
aborts with an error when it sees such keys:

  line 5 invalid key: example.net...
  /root/ansible_testing/known_hosts is not a valid known_hosts file.

* Fix Python 3 errors

Specifically, the default mode of tempfile.NamedTemporaryFile is 'w+b',
which means Python 3 wants us to write bytes objects to it -- but the
keys we have are all unicode strings.
2017-02-08 09:56:03 -05:00
Brian Coca 8d17055831 error out if systemctl isn't present 2017-02-06 14:52:24 -05:00
Imran Hussain d7bf3749b7 Add Check Mode capability to kernel_blacklist module (#21007)
* Add Check Mode capability to kernel_blacklist module
* Add suggested changes from @tmshn
* Pass a bool into `Blacklist` that'll just be `module.check_mode`
* Move detection and creation of a file to a separate function within `Blacklist`
* If there's no file on the system and we are running under `Check Mode`, set `self.filename` to `os.devnull` AND mark a change, as the module would have created an empty file.
* Whenever a `self.filename` is being opened in a mode where changes can be made, replace with an if statement that checks `self.checkmode` and if true then open up `os.devnull` instead
2017-02-06 13:00:31 -05:00
Matt Martz 829c0b8f62 Update validate-modules (#20932)
* Update validate-modules

* Validates ANSIBLE_METADATA
* Ensures imports happen after documentation vars
* Some pep8 cleanup

* Clean up some left over unneeded code

* Update modules for new module guidelines and validate-modules checks

* Update imports for ec2_vpc_route_table and ec2_vpc_nat_gateway
2017-02-02 11:45:22 -08:00
Brian Coca 91b363ea9e allow device to be list for multidev fs (#20655)
* allow device to be list for multidev fs

fixes #20551

* reverted command to string
2017-02-01 13:13:12 -05:00
Matt Clay cb76200c7d PEP 8 E111 & E114 cleanup. (#20838) 2017-01-30 15:01:47 -08:00
Toshio Kuratomi 61ccc847d7 Fix service's exec_command() for python3 (#20826)
* Fix service's exec_command() for python3

exec_command() was mixing text and bytes in several places on python3.
Made changes so that we explicitly convert between the two.

Fixes #20818

* Also handle basestring and shlex.split in a python2/python3 compatible fashion
2017-01-30 13:08:31 -05:00
Brian Coca 294a23d7f6 renamed sv to runit, avoid svc confusion 2017-01-30 10:24:43 -05:00
James Sumners 693c176f43 Add sv module to manage runit services #20181 (#20471)
* Add sv module to manage runit services

* Add mission `restarted` method
2017-01-30 10:22:54 -05:00
Matt Clay 10d9318de7 PEP 8 indent cleanup. (#20800)
* PEP 8 E121 cleanup.

* PEP 8 E126 cleanup.

* PEP 8 E122 cleanup.
2017-01-29 07:28:53 +00:00
Matt Clay e2c0b375d3 PEP 8 cleanup. (#20790)
* PEP 8 E115 cleanup.
* PEP 8 E131 cleanup.
2017-01-28 01:39:40 -08:00
Matt Clay d0d1158c5e PEP 8 cleanup. (#20789)
* PEP 8 E703 cleanup.
* PEP 8 E701 cleanup.
* PEP 8 E711 cleanup.
* PEP 8 W191 and E101 cleanup.
2017-01-28 00:12:11 -08:00
Matt Clay d913f69ba1 PEP 8 W291 whitespace cleanup. 2017-01-27 17:08:02 -08:00
Matt Clay 95789f3949 PEP 8 whitespace cleanup. (#20783)
* PEP 8 E271 whitespace cleanup.
* PEP 8 W293 whitespace cleanup.
* Fix whitespace issue from recent PR.
2017-01-27 15:45:23 -08:00
Matt Clay 63b1e0c277 Fix infrequent PEP 8 issues. 2017-01-27 14:06:21 -08:00
Jasper Lievisse Adriaanse 4a594b3702 Synchronous actions were introduced in Solaris 11.2 to be precise. 2017-01-25 14:51:55 -05:00
Jasper Lievisse Adriaanse a412be32b5 The '-s' option for restart/refresh is only supported on Oracle Solaris >= 11
Closes #20102
2017-01-25 13:57:40 -05:00
Brian Coca f8f0c4abc8 added formatting 2017-01-23 13:29:14 -05:00
Brian Coca f00490007c actually fix tickets in previous commit
both modules had similar issues and i conflated them
2017-01-23 13:28:34 -05:00
Brian Coca f86e6a2152 updated timezone docs to avoid repainting bikeshed
fixes #19272
fixes #20570
2017-01-23 13:24:06 -05:00
Brian Coca 19496b5b73 fix service status setting
fixes #18687 as 'disabled' can be at the end of the output
fixes #20228 by not falling back to init scripts when it is a user service
2017-01-19 18:57:47 -05:00
Fabio Alessandro Locati 7a275f61de system/beadm: improve examples (#20461) 2017-01-19 17:14:01 +00:00
Toshio Kuratomi 09ceaafd42 Removal wildcard import and unnecessary exception retrieval 2017-01-16 12:12:00 -08:00
Brian Coca 32b7f85f6c clarified docs on timezone module 2017-01-16 11:05:36 -05:00
Jasper Lievisse Adriaanse b0e23049a0 Timezone: Support for FreeBSD/NetBSD and improve SmartOS handling (#20268)
* Tweaks for SmartOS:

- prevent attempting from changing timezone in the global zone (read-only)
- provide meaningful error message in the unlikely case smtools isn't present

* Add support for FreeBSD and NetBSD to timezone module
2017-01-16 10:54:39 -05:00
Tobias Wolf f1ae2eb4f1 systemd: Add boolean option to enable --no-block
In our environment we have custom services that need to be stopped and
restarted very gracefully to not interrupt active sessions.

A stop job, depending on the state, can take up to 20 minutes until the
process exits. It simply reacts to SIGTERM with a graceful shutdown.

By default, systemctl blocks until the job has completed, which leads to
Ansible hanging on this task for up to 20 minutes.

Thankfully systemctl supports the `--no-block` flag which lets the job
continue in the background.

This PR adds support for that flag as the `no_block` boolean option.

From the man page:

   --no-block
       Do not synchronously wait for the requested operation to
       finish. If this is not specified, the job will be
       verified, enqueued and systemctl will wait until the
       unit's start-up is completed. By passing this argument,
       it is only verified and enqueued. This option may not be
       combined with --wait.
2017-01-13 16:26:06 -05:00
Dag Wieers 1ad55ec9de Consistent path attribute for file-related modules
Not all file-related modules consistently use "path" as the attribute to specify a single filename, some use "dest", others use "name". Most do have aliases for either "name" or "destfile".

This change makes "path" the default attribute for (single) file-related modules, but also adds "dest" and "name" as aliases, so that people can use a consistent way of attributing paths, but also to ensure backward compatibility with existing playbooks.

NOTE: The reason for changing this, is that it makes Ansible needlessly harder to use if you have to remember that e.g. the xattr module requires the name attribute, the lineinfile module requires a dest attribute, and the stat module requires a path attribute.
2017-01-13 15:49:42 -05:00
Jasper Lievisse Adriaanse e9038d8dc1 Add support for OpenBSD and SmartOS to timezone module 2017-01-13 14:45:54 -05:00
Jasper Lievisse Adriaanse 0988de8c4c Remove outdated requirements and add a note trying to reflect reality. 2017-01-13 12:16:23 -05:00
Jasper Lievisse Adriaanse 2ea5bb8dbb Fix required_one_of in timezone module (#20185) 2017-01-12 16:35:14 +00:00
Michael Kwardakov 0183a148c5 Update cronvar.py (#19227) 2017-01-11 18:56:34 -05:00
Jasper Lievisse Adriaanse b384a0f795 timezone: Tidy up docs and arg parsing (#20133)
* Small tweaks for timezone module:

- small textual fixes
- ensure the generated docs list either hwclock or name as required
  by using a non-generated value for required_one_of

* Update docs with the DOCUMENTATION block about either name/hwclock being required
2017-01-11 15:22:27 +00:00
Brian Coca afbe3bd63f corrected service condition 2017-01-09 15:44:53 -05:00
James Cooke fafe5bba59 Fix authorized_key crash in Python3 with remote key file (#20037)
* Decode downloaded keys bytes if Python3
* Fixes #20007
* Thanks @georgepsarakis
2017-01-09 12:21:51 -08:00
Evan Kaufman ad9c25a54f Apply SELinux context only if cron_file param exists
Use selinux calls in module_utils/basic instead of native selinux bindings

Fixes #18768
2017-01-09 14:02:05 -05:00
Valentín Gutiérrez 6c448d3673 Fix pamd module (#20048)
* Fix string_types usage

* Fix adding arguments for argument=value arguments

* Remove unnecesary check on module_args

* Fix argument requirements

* Proper handling of parameter=value arguments
2017-01-09 09:30:32 -08:00
Brian Coca 0ef60aeacb improved negative service status handling
This is still far from optimal but the nature of the initscripts does not really allow for much better.
fixes #20028
2017-01-09 11:09:11 -05:00
Adam Števko d9ced3f4d1 Modules for gathering facts about ZFS datasets and pools (#19181)
* Add modules for gathering facts about ZFS datasets and pools

* Move zfs module to storage/zfs subcategory

* Replace dict.iteritems() with iteritems(dict)

* Add ANSIBLE_METADATA
Document return values
Make imports explicit
Use native YAML syntax in EXAMPLES

* Add zfs_facts and zpool_facts modules to CHANGELOG.md

* Add facts to return values
2017-01-09 07:53:42 +00:00
Adam Števko 3744764fae Add module for managing boot environments on FreeBSD/Solaris/illumos … (#19180)
* Add module for managing boot environments on FreeBSD/Solaris/illumos systems

* Add ANSIBLE_METADATA
Document return values
Make imports explicit
Use native YAML syntax in EXAMPLES

* Add beadm module to CHANGELOG.md

* Update version to 2.3
2017-01-09 07:52:06 +00:00
Toshio Kuratomi 08d6990e67 Fix code-blocks to use correct syntax highlighting 2017-01-08 09:18:45 -08:00
Fabio Alessandro Locati 2790999ee9 Add output (#19212) 2017-01-08 15:33:05 +00:00
Fabio Alessandro Locati 85f7d2b97a authorized_key: doc: Improve example description (#19209) 2017-01-08 12:28:29 +01:00
Ken Evensen 99e19ad617 Minor rework of pamd module. Fixed some documentation. (#19758)
* Minor rework.  Fixed some documentation.

* Requested changes in the case the arg is unicode
2017-01-05 15:48:24 -08:00
Toshio Kuratomi 5536ffe978 Fix OSX defaults for lists
In modern ansible, parameters default to string type.  This causes
issues for polymorphic parameters like this module's value param.  note
that this fix restores ansible-2.0 and previous behaviour but it is not
perfect.  If a parameter is specified via key=value or given on the
commandline then it will be a string before it reaches the module code.
There's nothing we can do about that.

Fixes #19585
2017-01-05 15:45:26 -08:00
Fabrizio Colonna b6f9b0be1f Added arbiter support to gluster_volume module. 2017-01-04 17:09:24 -08:00
Toshio Kuratomi e98c0a3009 Fix locale_gen to compare native strings rather than mixing byte and text strings
Fixes #19426
2017-01-04 10:11:33 -08:00
Joseph Price 1ea86bc66a Clarify state=reloaded will start service 2017-01-03 11:34:07 -05:00
tmshn 6a6113e951 [timezone module] Return tzfile from _verify_timezone (fix #19745)
Modification picked from https://github.com/ansible/ansible-modules-extras/pull/3337
2017-01-03 11:20:38 -05:00
Marius Gedminas b0b7a636d8 authorized_key: support --diff (#19277)
* Refactoring: split readkeys() into readfile() and parsekeys()

* Refactoring: split writekeys() into writefile() and serialize()

* authorized_key: support --diff

* Refactoring: remove no-longer used readkeys()/writekeys()

* Integration test for authorized_key in check mode
2017-01-03 09:32:32 -05:00
George Brighton a10209cbe9 iptables: Fixes invalid ip6tables option (#19657)
fixes #19656
2016-12-27 08:27:22 +01:00
Brian Coca 3691c784d2 fix check mode for all options
also simplified code paths and changed import away from *
fixes #19476
2016-12-21 09:36:46 -05:00
Adrian Likins 388510f379 Fix missing imports from sysctl module
This module was missing an import of get_exception()
and had an unused import of 're'
2016-12-20 10:23:48 -05:00
Ken Evensen bcace3cfc4 Gconf2 module (#19540)
* Pull #19267 broke sysctl module.  Minor corrections

* Correct description.  Functional updates
2016-12-20 11:53:49 +00:00
tmshn 112d950794 [timezone module] Check if timedatectl command is actually available 2016-12-19 21:18:12 -05:00
Rezart Qelibari 507b96ff30 user: make system=yes work on Darwin systems. (#19464)
* Update system/user.py module.

Add ability to add real system users with next free system uid (< 500) on macOS.

* Improve syntax in system/user.py module.

Remove complex if else line and replace by simple comparison which yields the same boolean value.

* Remove "True" comparison of user.py.

Remove comparison to true, as it is not pep8 conform.
2016-12-19 16:35:56 -05:00
Fabio Alessandro Locati a080d44a47 Improve YAML examples - system/solaris_zone.py (#19410) 2016-12-19 16:49:47 +00:00
Ken Evensen 58b067532f gconftool2 module (#19461)
* Pull #19267 broke sysctl module.  Minor corrections

* Commit of gconftool2 module
2016-12-19 14:57:31 +00:00
Artur Molchanov a8d5358d7f systemd module: Allow to stop activating service (#19383)
* systemd module: Allow to stop activating service

Allow to stop service with ActiveState=activating.

* systemd: Fix incompatibility with Python 2.4
2016-12-15 11:14:33 -05:00
Toshio Kuratomi 0b440a9289 Code smell test for iteritems and itervalues (#19292)
* Code smell test for iteritems and itervalues

* Change the keydict object in authorized_keys so it doesn't throw a false postive

keydict is a bad data structure anyway.  We don't use the iteritems and
itervalues methods so just disable them so that the code-smell tests do
not trigger on it.

* Change release templates so they work with py3
2016-12-14 12:16:16 -08:00
Ken Evensen 6b62b9f48c Adding pamd module for Ansible (#19029) 2016-12-13 15:34:44 -05:00
Carlos E. Garcia 0b8011436d minor spelling changes 2016-12-13 13:51:13 -05:00
Michael Scherer 054a3fccf8 Cleanup import for sysctl module 2016-12-13 13:26:54 -05:00
Michael Scherer db8719cf8b Add support for NetBSD
While I only checked on NetBSD 7.0, it seems to use the same
rc system as FreeBSD so it should be working for now.
2016-12-13 13:24:34 -05:00
Michael Scherer 6ffd494efb Cleanup imports for user
Some class use shutil, who was not imported, and we want to
avoid '*' for future refactoring.
2016-12-13 11:53:18 -05:00
Andrea Tartaglia ef391a11ec Removed dict.iteritems() in modules. (#18859)
This is for py3 compatibility, addressed in #18506
2016-12-12 15:16:23 -08:00
Alexandre Garnier 0f7abad38f Fix python 2.4 compatibility
`start` keyword of `enumerate` is only available since python 2.6
2016-12-10 11:06:11 -08:00
Fabio Alessandro Locati 9a075b5917 Avoid using an object if it does not exists (#19058) 2016-12-09 17:36:39 -05:00
Fabio Alessandro Locati 6c06aeb792 Explicitally add the state - system/authorized_key.py (#18837) 2016-12-09 08:40:16 -05:00
Matt Clay c709b22e5c Fix differences with devel. 2016-12-08 11:35:21 -05:00
James Cammarata fa5386c488 Some additional module cleanup of mistakes made during merging 2016-12-08 11:35:20 -05:00
James Cammarata 011ea55a8f Relocating extras into lib/ansible/modules/ after merge 2016-12-08 11:35:18 -05:00
James Cammarata 8afa090417 Resolving differences in core modules post-merge 2016-12-08 11:25:36 -05:00
Toshio Kuratomi 7319104552 Refreshed metadata for core modules 2016-12-08 11:25:35 -05:00
Fabio Alessandro Locati a6cd0272fb Call main in conditional way - system 2016-12-08 11:25:35 -05:00
Toshio Kuratomi 42a5b1977f Do not use the fstab parameter on openbsd for mounting (#5805)
* Do not use the fstab parameter on openbsd for mounting

OpenBSD's mount command doesn't allow selecting which fstab file to use.
So if we're operating on the live filesystem (mount or remount) return
an error if the user specified an fstab file.

Fixes #5591

* Fix the logic inversion (thanks to @landryb)
2016-12-08 11:25:35 -05:00
Fabio Alessandro Locati eb54b80a92 Unquote urls in YAML - system (#5796) 2016-12-08 11:25:34 -05:00
Evan Kaufman 580c74140a Fix for python 2.4 compatibility (#5693)
Fixes #5692
2016-12-08 11:25:34 -05:00
Brian Coca e3a43c0d4b made fact_path actual path (#5789) 2016-12-08 11:25:34 -05:00
Dustin C. Hatch b49aa70c29 systemd: Start inactive units for reload/restart
The `service` module starts services that are not running when
`action=restarted` or `action=reloaded`, which is especially convenient
for initial deployments because it eliminates an extraneous operation
for when the service starts for the first time. This commit adjusts the
behavior of the `systemd` module to match.
2016-12-08 11:25:33 -05:00
ekultails 0358919db8 add correct SELinux file context for crontabs (#4511) (#4595) 2016-12-08 11:25:33 -05:00
jctanner d41b4e3802 Use the the new features of fail_if_missing for checkmode (#5750) 2016-12-08 11:25:33 -05:00
Brian Coca d2fec9d259 added docs for use option
(cherry picked from commit ad5cb0f0d7231ff74d7918faa26091ba710c4709)
2016-12-08 11:25:33 -05:00
Toshio Kuratomi b95f483b8d Force BSDs to use umount/mount instead of trying to use remount. (#5715)
* Force BSDs to use umount/mount instead of trying to use remount.

Fixes #5591

* Initialize out and err
2016-12-08 11:25:33 -05:00
Brian Coca da9adccb02 systemctl show rc changes across versions
to avoid different errors across versions, ignore rc in favor of
found/notfound

fixes #5710
2016-12-08 11:25:33 -05:00
Jiri Tyr b264f8c1cd Fall back if mountinfo reading failed (fixing #5603) 2016-12-08 11:25:33 -05:00
Toshio Kuratomi ef3699e277 Fix for call to umount() in remount() 2016-12-08 11:25:32 -05:00
Brian Coca 1d8be78963 try remount but fallback to unmount + mount (#2445)
* allow mount to try remount

falls back to unmount/mount

* fixed fstab handling and switched to ismount

custom function deals with bind mounts unlike built in

* un ** args

* last ** args
2016-12-08 11:25:32 -05:00
Brian Coca 44c07d7ca8 Several systemd fixes
Allow some operations on missing services
Better sysv handling
Rearranged error reporting
fixed load error catching and order logic
also minor doc/comment updates
added warnings
2016-12-08 11:25:32 -05:00
Dag Wieers c843eeabc2 Performance improvement using in-operator for hash lookups
Just a small cleanup for the existing occurrences.

Using the in-operator for hash lookups is faster than using .has_key()
http://stackoverflow.com/questions/1323410/has-key-or-in
2016-12-08 11:25:31 -05:00
Sam Doran b56a9852ee Examples syntax batch4 (#5620)
* Change example syntax on authorized_key module

* Change example syntax on cron module

* Change example syntax on group module

* Change example syntax on hostname module

* Change example syntax on seboolean module

* Change example syntax on selinux module

* Change example syntax on service module

* Change example syntax on sysctl module

* Change example syntax on systemd module

* Change example syntax on user module

* Change example syntax on debug module

* Change example syntax on fail module

* Change example syntax on include module

* Change example syntax on include_role module

* Change example syntax on include_vars module

* Change example syntax on pause module

* Change example syntax on wait_for module

* Change example syntax on apache2_module module

* > Change example syntax on django_manage module

* Change example syntax on htpasswd module
2016-12-08 11:25:31 -05:00
Rezart Qelibari d7e9fbe631 Update system/group.py module.
Add ability to add system groups with next free system gid (< 500) on macOS.
2016-12-08 11:25:29 -05:00
Fabio Alessandro Locati 2cacc3e787 Use native YAML (#5571) 2016-12-08 11:25:28 -05:00
Michael Scherer 352d280058 Make service work when the service is not present in rc.conf
After installing a package from the ports collection on a
fresh FreeBSD 11.0, Ansible was unable to enable it, failing with
"unable to get current rcvar value". Debugging showed that sysrc
didn't see the variable from /usr/local/etc/rc.d/myservice, but
adding the value was working.

So we will just fallback to the default value if we can't find it.
2016-12-08 11:25:26 -05:00
Brian Coca 00fbd98f97 dont join when group is none 2016-12-08 11:25:25 -05:00
Brian Coca 97b23c0fb7 docit 2016-12-08 11:25:25 -05:00
Brian Coca 52332f5b78 allow groups to be passed as YAML list as well
keeps backwards copat with 'comma delimited string'
fixes #5163
2016-12-08 11:25:25 -05:00
Evan Kaufman 5d3e64b0d2 Identify existing unmanaged jobs by exact match, when no header comment is found
* updated `find_job` method to find by exact match of job, when no matching header comment is found
  * note this fallback injects a header comment for later calls to `update_job` or `remove_job`
* abstracted header comment building to `do_comment` method

Fixes #3256
2016-12-08 11:25:25 -05:00
Brian Coca d36bea766d make sure all svcadm operations are syncronous
fixes #5296
2016-12-08 11:25:25 -05:00
Hiroaki Nakamura c2d37f1db9 hostname: add support for alpine linux (#4837)
* Add update_current_and_permanent_hostname to the hostname module

* Add support for Alpine Linux to the hostname module
2016-12-08 11:25:24 -05:00
Jonathan Mainguy 51313e6da8 update maintainer 2016-12-08 11:25:24 -05:00
Evan Kaufman f8dad7130d Record existing cron file as string property, rather than only recording termination
This seems less hackish, and feels more proper for diff generation
2016-12-08 11:25:24 -05:00
Evan Kaufman f64990df02 Rendering of crontab should reflect actual newline termination, in diff mode 2016-12-08 11:25:24 -05:00
Evan Kaufman b416015634 Ensure trailing newline is written to cron file
Records whether existing cron file (or CRONCMD output) has a terminating newline, and ensures a trailing newline is written as necessary EVEN IF NO CHANGE WAS MADE to the target env/job

Fixes #2316
2016-12-08 11:25:23 -05:00
Adrian Likins 29978344ea Make authorized_key preserve key order (#5339)
* Make authorized_key preserve key order

Track the ordering of keys in the original file (rank)
and try to preserve it when writing out updates.

Fixes #4780
2016-12-08 11:25:23 -05:00
Toshio Kuratomi 9bbe71154c Fix authorized_key module to preserve the order of options
The last fix allowing multiple definitions of the same option key (for
permitopen support) introduced a set() which removed the guaranteed
ordering of the options.

This change restores ordering.  The change is larger than simply
removing the set because we do need to handle the non-dict semantics
around keys not being unique in the data structure.  The new code make
use of __setitem__() and items() to do its work.  Trying to use
getitem() or keys() should be looked upon with suspicion as neither of
those follow dictionary semantics and it is quite possible the coder
doesn't realize this.  The next time we need to touch or enhance the
keydict code it should probably be rewritten to not pretend to extend
the dictionary interface.
2016-12-08 11:25:22 -05:00
Michael Scherer ed590257a3 Fix code for python 3
Since dict.keys return a dictkeys under python 3, we hav to cast it
to a list to avoid traceback:

    Traceback (most recent call last):
      File "/tmp/ansible_sh16ejbd/ansible_module_authorized_key.py", line 496, in <module>
        main()
      File "/tmp/ansible_sh16ejbd/ansible_module_authorized_key.py", line 490, in main
        results = enforce_state(module, module.params)
      File "/tmp/ansible_sh16ejbd/ansible_module_authorized_key.py", line 410, in enforce_state
        parsed_new_key = parsekey(module, new_key)
      File "/tmp/ansible_sh16ejbd/ansible_module_authorized_key.py", line 308, in parsekey
        options = parseoptions(module, options)
      File "/tmp/ansible_sh16ejbd/ansible_module_authorized_key.py", line 259, in parseoptions
        options_dict[key] = value
      File "/tmp/ansible_sh16ejbd/ansible_module_authorized_key.py", line 164, in __setitem__
        self.itemlist.append(key)
    AttributeError: 'dict_keys' object has no attribute 'append'

Yet another fix for https://github.com/ansible/ansible/pull/18053
2016-12-08 11:25:22 -05:00
Michael Scherer 2c078dcb97 Cleanup import for authorized_key
Do not import '*', to ease future refactoring and cleanup of
module_utils.
2016-12-08 11:25:21 -05:00
Michael Scherer 9ecd220683 Make the code run on python 3
Test suite block on:

    Traceback (most recent call last):
      File "/tmp/ansible_fhootp1e/ansible_module_authorized_key.py", line 496, in <module>
        main()
      File "/tmp/ansible_fhootp1e/ansible_module_authorized_key.py", line 490, in main
        results = enforce_state(module, module.params)
      File "/tmp/ansible_fhootp1e/ansible_module_authorized_key.py", line 410, in enforce_state
        parsed_new_key = parsekey(module, new_key)
      File "/tmp/ansible_fhootp1e/ansible_module_authorized_key.py", line 308, in parsekey
        options = parseoptions(module, options)
      File "/tmp/ansible_fhootp1e/ansible_module_authorized_key.py", line 253, in parseoptions
        if options_dict.has_key(key):
    AttributeError: 'keydict' object has no attribute 'has_key'

With keydict being a subclass of dict.
2016-12-08 11:25:21 -05:00
Michael Scherer c9da5e98a9 Remove the wide try/expect clause
This doesn't catch anything precise, and none of the methods should
throw a expection for anything. This also hide python 3 errors.
2016-12-08 11:25:21 -05:00
Steven de Vries 054fe53b43 Move job parameter to meet expected requirements (#5151)
closes #5273
2016-12-08 11:25:21 -05:00
Michael Scherer 7a0ef069fa Convert name to bytes to compare it to bools
On python 3, bools is a list of bytes:

    >>> rc,bools = selinux.security_get_boolean_names()
    >>> 'virt_use_nfs' in bools
    False
    >>> bools
    [b'abrt_anon_write', b'abrt_handle_event', ...]
2016-12-08 11:25:20 -05:00
John R Barker 25b6492d37 Bulk spelling improvement to modules-core (#5225)
* Correct spelling mistakes

* Correct more spelling issues

* merge conflict

* Revert typo in parms
2016-12-08 11:25:20 -05:00
Laurent Godet 336c9f9f35 Fix daemon_reload in systemd module 2016-12-08 11:25:18 -05:00
Jiri Tyr 2b145a0052 Fixing bind mount pattern in the mount module (#5084) 2016-12-08 11:25:15 -05:00
Toshio Kuratomi 9436d013d4 Fix mount default options -- should be defaults, not default 2016-12-08 11:25:14 -05:00
Jiri Tyr be1036f461 Ultimate fix of the mount module for Linux (#5055) 2016-12-08 11:25:14 -05:00
Jiri Tyr 5a9f5918d3 Fixing bind mount on Linux (#1942) (#4439)
* Fixing bind mount on Linux

* Fixing broken implementation
2016-12-08 11:25:13 -05:00
Toshio Kuratomi 08874e4bf6 Fix #3153 again (#4989) 2016-12-08 11:25:13 -05:00
Toshio Kuratomi 27759ee58f Working subset of mount fixes (#4987)
* Fixing bind mount on Linux

* The latest update from jtyr doesn't pass integration tests.

Manually select the changes that are necessary to fix the bug with
unmounting
2016-12-08 11:25:13 -05:00
Lars Engels 8010b7f980 Add support for password aging on Solaris (#4372)
* Add support for password aging on Solaris

* Fix shadow file editing when {MIN,MAX,WARN}WEEKS is not set in /etc/default/passwd

* Un-break with python3

* _Really_ un-break with python3
2016-12-08 11:25:12 -05:00
Riccardo Murri 6733d1c72c hostname: Support "Scientific Linux CERN" (#4855)
CERN maintains its own fork of "Scientific Linux",
which identifies as "Scientific Linux CERN SLC".
This commit lets Ansible know that this is again
another variant of RHEL.
2016-12-08 11:25:05 -05:00
Toshio Kuratomi ae310d5034 Fix syntax 2016-12-08 11:25:05 -05:00
Brian Coca 6030bcdb47 switched to use built in function for validation 2016-12-08 11:25:04 -05:00
Antonio Murdaca b9962d2389 system/systemd: enable systemctl --user (#4208)
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2016-12-08 11:25:04 -05:00
glovenglaven 289e5f1884 Added Solaris support to core mount module (#4771)
* Added Solaris support to the mount module.

* Added checking so that if a non-standard fstab file is specified it will
still work in Solaris without breaking existing functionality.

* Added a check to avoid writing duplicate vfstab entries on Solaris

* Added "version_added" to new boot option
2016-12-08 11:25:04 -05:00
Gregor Giesen b87ef7772f cron: replacement for os.getlogin() (#4777)
os.getlogin() returns the user logged in on the controlling terminal. However
'crontab' only looks for the login name of the process' real user id which
pwd.getpwuid(os.getuid())[0] does provide.

While in most cases there is no difference, the former might fail under certain
circumstances (e.g. a lxc container connected by attachment without login),
throwing the error 'OSError: [Errno 25] Inappropriate ioctl for device'.
2016-12-08 11:25:04 -05:00
Michael Scherer 30cd0e8afe Add support for selinux_boolean_sub conversion (#4570)
SELinux since 2012 use a configuration file to
convert boolean names from a old name to a new name,
for preserving backward compatibility.

However, this has to be done explicitely when using the python
bindings, and the module was not doing it.

Openshift ansible script use this construct to detect if
a boolean exist or not:

    - name: Check for existence of virt_sandbox_use_nfs seboolean
      command: getsebool virt_sandbox_use_nfs
      register: virt_sandbox_use_nfs_output
      failed_when: false
      changed_when: false

    - name: Set seboolean to allow nfs storage plugin access from containers(sandbox)
      seboolean:
        name: virt_sandbox_use_nfs
        state: yes
        persistent: yes
      when: virt_sandbox_use_nfs_output.rc == 0

On a system where virt_sandbox_use_nfs do not exist, this work. But
on a system where virt_sandbox_use_nfs is a alias to virt_use_nfs (like
Fedora 24), this fail because the seboolean is not aware of the alias.
2016-12-08 11:24:58 -05:00
Michael Scherer f4158304ac Port mount.py to python3, need to use six.iteritems (#4581) 2016-12-08 11:24:56 -05:00
Michael Scherer f2b6c7b6a2 Fix user module under python3 (#4560)
Using something like:

    - name: Create ssh keys
      user:
        name: root
        generate_ssh_key: yes
      register: key

result into this traceback on F24

    Traceback (most recent call last):
      File \"/tmp/ansible_jm5d4vlh/ansible_module_user.py\", line 2170, in <module>
        main()
      File \"/tmp/ansible_jm5d4vlh/ansible_module_user.py\", line 2108, in main
        (rc, out, err) = user.modify_user()
      File \"/tmp/ansible_jm5d4vlh/ansible_module_user.py\", line 660, in modify_user
        return self.modify_user_usermod()
      File \"/tmp/ansible_jm5d4vlh/ansible_module_user.py\", line 417, in modify_user_usermod
        has_append = self._check_usermod_append()
      File \"/tmp/ansible_jm5d4vlh/ansible_module_user.py\", line 405, in _check_usermod_append
        lines = helpout.split('\\n')
    TypeError: a bytes-like object is required, not 'str'
2016-12-08 11:24:56 -05:00
Michael Scherer 898cf5b462 Fix traceback on python3 (#4556)
Traceback (most recent call last):
  File "/tmp/ansible_csqv781s/ansible_module_systemd.py", line 374, in <module>
    main()
  File "/tmp/ansible_csqv781s/ansible_module_systemd.py", line 263, in main
    for line in out.split('\\n'): # systemd can have multiline values delimited with {}
2016-12-08 11:24:56 -05:00
Levi Morales 0c9d895438 Fixes #2322 fix for missing append check on Darwin systems (#4256) 2016-12-08 11:24:55 -05:00
Ali Ok 1e411f9551 Fix minor syntax error in authorized_key module doc (#4491) 2016-12-08 11:24:54 -05:00
Michael Scherer 338a8c8632 Convert command output to native string (#4559)
Without it, the module always return changed on python3,
which is harmless but add noise and can have some side effects.
2016-12-08 11:24:54 -05:00
Michael Scherer 1f8b2f3e6e Add support for setting fstab location on Linux too for mount (#3271)
Fix #3153
2016-12-08 11:24:52 -05:00
jctanner 6c439a4882 user: Cast all arguments to string before passing to run_command (#4398)
Fixes #4397
2016-12-08 11:24:50 -05:00
Brian Coca 16ccde49ad remove X bit 2016-12-08 11:24:49 -05:00
Indrajit Raychaudhuri fb255b3607 Improve hostname module to support systemd in more generic way (#4382)
Now that there is general purpose `Fact` helper to detect if systemd
is active, we would be able to rely on that to apply SystemdStrategy.

Detecting presence of systemd at runtime would be more reliable than
distribution version based heuristics. (e.g., Debian, Ubuntu allows
user to change the default init system, Gentoo allows switching as
well, and so on).
2016-12-08 11:24:49 -05:00
Brian Coca ab3a87cc1a improved logic when dealing with init scripts 2016-12-08 11:24:49 -05:00
Brian Coca 3c89a21e0c fixes corner case for systemd services
when both unit file and sysv init script exist
Thanks to @olfway for fix.

fixes #3764
2016-12-08 11:24:49 -05:00
Evan Kaufman 3a44d60fbc Fixes #3791 cron always returning changed state for multiline jobs (#4285)
Strip only newlines and carriage returns. Instead of stripping ALL whitespace, which may have unintended side effects
2016-12-08 11:24:49 -05:00
BradLook 766413e79d Allow cron to target remote user (#4270) 2016-12-08 11:24:49 -05:00
Michael Scherer cd3c454917 Add a example with a non service unit (#4355)
Since the documentation focus mostly on service
units, a explicit example may help people realizing
it can be used for socket and timer too.
2016-12-08 11:24:48 -05:00
Michael Scherer 3c2110215c Do not hardcode default ssh key size for RSA (#4074)
By default, ssh-keygen will pick a suitable default for ssh keys
for all type of keys. By hardocing the number of bits to the
RSA default, we make life harder for people picking Elliptic
Curve keys, so this commit make ssh-keygen use its own default
unless specificed otherwise by the playbook
2016-12-08 11:24:47 -05:00
Christian Schwarz e526b2ad3d system/service.py: fix false-positive service enablement on FreeBSD. (#4283)
sysrc(8) does not exit with non-zero status when encountering a
permission error.

By using service(8) `service <name> enabled`, we now check the actual
semantics expressed through calling sysrc(8), i.e. we check if the
service enablement worked from the rc(8) system's perspective.

Note that in case service(8) detects the wrong value is still set,
we still output the sysrc(8) output in the fail_json() call:
the user can derive the exact reason of failure from sysrc(8) output.
2016-12-08 11:24:46 -05:00
Marcos Diez f10413b919 better authorized_keys documentation (#3739) 2016-12-08 11:24:43 -05:00
Brian Coca 72eaf0281a updated checkmode for update-rc.d
fixes #4146
2016-12-08 11:24:43 -05:00
jctanner d5b35eb8db add gather_timeout parameter (#4093) 2016-12-08 11:24:42 -05:00
Christian Schwarz e25cb4df77 service module: use sysrc on FreeBSD (#4042)
* service module: use sysrc on FreeBSD

sysrc(8) is the designated userland program to edit rc files on FreeBSD.

It first appeared in FreeBSD 9.2, hence is available on all supported
versions of FreeBSD.

Side effect: fixes #2664

* Incorporate changes suggested by bcoca.

- Use `get_bin_path` to find sysrc binary.
- Only use sysrc when available (support for legacy versions of FreeBSD)
2016-12-08 11:24:41 -05:00
Brian Coca 186db40864 make daemon reload first thing always run
otherwise service detection can fail before we run it which might
be required to actually detect the service.
2016-12-08 11:24:41 -05:00
Michael LoSapio 20d8103b53 Showing some of the sysctl settings in proper yaml format per Ansible documentation (#4073) 2016-12-08 11:24:41 -05:00
Allen Sanabria 6d6b8a1823 Fixes #1715 Allow authorized_module accept multi. (#3573)
This will allow the authorized_module to accept options that can be
passed multiple times into ssh options. For instance permitopen.
2016-12-08 11:24:38 -05:00
Thomas Quinot 0bd32c3465 Clarify behaviour when state=present and no name is given (#3904) 2016-12-08 11:24:36 -05:00
Robin Naundorf 03515fc26c Fixed Typo in Examples of systemd module (#3870) 2016-12-08 11:24:35 -05:00
Brian Coca 03f06ca2e8 fixed issue with multiline output from systemd
fixes #3868
2016-12-08 11:24:35 -05:00
Brian Coca cffe358260 fixed enabled state 2016-12-08 11:24:33 -05:00
Brian Coca df1b03d0c6 fixed reported state 2016-12-08 11:24:33 -05:00
Erik Nadel 6f5dfcf1bd Added statement about escaping characters in chron tasks (#3770) 2016-12-08 11:24:32 -05:00
Dmitry Marakasov 13d7a61160 Fix crontab argument order for writing (#3750)
Currently, when writing user's crontab, ansible calls

    crontab <file> -u <user>

This is incorrect according to crontab(1) on both FreeBSD and Linux,
which suggest that file argument should be the last.

At least on FreeBSD, this leads to incorrect cron module bahavior which
writes to root's crontab instead of users's
2016-12-08 11:24:31 -05:00
Brian Coca 01819bbc9d fixed enabled reporting 2016-12-08 11:24:31 -05:00
Brian Coca 38d71b9eef fixed typo 2016-12-08 11:24:31 -05:00
Brian Coca 472d5c11ef added state in results for backwards compat 2016-12-08 11:24:31 -05:00
Brian Coca 8085678dc8 first draft systemd service plugin (#3660)
* first draft systemd service plugin

* now systemd status handles multiline values
2016-12-08 11:24:31 -05:00
Marcos Diez d34c5dfd69 Added one extra example in the authorized_key module. (#3637) 2016-12-08 11:24:30 -05:00
Ken Mitchell 8c2b333a73 Proposed fix to not require src and fstype arguments for mount. Issue #1259. (#1357) 2016-12-08 11:24:30 -05:00
jctanner c952753735 Do not ignore the primary group if modifying the list of secondary groups. (#3585)
Fixes #1118
2016-12-08 11:24:30 -05:00
Michael Scherer cca89ef489 Port seboolean to py3/py2.4 syntax (#3679) 2016-12-08 11:24:29 -05:00
Michael Scherer c793571bc3 Port mount to python3 and python 2.4 compatible syntax (#3678) 2016-12-08 11:24:29 -05:00
Michael Scherer fd61e81764 Port authorized_keys to a syntax compatible with python3 and 2.4 (#3677) 2016-12-08 11:24:28 -05:00
Michael Scherer 907b3fb667 Port hostname to a py24 and py3 compatible syntax (#3676) 2016-12-08 11:24:28 -05:00
Michael Scherer e02f401225 Port sysctl to a py3 and py24 compatible syntax (#3675) 2016-12-08 11:24:28 -05:00
Michael Scherer f0fd1109dd Port cron to a py3 and py24 compatible syntax (#3674) 2016-12-08 11:24:28 -05:00
Michael Scherer f2212dc41a Port user module to python3 and 2.4 compatible syntax (#3673) 2016-12-08 11:24:28 -05:00
Toshio Kuratomi 93fe022aa4 Port to dual python2/python3 compat 2016-12-08 11:24:27 -05:00
Toshio Kuratomi e10b7e1773 Port ping to dual python3/2 compat. 2016-12-08 11:24:27 -05:00
James Tanner bc39f8c42e Revert "remove checking of stderr for insserv (#1846)"
This reverts commit 2ee6e4cf668a9bba77c3bb019d473f3614563838.
2016-12-08 11:24:26 -05:00
TheSameCH ca8bf6ab4c remove checking of stderr for insserv (#1846)
stderr of insserv can also contain warnings which can be ignored. checking rc only is more accurate.
fixes #1502
2016-12-08 11:24:26 -05:00
Brian Coca 8a4257d297 removed incorrect defaults from docs 2016-12-08 11:24:23 -05:00
Konstantin Gribov 9284c80039 Escape spaces, backslashes when create new entry in fstab (#3193)
Supplement to PR #1454 and issue #530.

Fixes #3192.
Fixes #1861 (introduced by PR #1454).

Signed-off-by: Konstantin Gribov <grossws@gmail.com>
2016-12-08 11:24:23 -05:00
Guido Falsi 582a5bccc8 Make FreeBSD subclass respect the sleep option. 2016-12-08 11:24:20 -05:00
Michael Scherer 5b32a299a5 Change home and ssh_key_file to 'path' in user module 2016-12-08 11:24:20 -05:00
Joshua Kugler 15ae8c8e0b Fix mount's handling of passno 2016-12-08 11:24:17 -05:00
Robin Roth ee06cd27b2 use custom ismount function in mount module (#2737)
* based on cpython os.path.ismount
* includes patch from http://bugs.python.org/issue2466
* fixes #2186
* when the upstream bug is fixed this should be removed/rewritten
* use ismount from module_utils
2016-12-08 11:24:17 -05:00
Toshio Kuratomi 4c40886814 Remove the ignore_ohai and ignore_facter parameters as the functionality was merged into gather_subset 2016-12-08 11:24:12 -05:00
Tobias Wolf 368cf59e4b Add diff and check mode to cron module
supports not writing backup file in check mode and new environment
vars.

![example screenshot](http://i.imgur.com/mkAThq8.png)
2016-12-08 11:24:12 -05:00
Yannig Perré 02abe0b7c9 Use list type in order to convert directly gather_subset option into list. 2016-12-08 11:24:12 -05:00
Yannig Perré 12804a80b6 Add a way to restrict gathered facts in Ansible: - Using gather_subset options - By ignoring ohai/chef or facter/puppet facts 2016-12-08 11:24:12 -05:00
Joao Carreira 92d76e8828 added support for sles 10 & 11 2016-12-08 11:24:11 -05:00
Brian Coca 9e0aef8ea2 docs updates and fixes
fixes http://github.com/ansible/ansible/issues/14876
2016-12-08 11:24:11 -05:00
davidobrien1 072c68ea79 Restore filter on Windows and version reference for Windows facts. 2016-12-08 11:24:10 -05:00
David O'Brien ce7a86b4ce Add documentation to setup.py and remove use of $params.fact_path in setup.ps1 2016-12-08 11:24:09 -05:00
Toshio Kuratomi 646d0e406d Set one parameter to be type path 2016-12-08 11:24:08 -05:00
Ton Kersten b58e16ed3d Fix facter path
In Puppet 4 and in the PE edition, the Puppet tree is installed in
`/opt/puppetlabs/...` and all commands can be reached from
`/opt/puppetlabs/bin`.
2016-12-08 11:24:07 -05:00
Matt Martz aaf762573e Various simple linting type cleanups on modules 2016-12-08 11:24:06 -05:00
jjshoe a160d5426d List which version it was added
fixes https://github.com/ansible/ansible-modules-core/issues/2605
2016-12-08 11:24:05 -05:00
Luca Berruti feb309e3cf Typo. 2016-12-08 11:24:04 -05:00
Brian Coca b5c9945485 avoid chmod in check mode 2016-12-08 11:24:04 -05:00
Brian Coca 5aff573098 revamped checkmode support in user module
- defaulted to commands not executing in checkmode
- added force run for info gathering (for setting changed)
- added debug for what would have been run in check mode
- added check mode for spots that made changes using system calls instead of command
- removed now redundant checkmode checks

better failure now, if i missed anything, it will misreport changed value
instead of old default of actually making the change in checkmode
2016-12-08 11:24:04 -05:00
Matt Clay 642746d0a3 Make modify_user_usermod honor check mode on AIX. 2016-12-08 11:24:03 -05:00
Matt Clay 04ad3fe304 Make modify_user honor check mode on OS X. 2016-12-08 11:24:02 -05:00
Matt Clay c87f70429b Make modify_user honor check mode on FreeBSD. 2016-12-08 11:24:01 -05:00
Toshio Kuratomi f6aa1ff9a4 Remove duplicate documentation fields 2016-12-08 11:24:01 -05:00
Toshio Kuratomi b6ff36bed3 Fix documentation build in hostname 2016-12-08 11:24:01 -05:00
Hiroaki Nakamura f2246deaf9 Doc: Add NOTE about hostname modules does not modify /etc/hosts 2016-12-08 11:24:00 -05:00
Thomas Quinot ef3308159f Allow cron_file to be an absolute path
Support specifying an absolute path (typically /etc/crontab) rather than
a path relative to /etc/cron.d, to allow modifying the main system crontab.
Particularly useful for target systems that have /etc/crontab but no
/etc/cron.d.
2016-12-08 11:24:00 -05:00
Luca Berruti 0673a4919f cron module: add enviroment variables management 2016-12-08 11:23:59 -05:00
Brian Coca 4c6515e299 reverse order of cron commands
does not affect linux but fixes issue with busybox caring about order
fixes #2807
2016-12-08 11:23:58 -05:00
Jeroen Seegers 7be08b00b0 Update cron.py
Minor update to documentation for the cron module to reflect the required "name" parameter when the value of "state" is "absent".
2016-12-08 11:23:58 -05:00
Brian Coca f8a36c4047 service goes back to failing when absent
if no tools and no init script, this should always fail
2016-12-08 11:23:53 -05:00
Brian Coca f435f887fa better handling of checkmode for solaris fixes #2296 2016-12-08 11:23:51 -05:00
tobbe 65f12bccb6 add text to the description, more user friendly 2016-12-08 11:23:51 -05:00
tobbe 455da45e62 Add suport for selinux user when adding a new user on selinux enabled systems 2016-12-08 11:23:51 -05:00
Michael Scherer 55f2345829 Remove a unneeded use of use_unsafe_shell
Since use_unsafe_shell is suspicious from a security point
of view (or it wouldn't be unsafe), the less we have, the less
code we have to toroughly inspect for a security audit.
2016-12-08 11:23:51 -05:00
nitzmahone 0d0b78dd1e fixed disappearing groups on OSX user module
Ensure that we don't try to modify the groups collection if groups are not specified
2016-12-08 11:23:51 -05:00
Dominique Barton 5c05016d1e bugfix for issue #2537 2016-12-08 11:23:51 -05:00
Sina Sadeghi 2ad9c6c9e5 Update hostname.py
Added support for FreeBSD. (http://www.freebsd.org)
2016-12-08 11:23:50 -05:00
Brian Coca b3c14ee0c3 minor doc fixes and reformating updated validate_certs feature to be 2.1 2016-12-08 11:23:50 -05:00
Veaceslav (Slava) Mindru 2eb6b566b2 Squashed commit of the following:
commit 406214fad214359fcf13fe8c7cd3f8f8faac5386
commit 85d1c9b0a41dd075eb2683b1a7de595ca3119614
commit 4aa5049b5ae25dee71a248238201611a466a13c4
commit 65a96974c80aea1fef88d78e218ecb665d8113e1
commit 22ea5863d1dfd628735b46cc7de51c0fd33251de

Refactoring
2016-12-08 11:23:49 -05:00
Martin André aaa82d1942 Fix typo in ping module short description 2016-12-08 11:23:49 -05:00
Jordi De Groof 7aa57219f6 Update facts when hostname is changed
ansible_hostname contains the unqualified hostname
2016-12-08 11:23:48 -05:00
Greg DeKoenigsberg f08d60388c @bradobro stepping down as maintainer 2016-12-08 11:23:47 -05:00
Brian Coca d2cffb31c3 rearranged systemd check, removed redundant systemctl check fixed unused cmd and state var assignements 2016-12-08 11:23:44 -05:00
Simon Hafner 923e442409 added earlier paths to systemd
2b583ce657
b925e72633
2016-12-08 11:23:43 -05:00
Simon Hafner 4af48e139c simpler way to check if systemd is the init system
According to
http://www.freedesktop.org/software/systemd/man/sd_booted.html
check if the directory /run/systemd/system/ exists.
2016-12-08 11:23:43 -05:00
Brian Coca 505467d2ff clarified ping module purpose 2016-12-08 11:23:42 -05:00
Toshio Kuratomi 80b3bbd55e Mark a few parameters as no_log 2016-12-08 11:23:42 -05:00
Achilleas Pipinellis 961082620c Add missing documentation: cron_file requires user to be set 2016-12-08 11:23:40 -05:00
gekmihesg d003fcd662 Support sysctl on OpenBSD
Fixes #1233
2016-12-08 11:23:39 -05:00
Simon Li 607b7c14bd Fix incorrect variable in group.py: user -> group 2016-12-08 11:23:39 -05:00
Brian Coca 45907f2ff3 removed typo 2016-12-08 11:23:38 -05:00
Brian Coca d55ba3ab7c removed syslog in favor of common module logging functions 2016-12-08 11:23:38 -05:00
Brian Coca 682cb99d45 revert must_exist 2016-12-08 11:23:38 -05:00
Mike Boone dd76088019 Updated link to the FAQ. 2016-12-08 11:23:36 -05:00
Brian Coca 99159b3cdd changed chmod to 2.4 compat 2016-12-08 11:23:35 -05:00
Brian Coca 917b7071d6 partially reverted previous change to deal with systemctl show status not returning errors on missing service Now it looks for not-found key instead of running status which does return error codes when service is present but in diff states. fixes #12216 2016-12-08 11:23:34 -05:00
Brian Coca fd23120d42 check systemctl status before show as show will not return antyhing other than rc=0 even when it fails. 2016-12-08 11:23:34 -05:00
Marius Gedminas b2fc74337a authorized_key: fix example in documentation
'key=' cannot be pointing to a file name; it needs to be the key itself as a string (or a URL).
2016-12-08 11:23:33 -05:00
Tim Rupp 223cac3f39 Add hostname support for Kali linux 2.0
This patch allows the hostname module to detect and set the hostname for a
Kali Linux 2.0 installation. Without this patch, the hostname module raises
the following error

   hostname module cannot be used on platform Linux (Kali)

Kali is based off of Debian.
2016-12-08 11:23:33 -05:00
Marius Gedminas f97d00fbad user: don't generate SSH keys in check mode
Fixes https://github.com/ansible/ansible/issues/11768

Test plan:

- (in a Vagrant VM) created a user 'bob' with no ssh key
- ran the following playbook in check mode:

    ---
    - hosts: trusty
      tasks:
        - user: name=bob state=present generate_ssh_key=yes

- saw that ansible-playbook reported "changes=1"
- saw that /home/bob/.ssh was still absent
- ran the playbook for real
- saw that /home/bob/.ssh was created
- ran the playbook in check mode again
- saw that ansible-playbook reported no changes
- tried a variation with a different username for a user that didn't
  exist: ansible-playbook --check worked correctly (no errors, reported
  "changed")
2016-12-08 11:23:33 -05:00
Simon Li 28c44c554c Don't fail in check_mode if user exists
PR #1651 fixed issue #1515 but the requirement for path to be defined is unecessarily strict. If the user has previously been created a path isn't necessary.
2016-12-08 11:23:33 -05:00
Александр Костырев ec8a94f748 Fix documentation of authorized_key.py
man for sshd http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man8/sshd.8?query=sshd
says there's no "host" option but "from".
2016-12-08 11:23:31 -05:00
Brian Coca 34f8eb0f4c made continue into a pass (there was no loop) 2016-12-08 11:23:30 -05:00
Brian Coca 686026919e avoid shlex exceptions in rc parsing (happens with multiline entries) fixes #1898 2016-12-08 11:23:30 -05:00
Evgeny Vereshchagin fe840225fb Fix service.enable on: Debian 8, Ubuntu 15.04
Workaround for https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=751638
See https://github.com/systemd/systemd/issues/937
2016-12-08 11:23:30 -05:00
Austin Hyde ca512b5def Always end rc.conf entries with a new line 2016-12-08 11:23:30 -05:00
Evan Kaufman b3495e238c Add disabled option to cron module 2016-12-08 11:23:29 -05:00
Sam Thursfield cad0adc691 Fix permissions issue with 'cron' module
I have a task like this in a playbook. The ansible_ssh_user is 'root'
for this host.

    - cron:
        hour: 00
        job: /home/backup/backup.sh
        name: baserock.org data backup
        user: backup

Running it gave me the following error:

    TASK: [backup cron job, runs every day at midnight] ***************************
    failed: [baserock-backup1] => {"failed": true}
    msg: crontab: can't open '/tmp/crontabvVjoZe': Permission denied
    crontab: user backup cannot read /tmp/crontabvVjoZe

The temporary file created by the 'cron' module is created with the
Python tempfile.mkstemp() function. This creates a file that is readable
only by 'root' (mode 600). The Busybox `crontab` program then checks if
the file is readable by the 'backup' user, and fails if it isn't. So we
need to make sure the file is world-readable before running `crontab`.
2016-12-08 11:23:28 -05:00
Brian Coca 7d660adb39 changed verbose override variable 2016-12-08 11:23:27 -05:00
James Cammarata 05c6732462 Prefer non-zero rc's over text analyis in service status checks
Fixes ansible/ansible#10441
2016-12-08 11:23:26 -05:00
saito-hideki 19cd35806f Add Solaris support in hostname module
feature_pull_request: #1804
2016-12-08 11:23:26 -05:00
KIKUCHI Koichiro dab7305d3b Fix service enabled check failure on FreeBSD 2016-12-08 11:23:25 -05:00
Sébastien Gross 0fd3ece053 Allow '*' as empty password.
If `password` is defined as `*` `useradd` or `usermod` returns an error:

    msg: usermod: Invalid password: `*'

This works very well on Linux host to not define any password for a
user (mainly useful if your setup is only based on SSH keys for
auth). On OpenBSD this does not work, so we have to ignore the encrypted
password parameter if it defined as `*`.
2016-12-08 11:23:25 -05:00
fti7 581ce7dd32 mount: Support for Check-Mode 2016-12-08 11:23:24 -05:00
Brian Coca 7a6c8251dd prevent usless assignment of home 2016-12-08 11:23:22 -05:00
bambou ac41e7c669 Check if the gid is set 2016-12-08 11:23:22 -05:00
Mischa ter Smitten 10cae0acb3 The tilde expansion doesn't work with user.home 2016-12-08 11:23:21 -05:00
Sean Chittenden 4c8b573e2c Fix group mod and group add for FreeBSD 2016-12-08 11:23:18 -05:00
0tmc 6e4c5e0a12 Use of proper fstab file on FreeBSD 2016-12-08 11:23:17 -05:00
verm666 ac40d9f41a fix authorized_keys in check_mode
This change is in response to issue #1515.
Original pull request #1580.

The original problem is: in authorized_key module you have no idea about users
which will be created by Ansible at first run. I can propose next two ways to
solve this problem:

  1. Combine modules system/user.py and system/authorized_key.py in one module
     (so you will know everything about users in that module)
  2. Use small workaround: add my commit and always provide 'path' parameter
     for authorized_key module during runs with --check option.
2016-12-08 11:23:16 -05:00
Matt Martz d47de74ade Replaced tabbed indentation with spaces for group module 2016-12-08 11:23:16 -05:00
Brian Coca e91818ef77 updated docs to clarify use of exclusive 2016-12-08 11:23:14 -05:00
Konstantin Gribov 8d91c3a61a Escape spaces, backslashes and ampersands in fstab
Fixes #530.

It's more generic than #578 which only fixes spaces escaping in name (target dir to mount).
Escaping is used in both `set_mount` (important for `src`, `name` and `opts`) and
`unset_mount` (for `name`).

It's shouldn't be used in `mount` and `umount` since `name` parameter is passed as array element
to `module.run_command`.

Signed-off-by: Konstantin Gribov <grossws@gmail.com>
2016-12-08 11:23:14 -05:00
Arata Notsu cc76a479e1 Not use "is" to compare strings
As "is" tests whether if operands are the same object rather than
they have the same value, potentially causes a wrong result.
2016-12-08 11:23:14 -05:00
Alexis Seigneurin 53e9caa1d0 - 'name' should not be required so as to allow uninstalling a cron_file 2016-12-08 11:23:13 -05:00
sysadmin75 f096359608 ansible-modules-core #530 fix - Mount module does not accept spaces in mount point path 2016-12-08 11:23:13 -05:00
Hagai Kariti b46a1ff3e1 Hostname module should update ansible_hostname 2016-12-08 11:23:10 -05:00
Greg DeKoenigsberg eb881d7d5d Proper author info for all remaining modules 2016-12-08 11:23:07 -05:00
Brian Coca b2dadaadf8 Revert "added innitial daemon-reloaded support to service module"
This reverts commit 438d87d26991c26de4a6b1457b154eb8f50d093a.
2016-12-08 11:23:06 -05:00
Brian Coca 55d04f4ddf added innitial daemon-reloaded support to service module 2016-12-08 11:23:05 -05:00
Patrik Lundin 899788f1a7 service: Fix comments in OpenBsdService class.
No functional change.
2016-12-08 11:23:02 -05:00
Jonathan Mainguy 20301427f8 fixes check mode for Ubuntu 14.04 2016-12-08 11:23:01 -05:00
Vladislav Lewin 36ce019beb add SLE12 support to hostname.py 2016-12-08 11:23:01 -05:00
Jonathan Mainguy 06cd532cc5 added nice error for systemd hosts where name > 64 chars 2016-12-08 11:23:00 -05:00
Toshio Kuratomi 84110be91d Update the cron docs to specify that it takes a boolean value 2016-12-08 11:23:00 -05:00
Toshio Kuratomi 623f70ecd6 Fix documentation of the variable that backup file name is returned in 2016-12-08 11:23:00 -05:00
Brian Coca b13fd5ac9a value should be string as that is what it compares against 2016-12-08 11:22:59 -05:00
Jonathan Mainguy f4b07b105b added openbsd to hostname module 2016-12-08 11:22:59 -05:00
Semyon Deviatkin e94140e52b Fix unused variable systemd_enabled
Removed declared but unused variable systemd_enabled
2016-12-08 11:22:59 -05:00
Jesse Keating 17aabee6df Add service option to avoid failure on missing service
This adds a must_exist option to the service module, which gives callers the
ability to be tolerant to services that do not exist. This allows for
opportunistic manipulation of a list of services if they happen to exist on the
host. While failed_when could be used, it's difficult to track all the
different error strings that might come from various service tools regarding a
missing service.
2016-12-08 11:22:58 -05:00
Toshio Kuratomi 5336217649 Several cleanups to many modules:
* Fix docs to specify when python2.6+ is required (due to a library
  dep).  This helps us know when it is okay to use python2.6+ syntax in
  the file.
* remove BabyJson returns.  See #1211  This commit fixes all but the
  openstack modules.
* Use if __name__ == '__main__' to only run the main part of the module
  if the module is run as a program.  This allows for the potential to
  unittest the code later.
2016-12-08 11:22:58 -05:00