Archive for the ‘Ansible’ Category

Ansible: variables resolution in task name.

June 19th, 2015 No comments

Simply you can’t.
Variables are not resolved inside the


Only inside the actual tasks/conditions etc. the placeholders will be resolved.



SOURCE: Ansible: variable interpolation in task name

Categories: Ansible Tags: ,

Considerations on Ansible handlers

June 17th, 2015 No comments

1) Handlers should go at the bottom of the PLAY
“And in your main playbook file, just include it like so, at the bottom of a play:”

But I have seen that if you declare it even at the beginning, it works anyway.

2) You can call handlers/*.yml whatever you want, it doesn’t have to be necessarily main.yml

3) In notify you can use

[cce_yaml]notify: mysql_restart[/cce]


- mysql_restart[/cce]

both will work

4) If the handler is defined inside the PLAY, you can call it even from an included task

5) A handler will always be called at the end of the play.
If you need to run it when you notify it, you need to add

[cce_yaml]- meta: flush_handlers[/cce]

6) Calling the handler multiple times will result in only one run.
“These ‘notify’ actions are triggered at the end of each block of tasks in a playbook, and will only be triggered once even if notified by multiple different tasks.”

Categories: Ansible Tags: ,

User input in Ansible

June 17th, 2015 No comments

To retrieve user input in ansible, you can use vars_prompt but all questions will be asked at the beginning at the playbook.

So there is no way to ask for user input at a task level.


SOURCE: Ansible to Conditionally Prompt for a Variable?

Categories: Ansible Tags: ,