# syntax error... where there is no syntax error...

**URL:** <https://forum.ansible.com/t/syntax-error-where-there-is-no-syntax-error/23969>\
**Category:** Ansible Project\
**Created:** [March 14, 2017, 3:35pm UTC](https://forum.ansible.com/t/syntax-error-where-there-is-no-syntax-error/23969 "2017-03-14T15:35:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joost\_Ringoot](https://avatars.discourse-cdn.com/v4/letter/j/c67d28/32.png) [@Joost\_Ringoot](https://forum.ansible.com/u/Joost_Ringoot)\
**Post date:** [March 14, 2017, 3:35pm UTC](https://forum.ansible.com/t/syntax-error-where-there-is-no-syntax-error/23969/1 "2017-03-14T15:35:47Z")

</div>

But Hello,

I have this playbook,… that used to work in a previous version of ansible, I swear it did:

cat ansible/playbooks/apt/sssdconfig.yml

`

---

<div class="post-metadata">

**Author:** ![Andrew\_Latham](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@Andrew\_Latham](https://forum.ansible.com/u/Andrew_Latham)\
**Post date:** [March 14, 2017, 3:40pm UTC](https://forum.ansible.com/t/syntax-error-where-there-is-no-syntax-error/23969/2 "2017-03-14T15:40:29Z")

</div>

Joost

Try:

python -c ‘import yaml,sys;yaml.safe\_load(sys.stdin)’ \< ansible/playbooks/apt/sssdconfig.yml

Valid Yaml is not hard but you can add a post commit hook like the above to validate the yaml for you.

---

<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:** [March 14, 2017, 5:14pm UTC](https://forum.ansible.com/t/syntax-error-where-there-is-no-syntax-error/23969/3 "2017-03-14T17:14:49Z")

</div>

> I have this playbook,... that used to work in a previous version of  
> ansible, I swear it did:
> 
> cat ansible/playbooks/apt/sssdconfig.yml  
> ---  
> - hosts: "{{hosts}}"

I wouldn't use a variable named the same as a directive.

> # accelerate: true  
> &nbsp;&nbsp;remote\_user: root  
> &nbsp;&nbsp;tasks:  
> &nbsp;&nbsp;- name: install auth-client-config  
> &nbsp;&nbsp;&nbsp;&nbsp;apt: name=auth-client-config state=installed  
> &nbsp;&nbsp;- name: install sssd client  
> &nbsp;&nbsp;&nbsp;&nbsp;apt: name=sssd state=installed  
> &nbsp;&nbsp;- name: install ldap pam module  
> &nbsp;&nbsp;&nbsp;&nbsp;apt: name=libpam-ldap state=installed  
> &nbsp;&nbsp;- name: configure authentication  
> &nbsp;&nbsp;&nbsp;&nbsp;command: /usr/sbin/auth-client-config --enablesssd --enablesssdauth --enablelocauthorize  
> --enablepamaccess --enablemkhomedir --update  
> &nbsp;&nbsp;- name: make sure the config directory is present ( workaround for a bug  
> in sssd package)  
> &nbsp;&nbsp;&nbsp;&nbsp;command: /bin/mkdir -p /etc/sssd  
> &nbsp;&nbsp;- name: use a template sssd.conf  
> &nbsp;&nbsp;&nbsp;&nbsp;copy: src=/home/florence/ansible/files/sssd.conf dest=/etc/sssd  
> &nbsp;&nbsp;- name: ensure correct acl for the sssd directory  
> &nbsp;&nbsp;&nbsp;&nbsp;file: path=/etc/sssd mode=0600  
> &nbsp;&nbsp;- name: ensure correct acl for the sssd.conf file  
> &nbsp;&nbsp;&nbsp;&nbsp;file: path=/etc/sssd/sssd.conf mode=0600  
> &nbsp;&nbsp;- name: restart sssd  
> &nbsp;&nbsp;&nbsp;&nbsp;service: name=sssd enabled=yes state=restarted
> 
> But now this happens:
> 
> ansible-playbook /home/florence/ansible/playbooks/apt/sssdconfig.yml -e  
> cal-30  
> ERROR! the field 'hosts' has an invalid value, which appears to include a  
> variable that is undefined. The error was: 'hosts' is undefined

The variable hosts is not set, and your -e should be key=value.  
Are you trying to write -e hosts=cal-30 ?

---

<div class="post-metadata">

**Author:** ![Joost\_Ringoot](https://avatars.discourse-cdn.com/v4/letter/j/c67d28/32.png) [@Joost\_Ringoot](https://forum.ansible.com/u/Joost_Ringoot)\
**Post date:** [March 16, 2017, 7:47am UTC](https://forum.ansible.com/t/syntax-error-where-there-is-no-syntax-error/23969/4 "2017-03-16T07:47:57Z")

</div>

Thanks **Andrew latham**

This

`

python -c ‘import yaml,sys;yaml.safe\_load(sys.stdin)’ \< ansible/playbooks/apt/sssdconfig.yml

`  
has no output, so I guess syntax is correct.

Thanks Kai Stian Olstad  
_-e should be key=value._

That fixes it\*,\* thanks  
I also did a test changing

`

- hosts: “{{hosts}}”

`

into

`

- hosts: “{{destin}}”

`

in the yaml and it looks good from this point (I only need to make sure the destination machine is switched on)

`  
ansible-playbook ansible/playbooks/apt/sssdconfig.yml -e destin=cal-30

PLAY [cal-30] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK [setup] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [cal-30]: UNREACHABLE! =\> {“changed”: false, “msg”: “Failed to connect to the host via ssh: ssh: connect to host cal-30 port 22: Connection timed out\r\n”, “unreachable”: true}  
to retry, use: --limit @/home/florence/ansible/playbooks/apt/sssdconfig.retry

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
cal-30 : ok=0 changed=0 unreachable=1 failed=0

`
