Hi,

I want to fill a custom dashboard with specifics events raise in a 
playbook, not all tasks that can be confuse output for functionnal users.

To do that, I first developped a role, and include it everytime I want to 
push an event. This solution works, but introduce so much task in a 
playbook. I try to handle exceptions too, so I use block with rescue etc... 
and Playbook become so complex with this approch.

So, after some research, I think that a Callback plugin can answer my 
needs. The idea is to inject at the plays and tasks levels, a specific var 
that the callback plugin can catch and react in function.

Playbook Example ( this is the Ansiboad var ):














*---- name: "Callback module test"   hosts: "localhost"   gather_facts: no 
  vars:     Ansiboard:       project: "{{ Proj }}"       environment: "{{ 
Env }}"   tasks:  - debug:     msg: "{{ Proj }} - {{ Env }}"     vars:     
  Ansiboard:         another_project: "{{ Proj }}"         
another_environment: "{{ Env }}"*

This playbook is called with this two Extra :
$> ansible-playbook test.yml -e Proj=myproj -e Env=prod

My callback plugin works fine, I can check the presence of the var 
Ansiboard and apply actions when needed.

The problem is that Jinja templating isn't apply, for example, when I write 
this :
def v2_playbook_on_play_start(self, play):
  self.playbook_on_play_start(play.name)

  play_vars = play.get_vars()
  if "Ansiboard" in play_vars:
    ansiconf = play_vars["Ansiboard"]
    project = ansiconf["project"]


The value in the project variable is litteraly : {{ Proj }}

Someone knows how I can retreive the final value after the Jinja Template 
apply ? How can I launch the Jinja templating engine ? Did I need to get 
the VariableManager of the Play / Task ? I very confused how to acheive my 
need.

Best regards,
Didier Bourriaud from Kosmos.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/1ca46891-f04f-446a-b1b3-a8140cffbdbbn%40googlegroups.com.

Reply via email to