2 # file: roles/nomad/tasks/main.yaml
4 - name: Install Dependencies
6 name: "{{ packages | flatten(levels=1) }}"
9 install_recommends: false
11 - ansible_distribution|lower == 'ubuntu'
13 - nomad-inst-dependencies
15 - name: Conf - Add Nomad Group
17 name: "{{ nomad_group }}"
18 state: "{{ nomad_user_state }}"
22 - name: Conf - Add Nomad user
24 name: "{{ nomad_user }}"
25 group: "{{ nomad_group }}"
26 state: "{{ nomad_group_state }}"
31 - name: Inst - Download Nomad
33 url: "{{ nomad_zip_url }}"
34 dest: "{{ nomad_inst_dir }}/{{ nomad_pkg }}"
38 - name: Inst - Clean Nomad
40 path: "{{ nomad_inst_dir }}/nomad"
43 - nomad_force_update | bool
47 - name: Inst - Unarchive Nomad
49 src: "{{ nomad_inst_dir }}/{{ nomad_pkg }}"
50 dest: "{{ nomad_inst_dir }}/"
57 src: "{{ nomad_inst_dir }}/nomad"
58 dest: "{{ nomad_bin_dir }}"
59 owner: "{{ nomad_user }}"
60 group: "{{ nomad_group }}"
67 - name: Conf - Create Directories "{{ nomad_data_dir }}"
69 dest: "{{ nomad_data_dir }}"
71 owner: "{{ nomad_user }}"
72 group: "{{ nomad_group }}"
76 - name: Conf - Create Directories "{{ nomad_ssl_dir }}"
78 dest: "{{ nomad_ssl_dir }}"
80 owner: "{{ nomad_user }}"
81 group: "{{ nomad_group }}"
85 - name: Conf - Create Config Directory
87 dest: "{{ nomad_config_dir }}"
89 owner: "{{ nomad_user }}"
90 group: "{{ nomad_group }}"
95 - name: Conf - Base Configuration
98 dest: "{{ nomad_config_dir }}/base.hcl"
99 owner: "{{ nomad_user }}"
100 group: "{{ nomad_group }}"
105 - name: Conf - Server Configuration
108 dest: "{{ nomad_config_dir }}/server.hcl"
109 owner: "{{ nomad_user }}"
110 group: "{{ nomad_group }}"
113 - nomad_node_server | bool
117 - name: Conf - Client Configuration
120 dest: "{{ nomad_config_dir }}/client.hcl"
121 owner: "{{ nomad_user }}"
122 group: "{{ nomad_group }}"
125 - nomad_node_client | bool
129 - name: Conf - TLS Configuration
132 dest: "{{ nomad_config_dir }}/tls.hcl"
133 owner: "{{ nomad_user }}"
134 group: "{{ nomad_group }}"
139 - name: Conf - Telemetry Configuration
141 src: telemetry.hcl.j2
142 dest: "{{ nomad_config_dir }}/telemetry.hcl"
143 owner: "{{ nomad_user }}"
144 group: "{{ nomad_group }}"
149 - name: Conf - Consul Configuration
152 dest: "{{ nomad_config_dir }}/consul.hcl"
153 owner: "{{ nomad_user }}"
154 group: "{{ nomad_group }}"
159 - name: Conf - Copy Certificates And Keys
161 content: "{{ item.src }}"
162 dest: "{{ item.dest }}"
163 owner: "{{ nomad_user }}"
164 group: "{{ nomad_group }}"
167 loop: "{{ nomad_certificates | flatten(levels=1) }}"
173 - name: Conf - System.d Script
175 src: "nomad_systemd.service.j2"
176 dest: "/lib/systemd/system/nomad.service"
183 - nomad_service_mgr == "systemd"
187 - meta: flush_handlers