How to set sudo with variable?

In my playbook, I want to use variable values to set hosts, user and sudo. Just like this:
hosts: $webserver
user: $user
sudo: $sudo_mode

I can use extra variables to set hosts and user, but sudo failed whatever I use extra variables or variable files.
Who knows how to reslove it? Thank you very much!

I thought there was an open ticket on this one, but I don't see it.

Please share what version of ansible you are using (ansible --version)

Thanks!

My ansible is ansible 1.0. Thank you.

在 2013年3月20日星期三UTC+8下午8时39分10秒,Michael DeHaan写道:

Ok, please test in 1.1 and see if that works for you, if you don't mind.

Thanks!

Thank you. I will use 1.1 to verify it.

I’ve tested in 1.1. But I still cannot use extra variable to set sudo value.

Please show me your playbook and the command you are using to execute
/usr/bin/ansible.

Sorry, /usr/bin/ansible-playbook

My playbook:

I use ansible 1.1, but it is failed. Can you analyze for me?

My playbook:

Ok, seems like that's unfixed then.

I've opened up https://github.com/ansible/ansible/issues/2526 to track this.

Can we set sudo value in vars file using version 1.1?