Line appending failing

18 views
Skip to first unread message

amritha sanath

unread,
May 5, 2016, 3:22:00 PM5/5/16
to Ansible Project
I have a file which is datadog.conf in which i have to append the line dogstreams: /root/ddmonitor/pattern.txt:/opt/datadog-agent/agent/checks/libs/parsers.py:parse-web at EOF

i am using ansible lineinfile option and my code looks like below:

```- name: copy datadog agent configuration file
  lineinfile: dest=/etc/dd-agent/datadog.conf regexp="^dogstreams: " line="dogstreams: /root/ddmonitor/pattern.txt:/opt/datadog-agent/agent/checks/libs/parsers.py:parse-web"```

i am getting below error while running playbook :

ERROR! Syntax Error while loading YAML.


The error appears to have been in '/etc/ansible/roles/datadog-pegalogs-apptier/tasks/main.yml': line 19, column 66, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

- name: copy datadog agent configuration file
  lineinfile: dest=/etc/dd-agent/datadog.conf regexp="^dogstreams: " line="dogstreams: /root/ddmonitor/pattern.txt:/opt/datadog-agent/agent/checks/libs/parsers.py:parse_web"
                                                                 ^ here
We could be wrong, but this one looks like it might be an issue with
unbalanced quotes.  If starting a value with a quote, make sure the
line ends with the same set of quotes.  For instance this arbitrary
example:

    foo: "bad" "wolf"

Could be written as:

    foo: '"bad" "wolf"'

Johannes Kastl

unread,
May 6, 2016, 3:53:01 AM5/6/16
to ansible...@googlegroups.com
On 05.05.16 19:29 amritha sanath wrote:

> - name: copy datadog agent configuration file
> lineinfile: dest=/etc/dd-agent/datadog.conf regexp="^dogstreams: "
> line="dogstreams:
> /root/ddmonitor/pattern.txt:/opt/datadog-agent/agent/checks/libs/parsers.py:parse_web"

What happens if you use a different line?

lineinfile: dest=/etc/dd-agent/datadog.conf regexp="^dogstreams: "
line="foobar"

And, maybe, try using single quotes instead of the double quotes.

Johannes

signature.asc
Reply all
Reply to author
Forward
0 new messages