Fix parameter types and other fixes (#50111)

* Fix parameter types and other fixes

* Fix issues after review

* Fix Windows-references in system/files modules

This PR includes:
- Replacing version/v with just Ansible X.Y
- Removing Windows-alternatives from notes

* Update lib/ansible/modules/system/parted.py

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

* Update lib/ansible/modules/system/service.py

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

* Update lib/ansible/modules/system/service.py

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

* Revert type change, move to separate PR

* Update lib/ansible/modules/files/replace.py

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

* Update lib/ansible/modules/files/replace.py

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

* Update lib/ansible/modules/files/replace.py

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

* Update lib/ansible/modules/files/replace.py

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

* Update lib/ansible/modules/files/replace.py

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

* Update lib/ansible/modules/files/replace.py

Co-Authored-By: dagwieers <dag@wieers.com>
This commit is contained in:
Dag Wieers 2019-01-18 03:24:47 +01:00 committed by GitHub
commit 30227ace98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
43 changed files with 1222 additions and 1065 deletions

View file

@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# (c) 2017, Joris Weijters <joris.weijters@gmail.com>
# Copyright: (c) 2017, Joris Weijters <joris.weijters@gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@ -24,15 +24,18 @@ options:
name:
description:
- Name of the inittab entry.
type: str
required: yes
aliases: ['service']
aliases: [ service ]
runlevel:
description:
- Runlevel of the entry.
type: str
required: yes
action:
description:
- Action what the init has to do with this entry.
type: str
required: yes
choices:
- boot
@ -50,18 +53,21 @@ options:
command:
description:
- What command has to run.
type: str
required: yes
insertafter:
description:
- After which inittabline should the new entry inserted.
type: str
state:
description:
- Whether the entry should be present or absent in the inittab file.
type: str
choices: [ absent, present ]
default: present
notes:
- The changes are persistent across reboots, you need root rights to read or adjust the inittab with the C(lsitab), chitab,
C(mkitab) or C(rmitab) commands.
- The changes are persistent across reboots.
- You need root rights to read or adjust the inittab with the C(lsitab), C(chitab), C(mkitab) or C(rmitab) commands.
- Tested on AIX 7.1.
requirements:
- itertools
@ -101,17 +107,17 @@ EXAMPLES = '''
RETURN = '''
name:
description: name of the adjusted inittab entry
description: Name of the adjusted inittab entry
returned: always
type: str
sample: startmyservice
msg:
description: action done with the inittab entry
description: Action done with the inittab entry
returned: changed
type: str
sample: changed inittab entry startmyservice
changed:
description: whether the inittab changed or not
description: Whether the inittab changed or not
returned: always
type: bool
sample: true

View file

@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# (c) 2016, Alain Dejoux <adejoux@djouxtech.net>
# Copyright: (c) 2016, Alain Dejoux <adejoux@djouxtech.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@ -25,40 +25,51 @@ options:
vg:
description:
- The volume group this logical volume is part of.
type: str
required: true
lv:
description:
- The name of the logical volume.
type: str
required: true
lv_type:
description:
- The type of the logical volume.
type: str
default: jfs2
size:
description:
- The size of the logical volume with one of the [MGT] units.
type: str
copies:
description:
- The number of copies of the logical volume. Maximum copies are 3.
default: '1'
- The number of copies of the logical volume.
- Maximum copies are 3.
type: int
default: 1
policy:
description:
- Sets the interphysical volume allocation policy.
- C(maximum) allocates logical partitions across the maximum number of physical volumes.
- C(minimum) allocates logical partitions across the minimum number of physical volumes.
type: str
choices: [ maximum, minimum ]
default: maximum
description:
- Sets the interphysical volume allocation policy. C(maximum) allocates logical partitions across the maximum number of physical volumes.
C(minimum) allocates logical partitions across the minimum number of physical volumes.
state:
choices: [ absent, present ]
default: present
description:
- Control if the logical volume exists. If C(present) and the
volume does not already exist then the C(size) option is required.
type: str
choices: [ absent, present ]
default: present
opts:
description:
- Free-form options to be passed to the mklv command.
type: str
pvs:
description:
- Comma separated list of physical volumes e.g. C(hdisk1,hdisk2).
- A list of physical volumes e.g. C(hdisk1,hdisk2).
type: list
'''
EXAMPLES = r'''
@ -73,7 +84,7 @@ EXAMPLES = r'''
vg: testvg
lv: test2lv
size: 512M
pvs: hdisk1,hdisk2
pvs: [ hdisk1, hdisk2 ]
- name: Create a logical volume of 512M mirrored
aix_lvol:
@ -205,7 +216,7 @@ def main():
lv_type=dict(type='str', default='jfs2'),
size=dict(type='str'),
opts=dict(type='str', default=''),
copies=dict(type='str', default='1'),
copies=dict(type='str', default=1),
state=dict(type='str', default='present', choices=['absent', 'present']),
policy=dict(type='str', default='maximum', choices=['maximum', 'minimum']),
pvs=dict(type='list', default=list())

View file

@ -1,8 +1,8 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# (c) 2014, Gabe Mulley <gabe.mulley@gmail.com>
# (c) 2015, David Wittman <dwittman@gmail.com>
# Copyright: (c) 2014, Gabe Mulley <gabe.mulley@gmail.com>
# Copyright: (c) 2015, David Wittman <dwittman@gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@ -14,54 +14,56 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
'supported_by': 'community'}
DOCUMENTATION = '''
DOCUMENTATION = r'''
---
module: alternatives
short_description: Manages alternative programs for common commands
description:
- Manages symbolic links using the 'update-alternatives' tool
- Manages symbolic links using the 'update-alternatives' tool.
- Useful when multiple programs are installed but provide similar functionality (e.g. different editors).
version_added: "1.6"
author:
- "David Wittman (@DavidWittman)"
- "Gabe Mulley (@mulby)"
- David Wittman (@DavidWittman)
- Gabe Mulley (@mulby)
options:
name:
description:
- The generic name of the link.
type: str
required: true
path:
description:
- The path to the real executable that the link should point to.
type: path
required: true
link:
description:
- The path to the symbolic link that should point to the real executable.
- This option is always required on RHEL-based distributions. On Debian-based distributions this option is
required when the alternative I(name) is unknown to the system.
required: false
type: path
priority:
description:
- The priority of the alternative
required: false
- The priority of the alternative.
type: int
default: 50
version_added: "2.2"
requirements: [ update-alternatives ]
'''
EXAMPLES = '''
- name: correct java version selected
EXAMPLES = r'''
- name: Correct java version selected
alternatives:
name: java
path: /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
- name: alternatives link created
- name: Alternatives link created
alternatives:
name: hadoop-conf
link: /etc/hadoop/conf
path: /etc/hadoop/conf.ansible
- name: make java 32 bit an alternative with low priority
- name: Make java 32 bit an alternative with low priority
alternatives:
name: java
path: /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java
@ -79,11 +81,10 @@ def main():
module = AnsibleModule(
argument_spec=dict(
name=dict(required=True),
path=dict(required=True, type='path'),
link=dict(required=False, type='path'),
priority=dict(required=False, type='int',
default=50),
name=dict(type='str', required=True),
path=dict(type='path', required=True),
link=dict(type='path'),
priority=dict(type='int', default=50),
),
supports_check_mode=True,
)

View file

@ -23,28 +23,33 @@ options:
command:
description:
- A command to be executed in the future.
type: str
script_file:
description:
- An existing script file to be executed in the future.
type: str
count:
description:
- The count of units in the future to execute the command or script file.
type: int
required: true
units:
description:
- The type of units in the future to execute the command or script file.
choices: [ minutes, hours, days, weeks ]
type: str
required: true
choices: [ minutes, hours, days, weeks ]
state:
description:
- The state dictates if the command or script file should be evaluated as present(added) or absent(deleted).
type: str
choices: [ absent, present ]
default: present
unique:
description:
- If a matching job is present a new job will not be added.
type: bool
default: 'no'
default: no
requirements:
- at
author:
@ -52,18 +57,18 @@ author:
'''
EXAMPLES = '''
- name: Schedule a command to execute in 20 minutes as root.
- name: Schedule a command to execute in 20 minutes as root
at:
command: ls -d / >/dev/null
count: 20
units: minutes
- name: Match a command to an existing job and delete the job.
- name: Match a command to an existing job and delete the job
at:
command: ls -d / >/dev/null
state: absent
- name: Schedule a command to execute in 20 minutes making sure it is unique in the queue.
- name: Schedule a command to execute in 20 minutes making sure it is unique in the queue
at:
command: ls -d / >/dev/null
count: 20
@ -140,7 +145,7 @@ def main():
script_file=dict(type='str'),
count=dict(type='int'),
units=dict(type='str', choices=['minutes', 'hours', 'days', 'weeks']),
state=dict(type='str', default='present', choices=['present', 'absent']),
state=dict(type='str', default='present', choices=['absent', 'present']),
unique=dict(type='bool', default=False),
),
mutually_exclusive=[['command', 'script_file']],

View file

@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# (c) 2012, Brad Olson <brado@movedbylight.com>
# Copyright: (c) 2012, Brad Olson <brado@movedbylight.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@ -13,81 +13,86 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
'supported_by': 'core'}
DOCUMENTATION = '''
DOCUMENTATION = r'''
---
module: authorized_key
short_description: Adds or removes an SSH authorized key
description:
- "Adds or removes SSH authorized keys for particular user accounts"
- Adds or removes SSH authorized keys for particular user accounts.
version_added: "0.5"
options:
user:
description:
- The username on the remote host whose authorized_keys file will be modified
- The username on the remote host whose authorized_keys file will be modified.
type: str
required: true
key:
description:
- The SSH public key(s), as a string or (since 1.9) url (https://github.com/username.keys)
- The SSH public key(s), as a string or (since Ansible 1.9) url (https://github.com/username.keys).
type: str
required: true
path:
description:
- Alternate path to the authorized_keys file
default: "(homedir)+/.ssh/authorized_keys"
- Alternate path to the authorized_keys file.
- When unset, this value defaults to I(~/.ssh/authorized_keys).
type: path
version_added: "1.2"
manage_dir:
description:
- Whether this module should manage the directory of the authorized key file. If
set, the module will create the directory, as well as set the owner and permissions
of an existing directory. Be sure to
set C(manage_dir=no) if you are using an alternate directory for
authorized_keys, as set with C(path), since you could lock yourself out of
SSH access. See the example below.
- Whether this module should manage the directory of the authorized key file.
- If set to C(yes), the module will create the directory, as well as set the owner and permissions
of an existing directory.
- Be sure to set C(manage_dir=no) if you are using an alternate directory for authorized_keys,
as set with C(path), since you could lock yourself out of SSH access.
- See the example below.
type: bool
default: 'yes'
default: yes
version_added: "1.2"
state:
description:
- Whether the given key (with the given key_options) should or should not be in the file
choices: [ "present", "absent" ]
default: "present"
- Whether the given key (with the given key_options) should or should not be in the file.
type: str
choices: [ absent, present ]
default: present
key_options:
description:
- A string of ssh key options to be prepended to the key in the authorized_keys file
- A string of ssh key options to be prepended to the key in the authorized_keys file.
version_added: "1.4"
exclusive:
description:
- Whether to remove all other non-specified keys from the authorized_keys file. Multiple keys
can be specified in a single C(key) string value by separating them by newlines.
- This option is not loop aware, so if you use C(with_) , it will be exclusive per iteration
of the loop, if you want multiple keys in the file you need to pass them all to C(key) in a
single batch as mentioned above.
- Whether to remove all other non-specified keys from the authorized_keys file.
- Multiple keys can be specified in a single C(key) string value by separating them by newlines.
- This option is not loop aware, so if you use C(with_) , it will be exclusive per iteration of the loop.
- If you want multiple keys in the file you need to pass them all to C(key) in a single batch as mentioned above.
type: bool
default: 'no'
default: no
version_added: "1.9"
validate_certs:
description:
- This only applies if using a https url as the source of the keys. If set to C(no), the SSL certificates will not be validated.
- This only applies if using a https url as the source of the keys.
- If set to C(no), the SSL certificates will not be validated.
- This should only set to C(no) used on personally controlled sites using self-signed certificates as it avoids verifying the source site.
- Prior to 2.1 the code worked as if this was set to C(yes).
type: bool
default: 'yes'
default: yes
version_added: "2.1"
comment:
description:
- Change the comment on the public key. Rewriting the comment is useful in
cases such as fetching it from GitHub or GitLab.
- Change the comment on the public key.
- Rewriting the comment is useful in cases such as fetching it from GitHub or GitLab.
- If no comment is specified, the existing comment will be kept.
type: str
version_added: "2.4"
follow:
description:
- Follow path symlink instead of replacing it
- Follow path symlink instead of replacing it.
type: bool
default: 'no'
default: no
version_added: "2.7"
author: "Ansible Core Team"
author: Ansible Core Team
'''
EXAMPLES = '''
EXAMPLES = r'''
- name: Set authorized key taken from file
authorized_key:
user: charlie
@ -147,7 +152,7 @@ EXAMPLES = '''
key: "{{ lookup('file', lookup('env','HOME') + '/.ssh/id_rsa.pub') }}"
'''
RETURN = '''
RETURN = r'''
exclusive:
description: If the key has been forced to be exclusive or not.
returned: success
@ -655,19 +660,18 @@ def enforce_state(module, params):
def main():
module = AnsibleModule(
argument_spec=dict(
user=dict(required=True, type='str'),
key=dict(required=True, type='str'),
path=dict(required=False, type='str'),
manage_dir=dict(required=False, type='bool', default=True),
state=dict(default='present', choices=['absent', 'present']),
key_options=dict(required=False, type='str'),
unique=dict(default=False, type='bool'),
exclusive=dict(default=False, type='bool'),
comment=dict(required=False, default=None, type='str'),
validate_certs=dict(default=True, type='bool'),
follow=dict(default=False, type='bool')
user=dict(type='str', required=True),
key=dict(type='str', required=True),
path=dict(type='str'),
manage_dir=dict(type='bool', default=True),
state=dict(type='str', default='present', choices=['absent', 'present']),
key_options=dict(type='str'),
exclusive=dict(type='bool', default=False),
comment=dict(type='str'),
validate_certs=dict(type='bool', default=True),
follow=dict(type='bool', default=False),
),
supports_check_mode=True
supports_check_mode=True,
)
results = enforce_state(module, module.params)

View file

@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# (c) 2017, Ted Trask <ttrask01@yahoo.com>
# Copyright: (c) 2017, Ted Trask <ttrask01@yahoo.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@ -12,7 +12,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['stableinterface'],
'supported_by': 'community'}
DOCUMENTATION = '''
DOCUMENTATION = r'''
---
module: awall
short_description: Manage awall policies
@ -20,40 +20,44 @@ version_added: "2.4"
author: Ted Trask (@tdtrask) <ttrask01@yahoo.com>
description:
- This modules allows for enable/disable/activate of I(awall) policies.
Alpine Wall (I(awall)) generates a firewall configuration from the enabled policy files
- Alpine Wall (I(awall)) generates a firewall configuration from the enabled policy files
and activates the configuration on the system.
options:
name:
description:
- A policy name, like C(foo), or multiple policies, like C(foo, bar).
- One or more policy names.
type: list
state:
description:
- The policy(ies) will be C(enabled)
- The policy(ies) will be C(disabled)
- Whether the policies should be enabled or disabled.
type: str
choices: [ disabled, enabled ]
default: enabled
choices: [ "enabled", "disabled" ]
activate:
description:
- Activate the new firewall rules. Can be run with other steps or on it's own.
- Activate the new firewall rules.
- Can be run with other steps or on its own.
type: bool
default: 'no'
default: no
'''
EXAMPLES = '''
EXAMPLES = r'''
- name: Enable "foo" and "bar" policy
awall:
name: foo,bar
name: [ foo bar ]
state: enabled
- name: Disable "foo" and "bar" policy and activate new rules
awall:
name: foo,bar
name:
- foo
- bar
state: disabled
activate: False
activate: no
- name: Activate currently enabled firewall rules
awall:
activate: True
activate: yes
'''
RETURN = ''' # '''
@ -122,12 +126,12 @@ def disable_policy(module, names, act):
def main():
module = AnsibleModule(
argument_spec=dict(
state=dict(default='enabled', choices=['enabled', 'disabled']),
state=dict(type='str', default='enabled', choices=['disabled', 'enabled']),
name=dict(type='list'),
activate=dict(default=False, type='bool'),
activate=dict(type='bool', default=False),
),
required_one_of=[['name', 'activate']],
supports_check_mode=True
supports_check_mode=True,
)
global AWALL_PATH

View file

@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# (c) 2016, Adam Števko <adam.stevko@gmail.com>
# Copyright: (c) 2016, Adam Števko <adam.stevko@gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@ -13,7 +13,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
'supported_by': 'community'}
DOCUMENTATION = '''
DOCUMENTATION = r'''
---
module: beadm
short_description: Manage ZFS boot environments on FreeBSD/Solaris/illumos systems.
@ -26,47 +26,43 @@ options:
name:
description:
- ZFS boot environment name.
aliases: [ "be" ]
type: str
required: True
aliases: [ "be" ]
snapshot:
description:
- If specified, the new boot environment will be cloned from the given
snapshot or inactive boot environment.
required: false
default: false
type: str
description:
description:
- Associate a description with a new boot environment. This option is
available only on Solarish platforms.
required: false
default: false
type: str
options:
description:
- Create the datasets for new BE with specific ZFS properties. Multiple
options can be specified. This option is available only on
Solarish platforms.
required: false
default: false
- Create the datasets for new BE with specific ZFS properties.
- Multiple options can be specified.
- This option is available only on Solarish platforms.
type: str
mountpoint:
description:
- Path where to mount the ZFS boot environment
required: false
default: false
- Path where to mount the ZFS boot environment.
type: path
state:
description:
- Create or delete ZFS boot environment.
required: false
default: "present"
choices: [ "present", "absent", "activated", "mounted", "unmounted" ]
type: str
choices: [ absent, activated, mounted, present, unmounted ]
default: present
force:
description:
- Specifies if the unmount should be forced.
required: false
default: false
type: bool
default: false
'''
EXAMPLES = '''
EXAMPLES = r'''
- name: Create ZFS boot environment
beadm:
name: upgrade-be
@ -107,7 +103,7 @@ EXAMPLES = '''
state: activated
'''
RETURN = '''
RETURN = r'''
name:
description: BE name
returned: always
@ -139,7 +135,7 @@ state:
type: str
sample: present
force:
description: if forced action is wanted
description: If forced action is wanted
returned: always
type: bool
sample: False
@ -288,18 +284,15 @@ class BE(object):
def main():
module = AnsibleModule(
argument_spec=dict(
name=dict(required=True, aliases=['be'], type='str'),
name=dict(type='str', required=True, aliases=['be']),
snapshot=dict(type='str'),
description=dict(type='str'),
options=dict(type='str'),
mountpoint=dict(default=False, type='path'),
state=dict(
default='present',
choices=['present', 'absent', 'activated',
'mounted', 'unmounted']),
force=dict(default=False, type='bool'),
mountpoint=dict(type='path'),
state=dict(type='str', default='present', choices=['absent', 'activated', 'mounted', 'present', 'unmounted']),
force=dict(type='bool', default=False),
),
supports_check_mode=True
supports_check_mode=True,
)
be = BE(module)

View file

@ -11,7 +11,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community'}
DOCUMENTATION = '''
DOCUMENTATION = r'''
---
module: capabilities
short_description: Manage Linux capabilities
@ -22,28 +22,30 @@ options:
path:
description:
- Specifies the path to the file to be managed.
type: str
required: yes
capability:
description:
- Desired capability to set (with operator and flags, if state is C(present)) or remove (if state is C(absent))
type: str
required: yes
aliases: [ cap ]
state:
description:
- Whether the entry should be present or absent in the file's capabilities.
type: str
choices: [ absent, present ]
default: present
notes:
- The capabilities system will automatically transform operators and flags
into the effective set, so (for example, cap_foo=ep will probably become
cap_foo+ep). This module does not attempt to determine the final operator
and flags to compare, so you will want to ensure that your capabilities
argument matches the final capabilities.
- The capabilities system will automatically transform operators and flags into the effective set,
so for example, C(cap_foo=ep) will probably become C(cap_foo+ep).
- This module does not attempt to determine the final operator and flags to compare,
so you will want to ensure that your capabilities argument matches the final capabilities.
author:
- Nate Coraor (@natefoo)
'''
EXAMPLES = '''
EXAMPLES = r'''
- name: Set cap_sys_chroot+ep on /foo
capabilities:
path: /foo

View file

@ -65,9 +65,9 @@ options:
default: system-default(public)
permanent:
description:
- >
Should this configuration be in the running firewalld configuration or persist across reboots. As of Ansible version 2.3, permanent operations can
operate on firewalld configs when it's not running (requires firewalld >= 3.0.9). (NOTE: If this is false, immediate is assumed true.)
- Should this configuration be in the running firewalld configuration or persist across reboots.
- As of Ansible 2.3, permanent operations can operate on firewalld configs when it is not running (requires firewalld >= 3.0.9).
- Note that if this is C(no), immediate is assumed C(yes).
type: bool
immediate:
description:

View file

@ -14,8 +14,6 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
DOCUMENTATION = '''
---
module: group
author:
- Stephen Fromm (@sfromm)
version_added: "0.0.2"
short_description: Add or remove groups
requirements:
@ -29,32 +27,37 @@ options:
name:
description:
- Name of the group to manage.
type: str
required: true
gid:
description:
- Optional I(GID) to set for the group.
type: int
state:
description:
- Whether the group should be present or not on the remote host.
type: str
choices: [ absent, present ]
default: present
system:
description:
- If I(yes), indicates that the group created is a system group.
type: bool
default: 'no'
default: no
local:
version_added: "2.6"
required: false
default: 'no'
type: bool
description:
- Forces the use of "local" command alternatives on platforms that implement it.
This is useful in environments that use centralized authentication when you want to manipulate the local groups.
I.E. it uses `lgroupadd` instead of `useradd`.
- This is useful in environments that use centralized authentication when you want to manipulate the local groups.
(e.g. it uses C(lgroupadd) instead of C(useradd)).
- This requires that these commands exist on the targeted host, otherwise it will be a fatal error.
notes:
- For Windows targets, use the M(win_group) module instead.
type: bool
default: no
version_added: "2.6"
seealso:
- module: user
- module: win_group
author:
- Stephen Fromm (@sfromm)
'''
EXAMPLES = '''

View file

@ -12,7 +12,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community'}
DOCUMENTATION = '''
DOCUMENTATION = r'''
---
author:
- Alexander Bulimov (@abulimov)
@ -25,40 +25,50 @@ options:
vg:
description:
- The name of the volume group.
type: str
required: true
pvs:
description:
- List of comma-separated devices to use as physical devices in this volume group. Required when creating or resizing volume group.
- List of comma-separated devices to use as physical devices in this volume group.
- Required when creating or resizing volume group.
- The module will take care of running pvcreate if needed.
type: list
pesize:
description:
- The size of the physical extent. pesize must be a power of 2, or
multiple of 128KiB. Since version 2.6, pesize can be optionally suffixed
by a UNIT (k/K/m/M/g/G), default unit is megabyte.
- The size of the physical extent. pesize must be a power of 2, or multiple of 128KiB.
- Since Ansible 2.6, pesize can be optionally suffixed by a UNIT (k/K/m/M/g/G), default unit is megabyte.
type: int
default: 4
pv_options:
description:
- Additional options to pass to C(pvcreate) when creating the volume group.
type: str
version_added: "2.4"
vg_options:
description:
- Additional options to pass to C(vgcreate) when creating the volume group.
type: str
version_added: "1.6"
state:
description:
- Control if the volume group exists.
type: str
choices: [ absent, present ]
default: present
force:
description:
- If C(yes), allows to remove volume group with logical volumes.
type: bool
default: 'no'
default: no
seealso:
- module: filesystem
- module: lvol
- module: parted
notes:
- This module does not modify PE size for already present volume group.
'''
EXAMPLES = '''
EXAMPLES = r'''
- name: Create a volume group on top of /dev/sda1 with physical extent size = 32MB
lvg:
vg: vg.services

View file

@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# (c) 2017, Kenneth D. Evensen <kdevensen@gmail.com>
# Copyright: (c) 2017, Kenneth D. Evensen <kdevensen@gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import (absolute_import, division, print_function)
@ -13,93 +13,93 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
'supported_by': 'community'}
DOCUMENTATION = """
DOCUMENTATION = r'''
module: pamd
author:
- "Kenneth D. Evensen (@kevensen)"
- Kenneth D. Evensen (@kevensen)
short_description: Manage PAM Modules
description:
- Edit PAM service's type, control, module path and module arguments.
In order for a PAM rule to be modified, the type, control and
- In order for a PAM rule to be modified, the type, control and
module_path must match an existing rule. See man(5) pam.d for details.
version_added: "2.3"
options:
name:
required: true
description:
- The name generally refers to the PAM service file to
change, for example system-auth.
type: str
required: true
type:
required: true
description:
- The type of the PAM rule being modified. The type, control
and module_path all must match a rule to be modified.
- The type of the PAM rule being modified.
- The C(type), C(control) and C(module_path) all must match a rule to be modified.
type: str
required: true
control:
required: true
description:
- The control of the PAM rule being modified. This may be a
complicated control with brackets. If this is the case, be
sure to put "[bracketed controls]" in quotes. The type,
control and module_path all must match a rule to be modified.
- The control of the PAM rule being modified.
- This may be a complicated control with brackets. If this is the case, be
sure to put "[bracketed controls]" in quotes.
- The C(type), C(control) and C(module_path) all must match a rule to be modified.
type: str
required: true
module_path:
required: true
description:
- The module path of the PAM rule being modified. The type,
control and module_path all must match a rule to be modified.
- The module path of the PAM rule being modified.
- The C(type), C(control) and C(module_path) all must match a rule to be modified.
type: str
required: true
new_type:
description:
- The new type to assign to the new rule.
type: str
new_control:
description:
- The new control to assign to the new rule.
type: str
new_module_path:
description:
- The new module path to be assigned to the new rule.
type: str
module_arguments:
description:
- When state is 'updated', the module_arguments will replace existing
module_arguments. When state is 'args_absent' args matching those
listed in module_arguments will be removed. When state is
'args_present' any args listed in module_arguments are added if
missing from the existing rule. Furthermore, if the module argument
takes a value denoted by '=', the value will be changed to that specified
in module_arguments. Note that module_arguments is a list. Please see
the examples for usage.
- When state is C(updated), the module_arguments will replace existing module_arguments.
- When state is C(args_absent) args matching those listed in module_arguments will be removed.
- When state is C(args_present) any args listed in module_arguments are added if
missing from the existing rule.
- Furthermore, if the module argument takes a value denoted by C(=),
the value will be changed to that specified in module_arguments.
type: list
state:
default: updated
choices:
- updated
- before
- after
- args_present
- args_absent
- absent
description:
- The default of 'updated' will modify an existing rule if type,
control and module_path all match an existing rule. With 'before',
the new rule will be inserted before a rule matching type, control
and module_path. Similarly, with 'after', the new rule will be inserted
after an existing rule matching type, control and module_path. With
either 'before' or 'after' new_type, new_control, and new_module_path
must all be specified. If state is 'args_absent' or 'args_present',
new_type, new_control, and new_module_path will be ignored. State
'absent' will remove the rule. The 'absent' state was added in version
2.4 and is only available in Ansible versions >= 2.4.
- The default of C(updated) will modify an existing rule if type,
control and module_path all match an existing rule.
- With C(before), the new rule will be inserted before a rule matching type,
control and module_path.
- Similarly, with C(after), the new rule will be inserted after an existing rulematching type,
control and module_path.
- With either C(before) or C(after) new_type, new_control, and new_module_path must all be specified.
- If state is C(args_absent) or C(args_present), new_type, new_control, and new_module_path will be ignored.
- State C(absent) will remove the rule. The 'absent' state was added in Ansible 2.4.
type: str
choices: [ absent, before, after, args_absent, args_present, updated ]
default: updated
path:
default: /etc/pam.d/
description:
- This is the path to the PAM service files
type: path
default: /etc/pam.d/
backup:
description:
- Create a backup file including the timestamp information so you can
get the original file back if you somehow clobbered it incorrectly.
type: bool
default: 'no'
default: no
version_added: '2.6'
'''
"""
EXAMPLES = """
EXAMPLES = r'''
- name: Update pamd rule's control in /etc/pam.d/system-auth
pamd:
name: system-auth
@ -220,9 +220,9 @@ EXAMPLES = """
type: auth
module_path: pam_sss.so
control: 'requisite'
"""
'''
RETURN = '''
RETURN = r'''
change_count:
description: How many rules were changed
type: int
@ -230,14 +230,14 @@ change_count:
returned: success
version_added: 2.4
new_rule:
description: The changes to the rule. This was available in Ansible version 2.4 and 2.5. It was removed in 2.6.
description: The changes to the rule. This was available in Ansible 2.4 and Ansible 2.5. It was removed in Ansible 2.6.
type: str
sample: None None None sha512 shadow try_first_pass use_authtok
returned: success
version_added: 2.4
updated_rule_(n):
description: The rule(s) that was/were changed. This is only available in
Ansible version 2.4 and was removed in 2.5.
Ansible 2.4 and was removed in Ansible 2.5.
type: str
sample:
- password sufficient pam_unix.so sha512 shadow try_first_pass
@ -248,7 +248,7 @@ action:
description:
- "That action that was taken and is one of: update_rule,
insert_before_rule, insert_after_rule, args_present, args_absent,
absent. This was available in Ansible version 2.4 and removed in 2.8"
absent. This was available in Ansible 2.4 and removed in Ansible 2.8"
returned: always
type: str
sample: "update_rule"
@ -256,7 +256,7 @@ action:
dest:
description:
- "Path to pam.d service that was changed. This is only available in
Ansible version 2.3 and was removed in 2.4."
Ansible 2.3 and was removed in Ansible 2.4."
returned: success
type: str
sample: "/etc/pam.d/system-auth"
@ -770,21 +770,17 @@ def main():
module = AnsibleModule(
argument_spec=dict(
name=dict(required=True, type='str'),
type=dict(required=True,
choices=VALID_TYPES),
control=dict(required=True, type='str'),
module_path=dict(required=True, type='str'),
new_type=dict(required=False,
choices=VALID_TYPES),
new_control=dict(required=False, type='str'),
new_module_path=dict(required=False, type='str'),
module_arguments=dict(required=False, type='list'),
state=dict(required=False, default="updated",
choices=['before', 'after', 'updated',
'args_absent', 'args_present', 'absent']),
path=dict(required=False, default='/etc/pam.d', type='str'),
backup=dict(default=False, type='bool')
name=dict(type='str', required=True),
type=dict(type='str', required=True, choices=VALID_TYPES),
control=dict(type='str', required=True),
module_path=dict(type='str', required=True),
new_type=dict(type='str', choices=VALID_TYPES),
new_control=dict(type='str'),
new_module_path=dict(type='str'),
module_arguments=dict(type='list'),
state=dict(type='str', default='updated', choices=['absent', 'after', 'args_absent', 'args_present', 'before', 'updated']),
path=dict(type='path', default='/etc/pam.d'),
backup=dict(type='bool', default=False),
),
supports_check_mode=True,
required_if=[

View file

@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# (c) 2016, Fabrizio Colonna <colofabrix@tin.it>
# Copyright: (c) 2016, Fabrizio Colonna <colofabrix@tin.it>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@ -13,10 +13,10 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
'supported_by': 'community'}
DOCUMENTATION = '''
DOCUMENTATION = r'''
---
author:
- "Fabrizio Colonna (@ColOfAbRiX)"
- Fabrizio Colonna (@ColOfAbRiX)
module: parted
short_description: Configure block device partitions
version_added: "2.3"
@ -24,11 +24,6 @@ description:
- This module allows configuring block device partition using the C(parted)
command line tool. For a full description of the fields and the options
check the GNU parted manual.
notes:
- When fetching information about a new disk and when the version of parted
installed on the system is before version 3.1, the module queries the kernel
through C(/sys/) to obtain disk information. In this case the units CHS and
CYL are not supported.
requirements:
- This module requires parted version 1.8.3 and above.
- If the version of parted is below 3.1, it requires a Linux version running
@ -36,70 +31,79 @@ requirements:
options:
device:
description: The block device (disk) where to operate.
type: str
required: True
align:
description: Set alignment for newly created partitions.
choices: ['none', 'cylinder', 'minimal', 'optimal']
type: str
choices: [ cylinder, minimal, none, optimal ]
default: optimal
number:
description:
- The number of the partition to work with or the number of the partition
that will be created. Required when performing any action on the disk,
except fetching information.
- The number of the partition to work with or the number of the partition
that will be created.
- Required when performing any action on the disk, except fetching information.
type: int
unit:
description:
- Selects the current default unit that Parted will use to display
locations and capacities on the disk and to interpret those given by the
user if they are not suffixed by an unit. When fetching information about
a disk, it is always recommended to specify a unit.
choices: [
's', 'B', 'KB', 'KiB', 'MB', 'MiB', 'GB', 'GiB', 'TB', 'TiB', '%', 'cyl',
'chs', 'compact'
]
- Selects the current default unit that Parted will use to display
locations and capacities on the disk and to interpret those given by the
user if they are not suffixed by an unit.
- When fetching information about a disk, it is always recommended to specify a unit.
type: str
choices: [ s, B, KB, KiB, MB, MiB, GB, GiB, TB, TiB, '%', cyl, chs, compact ]
default: KiB
label:
description: Creates a new disk label.
choices: [
'aix', 'amiga', 'bsd', 'dvh', 'gpt', 'loop', 'mac', 'msdos', 'pc98',
'sun'
]
type: str
choices: [ aix, amiga, bsd, dvh, gpt, loop, mac, msdos, pc98, sun ]
default: msdos
part_type:
description:
- Is one of 'primary', 'extended' or 'logical' and may be specified only
with 'msdos' or 'dvh' partition tables. A name must be specified for a
'gpt' partition table. Neither part-type nor name may be used with a
'sun' partition table.
choices: ['primary', 'extended', 'logical']
- May be specified only with 'msdos' or 'dvh' partition tables.
- A C(name) must be specified for a 'gpt' partition table.
- Neither C(part_type) nor C(name) may be used with a 'sun' partition table.
type: str
choices: [ extended, logical, primary ]
default: primary
part_start:
description:
- Where the partition will start as offset from the beginning of the disk,
that is, the "distance" from the start of the disk. The distance can be
specified with all the units supported by parted (except compat) and
it is case sensitive. E.g. C(10GiB), C(15%).
- Where the partition will start as offset from the beginning of the disk,
that is, the "distance" from the start of the disk.
- The distance can be specified with all the units supported by parted
(except compat) and it is case sensitive, e.g. C(10GiB), C(15%).
type: str
default: 0%
part_end :
description:
- Where the partition will end as offset from the beginning of the disk,
that is, the "distance" from the start of the disk. The distance can be
specified with all the units supported by parted (except compat) and
it is case sensitive. E.g. C(10GiB), C(15%).
- Where the partition will end as offset from the beginning of the disk,
that is, the "distance" from the start of the disk.
- The distance can be specified with all the units supported by parted
(except compat) and it is case sensitive, e.g. C(10GiB), C(15%).
type: str
default: 100%
name:
description:
- Sets the name for the partition number (GPT, Mac, MIPS and PC98 only).
- Sets the name for the partition number (GPT, Mac, MIPS and PC98 only).
type: str
flags:
description: A list of the flags that has to be set on the partition.
type: list
state:
description:
- If to create or delete a partition. If set to C(info) the module will
only return the device information.
choices: ['present', 'absent', 'info']
- Whether to create or delete a partition.
- If set to C(info) the module will only return the device information.
type: str
choices: [ absent, present, info ]
default: info
notes:
- When fetching information about a new disk and when the version of parted
installed on the system is before version 3.1, the module queries the kernel
through C(/sys/) to obtain disk information. In this case the units CHS and
CYL are not supported.
'''
RETURN = '''
RETURN = r'''
partition_info:
description: Current partition information
returned: success
@ -142,46 +146,47 @@ partition_info:
}
'''
EXAMPLES = """
# Create a new primary partition
- parted:
EXAMPLES = r'''
- name: Create a new primary partition
parted:
device: /dev/sdb
number: 1
state: present
# Remove partition number 1
- parted:
- name: Remove partition number 1
parted:
device: /dev/sdb
number: 1
state: absent
# Create a new primary partition with a size of 1GiB
- parted:
- name: Create a new primary partition with a size of 1GiB
parted:
device: /dev/sdb
number: 1
state: present
part_end: 1GiB
# Create a new primary partition for LVM
- parted:
- name: Create a new primary partition for LVM
parted:
device: /dev/sdb
number: 2
flags: [ lvm ]
state: present
part_start: 1GiB
# Read device information (always use unit when probing)
- parted: device=/dev/sdb unit=MiB
# Example on how to read info and reuse it in subsequent task
- name: Read device information (always use unit when probing)
parted: device=/dev/sdb unit=MiB
register: sdb_info
# Remove all partitions from disk
- parted:
- name: Remove all partitions from disk
parted:
device: /dev/sdb
number: "{{ item.num }}"
number: '{{ item.num }}'
state: absent
with_items:
- "{{ sdb_info.partitions }}"
"""
- '{{ sdb_info.partitions }}'
'''
from ansible.module_utils.basic import AnsibleModule
@ -192,7 +197,7 @@ import os
# Reference prefixes (International System of Units and IEC)
units_si = ['B', 'KB', 'MB', 'GB', 'TB']
units_iec = ['B', 'KiB', 'MiB', 'GiB', 'TiB']
units_iec = ['KiB', 'MiB', 'GiB', 'TiB']
parted_units = units_si + units_iec + ['s', '%', 'cyl', 'chs', 'compact']
@ -531,54 +536,31 @@ def main():
output_script = ""
script = ""
module = AnsibleModule(
argument_spec={
'device': {'required': True, 'type': 'str'},
'align': {
'default': 'optimal',
'choices': ['none', 'cylinder', 'minimal', 'optimal'],
'type': 'str'
},
'number': {'default': None, 'type': 'int'},
argument_spec=dict(
device=dict(type='str', required=True),
align=dict(type='str', default='optimal', choices=['cylinder', 'minimal', 'none', 'optimal']),
number=dict(type='int'),
# unit <unit> command
'unit': {
'default': 'KiB',
'choices': parted_units,
'type': 'str'
},
unit=dict(type='str', default='KiB', choices=parted_units),
# mklabel <label-type> command
'label': {
'default': 'msdos',
'choices': [
'aix', 'amiga', 'bsd', 'dvh', 'gpt', 'loop', 'mac', 'msdos',
'pc98', 'sun'
],
'type': 'str'
},
label=dict(type='str', default='msdos', choices=['aix', 'amiga', 'bsd', 'dvh', 'gpt', 'loop', 'mac', 'msdos', 'pc98', 'sun']),
# mkpart <part-type> [<fs-type>] <start> <end> command
'part_type': {
'default': 'primary',
'choices': ['primary', 'extended', 'logical'],
'type': 'str'
},
'part_start': {'default': '0%', 'type': 'str'},
'part_end': {'default': '100%', 'type': 'str'},
part_type=dict(type='str', default='primary', choices=['extended', 'logical', 'primary']),
part_start=dict(type='str', default='0%'),
part_end=dict(type='str', default='100%'),
# name <partition> <name> command
'name': {'type': 'str'},
name=dict(type='str'),
# set <partition> <flag> <state> command
'flags': {'type': 'list'},
flags=dict(type='list'),
# rm/mkpart command
'state': {
'choices': ['present', 'absent', 'info'],
'default': 'info',
'type': 'str'
}
},
state=dict(type='str', default='info', choices=['absent', 'info', 'present']),
),
required_if=[
['state', 'present', ['number']],
['state', 'absent', ['number']],

View file

@ -25,14 +25,12 @@ description:
- This is NOT ICMP ping, this is just a trivial test module that requires Python on the remote-node.
- For Windows targets, use the M(win_ping) module instead.
- For Network targets, use the M(net_ping) module instead.
notes:
- For Windows targets, use the M(win_ping) module instead.
- For Network targets, use the M(net_ping) module instead.
options:
data:
description:
- Data to return for the C(ping) return value.
- If this parameter is set to C(crash), the module will cause an exception.
type: str
default: pong
seealso:
- module: net_ping

View file

@ -14,7 +14,8 @@ DOCUMENTATION = r'''
module: reboot
short_description: Reboot a machine
description:
- Reboot a machine, wait for it to go down, come back up, and respond to commands.
- Reboot a machine, wait for it to go down, come back up, and respond to commands.
- For Windows targets, use the M(win_reboot) module instead.
version_added: "2.7"
options:
pre_reboot_delay:
@ -22,21 +23,21 @@ options:
- Seconds for shutdown to wait before requesting reboot.
- On Linux, macOS and OpenBSD, this is converted to minutes and rounded down. If less than 60, it will be set to 0.
- On Solaris and FreeBSD, this will be seconds.
default: 0
type: int
default: 0
post_reboot_delay:
description:
- Seconds to wait after the reboot was successful and the connection was re-established.
- This is useful if you want wait for something to settle despite your connection already working.
default: 0
type: int
default: 0
reboot_timeout:
description:
- Maximum seconds to wait for machine to reboot and respond to a test command.
- This timeout is evaluated separately for both network connection and test command success so the
maximum execution time for the module is twice this amount.
default: 600
type: int
default: 600
connect_timeout:
description:
- Maximum seconds to wait for a successful connection to the managed hosts before trying again.
@ -46,15 +47,13 @@ options:
description:
- Command to run on the rebooted host and expect success from to determine the machine is ready for
further tasks.
default: whoami
type: str
default: whoami
msg:
description:
- Message to display to users before reboot.
default: Reboot initiated by Ansible
type: str
notes:
- For Windows targets, use the M(win_reboot) module instead.
default: Reboot initiated by Ansible
seealso:
- module: win_reboot
author:

View file

@ -11,7 +11,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['stableinterface'],
'supported_by': 'core'}
DOCUMENTATION = '''
DOCUMENTATION = r'''
---
module: service
version_added: "0.1"
@ -24,52 +24,60 @@ options:
name:
description:
- Name of the service.
type: str
required: true
state:
description:
- C(started)/C(stopped) are idempotent actions that will not run
commands unless necessary. C(restarted) will always bounce the
service. C(reloaded) will always reload. B(At least one of state
and enabled are required.) Note that reloaded will start the
service if it is not already started, even if your chosen init
system wouldn't normally.
commands unless necessary.
- C(restarted) will always bounce the service.
- C(reloaded) will always reload.
- B(At least one of state and enabled are required.)
- Note that reloaded will start the service if it is not already started,
even if your chosen init system wouldn't normally.
type: str
choices: [ reloaded, restarted, started, stopped ]
sleep:
description:
- If the service is being C(restarted) then sleep this many seconds
between the stop and start command. This helps to workaround badly
behaving init scripts that exit immediately after signaling a process
to stop.
between the stop and start command.
- This helps to work around badly-behaving init scripts that exit immediately
after signaling a process to stop.
type: int
version_added: "1.3"
pattern:
description:
- If the service does not respond to the status command, name a
substring to look for as would be found in the output of the I(ps)
command as a stand-in for a status result. If the string is found,
the service will be assumed to be started.
command as a stand-in for a status result.
- If the string is found, the service will be assumed to be started.
type: str
version_added: "0.7"
enabled:
description:
- Whether the service should start on boot. B(At least one of state and
enabled are required.)
- Whether the service should start on boot.
- B(At least one of state and enabled are required.)
type: bool
runlevel:
description:
- "For OpenRC init scripts (ex: Gentoo) only. The runlevel that this service belongs to."
- For OpenRC init scripts (e.g. Gentoo) only.
- The runlevel that this service belongs to.
type: str
default: default
arguments:
description:
- Additional arguments provided on the command line
- Additional arguments provided on the command line.
type: str
aliases: [ args ]
use:
description:
- The service module actually uses system specific modules, normally through auto detection, this setting can force a specific module.
- Normally it uses the value of the 'ansible_service_mgr' fact and falls back to the old 'service' module when none matching is found.
type: str
default: auto
version_added: 2.2
notes:
- For AIX group subsystem names can be used.
- For Windows targets, use the M(win_service) module instead.
- For AIX, group subsystem names can be used.
seealso:
- module: win_service
author:
@ -77,7 +85,7 @@ author:
- Michael DeHaan
'''
EXAMPLES = '''
EXAMPLES = r'''
- name: Start service httpd, if not started
service:
name: httpd

View file

@ -24,6 +24,7 @@ options:
name:
description:
- Name of the service to manage.
type: str
required: true
state:
description:
@ -33,13 +34,14 @@ options:
C(reloaded) will send a sigusr1 (svc -1).
C(once) will run a normally downed svc once (svc -o), not really
an idempotent operation.
type: str
choices: [ killed, once, reloaded, restarted, started, stopped ]
downed:
description:
- Should a 'down' file exist or not, if it exists it disables auto startup.
Defaults to no. Downed does not imply stopped.
type: bool
default: 'no'
default: no
enabled:
description:
- Whether the service is enabled or not, if disabled it also implies stopped.
@ -48,10 +50,13 @@ options:
service_dir:
description:
- Directory svscan watches for services
type: path
default: /service
service_src:
description:
- Directory where services are defined, the source of symlinks to service_dir.
type: path
default: /etc/service
'''
EXAMPLES = '''
@ -247,7 +252,6 @@ def main():
state=dict(type='str', choices=['killed', 'once', 'reloaded', 'restarted', 'started', 'stopped']),
enabled=dict(type='bool'),
downed=dict(type='bool'),
dist=dict(type='str', default='daemontools'),
service_dir=dict(type='str', default='/service'),
service_src=dict(type='str', default='/etc/service'),
),

View file

@ -11,7 +11,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community'}
DOCUMENTATION = '''
DOCUMENTATION = r'''
---
module: timezone
short_description: Configure timezone setting
@ -21,26 +21,28 @@ description:
- Several different tools are used depending on the OS/Distribution involved.
For Linux it can use C(timedatectl) or edit C(/etc/sysconfig/clock) or C(/etc/timezone) and C(hwclock).
On SmartOS, C(sm-set-timezone), for macOS, C(systemsetup), for BSD, C(/etc/localtime) is modified.
- As of version 2.3 support was added for SmartOS and BSDs.
- As of version 2.4 support was added for macOS.
- As of Ansible 2.3 support was added for SmartOS and BSDs.
- As of Ansible 2.4 support was added for macOS.
- Windows, AIX and HPUX are not supported, please let us know if you find any other OS/distro in which this fails.
version_added: "2.2"
options:
name:
description:
- Name of the timezone for the system clock.
Default is to keep current setting. B(At least one of name and
hwclock are required.)
- Default is to keep current setting.
- B(At least one of name and hwclock are required.)
type: str
hwclock:
description:
- Whether the hardware clock is in UTC or in local timezone.
Default is to keep current setting.
Note that this option is recommended not to change and may fail
- Default is to keep current setting.
- Note that this option is recommended not to change and may fail
to configure, especially on virtual environments such as AWS.
B(At least one of name and hwclock are required.)
I(Only used on Linux.)
- B(At least one of name and hwclock are required.)
- I(Only used on Linux.)
type: str
aliases: [ rtc ]
choices: [ "UTC", "local" ]
choices: [ local, UTC ]
notes:
- On SmartOS the C(sm-set-timezone) utility (part of the smtools package) is required to set the zone timezone
author:
@ -49,7 +51,7 @@ author:
- Indrajit Raychaudhuri (@indrajitr)
'''
RETURN = '''
RETURN = r'''
diff:
description: The differences about the given arguments.
returned: success
@ -63,8 +65,8 @@ diff:
type: dict
'''
EXAMPLES = '''
- name: set timezone to Asia/Tokyo
EXAMPLES = r'''
- name: Set timezone to Asia/Tokyo
timezone:
name: Asia/Tokyo
'''

View file

@ -13,15 +13,235 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
DOCUMENTATION = '''
module: user
author:
- Stephen Fromm (@sfromm)
version_added: "0.2"
short_description: Manage user accounts
description:
- Manage user accounts and user attributes.
- For Windows targets, use the M(win_user) module instead.
options:
name:
description:
- Name of the user to create, remove or modify.
type: str
required: true
aliases: [ user ]
uid:
description:
- Optionally sets the I(UID) of the user.
type: int
comment:
description:
- Optionally sets the description (aka I(GECOS)) of user account.
type: str
hidden:
description:
- macOS only, optionally hide the user from the login window and system preferences.
- The default will be C(yes) if the I(system) option is used.
type: bool
required: false
version_added: "2.6"
non_unique:
description:
- Optionally when used with the -u option, this option allows to change the user ID to a non-unique value.
type: bool
default: no
version_added: "1.1"
seuser:
description:
- Optionally sets the seuser type (user_u) on selinux enabled systems.
type: str
version_added: "2.1"
group:
description:
- Optionally sets the user's primary group (takes a group name).
type: str
groups:
description:
- List of groups user will be added to. When set to an empty string C(''),
C(null), or C(~), the user is removed from all groups except the
primary group. (C(~) means C(null) in YAML)
- Before Ansible 2.3, the only input format allowed was a comma separated string.
type: list
append:
description:
- If C(yes), add the user to the groups specified in C(groups).
- If C(no), user will only be added to the groups specified in C(groups),
removing them from all other groups.
type: bool
default: no
shell:
description:
- Optionally set the user's shell.
- On macOS, before Ansible 2.5, the default shell for non-system users was C(/usr/bin/false).
Since Ansible 2.5, the default shell for non-system users on macOS is C(/bin/bash).
- On other operating systems, the default shell is determined by the underlying tool being
used. See Notes for details.
type: str
home:
description:
- Optionally set the user's home directory.
type: path
skeleton:
description:
- Optionally set a home skeleton directory.
- Requires C(create_home) option!
type: str
version_added: "2.0"
password:
description:
- Optionally set the user's password to this crypted value.
- On macOS systems, this value has to be cleartext. Beware of security issues.
- To create a disabled account on Linux systems, set this to C('!') or C('*').
- See U(https://docs.ansible.com/ansible/faq.html#how-do-i-generate-crypted-passwords-for-the-user-module)
for details on various ways to generate these password values.
type: str
state:
description:
- Whether the account should exist or not, taking action if the state is different from what is stated.
type: str
choices: [ absent, present ]
default: present
create_home:
description:
- Unless set to C(no), a home directory will be made for the user
when the account is created or if the home directory does not exist.
- Changed from C(createhome) to C(create_home) in Ansible 2.5.
type: bool
default: yes
aliases: [ createhome ]
move_home:
description:
- "If set to C(yes) when used with C(home: ), attempt to move the user's old home
directory to the specified directory if it isn't there already and the old home exists."
type: bool
default: no
system:
description:
- When creating an account C(state=present), setting this to C(yes) makes the user a system account.
- This setting cannot be changed on existing users.
type: bool
default: no
force:
description:
- This only affects C(state=absent), it forces removal of the user and associated directories on supported platforms.
- The behavior is the same as C(userdel --force), check the man page for C(userdel) on your system for details and support.
- When used with C(generate_ssh_key=yes) this forces an existing key to be overwritten.
type: bool
default: no
remove:
description:
- This only affects C(state=absent), it attempts to remove directories associated with the user.
- The behavior is the same as C(userdel --remove), check the man page for details and support.
type: bool
default: no
login_class:
description:
- Optionally sets the user's login class, a feature of most BSD OSs.
type: str
generate_ssh_key:
description:
- Whether to generate a SSH key for the user in question.
- This will B(not) overwrite an existing SSH key unless used with C(force=yes).
type: bool
default: no
version_added: "0.9"
ssh_key_bits:
description:
- Optionally specify number of bits in SSH key to create.
type: int
default: default set by ssh-keygen
version_added: "0.9"
ssh_key_type:
description:
- Optionally specify the type of SSH key to generate.
- Available SSH key types will depend on implementation
present on target host.
type: str
default: rsa
version_added: "0.9"
ssh_key_file:
description:
- Optionally specify the SSH key filename.
- If this is a relative filename then it will be relative to the user's home directory.
type: path
default: .ssh/id_rsa
version_added: "0.9"
ssh_key_comment:
description:
- Optionally define the comment for the SSH key.
type: str
default: ansible-generated on $HOSTNAME
version_added: "0.9"
ssh_key_passphrase:
description:
- Set a passphrase for the SSH key.
- If no passphrase is provided, the SSH key will default to having no passphrase.
type: str
version_added: "0.9"
update_password:
description:
- C(always) will update passwords if they differ.
- C(on_create) will only set the password for newly created users.
type: str
choices: [ always, on_create ]
default: always
version_added: "1.3"
expires:
description:
- An expiry time for the user in epoch, it will be ignored on platforms that do not support this.
- Currently supported on GNU/Linux, FreeBSD, and DragonFlyBSD.
- Since Ansible 2.6 you can remove the expiry time specify a negative value.
Currently supported on GNU/Linux and FreeBSD.
type: float
version_added: "1.9"
password_lock:
description:
- Lock the password (usermod -L, pw lock, usermod -C).
- BUT implementation differs on different platforms, this option does not always mean the user cannot login via other methods.
- This option does not disable the user, only lock the password. Do not change the password in the same task.
- Currently supported on Linux, FreeBSD, DragonFlyBSD, NetBSD, OpenBSD.
type: bool
version_added: "2.6"
local:
description:
- Forces the use of "local" command alternatives on platforms that implement it.
- This is useful in environments that use centralized authentification when you want to manipulate the local users
(i.e. it uses C(luseradd) instead of C(useradd)).
- This requires that these commands exist on the targeted host, otherwise it will be a fatal error.
type: bool
default: no
version_added: "2.4"
profile:
description:
- Sets the profile of the user.
- Does nothing when used with other platforms.
- Can set multiple profiles using comma separation.
- To delete all the profiles, use C(profile='').
- Currently supported on Illumos/Solaris.
type: str
version_added: "2.8"
authorization:
description:
- Sets the authorization of the user.
- Does nothing when used with other platforms.
- Can set multiple authorizations using comma separation.
- To delete all authorizations, use C(authorization='').
- Currently supported on Illumos/Solaris.
type: str
version_added: "2.8"
role:
description:
- Sets the role of the user.
- Does nothing when used with other platforms.
- Can set multiple roles using comma separation.
- To delete all roles, use C(role='').
- Currently supported on Illumos/Solaris.
type: str
version_added: "2.8"
notes:
- There are specific requirements per platform on user management utilities. However
they generally come pre-installed with the system and Ansible will require they
are present at runtime. If they are not, a descriptive error message will be shown.
- For Windows targets, use the M(win_user) module instead.
- On SunOS platforms, the shadow file is backed up automatically since this module edits it directly.
On other platforms, the shadow file is backed up by the underlying tools used by this module.
- On macOS, this module uses C(dscl) to create, modify, and delete accounts. C(dseditgroup) is used to
@ -31,206 +251,12 @@ notes:
C(pw userdel) remove, C(pw lock) to lock, and C(pw unlock) to unlock accounts.
- On all other platforms, this module uses C(useradd) to create, C(usermod) to modify, and
C(userdel) to remove accounts.
description:
- Manage user accounts and user attributes.
- For Windows targets, use the M(win_user) module instead.
options:
name:
description:
- Name of the user to create, remove or modify.
required: true
aliases: [ user ]
uid:
description:
- Optionally sets the I(UID) of the user.
comment:
description:
- Optionally sets the description (aka I(GECOS)) of user account.
hidden:
required: false
type: bool
description:
- macOS only, optionally hide the user from the login window and system preferences.
- The default will be 'True' if the I(system) option is used.
version_added: "2.6"
non_unique:
description:
- Optionally when used with the -u option, this option allows to change the user ID to a non-unique value.
type: bool
default: "no"
version_added: "1.1"
seuser:
description:
- Optionally sets the seuser type (user_u) on selinux enabled systems.
version_added: "2.1"
group:
description:
- Optionally sets the user's primary group (takes a group name).
groups:
description:
- List of groups user will be added to. When set to an empty string C(''),
C(null), or C(~), the user is removed from all groups except the
primary group. (C(~) means C(null) in YAML)
- Before version 2.3, the only input format allowed was a comma separated string.
Now this parameter accepts a list as well as a comma separated string.
append:
description:
- If C(yes), add the user to the groups specified in C(groups).
- If C(no), user will only be added to the groups specified in C(groups),
removing them from all other groups.
type: bool
default: "no"
shell:
description:
- Optionally set the user's shell.
- On macOS, before version 2.5, the default shell for non-system users was /usr/bin/false.
Since 2.5, the default shell for non-system users on macOS is /bin/bash.
- On other operating systems, the default shell is determined by the underlying tool being
used. See Notes for details.
home:
description:
- Optionally set the user's home directory.
skeleton:
description:
- Optionally set a home skeleton directory. Requires create_home option!
version_added: "2.0"
password:
description:
- Optionally set the user's password to this crypted value.
- On macOS systems, this value has to be cleartext. Beware of security issues.
- To create a disabled account on Linux systems, set this to C('!') or C('*').
- See U(https://docs.ansible.com/ansible/faq.html#how-do-i-generate-crypted-passwords-for-the-user-module)
for details on various ways to generate these password values.
state:
description:
- Whether the account should exist or not, taking action if the state is different from what is stated.
choices: [ absent, present ]
default: present
create_home:
description:
- Unless set to C(no), a home directory will be made for the user
when the account is created or if the home directory does not exist.
- Changed from C(createhome) to C(create_home) in version 2.5.
type: bool
default: 'yes'
aliases: ['createhome']
move_home:
description:
- "If set to C(yes) when used with C(home: ), attempt to move the user's old home
directory to the specified directory if it isn't there already and the old home exists."
type: bool
default: "no"
system:
description:
- "When creating an account C(state: present), setting this to C(yes) makes the user a system account.
This setting cannot be changed on existing users."
type: bool
default: "no"
force:
description:
- "This only affects C(state: absent), it forces removal of the user and associated directories on supported platforms.
The behavior is the same as C(userdel --force), check the man page for C(userdel) on your system for details and support."
- "When used with C(generate_ssh_key: yes) this forces an existing key to be overwritten."
type: bool
default: "no"
remove:
description:
- "This only affects C(state: absent), it attempts to remove directories associated with the user.
The behavior is the same as C(userdel --remove), check the man page for details and support."
type: bool
default: "no"
login_class:
description:
- Optionally sets the user's login class, a feature of most BSD OSs.
generate_ssh_key:
description:
- "Whether to generate a SSH key for the user in question.
This will not overwrite an existing SSH key unless used with C(force: yes)."
type: bool
default: "no"
version_added: "0.9"
ssh_key_bits:
description:
- Optionally specify number of bits in SSH key to create.
default: default set by ssh-keygen
version_added: "0.9"
ssh_key_type:
description:
- Optionally specify the type of SSH key to generate.
Available SSH key types will depend on implementation
present on target host.
default: rsa
version_added: "0.9"
ssh_key_file:
description:
- Optionally specify the SSH key filename. If this is a relative
filename then it will be relative to the user's home directory.
default: .ssh/id_rsa
version_added: "0.9"
ssh_key_comment:
description:
- Optionally define the comment for the SSH key.
default: ansible-generated on $HOSTNAME
version_added: "0.9"
ssh_key_passphrase:
description:
- Set a passphrase for the SSH key. If no
passphrase is provided, the SSH key will default to
having no passphrase.
version_added: "0.9"
update_password:
description:
- C(always) will update passwords if they differ. C(on_create) will only set the password for newly created users.
choices: [ always, on_create ]
default: always
version_added: "1.3"
expires:
description:
- An expiry time for the user in epoch, it will be ignored on platforms that do not support this.
Currently supported on GNU/Linux, FreeBSD, and DragonFlyBSD.
- Since version 2.6 you can remove the expiry time specify a negative value. Currently supported on GNU/Linux and FreeBSD.
version_added: "1.9"
password_lock:
description:
- Lock the password (usermod -L, pw lock, usermod -C).
BUT implementation differs on different platforms, this option does not always mean the user cannot login via other methods.
This option does not disable the user, only lock the password. Do not change the password in the same task.
Currently supported on Linux, FreeBSD, DragonFlyBSD, NetBSD, OpenBSD.
type: bool
version_added: "2.6"
local:
description:
- Forces the use of "local" command alternatives on platforms that implement it.
This is useful in environments that use centralized authentification when you want to manipulate the local users.
I.E. it uses `luseradd` instead of `useradd`.
- This requires that these commands exist on the targeted host, otherwise it will be a fatal error.
type: bool
default: 'no'
version_added: "2.4"
profile:
description:
- Sets the profile of the user.
- Does nothing when used with other platforms.
- Can set multiple profiles using comma separation.
- "To delete all the profiles, use C(profile: '')"
- Currently supported on Illumos/Solaris.
version_added: "2.8"
authorization:
description:
- Sets the authorization of the user.
- Does nothing when used with other platforms.
- Can set multiple authorizations using comma separation.
- "To delete all authorizations, use C(authorization: '')"
- Currently supported on Illumos/Solaris.
version_added: "2.8"
role:
description:
- Sets the role of the user.
- Does nothing when used with other platforms.
- Can set multiple roles using comma separation.
- "To delete all roles, use C(role: '')"
- Currently supported on Illumos/Solaris.
version_added: "2.8"
seealso:
- module: authorized_key
- module: group
- module: win_user
author:
- Stephen Fromm (@sfromm)
'''
EXAMPLES = '''
@ -268,7 +294,7 @@ EXAMPLES = '''
groups: developers
expires: 1422403387
- name: starting at version 2.6, modify user, remove expiry time
- name: Starting at Ansible 2.6, modify user, remove expiry time
user:
name: james18
expires: -1

View file

@ -16,10 +16,10 @@ ANSIBLE_METADATA = {
'supported_by': 'community'
}
DOCUMENTATION = '''
DOCUMENTATION = r'''
---
author:
- "Bryan Gurney (@bgurney-rh)"
- Bryan Gurney (@bgurney-rh)
module: vdo
@ -29,7 +29,7 @@ version_added: "2.5"
description:
- This module controls the VDO dedupe and compression device.
VDO, or Virtual Data Optimizer, is a device-mapper target that
- VDO, or Virtual Data Optimizer, is a device-mapper target that
provides inline block-level deduplication, compression, and
thin provisioning capabilities to primary storage.
@ -37,9 +37,9 @@ options:
name:
description:
- The name of the VDO volume.
type: str
required: true
state:
choices: [ "present", "absent" ]
description:
- Whether this VDO volume should be "present" or "absent".
If a "present" VDO volume does not exist, it will be
@ -51,9 +51,11 @@ options:
parameters that can be modified after creation. If an
"absent" VDO volume does not exist, it will not be
removed.
type: str
required: true
choices: [ absent, present ]
default: present
activated:
choices: [ "yes", "no" ]
description:
- The "activate" status for a VDO volume. If this is set
to "no", the VDO volume cannot be started, and it will
@ -65,19 +67,17 @@ options:
(filesystem, LVM headers, etc.) to the VDO volume prior
to stopping the volume, and leaving it deactivated
until ready to use.
required: false
type: bool
running:
choices: [ "yes", "no" ]
description:
- Whether this VDO volume is running. A VDO volume must
be activated in order to be started.
required: false
- Whether this VDO volume is running.
- A VDO volume must be activated in order to be started.
type: bool
device:
description:
- The full path of the device to use for VDO storage.
This is required if "state" is "present".
required: false
- This is required if "state" is "present".
type: str
logicalsize:
description:
- The logical size of the VDO volume (in megabytes, or
@ -89,24 +89,24 @@ options:
than or identical to the current size. If the specified
size is larger than the current size, a growlogical
operation will be performed.
required: false
type: str
deduplication:
choices: [ "enabled", "disabled" ]
description:
- Configures whether deduplication is enabled. The
default for a created volume is 'enabled'. Existing
volumes will maintain their previously configured
setting unless a different value is specified in the
playbook.
required: false
type: str
choices: [ disabled, enabled ]
compression:
choices: [ "enabled", "disabled" ]
description:
- Configures whether compression is enabled. The default
for a created volume is 'enabled'. Existing volumes
will maintain their previously configured setting unless
a different value is specified in the playbook.
required: false
type: str
choices: [ disabled, enabled ]
blockmapcachesize:
description:
- The amount of memory allocated for caching block map
@ -120,9 +120,8 @@ options:
volumes will maintain their previously configured
setting unless a different value is specified in the
playbook.
required: false
type: str
readcache:
choices: [ "enabled", "disabled" ]
description:
- Enables or disables the read cache. The default is
'disabled'. Choosing 'enabled' enables a read cache
@ -132,7 +131,8 @@ options:
volumes will maintain their previously configured
setting unless a different value is specified in the
playbook.
required: false
type: str
choices: [ disabled, enabled ]
readcachesize:
description:
- Specifies the extra VDO device read cache size in
@ -146,9 +146,8 @@ options:
Existing volumes will maintain their previously
configured setting unless a different value is specified
in the playbook.
required: false
type: str
emulate512:
type: bool
description:
- Enables 512-byte emulation mode, allowing drivers or
filesystems to access the VDO volume at 512-byte
@ -158,16 +157,15 @@ options:
a device. This option is only available when creating
a new volume, and cannot be changed for an existing
volume.
required: false
growphysical:
type: bool
growphysical:
description:
- Specifies whether to attempt to execute a growphysical
operation, if there is enough unused space on the
device. A growphysical operation will be executed if
there is at least 64 GB of free space, relative to the
previous physical size of the affected VDO volume.
required: false
type: bool
default: false
slabsize:
description:
@ -179,9 +177,8 @@ options:
The maximum, 32G, supports a physical size of up to 256T.
This option is only available when creating a new
volume, and cannot be changed for an existing volume.
required: false
type: str
writepolicy:
choices: [ "auto", "sync", "async" ]
description:
- Specifies the write policy of the VDO volume. The
'sync' mode acknowledges writes only after data is on
@ -195,7 +192,8 @@ options:
Existing volumes will maintain their previously
configured setting unless a different value is
specified in the playbook.
required: false
type: str
choices: [ async, auto, sync ]
indexmem:
description:
- Specifies the amount of index memory in gigabytes. The
@ -203,7 +201,7 @@ options:
and 0.75 can be used, as can any positive integer.
This option is only available when creating a new
volume, and cannot be changed for an existing volume.
required: false
type: str
indexmode:
description:
- Specifies the index mode of the Albireo index. The
@ -215,7 +213,7 @@ options:
100 GB of index data on persistent storage. This option
is only available when creating a new volume, and cannot
be changed for an existing volume.
required: false
type: str
ackthreads:
description:
- Specifies the number of threads to use for
@ -225,7 +223,7 @@ options:
1. Existing volumes will maintain their previously
configured setting unless a different value is specified
in the playbook.
required: false
type: str
biothreads:
description:
- Specifies the number of threads to use for submitting I/O
@ -235,7 +233,7 @@ options:
Existing volumes will maintain their previously
configured setting unless a different value is specified
in the playbook.
required: false
type: str
cputhreads:
description:
- Specifies the number of threads to use for CPU-intensive
@ -245,7 +243,7 @@ options:
Existing volumes will maintain their previously
configured setting unless a different value is specified
in the playbook.
required: false
type: str
logicalthreads:
description:
- Specifies the number of threads across which to
@ -255,7 +253,7 @@ options:
The default is 1. Existing volumes will maintain their
previously configured setting unless a different value
is specified in the playbook.
required: false
type: str
physicalthreads:
description:
- Specifies the number of threads across which to
@ -267,7 +265,7 @@ options:
is 1. Existing volumes will maintain their previously
configured setting unless a different value is specified
in the playbook.
required: false
type: str
notes:
- In general, the default thread configuration should be used.
requirements:
@ -276,8 +274,7 @@ requirements:
- vdo
'''
EXAMPLES = '''
# Create a VDO volume
EXAMPLES = r'''
- name: Create 2 TB VDO volume vdo1 on device /dev/md0
vdo:
name: vdo1
@ -285,14 +282,13 @@ EXAMPLES = '''
device: /dev/md0
logicalsize: 2T
# Remove a VDO volume
- name: Remove VDO volume vdo1
vdo:
name: vdo1
state: absent
'''
RETURN = '''# '''
RETURN = r'''# '''
from ansible.module_utils.basic import AnsibleModule
import re
@ -453,35 +449,35 @@ def run_module():
# Creation param defaults are determined by the creation section.
module_args = dict(
name=dict(required=True),
state=dict(choices=['absent', 'present'], default='present'),
activated=dict(choices=['yes', 'no']),
running=dict(choices=['yes', 'no']),
name=dict(type='str', required=True),
state=dict(type='str', default='present', choices=['absent', 'present']),
activated=dict(type='bool'),
running=dict(type='bool'),
growphysical=dict(type='bool', default=False),
device=dict(),
logicalsize=dict(),
deduplication=dict(choices=['enabled', 'disabled']),
compression=dict(choices=['enabled', 'disabled']),
device=dict(type='str'),
logicalsize=dict(type='str'),
deduplication=dict(type='str', choices=['disabled', 'enabled']),
compression=dict(type='str', choices=['disabled', 'enabled']),
blockmapcachesize=dict(type='str'),
readcache=dict(choices=['enabled', 'disabled']),
readcachesize=dict(),
readcache=dict(type='str', choices=['disabled', 'enabled']),
readcachesize=dict(type='str'),
emulate512=dict(type='bool', default=False),
slabsize=dict(),
writepolicy=dict(choices=['auto', 'sync', 'async']),
indexmem=dict(),
indexmode=dict(choices=['dense', 'sparse']),
ackthreads=dict(),
biothreads=dict(),
cputhreads=dict(),
logicalthreads=dict(),
physicalthreads=dict()
slabsize=dict(type='str'),
writepolicy=dict(type='str', choices=['async', 'auto', 'sync']),
indexmem=dict(type='str'),
indexmode=dict(type='str', choices=['dense', 'sparse']),
ackthreads=dict(type='str'),
biothreads=dict(type='str'),
cputhreads=dict(type='str'),
logicalthreads=dict(type='str'),
physicalthreads=dict(type='str')
)
# Seed the result dictionary in the object. There will be an
# 'invocation' dictionary added with 'module_args' (arguments
# given).
result = dict(
changed=False
changed=False,
)
# the AnsibleModule object will be our abstraction working with Ansible
@ -490,7 +486,7 @@ def run_module():
# supports check mode
module = AnsibleModule(
argument_spec=module_args,
supports_check_mode=False
supports_check_mode=False,
)
if not HAS_YAML: