Loading...

Testing YAML

YAML (YAML Ain’t Markup Language) is a essential part of Ansible playbooks. If you have really long options to pass to programs, yaml offers several possibilities to maintain it readable and thus maintainable. This article demonstrates how how to split a string over multiple lines in yaml.

Experimenting with Apache Kafka and Docker I have following situation. I want to enable JMX by passing this options:

KAFKA_JMX_OPTS: "-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname={{ansible_hostname}}"

I prefer to have each option on a separate line. Several sources on that

The solution:

KAFKA_JMX_OPTS: "-Dcom.sun.management.jmxremote \
  -Dcom.sun.management.jmxremote.authenticate=false \
  -Dcom.sun.management.jmxremote.ssl=false \
  -Djava.rmi.server.hostname={{ansible_hostname}} \
  -Dcom.sun.management.jmxremote.rmi.port=9099"
JMX_PORT: 9099

There is also a great Online Tool for testing the YAML specification.

YAML JavaScript Parser

Comments


Leave a comment