Commit Graph

450 Commits (11e72d495dc1b35723a2c1878704a39bb9e32411)

Author SHA1 Message Date
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
macbeth76 fce97365a4 Update user.py
M in date format is minutes. m is for months.
2016-12-08 11:22:58 -05:00
louis 9d20a3091e added skeleton support in user module 2016-12-08 11:22:57 -05:00
James Cammarata d7ce6b0d4b Fix bug in service where upstart services incorrectly use init scripts
Fixes #1170
2016-12-08 11:22:57 -05:00
Evgenii Terechkov 37d6c10133 Add ALT Linux support to hostname module 2016-12-08 11:22:56 -05:00
Michael Scherer f7707ea137 Name is a required parameter, fix https://github.com/ansible/ansible/issues/10335 2016-12-08 11:22:55 -05:00
Brian Coca a6107e35e9 simplified bad if chain hopefully fixes #1136 2016-12-08 11:22:54 -05:00
Keith Johnson 06579c560e Make link clickable 2016-12-08 11:22:54 -05:00
James Cammarata 68a07a2bb5 Merge branch 'osx_user_fix' of https://github.com/bambou42/ansible-modules-core into bambou42-osx_user_fix
Includes commits for:
* Don't return change if the password is not set
* Set the group to nogroup if none is specified
* Set an uid if none is specified
* Test if SHADOWFILE is set (for Darwin)
* remove unused uid
2016-12-08 11:22:53 -05:00
David Wittman 15235a718d Fix bug with upstart detection
Upstart scripts are being incorrectly identified as SysV init scripts
due to a logic error in the `service` module.

Because upstart uses multiple commands (`/sbin/start`, `/sbin/stop`,
etc.) for managing service state, the codepath for upstart sets
`self.svc_cmd` to an empty string on line 451.

Empty strings are considered a non-truthy value in Python, so
conditionals which are checking the state of `self.svc_cmd` should
explicitly compare it to `None` to avoid overlooking the fact that
the service may be controlled by an upstart script.
2016-12-08 11:22:52 -05:00
David Fritzsche 14720b54ac Add working status detection for pf on FreeBSD
The return code of "service pf onestatus" is usually zero on FreeBSD (tested with FreeBSD 10.0), even if pf is not running. So the service module always thinks that pf is running, even when it needs to be started.
2016-12-08 11:22:50 -05:00
Sam Thursfield 5d2652f31b Fix authorized_key module crashing when given an invalid key
I tried a playbook with the following (accidentally wrong) task:

  tasks:
      - name: authorized key test
        authorized_key: key=/home/sam/.ssh/id_rsa.pub key_options='command="/foo/bar"' user=sam

I got the following traceback:

    TASK: [authorized key test] ***************************************************
    failed: [localhost] => {"failed": true, "parsed": false}
    Traceback (most recent call last):
    File "/home/sam/.ansible/tmp/ansible-tmp-1427110003.65-277897441194582/authorized_key", line 2515, in <module>
        main()
    File "/home/sam/.ansible/tmp/ansible-tmp-1427110003.65-277897441194582/authorized_key", line 460, in main
        results = enforce_state(module, module.params)
    File "/home/sam/.ansible/tmp/ansible-tmp-1427110003.65-277897441194582/authorized_key", line 385, in enforce_state
        parsed_new_key = (parsed_new_key[0], parsed_new_key[1], parsed_options, parsed_new_key[3])
    TypeError: 'NoneType' object has no attribute '__getitem__'

With this fix, I see the expected error instead:

    TASK: [authorized key test] ***************************************************
    failed: [localhost] => {"failed": true}
    msg: invalid key specified: /home/sam/.ssh/id_rsa.pub
2016-12-08 11:22:50 -05:00
Mario Loria 00613cd4f3 Setting the actual passno and dump defaults, and warning user of consequences in nulling
Using ansible 1.8.4, I found that these two options actually work slightly different than advertised.
2016-12-08 11:22:48 -05:00
Dag Wieers 43ef3a2bd9 Update authorized_key.py
Fix a (common) error in the examples. This is something that may go unnoticed during troubleshooting when copy&pasting the example.
2016-12-08 11:22:46 -05:00
Toshio Kuratomi 9fa04de137 In service_enable, the default of changed is True so we have to set it to False explicitly if it is False.
Fixes #875
2016-12-08 11:22:46 -05:00
Carlo Mandelli 1f93a052d6 Added HP-UX subclass 2016-12-08 11:22:47 -05:00
Oleg A. Mamontov 845b6d78be On FreeBSD apply 'login_class' only if there is real change. 2016-12-08 11:22:45 -05:00
Edward Larkey d17726bae9 Fix typo in authorized key module documentation.
Added opening double quote
2016-12-08 11:22:45 -05:00
Stefan J. Betz aca24caa19 Create SSH Keys always after creating $HOME 2016-12-08 11:22:44 -05:00
Brian Coca 2278a69f7b fix for mount w/o opts (bug introduced when fixing bind mounts) 2016-12-08 11:22:43 -05:00
Jon Hadfield 90f5a23f34 use is-enabled to check systemd service status. 2016-12-08 11:22:42 -05:00
Graham Hay 15fcbcb0ee Use insserv where available 2016-12-08 11:22:42 -05:00
Sébastien Gross 164d518370 Add basic support for OSX groups. 2016-12-08 11:22:42 -05:00
Sébastien Gross 624be0e239 Add basic support for OS X (Darwin) user management. 2016-12-08 11:22:41 -05:00
Dagobert Michelsen 9991e8d8f1 Solaris SMF is already supported and should be mentioned in the docs, 2016-12-08 11:22:41 -05:00
Brian Coca 132c43a84f added note that url src is only avaialable from 1.9 on 2016-12-08 11:22:41 -05:00
Toshio Kuratomi 691f4cc049 Tabs to spaces 2016-12-08 11:22:41 -05:00
Paul Geraghty 5f24584010 Correct grammar of comment relating to example 2016-12-08 11:22:41 -05:00
Jesse Keating 6f4273a3ff Add exclusive option to authorized_keys
This option allows the module to ensure that ONLY the specified keys
exist in the authorized_keys file. All others will be removed. This is
quite useful when rotating keys and ensuring no other key will be
accepted.
2016-12-08 11:22:41 -05:00
Philippe ALEXANDRE 5b48ecc80a Add Linuxmint support in hostname module 2016-12-08 11:22:41 -05:00
Jeff Gonzalez 7ea6650d6c Refactored code to use module utility fetch_url function. 2016-12-08 11:22:41 -05:00
Jeff Gonzalez 04fb952d49 Added documentation for using url as key source 2016-12-08 11:22:41 -05:00
Brian Coca b6a1927f13 now allows for case in which someone removed the K* links and is trying to reenable a service 2016-12-08 11:22:41 -05:00
Brian Coca 03273e06c7 simplified update-rc.d enable/disable handling, removed forced defaults creation as that breaks local customizations 2016-12-08 11:22:41 -05:00
Brian Coca 884471a6b5 implemented account expiration as flag and not state, removed from unsupported platforms 2016-12-08 11:22:40 -05:00
Toshio Kuratomi a73bd8dcbc More information about distutils on Solaris in case we run into this again 2016-12-08 11:22:39 -05:00
Ben Konrath 96a20de9ff Add support for SL7 to hostname module. 2016-12-08 11:22:39 -05:00
Brian Coca 8405edd5a2 now handles non string values for sysctl 2016-12-08 11:22:38 -05:00
Patrik Lundin 88fe45d7e7 Update OpenBSD rcctl handling to use new syntax.
See http://marc.info/?l=openbsd-cvs&m=142054488027109&w=2
2016-12-08 11:22:38 -05:00
Tim G b2e39265e1 Load distutils on all platforms EXCEPT Solaris.
Solaris doesn't ship distutils with with the default Python package.  This patch fixes "service" on Solaris since 30d6713.
2016-12-08 11:22:38 -05:00
Tim G ea77ac076b distutils is not available on some non-Linux OS's 2016-12-08 11:22:37 -05:00
Michael Scherer 0a745de765 Do not use echo shell builtin for password
Using \t in a password may result in a different password
being set :

    $ echo 'a\ta'
    a   a

Problem report originally found by Pilou-
( https://github.com/ansible/ansible-modules-extras/pull/198 )
2016-12-08 11:22:37 -05:00
Toshio Kuratomi e75dc7e5a6 Clarify documented behaviour of user module's ssh_key_file parameter
Fixes #9873
2016-12-08 11:22:37 -05:00
Johnny Robeson 6fc04862a4 rename FedoraStratgy to SystemdStrategy 2016-12-08 11:22:37 -05:00
Jeff Gonzalez 30822706dd Added ability to use url as key source 2016-12-08 11:22:36 -05:00
Patrik Lundin 9803938663 Handle string returned by 'default' correctly.
We need to handle the string returned by 'default' in the same way we handle
the string returned by 'status' since the resulting flags are compared later.
2016-12-08 11:22:36 -05:00
Patrik Lundin d88080007a Fix typo: Replace "N0" with "NO". 2016-12-08 11:22:36 -05:00
Patrik Lundin 6594a1458d Multiple fixes for OpenBSD rcctl handling.
* Use the newly added 'default' argument to know if the default flags are set
  or not.
* Handle that 'status' may either return flags or YES/NO.
* Centralize flag handling logic.
* Set action variable after check if we need to keep going.

Big thanks to @ajacoutot for implementing the rcctl 'default' argument.
2016-12-08 11:22:36 -05:00
Jonathan Mainguy aef138107c Fixes bind mounts
Fixed tab's and spaces, or so I think I did

Fixed tabs and spaces for real this time
2016-12-08 11:22:36 -05:00
billwanjohi b019076dd3 user: add expired state
ported from
https://github.com/ansible/ansible/pull/6303

It's very useful and routine to disable a *nix user.
I implemented expired instead of locked because this prevents any use of
the account, safer than just preventing password-based authentication.

I have tests [1], but since none of the suite came along with the core
modules, I'm unsure how to submit them.

[1] https://github.com/billwanjohi/ansible/blob/add_locked_state/test/integration/roles/test_user/tasks/main.yml
2016-12-08 11:22:35 -05:00
kustodian 447c625cb3 Set selinux state to 'permissive' for state=disabled 2016-12-08 11:22:35 -05:00
Michael Scherer 36c653f54a Add hostname to generated user SSH key comment
The default is not very useful to sort between different
keys and user. Adding the hostname in the comment permit to later
sort them if you start to reuse the key and set them in different
servers. See https://github.com/ansible/ansible/pull/7420
for the rational.
2016-12-08 11:22:35 -05:00
Peter Oliver 432a6286db Fix appending to a user's group on Solaris
Without this change, you get:
    AttributeError: 'set' object has no attribute 'extend'

Tested on a Solaris 11.2 client with the included Python 2.6.8.
2016-12-08 11:22:34 -05:00
Jonathan Mainguy 8c05023be3 Fixed hostname for rhel5 python 2.4.3 2016-12-08 11:22:33 -05:00
zitterbacke 1d4808780f re-enable AIX password setting
the AIX class uses a unsafe shell for setting the user password (containing a pipe in the command). This patch adopts to the new behavior of module_utils/basic.py (since somewhere around 1.7).

besides it changes the qoutes for the echo command from double to single, because password-hashes contain $-signs and one would not have this variables expanded.
2016-12-08 11:22:33 -05:00
Michael Scherer 104f91ed3b Revert commit cbc417c, as the code is broken, see #438
LooseVersion expect a string, so filtering to return a int
is incorrect. Thanks to Jeremy Brown for the analysis.
2016-12-08 11:22:33 -05:00
Toshio Kuratomi e359f7cfcf Don't traceback if a gid is specified instead of a group name
Fixes https://github.com/ansible/ansible/issues/9796
2016-12-08 11:22:33 -05:00
Brian Coca 6d56767454 fixed hostname for gentoo 2016-12-08 11:22:32 -05:00
Brian Coca 77ec45e3d1 vastly simplified systemd detection, made enable/disable errors clearer both of which allows us to remove 'service name detection' as if systemd is init we still use it to handle initscripts. 2016-12-08 11:22:31 -05:00
Brian Coca 8b9772565e now actually adds usable name for systemd when service only has init script 2016-12-08 11:22:31 -05:00
Toshio Kuratomi cd7cc07e85 Gixes to doc formatting 2016-12-08 11:22:31 -05:00
Toshio Kuratomi 7ff9b3990a Update cron example for setting to run twice a day
Fixes #415
2016-12-08 11:22:31 -05:00
Brian Coca ab96ff8b6d service cleanup 2016-12-08 11:22:30 -05:00
Patrik Lundin 8a6a4a7757 Simplify self.arguments logic.
Strange logic pointed out by @jarmani, thanks!
2016-12-08 11:22:30 -05:00
Patrik Lundin 2b18e544f5 Depend more on rcctl if it is present.
* Make the module support enable/disable of special services like pf via rcctl.
  Idea and method from @jarmani.
* Make the module handle when the user supplied 'arguments' variable does not
  match the current flags in rc.conf.local.
* Update description now that the code tries to use rcctl for everything if it
  is available.
2016-12-08 11:22:30 -05:00
Patrik Lundin 25c3c03a11 Tweak error checking for "enabled" code.
Based on input from @jarmani:
* A return value of 2 now means a service does not exist. Instead of
  trying to handle the different meanings of rc after running "status",
  just look at stderr to know if something failed.
* Skip looking at stdout to make the code cleaner. Any errors should
  turn up on stderr.
2016-12-08 11:22:30 -05:00
Patrik Lundin 32cb025b85 Fail if "rcctl status" writes to stderr. 2016-12-08 11:22:30 -05:00
Patrik Lundin 03d4b76b14 Check rc and print error message if any.
It is probably good to use stdout before printing a generic error
message as well.
2016-12-08 11:22:29 -05:00
Patrik Lundin 38d8db473f Make "enabled" code aware of --check mode. 2016-12-08 11:22:29 -05:00
Jonathan Armani d1433eca14 Add enable / disable of services for OpenBSD if rcctl is present 2016-12-08 11:22:29 -05:00
Achilleas Pipinellis 872f6aa559 Clarify supported init systems. 2016-12-08 11:22:28 -05:00
Pascal Borreli 187b07e6c0 Fixed typo 2016-12-08 11:22:28 -05:00
Fabrice Bernhard 3d437b068e Typo in comments
Credit goes to @kbsali
@pborreli : you did not see that one? :-)
2016-12-08 11:22:28 -05:00
Brian Coca 78fb3217d6 service now detects systemd is actually running, not just installed 2016-12-08 11:22:27 -05:00
Jonathan Mainguy a71ce0615a fixes user module for rhel5 by using -n instead of -N, all other distros will still use -N 2016-12-08 11:22:27 -05:00
Robert Estelle 4e2d05b1f3 Remove incorrect executable permissions. 2016-12-08 11:22:26 -05:00
Brian Coca c071d6a85c switched to iterator as per comments 2016-12-08 11:22:25 -05:00
Martijn P. Rijkeboer fcf527557d Fix whitespace around '=' in sysctl.conf. 2016-12-08 11:22:25 -05:00
Brian Coca a91b5fc170 made hostname work with python 2.4 2016-12-08 11:22:25 -05:00
Toshio Kuratomi 1429507489 Fix for systemd service scripts with newlines
Fixes #127
2016-12-08 11:22:24 -05:00
Michael DeHaan ef2a2b9093 package files 2016-12-08 11:22:22 -05:00
Michael DeHaan 213e518165 file extensions! 2016-12-08 11:22:22 -05:00
Michael DeHaan c7eec45b73 Restructuring. 2016-12-08 11:22:22 -05:00