consul-formula icon indicating copy to clipboard operation
consul-formula copied to clipboard

Use cmd_check to validate config files

Open nledez opened this issue 7 years ago • 2 comments

In some case I have an error in config file. State detect a change, restart services, restart fail. It's bad.

Soo, I rewrite the resources to use file.managed allowed cmd_check.

It works as:

  Name: /usr/local/bin/consul - Function: file.symlink - Result: Clean Started: - 14:26:24.064532 Duration: 2.029 ms
----------
          ID: consul-config
    Function: file.managed
        Name: /etc/consul.d/config.json
      Result: False
     Comment: check_cmd execution failed
              Config validation failed: Error parsing /tmp/__salt.tmp.sQ8J8n.json: 1 error(s) occurred:

              * invalid config key asdf
     Started: 14:26:24.067033
    Duration: 193.813 ms
     Changes:
  Name: /etc/consul.d/services.json - Function: file.managed - Result: Clean Started: - 14:26:24.261664 Duration: 68.404 ms
  Name: /etc/default/consul - Function: file.managed - Result: Clean Started: - 14:26:24.330434 Duration: 13.754 ms
  Name: /etc/systemd/system/consul.service - Function: file.managed - Result: Clean Started: - 14:26:24.344581 Duration: 38.792 ms
----------
          ID: consul-service
    Function: service.running
        Name: consul
      Result: False
     Comment: One or more requisite failed: consul.config.consul-config
     Started: 14:26:24.386892
    Duration: 0.018 ms
     Changes:

Last think. I have an issue with whitespace and end of some lines :/ It's not a problem for Consul or Saltstack. Just for me when I open file with my vi doesn't like them and show me a "warning" (like my brain in fact :p ).

nledez avatar Nov 04 '18 15:11 nledez

Work on Travis’s issue.

nledez avatar Nov 04 '18 15:11 nledez

Ready to merge :)

nledez avatar Nov 04 '18 16:11 nledez