Reputation: 199
I have ansible role. When start ansibple-playbook main.yml -C get this error:
ERROR! Syntax Error while loading YAML.
found unknown escape character
The error appears to be in '/main': line 41, column 93, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
service : "-XX:+UseG1GC -Xmx3584m -Xms3584m -Xmn896m -XX:MaxPermSize=512M -XX:SurvivorRatio=5 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=9090 -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.authenticate=false -XX:MaxTenuringThreshold=10 -XX:InitialTenuringThreshold=10 -Xloggc:gclogs/gc.log -XX:+PrintGCDetails -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCApplicationConcurrentTime -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=2000k"
^ here
There appears to be both 'k=v' shorthand syntax and YAML in this task. Only one syntax may be used.
This one looks easy to fix. It seems that there is a value started
with a quote, and the YAML parser is expecting to see the line ended
with the same kind of quote. For instance:
when: "ok" in result.stdout
Could be written as:
when: '"ok" in result.stdout'
Or equivalently:
when: "'ok' in result.stdout"
in our group_vars folder we use variable like this:
service : "-XX:+UseG1GC -Xmx3584m -Xms3584m -Xmn896m -XX:MaxPermSize=512M -XX:SurvivorRatio=5 -Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.port=9090 -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.authenticate=false -XX:MaxTenuringThreshold=10 -XX:
InitialTenuringThreshold=10 -Xloggc:gclogs/gc.log -XX:+PrintGCDetails -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCApplicationConcurrentTime -XX:+PrintGCDate
Stamps -XX:+PrintTenuringDistribution -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=2000k"
this is command to start as systemd unit. Where i mistake ? I think that error in equal sign but i`m cant replace it.
Upvotes: 2
Views: 7751
Reputation: 68034
This must be some problem with the formatting or indentation. The play below works as expected.
- hosts: localhost
vars:
svc: "-XX:+UseG1GC -Xmx3584m -Xms3584m -Xmn896m -XX:MaxPermSize=512M -XX:SurvivorRatio=5
-Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=9090
-Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.authenticate=false
-XX:MaxTenuringThreshold=10 -XX:InitialTenuringThreshold=10 -Xloggc:gclogs/gc.log
-XX:+PrintGCDetails -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCApplicationConcurrentTime
-XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution -XX:+UseGCLogFileRotation
-XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=2000k"
tasks:
- debug:
var: svc
Upvotes: 1