ansible-collections/ansible-consul

Second run corrupts /etc/consul/config.json

bbaassssiiee opened this issue · 2 comments

When I run this role for a second time my configuration file suffers from some weird autoescaping.

In the first run config.yml copies the template with to_nice_json just fine. When I pipe it through to jq then I see a nice structure. The second run leaves the file as one line with multiple escaped newlines as '\n'.

I rolled back to ansible 2.8.5. to avoid ansible/ansible#63940

"{\n    \n        \"node_name\": \"cons1\",\n    \"datacenter\": \"dc1\",\n    \"domain\": \"consul\",\n            \"performance\": {\"raft_multiplier\": 1, \"leave_drain_time\": \"5s\", \"rpc_hold_timeout\": \"7s\"},\n\n        \"bind_addr\": \"10.1.1.196\",\n    \"advertise_addr\": \"10.1.1.196\",\n    \"advertise_addr_wan\": \"10.1.1.196\",\n    \"translate_wan_addrs\": false,\n    \"client_addr\": \"0.0.0.0\",\n    \"addresses\": {\n                \"dns\": \"0.0.0.0\",\n        \"http\": \"0.0.0.0\",\n        \"https\": \"0.0.0.0\",\n                \"grpc\": \"0.0.0.0\"\n            },\n        \"ports\": {\n                \"dns\": 8600,\n        \"http\": 8500,\n        \"https\": 8501,\n        \"serf_lan\": 8301,\n        \"serf_wan\": 8302,\n        \"server\": 8300,\n                \"grpc\": -1\n            },\n\n        \"raft_protocol\": 3,\n\n                \"recursors\": [\"10.1.1.100\", \"10.1.1.110\"],\n    \n        \"data_dir\": \"/var/consul\",\n    \"log_level\": \"INFO\",\n        \"log_file\": \"/var/log/consul/consul.log\",\n    \"log_rotate_bytes\": 0,\n    \"log_rotate_duration\": \"24h\",\n    \"log_rotate_max_files\": 14,\n        \"disable_update_check\": false,\n    \"enable_script_checks\": true,\n    \"enable_local_script_checks\": false,\n\n            \"encrypt\": \"6FK9j8P0mMd9UaiC4662f/3a5gUYlzoZY4acb6TlQr0=\",\n                \"ca_file\": \"/etc/consul/ssl/ca.cert\",\n    \"cert_file\": \"/etc/consul/ssl/server.crt\",\n    \"key_file\": \"/etc/consul/ssl/server.key\",\n    \"verify_incoming\": false,\n    \"verify_outgoing\": true,\n    \"verify_incoming_https\": false,\n    \"verify_server_hostname\": false,\n    \"tls_min_version\": \"tls12\",\n        \"tls_prefer_server_cipher_suites\": false,\n    \n        \"retry_interval\": \"30s\",\n    \"retry_max\": 0,\n\n    \"retry_join\":\n                                                      [\"10.1.1.196\", \"10.1.1.195\", \"10.1.1.197\"],\n\n        \"server\": true,\n\n        \n        \n        \"bootstrap\": false,\n            \"bootstrap_expect\": 3,\n\n                \n    \n        \"retry_interval_wan\": \"30s\",\n    \"retry_max_wan\": 0,\n\n    \n                                    \"primary_datacenter\": \"dc1\",\n            \"acl\": {\n                \"enabled\": true,\n                \"default_policy\": \"deny\",\n                \"down_policy\": \"extend-cache\",\n                \"token_ttl\": \"30s\",\n                \"tokens\": {\n                                        \"default\": \"anonymous\",\n                                                            \"agent\": \"anonymous\",\n                                                                                \"master\": \"12345678-abcd-abcd-abcd-111abc30ca9f\",\n                                                            \"replication\": \"s/^ *//;s/ *$//\n            12345678-abcd-def1-def1-111abc30ca9f\",\n                                    }\n            },\n                \n        \"ui\": true\n}\n\n"

Already fixed by e1a0a8a