Implement support for naming playbooks
This allows users to give arbitrary names to their playbooks based on the "ara_playbook_name" Ansible variable that can be supplied either as a literal Ansible variable or as an extra_var. Change-Id: I8bbe644003a1a277a9639167effdee1146907c6f
This commit is contained in:
parent
c7933f3425
commit
b129ad91c7
|
@ -163,6 +163,12 @@ class CallbackModule(CallbackBase):
|
|||
self._end_task()
|
||||
self._end_play()
|
||||
|
||||
# Load variables to verify if there is anything relevant for ara
|
||||
play_vars = play._variable_manager.get_vars(play=play)["vars"]
|
||||
for key in play_vars.keys():
|
||||
if key == "ara_playbook_name":
|
||||
self._set_playbook_name(name=play_vars[key])
|
||||
|
||||
# Record all the files involved in the play
|
||||
self._load_files(play._loader._FILE_CACHE.keys())
|
||||
|
||||
|
@ -252,6 +258,10 @@ class CallbackModule(CallbackBase):
|
|||
"/api/v1/playbooks/%s" % self.playbook["id"], status=status, ended=datetime.datetime.now().isoformat()
|
||||
)
|
||||
|
||||
def _set_playbook_name(self, name):
|
||||
if self.playbook["name"] != name:
|
||||
self.playbook = self.client.patch("/api/v1/playbooks/%s" % self.playbook["id"], name=name)
|
||||
|
||||
def _get_one_item(self, endpoint, **query):
|
||||
"""
|
||||
Searching with the API returns a list of results. This method is used
|
||||
|
|
Loading…
Reference in New Issue