title: Ansible pass vars_prompt answers to roles vars
body: <p>I created a playbook with a role for deploying new customers on mikrotik. The role should get from the playbook which vlan-id it should create. The playbook gets it from the vars_prompt. See code example below.</p>
  <p>playbook:</p>
  <pre><code>- hosts: all
    vars_prompt:
      - name: vlan_id
        prompt: What vlan-id to use
        private: no
  - hosts: brasses
    roles:
      - role: bras
        vars: 
          vlanid: {{ vlan_id  }}
  </code></pre>
  <p>role:</p>
  <pre><code>- debug:
    msg: Het customer vlan is {{ vlanid}}
  
  - name: 'Create customer vlan'
    routeros_command:
      commands: /interface vlan add interface=sfp-sfpplus2 name=sfp2-vlan{{ vlanid}} vlan-id={{ vlanid }}
  </code></pre>
  <p>This doesn't work. It looks like the variable vlanid is already set before the prompt is executed. Is this true? Is there a way to mitigate this?</p>
  <p>Giving the vlan id directly without the vars_promt does work. See below</p>
  <pre><code>ansible-playbooks create_new_customer.yml --extra-vars &quot;vlan_id=900&quot;
  </code></pre>