Loading...

Testing YAML

:heavy_exclamation_mark: This post is older than a year. Consider some information might not be accurate anymore. :heavy_exclamation_mark:

Used:   yaml v1.2 

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
Please remember the terms for blog comments.