From ba4e36a9a915548774f27522a00c757c10d2fbb5 Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Sun, 26 Feb 2012 22:31:42 -0500 Subject: [PATCH] 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. --- README.md | 6 ++-- docs/man/man5/ansible-modules.5 | 13 ++----- docs/man/man5/ansible-modules.5.asciidoc | 2 +- docs/man/man5/ansible-playbook.5 | 41 ++++++++--------------- docs/man/man5/ansible-playbook.5.asciidoc | 31 +++++++---------- examples/playbook.yml | 2 +- library/copy | 2 +- library/git | 2 +- library/service | 16 ++++----- library/template | 2 +- 10 files changed, 45 insertions(+), 72 deletions(-) diff --git a/README.md b/README.md index a6d3c16e20e..08392d7f65f 100644 --- a/README.md +++ b/README.md @@ -149,16 +149,16 @@ up around the library scripts, and you can easily write your own. 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 * facter - retrieves facts about the host OS * ohai - similar to facter, but returns structured data * copy - add files to remote systems * setup - pushes key/value data onto the system for use in templating * 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 -are coming soon. +More coming soon! Contributions welcome! Playbooks ========= diff --git a/docs/man/man5/ansible-modules.5 b/docs/man/man5/ansible-modules.5 index 5ab7966999b..132ddba00b8 100644 --- a/docs/man/man5/ansible-modules.5 +++ b/docs/man/man5/ansible-modules.5 @@ -1,7 +1,7 @@ '\" t .\" Title: ansible-modules .\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.76.1 +.\" Generator: DocBook XSL Stylesheets v1.75.2 .\" Date: 02/26/2012 .\" Manual: System administration commands .\" Source: Ansible-modules 0.0.1 @@ -9,15 +9,6 @@ .\" .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 .\" ----------------------------------------------------------------- .\" disable hyphenation @@ -101,7 +92,7 @@ This module is informative only \- it takes no parameters & does not support cha .sp Controls services on remote machines\&. .PP -\fBensure=\fR +\fBstate=\fR .RS 4 Values are \fIstarted\fR, diff --git a/docs/man/man5/ansible-modules.5.asciidoc b/docs/man/man5/ansible-modules.5.asciidoc index f82ae6ed5c8..cde62b0ba95 100644 --- a/docs/man/man5/ansible-modules.5.asciidoc +++ b/docs/man/man5/ansible-modules.5.asciidoc @@ -121,7 +121,7 @@ service Controls services on remote machines. -*ensure=*:: +*state=*:: Values are 'started', 'stopped', or 'restarted'. Started/stopped are idempotent actions that will not run commands unless neccessary. diff --git a/docs/man/man5/ansible-playbook.5 b/docs/man/man5/ansible-playbook.5 index 02904edc2c2..aabea67071d 100644 --- a/docs/man/man5/ansible-playbook.5 +++ b/docs/man/man5/ansible-playbook.5 @@ -1,7 +1,7 @@ '\" t .\" Title: ansible-modules .\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.76.1 +.\" Generator: DocBook XSL Stylesheets v1.75.2 .\" Date: 02/26/2012 .\" Manual: System administration commands .\" Source: Ansible-playbook 0.0.1 @@ -9,15 +9,6 @@ .\" .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 .\" ----------------------------------------------------------------- .\" disable hyphenation @@ -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\&. .SH "EXAMPLE" .sp +FIXME: verify this is correct below +.sp .if n \{\ .RS 4 .\} .nf \-\-\- -\- pattern: \*(Aq*\*(Aq - hosts: \*(Aq/etc/ansible/hosts\*(Aq +\- pattern: \'*\' + hosts: \'/etc/ansible/hosts\' tasks: - \- do: - \- configure template & module variables for future template calls - \- setup http_port=80 max_clients=200 - \- do: - \- write the apache config file - \- template src=/srv/mytemplates/httpd\&.j2 dest=/etc/httpd/conf + \- name:configure template & module variables for future template calls + action: setup http_port=80 max_clients=200 + \- name: write the apache config file + action: template src=/srv/mytemplates/httpd\&.j2 dest=/etc/httpd/conf notify: \- restart apache - \- do - \- ensure apache is running - \- service name=httpd ensure=started + \- name: ensure apache is running + action: service name=httpd ensure=started handlers: - \- do: - \- restart apache - \- service name=httpd ensure=restarted + \- name: restart apache + \- action: service name=httpd ensure=restarted .fi .if n \{\ .RE @@ -81,9 +70,7 @@ Playbooks are executed top down and can contain multiple references to patterns\ .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\&. .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\&. -.sp -The second line in each "do" is the module name followed by module arguments\&. +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 Most modules accept key=value format arguments\&. .sp diff --git a/docs/man/man5/ansible-playbook.5.asciidoc b/docs/man/man5/ansible-playbook.5.asciidoc index a01025a85ac..6509dfd6c73 100644 --- a/docs/man/man5/ansible-playbook.5.asciidoc +++ b/docs/man/man5/ansible-playbook.5.asciidoc @@ -29,26 +29,24 @@ be supported in the future. EXAMPLE ------- +FIXME: verify this is correct below + [literal] --- - pattern: '*' hosts: '/etc/ansible/hosts' tasks: - - do: - - configure template & module variables for future template calls - - setup http_port=80 max_clients=200 - - do: - - write the apache config file - - template src=/srv/mytemplates/httpd.j2 dest=/etc/httpd/conf + - name:configure template & module variables for future template calls + action: setup http_port=80 max_clients=200 + - name: write the apache config file + action: template src=/srv/mytemplates/httpd.j2 dest=/etc/httpd/conf notify: - restart apache - - do - - ensure apache is running - - service name=httpd ensure=started + - name: ensure apache is running + action: service name=httpd ensure=started handlers: - - do: - - restart apache - - service name=httpd ensure=restarted + - name: restart apache + - action: service name=httpd ensure=restarted WHAT THE EXAMPLE MEANS @@ -82,13 +80,10 @@ something different to all webservers again. For each pattern, the tasks in the 'tasks' list are executed in order 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 -arguments. The first line in the "do" is the name of the task -- this -will appear in any log output. - -The second line in each "do" is the module name followed by module -arguments. +arguments. Additional fields like 'comment:' can be added and will +be ignored. Most modules accept key=value format arguments. diff --git a/examples/playbook.yml b/examples/playbook.yml index 31e2c7fbbe7..527c7bf1aa7 100644 --- a/examples/playbook.yml +++ b/examples/playbook.yml @@ -17,4 +17,4 @@ action: command /bin/false handlers: - name: restart apache - action: service name=httpd ensure=restarted + action: service name=httpd state=restarted diff --git a/library/copy b/library/copy index a7514fe27b6..bd8c86ccb3f 100644 --- a/library/copy +++ b/library/copy @@ -10,7 +10,7 @@ except ImportError: import simplejson as json # =========================================== -# convert arguments of form ensure=running name=foo +# convert arguments of form a=b c=d # to a dictionary # FIXME: make more idiomatic diff --git a/library/git b/library/git index 9d85eba2994..873d8a1638d 100755 --- a/library/git +++ b/library/git @@ -16,7 +16,7 @@ import shlex import subprocess # =========================================== -# convert arguments of form ensure=running name=foo +# convert arguments of form a=b c=d # to a dictionary # FIXME: make more idiomatic diff --git a/library/service b/library/service index 4a20193d512..e28aa8ff8ea 100755 --- a/library/service +++ b/library/service @@ -10,7 +10,7 @@ import shlex import subprocess # =========================================== -# convert arguments of form ensure=running name=foo +# convert arguments of form a=b c=d # to a dictionary # FIXME: make more idiomatic @@ -22,7 +22,7 @@ for x in items: params[k] = v name = params['name'] -ensure = params.get('ensure','running') +state = params.get('state','running') # =========================================== # get service status @@ -43,11 +43,11 @@ elif name == 'iptables' and status.find("ACCEPT") != -1: running = True changed = False -if not running and ensure == "started": +if not running and state == "started": changed = True -elif running and ensure == "stopped": +elif running and state == "stopped": changed = True -elif ensure == "restarted": +elif state == "restarted": changed = True # =========================================== @@ -61,11 +61,11 @@ def _run(cmd): rc = 0 if changed: - if ensure == 'started': + if state == 'started': rc = _run("/sbin/service %s start" % name) - elif ensure == 'stopped': + elif state == 'stopped': rc = _run("/sbin/service %s stop" % name) - elif ensure == 'restarted': + elif state == 'restarted': rc1 = _run("/sbin/service %s stop" % name) rc2 = _run("/sbin/service %s start" % name) rc = rc1 and rc2 diff --git a/library/template b/library/template index 4ce579c78b7..8868350ae86 100644 --- a/library/template +++ b/library/template @@ -10,7 +10,7 @@ except ImportError: import simplejson as json # =========================================== -# convert arguments of form ensure=running name=foo +# convert arguments of form a=b c=d # to a dictionary # FIXME: make more idiomatic