sivann sivann - 1 year ago 235
YAML Question

SaltStack: edit yaml file on minion host based on salt pillar data

Say the minion host has a default yaml configuration named

. What I want to do is to edit parts of those yaml entries using values from a pillar. I can't even begin to think how to do this on Salt. The only think I can think of is to run a custom python script on the host via
and feed it with input via arguments, but this seems overcomplicated.

I want to avoid
. I cannot use a template, since the
file is big, and can change by external means. I just want to edit a few parameters in it. I suppose a python script could do it but I thought salt could do it without writing s/w

I have found
with the
option, I will try this and report.

Answer Source

This can be done for both json and yaml with file.serialize. Input can be inline on the state or come from a pillar. A short excerpt follows:


    - serialize
#    - dataset:
#        concurrent_reads: 8
    - dataset_pillar: cassandra_yaml
    - name: /etc/cassandra/conf/cassandra.yaml
    - formatter: yaml
    - merge_if_exists: True
    - require:
      - pkg: cassandra-pkgs


  concurrent_reads: "8"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download