mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 11:51:26 -07:00
PEP8 fixes: Ansible system module and playbook base.py (#32322)
* Ansible files module sanity pep8 fixes * Ansible system module and playbook base.py * Undo empty lines not required by sanity checks * Undo empty lines not required by sanity checks * Undo empty lines not required by sanity checks * Undo empty lines not required by sanity checks * Undo empty lines not required by sanity checks * Undo empty lines not required by sanity checks * Undo empty lines not required by sanity checks * Undo empty lines not required by sanity checks * Undo empty lines not required by sanity checks * Undo empty lines not required by sanity checks * Undo empty lines not required by sanity checks * Various changes * Various changes * Various changes * Various changes * Undo blank lines not required by sanity checks * Various changes * Various changes * Various changes * Various changes * Various changes * Undo blank line changes not required by sanity checks * Various changes * Various changes * Various changes * Various changes * Various changes * Missing piece after merge * Blank lines * Blank line * Line too long * Fix typo * Unnecessary quotes * Fix example error
This commit is contained in:
parent
a5da2e44a1
commit
a2d34e914e
31 changed files with 878 additions and 1004 deletions
|
@ -181,15 +181,15 @@ def check_file_attrs(module, changed, message, diff):
|
|||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
path=dict(required=True, aliases=['dest', 'destfile', 'name'], type='path'),
|
||||
state=dict(default='present', choices=['absent', 'present']),
|
||||
marker=dict(default='# {mark} ANSIBLE MANAGED BLOCK', type='str'),
|
||||
block=dict(default='', type='str', aliases=['content']),
|
||||
insertafter=dict(default=None),
|
||||
insertbefore=dict(default=None),
|
||||
create=dict(default=False, type='bool'),
|
||||
backup=dict(default=False, type='bool'),
|
||||
validate=dict(default=None, type='str'),
|
||||
path=dict(type='path', required=True, aliases=['dest', 'destfile', 'name']),
|
||||
state=dict(type='str', default='present', choices=['absent', 'present']),
|
||||
marker=dict(type='str', default='# {mark} ANSIBLE MANAGED BLOCK'),
|
||||
block=dict(type='str', default='', aliases=['content']),
|
||||
insertafter=dict(type='str'),
|
||||
insertbefore=dict(type='str'),
|
||||
create=dict(type='bool', default=False),
|
||||
backup=dict(type='bool', default=False),
|
||||
validate=dict(type='str'),
|
||||
),
|
||||
mutually_exclusive=[['insertbefore', 'insertafter']],
|
||||
add_file_common_args=True,
|
||||
|
|
|
@ -331,8 +331,8 @@ def is_rsh_needed(source, dest):
|
|||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
src=dict(required=True),
|
||||
dest=dict(required=True),
|
||||
src=dict(type='str', required=True),
|
||||
dest=dict(type='str', required=True),
|
||||
dest_port=dict(type='int'),
|
||||
delete=dict(type='bool', default=False),
|
||||
private_key=dict(type='path'),
|
||||
|
|
|
@ -1,25 +1,22 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2014, Brian Coca <briancoca+ansible@gmail.com>
|
||||
# Copyright: (c) 2014, Brian Coca <briancoca+ansible@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
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['stableinterface'],
|
||||
'supported_by': 'core'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: debconf
|
||||
short_description: Configure a .deb package
|
||||
description:
|
||||
- Configure a .deb package using debconf-set-selections. Or just query
|
||||
existing selections.
|
||||
- Configure a .deb package using debconf-set-selections. Or just query existing selections.
|
||||
version_added: "1.6"
|
||||
notes:
|
||||
- This module requires the command line debconf tools.
|
||||
|
@ -33,60 +30,54 @@ options:
|
|||
description:
|
||||
- Name of package to configure.
|
||||
required: true
|
||||
default: null
|
||||
aliases: ['pkg']
|
||||
aliases: [ pkg ]
|
||||
question:
|
||||
description:
|
||||
- A debconf configuration setting
|
||||
required: false
|
||||
default: null
|
||||
aliases: ['setting', 'selection']
|
||||
- A debconf configuration setting.
|
||||
aliases: [ selection, setting ]
|
||||
vtype:
|
||||
description:
|
||||
- The type of the value supplied.
|
||||
- C(seen) was added in 2.2.
|
||||
required: false
|
||||
default: null
|
||||
choices: [string, password, boolean, select, multiselect, note, error, title, text, seen]
|
||||
choices: [ boolean, error, multiselect, note, password, seen, select, string, text, title, text ]
|
||||
value:
|
||||
description:
|
||||
- Value to set the configuration to
|
||||
required: false
|
||||
default: null
|
||||
aliases: ['answer']
|
||||
- Value to set the configuration to.
|
||||
aliases: [ answer ]
|
||||
unseen:
|
||||
description:
|
||||
- Do not set 'seen' flag when pre-seeding
|
||||
required: false
|
||||
- Do not set 'seen' flag when pre-seeding.
|
||||
type: bool
|
||||
default: False
|
||||
author: "Brian Coca (@bcoca)"
|
||||
author:
|
||||
- Brian Coca (@bcoca)
|
||||
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Set default locale to fr_FR.UTF-8
|
||||
- debconf:
|
||||
- name: Set default locale to fr_FR.UTF-8
|
||||
debconf:
|
||||
name: locales
|
||||
question: locales/default_environment_locale
|
||||
value: fr_FR.UTF-8
|
||||
vtype: select
|
||||
|
||||
# set to generate locales:
|
||||
- debconf:
|
||||
- name: set to generate locales
|
||||
debconf:
|
||||
name: locales
|
||||
question: locales/locales_to_be_generated
|
||||
value: en_US.UTF-8 UTF-8, fr_FR.UTF-8 UTF-8
|
||||
vtype: multiselect
|
||||
|
||||
# Accept oracle license
|
||||
- debconf:
|
||||
- name: Accept oracle license
|
||||
debconf:
|
||||
name: oracle-java7-installer
|
||||
question: shared/accepted-oracle-license-v1-1
|
||||
value: true
|
||||
vtype: select
|
||||
|
||||
# Specifying package you can register/return the list of questions and current values
|
||||
- debconf:
|
||||
- name: Specifying package you can register/return the list of questions and current values
|
||||
debconf:
|
||||
name: tzdata
|
||||
'''
|
||||
|
||||
|
@ -110,7 +101,6 @@ def get_selections(module, pkg):
|
|||
|
||||
|
||||
def set_selection(module, pkg, question, vtype, value, unseen):
|
||||
|
||||
setsel = module.get_bin_path('debconf-set-selections', True)
|
||||
cmd = [setsel]
|
||||
if unseen:
|
||||
|
@ -125,16 +115,15 @@ def set_selection(module, pkg, question, vtype, value, unseen):
|
|||
|
||||
return module.run_command(cmd, data=data)
|
||||
|
||||
def main():
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
name=dict(required=True, aliases=['pkg'], type='str'),
|
||||
question=dict(required=False, aliases=['setting', 'selection'], type='str'),
|
||||
vtype=dict(required=False, type='str', choices=['string', 'password', 'boolean', 'select', 'multiselect', 'note', 'error', 'title',
|
||||
'text', 'seen']),
|
||||
value=dict(required=False, type='str', aliases=['answer']),
|
||||
unseen=dict(required=False, type='bool'),
|
||||
name=dict(type='str', required=True, aliases=['pkg']),
|
||||
question=dict(type='str', aliases=['selection', 'setting']),
|
||||
vtype=dict(type='str', choices=['boolean', 'error', 'multiselect', 'note', 'password', 'seen', 'select', 'string', 'text', 'title']),
|
||||
value=dict(type='str', aliases=['answer']),
|
||||
unseen=dict(type='bool'),
|
||||
),
|
||||
required_together=(['question', 'vtype', 'value'],),
|
||||
supports_check_mode=True,
|
||||
|
@ -156,7 +145,7 @@ def main():
|
|||
if vtype is None or value is None:
|
||||
module.fail_json(msg="when supplying a question you must supply a valid vtype and value")
|
||||
|
||||
if not question in prev or prev[question] != value:
|
||||
if question not in prev or prev[question] != value:
|
||||
changed = True
|
||||
|
||||
if changed:
|
||||
|
|
|
@ -1,18 +1,16 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>
|
||||
# Copyright: (c) 2012, Michael DeHaan <michael.dehaan@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
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: facter
|
||||
|
@ -22,12 +20,12 @@ description:
|
|||
(U(https://github.com/puppetlabs/facter)) on the remote system, returning
|
||||
JSON data that can be useful for inventory purposes.
|
||||
version_added: "0.2"
|
||||
options: {}
|
||||
notes: []
|
||||
requirements: [ "facter", "ruby-json" ]
|
||||
requirements:
|
||||
- facter
|
||||
- ruby-json
|
||||
author:
|
||||
- "Ansible Core Team"
|
||||
- "Michael DeHaan"
|
||||
- Ansible Core Team
|
||||
- Michael DeHaan
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
|
|
|
@ -1,21 +1,20 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2013, Alexander Bulimov <lazywolf0@gmail.com>
|
||||
# Copyright: (c) 2013, Alexander Bulimov <lazywolf0@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
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
author: "Alexander Bulimov (@abulimov)"
|
||||
author:
|
||||
- Alexander Bulimov (@abulimov)
|
||||
module: filesystem
|
||||
short_description: Makes file system on block device
|
||||
description:
|
||||
|
@ -23,48 +22,48 @@ description:
|
|||
version_added: "1.2"
|
||||
options:
|
||||
fstype:
|
||||
choices: [ "ext4", "ext4dev", "ext3", "ext2", "xfs", "btrfs", "reiserfs", "lvm"]
|
||||
choices: [ btrfs, ext2, ext3, ext4, ext4dev, lvm, reiserfs, xfs ]
|
||||
description:
|
||||
- File System type to be created.
|
||||
- reiserfs support was added in 2.2.
|
||||
- lvm support was added in 2.5.
|
||||
required: true
|
||||
required: yes
|
||||
dev:
|
||||
description:
|
||||
- Target block device.
|
||||
required: true
|
||||
required: yes
|
||||
force:
|
||||
choices: [ "yes", "no" ]
|
||||
default: "no"
|
||||
description:
|
||||
- If yes, allows to create new filesystem on devices that already has filesystem.
|
||||
required: false
|
||||
- If C(yes), allows to create new filesystem on devices that already has filesystem.
|
||||
type: bool
|
||||
default: 'no'
|
||||
resizefs:
|
||||
choices: [ "yes", "no" ]
|
||||
default: "no"
|
||||
description:
|
||||
- If yes, if the block device and filessytem size differ, grow the filesystem into the space. Note, XFS Will only grow if mounted.
|
||||
required: false
|
||||
- If C(yes), if the block device and filessytem size differ, grow the filesystem into the space.
|
||||
- Note, XFS Will only grow if mounted.
|
||||
type: bool
|
||||
default: 'no'
|
||||
version_added: "2.0"
|
||||
opts:
|
||||
description:
|
||||
- List of options to be passed to mkfs command.
|
||||
notes:
|
||||
- uses mkfs command
|
||||
- Uses mkfs command.
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Create a ext2 filesystem on /dev/sdb1.
|
||||
- filesystem:
|
||||
- name: Create a ext2 filesystem on /dev/sdb1
|
||||
filesystem:
|
||||
fstype: ext2
|
||||
dev: /dev/sdb1
|
||||
|
||||
# Create a ext4 filesystem on /dev/sdb1 and check disk blocks.
|
||||
- filesystem:
|
||||
- name: Create a ext4 filesystem on /dev/sdb1 and check disk blocks
|
||||
filesystem:
|
||||
fstype: ext4
|
||||
dev: /dev/sdb1
|
||||
opts: -cc
|
||||
'''
|
||||
|
||||
import os
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
@ -191,17 +190,16 @@ def main():
|
|||
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
fstype=dict(required=True, aliases=['type'],
|
||||
fstype=dict(type='str', required=True, aliases=['type'],
|
||||
choices=fs_cmd_map.keys() + friendly_names.keys()),
|
||||
dev=dict(required=True, aliases=['device']),
|
||||
opts=dict(),
|
||||
force=dict(type='bool', default='no'),
|
||||
resizefs=dict(type='bool', default='no'),
|
||||
dev=dict(type='str', required=True, aliases=['device']),
|
||||
opts=dict(type='str'),
|
||||
force=dict(type='bool', default=False),
|
||||
resizefs=dict(type='bool', default=False),
|
||||
),
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
|
||||
dev = module.params['dev']
|
||||
fstype = module.params['fstype']
|
||||
opts = module.params['opts']
|
||||
|
@ -242,7 +240,6 @@ def main():
|
|||
else:
|
||||
fs_smaller = False
|
||||
|
||||
|
||||
if module.check_mode and fs_smaller:
|
||||
module.exit_json(changed=True, msg="Resizing filesystem %s on device %s" % (fstype, dev))
|
||||
elif module.check_mode and not fs_smaller:
|
||||
|
@ -262,7 +259,7 @@ def main():
|
|||
elif fs and not force:
|
||||
module.fail_json(msg="'%s' is already used as %s, use force=yes to overwrite" % (dev, fs), rc=rc, err=err)
|
||||
|
||||
### create fs
|
||||
# create fs
|
||||
|
||||
if module.check_mode:
|
||||
changed = True
|
||||
|
|
|
@ -1,23 +1,21 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# (c) 2016, Kenneth D. Evensen <kevensen@redhat.com>
|
||||
# (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
|
||||
#
|
||||
|
||||
# Copyright: (c) 2016, Kenneth D. Evensen <kevensen@redhat.com>
|
||||
# Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.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
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = """
|
||||
module: gconftool2
|
||||
author:
|
||||
- "Kenneth D. Evensen (@kevensen)"
|
||||
- Kenneth D. Evensen (@kevensen)
|
||||
short_description: Edit GNOME Configurations
|
||||
description:
|
||||
- This module allows for the manipulation of GNOME 2 Configuration via
|
||||
|
@ -25,47 +23,35 @@ description:
|
|||
version_added: "2.3"
|
||||
options:
|
||||
key:
|
||||
required: true
|
||||
description:
|
||||
- A GConf preference key is an element in the GConf repository
|
||||
that corresponds to an application preference. See man gconftool-2(1)
|
||||
required: yes
|
||||
value:
|
||||
required: false
|
||||
description:
|
||||
- Preference keys typically have simple values such as strings,
|
||||
integers, or lists of strings and integers. This is ignored if the state
|
||||
is "get". See man gconftool-2(1)
|
||||
value_type:
|
||||
required: false
|
||||
choices:
|
||||
- int
|
||||
- bool
|
||||
- float
|
||||
- string
|
||||
description:
|
||||
- The type of value being set. This is ignored if the state is "get".
|
||||
choices: [ bool, float, int, string ]
|
||||
state:
|
||||
required: true
|
||||
choices:
|
||||
- get
|
||||
- present
|
||||
- absent
|
||||
description:
|
||||
- The action to take upon the key/value.
|
||||
required: yes
|
||||
choices: [ absent, get, present ]
|
||||
config_source:
|
||||
required: false
|
||||
description:
|
||||
- Specify a configuration source to use rather than the default path.
|
||||
See man gconftool-2(1)
|
||||
direct:
|
||||
required: false
|
||||
choices: [ "yes", "no" ]
|
||||
default: no
|
||||
description:
|
||||
- Access the config database directly, bypassing server. If direct is
|
||||
specified then the config_source must be specified as well.
|
||||
See man gconftool-2(1)
|
||||
|
||||
type: bool
|
||||
default: 'no'
|
||||
"""
|
||||
|
||||
EXAMPLES = """
|
||||
|
@ -81,12 +67,12 @@ RETURN = '''
|
|||
description: The key specified in the module parameters
|
||||
returned: success
|
||||
type: string
|
||||
sample: "/desktop/gnome/interface/font_name"
|
||||
sample: /desktop/gnome/interface/font_name
|
||||
value_type:
|
||||
description: The type of the value that was changed
|
||||
returned: success
|
||||
type: string
|
||||
sample: "string"
|
||||
sample: string
|
||||
value:
|
||||
description: The value of the preference key after executing the module
|
||||
returned: success
|
||||
|
@ -165,17 +151,12 @@ def main():
|
|||
# Setup the Ansible module
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
key=dict(required=True, default=None, type='str'),
|
||||
value_type=dict(required=False,
|
||||
choices=['int', 'bool', 'float', 'string'],
|
||||
type='str'),
|
||||
value=dict(required=False, default=None, type='str'),
|
||||
state=dict(required=True,
|
||||
default=None,
|
||||
choices=['present', 'get', 'absent'],
|
||||
type='str'),
|
||||
direct=dict(required=False, default=False, type='bool'),
|
||||
config_source=dict(required=False, default=None, type='str')
|
||||
key=dict(type='str', required=True),
|
||||
value_type=dict(type='str', choices=['bool', 'float', 'int', 'string']),
|
||||
value=dict(type='str'),
|
||||
state=dict(type='str', required=True, choices=['absent', 'get', 'present']),
|
||||
direct=dict(type='bool', default=False),
|
||||
config_source=dict(type='str'),
|
||||
),
|
||||
supports_check_mode=True
|
||||
)
|
||||
|
@ -247,5 +228,6 @@ def main():
|
|||
|
||||
module.exit_json(changed=change, ansible_facts=facts)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -1,18 +1,16 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2014, Taneli Leppä <taneli@crasman.fi>
|
||||
# Copyright: (c) 2014, Taneli Leppä <taneli@crasman.fi>
|
||||
# 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
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = """
|
||||
module: gluster_volume
|
||||
short_description: Manage GlusterFS volumes
|
||||
|
@ -22,75 +20,76 @@ version_added: '1.9'
|
|||
options:
|
||||
name:
|
||||
description:
|
||||
- The volume name
|
||||
- The volume name.
|
||||
required: true
|
||||
state:
|
||||
description:
|
||||
- Use present/absent ensure if a volume exists or not.
|
||||
Use started/stopped to control its availability.
|
||||
required: true
|
||||
choices: ['present', 'absent', 'started', 'stopped']
|
||||
choices: ['absent', 'present', 'started', 'stopped']
|
||||
cluster:
|
||||
description:
|
||||
- List of hosts to use for probing and brick setup
|
||||
- List of hosts to use for probing and brick setup.
|
||||
host:
|
||||
description:
|
||||
- Override local hostname (for peer probing purposes)
|
||||
- Override local hostname (for peer probing purposes).
|
||||
replicas:
|
||||
description:
|
||||
- Replica count for volume
|
||||
- Replica count for volume.
|
||||
arbiter:
|
||||
description:
|
||||
- Arbiter count for volume
|
||||
- Arbiter count for volume.
|
||||
version_added: '2.3'
|
||||
stripes:
|
||||
description:
|
||||
- Stripe count for volume
|
||||
- Stripe count for volume.
|
||||
disperses:
|
||||
description:
|
||||
- Disperse count for volume
|
||||
- Disperse count for volume.
|
||||
version_added: '2.2'
|
||||
redundancies:
|
||||
description:
|
||||
- Redundancy count for volume
|
||||
- Redundancy count for volume.
|
||||
version_added: '2.2'
|
||||
transport:
|
||||
description:
|
||||
- Transport type for volume
|
||||
default: 'tcp'
|
||||
choices: ['tcp', 'rdma', 'tcp,rdma']
|
||||
- Transport type for volume.
|
||||
default: tcp
|
||||
choices: [ rdma, tcp, tcp,rdma ]
|
||||
bricks:
|
||||
description:
|
||||
- Brick paths on servers. Multiple brick paths can be separated by commas.
|
||||
aliases: ['brick']
|
||||
aliases: [ brick ]
|
||||
start_on_create:
|
||||
description:
|
||||
- Controls whether the volume is started after creation or not
|
||||
default: 'yes'
|
||||
- Controls whether the volume is started after creation or not.
|
||||
type: bool
|
||||
default: 'yes'
|
||||
rebalance:
|
||||
description:
|
||||
- Controls whether the cluster is rebalanced after changes
|
||||
default: 'no'
|
||||
- Controls whether the cluster is rebalanced after changes.
|
||||
type: bool
|
||||
default: 'no'
|
||||
directory:
|
||||
description:
|
||||
- Directory for limit-usage
|
||||
- Directory for limit-usage.
|
||||
options:
|
||||
description:
|
||||
- A dictionary/hash with options/settings for the volume
|
||||
- A dictionary/hash with options/settings for the volume.
|
||||
quota:
|
||||
description:
|
||||
- Quota value for limit-usage (be sure to use 10.0MB instead of 10MB, see quota list)
|
||||
- Quota value for limit-usage (be sure to use 10.0MB instead of 10MB, see quota list).
|
||||
force:
|
||||
description:
|
||||
- If brick is being created in the root partition, module will fail.
|
||||
Set force to true to override this behaviour.
|
||||
type: bool
|
||||
notes:
|
||||
- Requires cli tools for GlusterFS on servers
|
||||
- Will add new bricks, but not remove them
|
||||
author: Taneli Leppä (@rosmo)
|
||||
- Requires cli tools for GlusterFS on servers.
|
||||
- Will add new bricks, but not remove them.
|
||||
author:
|
||||
- Taneli Leppä (@rosmo)
|
||||
"""
|
||||
|
||||
EXAMPLES = """
|
||||
|
@ -153,7 +152,6 @@ import traceback
|
|||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
|
||||
glusterbin = ''
|
||||
|
||||
|
||||
|
@ -172,6 +170,7 @@ def run_gluster(gargs, **kwargs):
|
|||
to_native(e)), exception=traceback.format_exc())
|
||||
return out
|
||||
|
||||
|
||||
def run_gluster_nofail(gargs, **kwargs):
|
||||
global glusterbin
|
||||
global module
|
||||
|
@ -182,6 +181,7 @@ def run_gluster_nofail(gargs, **kwargs):
|
|||
return None
|
||||
return out
|
||||
|
||||
|
||||
def get_peers():
|
||||
out = run_gluster(['peer', 'status'])
|
||||
peers = {}
|
||||
|
@ -208,6 +208,7 @@ def get_peers():
|
|||
shortNames = False
|
||||
return peers
|
||||
|
||||
|
||||
def get_volumes():
|
||||
out = run_gluster(['volume', 'info'])
|
||||
|
||||
|
@ -227,17 +228,17 @@ def get_volumes():
|
|||
if key.lower() == 'transport-type':
|
||||
volume['transport'] = value
|
||||
if value.lower().endswith(' (arbiter)'):
|
||||
if not 'arbiters' in volume:
|
||||
if 'arbiters' not in volume:
|
||||
volume['arbiters'] = []
|
||||
value = value[:-10]
|
||||
volume['arbiters'].append(value)
|
||||
if key.lower() != 'bricks' and key.lower()[:5] == 'brick':
|
||||
if not 'bricks' in volume:
|
||||
if 'bricks' not in volume:
|
||||
volume['bricks'] = []
|
||||
volume['bricks'].append(value)
|
||||
# Volume options
|
||||
if '.' in key:
|
||||
if not 'options' in volume:
|
||||
if 'options' not in volume:
|
||||
volume['options'] = {}
|
||||
volume['options'][key] = value
|
||||
if key == 'features.quota' and value == 'on':
|
||||
|
@ -249,6 +250,7 @@ def get_volumes():
|
|||
volume = {}
|
||||
return volumes
|
||||
|
||||
|
||||
def get_quotas(name, nofail):
|
||||
quotas = {}
|
||||
if nofail:
|
||||
|
@ -263,6 +265,7 @@ def get_quotas(name, nofail):
|
|||
quotas[q[0]] = q[1]
|
||||
return quotas
|
||||
|
||||
|
||||
def wait_for_peer(host):
|
||||
for x in range(0, 4):
|
||||
peers = get_peers()
|
||||
|
@ -271,18 +274,21 @@ def wait_for_peer(host):
|
|||
time.sleep(1)
|
||||
return False
|
||||
|
||||
|
||||
def probe(host, myhostname):
|
||||
global module
|
||||
out = run_gluster(['peer', 'probe', host])
|
||||
if out.find('localhost') == -1 and not wait_for_peer(host):
|
||||
module.fail_json(msg='failed to probe peer %s on %s' % (host, myhostname))
|
||||
|
||||
|
||||
def probe_all_peers(hosts, peers, myhostname):
|
||||
for host in hosts:
|
||||
host = host.strip() # Clean up any extra space for exact comparison
|
||||
if host not in peers:
|
||||
probe(host, myhostname)
|
||||
|
||||
|
||||
def create_volume(name, stripe, replica, arbiter, disperse, redundancy, transport, hosts, bricks, force):
|
||||
args = ['volume', 'create']
|
||||
args.append(name)
|
||||
|
@ -310,15 +316,19 @@ def create_volume(name, stripe, replica, arbiter, disperse, redundancy, transpor
|
|||
args.append('force')
|
||||
run_gluster(args)
|
||||
|
||||
|
||||
def start_volume(name):
|
||||
run_gluster(['volume', 'start', name])
|
||||
|
||||
|
||||
def stop_volume(name):
|
||||
run_gluster(['volume', 'stop', name])
|
||||
|
||||
|
||||
def set_volume_option(name, option, parameter):
|
||||
run_gluster(['volume', 'set', name, option, parameter])
|
||||
|
||||
|
||||
def add_bricks(name, new_bricks, stripe, replica, force):
|
||||
args = ['volume', 'add-brick', name]
|
||||
if stripe:
|
||||
|
@ -332,40 +342,43 @@ def add_bricks(name, new_bricks, stripe, replica, force):
|
|||
args.append('force')
|
||||
run_gluster(args)
|
||||
|
||||
|
||||
def do_rebalance(name):
|
||||
run_gluster(['volume', 'rebalance', name, 'start'])
|
||||
|
||||
|
||||
def enable_quota(name):
|
||||
run_gluster(['volume', 'quota', name, 'enable'])
|
||||
|
||||
|
||||
def set_quota(name, directory, value):
|
||||
run_gluster(['volume', 'quota', name, 'limit-usage', directory, value])
|
||||
|
||||
|
||||
def main():
|
||||
### MAIN ###
|
||||
# MAIN
|
||||
|
||||
global module
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
name=dict(required=True, aliases=['volume']),
|
||||
state=dict(required=True, choices=['present', 'absent', 'started', 'stopped']),
|
||||
cluster=dict(default=None, type='list'),
|
||||
host=dict(default=None),
|
||||
stripes=dict(default=None, type='int'),
|
||||
replicas=dict(default=None, type='int'),
|
||||
arbiters=dict(default=None, type='int'),
|
||||
disperses=dict(default=None, type='int'),
|
||||
redundancies=dict(default=None, type='int'),
|
||||
transport=dict(default='tcp', choices=['tcp', 'rdma', 'tcp,rdma']),
|
||||
bricks=dict(default=None, aliases=['brick']),
|
||||
start_on_create=dict(default=True, type='bool'),
|
||||
rebalance=dict(default=False, type='bool'),
|
||||
options=dict(default={}, type='dict'),
|
||||
quota=dict(),
|
||||
directory=dict(default=None),
|
||||
force=dict(default=False, type='bool'),
|
||||
)
|
||||
name=dict(type='str', required=True, aliases=['volume']),
|
||||
state=dict(type='str', required=True, choices=['absent', 'started', 'stopped', 'present']),
|
||||
cluster=dict(type='list'),
|
||||
host=dict(type='str'),
|
||||
stripes=dict(type='int'),
|
||||
replicas=dict(type='int'),
|
||||
arbiters=dict(type='int'),
|
||||
disperses=dict(type='int'),
|
||||
redundancies=dict(type='int'),
|
||||
transport=dict(type='str', default='tcp', choices=['tcp', 'rdma', 'tcp,rdma']),
|
||||
bricks=dict(type='str', aliases=['brick']),
|
||||
start_on_create=dict(type='bool', default=True),
|
||||
rebalance=dict(type='bool', default=False),
|
||||
options=dict(type='dict', default={}),
|
||||
quota=dict(type='str'),
|
||||
directory=dict(type='str'),
|
||||
force=dict(type='bool', default=False),
|
||||
),
|
||||
)
|
||||
|
||||
global glusterbin
|
||||
|
@ -408,7 +421,6 @@ def main():
|
|||
quota = module.params['quota']
|
||||
directory = module.params['directory']
|
||||
|
||||
|
||||
# get current state info
|
||||
peers = get_peers()
|
||||
volumes = get_volumes()
|
||||
|
|
|
@ -1,56 +1,55 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2012, Stephen Fromm <sfromm@gmail.com>
|
||||
# Copyright: (c) 2012, Stephen Fromm <sfromm@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
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['stableinterface'],
|
||||
'supported_by': 'core'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: group
|
||||
author: "Stephen Fromm (@sfromm)"
|
||||
author:
|
||||
- Stephen Fromm (@sfromm)
|
||||
version_added: "0.0.2"
|
||||
short_description: Add or remove groups
|
||||
requirements: [ groupadd, groupdel, groupmod ]
|
||||
requirements:
|
||||
- groupadd
|
||||
- groupdel
|
||||
- groupmod
|
||||
description:
|
||||
- Manage presence of groups on a host.
|
||||
- For Windows targets, use the M(win_group) module instead.
|
||||
options:
|
||||
name:
|
||||
required: true
|
||||
description:
|
||||
- Name of the group to manage.
|
||||
required: true
|
||||
gid:
|
||||
required: false
|
||||
description:
|
||||
- Optional I(GID) to set for the group.
|
||||
state:
|
||||
required: false
|
||||
default: "present"
|
||||
choices: [ present, absent ]
|
||||
description:
|
||||
- Whether the group should be present or not on the remote host.
|
||||
choices: [ absent, present ]
|
||||
default: present
|
||||
system:
|
||||
required: false
|
||||
default: "no"
|
||||
choices: [ "yes", "no" ]
|
||||
description:
|
||||
- If I(yes), indicates that the group created is a system group.
|
||||
type: bool
|
||||
default: 'no'
|
||||
notes:
|
||||
- For Windows targets, use the M(win_group) module instead.
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Example group command from Ansible Playbooks
|
||||
- group:
|
||||
- name: Ensure group "somegroup" exists
|
||||
group:
|
||||
name: somegroup
|
||||
state: present
|
||||
'''
|
||||
|
@ -136,6 +135,7 @@ class Group(object):
|
|||
return False
|
||||
return info
|
||||
|
||||
|
||||
# ===========================================
|
||||
|
||||
class SunOS(Group):
|
||||
|
@ -205,6 +205,7 @@ class AIX(Group):
|
|||
cmd.append(self.name)
|
||||
return self.execute_command(cmd)
|
||||
|
||||
|
||||
# ===========================================
|
||||
|
||||
class FreeBsdGroup(Group):
|
||||
|
@ -246,10 +247,9 @@ class FreeBsdGroup(Group):
|
|||
return self.execute_command(cmd)
|
||||
return (None, '', '')
|
||||
|
||||
|
||||
# ===========================================
|
||||
|
||||
|
||||
|
||||
class DarwinGroup(Group):
|
||||
"""
|
||||
This is a Mac OS X Darwin Group manipulation class.
|
||||
|
@ -318,6 +318,7 @@ class DarwinGroup(Group):
|
|||
except:
|
||||
return False
|
||||
|
||||
|
||||
class OpenBsdGroup(Group):
|
||||
"""
|
||||
This is a OpenBSD Group manipulation class.
|
||||
|
@ -357,6 +358,7 @@ class OpenBsdGroup(Group):
|
|||
cmd.append(self.name)
|
||||
return self.execute_command(cmd)
|
||||
|
||||
|
||||
# ===========================================
|
||||
|
||||
class NetBsdGroup(Group):
|
||||
|
@ -398,17 +400,18 @@ class NetBsdGroup(Group):
|
|||
cmd.append(self.name)
|
||||
return self.execute_command(cmd)
|
||||
|
||||
|
||||
# ===========================================
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
state=dict(default='present', choices=['present', 'absent'], type='str'),
|
||||
name=dict(required=True, type='str'),
|
||||
gid=dict(default=None, type='str'),
|
||||
system=dict(default=False, type='bool'),
|
||||
state=dict(type='str', default='present', choices=['absent', 'present']),
|
||||
name=dict(type='str', required=True),
|
||||
gid=dict(type='str'),
|
||||
system=dict(type='bool', default=False),
|
||||
),
|
||||
supports_check_mode=True
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
group = Group(module)
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
#!/usr/bin/python
|
||||
#
|
||||
# (c) 2013, RSD Services S.A
|
||||
# Copyright: (c) 2013, RSD Services S.A
|
||||
# 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
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: java_cert
|
||||
|
@ -65,10 +63,10 @@ options:
|
|||
state:
|
||||
description:
|
||||
- Defines action which can be either certificate import or removal.
|
||||
choices: [ 'present', 'absent' ]
|
||||
choices: [ absent, present ]
|
||||
default: present
|
||||
|
||||
author: Adam Hamsik @haad
|
||||
author:
|
||||
- Adam Hamsik (@haad)
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
|
@ -131,6 +129,7 @@ import os
|
|||
# import module snippets
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
|
||||
def check_cert_present(module, executable, keystore_path, keystore_pass, alias):
|
||||
''' Check if certificate with alias is present in keystore
|
||||
located at keystore_path '''
|
||||
|
@ -142,6 +141,7 @@ def check_cert_present(module, executable, keystore_path, keystore_pass, alias):
|
|||
return True
|
||||
return False
|
||||
|
||||
|
||||
def import_cert_url(module, executable, url, port, keystore_path, keystore_pass, alias):
|
||||
''' Import certificate from URL into keystore located at keystore_path '''
|
||||
import re
|
||||
|
@ -189,6 +189,7 @@ def import_cert_url(module, executable, url, port, keystore_path, keystore_pass,
|
|||
return module.fail_json(msg=import_out, rc=import_rc, cmd=import_cmd,
|
||||
error=import_err)
|
||||
|
||||
|
||||
def import_cert_path(module, executable, path, keystore_path, keystore_pass, alias):
|
||||
''' Import certificate from path into keystore located on
|
||||
keystore_path as alias '''
|
||||
|
@ -213,6 +214,7 @@ def import_cert_path(module, executable, path, keystore_path, keystore_pass, ali
|
|||
else:
|
||||
return module.fail_json(msg=import_out, rc=import_rc, cmd=import_cmd)
|
||||
|
||||
|
||||
def import_pkcs12_path(module, executable, path, keystore_path, keystore_pass, pkcs12_pass, pkcs12_alias, alias):
|
||||
''' Import pkcs12 from path into keystore located on
|
||||
keystore_path as alias '''
|
||||
|
@ -254,23 +256,26 @@ def delete_cert(module, executable, keystore_path, keystore_pass, alias):
|
|||
rc=del_rc, cmd=del_cmd, stdout=del_out,
|
||||
error=del_err, diff=diff)
|
||||
|
||||
|
||||
def test_keytool(module, executable):
|
||||
''' Test if keytool is actuall executable or not '''
|
||||
test_cmd = "%s" % (executable)
|
||||
|
||||
module.run_command(test_cmd, check_rc=True)
|
||||
|
||||
|
||||
def test_keystore(module, keystore_path):
|
||||
''' Check if we can access keystore as file or not '''
|
||||
if keystore_path is None:
|
||||
keystore_path = ''
|
||||
|
||||
if not os.path.exists(keystore_path) and not os.path.isfile(keystore_path):
|
||||
## Keystore doesn't exist we want to create it
|
||||
# Keystore doesn't exist we want to create it
|
||||
return module.fail_json(changed=False,
|
||||
msg="Module require existing keystore at keystore_path '%s'"
|
||||
% (keystore_path))
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = dict(
|
||||
cert_url=dict(type='str'),
|
||||
|
@ -279,13 +284,12 @@ def main():
|
|||
pkcs12_password=dict(type='str', no_log=True),
|
||||
pkcs12_alias=dict(type='str'),
|
||||
cert_alias=dict(type='str'),
|
||||
cert_port=dict(default='443', type='int'),
|
||||
cert_port=dict(type='int', default='443'),
|
||||
keystore_path=dict(type='path'),
|
||||
keystore_pass=dict(required=True, type='str', no_log=True),
|
||||
keystore_create=dict(default=False, type='bool'),
|
||||
executable=dict(default='keytool', type='str'),
|
||||
state=dict(default='present',
|
||||
choices=['present', 'absent'])
|
||||
keystore_pass=dict(type='str', required=True, no_log=True),
|
||||
keystore_create=dict(type='bool', default=False),
|
||||
executable=dict(type='str', default='keytool'),
|
||||
state=dict(type='str', default='present', choices=['absent', 'present']),
|
||||
)
|
||||
|
||||
module = AnsibleModule(
|
||||
|
@ -347,5 +351,6 @@ def main():
|
|||
|
||||
module.exit_json(changed=False)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
@ -1,49 +1,44 @@
|
|||
#!/usr/bin/python
|
||||
# encoding: utf-8 -*-
|
||||
|
||||
# (c) 2013, Matthias Vogelgesang <matthias.vogelgesang@gmail.com>
|
||||
# Copyright: (c) 2013, Matthias Vogelgesang <matthias.vogelgesang@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
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: kernel_blacklist
|
||||
author: "Matthias Vogelgesang (@matze)"
|
||||
version_added: 1.4
|
||||
author:
|
||||
- Matthias Vogelgesang (@matze)
|
||||
version_added: '1.4'
|
||||
short_description: Blacklist kernel modules
|
||||
description:
|
||||
- Add or remove kernel modules from blacklist.
|
||||
options:
|
||||
name:
|
||||
required: true
|
||||
description:
|
||||
- Name of kernel module to black- or whitelist.
|
||||
required: true
|
||||
state:
|
||||
required: false
|
||||
default: "present"
|
||||
choices: [ present, absent ]
|
||||
description:
|
||||
- Whether the module should be present in the blacklist or absent.
|
||||
choices: [ absent, present ]
|
||||
default: present
|
||||
blacklist_file:
|
||||
required: false
|
||||
description:
|
||||
- If specified, use this blacklist file instead of
|
||||
C(/etc/modprobe.d/blacklist-ansible.conf).
|
||||
default: null
|
||||
requirements: []
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Blacklist the nouveau driver module
|
||||
- kernel_blacklist:
|
||||
- name: Blacklist the nouveau driver module
|
||||
kernel_blacklist:
|
||||
name: nouveau
|
||||
state: present
|
||||
'''
|
||||
|
@ -118,13 +113,13 @@ class Blacklist(object):
|
|||
|
||||
f.close()
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
name=dict(required=True),
|
||||
state=dict(required=False, choices=['present', 'absent'],
|
||||
default='present'),
|
||||
blacklist_file=dict(required=False, default=None)
|
||||
name=dict(type='str', required=True),
|
||||
state=dict(type='str', default='present', choices=['absent', 'present']),
|
||||
blacklist_file=dict(type='str')
|
||||
),
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
|
|
@ -1,51 +1,46 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
|
||||
# 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
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: locale_gen
|
||||
short_description: Creates or removes locales.
|
||||
short_description: Creates or removes locales
|
||||
description:
|
||||
- Manages locales by editing /etc/locale.gen and invoking locale-gen.
|
||||
version_added: "1.6"
|
||||
author: "Augustus Kling (@AugustusKling)"
|
||||
author:
|
||||
- Augustus Kling (@AugustusKling)
|
||||
options:
|
||||
name:
|
||||
description:
|
||||
- Name and encoding of the locale, such as "en_GB.UTF-8".
|
||||
required: true
|
||||
default: null
|
||||
aliases: []
|
||||
state:
|
||||
description:
|
||||
- Whether the locale shall be present.
|
||||
required: false
|
||||
choices: ["present", "absent"]
|
||||
default: "present"
|
||||
choices: [ absent, present ]
|
||||
default: present
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Ensure a locale exists.
|
||||
- locale_gen:
|
||||
- name: Ensure a locale exists
|
||||
locale_gen:
|
||||
name: de_CH.UTF-8
|
||||
state: present
|
||||
'''
|
||||
|
||||
import os
|
||||
import os.path
|
||||
from subprocess import Popen, PIPE, call
|
||||
import re
|
||||
from subprocess import Popen, PIPE, call
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.pycompat24 import get_exception
|
||||
|
@ -64,6 +59,7 @@ LOCALE_NORMALIZATION = {
|
|||
".euctw": ".EUC-TW",
|
||||
}
|
||||
|
||||
|
||||
# ===========================================
|
||||
# location module specific support methods.
|
||||
#
|
||||
|
@ -89,12 +85,14 @@ def is_available(name, ubuntuMode):
|
|||
fd.close()
|
||||
return False
|
||||
|
||||
|
||||
def is_present(name):
|
||||
"""Checks if the given locale is currently installed."""
|
||||
output = Popen(["locale", "-a"], stdout=PIPE).communicate()[0]
|
||||
output = to_native(output)
|
||||
return any(fix_case(name) == fix_case(line) for line in output.splitlines())
|
||||
|
||||
|
||||
def fix_case(name):
|
||||
"""locale -a might return the encoding in either lower or upper case.
|
||||
Passing through this function makes them uniform for comparisons."""
|
||||
|
@ -102,6 +100,7 @@ def fix_case(name):
|
|||
name = name.replace(s, r)
|
||||
return name
|
||||
|
||||
|
||||
def replace_line(existing_line, new_line):
|
||||
"""Replaces lines in /etc/locale.gen"""
|
||||
try:
|
||||
|
@ -115,6 +114,7 @@ def replace_line(existing_line, new_line):
|
|||
finally:
|
||||
f.close()
|
||||
|
||||
|
||||
def set_locale(name, enabled=True):
|
||||
""" Sets the state of the locale. Defaults to enabled. """
|
||||
search_string = '#{0,1}\s*%s (?P<charset>.+)' % name
|
||||
|
@ -133,6 +133,7 @@ def set_locale(name, enabled=True):
|
|||
finally:
|
||||
f.close()
|
||||
|
||||
|
||||
def apply_change(targetState, name):
|
||||
"""Create or remove locale.
|
||||
|
||||
|
@ -151,6 +152,7 @@ def apply_change(targetState, name):
|
|||
if localeGenExitValue != 0:
|
||||
raise EnvironmentError(localeGenExitValue, "locale.gen failed to execute, it returned " + str(localeGenExitValue))
|
||||
|
||||
|
||||
def apply_change_ubuntu(targetState, name):
|
||||
"""Create or remove locale.
|
||||
|
||||
|
@ -184,17 +186,14 @@ def apply_change_ubuntu(targetState, name):
|
|||
if localeGenExitValue != 0:
|
||||
raise EnvironmentError(localeGenExitValue, "locale.gen failed to execute, it returned " + str(localeGenExitValue))
|
||||
|
||||
# ==============================================================
|
||||
# main
|
||||
|
||||
def main():
|
||||
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
name = dict(required=True),
|
||||
state = dict(choices=['present','absent'], default='present'),
|
||||
name=dict(type='str', required=True),
|
||||
state=dict(type='str', default='present', choices=['absent', 'present']),
|
||||
),
|
||||
supports_check_mode=True
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
name = module.params['name']
|
||||
|
|
|
@ -1,22 +1,21 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2013, Alexander Bulimov <lazywolf0@gmail.com>
|
||||
# based on lvol module by Jeroen Hoekx <jeroen.hoekx@dsquare.be>
|
||||
# Copyright: (c) 2013, Alexander Bulimov <lazywolf0@gmail.com>
|
||||
# Based on lvol module by Jeroen Hoekx <jeroen.hoekx@dsquare.be>
|
||||
# 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
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
author: "Alexander Bulimov (@abulimov)"
|
||||
author:
|
||||
- Alexander Bulimov (@abulimov)
|
||||
module: lvg
|
||||
short_description: Configure LVM volume groups
|
||||
description:
|
||||
|
@ -31,61 +30,54 @@ options:
|
|||
description:
|
||||
- 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.
|
||||
required: false
|
||||
pesize:
|
||||
description:
|
||||
- The size of the physical extent in megabytes. Must be a power of 2.
|
||||
default: 4
|
||||
required: false
|
||||
pv_options:
|
||||
description:
|
||||
- Additional options to pass to C(pvcreate) when creating the volume group.
|
||||
default: null
|
||||
required: false
|
||||
version_added: "2.4"
|
||||
vg_options:
|
||||
description:
|
||||
- Additional options to pass to C(vgcreate) when creating the volume group.
|
||||
default: null
|
||||
required: false
|
||||
version_added: "1.6"
|
||||
state:
|
||||
choices: [ "present", "absent" ]
|
||||
default: present
|
||||
description:
|
||||
- Control if the volume group exists.
|
||||
required: false
|
||||
choices: [ absent, present ]
|
||||
default: present
|
||||
force:
|
||||
choices: [ "yes", "no" ]
|
||||
default: "no"
|
||||
description:
|
||||
- If yes, allows to remove volume group with logical volumes.
|
||||
required: false
|
||||
- If C(yes), allows to remove volume group with logical volumes.
|
||||
type: bool
|
||||
default: 'no'
|
||||
notes:
|
||||
- module does not modify PE size for already present volume group
|
||||
- This module does not modify PE size for already present volume group.
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Create a volume group on top of /dev/sda1 with physical extent size = 32MB.
|
||||
- lvg:
|
||||
- name: Create a volume group on top of /dev/sda1 with physical extent size = 32MB
|
||||
lvg:
|
||||
vg: vg.services
|
||||
pvs: /dev/sda1
|
||||
pesize: 32
|
||||
|
||||
# Create or resize a volume group on top of /dev/sdb1 and /dev/sdc5.
|
||||
# If, for example, we already have VG vg.services on top of /dev/sdb1,
|
||||
# this VG will be extended by /dev/sdc5. Or if vg.services was created on
|
||||
# top of /dev/sda5, we first extend it with /dev/sdb1 and /dev/sdc5,
|
||||
# and then reduce by /dev/sda5.
|
||||
- lvg:
|
||||
- name: Create or resize a volume group on top of /dev/sdb1 and /dev/sdc5.
|
||||
lvg:
|
||||
vg: vg.services
|
||||
pvs: /dev/sdb1,/dev/sdc5
|
||||
|
||||
# Remove a volume group with name vg.services.
|
||||
- lvg:
|
||||
- name: Remove a volume group with name vg.services
|
||||
lvg:
|
||||
vg: vg.services
|
||||
state: absent
|
||||
'''
|
||||
|
||||
import os
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
@ -102,6 +94,7 @@ def parse_vgs(data):
|
|||
})
|
||||
return vgs
|
||||
|
||||
|
||||
def find_mapper_device_name(module, dm_device):
|
||||
dmsetup_cmd = module.get_bin_path('dmsetup', True)
|
||||
mapper_prefix = '/dev/mapper/'
|
||||
|
@ -111,6 +104,7 @@ def find_mapper_device_name(module, dm_device):
|
|||
mapper_device = mapper_prefix + dm_name.rstrip()
|
||||
return mapper_device
|
||||
|
||||
|
||||
def parse_pvs(module, data):
|
||||
pvs = []
|
||||
dm_prefix = '/dev/dm-'
|
||||
|
@ -124,16 +118,17 @@ def parse_pvs(module, data):
|
|||
})
|
||||
return pvs
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
vg=dict(required=True),
|
||||
vg=dict(type='str', required=True),
|
||||
pvs=dict(type='list'),
|
||||
pesize=dict(type='int', default=4),
|
||||
pv_options=dict(default=''),
|
||||
vg_options=dict(default=''),
|
||||
state=dict(choices=["absent", "present"], default='present'),
|
||||
force=dict(type='bool', default='no'),
|
||||
pv_options=dict(type='str', default=''),
|
||||
vg_options=dict(type='str', default=''),
|
||||
state=dict(type='str', default='present', choices=['absent', 'present']),
|
||||
force=dict(type='bool', default=False),
|
||||
),
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
@ -156,18 +151,18 @@ def main():
|
|||
dev_list[idx] = os.path.realpath(dev)
|
||||
|
||||
if state == 'present':
|
||||
### check given devices
|
||||
# check given devices
|
||||
for test_dev in dev_list:
|
||||
if not os.path.exists(test_dev):
|
||||
module.fail_json(msg="Device %s not found." % test_dev)
|
||||
|
||||
### get pv list
|
||||
# get pv list
|
||||
pvs_cmd = module.get_bin_path('pvs', True)
|
||||
rc, current_pvs, err = module.run_command("%s --noheadings -o pv_name,vg_name --separator ';'" % pvs_cmd)
|
||||
if rc != 0:
|
||||
module.fail_json(msg="Failed executing pvs command.", rc=rc, err=err)
|
||||
|
||||
### check pv for devices
|
||||
# check pv for devices
|
||||
pvs = parse_pvs(module, current_pvs)
|
||||
used_pvs = [pv for pv in pvs if pv['name'] in dev_list and pv['vg_name'] and pv['vg_name'] != vg]
|
||||
if used_pvs:
|
||||
|
@ -192,11 +187,11 @@ def main():
|
|||
|
||||
if this_vg is None:
|
||||
if state == 'present':
|
||||
### create VG
|
||||
# create VG
|
||||
if module.check_mode:
|
||||
changed = True
|
||||
else:
|
||||
### create PV
|
||||
# create PV
|
||||
pvcreate_cmd = module.get_bin_path('pvcreate', True)
|
||||
for current_dev in dev_list:
|
||||
rc, _, err = module.run_command([pvcreate_cmd] + pvoptions + ['-f', str(current_dev)])
|
||||
|
@ -216,7 +211,7 @@ def main():
|
|||
module.exit_json(changed=True)
|
||||
else:
|
||||
if this_vg['lv_count'] == 0 or force:
|
||||
### remove VG
|
||||
# remove VG
|
||||
vgremove_cmd = module.get_bin_path('vgremove', True)
|
||||
rc, _, err = module.run_command("%s --force %s" % (vgremove_cmd, vg))
|
||||
if rc == 0:
|
||||
|
@ -226,7 +221,7 @@ def main():
|
|||
else:
|
||||
module.fail_json(msg="Refuse to remove non-empty volume group %s without force=yes" % (vg))
|
||||
|
||||
### resize VG
|
||||
# resize VG
|
||||
current_devs = [os.path.realpath(pv['name']) for pv in pvs if pv['vg_name'] == vg]
|
||||
devs_to_remove = list(set(current_devs) - set(dev_list))
|
||||
devs_to_add = list(set(dev_list) - set(current_devs))
|
||||
|
@ -237,7 +232,7 @@ def main():
|
|||
else:
|
||||
if devs_to_add:
|
||||
devs_to_add_string = ' '.join(devs_to_add)
|
||||
### create PV
|
||||
# create PV
|
||||
pvcreate_cmd = module.get_bin_path('pvcreate', True)
|
||||
for current_dev in devs_to_add:
|
||||
rc, _, err = module.run_command([pvcreate_cmd] + pvoptions + ['-f', str(current_dev)])
|
||||
|
@ -245,7 +240,7 @@ def main():
|
|||
changed = True
|
||||
else:
|
||||
module.fail_json(msg="Creating physical volume '%s' failed" % current_dev, rc=rc, err=err)
|
||||
### add PV to our VG
|
||||
# add PV to our VG
|
||||
vgextend_cmd = module.get_bin_path('vgextend', True)
|
||||
rc, _, err = module.run_command("%s %s %s" % (vgextend_cmd, vg, devs_to_add_string))
|
||||
if rc == 0:
|
||||
|
@ -253,7 +248,7 @@ def main():
|
|||
else:
|
||||
module.fail_json(msg="Unable to extend %s by %s." % (vg, devs_to_add_string), rc=rc, err=err)
|
||||
|
||||
### remove some PV from our VG
|
||||
# remove some PV from our VG
|
||||
if devs_to_remove:
|
||||
devs_to_remove_string = ' '.join(devs_to_remove)
|
||||
vgreduce_cmd = module.get_bin_path('vgreduce', True)
|
||||
|
|
|
@ -1,23 +1,21 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2013, Jeroen Hoekx <jeroen.hoekx@dsquare.be>, Alexander Bulimov <lazywolf0@gmail.com>
|
||||
# Copyright: (c) 2013, Jeroen Hoekx <jeroen.hoekx@dsquare.be>, Alexander Bulimov <lazywolf0@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
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
author:
|
||||
- "Jeroen Hoekx (@jhoekx)"
|
||||
- "Alexander Bulimov (@abulimov)"
|
||||
- Jeroen Hoekx (@jhoekx)
|
||||
- Alexander Bulimov (@abulimov)
|
||||
module: lvol
|
||||
short_description: Configure LVM logical volumes
|
||||
description:
|
||||
|
@ -40,152 +38,147 @@ options:
|
|||
Float values must begin with a digit.
|
||||
Resizing using percentage values was not supported prior to 2.1.
|
||||
state:
|
||||
choices: [ "present", "absent" ]
|
||||
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.
|
||||
required: false
|
||||
choices: [ absent, present ]
|
||||
default: present
|
||||
active:
|
||||
version_added: "2.2"
|
||||
choices: [ "yes", "no" ]
|
||||
default: "yes"
|
||||
description:
|
||||
- Whether the volume is activate and visible to the host.
|
||||
required: false
|
||||
type: bool
|
||||
default: 'yes'
|
||||
version_added: "2.2"
|
||||
force:
|
||||
version_added: "1.5"
|
||||
choices: [ "yes", "no" ]
|
||||
default: "no"
|
||||
description:
|
||||
- Shrink or remove operations of volumes requires this switch. Ensures that
|
||||
that filesystems get never corrupted/destroyed by mistake.
|
||||
required: false
|
||||
type: bool
|
||||
default: 'no'
|
||||
version_added: "1.5"
|
||||
opts:
|
||||
version_added: "2.0"
|
||||
description:
|
||||
- Free-form options to be passed to the lvcreate command
|
||||
version_added: "2.0"
|
||||
snapshot:
|
||||
version_added: "2.1"
|
||||
description:
|
||||
- The name of the snapshot volume
|
||||
required: false
|
||||
version_added: "2.1"
|
||||
pvs:
|
||||
version_added: "2.2"
|
||||
description:
|
||||
- Comma separated list of physical volumes e.g. /dev/sda,/dev/sdb
|
||||
required: false
|
||||
shrink:
|
||||
version_added: "2.2"
|
||||
shrink:
|
||||
description:
|
||||
- shrink if current size is higher than size requested
|
||||
required: false
|
||||
default: yes
|
||||
type: bool
|
||||
default: 'yes'
|
||||
version_added: "2.2"
|
||||
notes:
|
||||
- Filesystems on top of the volume are not resized.
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Create a logical volume of 512m.
|
||||
- lvol:
|
||||
- name: Create a logical volume of 512m
|
||||
lvol:
|
||||
vg: firefly
|
||||
lv: test
|
||||
size: 512
|
||||
|
||||
# Create a logical volume of 512m with disks /dev/sda and /dev/sdb
|
||||
- lvol:
|
||||
- name: Create a logical volume of 512m with disks /dev/sda and /dev/sdb
|
||||
lvol:
|
||||
vg: firefly
|
||||
lv: test
|
||||
size: 512
|
||||
pvs: /dev/sda,/dev/sdb
|
||||
|
||||
# Create cache pool logical volume
|
||||
- lvol:
|
||||
- name: Create cache pool logical volume
|
||||
lvol:
|
||||
vg: firefly
|
||||
lv: lvcache
|
||||
size: 512m
|
||||
opts: --type cache-pool
|
||||
|
||||
# Create a logical volume of 512g.
|
||||
- lvol:
|
||||
- name: Create a logical volume of 512g.
|
||||
lvol:
|
||||
vg: firefly
|
||||
lv: test
|
||||
size: 512g
|
||||
|
||||
# Create a logical volume the size of all remaining space in the volume group
|
||||
- lvol:
|
||||
- name: Create a logical volume the size of all remaining space in the volume group
|
||||
lvol:
|
||||
vg: firefly
|
||||
lv: test
|
||||
size: 100%FREE
|
||||
|
||||
# Create a logical volume with special options
|
||||
- lvol:
|
||||
- name: Create a logical volume with special options
|
||||
lvol:
|
||||
vg: firefly
|
||||
lv: test
|
||||
size: 512g
|
||||
opts: -r 16
|
||||
|
||||
# Extend the logical volume to 1024m.
|
||||
- lvol:
|
||||
- name: Extend the logical volume to 1024m.
|
||||
lvol:
|
||||
vg: firefly
|
||||
lv: test
|
||||
size: 1024
|
||||
|
||||
# Extend the logical volume to consume all remaining space in the volume group
|
||||
- lvol:
|
||||
- name: Extend the logical volume to consume all remaining space in the volume group
|
||||
lvol:
|
||||
vg: firefly
|
||||
lv: test
|
||||
size: +100%FREE
|
||||
|
||||
# Extend the logical volume to take all remaining space of the PVs
|
||||
- lvol:
|
||||
- name: Extend the logical volume to take all remaining space of the PVs
|
||||
lvol:
|
||||
vg: firefly
|
||||
lv: test
|
||||
size: 100%PVS
|
||||
|
||||
# Resize the logical volume to % of VG
|
||||
- lvol:
|
||||
- name: Resize the logical volume to % of VG
|
||||
lvol:
|
||||
vg: firefly
|
||||
lv: test
|
||||
size: 80%VG
|
||||
force: yes
|
||||
|
||||
# Reduce the logical volume to 512m
|
||||
- lvol:
|
||||
- name: Reduce the logical volume to 512m
|
||||
lvol:
|
||||
vg: firefly
|
||||
lv: test
|
||||
size: 512
|
||||
force: yes
|
||||
|
||||
# Set the logical volume to 512m and do not try to shrink if size is lower than current one
|
||||
- lvol:
|
||||
- name: Set the logical volume to 512m and do not try to shrink if size is lower than current one
|
||||
lvol:
|
||||
vg: firefly
|
||||
lv: test
|
||||
size: 512
|
||||
shrink: no
|
||||
|
||||
# Remove the logical volume.
|
||||
- lvol:
|
||||
- name: Remove the logical volume.
|
||||
lvol:
|
||||
vg: firefly
|
||||
lv: test
|
||||
state: absent
|
||||
force: yes
|
||||
|
||||
# Create a snapshot volume of the test logical volume.
|
||||
- lvol:
|
||||
- name: Create a snapshot volume of the test logical volume.
|
||||
lvol:
|
||||
vg: firefly
|
||||
lv: test
|
||||
snapshot: snap1
|
||||
size: 100m
|
||||
|
||||
# Deactivate a logical volume
|
||||
- lvol:
|
||||
- name: Deactivate a logical volume
|
||||
lvol:
|
||||
vg: firefly
|
||||
lv: test
|
||||
active: false
|
||||
|
||||
# Create a deactivated logical volume
|
||||
- lvol:
|
||||
- name: Create a deactivated logical volume
|
||||
lvol:
|
||||
vg: firefly
|
||||
lv: test
|
||||
size: 512g
|
||||
|
@ -196,13 +189,13 @@ import re
|
|||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
|
||||
decimal_point = re.compile(r"(\d+)")
|
||||
|
||||
|
||||
def mkversion(major, minor, patch):
|
||||
return (1000 * 1000 * int(major)) + (1000 * int(minor)) + int(patch)
|
||||
|
||||
|
||||
def parse_lvs(data):
|
||||
lvs = []
|
||||
for line in data.splitlines():
|
||||
|
@ -214,6 +207,7 @@ def parse_lvs(data):
|
|||
})
|
||||
return lvs
|
||||
|
||||
|
||||
def parse_vgs(data):
|
||||
vgs = []
|
||||
for line in data.splitlines():
|
||||
|
@ -241,15 +235,15 @@ def get_lvm_version(module):
|
|||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
vg=dict(required=True),
|
||||
lv=dict(required=True),
|
||||
vg=dict(type='str', required=True),
|
||||
lv=dict(type='str', required=True),
|
||||
size=dict(type='str'),
|
||||
opts=dict(type='str'),
|
||||
state=dict(choices=["absent", "present"], default='present'),
|
||||
force=dict(type='bool', default='no'),
|
||||
shrink=dict(type='bool', default='yes'),
|
||||
active=dict(type='bool', default='yes'),
|
||||
snapshot=dict(type='str', default=None),
|
||||
state=dict(type='str', default='present', choices=['absent', 'present']),
|
||||
force=dict(type='bool', default=False),
|
||||
shrink=dict(type='bool', default=True),
|
||||
active=dict(type='bool', default=True),
|
||||
snapshot=dict(type='str'),
|
||||
pvs=dict(type='str')
|
||||
),
|
||||
supports_check_mode=True,
|
||||
|
@ -307,7 +301,7 @@ def main():
|
|||
size_opt = 'l'
|
||||
size_unit = ''
|
||||
|
||||
if not '%' in size:
|
||||
if '%' not in size:
|
||||
# LVCREATE(8) -L --size option unit
|
||||
if size[-1].lower() in 'bskmgtpe':
|
||||
size_unit = size[-1].lower()
|
||||
|
@ -373,7 +367,7 @@ def main():
|
|||
msg = ''
|
||||
if this_lv is None:
|
||||
if state == 'present':
|
||||
### create LV
|
||||
# create LV
|
||||
lvcreate_cmd = module.get_bin_path("lvcreate", required=True)
|
||||
if snapshot is not None:
|
||||
cmd = "%s %s %s -%s %s%s -s -n %s %s %s/%s" % (lvcreate_cmd, test_opt, yesopt, size_opt, size, size_unit, snapshot, opts, vg, lv)
|
||||
|
@ -386,7 +380,7 @@ def main():
|
|||
module.fail_json(msg="Creating logical volume '%s' failed" % lv, rc=rc, err=err)
|
||||
else:
|
||||
if state == 'absent':
|
||||
### remove LV
|
||||
# remove LV
|
||||
if not force:
|
||||
module.fail_json(msg="Sorry, no removal of logical volume %s without force=yes." % (this_lv['name']))
|
||||
lvremove_cmd = module.get_bin_path("lvremove", required=True)
|
||||
|
@ -400,7 +394,7 @@ def main():
|
|||
pass
|
||||
|
||||
elif size_opt == 'l':
|
||||
### Resize LV based on % value
|
||||
# Resize LV based on % value
|
||||
tool = None
|
||||
size_free = this_vg['free']
|
||||
if size_whole == 'VG' or size_whole == 'PVS':
|
||||
|
@ -442,7 +436,7 @@ def main():
|
|||
module.fail_json(msg="Unable to resize %s to %s%s" % (lv, size, size_unit), rc=rc, err=err)
|
||||
|
||||
else:
|
||||
### resize LV based on absolute values
|
||||
# resize LV based on absolute values
|
||||
tool = None
|
||||
if int(size) > this_lv['size']:
|
||||
tool = module.get_bin_path("lvextend", required=True)
|
||||
|
|
|
@ -5,14 +5,13 @@
|
|||
# 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
|
||||
__metaclass__ = type
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: ohai
|
||||
|
|
|
@ -5,14 +5,13 @@
|
|||
# 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
|
||||
__metaclass__ = type
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: open_iscsi
|
||||
|
@ -113,19 +112,16 @@ import time
|
|||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
|
||||
ISCSIADM = 'iscsiadm'
|
||||
|
||||
|
||||
def compare_nodelists(l1, l2):
|
||||
|
||||
l1.sort()
|
||||
l2.sort()
|
||||
return l1 == l2
|
||||
|
||||
|
||||
def iscsi_get_cached_nodes(module, portal=None):
|
||||
|
||||
cmd = '%s --mode node' % iscsiadm_cmd
|
||||
(rc, out, err) = module.run_command(cmd)
|
||||
|
||||
|
@ -156,7 +152,6 @@ def iscsi_get_cached_nodes(module, portal=None):
|
|||
|
||||
|
||||
def iscsi_discover(module, portal, port):
|
||||
|
||||
cmd = '%s --mode discovery --type sendtargets --portal %s:%s' % (iscsiadm_cmd, portal, port)
|
||||
(rc, out, err) = module.run_command(cmd)
|
||||
|
||||
|
@ -165,7 +160,6 @@ def iscsi_discover(module, portal, port):
|
|||
|
||||
|
||||
def target_loggedon(module, target):
|
||||
|
||||
cmd = '%s --mode session' % iscsiadm_cmd
|
||||
(rc, out, err) = module.run_command(cmd)
|
||||
|
||||
|
@ -178,7 +172,6 @@ def target_loggedon(module, target):
|
|||
|
||||
|
||||
def target_login(module, target):
|
||||
|
||||
node_auth = module.params['node_auth']
|
||||
node_user = module.params['node_user']
|
||||
node_pass = module.params['node_pass']
|
||||
|
@ -201,7 +194,6 @@ def target_login(module, target):
|
|||
|
||||
|
||||
def target_logout(module, target):
|
||||
|
||||
cmd = '%s --mode node --targetname %s --logout' % (iscsiadm_cmd, target)
|
||||
(rc, out, err) = module.run_command(cmd)
|
||||
|
||||
|
@ -210,7 +202,6 @@ def target_logout(module, target):
|
|||
|
||||
|
||||
def target_device_node(module, target):
|
||||
|
||||
# if anyone know a better way to find out which devicenodes get created for
|
||||
# a given target...
|
||||
|
||||
|
@ -227,7 +218,6 @@ def target_device_node(module, target):
|
|||
|
||||
|
||||
def target_isauto(module, target):
|
||||
|
||||
cmd = '%s --mode node --targetname %s' % (iscsiadm_cmd, target)
|
||||
(rc, out, err) = module.run_command(cmd)
|
||||
|
||||
|
@ -242,7 +232,6 @@ def target_isauto(module, target):
|
|||
|
||||
|
||||
def target_setauto(module, target):
|
||||
|
||||
cmd = '%s --mode node --targetname %s --op=update --name node.startup --value automatic' % (iscsiadm_cmd, target)
|
||||
(rc, out, err) = module.run_command(cmd)
|
||||
|
||||
|
@ -251,7 +240,6 @@ def target_setauto(module, target):
|
|||
|
||||
|
||||
def target_setmanual(module, target):
|
||||
|
||||
cmd = '%s --mode node --targetname %s --op=update --name node.startup --value manual' % (iscsiadm_cmd, target)
|
||||
(rc, out, err) = module.run_command(cmd)
|
||||
|
||||
|
@ -260,7 +248,6 @@ def target_setmanual(module, target):
|
|||
|
||||
|
||||
def main():
|
||||
|
||||
# load ansible module object
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
|
|
|
@ -4,14 +4,13 @@
|
|||
# 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
|
||||
__metaclass__ = type
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
module: openwrt_init
|
||||
author:
|
||||
|
@ -85,6 +84,7 @@ from ansible.module_utils._text import to_bytes, to_native
|
|||
module = None
|
||||
init_script = None
|
||||
|
||||
|
||||
# ===============================
|
||||
# Check if service is enabled
|
||||
def is_enabled():
|
||||
|
@ -93,6 +93,7 @@ def is_enabled():
|
|||
return True
|
||||
return False
|
||||
|
||||
|
||||
# ===========================================
|
||||
# Main control flow
|
||||
|
||||
|
@ -164,7 +165,7 @@ def main():
|
|||
if rc == 0:
|
||||
lines = psout.split("\n")
|
||||
for line in lines:
|
||||
if module.params['pattern'] in line and not "pattern=" in line:
|
||||
if module.params['pattern'] in line and "pattern=" not in line:
|
||||
# so as to not confuse ./hacking/test-module
|
||||
running = True
|
||||
break
|
||||
|
@ -197,8 +198,8 @@ def main():
|
|||
if rc != 0:
|
||||
module.fail_json(msg="Unable to %s service %s: %s" % (action, service, err))
|
||||
|
||||
|
||||
module.exit_json(**result)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -5,14 +5,13 @@
|
|||
# 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
|
||||
__metaclass__ = type
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['stableinterface'],
|
||||
'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: osx_defaults
|
||||
|
@ -118,15 +117,17 @@ from ansible.module_utils.six import binary_type, text_type
|
|||
# exceptions --------------------------------------------------------------- {{{
|
||||
class OSXDefaultsException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
# /exceptions -------------------------------------------------------------- }}}
|
||||
|
||||
# class MacDefaults -------------------------------------------------------- {{{
|
||||
class OSXDefaults(object):
|
||||
|
||||
""" Class to manage Mac OS user defaults """
|
||||
|
||||
# init ---------------------------------------------------------------- {{{
|
||||
""" Initialize this module. Finds 'defaults' executable and preps the parameters """
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
|
||||
# Initial var for storing current defaults value
|
||||
|
@ -157,6 +158,7 @@ class OSXDefaults(object):
|
|||
|
||||
# tools --------------------------------------------------------------- {{{
|
||||
""" Converts value to given type """
|
||||
|
||||
def _convert_type(self, type, value):
|
||||
|
||||
if type == "string":
|
||||
|
@ -194,6 +196,7 @@ class OSXDefaults(object):
|
|||
raise OSXDefaultsException('Type is not supported: {0}'.format(type))
|
||||
|
||||
""" Returns a normalized list of commandline arguments based on the "host" attribute """
|
||||
|
||||
def _host_args(self):
|
||||
if self.host is None:
|
||||
return []
|
||||
|
@ -203,10 +206,12 @@ class OSXDefaults(object):
|
|||
return ['-host', self.host]
|
||||
|
||||
""" Returns a list containing the "defaults" executable and any common base arguments """
|
||||
|
||||
def _base_command(self):
|
||||
return [self.executable] + self._host_args()
|
||||
|
||||
""" Converts array output from defaults to an list """
|
||||
|
||||
@staticmethod
|
||||
def _convert_defaults_str_to_list(value):
|
||||
|
||||
|
@ -221,10 +226,12 @@ class OSXDefaults(object):
|
|||
value = [re.sub(',$', '', x.strip(' ')) for x in value]
|
||||
|
||||
return value
|
||||
|
||||
# /tools -------------------------------------------------------------- }}}
|
||||
|
||||
# commands ------------------------------------------------------------ {{{
|
||||
""" Reads value of this domain & key from defaults """
|
||||
|
||||
def read(self):
|
||||
# First try to find out the type
|
||||
rc, out, err = self.module.run_command(self._base_command() + ["read-type", self.domain, self.key])
|
||||
|
@ -258,6 +265,7 @@ class OSXDefaults(object):
|
|||
self.current_value = self._convert_type(type, out)
|
||||
|
||||
""" Writes value to this domain & key to defaults """
|
||||
|
||||
def write(self):
|
||||
|
||||
# We need to convert some values so the defaults commandline understands it
|
||||
|
@ -289,6 +297,7 @@ class OSXDefaults(object):
|
|||
raise OSXDefaultsException('An error occurred while writing value to defaults: ' + out)
|
||||
|
||||
""" Deletes defaults key from domain """
|
||||
|
||||
def delete(self):
|
||||
rc, out, err = self.module.run_command(self._base_command() + ['delete', self.domain, self.key])
|
||||
if rc != 0:
|
||||
|
@ -298,6 +307,7 @@ class OSXDefaults(object):
|
|||
|
||||
# run ----------------------------------------------------------------- {{{
|
||||
""" Does the magic! :) """
|
||||
|
||||
def run(self):
|
||||
|
||||
# Get the current value from defaults
|
||||
|
@ -321,8 +331,7 @@ class OSXDefaults(object):
|
|||
if self.type == "array" and self.current_value is not None and not self.array_add and \
|
||||
set(self.current_value) == set(self.value):
|
||||
return False
|
||||
elif self.type == "array" and self.current_value is not None and self.array_add and \
|
||||
len(list(set(self.value) - set(self.current_value))) == 0:
|
||||
elif self.type == "array" and self.current_value is not None and self.array_add and len(list(set(self.value) - set(self.current_value))) == 0:
|
||||
return False
|
||||
elif self.current_value == self.value:
|
||||
return False
|
||||
|
@ -336,6 +345,7 @@ class OSXDefaults(object):
|
|||
|
||||
# /run ---------------------------------------------------------------- }}}
|
||||
|
||||
|
||||
# /class MacDefaults ------------------------------------------------------ }}}
|
||||
|
||||
|
||||
|
@ -410,6 +420,7 @@ def main():
|
|||
except OSXDefaultsException as e:
|
||||
module.fail_json(msg=e.message)
|
||||
|
||||
|
||||
# /main ------------------------------------------------------------------- }}}
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -5,14 +5,13 @@
|
|||
# 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
|
||||
__metaclass__ = type
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: pam_limits
|
||||
|
@ -133,7 +132,6 @@ from ansible.module_utils._text import to_native
|
|||
|
||||
|
||||
def main():
|
||||
|
||||
pam_items = ['core', 'data', 'fsize', 'memlock', 'nofile', 'rss', 'stack', 'cpu', 'nproc', 'as', 'maxlogins', 'maxsyslogins', 'priority', 'locks',
|
||||
'sigpending', 'msgqueue', 'nice', 'rtprio', 'chroot']
|
||||
|
||||
|
|
|
@ -4,14 +4,13 @@
|
|||
# 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
|
||||
__metaclass__ = type
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['stableinterface'],
|
||||
'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: puppet
|
||||
|
|
|
@ -1,36 +1,33 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# (c) 2015, Brian Coca <bcoca@ansible.com>
|
||||
# Copyright: (c) 2015, Brian Coca <bcoca@ansible.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
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['stableinterface'],
|
||||
'supported_by': 'community'}
|
||||
|
||||
|
||||
# This is a modification of @bcoca's `svc` module
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: runit
|
||||
author: "James Sumners (@jsumners)"
|
||||
author:
|
||||
- James Sumners (@jsumners)
|
||||
version_added: "2.3"
|
||||
short_description: Manage runit services.
|
||||
short_description: Manage runit services
|
||||
description:
|
||||
- Controls runit services on remote hosts using the sv utility.
|
||||
options:
|
||||
name:
|
||||
required: true
|
||||
description:
|
||||
- Name of the service to manage.
|
||||
required: yes
|
||||
state:
|
||||
required: false
|
||||
choices: [ started, stopped, restarted, killed, reloaded, once ]
|
||||
description:
|
||||
- C(started)/C(stopped) are idempotent actions that will not run
|
||||
commands unless necessary. C(restarted) will always bounce the
|
||||
|
@ -38,51 +35,49 @@ options:
|
|||
C(reloaded) will send a HUP (sv reload).
|
||||
C(once) will run a normally downed sv once (sv once), not really
|
||||
an idempotent operation.
|
||||
choices: [ killed, once, reloaded, restarted, started, stopped ]
|
||||
enabled:
|
||||
required: false
|
||||
choices: [ "yes", "no" ]
|
||||
description:
|
||||
- Wheater the service is enabled or not, if disabled it also implies stopped.
|
||||
type: bool
|
||||
service_dir:
|
||||
required: false
|
||||
default: /var/service
|
||||
description:
|
||||
- directory runsv watches for services
|
||||
default: /var/service
|
||||
service_src:
|
||||
required: false
|
||||
default: /etc/sv
|
||||
description:
|
||||
- directory where services are defined, the source of symlinks to service_dir.
|
||||
default: /etc/sv
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Example action to start sv dnscache, if not running
|
||||
- runit:
|
||||
- name: Start sv dnscache, if not running
|
||||
runit:
|
||||
name: dnscache
|
||||
state: started
|
||||
|
||||
# Example action to stop sv dnscache, if running
|
||||
- runit:
|
||||
- name: Stop sv dnscache, if running
|
||||
runit:
|
||||
name: dnscache
|
||||
state: stopped
|
||||
|
||||
# Example action to kill sv dnscache, in all cases
|
||||
- runit:
|
||||
- name: Kill sv dnscache, in all cases
|
||||
runit:
|
||||
name: dnscache
|
||||
state: killed
|
||||
|
||||
# Example action to restart sv dnscache, in all cases
|
||||
- runit:
|
||||
- name: Restart sv dnscache, in all cases
|
||||
runit:
|
||||
name: dnscache
|
||||
state: restarted
|
||||
|
||||
# Example action to reload sv dnscache, in all cases
|
||||
- runit:
|
||||
- name: Reload sv dnscache, in all cases
|
||||
runit:
|
||||
name: dnscache
|
||||
state: reloaded
|
||||
|
||||
# Example using alt sv directory location
|
||||
- runit:
|
||||
- name: Use alternative sv directory location
|
||||
runit:
|
||||
name: dnscache
|
||||
state: reloaded
|
||||
service_dir: /run/service
|
||||
|
@ -114,18 +109,16 @@ def _load_dist_subclass(cls, *args, **kwargs):
|
|||
|
||||
return super(cls, subclass).__new__(subclass)
|
||||
|
||||
|
||||
class Sv(object):
|
||||
"""
|
||||
Main class that handles daemontools, can be subclassed and overridden in case
|
||||
we want to use a 'derivative' like encore, s6, etc
|
||||
"""
|
||||
|
||||
|
||||
# def __new__(cls, *args, **kwargs):
|
||||
# return _load_dist_subclass(cls, args, kwargs)
|
||||
|
||||
|
||||
|
||||
def __init__(self, module):
|
||||
self.extra_paths = []
|
||||
self.report_vars = ['state', 'enabled', 'svc_full', 'src_full', 'pid', 'duration', 'full_state']
|
||||
|
@ -152,7 +145,6 @@ class Sv(object):
|
|||
else:
|
||||
self.state = 'stopped'
|
||||
|
||||
|
||||
def enable(self):
|
||||
if os.path.exists(self.src_full):
|
||||
try:
|
||||
|
@ -240,18 +232,16 @@ class Sv(object):
|
|||
states[k] = self.__dict__[k]
|
||||
return states
|
||||
|
||||
# ===========================================
|
||||
# Main control flow
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
name = dict(required=True),
|
||||
state = dict(choices=['started', 'stopped', 'restarted', 'killed', 'reloaded', 'once']),
|
||||
enabled = dict(required=False, type='bool'),
|
||||
dist = dict(required=False, default='runit'),
|
||||
service_dir = dict(required=False, default='/var/service'),
|
||||
service_src = dict(required=False, default='/etc/sv'),
|
||||
name=dict(type='str', required=True),
|
||||
state=dict(type='str', choices=['killed', 'once', 'reloaded', 'restarted', 'started', 'stopped']),
|
||||
enabled=dict(type='bool'),
|
||||
dist=dict(type='str', default='runit'),
|
||||
service_dir=dict(type='str', default='/var/service'),
|
||||
service_src=dict(type='str', default='/etc/sv'),
|
||||
),
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
|
|
@ -42,8 +42,8 @@ author:
|
|||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Set (httpd_can_network_connect) flag on and keep it persistent across reboots
|
||||
- seboolean:
|
||||
- name: Set httpd_can_network_connect flag on and keep it persistent across reboots
|
||||
seboolean:
|
||||
name: httpd_can_network_connect
|
||||
state: yes
|
||||
persistent: yes
|
||||
|
@ -173,7 +173,7 @@ def main():
|
|||
argument_spec=dict(
|
||||
name=dict(type='str', required=True),
|
||||
persistent=dict(type='bool', default=False),
|
||||
state=dict(type='bool', required=True)
|
||||
state=dict(type='bool', required=True),
|
||||
),
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
@ -190,6 +190,7 @@ def main():
|
|||
name = module.params['name']
|
||||
persistent = module.params['persistent']
|
||||
state = module.params['state']
|
||||
|
||||
result = dict(
|
||||
name=name,
|
||||
)
|
||||
|
@ -205,12 +206,11 @@ def main():
|
|||
cur_value = get_boolean_value(module, name)
|
||||
|
||||
if cur_value == state:
|
||||
result['state'] = cur_value
|
||||
result['changed'] = False
|
||||
module.exit_json(**result)
|
||||
module.exit_json(changed=False, state=cur_value, **result)
|
||||
|
||||
if module.check_mode:
|
||||
module.exit_json(changed=True)
|
||||
|
||||
if persistent:
|
||||
r = semanage_boolean_value(module, name, state)
|
||||
else:
|
||||
|
@ -223,6 +223,7 @@ def main():
|
|||
selinux.security_commit_booleans()
|
||||
except:
|
||||
module.fail_json(msg="Failed to commit pending boolean %s value" % name)
|
||||
|
||||
module.exit_json(**result)
|
||||
|
||||
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
# (c) 2014, Dan Keder <dan.keder@gmail.com>
|
||||
# Copyright: (c) 2014, Dan Keder <dan.keder@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
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: seport
|
||||
|
@ -22,55 +20,55 @@ version_added: "2.0"
|
|||
options:
|
||||
ports:
|
||||
description:
|
||||
- Ports or port ranges, separated by a comma
|
||||
- Ports or port ranges, separated by a comma.
|
||||
required: true
|
||||
default: null
|
||||
proto:
|
||||
description:
|
||||
- Protocol for the specified port.
|
||||
required: true
|
||||
default: null
|
||||
choices: [ 'tcp', 'udp' ]
|
||||
choices: [ tcp, udp ]
|
||||
setype:
|
||||
description:
|
||||
- SELinux type for the specified port.
|
||||
required: true
|
||||
default: null
|
||||
state:
|
||||
description:
|
||||
- Desired boolean value.
|
||||
required: true
|
||||
choices: [ absent, present ]
|
||||
default: present
|
||||
choices: [ 'present', 'absent' ]
|
||||
reload:
|
||||
description:
|
||||
- Reload SELinux policy after commit.
|
||||
required: false
|
||||
default: yes
|
||||
type: bool
|
||||
default: 'yes'
|
||||
notes:
|
||||
- The changes are persistent across reboots
|
||||
- Not tested on any debian based system
|
||||
requirements: [ 'libselinux-python', 'policycoreutils-python' ]
|
||||
author: Dan Keder
|
||||
- The changes are persistent across reboots.
|
||||
- Not tested on any debian based system.
|
||||
requirements:
|
||||
- libselinux-python
|
||||
- policycoreutils-python
|
||||
author:
|
||||
- Dan Keder
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Allow Apache to listen on tcp port 8888
|
||||
- seport:
|
||||
- name: Allow Apache to listen on tcp port 8888
|
||||
seport:
|
||||
ports: 8888
|
||||
proto: tcp
|
||||
setype: http_port_t
|
||||
state: present
|
||||
|
||||
# Allow sshd to listen on tcp port 8991
|
||||
- seport:
|
||||
- name: Allow sshd to listen on tcp port 8991
|
||||
seport:
|
||||
ports: 8991
|
||||
proto: tcp
|
||||
setype: ssh_port_t
|
||||
state: present
|
||||
|
||||
# Allow memcached to listen on tcp ports 10000-10100 and 10112
|
||||
- seport:
|
||||
- name: Allow memcached to listen on tcp ports 10000-10100 and 10112
|
||||
seport:
|
||||
ports: 10000-10100,10112
|
||||
proto: tcp
|
||||
setype: memcache_port_t
|
||||
|
@ -232,29 +230,16 @@ def semanage_port_del(module, ports, proto, setype, do_reload, sestore=''):
|
|||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec={
|
||||
'ports': {
|
||||
'required': True,
|
||||
},
|
||||
'proto': {
|
||||
'required': True,
|
||||
'choices': ['tcp', 'udp'],
|
||||
},
|
||||
'setype': {
|
||||
'required': True,
|
||||
},
|
||||
'state': {
|
||||
'required': True,
|
||||
'choices': ['present', 'absent'],
|
||||
},
|
||||
'reload': {
|
||||
'required': False,
|
||||
'type': 'bool',
|
||||
'default': 'yes',
|
||||
},
|
||||
},
|
||||
supports_check_mode=True
|
||||
argument_spec=dict(
|
||||
ports=dict(type='str', required=True),
|
||||
proto=dict(type='str', required=True, choices=['tcp', 'udp']),
|
||||
setype=dict(type='str', required=True),
|
||||
state=dict(type='str', required=True, choices=['absent', 'present']),
|
||||
reload=dict(type='bool', default=True),
|
||||
),
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
if not HAVE_SELINUX:
|
||||
module.fail_json(msg="This module requires libselinux-python")
|
||||
|
||||
|
|
|
@ -6,12 +6,10 @@
|
|||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: solaris_zone
|
||||
|
@ -20,12 +18,12 @@ description:
|
|||
- Create, start, stop and delete Solaris zones. This module doesn't currently allow
|
||||
changing of options for a zone that's already been created.
|
||||
version_added: "2.0"
|
||||
author: Paul Markham
|
||||
author:
|
||||
- Paul Markham
|
||||
requirements:
|
||||
- Solaris 10 or 11
|
||||
options:
|
||||
state:
|
||||
required: true
|
||||
description:
|
||||
- C(present), configure and install the zone.
|
||||
- C(installed), synonym for C(present).
|
||||
|
@ -37,8 +35,9 @@ options:
|
|||
- C(configured), configure the ready so that it's to be attached.
|
||||
- C(attached), attach a zone, but do not boot it.
|
||||
- C(detached), shutdown and detach a zone
|
||||
choices: ['present', 'installed', 'started', 'running', 'stopped', 'absent', 'configured', 'attached', 'detached']
|
||||
choices: [ absent, attached, configured, detached, installed, present, running, started, stopped ]
|
||||
default: present
|
||||
required: true
|
||||
name:
|
||||
description:
|
||||
- Zone name.
|
||||
|
@ -47,48 +46,39 @@ options:
|
|||
description:
|
||||
- The path where the zone will be created. This is required when the zone is created, but not
|
||||
used otherwise.
|
||||
required: false
|
||||
default: null
|
||||
sparse:
|
||||
description:
|
||||
- Whether to create a sparse (C(true)) or whole root (C(false)) zone.
|
||||
required: false
|
||||
default: false
|
||||
type: bool
|
||||
default: 'no'
|
||||
root_password:
|
||||
description:
|
||||
- The password hash for the root account. If not specified, the zone's root account
|
||||
will not have a password.
|
||||
required: false
|
||||
default: null
|
||||
config:
|
||||
description:
|
||||
- 'The zonecfg configuration commands for this zone. See zonecfg(1M) for the valid options
|
||||
and syntax. Typically this is a list of options separated by semi-colons or new lines, e.g.
|
||||
"set auto-boot=true;add net;set physical=bge0;set address=10.1.1.1;end"'
|
||||
required: false
|
||||
default: empty string
|
||||
create_options:
|
||||
description:
|
||||
- 'Extra options to the zonecfg(1M) create command.'
|
||||
required: false
|
||||
default: empty string
|
||||
install_options:
|
||||
description:
|
||||
- 'Extra options to the zoneadm(1M) install command. To automate Solaris 11 zone creation,
|
||||
use this to specify the profile XML file, e.g. install_options="-c sc_profile.xml"'
|
||||
required: false
|
||||
default: empty string
|
||||
attach_options:
|
||||
description:
|
||||
- 'Extra options to the zoneadm attach command. For example, this can be used to specify
|
||||
whether a minimum or full update of packages is required and if any packages need to
|
||||
be deleted. For valid values, see zoneadm(1M)'
|
||||
required: false
|
||||
default: empty string
|
||||
timeout:
|
||||
description:
|
||||
- Timeout, in seconds, for zone to boot.
|
||||
required: false
|
||||
default: 600
|
||||
'''
|
||||
|
||||
|
@ -434,21 +424,23 @@ class Zone(object):
|
|||
else:
|
||||
self.msg.append('zone already attached')
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
name=dict(required=True),
|
||||
state=dict(default='present', choices=['running', 'started', 'present', 'installed', 'stopped', 'absent', 'configured', 'detached', 'attached']),
|
||||
path=dict(default=None),
|
||||
sparse=dict(default=False, type='bool'),
|
||||
root_password=dict(default=None, no_log=True),
|
||||
timeout=dict(default=600, type='int'),
|
||||
config=dict(default=''),
|
||||
create_options=dict(default=''),
|
||||
install_options=dict(default=''),
|
||||
attach_options=dict(default=''),
|
||||
name=dict(type='str', required=True),
|
||||
state=dict(type='str', default='present',
|
||||
choices=['absent', 'attached', 'configured', 'detached', 'installed', 'present', 'running', 'started', 'stopped']),
|
||||
path=dict(type='str'),
|
||||
sparse=dict(type='bool', default=False),
|
||||
root_password=dict(type='str', no_log=True),
|
||||
timeout=dict(type='int', default=600),
|
||||
config=dict(type='str', default=''),
|
||||
create_options=dict(type='str', default=''),
|
||||
install_options=dict(type='str', default=''),
|
||||
attach_options=dict(type='str', default=''),
|
||||
),
|
||||
supports_check_mode=True
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
zone = Zone(module)
|
||||
|
|
|
@ -1,34 +1,31 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# (c) 2015, Brian Coca <bcoca@ansible.com>
|
||||
# Copyright: (c) 2015, Brian Coca <bcoca@ansible.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
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['stableinterface'],
|
||||
'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: svc
|
||||
author: "Brian Coca (@bcoca)"
|
||||
author:
|
||||
- Brian Coca (@bcoca)
|
||||
version_added: "1.9"
|
||||
short_description: Manage daemontools services.
|
||||
short_description: Manage daemontools services
|
||||
description:
|
||||
- Controls daemontools services on remote hosts using the svc utility.
|
||||
options:
|
||||
name:
|
||||
required: true
|
||||
description:
|
||||
- Name of the service to manage.
|
||||
required: true
|
||||
state:
|
||||
required: false
|
||||
choices: [ started, stopped, restarted, reloaded, once, killed ]
|
||||
description:
|
||||
- C(Started)/C(stopped) are idempotent actions that will not run
|
||||
commands unless necessary. C(restarted) will always bounce the
|
||||
|
@ -36,58 +33,55 @@ 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.
|
||||
choices: [ killed, once, reloaded, restarted, started, stopped ]
|
||||
downed:
|
||||
required: false
|
||||
choices: [ "yes", "no" ]
|
||||
default: no
|
||||
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'
|
||||
enabled:
|
||||
required: false
|
||||
choices: [ "yes", "no" ]
|
||||
description:
|
||||
- Wheater the service is enabled or not, if disabled it also implies stopped.
|
||||
Make note that a service can be enabled and downed (no auto restart).
|
||||
type: bool
|
||||
service_dir:
|
||||
required: false
|
||||
default: /service
|
||||
description:
|
||||
- directory svscan watches for services
|
||||
default: /service
|
||||
service_src:
|
||||
required: false
|
||||
description:
|
||||
- directory where services are defined, the source of symlinks to service_dir.
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Example action to start svc dnscache, if not running
|
||||
- svc:
|
||||
- name: Start svc dnscache, if not running
|
||||
svc:
|
||||
name: dnscache
|
||||
state: started
|
||||
|
||||
# Example action to stop svc dnscache, if running
|
||||
- svc:
|
||||
- name: Stop svc dnscache, if running
|
||||
svc:
|
||||
name: dnscache
|
||||
state: stopped
|
||||
|
||||
# Example action to kill svc dnscache, in all cases
|
||||
- svc:
|
||||
- name: Kill svc dnscache, in all cases
|
||||
svc:
|
||||
name: dnscache
|
||||
state: killed
|
||||
|
||||
# Example action to restart svc dnscache, in all cases
|
||||
- svc:
|
||||
- name: Restart svc dnscache, in all cases
|
||||
svc:
|
||||
name: dnscache
|
||||
state: restarted
|
||||
|
||||
# Example action to reload svc dnscache, in all cases
|
||||
- svc:
|
||||
- name: Reload svc dnscache, in all cases
|
||||
svc:
|
||||
name: dnscache
|
||||
state: reloaded
|
||||
|
||||
# Example using alt svc directory location
|
||||
- svc:
|
||||
- name: Using alternative svc directory location
|
||||
svc:
|
||||
name: dnscache
|
||||
state: reloaded
|
||||
service_dir: /var/service
|
||||
|
@ -119,18 +113,16 @@ def _load_dist_subclass(cls, *args, **kwargs):
|
|||
|
||||
return super(cls, subclass).__new__(subclass)
|
||||
|
||||
|
||||
class Svc(object):
|
||||
"""
|
||||
Main class that handles daemontools, can be subclassed and overridden in case
|
||||
we want to use a 'derivative' like encore, s6, etc
|
||||
"""
|
||||
|
||||
|
||||
# def __new__(cls, *args, **kwargs):
|
||||
# return _load_dist_subclass(cls, args, kwargs)
|
||||
|
||||
|
||||
|
||||
def __init__(self, module):
|
||||
self.extra_paths = ['/command', '/usr/local/bin']
|
||||
self.report_vars = ['state', 'enabled', 'downed', 'svc_full', 'src_full', 'pid', 'duration', 'full_state']
|
||||
|
@ -160,7 +152,6 @@ class Svc(object):
|
|||
self.downed = os.path.lexists('%s/down' % self.src_full)
|
||||
self.state = 'stopped'
|
||||
|
||||
|
||||
def enable(self):
|
||||
if os.path.exists(self.src_full):
|
||||
try:
|
||||
|
@ -245,19 +236,20 @@ class Svc(object):
|
|||
states[k] = self.__dict__[k]
|
||||
return states
|
||||
|
||||
|
||||
# ===========================================
|
||||
# Main control flow
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
name = dict(required=True),
|
||||
state = dict(choices=['started', 'stopped', 'restarted', 'killed', 'reloaded', 'once']),
|
||||
enabled = dict(required=False, type='bool'),
|
||||
downed = dict(required=False, type='bool'),
|
||||
dist = dict(required=False, default='daemontools'),
|
||||
service_dir = dict(required=False, default='/service'),
|
||||
service_src = dict(required=False, default='/etc/service'),
|
||||
name=dict(type='str', required=True),
|
||||
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'),
|
||||
),
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
@ -303,7 +295,5 @@ def main():
|
|||
module.exit_json(changed=changed, svc=svc.report())
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -392,7 +392,6 @@ def main():
|
|||
if not module.params['user'] and \
|
||||
is_initd and \
|
||||
(not out.strip().endswith('disabled') or sysv_is_enabled(unit)):
|
||||
|
||||
enabled = True
|
||||
|
||||
# default to current state
|
||||
|
|
|
@ -1,18 +1,16 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2016, Shinichi TAMURA (@tmshn)
|
||||
# Copyright: (c) 2016, Shinichi TAMURA (@tmshn)
|
||||
# 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
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: timezone
|
||||
|
@ -33,7 +31,6 @@ options:
|
|||
- Name of the timezone for the system clock.
|
||||
Default is to keep current setting. B(At least one of name and
|
||||
hwclock are required.)
|
||||
required: false
|
||||
hwclock:
|
||||
description:
|
||||
- Whether the hardware clock is in UTC or in local timezone.
|
||||
|
@ -42,14 +39,13 @@ options:
|
|||
to configure, especially on virtual environments such as AWS.
|
||||
B(At least one of name and hwclock are required.)
|
||||
I(Only used on Linux.)
|
||||
required: false
|
||||
aliases: ['rtc']
|
||||
aliases: [ rtc ]
|
||||
notes:
|
||||
- On SmartOS the C(sm-set-timezone) utility (part of the smtools package) is required to set the zone timezone
|
||||
author:
|
||||
- "Shinichi TAMURA (@tmshn)"
|
||||
- "Jasper Lievisse Adriaanse (@jasperla)"
|
||||
- "Indrajit Raychaudhuri (@indrajitr)"
|
||||
- Shinichi TAMURA (@tmshn)
|
||||
- Jasper Lievisse Adriaanse (@jasperla)
|
||||
- Indrajit Raychaudhuri (@indrajitr)
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
|
@ -558,7 +554,7 @@ class DarwinTimezone(Timezone):
|
|||
# Note: Skip the first line that contains the label 'Time Zones:'
|
||||
out = self.execute(self.systemsetup, '-listtimezones').splitlines()[1:]
|
||||
tz_list = list(map(lambda x: x.strip(), out))
|
||||
if not tz in tz_list:
|
||||
if tz not in tz_list:
|
||||
self.abort('given timezone "%s" is not available' % tz)
|
||||
return tz
|
||||
|
||||
|
@ -631,11 +627,13 @@ def main():
|
|||
# Construct 'module' and 'tz'
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
hwclock=dict(choices=['UTC', 'local'], aliases=['rtc']),
|
||||
name=dict(),
|
||||
hwclock=dict(type='str', choices=['local', 'UTC'], aliases=['rtc']),
|
||||
name=dict(type='str'),
|
||||
),
|
||||
required_one_of=[['hwclock', 'name']],
|
||||
supports_check_mode=True
|
||||
required_one_of=[
|
||||
['hwclock', 'name']
|
||||
],
|
||||
supports_check_mode=True,
|
||||
)
|
||||
tz = Timezone(module)
|
||||
|
||||
|
|
|
@ -1,22 +1,19 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2014, Ahti Kitsik <ak@ahtik.com>
|
||||
# (c) 2014, Jarno Keskikangas <jarno.keskikangas@gmail.com>
|
||||
# (c) 2013, Aleksey Ovcharenko <aleksey.ovcharenko@gmail.com>
|
||||
# (c) 2013, James Martin <jmartin@basho.com>
|
||||
#
|
||||
# Copyright: (c) 2014, Ahti Kitsik <ak@ahtik.com>
|
||||
# Copyright: (c) 2014, Jarno Keskikangas <jarno.keskikangas@gmail.com>
|
||||
# Copyright: (c) 2013, Aleksey Ovcharenko <aleksey.ovcharenko@gmail.com>
|
||||
# Copyright: (c) 2013, James Martin <jmartin@basho.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
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: ufw
|
||||
|
@ -25,9 +22,9 @@ description:
|
|||
- Manage firewall with UFW.
|
||||
version_added: 1.6
|
||||
author:
|
||||
- "Aleksey Ovcharenko (@ovcharenko)"
|
||||
- "Jarno Keskikangas (@pyykkis)"
|
||||
- "Ahti Kitsik (@ahtik)"
|
||||
- Aleksey Ovcharenko (@ovcharenko)
|
||||
- Jarno Keskikangas (@pyykkis)
|
||||
- Ahti Kitsik (@ahtik)
|
||||
notes:
|
||||
- See C(man ufw) for more examples.
|
||||
requirements:
|
||||
|
@ -39,99 +36,82 @@ options:
|
|||
- C(disabled) unloads firewall and disables firewall on boot.
|
||||
- C(reloaded) reloads firewall.
|
||||
- C(reset) disables and resets firewall to installation defaults.
|
||||
required: false
|
||||
choices: ['enabled', 'disabled', 'reloaded', 'reset']
|
||||
choices: [ disabled, enabled, reloaded, reset ]
|
||||
policy:
|
||||
description:
|
||||
- Change the default policy for incoming or outgoing traffic.
|
||||
required: false
|
||||
aliases: ['default']
|
||||
choices: ['allow', 'deny', 'reject']
|
||||
aliases: [ default ]
|
||||
choices: [ allow, deny, reject ]
|
||||
direction:
|
||||
description:
|
||||
- Select direction for a rule or default policy command.
|
||||
required: false
|
||||
choices: ['in', 'out', 'incoming', 'outgoing', 'routed']
|
||||
choices: [ in, incoming, out, outgoing, routed ]
|
||||
logging:
|
||||
description:
|
||||
- Toggles logging. Logged packets use the LOG_KERN syslog facility.
|
||||
choices: ['on', 'off', 'low', 'medium', 'high', 'full']
|
||||
required: false
|
||||
choices: [ on, off, low, medium, high, full ]
|
||||
insert:
|
||||
description:
|
||||
- Insert the corresponding rule as rule number NUM
|
||||
required: false
|
||||
rule:
|
||||
description:
|
||||
- Add firewall rule
|
||||
required: false
|
||||
choices: ['allow', 'deny', 'reject', 'limit']
|
||||
choices: ['allow', 'deny', 'limit', 'reject']
|
||||
log:
|
||||
description:
|
||||
- Log new connections matched to this rule
|
||||
required: false
|
||||
choices: ['yes', 'no']
|
||||
type: bool
|
||||
from_ip:
|
||||
description:
|
||||
- Source IP address.
|
||||
required: false
|
||||
aliases: ['from', 'src']
|
||||
default: 'any'
|
||||
aliases: [ from, src ]
|
||||
default: any
|
||||
from_port:
|
||||
description:
|
||||
- Source port.
|
||||
required: false
|
||||
to_ip:
|
||||
description:
|
||||
- Destination IP address.
|
||||
required: false
|
||||
aliases: ['to', 'dest']
|
||||
default: 'any'
|
||||
aliases: [ dest, to]
|
||||
default: any
|
||||
to_port:
|
||||
description:
|
||||
- Destination port.
|
||||
required: false
|
||||
aliases: ['port']
|
||||
aliases: [ port ]
|
||||
proto:
|
||||
description:
|
||||
- TCP/IP protocol.
|
||||
choices: ['any', 'tcp', 'udp', 'ipv6', 'esp', 'ah']
|
||||
required: false
|
||||
choices: [ any, tcp, udp, ipv6, esp, ah ]
|
||||
name:
|
||||
description:
|
||||
- Use profile located in C(/etc/ufw/applications.d)
|
||||
required: false
|
||||
aliases: ['app']
|
||||
- Use profile located in C(/etc/ufw/applications.d).
|
||||
aliases: [ app ]
|
||||
delete:
|
||||
description:
|
||||
- Delete rule.
|
||||
required: false
|
||||
choices: ['yes', 'no']
|
||||
type: bool
|
||||
interface:
|
||||
description:
|
||||
- Specify interface for rule.
|
||||
required: false
|
||||
aliases: ['if']
|
||||
aliases: [ if ]
|
||||
route:
|
||||
description:
|
||||
- Apply the rule to routed/forwarded packets.
|
||||
required: false
|
||||
choices: ['yes', 'no']
|
||||
type: bool
|
||||
comment:
|
||||
description:
|
||||
- Add a comment to the rule. Requires UFW version >=0.35.
|
||||
required: false
|
||||
version_added: "2.4"
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Allow everything and enable UFW
|
||||
- ufw:
|
||||
- name: Allow everything and enable UFW
|
||||
ufw:
|
||||
state: enabled
|
||||
policy: allow
|
||||
|
||||
# Set logging
|
||||
- ufw:
|
||||
- name: Set logging
|
||||
ufw:
|
||||
logging: on
|
||||
|
||||
# Sometimes it is desirable to let the sender know when traffic is
|
||||
|
@ -159,30 +139,30 @@ EXAMPLES = '''
|
|||
rule: allow
|
||||
name: OpenSSH
|
||||
|
||||
# Delete OpenSSH rule
|
||||
- ufw:
|
||||
- name: Delete OpenSSH rule
|
||||
ufw:
|
||||
rule: allow
|
||||
name: OpenSSH
|
||||
delete: yes
|
||||
|
||||
# Deny all access to port 53:
|
||||
- ufw:
|
||||
- name: Deny all access to port 53
|
||||
ufw:
|
||||
rule: deny
|
||||
port: 53
|
||||
|
||||
# Allow port range 60000-61000
|
||||
- ufw:
|
||||
- name: Allow port range 60000-61000
|
||||
ufw:
|
||||
rule: allow
|
||||
port: '60000:61000'
|
||||
port: 60000:61000
|
||||
|
||||
# Allow all access to tcp port 80:
|
||||
- ufw:
|
||||
- name: Allow all access to tcp port 80
|
||||
ufw:
|
||||
rule: allow
|
||||
port: 80
|
||||
proto: tcp
|
||||
|
||||
# Allow all access from RFC1918 networks to this host:
|
||||
- ufw:
|
||||
- name: Allow all access from RFC1918 networks to this host
|
||||
ufw:
|
||||
rule: allow
|
||||
src: '{{ item }}'
|
||||
with_items:
|
||||
|
@ -190,16 +170,16 @@ EXAMPLES = '''
|
|||
- 172.16.0.0/12
|
||||
- 192.168.0.0/16
|
||||
|
||||
# Deny access to udp port 514 from host 1.2.3.4 and include a comment:
|
||||
- ufw:
|
||||
- name: Deny access to udp port 514 from host 1.2.3.4 and include a comment
|
||||
ufw:
|
||||
rule: deny
|
||||
proto: udp
|
||||
src: 1.2.3.4
|
||||
port: 514
|
||||
comment: "Block syslog"
|
||||
comment: Block syslog
|
||||
|
||||
# Allow incoming access to eth0 from 1.2.3.5 port 5469 to 1.2.3.4 port 5469
|
||||
- ufw:
|
||||
- name: Allow incoming access to eth0 from 1.2.3.5 port 5469 to 1.2.3.4 port 5469
|
||||
ufw:
|
||||
rule: allow
|
||||
interface: eth0
|
||||
direction: in
|
||||
|
@ -209,17 +189,17 @@ EXAMPLES = '''
|
|||
dest: 1.2.3.4
|
||||
to_port: 5469
|
||||
|
||||
# Deny all traffic from the IPv6 2001:db8::/32 to tcp port 25 on this host.
|
||||
# Note that IPv6 must be enabled in /etc/default/ufw for IPv6 firewalling to work.
|
||||
- ufw:
|
||||
- name: Deny all traffic from the IPv6 2001:db8::/32 to tcp port 25 on this host
|
||||
ufw:
|
||||
rule: deny
|
||||
proto: tcp
|
||||
src: '2001:db8::/32'
|
||||
src: 2001:db8::/32
|
||||
port: 25
|
||||
|
||||
# Deny forwarded/routed traffic from subnet 1.2.3.0/24 to subnet 4.5.6.0/24.
|
||||
# Can be used to further restrict a global FORWARD policy set to allow
|
||||
- ufw:
|
||||
- name: Deny forwarded/routed traffic from subnet 1.2.3.0/24 to subnet 4.5.6.0/24
|
||||
ufw:
|
||||
rule: deny
|
||||
route: yes
|
||||
src: 1.2.3.0/24
|
||||
|
@ -235,26 +215,28 @@ from ansible.module_utils.basic import AnsibleModule
|
|||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
state = dict(default=None, choices=['enabled', 'disabled', 'reloaded', 'reset']),
|
||||
default = dict(default=None, aliases=['policy'], choices=['allow', 'deny', 'reject']),
|
||||
logging = dict(default=None, choices=['on', 'off', 'low', 'medium', 'high', 'full']),
|
||||
direction = dict(default=None, choices=['in', 'incoming', 'out', 'outgoing', 'routed']),
|
||||
delete = dict(default=False, type='bool'),
|
||||
route = dict(default=False, type='bool'),
|
||||
insert = dict(default=None),
|
||||
rule = dict(default=None, choices=['allow', 'deny', 'reject', 'limit']),
|
||||
interface = dict(default=None, aliases=['if']),
|
||||
log = dict(default=False, type='bool'),
|
||||
from_ip = dict(default='any', aliases=['src', 'from']),
|
||||
from_port = dict(default=None),
|
||||
to_ip = dict(default='any', aliases=['dest', 'to']),
|
||||
to_port = dict(default=None, aliases=['port']),
|
||||
proto = dict(default=None, aliases=['protocol'], choices=['any', 'tcp', 'udp', 'ipv6', 'esp', 'ah']),
|
||||
app = dict(default=None, aliases=['name']),
|
||||
comment = dict(default=None, type='str')
|
||||
state=dict(type='str', choices=['enabled', 'disabled', 'reloaded', 'reset']),
|
||||
default=dict(type='str', aliases=['policy'], choices=['allow', 'deny', 'reject']),
|
||||
logging=dict(type='str', choices=['full', 'high', 'low', 'medium', 'off', 'on']),
|
||||
direction=dict(type='str', choices=['in', 'incoming', 'out', 'outgoing', 'routed']),
|
||||
delete=dict(type='bool', default=False),
|
||||
route=dict(type='bool', default=False),
|
||||
insert=dict(type='str'),
|
||||
rule=dict(type='str', choices=['allow', 'deny', 'limit', 'reject']),
|
||||
interface=dict(type='str', aliases=['if']),
|
||||
log=dict(type='bool', default=False),
|
||||
from_ip=dict(type='str', default='any', aliases=['from', 'src']),
|
||||
from_port=dict(type='str'),
|
||||
to_ip=dict(type='str', default='any', aliases=['dest', 'to']),
|
||||
to_port=dict(type='str', aliases=['port']),
|
||||
proto=dict(type='str', aliases=['protocol'], choices=['ah', 'any', 'esp', 'ipv6', 'tcp', 'udp']),
|
||||
app=dict(type='str', aliases=['name']),
|
||||
comment=dict(type='str'),
|
||||
),
|
||||
supports_check_mode=True,
|
||||
mutually_exclusive = [['app', 'proto', 'logging']]
|
||||
mutually_exclusive=[
|
||||
['app', 'proto', 'logging']
|
||||
],
|
||||
)
|
||||
|
||||
cmds = []
|
||||
|
@ -346,7 +328,6 @@ def main():
|
|||
for (key, template) in [('from_ip', "from %s"), ('from_port', "port %s"),
|
||||
('to_ip', "to %s"), ('to_port', "port %s"),
|
||||
('proto', "proto %s"), ('app', "app '%s'")]:
|
||||
|
||||
value = params[key]
|
||||
cmd.append([value, template % (value)])
|
||||
|
||||
|
|
|
@ -1093,8 +1093,6 @@ class OpenBSDUser(User):
|
|||
return self.execute_command(cmd)
|
||||
|
||||
|
||||
# ===========================================
|
||||
|
||||
class NetBSDUser(User):
|
||||
"""
|
||||
This is a NetBSD User manipulation class.
|
||||
|
@ -1250,8 +1248,6 @@ class NetBSDUser(User):
|
|||
return self.execute_command(cmd)
|
||||
|
||||
|
||||
# ===========================================
|
||||
|
||||
class SunOS(User):
|
||||
"""
|
||||
This is a SunOS User manipulation class - The main difference between
|
||||
|
@ -2242,6 +2238,7 @@ def main():
|
|||
|
||||
module.exit_json(**result)
|
||||
|
||||
|
||||
# import module snippets
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -321,26 +321,3 @@ lib/ansible/modules/system/aix_inittab.py
|
|||
lib/ansible/modules/system/capabilities.py
|
||||
lib/ansible/modules/system/cronvar.py
|
||||
lib/ansible/modules/system/crypttab.py
|
||||
lib/ansible/modules/system/debconf.py
|
||||
lib/ansible/modules/system/facter.py
|
||||
lib/ansible/modules/system/filesystem.py
|
||||
lib/ansible/modules/system/gconftool2.py
|
||||
lib/ansible/modules/system/gluster_volume.py
|
||||
lib/ansible/modules/system/group.py
|
||||
lib/ansible/modules/system/java_cert.py
|
||||
lib/ansible/modules/system/kernel_blacklist.py
|
||||
lib/ansible/modules/system/locale_gen.py
|
||||
lib/ansible/modules/system/lvg.py
|
||||
lib/ansible/modules/system/lvol.py
|
||||
lib/ansible/modules/system/ohai.py
|
||||
lib/ansible/modules/system/open_iscsi.py
|
||||
lib/ansible/modules/system/openwrt_init.py
|
||||
lib/ansible/modules/system/osx_defaults.py
|
||||
lib/ansible/modules/system/pam_limits.py
|
||||
lib/ansible/modules/system/puppet.py
|
||||
lib/ansible/modules/system/runit.py
|
||||
lib/ansible/modules/system/seport.py
|
||||
lib/ansible/modules/system/solaris_zone.py
|
||||
lib/ansible/modules/system/svc.py
|
||||
lib/ansible/modules/system/timezone.py
|
||||
lib/ansible/modules/system/ufw.py
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue