# inventory works ad-hoc but not for playbooks

**URL:** <https://forum.ansible.com/t/inventory-works-ad-hoc-but-not-for-playbooks/38260>\
**Category:** Ansible Project\
**Created:** [July 26, 2023, 8:19am UTC](https://forum.ansible.com/t/inventory-works-ad-hoc-but-not-for-playbooks/38260 "2023-07-26T08:19:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dulhaver](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dulhaver/32/1061_2.png) [@dulhaver](https://forum.ansible.com/u/dulhaver)\
**Post date:** [July 26, 2023, 8:19am UTC](https://forum.ansible.com/t/inventory-works-ad-hoc-but-not-for-playbooks/38260/1 "2023-07-26T08:19:26Z")

</div>

i have an inventory vm-414001-0315.ini that looks like this

&nbsp;&nbsp;&nbsp;[vm-414001-0315]  
&nbsp;&nbsp;&nbsp;vm-414001-0315.step.zrz.dvz.cn-mv.de

this works wit ad-hoc commands but throws an error with ansible-playbook

#########################################################################anplay -i ../temp/vm-414001-0315.ini pg\_install.yml -e '{"postgresversion":"12.12";"targets":"vm-414001-0315"}' --list-hosts

[WARNING]: \* Failed to parse /home/gwagner/repos/automation\_postgres/temp/vm-414001-0315.ini with ini plugin: We were unable to read either  
as JSON nor YAML, these are the errors we got from each: JSON: Expecting ',' delimiter: line 1 column 27 (char 26) Syntax Error while  
loading YAML. found unexpected ':' The error appears to be in '\<string\>': line 1, column 37, but may be elsewhere in the file depending  
on the exact syntax problem.  
[WARNING]: Unable to parse /home/gwagner/repos/automation\_postgres/temp/vm-414001-0315.ini as an inventory source  
[WARNING]: No inventory was parsed, only implicit localhost is available  
ERROR! We were unable to read either as JSON nor YAML, these are the errors we got from each:  
JSON: Expecting ',' delimiter: line 1 column 27 (char 26)

Syntax Error while loading YAML.  
&nbsp;&nbsp;found unexpected ':'

The error appears to be in '\<string\>': line 1, column 37, but may  
be elsewhere in the file depending on the exact syntax problem.

---

<div class="post-metadata">

**Author:** ![dulhaver](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dulhaver/32/1061_2.png) [@dulhaver](https://forum.ansible.com/u/dulhaver)\
**Post date:** [July 26, 2023, 8:29am UTC](https://forum.ansible.com/t/inventory-works-ad-hoc-but-not-for-playbooks/38260/2 "2023-07-26T08:29:05Z")

</div>

sorry, the command I am calling this with was not correct (copy'n'paste error):

ansible-playbook -i ../temp/vm-414001-0315.ini pg\_install.yml -e '{"postgresversion":"12.12";"targets":"vm-414001-0315"}' --list-hosts

---

<div class="post-metadata">

**Author:** ![Will\_McDonald](https://avatars.discourse-cdn.com/v4/letter/w/f475e1/32.png) [@Will\_McDonald](https://forum.ansible.com/u/Will_McDonald)\
**Post date:** [July 26, 2023, 8:47am UTC](https://forum.ansible.com/t/inventory-works-ad-hoc-but-not-for-playbooks/38260/3 "2023-07-26T08:47:56Z")

</div>

I think the following error: Expecting ‘,’ delimiter: line 1 column 27 (char 26)

Is pointing you towards your extra vars: ‘{“postgresversion”:“12.12” **;** “targets”:“vm-414001-0315”}’

You have a semi-colon ‘;’ at position 28, that should be a comma. ‘,’

---

<div class="post-metadata">

**Author:** ![dulhaver](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dulhaver/32/1061_2.png) [@dulhaver](https://forum.ansible.com/u/dulhaver)\
**Post date:** [July 26, 2023, 9:00am UTC](https://forum.ansible.com/t/inventory-works-ad-hoc-but-not-for-playbooks/38260/4 "2023-07-26T09:00:13Z")

</div>

yes, exactly, semicolon in my command is the culprit. Thanks

---

<div class="post-metadata">

**Author:** ![dulhaver](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dulhaver/32/1061_2.png) [@dulhaver](https://forum.ansible.com/u/dulhaver)\
**Post date:** [July 26, 2023, 9:09am UTC](https://forum.ansible.com/t/inventory-works-ad-hoc-but-not-for-playbooks/38260/5 "2023-07-26T09:09:06Z")

</div>

another comment on the side

group name in the inventory ideally would not contain ‘-’ characters. This does not produce a FATAL but at least ansible is not all to happy with it

so this:
