如何为跳过的播放禁用vars_prompt?

时间:2019-06-12 14:37:20

标签: ansible

我正在播放一部名为“ partial_upgrade.yml”的剧本,该剧本带有vars_prompt提示用户输入。

我正在将该剧本导入另一个根据条件导入的剧本“ choose_play.yml”。

即使跳过了“ partial_upgrade.yml”,也会提示用户输入。

1. choose_play.yml
---
- hosts: localhost
  vars_prompt:
    - name: "option"
      prompt: |
         >>> 1. Partial Upgrade
         >>> 2. Full Upgrade
         >>> Enter the option which you want to run -
      private: no

  tasks:
    - set_fact:
        option: "{{ option }}"
    - debug:
        var: option

- import_playbook: partial_upgrade.yml
  vars:
    partial_upgrade: true
    full_upgrade: false
  when: hostvars["localhost"]["option"]|int == 1

- import_playbook: full-upgrade.yml
  vars:
    partial_upgrade: false
    full_upgrade: true
  when: hostvars["localhost"]["option"]|int == 2


2. deploy.yml
---
- hosts: nodes
  gather_facts: false
  sudo: true
  vars_prompt:
     - name: "server_ip"
       prompt: "Enter Server IP"
       private: no

     - name: "server_path"
       prompt: "Enter Server path"
       private: no

  roles:
    - setup-master
    - setup-worker

当我运行“ choose_play.yml”并按2时,它会跳过“ partial_upgrade.yml”,但提示输入“服务器IP”和“服务器路径”。

我不想输入跳过播放的详细信息。

跳过播放时,请帮助我禁用vars_prompt。

0 个答案:

没有答案