Consul modules for SaltStack
I'd been meaning to write this for awhile, then one afternoon just decided I didn't want to lay down json for every service & check, not to mention reload the service. Still a work in progress, but most of the functions I use are represented here.
- drop the modules into
{_modules,_states}
intofile_roots
on yoursalt-master
- ensure the pypi
python-consul
package is installed
salt-call consul.key_put foo bar
salt-call consul.key_get foo
salt-call consul.key_delete foo
salt-call consul.service_list
salt-call consul.service_get foo
salt-call consul.service_register name=foo port=6969 script=/path/to/script interval=10s
salt-call consul.service_deregister name=foo
salt-call consul.get_service_status name=foo
salt-call consul.check_list
salt-call consul.check_get foo
salt-call consul.check_register name=foo script=/path/to/script interval=10s
salt-call consul.check_deregister name=foo
salt-call consul.node_list
salt-call consul.node_get foo
salt-call consul.ttl_pass foo type=service notes=bar
salt-call consul.ttl_fail foo type=check notes=bar
salt-call consul.ttl_warn foo notes=bar
salt-call consul.acl_create master_token=master_token rules='key "" { policy = "read" }'
salt-call consul.acl_list master_token=master_token
salt-call consul.acl_get acl_id=e02be371-60c3-ed74-56a3-c325a86f36e3 master_token=master_token
salt-call consul.acl_update acl_id=e02be371-60c3-ed74-56a3-c325a86f36e3 name=foo type=management master_token=master_token
salt-call consul.acl_destroy acl_id=e02be371-60c3-ed74-56a3-c325a86f36e3
consul-key-present:
consul_key.present:
- name: foo
- value: bar
consul-key-absent:
consul_key.absent:
- name: foo
consul-service-present:
consul_service.present:
- name: foo
- port: 6969
- script: nc -z localhost 6969
- interval: 10s
consul-service-absent:
consul_service.absent:
- name: foo
consul-check-present:
consul_check.present:
- name: foo
- script: nz -z localhost 6969
- interval: 10s
consul-check-absent:
consul_check.absent:
- name: foo
consul-set-service-ttl:
consul_service.ttl_set:
- name: foo
- status: failing
- notes: bar
consul-set-check-ttl:
consul_check.ttl_set:
- name: foo
- status: failing
- notes: bar
- acls
- fork
- code
- submit pr