mirror of
https://git.lapiole.org/dani/ansible-roles.git
synced 2025-07-27 00:05:44 +02:00
Update to 2022-09-13 17:00
This commit is contained in:
18
roles/consul/templates/agent_bundle.pem.tpl.j2
Normal file
18
roles/consul/templates/agent_bundle.pem.tpl.j2
Normal file
@@ -0,0 +1,18 @@
|
||||
{% if consul_conf.server %}
|
||||
[[ with pkiCert "{{ consul_vault_secrets.pki.path }}/issue/{{ consul_vault_secrets.pki.role }}" "common_name=server-{{ ansible_fqdn | regex_replace('\\.', '-') }}.{{ consul_conf.datacenter | default('dc1') }}.{{ consul_conf.domain | default('consul') }}" "alt_names=localhost,consul.service.{{ consul_conf.domain | default('consul') }},server.{{ consul_conf.datacenter | default('dc1') }}.{{ consul_conf.domain | default('consul') }}" ]]
|
||||
[[ .CA ]]
|
||||
[[ .Cert ]]
|
||||
[[ .Key ]]
|
||||
[[ .CA | writeToFile "{{ consul_conf.tls.defaults.ca_file }}" "root" "root" "0644" ]]
|
||||
[[ .Cert | writeToFile "{{ consul_conf.tls.defaults.cert_file }}" "root" "root" "0644" ]]
|
||||
[[ .Key | writeToFile "{{ consul_conf.tls.defaults.key_file }}" "root" "{{ consul_user }}" "0640" ]]
|
||||
[[ end ]]
|
||||
[[ with secret "{{ consul_vault_secrets.pki.path }}/cert/ca" ]]
|
||||
[[ .Data.certificate | writeToFile "{{ consul_conf.tls.defaults.cert_file }}" "root" "root" "0644" "append,newline" ]]
|
||||
[[ end ]]
|
||||
{% else %}
|
||||
[[ with secret "{{ consul_vault_secrets.pki.path }}/cert/ca" ]]
|
||||
[[ .Data.certificate | writeToFile "{{ consul_conf.tls.defaults.ca_file }}" "root" "root" "0644" ]]
|
||||
[[ end ]]
|
||||
{% endif %}
|
||||
|
@@ -1,14 +0,0 @@
|
||||
{% if consul_conf.server %}
|
||||
[[ with secret "{{ consul_vault_secrets.pki.path }}/issue/{{ consul_vault_secrets.pki.role }}" "common_name=server-{{ ansible_fqdn | regex_replace('\\.', '-') }}.{{ consul_conf.datacenter | default('dc1') }}.{{ consul_conf.domain | default('consul') }}" "alt_names=localhost,consul.service.{{ consul_conf.domain | default('consul') }},server.{{ consul_conf.datacenter | default('dc1') }}.{{ consul_conf.domain | default('consul') }}" ]]
|
||||
[[ .Data.{{ item.what }} ]]
|
||||
[[ end ]]
|
||||
{% if item.what == 'certificate' %}
|
||||
[[ with secret "{{ consul_vault_secrets.pki.path }}/cert/ca" ]]
|
||||
[[ .Data.certificate ]]
|
||||
[[ end ]]
|
||||
{% endif %}
|
||||
{% else %}
|
||||
[[ with secret "{{ consul_vault_secrets.pki.path }}/cert/ca" ]]
|
||||
[[ .Data.certificate ]]
|
||||
[[ end ]]
|
||||
{% endif %}
|
7
roles/consul/templates/cli_bundle.pem.tpl.j2
Normal file
7
roles/consul/templates/cli_bundle.pem.tpl.j2
Normal file
@@ -0,0 +1,7 @@
|
||||
[[ with pkiCert "{{ consul_vault_secrets.pki.path }}/issue/{{ consul_vault_secrets.pki.role }}" "common_name=cli-{{ ansible_fqdn | regex_replace('\\.', '-') }}.{{ consul_conf.datacenter | default('dc1') }}.{{ consul_conf.domain | default('consul') }}" ]]
|
||||
[[ .CA ]]
|
||||
[[ .Cert ]]
|
||||
[[ .Key ]]
|
||||
[[ .Cert | writeToFile "{{ consul_root_dir }}/tls/cli.crt" "root" "root" "0644" ]]
|
||||
[[ .Key | writeToFile "{{ consul_root_dir }}/tls/cli.key" "root" "root" "0640" ]]
|
||||
[[ end ]]
|
@@ -1,3 +0,0 @@
|
||||
[[ with secret "{{ consul_vault_secrets.pki.path }}/issue/{{ consul_vault_secrets.pki.role }}" "common_name=cli-{{ ansible_fqdn | regex_replace('\\.', '-') }}.{{ consul_conf.datacenter | default('dc1') }}.{{ consul_conf.domain | default('consul') }}" ]]
|
||||
[[ .Data.{{ item.what }} ]]
|
||||
[[ end ]]
|
@@ -5,55 +5,27 @@ vault {
|
||||
}
|
||||
|
||||
template {
|
||||
source = "{{ consul_root_dir }}/consul-template/ca.crt.tpl"
|
||||
source = "{{ consul_root_dir }}/consul-template/agent_bundle.pem.tpl"
|
||||
left_delimiter = "[["
|
||||
right_delimiter = "]]"
|
||||
destination = "{{ consul_conf.tls.defaults.ca_file }}"
|
||||
perms = 0644
|
||||
destination = "{{ consul_root_dir }}/tls/agent_bundle.pem"
|
||||
perms = 0640
|
||||
exec {
|
||||
command = "sh -c 'systemctl reload consul || true'"
|
||||
}
|
||||
}
|
||||
|
||||
{% if consul_vault_secrets.pki.enabled %}
|
||||
{% if consul_conf.server %}
|
||||
template {
|
||||
source = "{{ consul_root_dir }}/consul-template/agent.crt.tpl"
|
||||
source = "{{ consul_root_dir }}/consul-template/cli_bundle.pem.tpl"
|
||||
left_delimiter = "[["
|
||||
right_delimiter = "]]"
|
||||
destination = "{{ consul_conf.tls.defaults.cert_file }}"
|
||||
perms = 0644
|
||||
destination = "{{ consul_root_dir }}/tls/cli_bundle.pem"
|
||||
perms = 0640
|
||||
exec {
|
||||
command = "sh -c 'systemctl reload consul || true'"
|
||||
}
|
||||
}
|
||||
|
||||
template {
|
||||
source = "{{ consul_root_dir }}/consul-template/agent.key.tpl"
|
||||
left_delimiter = "[["
|
||||
right_delimiter = "]]"
|
||||
destination = "{{ consul_conf.tls.defaults.key_file }}"
|
||||
perms = 0640
|
||||
exec {
|
||||
command = "sh -c 'chgrp {{ consul_user }} {{ consul_conf.tls.defaults.key_file }} && systemctl reload consul || true'"
|
||||
}
|
||||
}
|
||||
|
||||
template {
|
||||
source = "{{ consul_root_dir }}/consul-template/cli.crt.tpl"
|
||||
left_delimiter = "[["
|
||||
right_delimiter = "]]"
|
||||
destination = "{{ consul_root_dir }}/tls/cli.crt"
|
||||
}
|
||||
|
||||
template {
|
||||
source = "{{ consul_root_dir }}/consul-template/cli.key.tpl"
|
||||
left_delimiter = "[["
|
||||
right_delimiter = "]]"
|
||||
destination = "{{ consul_root_dir }}/tls/cli.key"
|
||||
perms = 0640
|
||||
}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if consul_vault_secrets.tokens.enabled %}
|
||||
|
@@ -89,6 +89,7 @@ acl {
|
||||
}
|
||||
|
||||
{% if consul_conf.tls.enabled %}
|
||||
{% if consul_conf.server %}
|
||||
# TLS settings
|
||||
tls {
|
||||
{% for section in ['defaults', 'grpc', 'https', 'internal_rpc'] %}
|
||||
@@ -110,7 +111,6 @@ tls {
|
||||
}
|
||||
|
||||
# auto_encrypt, to distribute certificates from servers to clients
|
||||
{% if consul_conf.server %}
|
||||
auto_encrypt {
|
||||
allow_tls = true
|
||||
}
|
||||
|
@@ -6,7 +6,6 @@ After=network-online.target
|
||||
ConditionFileNotEmpty={{ consul_root_dir }}/etc/consul.hcl
|
||||
|
||||
[Service]
|
||||
Type=notify
|
||||
EnvironmentFile=-{{ consul_root_dir }}/etc/consul.env
|
||||
User={{ consul_user }}
|
||||
Group={{ consul_user }}
|
||||
|
Reference in New Issue
Block a user