Ansible: Nomad 0.12.0 upgrade
[csit.git] / resources / tools / testbed-setup / ansible / roles / nomad / tasks / main.yaml
1 ---
2 # file: roles/nomad/tasks/main.yaml
3
4 - name: Inst - Prerequisites
5   package:
6     name: "{{ packages | flatten(levels=1) }}"
7     state: latest
8     update_cache: true
9   tags:
10     - nomad-inst-prerequisites
11
12 - name: Conf - Add Nomad Group
13   group:
14     name: "{{ nomad_group }}"
15     state: "{{ nomad_group_state }}"
16   when:
17     - nomad_manage_group | bool
18   tags:
19     - nomad-conf-user
20
21 - name: Conf - Add Nomad user
22   user:
23     name: "{{ nomad_user }}"
24     group: "{{ nomad_group }}"
25     groups: "{{ nomad_user_groups }}"
26     state: "{{ nomad_user_state }}"
27     system: true
28   when:
29     - nomad_manage_user | bool
30   tags:
31     - nomad-conf-user
32
33 - name: Inst - Clean Nomad
34   file:
35     path: "{{ nomad_inst_dir }}/nomad"
36     state: "absent"
37   tags:
38     - nomad-inst-package
39
40 - name: Inst - Download Nomad
41   get_url:
42     url: "{{ nomad_zip_url }}"
43     dest: "{{ nomad_inst_dir }}/{{ nomad_pkg }}"
44   tags:
45     - nomad-inst-package
46
47 - name: Inst - Unarchive Nomad
48   unarchive:
49     src: "{{ nomad_inst_dir }}/{{ nomad_pkg }}"
50     dest: "{{ nomad_inst_dir }}/"
51     creates: "{{ nomad_inst_dir }}/nomad"
52     remote_src: true
53   tags:
54     - nomad-inst-package
55
56 - name: Inst - Nomad
57   copy:
58     src: "{{ nomad_inst_dir }}/nomad"
59     dest: "{{ nomad_bin_dir }}"
60     owner: "{{ nomad_user }}"
61     group: "{{ nomad_group }}"
62     force: true
63     mode: 0755
64     remote_src: true
65   tags:
66     - nomad-inst-package
67
68 - name: Conf - Create Directories "{{ nomad_data_dir }}"
69   file:
70     dest: "{{ nomad_data_dir }}"
71     state: directory
72     owner: "{{ nomad_user }}"
73     group: "{{ nomad_group }}"
74   tags:
75     - nomad-conf
76
77 - name: Conf - Create Directories "{{ nomad_ssl_dir }}"
78   file:
79     dest: "{{ nomad_ssl_dir }}"
80     state: directory
81     owner: "{{ nomad_user }}"
82     group: "{{ nomad_group }}"
83   tags:
84     - nomad-conf
85
86 - name: Conf - Create Config Directory
87   file:
88     dest: "{{ nomad_config_dir }}"
89     state: directory
90     owner: "{{ nomad_user }}"
91     group: "{{ nomad_group }}"
92     mode: 0755
93   tags:
94     - nomad-conf
95
96 - name: Conf - Base Configuration
97   template:
98     src: base.hcl.j2
99     dest: "{{ nomad_config_dir }}/base.hcl"
100     owner: "{{ nomad_user }}"
101     group: "{{ nomad_group }}"
102     mode: 0644
103   tags:
104     - nomad-conf
105
106 - name: Conf - Server Configuration
107   template:
108     src: server.hcl.j2
109     dest: "{{ nomad_config_dir }}/server.hcl"
110     owner: "{{ nomad_user }}"
111     group: "{{ nomad_group }}"
112     mode: 0644
113   when:
114     - nomad_node_server | bool
115   tags:
116     - nomad-conf
117
118 - name: Conf - Client Configuration
119   template:
120     src: client.hcl.j2
121     dest: "{{ nomad_config_dir }}/client.hcl"
122     owner: "{{ nomad_user }}"
123     group: "{{ nomad_group }}"
124     mode: 0644
125   when:
126     - nomad_node_client | bool
127   tags:
128     - nomad-conf
129
130 - name: Conf - TLS Configuration
131   template:
132     src: tls.hcl.j2
133     dest: "{{ nomad_config_dir }}/tls.hcl"
134     owner: "{{ nomad_user }}"
135     group: "{{ nomad_group }}"
136     mode: 0644
137   tags:
138     - nomad-conf
139
140 - name: Conf - Telemetry Configuration
141   template:
142     src: telemetry.hcl.j2
143     dest: "{{ nomad_config_dir }}/telemetry.hcl"
144     owner: "{{ nomad_user }}"
145     group: "{{ nomad_group }}"
146     mode: 0644
147   tags:
148     - nomad-conf
149
150 - name: Conf - Custom Configuration
151   template:
152     src: custom.json.j2
153     dest: "{{ nomad_config_dir }}/custom.json"
154     owner: "{{ nomad_user }}"
155     group: "{{ nomad_group }}"
156     mode: 0644
157   when:
158     - nomad_config_custom is defined
159   tags:
160     - nomad-conf
161
162 - name: Conf - Copy Certificates And Keys
163   copy:
164     content: "{{ item.src }}"
165     dest: "{{ item.dest }}"
166     owner: "{{ nomad_user }}"
167     group: "{{ nomad_group }}"
168     mode: 0600
169   no_log: true
170   loop: "{{ nomad_certificates | flatten(levels=1) }}"
171   tags:
172     - nomad-conf
173
174 - name: Conf - System.d Script
175   template:
176     src: "nomad_systemd.service.j2"
177     dest: "/lib/systemd/system/nomad.service"
178     owner: "root"
179     group: "root"
180     mode: 0644
181 #  notify:
182 #    - "Restart Nomad"
183   tags:
184     - nomad-conf