feat/consul-internal-tls #8
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,5 +6,6 @@ vault_config.yml
|
|||||||
consul_config.yml
|
consul_config.yml
|
||||||
**/certificates/**
|
**/certificates/**
|
||||||
**/secrets/credentials.yml
|
**/secrets/credentials.yml
|
||||||
|
**/secrets/credentials.decrypt.yml
|
||||||
**/secrets/vault.yml
|
**/secrets/vault.yml
|
||||||
**/.ansible-vault
|
**/.ansible-vault
|
||||||
|
@ -192,7 +192,7 @@
|
|||||||
|
|
||||||
- name: "Create Consul certificates"
|
- name: "Create Consul certificates"
|
||||||
when:
|
when:
|
||||||
- "'consul_servers' in group_names"
|
- "('consul_servers' in group_names) or ('consul_agents' in group_names)"
|
||||||
vars:
|
vars:
|
||||||
consul_private_key_path: "{{ sub_configuration_directories['certificates'] }}/consul/{{ inventory_hostname }}/key.pem"
|
consul_private_key_path: "{{ sub_configuration_directories['certificates'] }}/consul/{{ inventory_hostname }}/key.pem"
|
||||||
consul_certificate_path: "{{ sub_configuration_directories['certificates'] }}/consul/{{ inventory_hostname }}/cert.pem"
|
consul_certificate_path: "{{ sub_configuration_directories['certificates'] }}/consul/{{ inventory_hostname }}/cert.pem"
|
||||||
|
@ -5,6 +5,16 @@
|
|||||||
# #
|
# #
|
||||||
#####################################################
|
#####################################################
|
||||||
|
|
||||||
|
#####################
|
||||||
|
# consul api config #
|
||||||
|
#####################
|
||||||
|
|
||||||
|
consul_api_addr: "{{ consul_api_scheme }}://{{ api_interface_address }}:{{ consul_api_port[consul_api_scheme] }}"
|
||||||
|
consul_api_scheme: "{{ 'https' if consul_enable_tls else 'http' }}"
|
||||||
|
consul_api_port:
|
||||||
|
http: 8500
|
||||||
|
https: 8501
|
||||||
|
|
||||||
##########################
|
##########################
|
||||||
# consul haproxy backend #
|
# consul haproxy backend #
|
||||||
##########################
|
##########################
|
||||||
@ -27,7 +37,7 @@ consul_external_backend_options:
|
|||||||
consul_external_backend_servers: |
|
consul_external_backend_servers: |
|
||||||
[
|
[
|
||||||
{% for host in groups['consul_servers'] %}
|
{% for host in groups['consul_servers'] %}
|
||||||
'server consul-{{ hostvars[host].api_interface_address }} {{ hostvars[host].api_interface_address }}:{{ hashi_consul_configuration.ports.http }} check inter 5s'{% if not loop.last %},{% endif %}
|
'server consul-{{ hostvars[host].api_interface_address }} {{ hostvars[host].api_interface_address }}:{{ hostvars[host].consul_api_port[consul_api_scheme] }} check {{ 'ssl verify none ' if consul_enable_tls }}inter 5s'{% if not loop.last %},{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -43,6 +53,15 @@ consul_default_agent_policy: |
|
|||||||
policy = "read"
|
policy = "read"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#######################
|
||||||
|
# consul internal tls #
|
||||||
|
#######################
|
||||||
|
|
||||||
|
consul_certificates_directory: "{{ hashi_consul_config_dir }}/tls"
|
||||||
|
consul_certificates_extra_files_dir:
|
||||||
|
- src: "{{ sub_configuration_directories['certificates'] }}/consul/{{ inventory_hostname }}"
|
||||||
|
dest: "{{ consul_certificates_directory }}"
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
# consul role variables #
|
# consul role variables #
|
||||||
#########################
|
#########################
|
||||||
@ -53,9 +72,15 @@ hashi_consul_deploy_method: "{{ deployment_method }}"
|
|||||||
hashi_consul_env_variables: {}
|
hashi_consul_env_variables: {}
|
||||||
hashi_consul_config_dir: "/etc/consul.d"
|
hashi_consul_config_dir: "/etc/consul.d"
|
||||||
hashi_consul_data_dir: "/opt/consul"
|
hashi_consul_data_dir: "/opt/consul"
|
||||||
hashi_consul_extra_files: false
|
hashi_consul_extra_files: true
|
||||||
hashi_consul_extra_files_src: "{{ sub_configuration_directories.consul_servers }}/config"
|
hashi_consul_extra_files_list: "{{ ([] +
|
||||||
hashi_consul_extra_files_dst: "{{ hashi_consul_config_dir }}/config"
|
(consul_certificates_extra_files_dir if consul_enable_tls else []) +
|
||||||
|
(vault_plugin_extra_files_dir if vault_enable_plugins else []) +
|
||||||
|
vault_extra_files_list)
|
||||||
|
| unique
|
||||||
|
| sort
|
||||||
|
}}"
|
||||||
|
hashi_consul_extra_container_volumes: "{{ default_container_extra_volumes | union(extra_consul_container_volumes) | unique }}"
|
||||||
hashi_consul_envoy_install: false
|
hashi_consul_envoy_install: false
|
||||||
hashi_consul_envoy_version: v1.27.2
|
hashi_consul_envoy_version: v1.27.2
|
||||||
hashi_consul_configuration:
|
hashi_consul_configuration:
|
||||||
@ -83,8 +108,6 @@ hashi_consul_configuration:
|
|||||||
dns_config: "{{ consul_dns_configuration }}"
|
dns_config: "{{ consul_dns_configuration }}"
|
||||||
ports:
|
ports:
|
||||||
dns: 8600
|
dns: 8600
|
||||||
http: 8500 # "{{ ('8500'|int) if not }}"
|
|
||||||
https: -1
|
|
||||||
grpc: 8502
|
grpc: 8502
|
||||||
grpc_tls: 8503
|
grpc_tls: 8503
|
||||||
server: 8300
|
server: 8300
|
||||||
@ -98,3 +121,6 @@ hashi_consul_configuration:
|
|||||||
# this is used to circumvent jinja limitation to convert string to integer
|
# this is used to circumvent jinja limitation to convert string to integer
|
||||||
hashi_consul_configuration_string: |
|
hashi_consul_configuration_string: |
|
||||||
bootstrap_expect: {{ (groups['consul_servers'] | length) }}
|
bootstrap_expect: {{ (groups['consul_servers'] | length) }}
|
||||||
|
ports:
|
||||||
|
http: {{ (consul_api_port.http|int) if not consul_enable_tls else ('-1' | int) }}
|
||||||
|
https: {{ (consul_api_port.https|int) if consul_enable_tls else ('-1' | int) }}
|
||||||
|
@ -100,22 +100,29 @@ consul_mesh_configuration:
|
|||||||
# consul tls configuration #
|
# consul tls configuration #
|
||||||
############################
|
############################
|
||||||
|
|
||||||
consul_enable_tls: false
|
consul_enable_tls: true
|
||||||
consul_tls_configuration:
|
consul_tls_configuration:
|
||||||
default:
|
defaults:
|
||||||
ca_file: "/etc/ssl/certs/ca-certificates.crt"
|
ca_file: "/etc/ssl/certs/ca-certificates.crt"
|
||||||
cert_file: "{{ hashi_consul_config_dir }}/tls/cert.pem"
|
cert_file: "{{ consul_certificates_directory }}/cert.pem"
|
||||||
key_file: "{{ hashi_consul_config_dir }}/tls/key.pem"
|
key_file: "{{ consul_certificates_directory }}/key.pem"
|
||||||
verify_incoming: false
|
verify_incoming: false
|
||||||
verify_outgoing: true
|
verify_outgoing: true
|
||||||
internal_rpc:
|
internal_rpc:
|
||||||
verify_server_hostname: true
|
verify_server_hostname: true
|
||||||
|
|
||||||
|
############################
|
||||||
|
# consul container volumes #
|
||||||
|
############################
|
||||||
|
|
||||||
|
extra_consul_container_volumes: []
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
# extra configuration #
|
# extra configuration #
|
||||||
#######################
|
#######################
|
||||||
|
|
||||||
consul_extra_configuration: {}
|
consul_extra_configuration: {}
|
||||||
|
consul_extra_files_list: []
|
||||||
|
|
||||||
#####################################################
|
#####################################################
|
||||||
# #
|
# #
|
||||||
|
@ -38,7 +38,7 @@ vault_external_backend_servers: |
|
|||||||
vault_certificates_directory: "{{ hashi_vault_config_dir }}/tls"
|
vault_certificates_directory: "{{ hashi_vault_config_dir }}/tls"
|
||||||
vault_certificates_extra_files_dir:
|
vault_certificates_extra_files_dir:
|
||||||
- src: "{{ sub_configuration_directories['certificates'] }}/vault/{{ inventory_hostname }}"
|
- src: "{{ sub_configuration_directories['certificates'] }}/vault/{{ inventory_hostname }}"
|
||||||
dest: "{{ hashi_vault_config_dir }}/tls"
|
dest: "{{ vault_certificates_directory }}"
|
||||||
|
|
||||||
#################
|
#################
|
||||||
# vault plugins #
|
# vault plugins #
|
||||||
@ -47,7 +47,7 @@ vault_certificates_extra_files_dir:
|
|||||||
vault_plugin_directory: "{{ hashi_vault_config_dir }}/plugin"
|
vault_plugin_directory: "{{ hashi_vault_config_dir }}/plugin"
|
||||||
vault_plugin_extra_files_dir:
|
vault_plugin_extra_files_dir:
|
||||||
- src: "{{ sub_configuration_directories['vault_servers'] }}/plugin"
|
- src: "{{ sub_configuration_directories['vault_servers'] }}/plugin"
|
||||||
dest: "{{ hashi_vault_config_dir }}/plugin"
|
dest: "{{ vault_plugin_directory }}"
|
||||||
|
|
||||||
########################
|
########################
|
||||||
# vault role variables #
|
# vault role variables #
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
- name: "Wait for consul cluster to initialize" # noqa: run-once[task]
|
- name: "Wait for consul cluster to initialize" # noqa: run-once[task]
|
||||||
ansible.builtin.uri:
|
ansible.builtin.uri:
|
||||||
url: "http://{{ api_interface_address }}:8500" # TODO: this should be dynamic (http/https)
|
url: "{{ consul_api_addr }}"
|
||||||
validate_certs: no
|
validate_certs: no
|
||||||
return_content: yes
|
return_content: yes
|
||||||
status_code:
|
status_code:
|
||||||
@ -20,9 +20,9 @@
|
|||||||
- name: "Initialize consul cluster" # noqa: run-once[task]
|
- name: "Initialize consul cluster" # noqa: run-once[task]
|
||||||
community.general.consul_acl_bootstrap:
|
community.general.consul_acl_bootstrap:
|
||||||
bootstrap_secret: "{{ _credentials.consul.root_token.secret_id }}"
|
bootstrap_secret: "{{ _credentials.consul.root_token.secret_id }}"
|
||||||
host: "{{ hashi_consul_configuration['advertise_addr'] }}"
|
host: "{{ api_interface_address }}"
|
||||||
port: 8500
|
port: "{{ consul_api_port[consul_api_scheme] }}"
|
||||||
scheme: http
|
scheme: "{{ consul_api_scheme }}"
|
||||||
state: present
|
state: present
|
||||||
run_once: true
|
run_once: true
|
||||||
delegate_to: "{{ groups['consul_servers'] | first }}"
|
delegate_to: "{{ groups['consul_servers'] | first }}"
|
||||||
@ -63,8 +63,8 @@
|
|||||||
community.general.consul_policy:
|
community.general.consul_policy:
|
||||||
token: "{{ _credentials.consul.root_token.secret_id }}"
|
token: "{{ _credentials.consul.root_token.secret_id }}"
|
||||||
host: "{{ api_interface_address }}"
|
host: "{{ api_interface_address }}"
|
||||||
port: 8500
|
port: "{{ consul_api_port[consul_api_scheme] }}"
|
||||||
scheme: http # TODO: this should be dynamic
|
scheme: "{{ consul_api_scheme }}"
|
||||||
validate_certs: false
|
validate_certs: false
|
||||||
state: present
|
state: present
|
||||||
name: agents-policy
|
name: agents-policy
|
||||||
@ -73,14 +73,13 @@
|
|||||||
|
|
||||||
- name: "Create consul agents token"
|
- name: "Create consul agents token"
|
||||||
vars:
|
vars:
|
||||||
consul_full_url: "http://{{ hashi_consul_configuration['advertise_addr'] }}:8500"
|
|
||||||
consul_token_body:
|
consul_token_body:
|
||||||
Description: "Consul agents token"
|
Description: "Consul agents token"
|
||||||
SecretID: "{{ _credentials.consul.tokens.agent }}"
|
SecretID: "{{ _credentials.consul.tokens.agent }}"
|
||||||
Policies:
|
Policies:
|
||||||
- ID: "{{ _consul_agent_policy.policy.ID }}"
|
- ID: "{{ _consul_agent_policy.policy.ID }}"
|
||||||
ansible.builtin.uri:
|
ansible.builtin.uri:
|
||||||
url: "{{ consul_full_url }}/v1/acl/token"
|
url: "{{ consul_api_addr }}/v1/acl/token"
|
||||||
method: PUT
|
method: PUT
|
||||||
headers:
|
headers:
|
||||||
X-Consul-Token: "{{ _credentials.consul.root_token.secret_id }}"
|
X-Consul-Token: "{{ _credentials.consul.root_token.secret_id }}"
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit c6fbfe5b78ef8b8884af129ea84afb26da754833
|
Subproject commit 56696c3552308225d4e5b91efc8e4bf75d31d2f3
|
Loading…
Reference in New Issue
Block a user