You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
states/app/consul/tls.sls

49 lines
1.3 KiB

---
include:
- app.consul.ca
{% set consul_cert_file = salt.pillar.get("consul:config:cert_file") %}
{% if not consul_cert_file %}
{{ raise("Consul's `cert_file` value is unset!") }}
{% endif %}
{% set consul_key_file = salt.pillar.get("consul:config:key_file") %}
{% if not consul_key_file %}
{{ raise("Consul's `key_file` value is unset!") }}
{% endif %}
{% if "consul_agent" in grains["roles"] -%}
{{ consul_cert_file }}:
file.managed:
- user: {{ salt.pillar.get("consul:user", "root") }}
- group: {{ salt.pillar.get("consul:group", "root") }}
- mode: 0660
- contents_pillar: "consul:tls:client:certificate"
{{ consul_key_file }}:
file.managed:
- user: {{ salt.pillar.get("consul:user", "root") }}
- group: {{ salt.pillar.get("consul:group", "root") }}
- mode: 0660
- contents_pillar: "consul:tls:client:key"
{% elif "consul_server" in grains["roles"] -%}
{{ consul_cert_file }}:
file.managed:
- user: {{ salt.pillar.get("consul:user", "root") }}
- group: {{ salt.pillar.get("consul:group", "root") }}
- mode: 0660
- contents_pillar: "consul:tls:server:certificate"
{{ consul_key_file }}:
file.managed:
- user: {{ salt.pillar.get("consul:user", "root") }}
- group: {{ salt.pillar.get("consul:group", "root") }}
- mode: 0660
- contents_pillar: "consul:tls:server:key"
{% endif %}