<h5 dir="auto">Issue Type:</h5>
<p dir="auto">Feature Idea</p>
<h5 dir="auto">Ansible Version:</h5>
<p dir="auto">ansible 1.5.4</p>
<h5 dir="auto">Environment:</h5>
<p dir="auto">N/A</p>
<h5 dir="auto">Summary:</h5>
<p dir="auto">Related to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="15690632" data-permission-text="Title is private" data-url="https://github.com/ansible/ansible/issues/3245" data-hovercard-type="issue" data-hovercard-url="/ansible/ansible/issues/3245/hovercard" href="https://github.com/ansible/ansible/issues/3245">#3245</a> I'd like to request the ability to use vars_prompt in a role, such as:</p>
<ul dir="auto">
<li>an action "include_vars_prompt" similar to "include_vars" but which functions as vars_prompt does</li>
</ul>
<p dir="auto">OR</p>
<ul dir="auto">
<li>have the ability to have vars_prompt function in role vars files (perhaps a ROLES/vars/prompt.yml file in addition to main.yml)</li>
</ul>
<p dir="auto">My use case:<br>
My deployment system uses a role to handle the actual deployment.  Specifically, hosts are grouped in inventory into application groups, each group has a group_vars file that sets the required vars (git repos, pip files, application name, etc..) for the role to perform the deployment with.</p>
<p dir="auto">Our main playbook then has a play for each application, targeted at the application group, that calls the deployment role.</p>
<p dir="auto">What I would like to do now is easily add vars_prompt: functionality into the deployment role so that I may prompt the user for the desired release to deploy.  For automated invocation, the release would need to be supplied as an extra var, which is fine.</p>
<p dir="auto">Having this feature would allow me to avoid having to duplicate via copy-n-paste the vars_prompt bits for each application deployment play.  Since I have multiple prompts per application and would like to use Jinja templates to define the prompt and default vars, the repetition of this code gets unwieldy quickly.  Moreso when I end up needing to split applications up into separate playbooks.</p>
<p dir="auto">Thanks!</p>
<p dir="auto">-n</p>
<p dir="auto">Neither of the following obvious approaches work for storing <code class="notranslate">/etc/ssh/ssh_host_key</code> in an Ansible vault, i.e. a vars file:</p>
<ul dir="auto">
<li>YAML 1.1's <code class="notranslate">!binary</code> (<a href="http://yaml.org/spec/1.1/" rel="nofollow">spec</a>, <a href="http://yaml.org/type/binary.html" rel="nofollow">tag draft</a>), because the parser fails</li>
<li><code class="notranslate">copy</code> with <code class="notranslate">content</code> set to <code class="notranslate">"{{ ssh_host_key|b64decode }}"</code>, because the Jinja2 template engine <a href="https://groups.google.com/forum/#!topic/ansible-devel/lR0k2S0GIQw/discussion" rel="nofollow">corrupts the result</a></li>
</ul>
<p dir="auto">All the workarounds I've found involve writing to temporary files and decoding them, plus use of <code class="notranslate">register</code> and <code class="notranslate">changed_when</code> to detect whether the target really changed or not.</p>
<p dir="auto">Could we add the <code class="notranslate">!binary</code> parser to avoid the need to use Jinja2, or fix our use of Jinja2, or fix Jinja2?</p>
<p dir="auto">See also: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="102672021" data-permission-text="Title is private" data-url="https://github.com/ansible/ansible-modules-core/issues/1961" data-hovercard-type="issue" data-hovercard-url="/ansible/ansible-modules-core/issues/1961/hovercard" href="https://github.com/ansible/ansible-modules-core/issues/1961">ansible/ansible-modules-core#1961</a></p>