---
# file: roles/nomad/tasks/main.yaml
-- name: Inst - Update Package Cache (APT)
+- name: Install Dependencies
apt:
- update_cache: yes
+ name: "{{ packages | flatten(levels=1) }}"
+ state: "present"
cache_valid_time: 3600
+ install_recommends: false
when:
- ansible_distribution|lower == 'ubuntu'
tags:
- - nomad-inst-prerequisites
-
-- name: Inst - Prerequisites
- package:
- name: "{{ packages | flatten(levels=1) }}"
- state: latest
- tags:
- - nomad-inst-prerequisites
+ - nomad-inst-dependencies
- name: Conf - Add Nomad Group
group:
name: "{{ nomad_group }}"
- state: "{{ nomad_group_state }}"
- when:
- - nomad_manage_group | bool
+ state: "{{ nomad_user_state }}"
tags:
- nomad-conf-user
user:
name: "{{ nomad_user }}"
group: "{{ nomad_group }}"
- groups: "{{ nomad_user_groups }}"
- state: "{{ nomad_user_state }}"
+ state: "{{ nomad_group_state }}"
system: true
- when:
- - nomad_manage_user | bool
tags:
- nomad-conf-user
-- name: Inst - Clean Nomad
- file:
- path: "{{ nomad_inst_dir }}/nomad"
- state: "absent"
- tags:
- - nomad-inst-package
-
- name: Inst - Download Nomad
get_url:
url: "{{ nomad_zip_url }}"
tags:
- nomad-inst-package
+- name: Inst - Clean Nomad
+ file:
+ path: "{{ nomad_inst_dir }}/nomad"
+ state: "absent"
+ when:
+ - nomad_force_update | bool
+ tags:
+ - nomad-inst-package
+
- name: Inst - Unarchive Nomad
unarchive:
src: "{{ nomad_inst_dir }}/{{ nomad_pkg }}"
dest: "{{ nomad_inst_dir }}/"
- creates: "{{ nomad_inst_dir }}/nomad"
remote_src: true
tags:
- nomad-inst-package
tags:
- nomad-conf
-- name: Conf - Custom Configuration
+- name: Conf - Consul Configuration
template:
- src: custom.json.j2
- dest: "{{ nomad_config_dir }}/custom.json"
+ src: consul.hcl.j2
+ dest: "{{ nomad_config_dir }}/consul.hcl"
owner: "{{ nomad_user }}"
group: "{{ nomad_group }}"
mode: 0644
- when:
- - nomad_config_custom is defined
tags:
- nomad-conf
mode: 0600
no_log: true
loop: "{{ nomad_certificates | flatten(levels=1) }}"
+ when:
+ - nomad_certificates
tags:
- nomad-conf
owner: "root"
group: "root"
mode: 0644
-# notify:
-# - "Restart Nomad"
+ notify:
+ - "Restart Nomad"
+ when:
+ - nomad_service_mgr == "systemd"
tags:
- nomad-conf
+
+- meta: flush_handlers