Not able to test variable after it is set in vars_prompt section to determine if I should execute the next prompt

26 views
Skip to first unread message

richard...@nike.com

unread,
May 13, 2015, 7:39:27 AM5/13/15
to ansible...@googlegroups.com
---
- hosts: local
  gather_facts: no
  vars_prompt:
    - name: dest_env
      prompt: "Enter the destination ENV to be installed (eg. dev, qa or default: prd)? "
      default: ""
      private: no
      when: dest_env is not defined
    - name: src_env
      prompt: "Enter the source ENV to use as the base for packages (eg. dev, qa or default: prd)? "
      default: "prd"
      private: no
      when: src_env is not defined
    - name: force
      prompt: "Would you like to force all packages to be re-deployed? "
      default: "no"
      private: no
      when: force is not defined
    - name: confirmation
      prompt: "Are you sure you want to run this playbook for PRODUCTION? Answer with 'YES'"
      default: "NO"
      private: no
      when: dest_env == "prd"

  vars:
    ensure_packages:
      - app: "test"

  tasks:
    # - include_vars: ../../vault/{{ tower_user_name|default(lookup('env','USER')) }}.yml
    - name: Check confirmation
      fail: msg="Playbook run confirmation failed"
      when: confirmation != "YES" and dest_env == "prd"
    - name: deploy the specified applications and their associated dependencies
      # ignore_errors: yes
      pause:
        seconds: "5"
      with_items:  ensure_packages

Brian Coca

unread,
May 13, 2015, 8:41:33 AM5/13/15
to ansible...@googlegroups.com
when does not work with vars_prompt, only with tasks.


--
Brian Coca
Reply all
Reply to author
Forward
0 new messages