(ie, vars set by --extra-vars on the command-line cannot be overridden)

On Friday, January 13, 2017 at 12:19:16 PM UTC-8, Matt Davis wrote:
>
> The problem is that vars set on the command-line have the highest possible 
> precedence. If you were to set the initial value in inventory, or someplace 
> else with a lower precedence than a play/task var, it'd work fine 
> (verified).
>
> See 
> http://docs.ansible.com/ansible/playbooks_variables.html#variable-precedence-where-should-i-put-a-variable
>  for 
> more details.
>
> -Matt
>
> On Friday, January 13, 2017 at 10:28:33 AM UTC-8, davidfof wrote:
>>
>> Hi all,
>>
>>
>> I have role that contains several tasks that should be run by different 
>> Ansible users. The playbook that uses this role should run on Windows hosts 
>> and I do this using a command similar to the following:
>>
>>
>>  ansible-playbook --limit windows -i hosts --extra-vars 
>> "ansible_user=my_username ansible_password=my_password" site.yaml
>>
>> Most of the tasks in the role should be done through the user specified 
>> in the command above while others should use another Windows user. For 
>> these other tasks, I try to override the user credential variables as shown 
>> below:
>>
>>
>>
>>
>>  - include: task_for_other_windows_user.yml
>>  vars:
>>  ansible_user: "{{other_windows_user_name}}"
>>  ansible_password: "{{other_windows_user_pw}}"
>>
>>
>> This unfortunately doesn't work as the playbook appears to use the same 
>> user initially defined, on all the plays. How do I implement what I'm 
>> trying to achieve here?
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/94abd169-67f3-4878-ba42-a2295517e1c5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to