Rename set_up and tear_down to pre_tasks and post_tasks
This commit is contained in:
parent
d7623d1f91
commit
37789a852a
2 changed files with 19 additions and 16 deletions
|
@ -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 @@
|
||||||
|
|
||||||
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 }}'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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):
|
||||||
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):
|
||||||
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):
|
||||||
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
|
||||||
|
|
Loading…
Reference in a new issue