Native YAML - Web infrastructure (#3594)
* Native YAML * YAML for jira as well * Native YAML for Jboss * Fix missing spaces
This commit is contained in:
parent
367a0c5d99
commit
5209969a7c
5 changed files with 202 additions and 85 deletions
|
@ -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 = '''
|
||||
|
|
|
@ -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']
|
||||
- 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.shared_path }}/{{ item }}'
|
||||
state: directory
|
||||
with_items:
|
||||
- { path: "app/sessions", src: "sessions" }
|
||||
- { path: "web/uploads", src: "uploads" }
|
||||
- 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
|
||||
with_items:
|
||||
- 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
|
||||
|
|
|
@ -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
|
||||
ejabberd_user:
|
||||
username: test
|
||||
host: server
|
||||
password: password
|
||||
|
||||
- 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: 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 *
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
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
|
||||
# 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:
|
||||
|
|
Loading…
Reference in a new issue