Ansible to Conditionally Prompt for a Variable?

前端 未结 6 1401
遇见更好的自我
遇见更好的自我 2020-12-28 13:04

I would like to be able to prompt for my super secure password variable if it is not already in the environment variables. (I\'m thinking that I might not want to put the de

6条回答
  •  感情败类
    2020-12-28 13:15

    This is indeed not possible by default in Ansible. I understand the reasoning behind not allowing it, yet I think it can be appropriate in some contexts. I've been writing an AWS EC2 deploy script, using the blue/green deploy system, and at some point in the role I need to ask the user if a rollback needs to be done if something has gone awry. As said, there is no way to do this (conditionally and/or non-fugly).

    So I wrote a very simple Ansible (2.x) action plugin, based on the pause action from the standard library. It a bit spartan in that it only accepts a single key press, but it might be of use. You can find it in a Github gist here. You need to copy the whole Gist file to the action_plugins directory of your playbook directory. See the documentation in the file.

提交回复
热议问题