Commit ba4e36a9 by Michael DeHaan

Rename 'ensure' to 'state' because I think it's a bit cleaner and doesn't imply

all modules take a common parameter name.  But more or less we still work idempotently
in modules.
parent 228d1a08
...@@ -149,16 +149,16 @@ up around the library scripts, and you can easily write your own. ...@@ -149,16 +149,16 @@ up around the library scripts, and you can easily write your own.
Current modules include: Current modules include:
* command -- runs commands, giving output, return codes, and run time info * command - runs commands, giving output, return codes, and run time info
* ping - just returns if the system is up or not * ping - just returns if the system is up or not
* facter - retrieves facts about the host OS * facter - retrieves facts about the host OS
* ohai - similar to facter, but returns structured data * ohai - similar to facter, but returns structured data
* copy - add files to remote systems * copy - add files to remote systems
* setup - pushes key/value data onto the system for use in templating * setup - pushes key/value data onto the system for use in templating
* template - takes a local template file and saves a templated version remotely * template - takes a local template file and saves a templated version remotely
* git - deploy simple apps directly from source control
Service, package, and user modules, supporting puppet-like ensure semantics More coming soon! Contributions welcome!
are coming soon.
Playbooks Playbooks
========= =========
......
'\" t '\" t
.\" Title: ansible-modules .\" Title: ansible-modules
.\" Author: [see the "AUTHOR" section] .\" Author: [see the "AUTHOR" section]
.\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
.\" Date: 02/26/2012 .\" Date: 02/26/2012
.\" Manual: System administration commands .\" Manual: System administration commands
.\" Source: Ansible-modules 0.0.1 .\" Source: Ansible-modules 0.0.1
...@@ -9,15 +9,6 @@ ...@@ -9,15 +9,6 @@
.\" .\"
.TH "ANSIBLE\-MODULES" "5" "02/26/2012" "Ansible\-modules 0\&.0\&.1" "System administration commands" .TH "ANSIBLE\-MODULES" "5" "02/26/2012" "Ansible\-modules 0\&.0\&.1" "System administration commands"
.\" ----------------------------------------------------------------- .\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting .\" * set default formatting
.\" ----------------------------------------------------------------- .\" -----------------------------------------------------------------
.\" disable hyphenation .\" disable hyphenation
...@@ -101,7 +92,7 @@ This module is informative only \- it takes no parameters & does not support cha ...@@ -101,7 +92,7 @@ This module is informative only \- it takes no parameters & does not support cha
.sp .sp
Controls services on remote machines\&. Controls services on remote machines\&.
.PP .PP
\fBensure=\fR \fBstate=\fR
.RS 4 .RS 4
Values are Values are
\fIstarted\fR, \fIstarted\fR,
......
...@@ -121,7 +121,7 @@ service ...@@ -121,7 +121,7 @@ service
Controls services on remote machines. Controls services on remote machines.
*ensure=*:: *state=*::
Values are 'started', 'stopped', or 'restarted'. Started/stopped Values are 'started', 'stopped', or 'restarted'. Started/stopped
are idempotent actions that will not run commands unless neccessary. are idempotent actions that will not run commands unless neccessary.
......
'\" t '\" t
.\" Title: ansible-modules .\" Title: ansible-modules
.\" Author: [see the "AUTHOR" section] .\" Author: [see the "AUTHOR" section]
.\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
.\" Date: 02/26/2012 .\" Date: 02/26/2012
.\" Manual: System administration commands .\" Manual: System administration commands
.\" Source: Ansible-playbook 0.0.1 .\" Source: Ansible-playbook 0.0.1
...@@ -9,15 +9,6 @@ ...@@ -9,15 +9,6 @@
.\" .\"
.TH "ANSIBLE\-MODULES" "5" "02/26/2012" "Ansible\-playbook 0\&.0\&.1" "System administration commands" .TH "ANSIBLE\-MODULES" "5" "02/26/2012" "Ansible\-playbook 0\&.0\&.1" "System administration commands"
.\" ----------------------------------------------------------------- .\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting .\" * set default formatting
.\" ----------------------------------------------------------------- .\" -----------------------------------------------------------------
.\" disable hyphenation .\" disable hyphenation
...@@ -37,29 +28,27 @@ Ansible ships with a ansible\-playbook tool for running playbooks\&. Playbooks c ...@@ -37,29 +28,27 @@ Ansible ships with a ansible\-playbook tool for running playbooks\&. Playbooks c
Playbooks are currently writeable in YAML\&. Other formats (JSON?) may be supported in the future\&. Playbooks are currently writeable in YAML\&. Other formats (JSON?) may be supported in the future\&.
.SH "EXAMPLE" .SH "EXAMPLE"
.sp .sp
FIXME: verify this is correct below
.sp
.if n \{\ .if n \{\
.RS 4 .RS 4
.\} .\}
.nf .nf
\-\-\- \-\-\-
\- pattern: \*(Aq*\*(Aq \- pattern: \'*\'
hosts: \*(Aq/etc/ansible/hosts\*(Aq hosts: \'/etc/ansible/hosts\'
tasks: tasks:
\- do: \- name:configure template & module variables for future template calls
\- configure template & module variables for future template calls action: setup http_port=80 max_clients=200
\- setup http_port=80 max_clients=200 \- name: write the apache config file
\- do: action: template src=/srv/mytemplates/httpd\&.j2 dest=/etc/httpd/conf
\- write the apache config file
\- template src=/srv/mytemplates/httpd\&.j2 dest=/etc/httpd/conf
notify: notify:
\- restart apache \- restart apache
\- do \- name: ensure apache is running
\- ensure apache is running action: service name=httpd ensure=started
\- service name=httpd ensure=started
handlers: handlers:
\- do: \- name: restart apache
\- restart apache \- action: service name=httpd ensure=restarted
\- service name=httpd ensure=restarted
.fi .fi
.if n \{\ .if n \{\
.RE .RE
...@@ -81,9 +70,7 @@ Playbooks are executed top down and can contain multiple references to patterns\ ...@@ -81,9 +70,7 @@ Playbooks are executed top down and can contain multiple references to patterns\
.sp .sp
For each pattern, the tasks in the \fItasks\fR list are executed in order for all hosts in the host file matching the pattern\&. For each pattern, the tasks in the \fItasks\fR list are executed in order for all hosts in the host file matching the pattern\&.
.sp .sp
For each task, a "do" statement describes what the task is and what ansible module to use to accomplish the task, along with any arguments\&. The first line in the "do" is the name of the task \(em this will appear in any log output\&. For each task, a name/action pair describes what the task is and what ansible module to use to accomplish the task, along with any arguments\&. Additional fields like \fIcomment:\fR can be added and will be ignored\&.
.sp
The second line in each "do" is the module name followed by module arguments\&.
.sp .sp
Most modules accept key=value format arguments\&. Most modules accept key=value format arguments\&.
.sp .sp
......
...@@ -29,26 +29,24 @@ be supported in the future. ...@@ -29,26 +29,24 @@ be supported in the future.
EXAMPLE EXAMPLE
------- -------
FIXME: verify this is correct below
[literal] [literal]
--- ---
- pattern: '*' - pattern: '*'
hosts: '/etc/ansible/hosts' hosts: '/etc/ansible/hosts'
tasks: tasks:
- do: - name:configure template & module variables for future template calls
- configure template & module variables for future template calls action: setup http_port=80 max_clients=200
- setup http_port=80 max_clients=200 - name: write the apache config file
- do: action: template src=/srv/mytemplates/httpd.j2 dest=/etc/httpd/conf
- write the apache config file
- template src=/srv/mytemplates/httpd.j2 dest=/etc/httpd/conf
notify: notify:
- restart apache - restart apache
- do - name: ensure apache is running
- ensure apache is running action: service name=httpd ensure=started
- service name=httpd ensure=started
handlers: handlers:
- do: - name: restart apache
- restart apache - action: service name=httpd ensure=restarted
- service name=httpd ensure=restarted
WHAT THE EXAMPLE MEANS WHAT THE EXAMPLE MEANS
...@@ -82,13 +80,10 @@ something different to all webservers again. ...@@ -82,13 +80,10 @@ something different to all webservers again.
For each pattern, the tasks in the 'tasks' list are executed in order For each pattern, the tasks in the 'tasks' list are executed in order
for all hosts in the host file matching the pattern. for all hosts in the host file matching the pattern.
For each task, a "do" statement describes what the task is and what For each task, a name/action pair describes what the task is and what
ansible module to use to accomplish the task, along with any ansible module to use to accomplish the task, along with any
arguments. The first line in the "do" is the name of the task -- this arguments. Additional fields like 'comment:' can be added and will
will appear in any log output. be ignored.
The second line in each "do" is the module name followed by module
arguments.
Most modules accept key=value format arguments. Most modules accept key=value format arguments.
......
...@@ -17,4 +17,4 @@ ...@@ -17,4 +17,4 @@
action: command /bin/false action: command /bin/false
handlers: handlers:
- name: restart apache - name: restart apache
action: service name=httpd ensure=restarted action: service name=httpd state=restarted
...@@ -10,7 +10,7 @@ except ImportError: ...@@ -10,7 +10,7 @@ except ImportError:
import simplejson as json import simplejson as json
# =========================================== # ===========================================
# convert arguments of form ensure=running name=foo # convert arguments of form a=b c=d
# to a dictionary # to a dictionary
# FIXME: make more idiomatic # FIXME: make more idiomatic
......
...@@ -16,7 +16,7 @@ import shlex ...@@ -16,7 +16,7 @@ import shlex
import subprocess import subprocess
# =========================================== # ===========================================
# convert arguments of form ensure=running name=foo # convert arguments of form a=b c=d
# to a dictionary # to a dictionary
# FIXME: make more idiomatic # FIXME: make more idiomatic
......
...@@ -10,7 +10,7 @@ import shlex ...@@ -10,7 +10,7 @@ import shlex
import subprocess import subprocess
# =========================================== # ===========================================
# convert arguments of form ensure=running name=foo # convert arguments of form a=b c=d
# to a dictionary # to a dictionary
# FIXME: make more idiomatic # FIXME: make more idiomatic
...@@ -22,7 +22,7 @@ for x in items: ...@@ -22,7 +22,7 @@ for x in items:
params[k] = v params[k] = v
name = params['name'] name = params['name']
ensure = params.get('ensure','running') state = params.get('state','running')
# =========================================== # ===========================================
# get service status # get service status
...@@ -43,11 +43,11 @@ elif name == 'iptables' and status.find("ACCEPT") != -1: ...@@ -43,11 +43,11 @@ elif name == 'iptables' and status.find("ACCEPT") != -1:
running = True running = True
changed = False changed = False
if not running and ensure == "started": if not running and state == "started":
changed = True changed = True
elif running and ensure == "stopped": elif running and state == "stopped":
changed = True changed = True
elif ensure == "restarted": elif state == "restarted":
changed = True changed = True
# =========================================== # ===========================================
...@@ -61,11 +61,11 @@ def _run(cmd): ...@@ -61,11 +61,11 @@ def _run(cmd):
rc = 0 rc = 0
if changed: if changed:
if ensure == 'started': if state == 'started':
rc = _run("/sbin/service %s start" % name) rc = _run("/sbin/service %s start" % name)
elif ensure == 'stopped': elif state == 'stopped':
rc = _run("/sbin/service %s stop" % name) rc = _run("/sbin/service %s stop" % name)
elif ensure == 'restarted': elif state == 'restarted':
rc1 = _run("/sbin/service %s stop" % name) rc1 = _run("/sbin/service %s stop" % name)
rc2 = _run("/sbin/service %s start" % name) rc2 = _run("/sbin/service %s start" % name)
rc = rc1 and rc2 rc = rc1 and rc2
......
...@@ -10,7 +10,7 @@ except ImportError: ...@@ -10,7 +10,7 @@ except ImportError:
import simplejson as json import simplejson as json
# =========================================== # ===========================================
# convert arguments of form ensure=running name=foo # convert arguments of form a=b c=d
# to a dictionary # to a dictionary
# FIXME: make more idiomatic # FIXME: make more idiomatic
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment