Ansible to Conditionally Prompt for a Variable?

前端 未结 6 1413
遇见更好的自我
遇见更好的自我 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:19

    Based on tehmoon's answer with some modifications I did it that way:

    - hosts:
        - hostA
      become: yes
      pre_tasks:
        - pause:
            prompt: "Give your username"
          register: prompt
          no_log: yes
          run_once: yes
        - set_fact:
            username: "{{prompt.user_input}}"
          no_log: yes
          run_once: yes
        - pause:
            prompt: "Give your password"
            echo: no
          register: prompt
          no_log: yes
          run_once: yes
        - set_fact:
            password: "{{prompt.user_input}}"
          no_log: yes
          run_once: yes
      tags: [my_role_using_user_pass]
      roles:
        - role: my_role_using_user_pass
    

提交回复
热议问题