From f0969ea815420e30f88b26fb4c42150e9a9458aa Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Tue, 2 Aug 2022 11:00:18 +0200 Subject: [PATCH] Update to 2022-08-02 11:00 --- roles/nomad/defaults/main.yml | 25 +++++++++++++++++++++++++ roles/nomad/templates/nomad.hcl.j2 | 19 +++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/roles/nomad/defaults/main.yml b/roles/nomad/defaults/main.yml index 865c41e..3c6208f 100644 --- a/roles/nomad/defaults/main.yml +++ b/roles/nomad/defaults/main.yml @@ -38,6 +38,30 @@ nomad_base_conf: # read_only: False host_volumes: [] + # An arbitrary string which can be used for job placement + # node_class: prod + + # Resource reservation for the host to work properly + reserved: + # Unit is MHz + cpu: 200 + # can be expressed as number, in which case it'll be the amount of RAM to reserve in MB + # or as a percentage, in which case it'll be a percentage of the total RAM + memory: 15% + # When memory is expressed as a percentage, you can set a minimum amount (in MB) which will be set + # if the percentage is less than that + memory_min: 500 + # Unit is MB + disk: 500 + # List of reserved ports which won't be allocated on tasks + reserved_ports: [] + + # Custom metadata to add in Nomad's conf + # meta: + # rack: 12-1 + # cni: macvlan,ipvlan + meta: {} + # Server related settings server: # Should server be enabled @@ -59,6 +83,7 @@ nomad_base_conf: # Consul and vault optional URL. This is just to add a shortcut in Nomad's UI # consul_ui: https://consul.example.org # vault_ui: https://vault.example.org + # You can override part of the default config without rewriting everything else # the dict will get merged nomad_extra_conf: {} diff --git a/roles/nomad/templates/nomad.hcl.j2 b/roles/nomad/templates/nomad.hcl.j2 index 15fc42a..c88cd28 100644 --- a/roles/nomad/templates/nomad.hcl.j2 +++ b/roles/nomad/templates/nomad.hcl.j2 @@ -56,6 +56,24 @@ client { {% endif %} } {% endfor %} + + reserved { + cpu = {{ nomad_conf.client.reserved.cpu }} + memory = {{ (nomad_conf.client.reserved.memory is search('%$')) | ternary([((nomad_conf.client.reserved.memory | regex_replace('%$', '') | int) * ansible_memtotal_mb * 0.01), nomad_conf.client.reserved.memory_min] | max | int, nomad_conf.client.reserved.memory) }} + disk = {{ nomad_conf.client.reserved.disk }} + reserved_ports = "{{ nomad_conf.client.reserved.reserved_ports | join(',') }}" + } + + meta { +{% for meta in nomad_conf.client.meta.keys() | list %} + {{ meta }} = "{{ nomad_conf.client.meta[meta] }}" +{% endfor %} + } + +{% if nomad_conf.client.node_class is defined %} + node_class = "{{ nomad_conf.client.node_class }}" +{% endif %} + } ui { @@ -71,3 +89,4 @@ ui { } {% endif %} } +