# "No escaped character" in inventory file

**URL:** <https://forum.ansible.com/t/no-escaped-character-in-inventory-file/19886>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [November 28, 2015, 2:31pm UTC](https://forum.ansible.com/t/no-escaped-character-in-inventory-file/19886 "2015-11-28T14:31:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew\_Langhorn](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@Andrew\_Langhorn](https://forum.ansible.com/u/Andrew_Langhorn)\
**Post date:** [November 28, 2015, 2:31pm UTC](https://forum.ansible.com/t/no-escaped-character-in-inventory-file/19886/1 "2015-11-28T14:31:59Z")

</div>

Hello,

I’m hooking up Ansible and a Vagrant VM running Ubuntu 14.04 LTS. To do this, I have the following inventory file:

> ​
> 
> default   
> ansible\_ssh\_host=“127.0.0.1”   
> ansible\_ssh\_port=“2202”   
> ansible\_ssh\_user=“vagrant”   
> ansible\_ssh\_private\_key\_file=“.vagrant/machines/default/virtualbox/private\_key”

​The path to the private key is relative to the directory the inventory file is in, and the private key exists. The other values - host, port and user - were populated based on the output of `vagrant ssh-config` after the Vagrant VM had booted:

> ✗ vagrant ssh-config
> 
> Host default
> 
> HostName 127.0.0.1
> 
> User vagrant
> 
> Port 2202
> 
> UserKnownHostsFile /dev/null
> 
> StrictHostKeyChecking no
> 
> PasswordAuthentication no
> 
> IdentityFile /projects/ansible/.vagrant/machines/default/virtualbox/private\_key
> 
> IdentitiesOnly yes
> 
> LogLevel FATAL

Given this, I think I should be able to run ansible default -i hosts -m ping, and have a successful response from the ping module. Unfortunately, I get a lovely stack trace back:

> ✗ ansible default -i hosts -m ping
> 
> Traceback (most recent call last):
> 
> File “/usr/local/Cellar/ansible/1.9.4/libexec/bin/ansible”, line 197, in
> 
> (runner, results) = cli.run(options, args)
> 
> File “/usr/local/Cellar/ansible/1.9.4/libexec/bin/ansible”, line 121, in run
> 
> inventory\_manager = inventory.Inventory(options.inventory, vault\_password=vault\_pass)
> 
> File “/usr/local/Cellar/ansible/1.9.4/libexec/lib/python2.7/site-packages/ansible/inventory/ **init**.py”, line 128, in **init**
> 
> self.parser = InventoryParser(filename=host\_list)
> 
> File “/usr/local/Cellar/ansible/1.9.4/libexec/lib/python2.7/site-packages/ansible/inventory/ini.py”, line 43, in **init**
> 
> self.\_parse()
> 
> File “/usr/local/Cellar/ansible/1.9.4/libexec/lib/python2.7/site-packages/ansible/inventory/ini.py”, line 47, in \_parse
> 
> self.\_parse\_base\_groups()
> 
> File “/usr/local/Cellar/ansible/1.9.4/libexec/lib/python2.7/site-packages/ansible/inventory/ini.py”, line 108, in \_parse\_base\_groups
> 
> tokens = shlex.split(line)
> 
> File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shlex.py”, line 279, in split
> 
> return list(lex)
> 
> File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shlex.py”, line 269, in next
> 
> token = self.get\_token()
> 
> File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shlex.py”, line 96, in get\_token
> 
> raw = self.read\_token()
> 
> File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shlex.py”, line 191, in read\_token
> 
> raise ValueError, “No escaped character”
> 
> ValueError: No escaped character

I’ve had a quick look about to see what might be causing the ValueError, but I can’t see much at fault. There must be something, though!

Running Ansible 1.9.4 and Python 2.7.10 on Yosemite.

Thanks in advance for any ideas,

Andrew

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [November 29, 2015, 4:46am UTC](https://forum.ansible.com/t/no-escaped-character-in-inventory-file/19886/2 "2015-11-29T04:46:36Z")

</div>

I don't believe the hosts file supports \ line continuations, try this  
as your hosts file:

default ansible\_ssh\_host="127.0.0.1" ansible\_ssh\_port="2202"  
ansible\_ssh\_user="vagrant"  
ansible\_ssh\_private\_key\_file=".vagrant/machines/default/virtualbox/private\_key"

---

<div class="post-metadata">

**Author:** ![Andrew\_Langhorn](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@Andrew\_Langhorn](https://forum.ansible.com/u/Andrew_Langhorn)\
**Post date:** [November 29, 2015, 5:06pm UTC](https://forum.ansible.com/t/no-escaped-character-in-inventory-file/19886/3 "2015-11-29T17:06:25Z")

</div>

In the end, putting everything on one line did the trick. I think this is because \ in Python escapes only characters, not carriage returns.

Thanks!
