diff --git a/roles/nomad/defaults/main.yml b/roles/nomad/defaults/main.yml index 7ebc833..e8eeadd 100644 --- a/roles/nomad/defaults/main.yml +++ b/roles/nomad/defaults/main.yml @@ -1,11 +1,11 @@ --- # Version of Nomad to install -nomad_version: 1.3.2 +nomad_version: 1.3.3 # URL of the archive nomad_archive_url: https://releases.hashicorp.com/nomad/{{ nomad_version }}/nomad_{{ nomad_version }}_linux_amd64.zip # Expected sha256 of the archive -nomad_archive_sha256: fc6b3800935c621633d98148ea30737ab8ac1f698020f45b28b07ac61fbf4a96 +nomad_archive_sha256: d908811cebe2a8373e93c4ad3d09af5c706241878ff3f21ee0f182b4ecb571f2 # List of plugins to install nomad_plugins: @@ -21,6 +21,10 @@ nomad_root_dir: /opt/nomad # Servers can run under an unprivileged user, while clients should run as root (or with equivalent privileges) nomad_user: "{{ nomad_conf.client.enabled | ternary('root', 'nomad') }}" +# If ACL are enabled, you need to set a management token for ansible +# to be able to manage Nomad (eg snapshot before upgrades) +# nomad_mgm_token: XXXXXXXXX + # List of nomad servers (not clients !) nomad_servers: [] @@ -126,6 +130,13 @@ nomad_base_conf: # consul_ui: https://consul.example.org # vault_ui: https://vault.example.org + # Telemetry settings + telemetry: + prometheus_metrics: False + disable_hostname: True + publish_allocation_metrics: True + publish_node_metrics: True + # 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/tasks/archive_pre.yml b/roles/nomad/tasks/archive_pre.yml index 27c9dfb..d68573f 100644 --- a/roles/nomad/tasks/archive_pre.yml +++ b/roles/nomad/tasks/archive_pre.yml @@ -5,12 +5,16 @@ tags: nomad - name: Snapshot nomad data - command: "{{ nomad_root_dir }}/bin/nomad operator save {{ nomad_root_dir }}/archives/{{ nomad_current_version }}/nomad.snap" + command: "{{ nomad_root_dir }}/bin/nomad operator snapshot save {{ nomad_root_dir }}/archives/{{ nomad_current_version }}/nomad.snap" + args: + creates: "{{ nomad_root_dir }}/archives/{{ nomad_current_version }}/nomad.snap" + environment: + NOMAD_TOKEN: "{{ nomad_mgm_token | default(omit) }}" tags: nomad - name: Backup previous version synchronize: - src: "{{ item }}" + src: "{{ nomad_root_dir }}/{{ item }}" dest: "{{ nomad_root_dir }}/archives/{{ nomad_current_version }}/" compress: False delegate_to: "{{ inventory_hostname }}" diff --git a/roles/nomad/tasks/facts.yml b/roles/nomad/tasks/facts.yml index 8977d67..a1b84fc 100644 --- a/roles/nomad/tasks/facts.yml +++ b/roles/nomad/tasks/facts.yml @@ -32,6 +32,7 @@ - when: nomad_bin.stat.exists and nomad_current_version != nomad_version set_fact: nomad_install_mode='upgrade' + tags: nomad - name: Build a list of enabled task drivers set_fact: nomad_enabled_task_drivers={{ nomad_conf.client.task_drivers | dict2items | selectattr('value.enabled', 'equalto', True) | map(attribute='key') }} diff --git a/roles/nomad/templates/nomad.hcl.j2 b/roles/nomad/templates/nomad.hcl.j2 index 8b3f94e..9395e28 100644 --- a/roles/nomad/templates/nomad.hcl.j2 +++ b/roles/nomad/templates/nomad.hcl.j2 @@ -138,3 +138,9 @@ ui { {% endif %} } +telemetry { + prometheus_metrics = {{ nomad_conf.telemetry.prometheus_metrics | ternary('true', 'false') }} + disable_hostname = {{ nomad_conf.telemetry.disable_hostname | ternary('true', 'false') }} + publish_allocation_metrics = {{ nomad_conf.telemetry.publish_allocation_metrics | ternary('true', 'false') }} + publish_node_metrics = {{ nomad_conf.telemetry.publish_node_metrics | ternary('true', 'false') }} +}