# issues with variables

**URL:** <https://forum.ansible.com/t/issues-with-variables/24643>\
**Category:** Ansible Project\
**Created:** [June 4, 2017, 11:30am UTC](https://forum.ansible.com/t/issues-with-variables/24643 "2017-06-04T11:30:28Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![DOkuwa](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dokuwa/32/1471_2.png) [@DOkuwa](https://forum.ansible.com/u/DOkuwa)\
**Post date:** [June 4, 2017, 11:30am UTC](https://forum.ansible.com/t/issues-with-variables/24643/1 "2017-06-04T11:30:28Z")

</div>

Hello  
i run a playbook and do get this error message  
:/etc/ansible$ ansible-playbook -u dokuwa1 --ask-pass playbook/apache.yml

ERROR! Syntax Error while loading YAML.

The error appears to have been in ‘/etc/ansible/playbook/apache.yml’: line 3, column 2, but may  
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

- hosts: all  
vars\_files:  
^ here

This is the playbook

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [June 4, 2017, 12:14pm UTC](https://forum.ansible.com/t/issues-with-variables/24643/2 "2017-06-04T12:14:13Z")

</div>

In yaml indentation is important and need to be consistent with number of spaces.

Your var\_files has only 1 space in front, it need to have 2 spaces so it's consistent with the rest.

---

<div class="post-metadata">

**Author:** ![DOkuwa](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dokuwa/32/1471_2.png) [@DOkuwa](https://forum.ansible.com/u/DOkuwa)\
**Post date:** [June 4, 2017, 12:43pm UTC](https://forum.ansible.com/t/issues-with-variables/24643/3 "2017-06-04T12:43:48Z")

</div>

Hello thanks

It is not retrieving this error  
but there is one thing i expect it not to ask me for my username and password  
I thought that variable should take care of that  
what am i doing wrong

---

<div class="post-metadata">

**Author:** ![DOkuwa](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dokuwa/32/1471_2.png) [@DOkuwa](https://forum.ansible.com/u/DOkuwa)\
**Post date:** [June 4, 2017, 3:00pm UTC](https://forum.ansible.com/t/issues-with-variables/24643/4 "2017-06-04T15:00:55Z")

</div>

Hello thanks

It is not retrieving this error  
but there is one thing i expect it not to ask me for my username and password  
I thought that variable should take care of that  
what am i doing wrong

---

<div class="post-metadata">

**Author:** ![Trond\_Hindenes](https://avatars.discourse-cdn.com/v4/letter/t/96bed5/32.png) [@Trond\_Hindenes](https://forum.ansible.com/u/Trond_Hindenes)\
**Post date:** [June 4, 2017, 4:08pm UTC](https://forum.ansible.com/t/issues-with-variables/24643/5 "2017-06-04T16:08:25Z")

</div>

use an editor with yaml validation when writing you playbooks, that will take care of errors like this. VSCode has a yaml plugin for instance.

---

<div class="post-metadata">

**Author:** ![DOkuwa](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dokuwa/32/1471_2.png) [@DOkuwa](https://forum.ansible.com/u/DOkuwa)\
**Post date:** [June 4, 2017, 4:34pm UTC](https://forum.ansible.com/t/issues-with-variables/24643/6 "2017-06-04T16:34:46Z")

</div>

Thanks  
But is this the issue as it as I still have to key in my password  
I thought the variable would authenticate for me  
Thanks

---

<div class="post-metadata">

**Author:** ![Trond\_Hindenes](https://avatars.discourse-cdn.com/v4/letter/t/96bed5/32.png) [@Trond\_Hindenes](https://forum.ansible.com/u/Trond_Hindenes)\
**Post date:** [June 5, 2017, 12:48pm UTC](https://forum.ansible.com/t/issues-with-variables/24643/7 "2017-06-05T12:48:55Z")

</div>

The issue is that your yaml file is malformed, so Ansible doesn’t understand it. For just getting started/testing things out, the easiest is probably to put the password in your inventory file. I would recommend reading up on that here: [http://docs.ansible.com/ansible/intro\_inventory.html](http://docs.ansible.com/ansible/intro_inventory.html), especially the section “list-of-behavioral-inventory-parameters”.

---

<div class="post-metadata">

**Author:** ![Karol\_Czeryna](https://avatars.discourse-cdn.com/v4/letter/k/ed655f/32.png) [@Karol\_Czeryna](https://forum.ansible.com/u/Karol_Czeryna)\
**Post date:** [June 5, 2017, 12:50pm UTC](https://forum.ansible.com/t/issues-with-variables/24643/8 "2017-06-05T12:50:49Z")

</div>

For the future I would strongly recommend to you to start using linter.

Even [http://www.yamllint.com/](http://www.yamllint.com/) is fine 🙂

Best,  
Karol

---

<div class="post-metadata">

**Author:** ![DOkuwa](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dokuwa/32/1471_2.png) [@DOkuwa](https://forum.ansible.com/u/DOkuwa)\
**Post date:** [June 5, 2017, 7:52pm UTC](https://forum.ansible.com/t/issues-with-variables/24643/9 "2017-06-05T19:52:34Z")

</div>

Hello

I still have issues with password  
i have added username and password to the inventory file and have used yamllink to validate my yaml  
at the command line i have to request for password all the time  
ansible\_connection=ssh  
ansible\_port=22  
ansible\_user=dokuwa1  
ansible\_ssh\_pass=xxxx

My command is without password is  
ansible-playbook -playbook/apache.yml - it fails

and with username password

ansible-playbook -u dokuwa1 --ask-pass playbook/apache.yml - it does not fail

thanks

---

<div class="post-metadata">

**Author:** ![DOkuwa](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dokuwa/32/1471_2.png) [@DOkuwa](https://forum.ansible.com/u/DOkuwa)\
**Post date:** [June 6, 2017, 7:15pm UTC](https://forum.ansible.com/t/issues-with-variables/24643/10 "2017-06-06T19:15:50Z")

</div>

Hello

Yes it looks very good [yamllint.com](http://yamllint.com) i have tried it  
but also still having issues with password and username  
i want a situation where it does not ask me for my username & password

---

<div class="post-metadata">

**Author:** ![Karol\_Czeryna](https://avatars.discourse-cdn.com/v4/letter/k/ed655f/32.png) [@Karol\_Czeryna](https://forum.ansible.com/u/Karol_Czeryna)\
**Post date:** [June 7, 2017, 12:42pm UTC](https://forum.ansible.com/t/issues-with-variables/24643/11 "2017-06-07T12:42:11Z")

</div>

Use your public/private key then.

By default Ansible will try to use those keys that are in the “ssh-agent” but you can also provide a path for the key in the inventory / vars / etc.

Basically everything is well explained here:

[http://docs.ansible.com/ansible/intro\_getting\_started.html](http://docs.ansible.com/ansible/intro_getting_started.html)

Best,  
Karol

---

<div class="post-metadata">

**Author:** ![DOkuwa](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dokuwa/32/1471_2.png) [@DOkuwa](https://forum.ansible.com/u/DOkuwa)\
**Post date:** [June 8, 2017, 12:14pm UTC](https://forum.ansible.com/t/issues-with-variables/24643/12 "2017-06-08T12:14:33Z")

</div>

Karol,

Yes thanks  
i was able to resolve the issue of prompting password for my user i had to go to ansible.cfg and change the ask-pass value to false  
but the only issue is that i could not do this for root as i need the password prompt to install some packages  
Is there any way out for root or sudo  
Thanks

---

<div class="post-metadata">

**Author:** ![Karol\_Czeryna](https://avatars.discourse-cdn.com/v4/letter/k/ed655f/32.png) [@Karol\_Czeryna](https://forum.ansible.com/u/Karol_Czeryna)\
**Post date:** [June 8, 2017, 1:10pm UTC](https://forum.ansible.com/t/issues-with-variables/24643/13 "2017-06-08T13:10:18Z")

</div>

Daley,

Please read documentation: [https://docs.ansible.com/ansible/become.html](https://docs.ansible.com/ansible/become.html)

Best,  
Karol
