Thanks for the info! It solved one piece of the puzzle.
I thought I'd document what I was trying to do, and some of the issues I ran into. There might be somebody else trying to do the same thing.
Fundamentally what I wanted was to configure a docker instance of Consul without using a static config file. In other words, configure my Consul docker image strictly from the command line. Further, since I can't use Nomad to control the placement of containers, I was using Ansible to create the container. Here are the issues I ran into and how I resolved them:
- There are no command line options for enabling consul connect or the grpc port. Doing so requires setting CONSUL_LOCAL_CONFIG environment variable.. The catch is that the contents need to be well formed json. But all the documentation examples are in HCL leaving me to intuit what the json equivalent was. This might be an opportunity for the Consul team to either 1) allow CONSUL_LOCAL_CONFIG to contain HCL or 2) redo documentation along the lines of Traefik which provides TOML, YAML and CLI examples for all configuration options.
- Trying to construct a well formed json string in Ansible isn't straightforward given the Ansible templating engine. The trick was to create a YAML equivalent of the json and then use the Ansible to_json filter.
- Although documented, I didn't expect that in addition to setting a environment variable I also needed to modify the Consul configuration. The Consul docker container processes the CONSUL_LOCAL_CONFIG by writing the contents to a file in /consul/config. The gotcha is that the /consul/config directory is not parsed by default. It requires that one set the -config-dir command line to /consul/config. I assumed - I think reasonably - that setting CONSUL_LOCAL_CONFIG was sufficient. There might be another opportunity here for the Consul team to modify behavior, update docs or provide an example.
Hope this either helps or give someone a good laugh!
-steve