"No escaped character" in inventory file

265 views
Skip to first unread message

Andrew Langhorn

unread,
Nov 28, 2015, 10:55:42 PM11/28/15
to ansible...@googlegroups.com

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 <module>
    (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

Brian Coca

unread,
Nov 28, 2015, 11:46:44 PM11/28/15
to Ansible Project
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"


--
Brian Coca

Andrew Langhorn

unread,
Nov 29, 2015, 12:06:33 PM11/29/15
to Ansible Project
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!
________________________________________
From: ansible...@googlegroups.com <ansible...@googlegroups.com> on behalf of Brian Coca <bc...@ansible.com>
Sent: 29 November 2015 04:46
To: Ansible Project
Subject: Re: [ansible-project] "No escaped character" in inventory file


--
Brian Coca

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAJ5XC8%3D4iqc68nUGWiHCny%2BPnWH7equfHVHL6vBT1z1D-uyE9Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages