Infra: Ansible speed up
[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 - Download Nomad
34   get_url:
35     url: "{{ nomad_zip_url }}"
36     dest: "{{ nomad_inst_dir }}/{{ nomad_pkg }}"
37   tags:
38     - nomad-inst-package
39
40 - name: Inst - Unarchive Nomad
41   unarchive:
42     src: "{{ nomad_inst_dir }}/{{ nomad_pkg }}"
43     dest: "{{ nomad_inst_dir }}/"
44     creates: "{{ nomad_inst_dir }}/nomad"
45     remote_src: true
46   tags:
47     - nomad-inst-package
48
49 - name: Inst - Nomad
50   copy:
51     src: "{{ nomad_inst_dir }}/nomad"
52     dest: "{{ nomad_bin_dir }}"
53     owner: "{{ nomad_user }}"
54     group: "{{ nomad_group }}"
55     force: true
56     mode: 0755
57     remote_src: true
58   tags:
59     - nomad-inst-package
60
61 - name: Conf - Create Directories "{{ nomad_data_dir }}"
62   file:
63     dest: "{{ nomad_data_dir }}"
64     state: directory
65     owner: "{{ nomad_user }}"
66     group: "{{ nomad_group }}"
67   tags:
68     - nomad-conf
69
70 - name: Conf - Create Directories "{{ nomad_ssl_dir }}"
71   file:
72     dest: "{{ nomad_ssl_dir }}"
73     state: directory
74     owner: "{{ nomad_user }}"
75     group: "{{ nomad_group }}"
76   tags:
77     - nomad-conf
78
79 - name: Conf - Create Config Directory
80   file:
81     dest: "{{ nomad_config_dir }}"
82     state: directory
83     owner: "{{ nomad_user }}"
84     group: "{{ nomad_group }}"
85     mode: 0755
86   tags:
87     - nomad-conf
88
89 - name: Conf - Base Configuration
90   template:
91     src: base.hcl.j2
92     dest: "{{ nomad_config_dir }}/base.hcl"
93     owner: "{{ nomad_user }}"
94     group: "{{ nomad_group }}"
95     mode: 0644
96   tags:
97     - nomad-conf
98
99 - name: Conf - Server Configuration
100   template:
101     src: server.hcl.j2
102     dest: "{{ nomad_config_dir }}/server.hcl"
103     owner: "{{ nomad_user }}"
104     group: "{{ nomad_group }}"
105     mode: 0644
106   when:
107     - nomad_node_server | bool
108   tags:
109     - nomad-conf
110
111 - name: Conf - Client Configuration
112   template:
113     src: client.hcl.j2
114     dest: "{{ nomad_config_dir }}/client.hcl"
115     owner: "{{ nomad_user }}"
116     group: "{{ nomad_group }}"
117     mode: 0644
118   when:
119     - nomad_node_client | bool
120   tags:
121     - nomad-conf
122
123 - name: Conf - TLS Configuration
124   template:
125     src: tls.hcl.j2
126     dest: "{{ nomad_config_dir }}/tls.hcl"
127     owner: "{{ nomad_user }}"
128     group: "{{ nomad_group }}"
129     mode: 0644
130   tags:
131     - nomad-conf
132
133 - name: Conf - Telemetry Configuration
134   template:
135     src: telemetry.hcl.j2
136     dest: "{{ nomad_config_dir }}/telemetry.hcl"
137     owner: "{{ nomad_user }}"
138     group: "{{ nomad_group }}"
139     mode: 0644
140   tags:
141     - nomad-conf
142
143 - name: Conf - Custom Configuration
144   template:
145     src: custom.json.j2
146     dest: "{{ nomad_config_dir }}/custom.json"
147     owner: "{{ nomad_user }}"
148     group: "{{ nomad_group }}"
149     mode: 0644
150   when:
151     - nomad_config_custom is defined
152   tags:
153     - nomad-conf
154
155 - name: Conf - Copy Certificates And Keys
156   copy:
157     content: "{{ item.src }}"
158     dest: "{{ item.dest }}"
159     owner: "{{ nomad_user }}"
160     group: "{{ nomad_group }}"
161     mode: 0600
162   no_log: true
163   loop: "{{ nomad_certificates | flatten(levels=1) }}"
164   tags:
165     - nomad-conf
166
167 - name: Conf - System.d Script
168   template:
169     src: "nomad_systemd.service.j2"
170     dest: "/lib/systemd/system/nomad.service"
171     owner: "root"
172     group: "root"
173     mode: 0644
174 #  notify:
175 #    - "Restart Nomad"
176   tags:
177     - nomad-conf