summaryrefslogtreecommitdiff
path: root/web_infrastructure
diff options
context:
space:
mode:
authorFabio Alessandro Locati <me@fale.io>2016-12-01 13:58:22 +0000
committerJohn R Barker <john@johnrbarker.com>2016-12-01 13:58:22 +0000
commite7064125095503bffb8b11a2473ed285d257197d (patch)
tree59cf8d35f6e6c5c250f2653276b8abcd5dc312b2 /web_infrastructure
parent1edda31110686907e49e7d1bdee03a70f4cd1e8e (diff)
downloadansible-modules-extras-e7064125095503bffb8b11a2473ed285d257197d.tar.gz
Native YAML - Web infrastructure (#3594)
* Native YAML * YAML for jira as well * Native YAML for Jboss * Fix missing spaces
Diffstat (limited to 'web_infrastructure')
-rw-r--r--web_infrastructure/apache2_mod_proxy.py36
-rw-r--r--web_infrastructure/deploy_helper.py120
-rw-r--r--web_infrastructure/ejabberd_user.py19
-rw-r--r--web_infrastructure/jboss.py16
-rwxr-xr-xweb_infrastructure/jira.py98
5 files changed, 203 insertions, 86 deletions
diff --git a/web_infrastructure/apache2_mod_proxy.py b/web_infrastructure/apache2_mod_proxy.py
index 0117c118..34bc0c80 100644
--- a/web_infrastructure/apache2_mod_proxy.py
+++ b/web_infrastructure/apache2_mod_proxy.py
@@ -71,21 +71,41 @@ options:
EXAMPLES = '''
# Get all current balancer pool members' attributes:
-- apache2_mod_proxy: balancer_vhost=10.0.0.2
+- apache2_mod_proxy:
+ balancer_vhost: 10.0.0.2
# Get a specific member's attributes:
-- apache2_mod_proxy: balancer_vhost=myws.mydomain.org balancer_suffix="/lb/" member_host=node1.myws.mydomain.org
+- apache2_mod_proxy:
+ balancer_vhost: myws.mydomain.org
+ balancer_suffix: /lb/
+ member_host: node1.myws.mydomain.org
# Enable all balancer pool members:
-- apache2_mod_proxy: balancer_vhost="{{ myloadbalancer_host }}"
+- apache2_mod_proxy:
+ balancer_vhost: '{{ myloadbalancer_host }}'
register: result
-- apache2_mod_proxy: balancer_vhost="{{ myloadbalancer_host }}" member_host="{{ item.host }}" state=present
- with_items: "{{ result.members }}"
+- apache2_mod_proxy:
+ balancer_vhost: '{{ myloadbalancer_host }}'
+ member_host: '{{ item.host }}'
+ state: present
+ with_items: '{{ result.members }}'
# Gracefully disable a member from a loadbalancer node:
-- apache2_mod_proxy: balancer_vhost="{{ vhost_host }}" member_host="{{ member.host }}" state=drained delegate_to=myloadbalancernode
-- wait_for: host="{{ member.host }}" port={{ member.port }} state=drained delegate_to=myloadbalancernode
-- apache2_mod_proxy: balancer_vhost="{{ vhost_host }}" member_host="{{ member.host }}" state=absent delegate_to=myloadbalancernode
+- apache2_mod_proxy:
+ balancer_vhost: '{{ vhost_host }}'
+ member_host: '{{ member.host }}'
+ state: drained
+ delegate_to: myloadbalancernode
+- wait_for:
+ host: '{{ member.host }}'
+ port: '{{ member.port }}'
+ state: drained
+ delegate_to: myloadbalancernode
+- apache2_mod_proxy:
+ balancer_vhost: '{{ vhost_host }}'
+ member_host: '{{ member.host }}'
+ state: absent
+ delegate_to: myloadbalancernode
'''
RETURN = '''
diff --git a/web_infrastructure/deploy_helper.py b/web_infrastructure/deploy_helper.py
index b956e38d..6fbdd141 100644
--- a/web_infrastructure/deploy_helper.py
+++ b/web_infrastructure/deploy_helper.py
@@ -163,69 +163,121 @@ procedure to remove it during cleanup.
# Typical usage:
- name: Initialize the deploy root and gather facts
- deploy_helper: path=/path/to/root
+ deploy_helper:
+ path: /path/to/root
- name: Clone the project to the new release folder
- git: repo=git://foosball.example.org/path/to/repo.git dest={{ deploy_helper.new_release_path }} version=v1.1.1
+ git:
+ repo: 'git://foosball.example.org/path/to/repo.git'
+ dest: '{{ deploy_helper.new_release_path }}'
+ version: 'v1.1.1'
- name: Add an unfinished file, to allow cleanup on successful finalize
- file: path={{ deploy_helper.new_release_path }}/{{ deploy_helper.unfinished_filename }} state=touch
+ file:
+ path: '{{ deploy_helper.new_release_path }}/{{ deploy_helper.unfinished_filename }}'
+ state: touch
- name: Perform some build steps, like running your dependency manager for example
- composer: command=install working_dir={{ deploy_helper.new_release_path }}
+ composer:
+ command: install
+ working_dir: '{{ deploy_helper.new_release_path }}'
- name: Create some folders in the shared folder
- file: path='{{ deploy_helper.shared_path }}/{{ item }}' state=directory
- with_items: ['sessions', 'uploads']
+ file:
+ path: '{{ deploy_helper.shared_path }}/{{ item }}'
+ state: directory
+ with_items:
+ - sessions
+ - uploads
- name: Add symlinks from the new release to the shared folder
- file: path='{{ deploy_helper.new_release_path }}/{{ item.path }}'
- src='{{ deploy_helper.shared_path }}/{{ item.src }}'
- state=link
+ file:
+ path: '{{ deploy_helper.new_release_path }}/{{ item.path }}'
+ src: '{{ deploy_helper.shared_path }}/{{ item.src }}'
+ state: link
with_items:
- - { path: "app/sessions", src: "sessions" }
- - { path: "web/uploads", src: "uploads" }
+ - path: app/sessions
+ src: sessions
+ - path: web/uploads
+ src: uploads
- name: Finalize the deploy, removing the unfinished file and switching the symlink
- deploy_helper: path=/path/to/root release={{ deploy_helper.new_release }} state=finalize
+ deploy_helper:
+ path: /path/to/root
+ release: '{{ deploy_helper.new_release }}'
+ state: finalize
# Retrieving facts before running a deploy
- name: Run 'state=query' to gather facts without changing anything
- deploy_helper: path=/path/to/root state=query
+ deploy_helper:
+ path: /path/to/root
+ state: query
# Remember to set the 'release' parameter when you actually call 'state=present' later
- name: Initialize the deploy root
- deploy_helper: path=/path/to/root release={{ deploy_helper.new_release }} state=present
+ deploy_helper:
+ path: /path/to/root
+ release: '{{ deploy_helper.new_release }}'
+ state: present
# all paths can be absolute or relative (to the 'path' parameter)
-- deploy_helper: path=/path/to/root
- releases_path=/var/www/project/releases
- shared_path=/var/www/shared
- current_path=/var/www/active
+- deploy_helper:
+ path: /path/to/root
+ releases_path: /var/www/project/releases
+ shared_path: /var/www/shared
+ current_path: /var/www/active
# Using your own naming strategy for releases (a version tag in this case):
-- deploy_helper: path=/path/to/root release=v1.1.1 state=present
-- deploy_helper: path=/path/to/root release={{ deploy_helper.new_release }} state=finalize
+- deploy_helper:
+ path: /path/to/root
+ release: 'v1.1.1'
+ state: present
+- deploy_helper:
+ path: /path/to/root
+ release: '{{ deploy_helper.new_release }}'
+ state: finalize
# Using a different unfinished_filename:
-- deploy_helper: path=/path/to/root
- unfinished_filename=README.md
- release={{ deploy_helper.new_release }}
- state=finalize
+- deploy_helper:
+ path: /path/to/root
+ unfinished_filename: README.md
+ release: '{{ deploy_helper.new_release }}'
+ state: finalize
# Postponing the cleanup of older builds:
-- deploy_helper: path=/path/to/root release={{ deploy_helper.new_release }} state=finalize clean=False
-- deploy_helper: path=/path/to/root state=clean
+- deploy_helper:
+ path: /path/to/root
+ release: '{{ deploy_helper.new_release }}'
+ state: finalize
+ clean: False
+- deploy_helper:
+ path: /path/to/root
+ state: clean
# Or running the cleanup ahead of the new deploy
-- deploy_helper: path=/path/to/root state=clean
-- deploy_helper: path=/path/to/root state=present
+- deploy_helper:
+ path: /path/to/root
+ state: clean
+- deploy_helper:
+ path: /path/to/root
+ state: present
# Keeping more old releases:
-- deploy_helper: path=/path/to/root release={{ deploy_helper.new_release }} state=finalize keep_releases=10
+- deploy_helper:
+ path: /path/to/root
+ release: '{{ deploy_helper.new_release }}'
+ state: finalize
+ keep_releases: 10
# Or, if you use 'clean=false' on finalize:
-- deploy_helper: path=/path/to/root state=clean keep_releases=10
+- deploy_helper:
+ path: /path/to/root
+ state: clean
+ keep_releases: 10
# Removing the entire project root folder
-- deploy_helper: path=/path/to/root state=absent
+- deploy_helper:
+ path: /path/to/root
+ state: absent
# Debugging the facts returned by the module
-- deploy_helper: path=/path/to/root
-- debug: var=deploy_helper
-
+- deploy_helper:
+ path: /path/to/root
+- debug:
+ var: deploy_helper
'''
+
# import module snippets
from ansible.module_utils.basic import *
from ansible.module_utils.pycompat24 import get_exception
diff --git a/web_infrastructure/ejabberd_user.py b/web_infrastructure/ejabberd_user.py
index e89918a2..0f47167f 100644
--- a/web_infrastructure/ejabberd_user.py
+++ b/web_infrastructure/ejabberd_user.py
@@ -59,14 +59,19 @@ notes:
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
+- name: create a user if it does not exists
+ ejabberd_user:
+ username: test
+ host: server
+ password: password
+
+- name: delete a user if it exists
+ ejabberd_user:
+ username: test
+ host: server
+ state: absent
'''
+
import syslog
from ansible.module_utils.pycompat24 import get_exception
from ansible.module_utils.basic import *
diff --git a/web_infrastructure/jboss.py b/web_infrastructure/jboss.py
index 9ec67b7c..53ffcf1f 100644
--- a/web_infrastructure/jboss.py
+++ b/web_infrastructure/jboss.py
@@ -52,11 +52,21 @@ author: "Jeroen Hoekx (@jhoekx)"
EXAMPLES = """
# Deploy a hello world application
-- jboss: src=/tmp/hello-1.0-SNAPSHOT.war deployment=hello.war state=present
+- 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
+- jboss:
+ src: /tmp/hello-1.1-SNAPSHOT.war
+ deployment: hello.war
+ state: present
+
# Undeploy the hello world application
-- jboss: deployment=hello.war state=absent
+- jboss:
+ deployment: hello.war
+ state: absent
"""
import os
diff --git a/web_infrastructure/jira.py b/web_infrastructure/jira.py
index 85b988d2..479e623b 100755
--- a/web_infrastructure/jira.py
+++ b/web_infrastructure/jira.py
@@ -105,59 +105,89 @@ author: "Steve Smith (@tarka)"
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
+ 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"
+ 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
+ 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
+ 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
- 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"
+ jira:
+ uri: '{{ server }}'
+ username: '{{ user }}'
+ password: '{{ pass }}'
+ issue: '{{ issue.meta.key }}'
+ operation: edit
+ args:
+ fields:
+ labels:
+ - autocreated
+ - ansible
# 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"
+ 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}}"
+ become: 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"
+ jira:
+ uri: '{{ server }}'
+ username: '{{ user }}'
+ password: '{{ pass }}'
+ issue: '{{ issue.meta.key }}'
+ operation: transition
+ status: Done
"""
try: