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
37789a85
Commit
37789a85
authored
Apr 20, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename set_up and tear_down to pre_tasks and post_tasks
parent
d7623d1f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
16 deletions
+19
-16
examples/playbooks/roletest.yml
+10
-7
lib/ansible/playbook/play.py
+9
-9
No files found.
examples/playbooks/roletest.yml
View file @
37789a85
...
@@ -26,10 +26,12 @@
...
@@ -26,10 +26,12 @@
-
hosts
:
all
-
hosts
:
all
set_up
:
pre_tasks
:
# set up tasks are executed prior to roles.
# these tasks are executed prior to roles.
-
local_action
:
shell echo "hi this is a setup step about {{ inventory_hostname }}"
# this might be a good time to signal an outage window or take a host out of a load balanced pool
-
local_action
:
shell echo "hi this is a pre_task step about {{ inventory_hostname }}"
roles
:
roles
:
...
@@ -53,15 +55,16 @@
...
@@ -53,15 +55,16 @@
tasks
:
tasks
:
# you can still have loose tasks/handlers and they will execute after roles
# you can still have loose tasks/handlers and they will execute after roles
are applied
-
shell
:
echo 'this is a loose task'
-
shell
:
echo 'this is a loose task'
tear_down
:
post_tasks
:
# just to provide a syntactic mirroring to 'set_up', tear_down runs dead last in the play.
# just to provide a syntactic mirroring to 'pre_tasks', these run absolute last in the play.
# this might be a good time to put a host back in a load balanced pool or end an outage window
-
local_action
:
shell echo 'this is a
teardown
task about {{ inventory_hostname }}'
-
local_action
:
shell echo 'this is a
post_
task about {{ inventory_hostname }}'
lib/ansible/playbook/play.py
View file @
37789a85
...
@@ -40,7 +40,7 @@ class Play(object):
...
@@ -40,7 +40,7 @@ class Play(object):
'hosts'
,
'name'
,
'vars'
,
'vars_prompt'
,
'vars_files'
,
'hosts'
,
'name'
,
'vars'
,
'vars_prompt'
,
'vars_files'
,
'tasks'
,
'handlers'
,
'user'
,
'port'
,
'include'
,
'tasks'
,
'handlers'
,
'user'
,
'port'
,
'include'
,
'sudo'
,
'sudo_user'
,
'connection'
,
'tags'
,
'gather_facts'
,
'serial'
,
'sudo'
,
'sudo_user'
,
'connection'
,
'tags'
,
'gather_facts'
,
'serial'
,
'any_errors_fatal'
,
'roles'
,
'
set_up'
,
'tear_down
'
'any_errors_fatal'
,
'roles'
,
'
pre_tasks'
,
'post_tasks
'
]
]
# *************************************************
# *************************************************
...
@@ -135,10 +135,10 @@ class Play(object):
...
@@ -135,10 +135,10 @@ class Play(object):
new_handlers
=
[]
new_handlers
=
[]
new_vars_files
=
[]
new_vars_files
=
[]
set_up
=
ds
.
get
(
'set_up
'
,
None
)
pre_tasks
=
ds
.
get
(
'pre_tasks
'
,
None
)
if
type
(
set_up
)
!=
list
:
if
type
(
pre_tasks
)
!=
list
:
set_up
=
[]
pre_tasks
=
[]
for
x
in
set_up
:
for
x
in
pre_tasks
:
new_tasks
.
append
(
x
)
new_tasks
.
append
(
x
)
# variables if the role was parameterized (i.e. given as a hash)
# variables if the role was parameterized (i.e. given as a hash)
...
@@ -186,7 +186,7 @@ class Play(object):
...
@@ -186,7 +186,7 @@ class Play(object):
new_vars_files
.
append
(
vars_file
)
new_vars_files
.
append
(
vars_file
)
tasks
=
ds
.
get
(
'tasks'
,
None
)
tasks
=
ds
.
get
(
'tasks'
,
None
)
tear_down
=
ds
.
get
(
'tear_down
'
,
None
)
post_tasks
=
ds
.
get
(
'post_tasks
'
,
None
)
handlers
=
ds
.
get
(
'handlers'
,
None
)
handlers
=
ds
.
get
(
'handlers'
,
None
)
vars_files
=
ds
.
get
(
'vars_files'
,
None
)
vars_files
=
ds
.
get
(
'vars_files'
,
None
)
...
@@ -197,11 +197,11 @@ class Play(object):
...
@@ -197,11 +197,11 @@ class Play(object):
handlers
=
[]
handlers
=
[]
if
type
(
vars_files
)
!=
list
:
if
type
(
vars_files
)
!=
list
:
vars_files
=
[]
vars_files
=
[]
if
type
(
tear_down
)
!=
list
:
if
type
(
post_tasks
)
!=
list
:
tear_down
=
[]
post_tasks
=
[]
new_tasks
.
extend
(
tasks
)
new_tasks
.
extend
(
tasks
)
new_tasks
.
extend
(
tear_down
)
new_tasks
.
extend
(
post_tasks
)
new_handlers
.
extend
(
handlers
)
new_handlers
.
extend
(
handlers
)
new_vars_files
.
extend
(
vars_files
)
new_vars_files
.
extend
(
vars_files
)
ds
[
'tasks'
]
=
new_tasks
ds
[
'tasks'
]
=
new_tasks
...
...
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