Nasty Ansible Bug

Lets say you are using the Ansible “template” function. Like this:

- name: setup my_conf.conf
  template: src= "templates/my_conf.conf.j2" dest="/etc/my_conf.conf"

Seems pretty straight forward. But it will give you fatal error:

fatal: [127.0.0.1] => {'msg': 'AnsibleError: unable to read /my_path/ansible', 'failed': True}

What’s the problem? See that space after “src=”? Get rid of that and the command works. This is frustrating because PEP 8, has given me the habit of putting spaces around =.

Advertisements

2 thoughts on “Nasty Ansible Bug

  1. Oh that is nasty. Is that something `ansible-playbook –syntax-check myplaybook.yml` would catch? I’ve never used it so I don’t know if the debug message is any good or not.

    • I just tried –syntax-check. It does not find anything wrong. Ansible does not consider the space to be invalid syntax. Rather it interprets the space as part of the path name, which is not what most programmers would expect.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s