2 # file: roles/nomad/tasks/main.yaml
4 - Name: Update package cache (apt)
9 - ansible_distribution|lower == 'ubuntu'
11 - name: Inst - Prerequisites
13 name: "{{ packages | flatten(levels=1) }}"
16 - nomad-inst-prerequisites
18 - name: Conf - Add Nomad Group
20 name: "{{ nomad_group }}"
21 state: "{{ nomad_group_state }}"
23 - nomad_manage_group | bool
27 - name: Conf - Add Nomad user
29 name: "{{ nomad_user }}"
30 group: "{{ nomad_group }}"
31 groups: "{{ nomad_user_groups }}"
32 state: "{{ nomad_user_state }}"
35 - nomad_manage_user | bool
39 - name: Inst - Clean Nomad
41 path: "{{ nomad_inst_dir }}/nomad"
46 - name: Inst - Download Nomad
48 url: "{{ nomad_zip_url }}"
49 dest: "{{ nomad_inst_dir }}/{{ nomad_pkg }}"
53 - name: Inst - Unarchive Nomad
55 src: "{{ nomad_inst_dir }}/{{ nomad_pkg }}"
56 dest: "{{ nomad_inst_dir }}/"
57 creates: "{{ nomad_inst_dir }}/nomad"
64 src: "{{ nomad_inst_dir }}/nomad"
65 dest: "{{ nomad_bin_dir }}"
66 owner: "{{ nomad_user }}"
67 group: "{{ nomad_group }}"
74 - name: Conf - Create Directories "{{ nomad_data_dir }}"
76 dest: "{{ nomad_data_dir }}"
78 owner: "{{ nomad_user }}"
79 group: "{{ nomad_group }}"
83 - name: Conf - Create Directories "{{ nomad_ssl_dir }}"
85 dest: "{{ nomad_ssl_dir }}"
87 owner: "{{ nomad_user }}"
88 group: "{{ nomad_group }}"
92 - name: Conf - Create Config Directory
94 dest: "{{ nomad_config_dir }}"
96 owner: "{{ nomad_user }}"
97 group: "{{ nomad_group }}"
102 - name: Conf - Base Configuration
105 dest: "{{ nomad_config_dir }}/base.hcl"
106 owner: "{{ nomad_user }}"
107 group: "{{ nomad_group }}"
112 - name: Conf - Server Configuration
115 dest: "{{ nomad_config_dir }}/server.hcl"
116 owner: "{{ nomad_user }}"
117 group: "{{ nomad_group }}"
120 - nomad_node_server | bool
124 - name: Conf - Client Configuration
127 dest: "{{ nomad_config_dir }}/client.hcl"
128 owner: "{{ nomad_user }}"
129 group: "{{ nomad_group }}"
132 - nomad_node_client | bool
136 - name: Conf - TLS Configuration
139 dest: "{{ nomad_config_dir }}/tls.hcl"
140 owner: "{{ nomad_user }}"
141 group: "{{ nomad_group }}"
146 - name: Conf - Telemetry Configuration
148 src: telemetry.hcl.j2
149 dest: "{{ nomad_config_dir }}/telemetry.hcl"
150 owner: "{{ nomad_user }}"
151 group: "{{ nomad_group }}"
156 - name: Conf - Custom Configuration
159 dest: "{{ nomad_config_dir }}/custom.json"
160 owner: "{{ nomad_user }}"
161 group: "{{ nomad_group }}"
164 - nomad_config_custom is defined
168 - name: Conf - Copy Certificates And Keys
170 content: "{{ item.src }}"
171 dest: "{{ item.dest }}"
172 owner: "{{ nomad_user }}"
173 group: "{{ nomad_group }}"
176 loop: "{{ nomad_certificates | flatten(levels=1) }}"
180 - name: Conf - System.d Script
182 src: "nomad_systemd.service.j2"
183 dest: "/lib/systemd/system/nomad.service"