mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
Remove wildcard imports
Made the following changes: * Removed wildcard imports * Replaced long form of GPL header with short form * Removed get_exception usage * Added from __future__ boilerplate * Adjust division operator to // where necessary For the following files: * web_infrastructure modules * system modules * linode, lxc, lxd, atomic, cloudscale, dimensiondata, ovh, packet, profitbricks, pubnub, smartos, softlayer, univention modules * compat dirs (disabled as its used intentionally)
This commit is contained in:
parent
f6d7fc548e
commit
4e6cce354e
185 changed files with 1657 additions and 3459 deletions
|
@ -2,22 +2,12 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2017, Joris Weijters <joris.weijters@gmail.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# 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.0',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
|
|
|
@ -2,21 +2,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2016, Alain Dejoux <adejoux@djouxtech.net>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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 = {'status': ['preview'],
|
||||
'supported_by': 'community',
|
||||
|
|
|
@ -1,26 +1,13 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Ansible module to manage symbolic link alternatives.
|
||||
(c) 2014, Gabe Mulley <gabe.mulley@gmail.com>
|
||||
(c) 2015, David Wittman <dwittman@gmail.com>
|
||||
# (c) 2014, Gabe Mulley <gabe.mulley@gmail.com>
|
||||
# (c) 2015, David Wittman <dwittman@gmail.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
This file is part of Ansible
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
Ansible is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Ansible is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.0',
|
||||
'status': ['preview'],
|
||||
|
|
|
@ -2,21 +2,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# (c) 2014, Richard Isaacson <richard.c.isaacson@gmail.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
'status': ['preview'],
|
||||
|
@ -90,6 +80,8 @@ EXAMPLES = '''
|
|||
import os
|
||||
import tempfile
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
|
||||
def add_job(module, result, at_cmd, count, units, command, script_file):
|
||||
at_command = "%s -f %s now + %s %s" % (at_cmd, script_file, count, units)
|
||||
|
@ -209,8 +201,6 @@ def main():
|
|||
|
||||
module.exit_json(**result)
|
||||
|
||||
# import module snippets
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -1,25 +1,12 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Ansible module to add authorized_keys for ssh logins.
|
||||
(c) 2012, Brad Olson <brado@movedbylight.com>
|
||||
# (c) 2012, Brad Olson <brado@movedbylight.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
This file is part of Ansible
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
Ansible is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Ansible is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.0',
|
||||
'status': ['preview'],
|
||||
|
|
|
@ -2,21 +2,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# (c) 2017, Ted Trask <ttrask01@yahoo.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# This module is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This software is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this software. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
'status': ['stableinterface'],
|
||||
|
|
|
@ -2,22 +2,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2016, Adam Števko <adam.stevko@gmail.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# 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.0',
|
||||
'status': ['preview'],
|
||||
|
|
|
@ -2,22 +2,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2014, Nate Coraor <nate@bx.psu.edu>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# 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.0',
|
||||
'status': ['preview'],
|
||||
|
@ -72,14 +61,11 @@ EXAMPLES = '''
|
|||
state: absent
|
||||
'''
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
|
||||
OPS = ( '=', '-', '+' )
|
||||
|
||||
# ==============================================================
|
||||
|
||||
import os
|
||||
import tempfile
|
||||
import re
|
||||
|
||||
class CapabilitiesModule(object):
|
||||
|
||||
|
@ -192,8 +178,5 @@ def main():
|
|||
CapabilitiesModule(module)
|
||||
|
||||
|
||||
# import module snippets
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -7,29 +7,11 @@
|
|||
# (c) 2015, Evan Kaufman <evan@digitalflophouse.com>
|
||||
# (c) 2015, Luca Berruti <nadirio@gmail.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Cron Plugin: The goal of this plugin is to provide an idempotent method for
|
||||
# setting up cron jobs on a host. The script will play well with other manually
|
||||
# entered crons. Each cron job entered will be preceded with a comment
|
||||
# describing the job so that it can be found later, which is required to be
|
||||
# present in order for this plugin to find/modify the job.
|
||||
#
|
||||
# This module is based on python-crontab by Martin Owens.
|
||||
#
|
||||
# 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.0',
|
||||
'status': ['preview'],
|
||||
|
@ -235,17 +217,23 @@ EXAMPLES = '''
|
|||
'''
|
||||
|
||||
import os
|
||||
import pwd
|
||||
import re
|
||||
import tempfile
|
||||
import platform
|
||||
import pipes
|
||||
import pwd
|
||||
import re
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule, get_platform
|
||||
|
||||
|
||||
CRONCMD = "/usr/bin/crontab"
|
||||
|
||||
|
||||
class CronTabError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class CronTab(object):
|
||||
"""
|
||||
CronTab object to write time based crontab file
|
||||
|
@ -785,8 +773,6 @@ def main():
|
|||
# --- should never get here
|
||||
module.exit_json(msg="Unable to execute cron task.")
|
||||
|
||||
# import module snippets
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -3,18 +3,8 @@
|
|||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
#
|
||||
# Cronvar Plugin: The goal of this plugin is to provide an idempotent
|
||||
# method for set cron variable values. It should play well with the
|
||||
|
@ -26,6 +16,10 @@
|
|||
# This module is based on the crontab module.
|
||||
#
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.0',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
|
@ -113,19 +107,24 @@ EXAMPLES = '''
|
|||
'''
|
||||
|
||||
import os
|
||||
import re
|
||||
import tempfile
|
||||
import platform
|
||||
import pipes
|
||||
import platform
|
||||
import pwd
|
||||
import re
|
||||
import shlex
|
||||
from ansible.module_utils.basic import *
|
||||
from ansible.module_utils.pycompat24 import get_exception
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
|
||||
CRONCMD = "/usr/bin/crontab"
|
||||
|
||||
|
||||
class CronVarError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class CronVar(object):
|
||||
"""
|
||||
CronVar object to write variables to crontabs.
|
||||
|
@ -160,7 +159,6 @@ class CronVar(object):
|
|||
self.lines = f.read().splitlines()
|
||||
f.close()
|
||||
except IOError:
|
||||
e = get_exception()
|
||||
# cron file does not exist
|
||||
return
|
||||
except:
|
||||
|
@ -217,7 +215,6 @@ class CronVar(object):
|
|||
os.unlink(self.cron_file)
|
||||
return True
|
||||
except OSError:
|
||||
e = get_exception()
|
||||
# cron file does not exist
|
||||
return False
|
||||
except:
|
||||
|
@ -234,7 +231,6 @@ class CronVar(object):
|
|||
raise CronVarError("Not a variable.")
|
||||
|
||||
def find_variable(self, name):
|
||||
comment = None
|
||||
for l in self.lines:
|
||||
try:
|
||||
(varname, value) = self.parse_for_var(l)
|
||||
|
@ -436,9 +432,6 @@ def main():
|
|||
|
||||
module.exit_json(**res_args)
|
||||
|
||||
# --- should never get here
|
||||
module.exit_json(msg="Unable to execute cronvar task.")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -2,21 +2,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2014, Steve <yo@groks.org>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
'status': ['preview'],
|
||||
|
@ -95,8 +85,11 @@ EXAMPLES = '''
|
|||
when: "'/dev/mapper/luks-' in {{ item.device }}"
|
||||
'''
|
||||
|
||||
from ansible.module_utils.basic import *
|
||||
from ansible.module_utils.pycompat24 import get_exception
|
||||
import os
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
def main():
|
||||
|
||||
|
@ -142,10 +135,9 @@ def main():
|
|||
try:
|
||||
crypttab = Crypttab(path)
|
||||
existing_line = crypttab.match(name)
|
||||
except Exception:
|
||||
e = get_exception()
|
||||
module.fail_json(msg="failed to open and parse crypttab file: %s" % e,
|
||||
**module.params)
|
||||
except Exception as e:
|
||||
module.fail_json(msg="failed to open and parse crypttab file: %s" % to_native(e),
|
||||
exception=traceback.format_exc(), **module.params)
|
||||
|
||||
if 'present' in state and existing_line is None and backing_device is None:
|
||||
module.fail_json(msg="'backing_device' required to add a new entry",
|
||||
|
@ -375,5 +367,6 @@ class Options(dict):
|
|||
ret.append('%s=%s' % (k, v))
|
||||
return ','.join(ret)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -2,21 +2,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2017, Branko Majic <branko@majic.rs>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
'status': ['preview'],
|
||||
|
|
|
@ -1,25 +1,12 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Ansible module to configure .deb packages.
|
||||
(c) 2014, Brian Coca <briancoca+ansible@gmail.com>
|
||||
# (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)
|
||||
|
||||
This file is part of Ansible
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
Ansible is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Ansible is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.0',
|
||||
'status': ['stableinterface'],
|
||||
|
@ -103,6 +90,9 @@ EXAMPLES = '''
|
|||
name: tzdata
|
||||
'''
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
|
||||
def get_selections(module, pkg):
|
||||
cmd = [module.get_bin_path('debconf-show', True), pkg]
|
||||
rc, out, err = module.run_command(' '.join(cmd))
|
||||
|
@ -191,8 +181,6 @@ def main():
|
|||
|
||||
module.exit_json(changed=changed, msg=msg, current=prev)
|
||||
|
||||
# import module snippets
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -2,22 +2,10 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# 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.0',
|
||||
|
@ -46,6 +34,10 @@ EXAMPLES = '''
|
|||
# Example command-line invocation
|
||||
ansible www.example.net -m facter
|
||||
'''
|
||||
import json
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
|
@ -59,8 +51,6 @@ def main():
|
|||
rc, out, err = module.run_command(cmd, check_rc=True)
|
||||
module.exit_json(**json.loads(out))
|
||||
|
||||
# import module snippets
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -2,21 +2,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2013, Alexander Bulimov <lazywolf0@gmail.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
'status': ['preview'],
|
||||
|
@ -73,6 +63,10 @@ EXAMPLES = '''
|
|||
dev: /dev/sdb1
|
||||
opts: -cc
|
||||
'''
|
||||
import os
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
|
||||
def _get_dev_size(dev, module):
|
||||
""" Return size in bytes of device. Returns int """
|
||||
|
@ -264,7 +258,6 @@ def main():
|
|||
|
||||
module.exit_json(changed=changed)
|
||||
|
||||
# import module snippets
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -2,21 +2,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2013, Adam Miller (maxamillion@fedoraproject.org)
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
'status': ['preview'],
|
||||
|
|
|
@ -3,20 +3,11 @@
|
|||
# (c) 2016, Kenneth D. Evensen <kevensen@redhat.com>
|
||||
# (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
|
||||
#
|
||||
# This file is part of Ansible (sort of)
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
'status': ['preview'],
|
||||
|
|
|
@ -3,21 +3,10 @@
|
|||
|
||||
# (c) 2014, Brian Coca <brian.coca+dev@gmail.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# 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.0',
|
||||
|
@ -100,9 +89,11 @@ EXAMPLES = '''
|
|||
var: getent_shadow
|
||||
|
||||
'''
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
from ansible.module_utils.basic import *
|
||||
from ansible.module_utils.pycompat24 import get_exception
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
|
@ -134,9 +125,8 @@ def main():
|
|||
|
||||
try:
|
||||
rc, out, err = module.run_command(cmd)
|
||||
except Exception:
|
||||
e = get_exception()
|
||||
module.fail_json(msg=str(e))
|
||||
except Exception as e:
|
||||
module.fail_json(msg=to_native(e), exception=traceback.format_exc())
|
||||
|
||||
msg = "Unexpected failure!"
|
||||
dbtree = 'getent_%s' % database
|
||||
|
|
|
@ -2,21 +2,10 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2014, Taneli Leppä <taneli@crasman.fi>
|
||||
#
|
||||
# This file is part of Ansible (sort of)
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
|
@ -182,14 +171,18 @@ EXAMPLES = """
|
|||
run_once: true
|
||||
"""
|
||||
|
||||
import shutil
|
||||
import time
|
||||
import re
|
||||
import socket
|
||||
from ansible.module_utils.pycompat24 import get_exception
|
||||
from ansible.module_utils.basic import *
|
||||
import time
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
|
||||
glusterbin = ''
|
||||
|
||||
|
||||
def run_gluster(gargs, **kwargs):
|
||||
global glusterbin
|
||||
global module
|
||||
|
@ -198,10 +191,11 @@ def run_gluster(gargs, **kwargs):
|
|||
try:
|
||||
rc, out, err = module.run_command(args, **kwargs)
|
||||
if rc != 0:
|
||||
module.fail_json(msg='error running gluster (%s) command (rc=%d): %s' % (' '.join(args), rc, out or err))
|
||||
except Exception:
|
||||
e = get_exception()
|
||||
module.fail_json(msg='error running gluster (%s) command: %s' % (' '.join(args), str(e)))
|
||||
module.fail_json(msg='error running gluster (%s) command (rc=%d): %s' %
|
||||
(' '.join(args), rc, out or err), exception=traceback.format_exc())
|
||||
except Exception as e:
|
||||
module.fail_json(msg='error running gluster (%s) command: %s' % (' '.join(args),
|
||||
to_native(e)), exception=traceback.format_exc())
|
||||
return out
|
||||
|
||||
def run_gluster_nofail(gargs, **kwargs):
|
||||
|
@ -226,7 +220,6 @@ def run_gluster_yes(gargs):
|
|||
|
||||
def get_peers():
|
||||
out = run_gluster([ 'peer', 'status'])
|
||||
i = 0
|
||||
peers = {}
|
||||
hostname = None
|
||||
uuid = None
|
||||
|
@ -319,7 +312,6 @@ def probe(host, myhostname):
|
|||
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))
|
||||
changed = True
|
||||
|
||||
def probe_all_peers(hosts, peers, myhostname):
|
||||
for host in hosts:
|
||||
|
@ -543,5 +535,6 @@ def main():
|
|||
|
||||
module.exit_json(changed=changed, ansible_facts=facts)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -2,21 +2,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2012, Stephen Fromm <sfromm@gmail.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
'status': ['stableinterface'],
|
||||
|
@ -66,7 +56,9 @@ EXAMPLES = '''
|
|||
'''
|
||||
|
||||
import grp
|
||||
import platform
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule, load_platform_subclass
|
||||
|
||||
|
||||
class Group(object):
|
||||
"""
|
||||
|
@ -355,7 +347,6 @@ class OpenBsdGroup(Group):
|
|||
def group_mod(self, **kwargs):
|
||||
cmd = [self.module.get_bin_path('groupmod', True)]
|
||||
info = self.group_info()
|
||||
cmd_len = len(cmd)
|
||||
if self.gid is not None and int(self.gid) != info[2]:
|
||||
cmd.append('-g')
|
||||
cmd.append('%d' % int(self.gid))
|
||||
|
@ -397,7 +388,6 @@ class NetBsdGroup(Group):
|
|||
def group_mod(self, **kwargs):
|
||||
cmd = [self.module.get_bin_path('groupmod', True)]
|
||||
info = self.group_info()
|
||||
cmd_len = len(cmd)
|
||||
if self.gid is not None and int(self.gid) != info[2]:
|
||||
cmd.append('-g')
|
||||
cmd.append('%d' % int(self.gid))
|
||||
|
@ -471,8 +461,6 @@ def main():
|
|||
|
||||
module.exit_json(**result)
|
||||
|
||||
# import module snippets
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -2,21 +2,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2013, Hiroaki Nakamura <hnakamur@gmail.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
'status': ['preview'],
|
||||
|
@ -48,13 +38,19 @@ EXAMPLES = '''
|
|||
name: web01
|
||||
'''
|
||||
|
||||
import os
|
||||
import socket
|
||||
import traceback
|
||||
from distutils.version import LooseVersion
|
||||
|
||||
# import module snippets
|
||||
from ansible.module_utils.basic import *
|
||||
from ansible.module_utils.basic import (AnsibleModule,
|
||||
get_distribution,
|
||||
get_distribution_version,
|
||||
get_platform,
|
||||
load_platform_subclass,
|
||||
)
|
||||
from ansible.module_utils.facts.system.service_mgr import ServiceMgrFactCollector
|
||||
from ansible.module_utils._text import to_bytes, to_native
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
|
||||
class UnimplementedStrategy(object):
|
||||
|
@ -203,20 +199,18 @@ class DebianStrategy(GenericStrategy):
|
|||
if not os.path.isfile(self.HOSTNAME_FILE):
|
||||
try:
|
||||
open(self.HOSTNAME_FILE, "a").write("")
|
||||
except IOError:
|
||||
err = get_exception()
|
||||
except IOError as e:
|
||||
self.module.fail_json(msg="failed to write file: %s" %
|
||||
str(err))
|
||||
to_native(e), exception=traceback.format_exc())
|
||||
try:
|
||||
f = open(self.HOSTNAME_FILE)
|
||||
try:
|
||||
return f.read().strip()
|
||||
finally:
|
||||
f.close()
|
||||
except Exception:
|
||||
err = get_exception()
|
||||
except Exception as e:
|
||||
self.module.fail_json(msg="failed to read hostname: %s" %
|
||||
str(err))
|
||||
to_native(e), exception=traceback.format_exc())
|
||||
|
||||
def set_permanent_hostname(self, name):
|
||||
try:
|
||||
|
@ -225,10 +219,9 @@ class DebianStrategy(GenericStrategy):
|
|||
f.write("%s\n" % name)
|
||||
finally:
|
||||
f.close()
|
||||
except Exception:
|
||||
err = get_exception()
|
||||
except Exception as e:
|
||||
self.module.fail_json(msg="failed to update hostname: %s" %
|
||||
str(err))
|
||||
to_native(e), exception=traceback.format_exc())
|
||||
|
||||
# ===========================================
|
||||
|
||||
|
@ -243,20 +236,18 @@ class SLESStrategy(GenericStrategy):
|
|||
if not os.path.isfile(self.HOSTNAME_FILE):
|
||||
try:
|
||||
open(self.HOSTNAME_FILE, "a").write("")
|
||||
except IOError:
|
||||
err = get_exception()
|
||||
except IOError as e:
|
||||
self.module.fail_json(msg="failed to write file: %s" %
|
||||
str(err))
|
||||
to_native(e), exception=traceback.format_exc())
|
||||
try:
|
||||
f = open(self.HOSTNAME_FILE)
|
||||
try:
|
||||
return f.read().strip()
|
||||
finally:
|
||||
f.close()
|
||||
except Exception:
|
||||
err = get_exception()
|
||||
except Exception as e:
|
||||
self.module.fail_json(msg="failed to read hostname: %s" %
|
||||
str(err))
|
||||
to_native(e), exception=traceback.format_exc())
|
||||
|
||||
def set_permanent_hostname(self, name):
|
||||
try:
|
||||
|
@ -265,10 +256,9 @@ class SLESStrategy(GenericStrategy):
|
|||
f.write("%s\n" % name)
|
||||
finally:
|
||||
f.close()
|
||||
except Exception:
|
||||
err = get_exception()
|
||||
except Exception as e:
|
||||
self.module.fail_json(msg="failed to update hostname: %s" %
|
||||
str(err))
|
||||
to_native(e), exception=traceback.format_exc())
|
||||
|
||||
# ===========================================
|
||||
|
||||
|
@ -289,10 +279,9 @@ class RedHatStrategy(GenericStrategy):
|
|||
return v.strip()
|
||||
finally:
|
||||
f.close()
|
||||
except Exception:
|
||||
err = get_exception()
|
||||
except Exception as e:
|
||||
self.module.fail_json(msg="failed to read hostname: %s" %
|
||||
str(err))
|
||||
to_native(e), exception=traceback.format_exc())
|
||||
|
||||
def set_permanent_hostname(self, name):
|
||||
try:
|
||||
|
@ -315,10 +304,9 @@ class RedHatStrategy(GenericStrategy):
|
|||
f.writelines(lines)
|
||||
finally:
|
||||
f.close()
|
||||
except Exception:
|
||||
err = get_exception()
|
||||
except Exception as e:
|
||||
self.module.fail_json(msg="failed to update hostname: %s" %
|
||||
str(err))
|
||||
to_native(e), exception=traceback.format_exc())
|
||||
|
||||
# ===========================================
|
||||
|
||||
|
@ -339,20 +327,18 @@ class AlpineStrategy(GenericStrategy):
|
|||
if not os.path.isfile(self.HOSTNAME_FILE):
|
||||
try:
|
||||
open(self.HOSTNAME_FILE, "a").write("")
|
||||
except IOError:
|
||||
err = get_exception()
|
||||
except IOError as e:
|
||||
self.module.fail_json(msg="failed to write file: %s" %
|
||||
str(err))
|
||||
to_native(e), exception=traceback.format_exc())
|
||||
try:
|
||||
f = open(self.HOSTNAME_FILE)
|
||||
try:
|
||||
return f.read().strip()
|
||||
finally:
|
||||
f.close()
|
||||
except Exception:
|
||||
err = get_exception()
|
||||
except Exception as e:
|
||||
self.module.fail_json(msg="failed to read hostname: %s" %
|
||||
str(err))
|
||||
to_native(e), exception=traceback.format_exc())
|
||||
|
||||
def set_permanent_hostname(self, name):
|
||||
try:
|
||||
|
@ -361,10 +347,9 @@ class AlpineStrategy(GenericStrategy):
|
|||
f.write("%s\n" % name)
|
||||
finally:
|
||||
f.close()
|
||||
except Exception:
|
||||
err = get_exception()
|
||||
except Exception as e:
|
||||
self.module.fail_json(msg="failed to update hostname: %s" %
|
||||
str(err))
|
||||
to_native(e), exception=traceback.format_exc())
|
||||
|
||||
def set_current_hostname(self, name):
|
||||
cmd = [self.hostname_cmd, '-F', self.HOSTNAME_FILE]
|
||||
|
@ -440,9 +425,9 @@ class OpenRCStrategy(GenericStrategy):
|
|||
line = line.strip()
|
||||
if line.startswith('hostname='):
|
||||
return line[10:].strip('"')
|
||||
except Exception:
|
||||
err = get_exception()
|
||||
self.module.fail_json(msg="failed to read hostname: %s" % str(err))
|
||||
except Exception as e:
|
||||
self.module.fail_json(msg="failed to read hostname: %s" %
|
||||
to_native(e), exception=traceback.format_exc())
|
||||
finally:
|
||||
f.close()
|
||||
|
||||
|
@ -462,9 +447,9 @@ class OpenRCStrategy(GenericStrategy):
|
|||
|
||||
f = open(self.HOSTNAME_FILE, 'w')
|
||||
f.write('\n'.join(lines) + '\n')
|
||||
except Exception:
|
||||
err = get_exception()
|
||||
self.module.fail_json(msg="failed to update hostname: %s" % str(err))
|
||||
except Exception as e:
|
||||
self.module.fail_json(msg="failed to update hostname: %s" %
|
||||
to_native(e), exception=traceback.format_exc())
|
||||
finally:
|
||||
f.close()
|
||||
|
||||
|
@ -482,20 +467,18 @@ class OpenBSDStrategy(GenericStrategy):
|
|||
if not os.path.isfile(self.HOSTNAME_FILE):
|
||||
try:
|
||||
open(self.HOSTNAME_FILE, "a").write("")
|
||||
except IOError:
|
||||
err = get_exception()
|
||||
except IOError as e:
|
||||
self.module.fail_json(msg="failed to write file: %s" %
|
||||
str(err))
|
||||
to_native(e), exception=traceback.format_exc())
|
||||
try:
|
||||
f = open(self.HOSTNAME_FILE)
|
||||
try:
|
||||
return f.read().strip()
|
||||
finally:
|
||||
f.close()
|
||||
except Exception:
|
||||
err = get_exception()
|
||||
except Exception as e:
|
||||
self.module.fail_json(msg="failed to read hostname: %s" %
|
||||
str(err))
|
||||
to_native(e), exception=traceback.format_exc())
|
||||
|
||||
def set_permanent_hostname(self, name):
|
||||
try:
|
||||
|
@ -504,10 +487,9 @@ class OpenBSDStrategy(GenericStrategy):
|
|||
f.write("%s\n" % name)
|
||||
finally:
|
||||
f.close()
|
||||
except Exception:
|
||||
err = get_exception()
|
||||
except Exception as e:
|
||||
self.module.fail_json(msg="failed to update hostname: %s" %
|
||||
str(err))
|
||||
to_native(e), exception=traceback.format_exc())
|
||||
|
||||
# ===========================================
|
||||
|
||||
|
@ -557,10 +539,9 @@ class FreeBSDStrategy(GenericStrategy):
|
|||
if not os.path.isfile(self.HOSTNAME_FILE):
|
||||
try:
|
||||
open(self.HOSTNAME_FILE, "a").write("hostname=temporarystub\n")
|
||||
except IOError:
|
||||
err = get_exception()
|
||||
except IOError as e:
|
||||
self.module.fail_json(msg="failed to write file: %s" %
|
||||
str(err))
|
||||
to_native(e), exception=traceback.format_exc())
|
||||
try:
|
||||
try:
|
||||
f = open(self.HOSTNAME_FILE, 'r')
|
||||
|
@ -568,9 +549,9 @@ class FreeBSDStrategy(GenericStrategy):
|
|||
line = line.strip()
|
||||
if line.startswith('hostname='):
|
||||
return line[10:].strip('"')
|
||||
except Exception:
|
||||
err = get_exception()
|
||||
self.module.fail_json(msg="failed to read hostname: %s" % str(err))
|
||||
except Exception as e:
|
||||
self.module.fail_json(msg="failed to read hostname: %s" %
|
||||
to_native(e), exception=traceback.format_exc())
|
||||
finally:
|
||||
f.close()
|
||||
|
||||
|
@ -590,9 +571,9 @@ class FreeBSDStrategy(GenericStrategy):
|
|||
|
||||
f = open(self.HOSTNAME_FILE, 'w')
|
||||
f.write('\n'.join(lines) + '\n')
|
||||
except Exception:
|
||||
err = get_exception()
|
||||
self.module.fail_json(msg="failed to update hostname: %s" % str(err))
|
||||
except Exception as e:
|
||||
self.module.fail_json(msg="failed to update hostname: %s" %
|
||||
to_native(e), exception=traceback.format_exc())
|
||||
finally:
|
||||
f.close()
|
||||
|
||||
|
@ -772,5 +753,6 @@ def main():
|
|||
ansible_fqdn=socket.getfqdn(),
|
||||
ansible_domain='.'.join(socket.getfqdn().split('.')[1:])))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -2,31 +2,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# (c) 2015, Linus Unnebäck <linus@folkdatorn.se>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# This module is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This software is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this software. If not, see <http://www.gnu.org/licenses/>.
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
BINS = dict(
|
||||
ipv4='iptables',
|
||||
ipv6='ip6tables',
|
||||
)
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
ICMP_TYPE_OPTIONS = dict(
|
||||
ipv4='--icmp-type',
|
||||
ipv6='--icmpv6-type',
|
||||
)
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.0',
|
||||
'status': ['preview'],
|
||||
|
@ -355,9 +335,20 @@ EXAMPLES = '''
|
|||
|
||||
import re
|
||||
|
||||
# import module snippets
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
|
||||
BINS = dict(
|
||||
ipv4='iptables',
|
||||
ipv6='ip6tables',
|
||||
)
|
||||
|
||||
ICMP_TYPE_OPTIONS = dict(
|
||||
ipv4='--icmp-type',
|
||||
ipv6='--icmpv6-type',
|
||||
)
|
||||
|
||||
|
||||
def append_param(rule, param, flag, is_list):
|
||||
if is_list:
|
||||
for item in param:
|
||||
|
|
|
@ -1,21 +1,11 @@
|
|||
#!/usr/bin/python
|
||||
#
|
||||
# (c) 2013, RSD Services S.A
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
'status': ['preview'],
|
||||
|
|
|
@ -2,21 +2,11 @@
|
|||
# encoding: utf-8 -*-
|
||||
|
||||
# (c) 2013, Matthias Vogelgesang <matthias.vogelgesang@gmail.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
'status': ['preview'],
|
||||
|
@ -61,6 +51,8 @@ EXAMPLES = '''
|
|||
import os
|
||||
import re
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
|
||||
class Blacklist(object):
|
||||
def __init__(self, module, filename, checkmode):
|
||||
|
@ -163,8 +155,6 @@ def main():
|
|||
|
||||
module.exit_json(**args)
|
||||
|
||||
# import module snippets
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -1,22 +1,11 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
"""
|
||||
Ansible module to manage the ssh known_hosts file.
|
||||
Copyright(c) 2014, Matthew Vernon <mcv21@cam.ac.uk>
|
||||
# Copyright(c) 2014, Matthew Vernon <mcv21@cam.ac.uk>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
This module is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
This module is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this module. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.0',
|
||||
'status': ['preview'],
|
||||
|
|
|
@ -1,20 +1,11 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
'status': ['preview'],
|
||||
|
|
|
@ -3,21 +3,11 @@
|
|||
|
||||
# (c) 2013, Alexander Bulimov <lazywolf0@gmail.com>
|
||||
# based on lvol module by Jeroen Hoekx <jeroen.hoekx@dsquare.be>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
'status': ['preview'],
|
||||
|
@ -90,6 +80,10 @@ EXAMPLES = '''
|
|||
vg: vg.services
|
||||
state: absent
|
||||
'''
|
||||
import os
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
|
||||
def parse_vgs(data):
|
||||
vgs = []
|
||||
|
@ -263,8 +257,6 @@ def main():
|
|||
|
||||
module.exit_json(changed=changed)
|
||||
|
||||
# import module snippets
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -2,21 +2,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2013, Jeroen Hoekx <jeroen.hoekx@dsquare.be>, Alexander Bulimov <lazywolf0@gmail.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
'status': ['preview'],
|
||||
|
@ -204,8 +194,12 @@ EXAMPLES = '''
|
|||
|
||||
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)
|
||||
|
||||
|
@ -493,8 +487,6 @@ def main():
|
|||
|
||||
module.exit_json(changed=changed, msg=msg)
|
||||
|
||||
# import module snippets
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -2,21 +2,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2015, Linus Unnebäck <linus@folkdatorn.se>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# This module is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This software is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this software. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
'status': ['preview'],
|
||||
|
|
|
@ -2,21 +2,10 @@
|
|||
#coding: utf-8 -*-
|
||||
|
||||
# (c) 2013, David Stygstra <david.stygstra@gmail.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# This module is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This software is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this software. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
|
@ -68,9 +57,11 @@ EXAMPLES = '''
|
|||
params: 'numdummies=2'
|
||||
'''
|
||||
|
||||
from ansible.module_utils.basic import *
|
||||
from ansible.module_utils.pycompat24 import get_exception
|
||||
import shlex
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
|
||||
def main():
|
||||
|
@ -100,9 +91,8 @@ def main():
|
|||
present = True
|
||||
break
|
||||
modules.close()
|
||||
except IOError:
|
||||
e = get_exception()
|
||||
module.fail_json(msg=str(e), **args)
|
||||
except IOError as e:
|
||||
module.fail_json(msg=to_native(e), exception=traceback.format_exc(), **args)
|
||||
|
||||
# Check only; don't modify
|
||||
if module.check_mode:
|
||||
|
@ -132,5 +122,6 @@ def main():
|
|||
|
||||
module.exit_json(**args)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -4,21 +4,10 @@
|
|||
# (c) 2012, Red Hat, inc
|
||||
# Written by Seth Vidal
|
||||
# based on the mount modules from salt and puppet
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
|
|
|
@ -2,22 +2,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# 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.0',
|
||||
'status': ['preview'],
|
||||
|
@ -46,6 +35,10 @@ EXAMPLES = '''
|
|||
# Retrieve (ohai) data from all Web servers and store in one-file per host
|
||||
ansible webservers -m ohai --tree=/tmp/ohaidata
|
||||
'''
|
||||
import json
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
|
@ -55,8 +48,6 @@ def main():
|
|||
rc, out, err = module.run_command(cmd, check_rc=True)
|
||||
module.exit_json(**json.loads(out))
|
||||
|
||||
# import module snippets
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -2,21 +2,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2013, Serge van Ginderachter <serge@vanginderachter.be>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
'status': ['preview'],
|
||||
|
@ -118,8 +108,12 @@ EXAMPLES = '''
|
|||
'''
|
||||
|
||||
import glob
|
||||
import os
|
||||
import time
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
|
||||
ISCSIADM = 'iscsiadm'
|
||||
|
||||
|
||||
|
@ -383,8 +377,5 @@ def main():
|
|||
module.exit_json(**result)
|
||||
|
||||
|
||||
# import module snippets
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -1,21 +1,11 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# (c) 2016, Andrew Gaffney <andrew@agaffney.org>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
'status': ['preview'],
|
||||
|
|
|
@ -2,19 +2,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2014, GeekChimp - Franck Nijhof <franck@geekchimp.com>
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
'status': ['stableinterface'],
|
||||
|
|
|
@ -2,21 +2,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2014, Sebastien Rohaut <sebastien.rohaut@gmail.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
'status': ['preview'],
|
||||
|
|
|
@ -1,21 +1,11 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# (c) 2016, Kenneth D. Evensen <kevensen@redhat.com>
|
||||
#
|
||||
# This file is part of Ansible (sort of)
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
'status': ['preview'],
|
||||
|
|
|
@ -2,21 +2,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2016, Fabrizio Colonna <colofabrix@tin.it>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
'status': ['preview'],
|
||||
|
@ -355,7 +345,7 @@ def format_disk_size(size_bytes, unit):
|
|||
elif unit in units_iec:
|
||||
multiplier = 1024.0 ** units_iec.index(unit)
|
||||
|
||||
output = size_bytes / multiplier * (1 + 1E-16)
|
||||
output = size_bytes // multiplier * (1 + 1E-16)
|
||||
|
||||
# Corrections to round up as per IEEE754 standard
|
||||
if output < 10:
|
||||
|
|
|
@ -3,21 +3,10 @@
|
|||
|
||||
# (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>
|
||||
# (c) 2016, Toshio Kuratomi <tkuratomi@ansible.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
|
|
|
@ -1,19 +1,11 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
# Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
|
||||
#
|
||||
# This module is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This software is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this software. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
'status': ['stableinterface'],
|
||||
|
@ -120,18 +112,12 @@ EXAMPLES = '''
|
|||
tags: update,nginx
|
||||
'''
|
||||
|
||||
import json
|
||||
import os
|
||||
import pipes
|
||||
import stat
|
||||
|
||||
try:
|
||||
import json
|
||||
except ImportError:
|
||||
try:
|
||||
import simplejson as json
|
||||
except ImportError:
|
||||
# Let snippet from module_utils/basic.py return a proper error in this case
|
||||
pass
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
|
||||
def _get_facter_dir():
|
||||
|
@ -295,8 +281,6 @@ def main():
|
|||
rc=rc, msg="%s failed with return code: %d" % (cmd, rc),
|
||||
stdout=stdout, stderr=stderr)
|
||||
|
||||
# import module snippets
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -2,21 +2,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# (c) 2015, Brian Coca <bcoca@ansible.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>
|
||||
# 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.0',
|
||||
'status': ['stableinterface'],
|
||||
|
@ -98,10 +88,13 @@ EXAMPLES = '''
|
|||
service_dir: /run/service
|
||||
'''
|
||||
|
||||
import platform
|
||||
import shlex
|
||||
from ansible.module_utils.pycompat24 import get_exception
|
||||
from ansible.module_utils.basic import *
|
||||
import os
|
||||
import re
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
|
||||
def _load_dist_subclass(cls, *args, **kwargs):
|
||||
'''
|
||||
|
@ -164,9 +157,8 @@ class Sv(object):
|
|||
if os.path.exists(self.src_full):
|
||||
try:
|
||||
os.symlink(self.src_full, self.svc_full)
|
||||
except OSError:
|
||||
e = get_exception()
|
||||
self.module.fail_json(path=self.src_full, msg='Error while linking: %s' % str(e))
|
||||
except OSError as e:
|
||||
self.module.fail_json(path=self.src_full, msg='Error while linking: %s' % to_native(e))
|
||||
else:
|
||||
self.module.fail_json(msg="Could not find source for service to enable (%s)." % self.src_full)
|
||||
|
||||
|
@ -174,9 +166,8 @@ class Sv(object):
|
|||
self.execute_command([self.svc_cmd,'force-stop',self.src_full])
|
||||
try:
|
||||
os.unlink(self.svc_full)
|
||||
except OSError:
|
||||
e = get_exception()
|
||||
self.module.fail_json(path=self.svc_full, msg='Error while unlinking: %s' % str(e))
|
||||
except OSError as e:
|
||||
self.module.fail_json(path=self.svc_full, msg='Error while unlinking: %s' % to_native(e))
|
||||
|
||||
def get_status(self):
|
||||
(rc, out, err) = self.execute_command([self.svstat_cmd, 'status', self.svc_full])
|
||||
|
@ -238,9 +229,8 @@ class Sv(object):
|
|||
def execute_command(self, cmd):
|
||||
try:
|
||||
(rc, out, err) = self.module.run_command(' '.join(cmd))
|
||||
except Exception:
|
||||
e = get_exception()
|
||||
self.module.fail_json(msg="failed to execute: %s" % str(e))
|
||||
except Exception as e:
|
||||
self.module.fail_json(msg="failed to execute: %s" % to_native(e), exception=traceback.format_exc())
|
||||
return (rc, out, err)
|
||||
|
||||
def report(self):
|
||||
|
@ -283,9 +273,8 @@ def main():
|
|||
sv.enable()
|
||||
else:
|
||||
sv.disable()
|
||||
except (OSError, IOError):
|
||||
e = get_exception()
|
||||
module.fail_json(msg="Could not change service link: %s" % str(e))
|
||||
except (OSError, IOError) as e:
|
||||
module.fail_json(msg="Could not change service link: %s" % to_native(e), exception=traceback.format_exc())
|
||||
|
||||
if state is not None and state != sv.state:
|
||||
changed = True
|
||||
|
@ -295,7 +284,5 @@ def main():
|
|||
module.exit_json(changed=changed, sv=sv.report())
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -1,21 +1,11 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
# (c) 2012, Stephen Fromm <sfromm@gmail.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
'status': ['stableinterface'],
|
||||
|
|
|
@ -1,21 +1,11 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
# (c) 2016, Dag Wieers <dag@wieers.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
'status': ['preview'],
|
||||
|
|
|
@ -2,21 +2,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2012, Derek Carter<goozbach@friocorte.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
'status': ['stableinterface'],
|
||||
|
|
|
@ -3,21 +3,11 @@
|
|||
|
||||
# (c) 2015, Michael Scherer <misc@zarb.org>
|
||||
# inspired by code of github.com/dandiker/
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
'status': ['preview'],
|
||||
|
@ -66,14 +56,17 @@ EXAMPLES = '''
|
|||
permissive: true
|
||||
'''
|
||||
|
||||
import traceback
|
||||
|
||||
HAVE_SEOBJECT = False
|
||||
try:
|
||||
import seobject
|
||||
HAVE_SEOBJECT = True
|
||||
except ImportError:
|
||||
pass
|
||||
from ansible.module_utils.basic import *
|
||||
from ansible.module_utils.pycompat24 import get_exception
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
|
||||
def main():
|
||||
|
@ -99,9 +92,8 @@ def main():
|
|||
|
||||
try:
|
||||
permissive_domains = seobject.permissiveRecords(store)
|
||||
except ValueError:
|
||||
e = get_exception()
|
||||
module.fail_json(domain=domain, msg=str(e))
|
||||
except ValueError as e:
|
||||
module.fail_json(domain=domain, msg=to_native(e), exception=traceback.format_exc())
|
||||
|
||||
# not supported on EL 6
|
||||
if 'set_reload' in dir(permissive_domains):
|
||||
|
@ -109,27 +101,24 @@ def main():
|
|||
|
||||
try:
|
||||
all_domains = permissive_domains.get_all()
|
||||
except ValueError:
|
||||
e = get_exception()
|
||||
module.fail_json(domain=domain, msg=str(e))
|
||||
except ValueError as e:
|
||||
module.fail_json(domain=domain, msg=to_native(e), exception=traceback.format_exc())
|
||||
|
||||
if permissive:
|
||||
if domain not in all_domains:
|
||||
if not module.check_mode:
|
||||
try:
|
||||
permissive_domains.add(domain)
|
||||
except ValueError:
|
||||
e = get_exception()
|
||||
module.fail_json(domain=domain, msg=str(e))
|
||||
except ValueError as e:
|
||||
module.fail_json(domain=domain, msg=to_native(e), exception=traceback.format_exc())
|
||||
changed = True
|
||||
else:
|
||||
if domain in all_domains:
|
||||
if not module.check_mode:
|
||||
try:
|
||||
permissive_domains.delete(domain)
|
||||
except ValueError:
|
||||
e = get_exception()
|
||||
module.fail_json(domain=domain, msg=str(e))
|
||||
except ValueError as e:
|
||||
module.fail_json(domain=domain, msg=to_native(e), exception=traceback.format_exc())
|
||||
changed = True
|
||||
|
||||
module.exit_json(changed=changed, store=store,
|
||||
|
|
|
@ -1,21 +1,11 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
# (c) 2014, Dan Keder <dan.keder@gmail.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
'status': ['preview'],
|
||||
|
@ -87,6 +77,8 @@ EXAMPLES = '''
|
|||
state: present
|
||||
'''
|
||||
|
||||
import traceback
|
||||
|
||||
try:
|
||||
import selinux
|
||||
HAVE_SELINUX=True
|
||||
|
@ -99,8 +91,8 @@ try:
|
|||
except ImportError:
|
||||
HAVE_SEOBJECT=False
|
||||
|
||||
from ansible.module_utils.basic import *
|
||||
from ansible.module_utils.pycompat24 import get_exception
|
||||
from ansible.module_utils.basic import AnsibleModule, HAVE_SELINUX
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
|
||||
def semanage_port_get_ports(seport, setype, proto):
|
||||
|
@ -191,21 +183,8 @@ def semanage_port_add(module, ports, proto, setype, do_reload, serange='s0', ses
|
|||
elif port_type is not None and not module.check_mode:
|
||||
seport.modify(port, proto, serange, setype)
|
||||
|
||||
except ValueError:
|
||||
e = get_exception()
|
||||
module.fail_json(msg="%s: %s\n" % (e.__class__.__name__, str(e)))
|
||||
except IOError:
|
||||
e = get_exception()
|
||||
module.fail_json(msg="%s: %s\n" % (e.__class__.__name__, str(e)))
|
||||
except KeyError:
|
||||
e = get_exception()
|
||||
module.fail_json(msg="%s: %s\n" % (e.__class__.__name__, str(e)))
|
||||
except OSError:
|
||||
e = get_exception()
|
||||
module.fail_json(msg="%s: %s\n" % (e.__class__.__name__, str(e)))
|
||||
except RuntimeError:
|
||||
e = get_exception()
|
||||
module.fail_json(msg="%s: %s\n" % (e.__class__.__name__, str(e)))
|
||||
except (ValueError, IOError, KeyError, OSError, RuntimeError) as e:
|
||||
module.fail_json(msg="%s: %s\n" % (e.__class__.__name__, to_native(e)), exception=traceback.format_exc())
|
||||
|
||||
return change
|
||||
|
||||
|
@ -245,21 +224,8 @@ def semanage_port_del(module, ports, proto, setype, do_reload, sestore=''):
|
|||
if not module.check_mode:
|
||||
seport.delete(port, proto)
|
||||
|
||||
except ValueError:
|
||||
e = get_exception()
|
||||
module.fail_json(msg="%s: %s\n" % (e.__class__.__name__, str(e)))
|
||||
except IOError:
|
||||
e = get_exception()
|
||||
module.fail_json(msg="%s: %s\n" % (e.__class__.__name__, str(e)))
|
||||
except KeyError:
|
||||
e = get_exception()
|
||||
module.fail_json(msg="%s: %s\n" % (e.__class__.__name__, str(e)))
|
||||
except OSError:
|
||||
e = get_exception()
|
||||
module.fail_json(msg="%s: %s\n" % (e.__class__.__name__, str(e)))
|
||||
except RuntimeError:
|
||||
e = get_exception()
|
||||
module.fail_json(msg="%s: %s\n" % (e.__class__.__name__, str(e)))
|
||||
except (ValueError, IOError, KeyError, OSError, RuntimeError) as e:
|
||||
module.fail_json(msg="%s: %s\n" % (e.__class__.__name__, to_native(e)), exception=traceback.format_exc())
|
||||
|
||||
return change
|
||||
|
||||
|
|
|
@ -2,21 +2,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
'status': ['stableinterface'],
|
||||
|
|
|
@ -2,21 +2,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
'status': ['stableinterface'],
|
||||
|
|
|
@ -1,21 +1,11 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
# (c) 2015, Paul Markham <pmarkham@netrefinery.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
'status': ['preview'],
|
||||
|
@ -155,10 +145,12 @@ EXAMPLES = '''
|
|||
attach_options: -u
|
||||
'''
|
||||
|
||||
import sys
|
||||
import os
|
||||
import platform
|
||||
import tempfile
|
||||
import time
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
|
||||
class Zone(object):
|
||||
|
@ -482,7 +474,6 @@ def main():
|
|||
|
||||
module.exit_json(changed=zone.changed, msg=', '.join(zone.msg))
|
||||
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -2,21 +2,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# (c) 2015, Brian Coca <bcoca@ansible.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>
|
||||
# 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.0',
|
||||
'status': ['stableinterface'],
|
||||
|
@ -103,10 +93,13 @@ EXAMPLES = '''
|
|||
service_dir: /var/service
|
||||
'''
|
||||
|
||||
import platform
|
||||
import shlex
|
||||
from ansible.module_utils.pycompat24 import get_exception
|
||||
from ansible.module_utils.basic import *
|
||||
import os
|
||||
import re
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
|
||||
def _load_dist_subclass(cls, *args, **kwargs):
|
||||
'''
|
||||
|
@ -172,18 +165,16 @@ class Svc(object):
|
|||
if os.path.exists(self.src_full):
|
||||
try:
|
||||
os.symlink(self.src_full, self.svc_full)
|
||||
except OSError:
|
||||
e = get_exception()
|
||||
self.module.fail_json(path=self.src_full, msg='Error while linking: %s' % str(e))
|
||||
except OSError as e:
|
||||
self.module.fail_json(path=self.src_full, msg='Error while linking: %s' % to_native(e))
|
||||
else:
|
||||
self.module.fail_json(msg="Could not find source for service to enable (%s)." % self.src_full)
|
||||
|
||||
def disable(self):
|
||||
try:
|
||||
os.unlink(self.svc_full)
|
||||
except OSError:
|
||||
e = get_exception()
|
||||
self.module.fail_json(path=self.svc_full, msg='Error while unlinking: %s' % str(e))
|
||||
except OSError as e:
|
||||
self.module.fail_json(path=self.svc_full, msg='Error while unlinking: %s' % to_native(e))
|
||||
self.execute_command([self.svc_cmd,'-dx',self.src_full])
|
||||
|
||||
src_log = '%s/log' % self.src_full
|
||||
|
@ -243,9 +234,8 @@ class Svc(object):
|
|||
def execute_command(self, cmd):
|
||||
try:
|
||||
(rc, out, err) = self.module.run_command(' '.join(cmd))
|
||||
except Exception:
|
||||
e = get_exception()
|
||||
self.module.fail_json(msg="failed to execute: %s" % str(e))
|
||||
except Exception as e:
|
||||
self.module.fail_json(msg="failed to execute: %s" % to_native(e), exception=traceback.format_exc())
|
||||
return (rc, out, err)
|
||||
|
||||
def report(self):
|
||||
|
@ -290,9 +280,8 @@ def main():
|
|||
svc.enable()
|
||||
else:
|
||||
svc.disable()
|
||||
except (OSError, IOError):
|
||||
e = get_exception()
|
||||
module.fail_json(msg="Could change service link: %s" % str(e))
|
||||
except (OSError, IOError) as e:
|
||||
module.fail_json(msg="Could change service link: %s" % to_native(e))
|
||||
|
||||
if state is not None and state != svc.state:
|
||||
changed = True
|
||||
|
@ -308,9 +297,8 @@ def main():
|
|||
open(d_file, "a").close()
|
||||
else:
|
||||
os.unlink(d_file)
|
||||
except (OSError, IOError):
|
||||
e = get_exception()
|
||||
module.fail_json(msg="Could change downed file: %s " % (str(e)))
|
||||
except (OSError, IOError) as e:
|
||||
module.fail_json(msg="Could change downed file: %s " % (to_native(e)))
|
||||
|
||||
module.exit_json(changed=changed, svc=svc.report())
|
||||
|
||||
|
|
|
@ -3,22 +3,11 @@
|
|||
|
||||
# (c) 2012, David "DaviXX" CHANIAL <david.chanial@gmail.com>
|
||||
# (c) 2014, James Tanner <tanner.jc@gmail.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# 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.0',
|
||||
'status': ['stableinterface'],
|
||||
|
|
|
@ -1,21 +1,11 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# (c) 2016, Brian Coca <bcoca@ansible.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
'status': ['stableinterface'],
|
||||
|
|
|
@ -2,21 +2,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2016, Shinichi TAMURA (@tmshn)
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
'status': ['preview'],
|
||||
|
|
|
@ -6,20 +6,11 @@
|
|||
# (c) 2013, Aleksey Ovcharenko <aleksey.ovcharenko@gmail.com>
|
||||
# (c) 2013, James Martin <jmartin@basho.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
'status': ['preview'],
|
||||
|
@ -235,8 +226,11 @@ EXAMPLES = '''
|
|||
dest: 4.5.6.0/24
|
||||
'''
|
||||
|
||||
import re
|
||||
from operator import itemgetter
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
|
@ -370,8 +364,6 @@ def main():
|
|||
|
||||
return module.exit_json(changed=changed, commands=cmds, msg=post_state.rstrip())
|
||||
|
||||
# import module snippets
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -2,21 +2,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2012, Stephen Fromm <sfromm@gmail.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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.0',
|
||||
'status': ['stableinterface'],
|
||||
|
@ -809,7 +799,7 @@ class FreeBsdUser(User):
|
|||
cmd.append(self.login_class)
|
||||
|
||||
if self.expires:
|
||||
days =( time.mktime(self.expires) - time.time() ) / 86400
|
||||
days =( time.mktime(self.expires) - time.time() ) // 86400
|
||||
cmd.append('-e')
|
||||
cmd.append(str(int(days)))
|
||||
|
||||
|
@ -907,7 +897,7 @@ class FreeBsdUser(User):
|
|||
cmd.append(','.join(new_groups))
|
||||
|
||||
if self.expires:
|
||||
days = ( time.mktime(self.expires) - time.time() ) / 86400
|
||||
days = ( time.mktime(self.expires) - time.time() ) // 86400
|
||||
cmd.append('-e')
|
||||
cmd.append(str(int(days)))
|
||||
|
||||
|
@ -1363,7 +1353,7 @@ class SunOS(User):
|
|||
lines.append(line)
|
||||
continue
|
||||
fields[1] = self.password
|
||||
fields[2] = str(int(time.time() / 86400))
|
||||
fields[2] = str(int(time.time() // 86400))
|
||||
if minweeks:
|
||||
fields[3] = str(int(minweeks) * 7)
|
||||
if maxweeks:
|
||||
|
@ -1457,7 +1447,7 @@ class SunOS(User):
|
|||
lines.append(line)
|
||||
continue
|
||||
fields[1] = self.password
|
||||
fields[2] = str(int(time.time() / 86400))
|
||||
fields[2] = str(int(time.time() // 86400))
|
||||
if minweeks:
|
||||
fields[3] = str(int(minweeks) * 7)
|
||||
if maxweeks:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue