summaryrefslogtreecommitdiff
path: root/web_infrastructure
diff options
context:
space:
mode:
authorMichael DeHaan <michael.dehaan@gmail.com>2014-09-26 09:23:50 -0400
committerMichael DeHaan <michael.dehaan@gmail.com>2014-09-26 09:23:50 -0400
commit73123b69fa5c15babaf28b2e5980b946ead1ace5 (patch)
treec757a913f95f26d08ebca9e2fbe586ccb1e45e7e /web_infrastructure
parentb2b5cc032caf22ece54852dc023b888baf109c8b (diff)
downloadansible-modules-core-73123b69fa5c15babaf28b2e5980b946ead1ace5.tar.gz
Move modules into subdirectory.
Diffstat (limited to 'web_infrastructure')
-rw-r--r--web_infrastructure/apache2_module89
-rw-r--r--web_infrastructure/django_manage281
-rwxr-xr-xweb_infrastructure/ejabberd_user214
-rw-r--r--web_infrastructure/htpasswd219
-rw-r--r--web_infrastructure/jboss140
-rw-r--r--web_infrastructure/jira347
-rw-r--r--web_infrastructure/supervisorctl221
7 files changed, 0 insertions, 1511 deletions
diff --git a/web_infrastructure/apache2_module b/web_infrastructure/apache2_module
deleted file mode 100644
index 39351482..00000000
--- a/web_infrastructure/apache2_module
+++ /dev/null
@@ -1,89 +0,0 @@
-#!/usr/bin/python
-#coding: utf-8 -*-
-
-# (c) 2013-2014, Christian Berendt <berendt@b1-systems.de>
-#
-# 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/>.
-
-DOCUMENTATION = '''
----
-module: apache2_module
-version_added: 1.6
-short_description: enables/disables a module of the Apache2 webserver
-description:
- - Enables or disables a specified module of the Apache2 webserver.
-options:
- name:
- description:
- - name of the module to enable/disable
- required: true
- state:
- description:
- - indicate the desired state of the resource
- choices: ['present', 'absent']
- default: present
-
-'''
-
-EXAMPLES = '''
-# enables the Apache2 module "wsgi"
-- apache2_module: state=present name=wsgi
-
-# disables the Apache2 module "wsgi"
-- apache2_module: state=absent name=wsgi
-'''
-
-import re
-
-def _disable_module(module):
- name = module.params['name']
- a2dismod_binary = module.get_bin_path("a2dismod")
- result, stdout, stderr = module.run_command("%s %s" % (a2dismod_binary, name))
-
- if re.match(r'.*' + name + r' already disabled.*', stdout, re.S):
- module.exit_json(changed = False, result = "Success")
- elif result != 0:
- module.fail_json(msg="Failed to disable module %s: %s" % (name, stdout))
- else:
- module.exit_json(changed = True, result = "Disabled")
-
-def _enable_module(module):
- name = module.params['name']
- a2enmod_binary = module.get_bin_path("a2enmod")
- result, stdout, stderr = module.run_command("%s %s" % (a2enmod_binary, name))
-
- if re.match(r'.*' + name + r' already enabled.*', stdout, re.S):
- module.exit_json(changed = False, result = "Success")
- elif result != 0:
- module.fail_json(msg="Failed to enable module %s: %s" % (name, stdout))
- else:
- module.exit_json(changed = True, result = "Enabled")
-
-def main():
- module = AnsibleModule(
- argument_spec = dict(
- name = dict(required=True),
- state = dict(default='present', choices=['absent', 'present'])
- ),
- )
-
- if module.params['state'] == 'present':
- _enable_module(module)
-
- if module.params['state'] == 'absent':
- _disable_module(module)
-
-# import module snippets
-from ansible.module_utils.basic import *
-main()
diff --git a/web_infrastructure/django_manage b/web_infrastructure/django_manage
deleted file mode 100644
index 580cc63c..00000000
--- a/web_infrastructure/django_manage
+++ /dev/null
@@ -1,281 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-
-# (c) 2013, Scott Anderson <scottanderson42@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/>.
-#
-
-DOCUMENTATION = '''
----
-module: django_manage
-short_description: Manages a Django application.
-description:
- - Manages a Django application using the I(manage.py) application frontend to I(django-admin). With the I(virtualenv) parameter, all management commands will be executed by the given I(virtualenv) installation.
-version_added: "1.1"
-options:
- command:
- choices: [ 'cleanup', 'collectstatic', 'flush', 'loaddata', 'migrate', 'runfcgi', 'syncdb', 'test', 'validate', ]
- description:
- - The name of the Django management command to run. Built in commands are cleanup, collectstatic, flush, loaddata, migrate, runfcgi, syncdb, test, and validate. Other commands can be entered, but will fail if they're unknown to Django.
- required: true
- app_path:
- description:
- - The path to the root of the Django application where B(manage.py) lives.
- required: true
- settings:
- description:
- - The Python path to the application's settings module, such as 'myapp.settings'.
- required: false
- pythonpath:
- description:
- - A directory to add to the Python path. Typically used to include the settings module if it is located external to the application directory.
- required: false
- virtualenv:
- description:
- - An optional path to a I(virtualenv) installation to use while running the manage application.
- required: false
- apps:
- description:
- - A list of space-delimited apps to target. Used by the 'test' command.
- required: false
- cache_table:
- description:
- - The name of the table used for database-backed caching. Used by the 'createcachetable' command.
- required: false
- database:
- description:
- - The database to target. Used by the 'createcachetable', 'flush', 'loaddata', and 'syncdb' commands.
- required: false
- failfast:
- description:
- - Fail the command immediately if a test fails. Used by the 'test' command.
- required: false
- default: "no"
- choices: [ "yes", "no" ]
- fixtures:
- description:
- - A space-delimited list of fixture file names to load in the database. B(Required) by the 'loaddata' command.
- required: false
- skip:
- description:
- - Will skip over out-of-order missing migrations, you can only use this parameter with I(migrate)
- required: false
- version_added: "1.3"
- merge:
- description:
- - Will run out-of-order or missing migrations as they are not rollback migrations, you can only use this parameter with 'migrate' command
- required: false
- version_added: "1.3"
- link:
- description:
- - Will create links to the files instead of copying them, you can only use this parameter with 'collectstatic' command
- required: false
- version_added: "1.3"
-notes:
- - I(virtualenv) (U(http://www.virtualenv.org)) must be installed on the remote host if the virtualenv parameter is specified.
- - This module will create a virtualenv if the virtualenv parameter is specified and a virtualenv does not already exist at the given location.
- - This module assumes English error messages for the 'createcachetable' command to detect table existence, unfortunately.
- - To be able to use the migrate command, you must have south installed and added as an app in your settings
- - To be able to use the collectstatic command, you must have enabled staticfiles in your settings
-requirements: [ "virtualenv", "django" ]
-author: Scott Anderson
-'''
-
-EXAMPLES = """
-# Run cleanup on the application installed in 'django_dir'.
-- django_manage: command=cleanup app_path={{ django_dir }}
-
-# Load the initial_data fixture into the application
-- django_manage: command=loaddata app_path={{ django_dir }} fixtures={{ initial_data }}
-
-#Run syncdb on the application
-- django_manage: >
- command=syncdb
- app_path={{ django_dir }}
- settings={{ settings_app_name }}
- pythonpath={{ settings_dir }}
- virtualenv={{ virtualenv_dir }}
-
-#Run the SmokeTest test case from the main app. Useful for testing deploys.
-- django_manage: command=test app_path=django_dir apps=main.SmokeTest
-"""
-
-
-import os
-
-def _fail(module, cmd, out, err, **kwargs):
- msg = ''
- if out:
- msg += "stdout: %s" % (out, )
- if err:
- msg += "\n:stderr: %s" % (err, )
- module.fail_json(cmd=cmd, msg=msg, **kwargs)
-
-
-def _ensure_virtualenv(module):
-
- venv_param = module.params['virtualenv']
- if venv_param is None:
- return
-
- vbin = os.path.join(os.path.expanduser(venv_param), 'bin')
- activate = os.path.join(vbin, 'activate')
-
- if not os.path.exists(activate):
- virtualenv = module.get_bin_path('virtualenv', True)
- vcmd = '%s %s' % (virtualenv, venv_param)
- vcmd = [virtualenv, venv_param]
- rc, out_venv, err_venv = module.run_command(vcmd)
- if rc != 0:
- _fail(module, vcmd, out_venv, err_venv)
-
- os.environ["PATH"] = "%s:%s" % (vbin, os.environ["PATH"])
- os.environ["VIRTUAL_ENV"] = venv_param
-
-def createcachetable_filter_output(line):
- return "Already exists" not in line
-
-def flush_filter_output(line):
- return "Installed" in line and "Installed 0 object" not in line
-
-def loaddata_filter_output(line):
- return "Installed" in line and "Installed 0 object" not in line
-
-def syncdb_filter_output(line):
- return ("Creating table " in line) or ("Installed" in line and "Installed 0 object" not in line)
-
-def migrate_filter_output(line):
- return ("Migrating forwards " in line) or ("Installed" in line and "Installed 0 object" not in line)
-
-def main():
- command_allowed_param_map = dict(
- cleanup=(),
- createcachetable=('cache_table', 'database', ),
- flush=('database', ),
- loaddata=('database', 'fixtures', ),
- syncdb=('database', ),
- test=('failfast', 'testrunner', 'liveserver', 'apps', ),
- validate=(),
- migrate=('apps', 'skip', 'merge'),
- collectstatic=('link', ),
- )
-
- command_required_param_map = dict(
- loaddata=('fixtures', ),
- createcachetable=('cache_table', ),
- )
-
- # forces --noinput on every command that needs it
- noinput_commands = (
- 'flush',
- 'syncdb',
- 'migrate',
- 'test',
- 'collectstatic',
- )
-
- # These params are allowed for certain commands only
- specific_params = ('apps', 'database', 'failfast', 'fixtures', 'liveserver', 'testrunner')
-
- # These params are automatically added to the command if present
- general_params = ('settings', 'pythonpath', 'database',)
- specific_boolean_params = ('failfast', 'skip', 'merge', 'link')
- end_of_command_params = ('apps', 'cache_table', 'fixtures')
-
- module = AnsibleModule(
- argument_spec=dict(
- command = dict(default=None, required=True),
- app_path = dict(default=None, required=True),
- settings = dict(default=None, required=False),
- pythonpath = dict(default=None, required=False, aliases=['python_path']),
- virtualenv = dict(default=None, required=False, aliases=['virtual_env']),
-
- apps = dict(default=None, required=False),
- cache_table = dict(default=None, required=False),
- database = dict(default=None, required=False),
- failfast = dict(default='no', required=False, type='bool', aliases=['fail_fast']),
- fixtures = dict(default=None, required=False),
- liveserver = dict(default=None, required=False, aliases=['live_server']),
- testrunner = dict(default=None, required=False, aliases=['test_runner']),
- skip = dict(default=None, required=False, type='bool'),
- merge = dict(default=None, required=False, type='bool'),
- link = dict(default=None, required=False, type='bool'),
- ),
- )
-
- command = module.params['command']
- app_path = module.params['app_path']
- virtualenv = module.params['virtualenv']
-
- for param in specific_params:
- value = module.params[param]
- if param in specific_boolean_params:
- value = module.boolean(value)
- if value and param not in command_allowed_param_map[command]:
- module.fail_json(msg='%s param is incompatible with command=%s' % (param, command))
-
- for param in command_required_param_map.get(command, ()):
- if not module.params[param]:
- module.fail_json(msg='%s param is required for command=%s' % (param, command))
-
- venv = module.params['virtualenv']
-
- _ensure_virtualenv(module)
-
- cmd = "python manage.py %s" % (command, )
-
- if command in noinput_commands:
- cmd = '%s --noinput' % cmd
-
- for param in general_params:
- if module.params[param]:
- cmd = '%s --%s=%s' % (cmd, param, module.params[param])
-
- for param in specific_boolean_params:
- if module.boolean(module.params[param]):
- cmd = '%s --%s' % (cmd, param)
-
- # these params always get tacked on the end of the command
- for param in end_of_command_params:
- if module.params[param]:
- cmd = '%s %s' % (cmd, module.params[param])
-
- rc, out, err = module.run_command(cmd, cwd=app_path)
- if rc != 0:
- if command == 'createcachetable' and 'table' in err and 'already exists' in err:
- out = 'Already exists.'
- else:
- if "Unknown command:" in err:
- _fail(module, cmd, err, "Unknown django command: %s" % command)
- _fail(module, cmd, out, err, path=os.environ["PATH"], syspath=sys.path)
-
- changed = False
-
- lines = out.split('\n')
- filt = globals().get(command + "_filter_output", None)
- if filt:
- filtered_output = filter(filt, out.split('\n'))
- if len(filtered_output):
- changed = filtered_output
-
- module.exit_json(changed=changed, out=out, cmd=cmd, app_path=app_path, virtualenv=virtualenv,
- settings=module.params['settings'], pythonpath=module.params['pythonpath'])
-
-# import module snippets
-from ansible.module_utils.basic import *
-
-main()
diff --git a/web_infrastructure/ejabberd_user b/web_infrastructure/ejabberd_user
deleted file mode 100755
index d8b03846..00000000
--- a/web_infrastructure/ejabberd_user
+++ /dev/null
@@ -1,214 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2013, Peter Sprygada <sprygada@gmail.com>
-#
-# This program 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 program 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 program. If not, see <http://www.gnu.org/licenses/>.
-#
-DOCUMENTATION = '''
----
-module: ejabberd_user
-version_added: "1.5"
-author: Peter Sprygada
-short_description: Manages users for ejabberd servers
-requirements:
- - ejabberd with mod_admin_extra
-description:
- - This module provides user management for ejabberd servers
-options:
- username:
- description:
- - the name of the user to manage
- required: true
- host:
- description:
- - the ejabberd host associated with this username
- required: true
- password:
- description:
- - the password to assign to the username
- required: false
- logging:
- description:
- - enables or disables the local syslog facility for this module
- required: false
- default: false
- choices: [ 'true', 'false', 'yes', 'no' ]
- state:
- description:
- - describe the desired state of the user to be managed
- required: false
- default: 'present'
- choices: [ 'present', 'absent' ]
-notes:
- - Password parameter is required for state == present only
- - Passwords must be stored in clear text for this release
- - The ejabberd configuration file must include mod_admin_extra as a module.
-'''
-EXAMPLES = '''
-Example playbook entries using the ejabberd_user module to manage users state.
-
- tasks:
-
- - name: create a user if it does not exists
- action: ejabberd_user username=test host=server password=password
-
- - name: delete a user if it exists
- action: ejabberd_user username=test host=server state=absent
-'''
-import syslog
-
-class EjabberdUserException(Exception):
- """ Base exeption for EjabberdUser class object """
- pass
-
-class EjabberdUser(object):
- """ This object represents a user resource for an ejabberd server. The
- object manages user creation and deletion using ejabberdctl. The following
- commands are currently supported:
- * ejabberdctl register
- * ejabberdctl deregister
- """
-
- def __init__(self, module):
- self.module = module
- self.logging = module.params.get('logging')
- self.state = module.params.get('state')
- self.host = module.params.get('host')
- self.user = module.params.get('username')
- self.pwd = module.params.get('password')
-
- @property
- def changed(self):
- """ This method will check the current user and see if the password has
- changed. It will return True if the user does not match the supplied
- credentials and False if it does not
- """
- try:
- options = [self.user, self.host, self.pwd]
- (rc, out, err) = self.run_command('check_password', options)
- except EjabberdUserException, e:
- (rc, out, err) = (1, None, "required attribute(s) missing")
- return rc
-
- @property
- def exists(self):
- """ This method will check to see if the supplied username exists for
- host specified. If the user exists True is returned, otherwise False
- is returned
- """
- try:
- options = [self.user, self.host]
- (rc, out, err) = self.run_command('check_account', options)
- except EjabberdUserException, e:
- (rc, out, err) = (1, None, "required attribute(s) missing")
- return True if rc == 0 else False
-
- def log(self, entry):
- """ This method will log information to the local syslog facility """
- if self.logging:
- syslog.openlog('ansible-%s' % os.path.basename(__file__))
- syslog.syslog(syslog.LOG_NOTICE, entry)
-
- def run_command(self, cmd, options):
- """ This method will run the any command specified and return the
- returns using the Ansible common module
- """
- if not all(options):
- raise EjabberdUserException
-
- cmd = 'ejabberdctl %s ' % cmd
- cmd += " ".join(options)
- self.log('command: %s' % cmd)
- return self.module.run_command(cmd.split())
-
- def update(self):
- """ The update method will update the credentials for the user provided
- """
- try:
- options = [self.user, self.host, self.pwd]
- (rc, out, err) = self.run_command('change_password', options)
- except EjabberdUserException, e:
- (rc, out, err) = (1, None, "required attribute(s) missing")
- return (rc, out, err)
-
- def create(self):
- """ The create method will create a new user on the host with the
- password provided
- """
- try:
- options = [self.user, self.host, self.pwd]
- (rc, out, err) = self.run_command('register', options)
- except EjabberdUserException, e:
- (rc, out, err) = (1, None, "required attribute(s) missing")
- return (rc, out, err)
-
- def delete(self):
- """ The delete method will delete the user from the host
- """
- try:
- options = [self.user, self.host]
- (rc, out, err) = self.run_command('unregister', options)
- except EjabberdUserException, e:
- (rc, out, err) = (1, None, "required attribute(s) missing")
- return (rc, out, err)
-
-def main():
- module = AnsibleModule(
- argument_spec = dict(
- host=dict(default=None, type='str'),
- username=dict(default=None, type='str'),
- password=dict(default=None, type='str'),
- state=dict(default='present', choices=['present', 'absent']),
- logging=dict(default=False, type='bool')
- ),
- supports_check_mode = True
- )
-
- obj = EjabberdUser(module)
-
- rc = None
- result = dict()
-
- if obj.state == 'absent':
- if obj.exists:
- if module.check_mode:
- module.exit_json(changed=True)
- (rc, out, err) = obj.delete()
- if rc != 0:
- module.fail_json(msg=err, rc=rc)
-
- elif obj.state == 'present':
- if not obj.exists:
- if module.check_mode:
- module.exit_json(changed=True)
- (rc, out, err) = obj.create()
- elif obj.changed:
- if module.check_mode:
- module.exit_json(changed=True)
- (rc, out, err) = obj.update()
- if rc is not None and rc != 0:
- module.fail_json(msg=err, rc=rc)
-
- if rc is None:
- result['changed'] = False
- else:
- result['changed'] = True
-
- module.exit_json(**result)
-
-
-# import module snippets
-from ansible.module_utils.basic import *
-main()
diff --git a/web_infrastructure/htpasswd b/web_infrastructure/htpasswd
deleted file mode 100644
index 4a72ea37..00000000
--- a/web_infrastructure/htpasswd
+++ /dev/null
@@ -1,219 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-
-# (c) 2013, Nimbis Services, Inc.
-#
-# 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/>.
-#
-DOCUMENTATION = """
-module: htpasswd
-version_added: "1.3"
-short_description: manage user files for basic authentication
-description:
- - Add and remove username/password entries in a password file using htpasswd.
- - This is used by web servers such as Apache and Nginx for basic authentication.
-options:
- path:
- required: true
- aliases: [ dest, destfile ]
- description:
- - Path to the file that contains the usernames and passwords
- name:
- required: true
- aliases: [ username ]
- description:
- - User name to add or remove
- password:
- required: false
- description:
- - Password associated with user.
- - Must be specified if user does not exist yet.
- crypt_scheme:
- required: false
- choices: ["apr_md5_crypt", "des_crypt", "ldap_sha1", "plaintext"]
- default: "apr_md5_crypt"
- description:
- - Encryption scheme to be used.
- state:
- required: false
- choices: [ present, absent ]
- default: "present"
- description:
- - Whether the user entry should be present or not
- create:
- required: false
- choices: [ "yes", "no" ]
- default: "yes"
- description:
- - Used with C(state=present). If specified, the file will be created
- if it does not already exist. If set to "no", will fail if the
- file does not exist
-notes:
- - "This module depends on the I(passlib) Python library, which needs to be installed on all target systems."
- - "On Debian, Ubuntu, or Fedora: install I(python-passlib)."
- - "On RHEL or CentOS: Enable EPEL, then install I(python-passlib)."
-requires: [ passlib>=1.6 ]
-author: Lorin Hochstein
-"""
-
-EXAMPLES = """
-# Add a user to a password file and ensure permissions are set
-- htpasswd: path=/etc/nginx/passwdfile name=janedoe password=9s36?;fyNp owner=root group=www-data mode=0640
-# Remove a user from a password file
-- htpasswd: path=/etc/apache2/passwdfile name=foobar state=absent
-"""
-
-
-import os
-from distutils.version import StrictVersion
-
-try:
- from passlib.apache import HtpasswdFile
- import passlib
-except ImportError:
- passlib_installed = False
-else:
- passlib_installed = True
-
-
-def create_missing_directories(dest):
- destpath = os.path.dirname(dest)
- if not os.path.exists(destpath):
- os.makedirs(destpath)
-
-
-def present(dest, username, password, crypt_scheme, create, check_mode):
- """ Ensures user is present
-
- Returns (msg, changed) """
- if not os.path.exists(dest):
- if not create:
- raise ValueError('Destination %s does not exist' % dest)
- if check_mode:
- return ("Create %s" % dest, True)
- create_missing_directories(dest)
- if StrictVersion(passlib.__version__) >= StrictVersion('1.6'):
- ht = HtpasswdFile(dest, new=True, default_scheme=crypt_scheme)
- else:
- ht = HtpasswdFile(dest, autoload=False, default=crypt_scheme)
- if getattr(ht, 'set_password', None):
- ht.set_password(username, password)
- else:
- ht.update(username, password)
- ht.save()
- return ("Created %s and added %s" % (dest, username), True)
- else:
- if StrictVersion(passlib.__version__) >= StrictVersion('1.6'):
- ht = HtpasswdFile(dest, new=False, default_scheme=crypt_scheme)
- else:
- ht = HtpasswdFile(dest, default=crypt_scheme)
-
- found = None
- if getattr(ht, 'check_password', None):
- found = ht.check_password(username, password)
- else:
- found = ht.verify(username, password)
-
- if found:
- return ("%s already present" % username, False)
- else:
- if not check_mode:
- if getattr(ht, 'set_password', None):
- ht.set_password(username, password)
- else:
- ht.update(username, password)
- ht.save()
- return ("Add/update %s" % username, True)
-
-
-def absent(dest, username, check_mode):
- """ Ensures user is absent
-
- Returns (msg, changed) """
- if not os.path.exists(dest):
- raise ValueError("%s does not exists" % dest)
-
- if StrictVersion(passlib.__version__) >= StrictVersion('1.6'):
- ht = HtpasswdFile(dest, new=False)
- else:
- ht = HtpasswdFile(dest)
-
- if username not in ht.users():
- return ("%s not present" % username, False)
- else:
- if not check_mode:
- ht.delete(username)
- ht.save()
- return ("Remove %s" % username, True)
-
-
-def check_file_attrs(module, changed, message):
-
- file_args = module.load_file_common_arguments(module.params)
- if module.set_fs_attributes_if_different(file_args, False):
-
- if changed:
- message += " and "
- changed = True
- message += "ownership, perms or SE linux context changed"
-
- return message, changed
-
-
-def main():
- arg_spec = dict(
- path=dict(required=True, aliases=["dest", "destfile"]),
- name=dict(required=True, aliases=["username"]),
- password=dict(required=False, default=None),
- crypt_scheme=dict(required=False, default=None),
- state=dict(required=False, default="present"),
- create=dict(type='bool', default='yes'),
-
- )
- module = AnsibleModule(argument_spec=arg_spec,
- add_file_common_args=True,
- supports_check_mode=True)
-
- path = module.params['path']
- username = module.params['name']
- password = module.params['password']
- crypt_scheme = module.params['crypt_scheme']
- state = module.params['state']
- create = module.params['create']
- check_mode = module.check_mode
-
- if not passlib_installed:
- module.fail_json(msg="This module requires the passlib Python library")
-
- try:
- if state == 'present':
- (msg, changed) = present(path, username, password, crypt_scheme, create, check_mode)
- elif state == 'absent':
- (msg, changed) = absent(path, username, check_mode)
- else:
- module.fail_json(msg="Invalid state: %s" % state)
-
- check_file_attrs(module, changed, msg)
- module.exit_json(msg=msg, changed=changed)
- except Exception, e:
- module.fail_json(msg=str(e))
-
-
-# import module snippets
-from ansible.module_utils.basic import *
-
-if __name__ == '__main__':
- main()
diff --git a/web_infrastructure/jboss b/web_infrastructure/jboss
deleted file mode 100644
index 94782356..00000000
--- a/web_infrastructure/jboss
+++ /dev/null
@@ -1,140 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-
-# (c) 2013, 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/>.
-
-DOCUMENTATION = """
-module: jboss
-version_added: "1.4"
-short_description: deploy applications to JBoss
-description:
- - Deploy applications to JBoss standalone using the filesystem
-options:
- deployment:
- required: true
- description:
- - The name of the deployment
- src:
- required: false
- description:
- - The remote path of the application ear or war to deploy
- deploy_path:
- required: false
- default: /var/lib/jbossas/standalone/deployments
- description:
- - The location in the filesystem where the deployment scanner listens
- state:
- required: false
- choices: [ present, absent ]
- default: "present"
- description:
- - Whether the application should be deployed or undeployed
-notes:
- - "The JBoss standalone deployment-scanner has to be enabled in standalone.xml"
- - "Ensure no identically named application is deployed through the JBoss CLI"
-author: Jeroen Hoekx
-"""
-
-EXAMPLES = """
-# Deploy a hello world application
-- jboss: src=/tmp/hello-1.0-SNAPSHOT.war deployment=hello.war state=present
-# Update the hello world application
-- jboss: src=/tmp/hello-1.1-SNAPSHOT.war deployment=hello.war state=present
-# Undeploy the hello world application
-- jboss: deployment=hello.war state=absent
-"""
-
-import os
-import shutil
-import time
-
-def is_deployed(deploy_path, deployment):
- return os.path.exists(os.path.join(deploy_path, "%s.deployed"%(deployment)))
-
-def is_undeployed(deploy_path, deployment):
- return os.path.exists(os.path.join(deploy_path, "%s.undeployed"%(deployment)))
-
-def is_failed(deploy_path, deployment):
- return os.path.exists(os.path.join(deploy_path, "%s.failed"%(deployment)))
-
-def main():
- module = AnsibleModule(
- argument_spec = dict(
- src=dict(),
- deployment=dict(required=True),
- deploy_path=dict(default='/var/lib/jbossas/standalone/deployments'),
- state=dict(choices=['absent', 'present'], default='present'),
- ),
- )
-
- changed = False
-
- src = module.params['src']
- deployment = module.params['deployment']
- deploy_path = module.params['deploy_path']
- state = module.params['state']
-
- if state == 'present' and not src:
- module.fail_json(msg="Argument 'src' required.")
-
- if not os.path.exists(deploy_path):
- module.fail_json(msg="deploy_path does not exist.")
-
- deployed = is_deployed(deploy_path, deployment)
-
- if state == 'present' and not deployed:
- if not os.path.exists(src):
- module.fail_json(msg='Source file %s does not exist.'%(src))
- if is_failed(deploy_path, deployment):
- ### Clean up old failed deployment
- os.remove(os.path.join(deploy_path, "%s.failed"%(deployment)))
-
- shutil.copyfile(src, os.path.join(deploy_path, deployment))
- while not deployed:
- deployed = is_deployed(deploy_path, deployment)
- if is_failed(deploy_path, deployment):
- module.fail_json(msg='Deploying %s failed.'%(deployment))
- time.sleep(1)
- changed = True
-
- if state == 'present' and deployed:
- if module.md5(src) != module.md5(os.path.join(deploy_path, deployment)):
- os.remove(os.path.join(deploy_path, "%s.deployed"%(deployment)))
- shutil.copyfile(src, os.path.join(deploy_path, deployment))
- deployed = False
- while not deployed:
- deployed = is_deployed(deploy_path, deployment)
- if is_failed(deploy_path, deployment):
- module.fail_json(msg='Deploying %s failed.'%(deployment))
- time.sleep(1)
- changed = True
-
- if state == 'absent' and deployed:
- os.remove(os.path.join(deploy_path, "%s.deployed"%(deployment)))
- while deployed:
- deployed = not is_undeployed(deploy_path, deployment)
- if is_failed(deploy_path, deployment):
- module.fail_json(msg='Undeploying %s failed.'%(deployment))
- time.sleep(1)
- changed = True
-
- module.exit_json(changed=changed)
-
-# import module snippets
-from ansible.module_utils.basic import *
-main()
diff --git a/web_infrastructure/jira b/web_infrastructure/jira
deleted file mode 100644
index 950fc3db..00000000
--- a/web_infrastructure/jira
+++ /dev/null
@@ -1,347 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-
-# (c) 2014, Steve Smith <ssmith@atlassian.com>
-# Atlassian open-source approval reference OSR-76.
-#
-# 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/>.
-#
-
-DOCUMENTATION = """
-module: jira
-version_added: "1.6"
-short_description: create and modify issues in a JIRA instance
-description:
- - Create and modify issues in a JIRA instance.
-
-options:
- uri:
- required: true
- description:
- - Base URI for the JIRA instance
-
- operation:
- required: true
- aliases: [ command ]
- choices: [ create, comment, edit, fetch, transition ]
- description:
- - The operation to perform.
-
- username:
- required: true
- description:
- - The username to log-in with.
-
- password:
- required: true
- description:
- - The password to log-in with.
-
- project:
- aliases: [ prj ]
- required: false
- description:
- - The project for this operation. Required for issue creation.
-
- summary:
- required: false
- description:
- - The issue summary, where appropriate.
-
- description:
- required: false
- description:
- - The issue description, where appropriate.
-
- issuetype:
- required: false
- description:
- - The issue type, for issue creation.
-
- issue:
- required: false
- description:
- - An existing issue key to operate on.
-
- comment:
- required: false
- description:
- - The comment text to add.
-
- status:
- required: false
- description:
- - The desired status; only relevant for the transition operation.
-
- assignee:
- required: false
- description:
- - Sets the assignee on create or transition operations. Note not all transitions will allow this.
-
- fields:
- required: false
- description:
- - This is a free-form data structure that can contain arbitrary data. This is passed directly to the JIRA REST API (possibly after merging with other required data, as when passed to create). See examples for more information, and the JIRA REST API for the structure required for various fields.
-
-notes:
- - "Currently this only works with basic-auth."
-
-author: Steve Smith
-"""
-
-EXAMPLES = """
-# Create a new issue and add a comment to it:
-- name: Create an issue
- jira: uri={{server}} username={{user}} password={{pass}}
- project=ANS operation=create
- summary="Example Issue" description="Created using Ansible" issuetype=Task
- register: issue
-
-- name: Comment on issue
- jira: uri={{server}} username={{user}} password={{pass}}
- issue={{issue.meta.key}} operation=comment
- comment="A comment added by Ansible"
-
-# Assign an existing issue using edit
-- name: Assign an issue using free-form fields
- jira: uri={{server}} username={{user}} password={{pass}}
- issue={{issue.meta.key}} operation=edit
- assignee=ssmith
-
-# Create an issue with an existing assignee
-- name: Create an assigned issue
- jira: uri={{server}} username={{user}} password={{pass}}
- project=ANS operation=create
- summary="Assigned issue" description="Created and assigned using Ansible"
- issuetype=Task assignee=ssmith
-
-# Edit an issue using free-form fields
-- name: Set the labels on an issue using free-form fields
- jira: uri={{server}} username={{user}} password={{pass}}
- issue={{issue.meta.key}} operation=edit
- args: { fields: {labels: ["autocreated", "ansible"]}}
-
-- name: Set the labels on an issue, YAML version
- jira: uri={{server}} username={{user}} password={{pass}}
- issue={{issue.meta.key}} operation=edit
- args:
- fields:
- labels:
- - "autocreated"
- - "ansible"
- - "yaml"
-
-# Retrieve metadata for an issue and use it to create an account
-- name: Get an issue
- jira: uri={{server}} username={{user}} password={{pass}}
- project=ANS operation=fetch issue="ANS-63"
- register: issue
-
-- name: Create a unix account for the reporter
- sudo: true
- user: name="{{issue.meta.fields.creator.name}}" comment="{{issue.meta.fields.creator.displayName}}"
-
-# Transition an issue by target status
-- name: Close the issue
- jira: uri={{server}} username={{user}} password={{pass}}
- issue={{issue.meta.key}} operation=transition status="Done"
-"""
-
-import json
-import base64
-
-def request(url, user, passwd, data=None, method=None):
- if data:
- data = json.dumps(data)
-
- # NOTE: fetch_url uses a password manager, which follows the
- # standard request-then-challenge basic-auth semantics. However as
- # JIRA allows some unauthorised operations it doesn't necessarily
- # send the challenge, so the request occurs as the anonymous user,
- # resulting in unexpected results. To work around this we manually
- # inject the basic-auth header up-front to ensure that JIRA treats
- # the requests as authorized for this user.
- auth = base64.encodestring('%s:%s' % (user, passwd)).replace('\n', '')
- response, info = fetch_url(module, url, data=data, method=method,
- headers={'Content-Type':'application/json',
- 'Authorization':"Basic %s" % auth})
-
- if info['status'] not in (200, 204):
- module.fail_json(msg=info['msg'])
-
- body = response.read()
-
- if body:
- return json.loads(body)
- else:
- return {}
-
-def post(url, user, passwd, data):
- return request(url, user, passwd, data=data, method='POST')
-
-def put(url, user, passwd, data):
- return request(url, user, passwd, data=data, method='PUT')
-
-def get(url, user, passwd):
- return request(url, user, passwd)
-
-
-def create(restbase, user, passwd, params):
- createfields = {
- 'project': { 'key': params['project'] },
- 'summary': params['summary'],
- 'description': params['description'],
- 'issuetype': { 'name': params['issuetype'] }}
-
- # Merge in any additional or overridden fields
- if params['fields']:
- createfields.update(params['fields'])
-
- data = {'fields': createfields}
-
- url = restbase + '/issue/'
-
- ret = post(url, user, passwd, data)
-
- return ret
-
-
-def comment(restbase, user, passwd, params):
- data = {
- 'body': params['comment']
- }
-
- url = restbase + '/issue/' + params['issue'] + '/comment'
-
- ret = post(url, user, passwd, data)
-
- return ret
-
-
-def edit(restbase, user, passwd, params):
- data = {
- 'fields': params['fields']
- }
-
- url = restbase + '/issue/' + params['issue']
-
- ret = put(url, user, passwd, data)
-
- return ret
-
-
-def fetch(restbase, user, passwd, params):
- url = restbase + '/issue/' + params['issue']
- ret = get(url, user, passwd)
- return ret
-
-
-def transition(restbase, user, passwd, params):
- # Find the transition id
- turl = restbase + '/issue/' + params['issue'] + "/transitions"
- tmeta = get(turl, user, passwd)
-
- target = params['status']
- tid = None
- for t in tmeta['transitions']:
- if t['name'] == target:
- tid = t['id']
- break
-
- if not tid:
- raise ValueError("Failed find valid transition for '%s'" % target)
-
- # Perform it
- url = restbase + '/issue/' + params['issue'] + "/transitions"
- data = { 'transition': { "id" : tid },
- 'fields': params['fields']}
-
- ret = post(url, user, passwd, data)
-
- return ret
-
-
-# Some parameters are required depending on the operation:
-OP_REQUIRED = dict(create=['project', 'issuetype', 'summary', 'description'],
- comment=['issue', 'comment'],
- edit=[],
- fetch=['issue'],
- transition=['status'])
-
-def main():
-
- global module
- module = AnsibleModule(
- argument_spec=dict(
- uri=dict(required=True),
- operation=dict(choices=['create', 'comment', 'edit', 'fetch', 'transition'],
- aliases=['command'], required=True),
- username=dict(required=True),
- password=dict(required=True),
- project=dict(),
- summary=dict(),
- description=dict(),
- issuetype=dict(),
- issue=dict(aliases=['ticket']),
- comment=dict(),
- status=dict(),
- assignee=dict(),
- fields=dict(default={})
- ),
- supports_check_mode=False
- )
-
- op = module.params['operation']
-
- # Check we have the necessary per-operation parameters
- missing = []
- for parm in OP_REQUIRED[op]:
- if not module.params[parm]:
- missing.append(parm)
- if missing:
- module.fail_json(msg="Operation %s require the following missing parameters: %s" % (op, ",".join(missing)))
-
- # Handle rest of parameters
- uri = module.params['uri']
- user = module.params['username']
- passwd = module.params['password']
- if module.params['assignee']:
- module.params['fields']['assignee'] = { 'name': module.params['assignee'] }
-
- if not uri.endswith('/'):
- uri = uri+'/'
- restbase = uri + 'rest/api/2'
-
- # Dispatch
- try:
-
- # Lookup the corresponding method for this operation. This is
- # safe as the AnsibleModule should remove any unknown operations.
- thismod = sys.modules[__name__]
- method = getattr(thismod, op)
-
- ret = method(restbase, user, passwd, module.params)
-
- except Exception as e:
- return module.fail_json(msg=e.message)
-
-
- module.exit_json(changed=True, meta=ret)
-
-
-from ansible.module_utils.basic import *
-from ansible.module_utils.urls import *
-main()
diff --git a/web_infrastructure/supervisorctl b/web_infrastructure/supervisorctl
deleted file mode 100644
index 2d458169..00000000
--- a/web_infrastructure/supervisorctl
+++ /dev/null
@@ -1,221 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-
-# (c) 2012, Matt Wright <matt@nobien.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/>.
-#
-import os
-
-DOCUMENTATION = '''
----
-module: supervisorctl
-short_description: Manage the state of a program or group of programs running via supervisord
-description:
- - Manage the state of a program or group of programs running via supervisord
-version_added: "0.7"
-options:
- name:
- description:
- - The name of the supervisord program or group to manage.
- - The name will be taken as group name when it ends with a colon I(:)
- - Group support is only available in Ansible version 1.6 or later.
- required: true
- default: null
- config:
- description:
- - The supervisor configuration file path
- required: false
- default: null
- version_added: "1.3"
- server_url:
- description:
- - URL on which supervisord server is listening
- required: false
- default: null
- version_added: "1.3"
- username:
- description:
- - username to use for authentication
- required: false
- default: null
- version_added: "1.3"
- password:
- description:
- - password to use for authentication
- required: false
- default: null
- version_added: "1.3"
- state:
- description:
- - The desired state of program/group.
- required: true
- default: null
- choices: [ "present", "started", "stopped", "restarted" ]
- supervisorctl_path:
- description:
- - path to supervisorctl executable
- required: false
- default: null
- version_added: "1.4"
-notes:
- - When C(state) = I(present), the module will call C(supervisorctl reread) then C(supervisorctl add) if the program/group does not exist.
- - When C(state) = I(restarted), the module will call C(supervisorctl update) then call C(supervisorctl restart).
-requirements: [ "supervisorctl" ]
-author: Matt Wright, Aaron Wang <inetfuture@gmail.com>
-'''
-
-EXAMPLES = '''
-# Manage the state of program to be in 'started' state.
-- supervisorctl: name=my_app state=started
-
-# Manage the state of program group to be in 'started' state.
-- supervisorctl: name='my_apps:' state=started
-
-# Restart my_app, reading supervisorctl configuration from a specified file.
-- supervisorctl: name=my_app state=restarted config=/var/opt/my_project/supervisord.conf
-
-# Restart my_app, connecting to supervisord with credentials and server URL.
-- supervisorctl: name=my_app state=restarted username=test password=testpass server_url=http://localhost:9001
-'''
-
-
-def main():
- arg_spec = dict(
- name=dict(required=True),
- config=dict(required=False),
- server_url=dict(required=False),
- username=dict(required=False),
- password=dict(required=False),
- supervisorctl_path=dict(required=False),
- state=dict(required=True, choices=['present', 'started', 'restarted', 'stopped'])
- )
-
- module = AnsibleModule(argument_spec=arg_spec, supports_check_mode=True)
-
- name = module.params['name']
- is_group = False
- if name.endswith(':'):
- is_group = True
- name = name.rstrip(':')
- state = module.params['state']
- config = module.params.get('config')
- server_url = module.params.get('server_url')
- username = module.params.get('username')
- password = module.params.get('password')
- supervisorctl_path = module.params.get('supervisorctl_path')
-
- if supervisorctl_path:
- supervisorctl_path = os.path.expanduser(supervisorctl_path)
- if os.path.exists(supervisorctl_path) and module.is_executable(supervisorctl_path):
- supervisorctl_args = [supervisorctl_path]
- else:
- module.fail_json(
- msg="Provided path to supervisorctl does not exist or isn't executable: %s" % supervisorctl_path)
- else:
- supervisorctl_args = [module.get_bin_path('supervisorctl', True)]
-
- if config:
- supervisorctl_args.extend(['-c', os.path.expanduser(config)])
- if server_url:
- supervisorctl_args.extend(['-s', server_url])
- if username:
- supervisorctl_args.extend(['-u', username])
- if password:
- supervisorctl_args.extend(['-p', password])
-
- def run_supervisorctl(cmd, name=None, **kwargs):
- args = list(supervisorctl_args) # copy the master args
- args.append(cmd)
- if name:
- args.append(name)
- return module.run_command(args, **kwargs)
-
- def get_matched_processes():
- matched = []
- rc, out, err = run_supervisorctl('status')
- for line in out.splitlines():
- # One status line may look like one of these two:
- # process not in group:
- # echo_date_lonely RUNNING pid 7680, uptime 13:22:18
- # process in group:
- # echo_date_group:echo_date_00 RUNNING pid 7681, uptime 13:22:18
- fields = [field for field in line.split(' ') if field != '']
- process_name = fields[0]
- status = fields[1]
-
- if is_group:
- # If there is ':', this process must be in a group.
- if ':' in process_name:
- group = process_name.split(':')[0]
- if group != name:
- continue
- else:
- continue
- else:
- if process_name != name:
- continue
-
- matched.append((process_name, status))
- return matched
-
- def take_action_on_processes(processes, status_filter, action, expected_result):
- to_take_action_on = []
- for process_name, status in processes:
- if status_filter(status):
- to_take_action_on.append(process_name)
-
- if len(to_take_action_on) == 0:
- module.exit_json(changed=False, name=name, state=state)
- if module.check_mode:
- module.exit_json(changed=True)
- for process_name in to_take_action_on:
- rc, out, err = run_supervisorctl(action, process_name)
- if '%s: %s' % (process_name, expected_result) not in out:
- module.fail_json(msg=out)
-
- module.exit_json(changed=True, name=name, state=state, affected=to_take_action_on)
-
- if state == 'restarted':
- rc, out, err = run_supervisorctl('update')
- processes = get_matched_processes()
- take_action_on_processes(processes, lambda s: True, 'restart', 'started')
-
- processes = get_matched_processes()
-
- if state == 'present':
- if len(processes) > 0:
- module.exit_json(changed=False, name=name, state=state)
-
- if module.check_mode:
- module.exit_json(changed=True)
- run_supervisorctl('reread', check_rc=True)
- rc, out, err = run_supervisorctl('add', name)
- if '%s: added process group' % name in out:
- module.exit_json(changed=True, name=name, state=state)
- else:
- module.fail_json(msg=out, name=name, state=state)
-
- if state == 'started':
- take_action_on_processes(processes, lambda s: s != 'RUNNING', 'start', 'started')
-
- if state == 'stopped':
- take_action_on_processes(processes, lambda s: s == 'RUNNING', 'stop', 'stopped')
-
-# import module snippets
-from ansible.module_utils.basic import *
-
-main()