Commit graph

870 commits

Author SHA1 Message Date
Riccardo Murri
344927a6b1 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-09-15 10:58:33 -04:00
Toshio Kuratomi
432ee70da1 Fix syntax 2016-09-12 11:54:58 -07:00
Brian Coca
067167a9b3 switched to use built in function for validation 2016-09-12 12:39:10 -04:00
Antonio Murdaca
dc7ba8f3c9 system/systemd: enable systemctl --user (#4208)
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2016-09-12 11:08:27 -04:00
glovenglaven
9bb0c498df 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-09-12 08:45:32 -04:00
Gregor Giesen
2f3fdc4975 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-09-12 07:39:12 +02:00
Michael Scherer
5f652c7584 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-09-01 04:26:23 -07:00
Michael Scherer
cee7473df6 Port mount.py to python3, need to use six.iteritems (#4581) 2016-08-31 08:16:35 -07:00
Michael Scherer
38992bbd57 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-08-31 07:52:46 -07:00
Michael Scherer
6063071a46 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-08-31 07:49:45 -07:00
Levi Morales
688fa6fc54 Fixes #2322 fix for missing append check on Darwin systems (#4256) 2016-08-30 11:59:04 +02:00
Ali Ok
ab55355b00 Fix minor syntax error in authorized_key module doc (#4491) 2016-08-27 16:52:03 +02:00
Michael Scherer
21688383c3 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-08-27 15:53:13 +02:00
Michael Scherer
5f1d6ded7f Add support for setting fstab location on Linux too for mount (#3271)
Fix #3153
2016-08-23 11:38:59 -04:00
jctanner
4047096ac4 user: Cast all arguments to string before passing to run_command (#4398)
Fixes #4397
2016-08-11 19:16:24 -04:00
Brian Coca
1eb01d7612 remove X bit 2016-08-11 14:21:24 -04:00
Indrajit Raychaudhuri
23ebb98570 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-08-11 17:44:16 +02:00
Brian Coca
f3e761f0c8 improved logic when dealing with init scripts 2016-08-11 09:43:16 -04:00
Brian Coca
92b4ae4768 fixes corner case for systemd services
when both unit file and sysv init script exist
Thanks to @olfway for fix.

fixes #3764
2016-08-11 09:24:42 -04:00
Evan Kaufman
4905ab66d6 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-08-10 23:43:58 +02:00
BradLook
7c4de52693 Allow cron to target remote user (#4270) 2016-08-10 23:30:09 +02:00
Michael Scherer
c46e425846 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-08-08 08:48:33 -04:00
Michael Scherer
21c9f0defc 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-08-02 21:59:10 +02:00
Christian Schwarz
635c37cec6 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-08-01 13:35:39 -04:00
Marcos Diez
f7558164b5 better authorized_keys documentation (#3739) 2016-07-12 08:52:00 -04:00
Brian Coca
7437b6b25f updated checkmode for update-rc.d
fixes #4146
2016-07-11 09:39:30 -04:00
jctanner
db8af4c5af add gather_timeout parameter (#4093) 2016-07-08 17:22:05 -04:00
Christian Schwarz
f5e8204dbc 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-07-05 09:43:05 -04:00
Brian Coca
380fb2be59 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-07-05 08:55:19 -04:00
Michael LoSapio
e626803882 Showing some of the sysctl settings in proper yaml format per Ansible documentation (#4073) 2016-06-30 19:27:41 -04:00
Allen Sanabria
343c3ecfb9 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-06-20 17:32:44 -04:00
Thomas Quinot
00fb13010c Clarify behaviour when state=present and no name is given (#3904) 2016-06-10 13:03:01 -04:00
Robin Naundorf
9c52f781c9 Fixed Typo in Examples of systemd module (#3870) 2016-06-06 13:50:47 -04:00
Brian Coca
a412451a89 fixed issue with multiline output from systemd
fixes #3868
2016-06-06 09:40:23 -04:00
Brian Coca
c50859d20b fixed enabled state 2016-06-01 12:34:26 -04:00
Brian Coca
b9686fbadf fixed reported state 2016-06-01 12:30:20 -04:00
Erik Nadel
7491a11581 Added statement about escaping characters in chron tasks (#3770) 2016-05-27 14:46:43 -04:00
Dmitry Marakasov
68cb864aad 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-05-27 06:54:03 +02:00
Brian Coca
96b2bc9084 fixed enabled reporting 2016-05-26 13:55:48 -04:00
Brian Coca
beb9ff9170 fixed typo 2016-05-26 13:22:21 -04:00
Brian Coca
d03914ed63 added state in results for backwards compat 2016-05-26 13:20:49 -04:00
Brian Coca
fb77ab49ab first draft systemd service plugin (#3660)
* first draft systemd service plugin

* now systemd status handles multiline values
2016-05-25 17:20:08 -04:00
Marcos Diez
873a7435df Added one extra example in the authorized_key module. (#3637) 2016-05-24 14:50:22 +02:00
Ken Mitchell
b903c54bac Proposed fix to not require src and fstype arguments for mount. Issue #1259. (#1357) 2016-05-23 11:20:10 -04:00
jctanner
76b7de943b Do not ignore the primary group if modifying the list of secondary groups. (#3585)
Fixes #1118
2016-05-19 22:37:57 -04:00
Michael Scherer
a62f088a24 Port seboolean to py3/py2.4 syntax (#3679) 2016-05-17 10:23:06 -07:00
Michael Scherer
c1e40b73f7 Port mount to python3 and python 2.4 compatible syntax (#3678) 2016-05-17 10:22:29 -07:00
Michael Scherer
f41a90eae4 Port authorized_keys to a syntax compatible with python3 and 2.4 (#3677) 2016-05-17 10:21:55 -07:00
Michael Scherer
2e0307e083 Port hostname to a py24 and py3 compatible syntax (#3676) 2016-05-17 10:21:26 -07:00
Michael Scherer
b19a8a9b8f Port sysctl to a py3 and py24 compatible syntax (#3675) 2016-05-17 10:20:36 -07:00