ansible: how to do string interpolation in a prompt?

How can I accomplish something like this?

    new_password: "new password for {{ target_username }}@{{ ansible_hostname }}?"

EDIT: based on mgsk's answer, I decided to simply store a default password during account creation, rather than prompt the user. My ssh play disables password logins anyway, so really I was just trying to prevent account lock due to not having a password entry for the user.

So I write a default password, and then use this handler to remind the operator to change it:

  - name: warn default password
    debug: msg="default password installed for {{ target_username }}; be sure to change it"


vars_prompt is run before facts gathering. I don't think you can do this, not with any standard ways. Quoting Ansible's author:

There's been a decided emphasis in automation in Ansible and asking questions at task level is not something we really want to do.

However, you can still ask vars_prompt questions at play level and use those variables throughout tasks. You just can't ask questions in roles.

And really, that's what I would like to enforce -- if a lot of Galaxy roles start asking questions, I can see that being annoying :)

See related discussion on ansible-devel mailing list.

Need Your Help

Mac App WebView background

objective-c osx background webview

How is it possible to set the an image as background of the WebView in a Mac App? Because the WebView has that "bouncing" effect, if you scroll further down than the content, the background is usua...

C# WPF close new user control

c# wpf

I am new to c#. I have created main windows that I am adding usercontrols to switch between screens with command:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.