Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
155c3ca8
Commit
155c3ca8
authored
Feb 27, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update playbook docs with updated syntax / minor edits
parent
302cc37c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
30 deletions
+43
-30
docs/man/man5/ansible-playbook.5.asciidoc
+12
-14
examples/playbook.yml
+8
-16
examples/playbook2.yml
+23
-0
No files found.
docs/man/man5/ansible-playbook.5.asciidoc
View file @
155c3ca8
...
...
@@ -29,24 +29,22 @@ be supported in the future.
EXAMPLE
-------
FIXME: verify this is correct below
[literal]
---
- pattern: '*'
hosts: '/etc/ansible/hosts'
tasks:
- name:configure template & module variables for future template calls
- 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/
my
templates/httpd.j2 dest=/etc/httpd/conf
action: template src=/srv/templates/httpd.j2 dest=/etc/httpd/conf
notify:
- restart apache
- name: ensure apache is running
action: service name=httpd
ensur
e=started
action: service name=httpd
stat
e=started
handlers:
- name: restart apache
- action: service name=httpd
ensur
e=restarted
- action: service name=httpd
stat
e=restarted
WHAT THE EXAMPLE MEANS
...
...
@@ -59,10 +57,10 @@ For all hosts in /etc/ansible/hosts (one host per line) that are named
on each remote system with the values max_clients and http_port.
Next, use a Jinja2 template locally residing at
/srv/
my
templates/httpd.j2 to write the Apache config file on each host
/srv/templates/httpd.j2 to write the Apache config file on each host
to the path /etc/httpd/conf, using the previous values.
E
nsure that apache is running if stopped.
We'll e
nsure that apache is running if stopped.
If and only if the config file changed, note that we need to restart
apache at the end of the run, otherwise, don't bother because we
...
...
@@ -83,20 +81,20 @@ for all hosts in the host file matching the pattern.
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 'comment:' can be added and will
be ignored.
be ignored
, so feel free to take notes in the file
.
Most modules accept key=value format arguments.
Handlers are like tasks, but are conditionally executed. If a module
reports a 'change', it can
choose to notify a
handler by name. If
reports a 'change', it can
notify one or more
handler by name. If
notified, it will run only for hosts that changed.
FUTURE BEHAVIOR
--------------
-
ERROR HANDLING
--------------
What the playbook run does with a host when an error is detected is
currently being refined and is subject to change
.
If a host has a failure, the host will be ignored for the remainder
of the playbook execution
.
AUTHOR
...
...
examples/playbook.yml
View file @
155c3ca8
---
-
pattern
:
'
*'
hosts
:
/etc/ansible/hosts
hosts
:
'
/etc/ansible/hosts'
tasks
:
-
name
:
config step
action
:
setup a=2 b=3 c=4
-
name
:
copy comand
action
:
copy src=/srv/a dest=/srv/b
notify
:
-
restart apache
-
name
:
template step
action
:
template src=/srv/template.j2 dest=/srv/file.out
-
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/httpd.j2 dest=/etc/httpd/conf
notify
:
-
restart apache
-
name
:
execute bin
false
comment
:
call something that will fail just to demo failure counts and such
action
:
command /bin/false
-
name
:
execute bin
true
comment
:
this will never be executed because previous will fail
action
:
command /bin/true
-
name
:
ensure apache is running
action
:
service name=httpd state=started
handlers
:
-
name
:
restart apache
action
:
service name=httpd state=restarted
-
action
:
service name=httpd state=restarted
examples/playbook2.yml
0 → 100644
View file @
155c3ca8
---
-
pattern
:
'
*'
hosts
:
/etc/ansible/hosts
tasks
:
-
name
:
config step
action
:
setup a=2 b=3 c=4
-
name
:
copy comand
action
:
copy src=/srv/a dest=/srv/b
notify
:
-
restart apache
-
name
:
template step
action
:
template src=/srv/template.j2 dest=/srv/file.out
notify
:
-
restart apache
-
name
:
execute bin
false
comment
:
call something that will fail just to demo failure counts and such
action
:
command /bin/false
-
name
:
execute bin
true
comment
:
this will never be executed because previous will fail
action
:
command /bin/true
handlers
:
-
name
:
restart apache
action
:
service name=httpd state=restarted
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment