aboutsummaryrefslogtreecommitdiffstats
path: root/fdio.infra.ansible/roles/nomad/templates
diff options
context:
space:
mode:
Diffstat (limited to 'fdio.infra.ansible/roles/nomad/templates')
-rw-r--r--fdio.infra.ansible/roles/nomad/templates/base.hcl.j225
-rw-r--r--fdio.infra.ansible/roles/nomad/templates/client.hcl.j247
-rw-r--r--fdio.infra.ansible/roles/nomad/templates/consul.hcl.j218
-rw-r--r--fdio.infra.ansible/roles/nomad/templates/custom.hcl.j25
-rw-r--r--fdio.infra.ansible/roles/nomad/templates/server.hcl.j230
-rw-r--r--fdio.infra.ansible/roles/nomad/templates/telemetry.hcl.j225
-rw-r--r--fdio.infra.ansible/roles/nomad/templates/tls.hcl.j210
7 files changed, 111 insertions, 49 deletions
diff --git a/fdio.infra.ansible/roles/nomad/templates/base.hcl.j2 b/fdio.infra.ansible/roles/nomad/templates/base.hcl.j2
index 7badecf9e0..cd7fb54f9c 100644
--- a/fdio.infra.ansible/roles/nomad/templates/base.hcl.j2
+++ b/fdio.infra.ansible/roles/nomad/templates/base.hcl.j2
@@ -1,11 +1,26 @@
-name = "{{ nomad_name }}"
+name = "{{ nomad_node_name }}"
region = "{{ nomad_region }}"
datacenter = "{{ nomad_datacenter }}"
-bind_addr = "{{ nomad_bind_addr }}"
-data_dir = "{{ nomad_data_dir }}"
-
-enable_syslog = {{ nomad_syslog_enable | bool | lower }}
enable_debug = {{ nomad_enable_debug | bool | lower }}
disable_update_check = {{ nomad_disable_update_check | bool | lower }}
+
+bind_addr = "{{ nomad_bind_address }}"
+advertise {
+ http = "{{ nomad_advertise_address }}:{{ nomad_ports.http }}"
+ rpc = "{{ nomad_advertise_address }}:{{ nomad_ports.rpc }}"
+ serf = "{{ nomad_advertise_address }}:{{ nomad_ports.serf }}"
+}
+ports {
+ http = {{ nomad_ports['http'] }}
+ rpc = {{ nomad_ports['rpc'] }}
+ serf = {{ nomad_ports['serf'] }}
+}
+
+data_dir = "{{ nomad_data_dir }}"
+
log_level = "{{ nomad_log_level }}"
+enable_syslog = {{ nomad_syslog_enable | bool | lower }}
+
+leave_on_terminate = {{ nomad_leave_on_terminate | bool | lower }}
+leave_on_interrupt = {{ nomad_leave_on_interrupt | bool | lower }}
diff --git a/fdio.infra.ansible/roles/nomad/templates/client.hcl.j2 b/fdio.infra.ansible/roles/nomad/templates/client.hcl.j2
index f245697a22..f82f38a4e4 100644
--- a/fdio.infra.ansible/roles/nomad/templates/client.hcl.j2
+++ b/fdio.infra.ansible/roles/nomad/templates/client.hcl.j2
@@ -1,14 +1,44 @@
client {
enabled = {{ nomad_node_client | bool | lower }}
- no_host_uuid = {{ nomad_no_host_uuid | bool | lower }}
+
node_class = "{{ nomad_node_class }}"
+ no_host_uuid = {{ nomad_no_host_uuid | bool | lower }}
+
+{% if nomad_use_consul == False %}
+ {% if nomad_servers -%}
+ servers = [ {% for ip_port in nomad_servers -%} "{{ ip_port }}" {% if not loop.last %},{% endif %}{%- endfor -%} ]
+ {% endif -%}
+{% endif %}
+ {% if nomad_network_interface is defined -%}
+ network_interface = "{{ nomad_network_interface }}"
+ {% endif -%}
+ {% if nomad_network_speed is defined -%}
+ network_speed = "{{ nomad_network_speed }}"
+ {% endif -%}
{% if nomad_cpu_total_compute is defined -%}
cpu_total_compute = {{ nomad_cpu_total_compute }}
{% endif -%}
- {% if nomad_servers -%}
- servers = [ {% for ip_port in nomad_servers -%} "{{ ip_port }}" {% if not loop.last %},{% endif %}{%- endfor -%} ]
+ reserved {
+ cpu = {{ nomad_reserved['cpu'] }}
+ memory = {{ nomad_reserved['memory'] }}
+ disk = {{ nomad_reserved['disk'] }}
+ }
+
+ {% for nomad_host_volume in nomad_volumes -%}
+ host_volume "{{ nomad_host_volume.name }}" {
+ path = "{{ nomad_host_volume.path }}"
+ read_only = {{ nomad_host_volume.read_only | bool | lower }}
+ }
+ {% endfor %}
+
+ {% if nomad_chroot_env != False -%}
+ chroot_env = {
+ {% for key, value in nomad_chroot_env.items() %}
+ "{{ key }}" = "{{ value }}"
+ {% endfor -%}
+ }
{% endif %}
{% if nomad_options -%}
@@ -19,13 +49,12 @@ client {
}
{% endif %}
- {% if nomad_volumes -%}
- {% for volume in nomad_volumes -%}
- host_volume "{{ volume.name }}" {
- path = "{{ volume.path }}"
- read_only = {{ volume.read_only | bool | lower }}
- }
+ {% if nomad_meta -%}
+ meta = {
+ {% for key, value in nomad_meta.items() %}
+ "{{ key }}" = "{{ value }}"
{% endfor -%}
+ }
{% endif %}
}
diff --git a/fdio.infra.ansible/roles/nomad/templates/consul.hcl.j2 b/fdio.infra.ansible/roles/nomad/templates/consul.hcl.j2
new file mode 100644
index 0000000000..6d30676ca0
--- /dev/null
+++ b/fdio.infra.ansible/roles/nomad/templates/consul.hcl.j2
@@ -0,0 +1,18 @@
+{% if nomad_use_consul | bool == True %}
+consul {
+ # The address to the Consul agent.
+ address = "{{ nomad_consul_address }}"
+ token = "{{ nomad_consul_token }}"
+ # The service name to register the server and client with Consul.
+ server_service_name = "{{ nomad_consul_servers_service_name }}"
+ client_service_name = "{{ nomad_consul_clients_service_name }}"
+ tags = {{ nomad_consul_tags | to_json }}
+
+ # Enables automatically registering the services.
+ auto_advertise = true
+
+ # Enabling the server and client to bootstrap using Consul.
+ server_auto_join = true
+ client_auto_join = true
+}
+{% endif %} \ No newline at end of file
diff --git a/fdio.infra.ansible/roles/nomad/templates/custom.hcl.j2 b/fdio.infra.ansible/roles/nomad/templates/custom.hcl.j2
deleted file mode 100644
index 37ff6f3496..0000000000
--- a/fdio.infra.ansible/roles/nomad/templates/custom.hcl.j2
+++ /dev/null
@@ -1,5 +0,0 @@
-{% if nomad_config_custom -%}
-{{ nomad_config_custom | to_nice_json }}
-{% else %}
-{}
-{% endif %}
diff --git a/fdio.infra.ansible/roles/nomad/templates/server.hcl.j2 b/fdio.infra.ansible/roles/nomad/templates/server.hcl.j2
index 5ccf45c1ac..663ee3a549 100644
--- a/fdio.infra.ansible/roles/nomad/templates/server.hcl.j2
+++ b/fdio.infra.ansible/roles/nomad/templates/server.hcl.j2
@@ -5,7 +5,29 @@ server {
bootstrap_expect = {{ nomad_bootstrap_expect }}
{%- endif %}
- encrypt = "{{ nomad_encrypt }}"
+ {% if nomad_authoritative_region is defined %}
+ authoritative_region = "{{ nomad_authoritative_region }}"
+ {% endif %}
+
+{% if nomad_use_consul == False %}
+ {% if nomad_retry_join | bool -%}
+ retry_join = [
+ {%- set comma = joiner(",") -%}
+ {% for server in nomad_servers -%}
+ {{ comma() }}"{{ hostvars[server]['nomad_advertise_address'] | ipwrap }}"
+ {%- endfor -%} ]
+ retry_max = {{ nomad_retry_max }}
+ retry_interval = "{{ nomad_retry_interval }}"
+ {% else -%}
+ start_join = [
+ {%- set comma = joiner(",") -%}
+ {% for server in nomad_servers -%}
+ {{ comma() }}"{{ hostvars[server]['nomad_advertise_address'] | ipwrap }}"
+ {%- endfor -%} ]
+ {%- endif %}
+{% endif %}
+
+ encrypt = "{{ nomad_encrypt | default('') }}"
{% if nomad_node_gc_threshold -%}
node_gc_threshold = "{{ nomad_node_gc_threshold }}"
@@ -27,10 +49,4 @@ server {
deployment_gc_threshold = "{{ nomad_deployment_gc_threshold }}"
{%- endif %}
- {% if nomad_retry_join | bool -%}
- server_join {
- retry_join = [ {% for ip_port in nomad_retry_servers -%} "{{ ip_port }}" {% if not loop.last %},{% endif %}{%- endfor -%} ]
- }
- {%- endif %}
-
}
diff --git a/fdio.infra.ansible/roles/nomad/templates/telemetry.hcl.j2 b/fdio.infra.ansible/roles/nomad/templates/telemetry.hcl.j2
index 7b62f76976..4ad5330d1b 100644
--- a/fdio.infra.ansible/roles/nomad/templates/telemetry.hcl.j2
+++ b/fdio.infra.ansible/roles/nomad/templates/telemetry.hcl.j2
@@ -1,19 +1,10 @@
+{% if nomad_telemetry | bool == True %}
telemetry {
- # Telemetry provider parameters
- {% for key, value in nomad_telemetry_provider_parameters.items() -%}
- {% if value|bool -%}
- {{ key }} = {{ value | bool | lower }}
- {% elif value|string or value == "" -%}
- {{ key }} = "{{ value }}"
- {% else %}
- {{ key }} = {{ value }}
- {% endif -%}
- {% endfor -%}
-
- # Common parameters
- disable_hostname = {{ nomad_disable_hostname | bool | lower }}
- collection_interval = "{{ nomad_collection_interval }}"
- use_node_name = {{ nomad_use_node_name | bool | lower }}
- publish_allocation_metrics = {{ nomad_publish_allocation_metrics | bool | lower }}
- publish_node_metrics = {{ nomad_publish_node_metrics | bool | lower }}
+ disable_hostname = "{{ nomad_telemetry_disable_hostname | default(false) | bool | lower }}"
+ collection_interval = "{{ nomad_telemetry_collection_interval | default("1s") }}"
+ use_node_name = "{{ nomad_telemetry_use_node_name | default(false) | bool | lower }}"
+ publish_allocation_metrics = "{{ nomad_telemetry_publish_allocation_metrics | default(false) | bool | lower }}"
+ publish_node_metrics = "{{ nomad_telemetry_publish_node_metrics | default(false) | bool | lower }}"
+ prometheus_metrics = "{{ nomad_telemetry_prometheus_metrics | default(false) | bool | lower }}"
}
+{% endif %}
diff --git a/fdio.infra.ansible/roles/nomad/templates/tls.hcl.j2 b/fdio.infra.ansible/roles/nomad/templates/tls.hcl.j2
index 46dc1fe6b1..ceccdc8be5 100644
--- a/fdio.infra.ansible/roles/nomad/templates/tls.hcl.j2
+++ b/fdio.infra.ansible/roles/nomad/templates/tls.hcl.j2
@@ -1,14 +1,12 @@
-{% if ( nomad_ca_file ) and
- ( nomad_cert_file ) and
- ( nomad_key_file )
-%}
+{% if nomad_tls_enable | bool %}
tls {
http = {{ nomad_http | bool | lower }}
rpc = {{ nomad_rpc | bool | lower }}
- verify_server_hostname = {{ nomad_verify_server_hostname | bool | lower }}
- verify_https_client = {{ nomad_verify_https_client | bool | lower }}
ca_file = "{{ nomad_ca_file }}"
cert_file = "{{ nomad_cert_file }}"
key_file = "{{ nomad_key_file }}"
+ rpc_upgrade_mode = {{ nomad_rpc_upgrade_mode | bool | lower }}
+ verify_server_hostname = {{ nomad_verify_server_hostname | bool | lower }}
+ verify_https_client = {{ nomad_verify_https_client | bool | lower }}
}
{% endif %}