aboutsummaryrefslogtreecommitdiffstats
path: root/resources/tools/testbed-setup/ansible/roles/nomad/tasks/main.yaml
diff options
context:
space:
mode:
authorpmikus <pmikus@cisco.com>2020-05-20 10:07:36 +0000
committerPeter Mikus <pmikus@cisco.com>2020-05-21 15:10:26 +0000
commitc180acb883d659136a96fa989c85d9b045eea467 (patch)
treeba661a41d51f69b25d8b3250f50a85c3941948c0 /resources/tools/testbed-setup/ansible/roles/nomad/tasks/main.yaml
parenta6ed764aecf2983a759931cc8d4bef161045d062 (diff)
Infra: Ansible Nomad
Signed-off-by: pmikus <pmikus@cisco.com> Change-Id: Icc03bf62d8639f603ca90aa6ab849a46dc911d56
Diffstat (limited to 'resources/tools/testbed-setup/ansible/roles/nomad/tasks/main.yaml')
-rw-r--r--resources/tools/testbed-setup/ansible/roles/nomad/tasks/main.yaml164
1 files changed, 164 insertions, 0 deletions
diff --git a/resources/tools/testbed-setup/ansible/roles/nomad/tasks/main.yaml b/resources/tools/testbed-setup/ansible/roles/nomad/tasks/main.yaml
new file mode 100644
index 0000000000..9093afd08e
--- /dev/null
+++ b/resources/tools/testbed-setup/ansible/roles/nomad/tasks/main.yaml
@@ -0,0 +1,164 @@
+---
+# file: roles/nomad/tasks/main.yaml
+
+- name: Inst - Prerequisites
+ package:
+ name: "{{ packages | flatten(levels=1) }}"
+ state: latest
+ update_cache: true
+ tags:
+ - nomad-inst-prerequisites
+
+- name: Conf - Add Nomad Group
+ group:
+ name: "{{ nomad_group }}"
+ state: "{{ nomad_group_state }}"
+ when:
+ - nomad_manage_group | bool
+ tags:
+ - nomad-conf-user
+
+- name: Conf - Add Nomad user
+ user:
+ name: "{{ nomad_user }}"
+ group: "{{ nomad_group }}"
+ groups: "{{ nomad_user_groups }}"
+ state: "{{ nomad_user_state }}"
+ system: true
+ when:
+ - nomad_manage_user | bool
+ tags:
+ - nomad-conf-user
+
+- name: Inst - Download Nomad
+ get_url:
+ url: "{{ nomad_zip_url }}"
+ dest: "{{ nomad_inst_dir }}/{{ nomad_pkg }}"
+ 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
+
+- name: Inst - Nomad
+ copy:
+ src: "{{ nomad_inst_dir }}/nomad"
+ dest: "{{ nomad_bin_dir }}"
+ owner: "{{ nomad_user }}"
+ group: "{{ nomad_group }}"
+ force: true
+ mode: 0755
+ remote_src: true
+ tags:
+ - nomad-inst-package
+
+- name: Inst - Cleanup
+ file:
+ path: "{{ nomad_inst_dir }}/nomad"
+ state: "absent"
+ tags:
+ - nomad-inst-package
+
+- name: Conf - Create Directories "{{ nomad_data_dir }}"
+ file:
+ dest: "{{ nomad_data_dir }}"
+ state: directory
+ owner: "{{ nomad_user }}"
+ group: "{{ nomad_group }}"
+ tags:
+ - nomad-conf
+
+- name: Conf - Create Directories "{{ nomad_ssl_dir }}"
+ file:
+ dest: "{{ nomad_ssl_dir }}"
+ state: directory
+ owner: "{{ nomad_user }}"
+ group: "{{ nomad_group }}"
+ tags:
+ - nomad-conf
+
+- name: Conf - Create Config Directory
+ file:
+ dest: "{{ nomad_config_dir }}"
+ state: directory
+ owner: "{{ nomad_user }}"
+ group: "{{ nomad_group }}"
+ mode: 0755
+ tags:
+ - nomad-conf
+
+- name: Conf - Base Configuration
+ template:
+ src: base.hcl.j2
+ dest: "{{ nomad_config_dir }}/base.hcl"
+ owner: "{{ nomad_user }}"
+ group: "{{ nomad_group }}"
+ mode: 0644
+ tags:
+ - nomad-conf
+
+- name: Conf - Server Configuration
+ template:
+ src: server.hcl.j2
+ dest: "{{ nomad_config_dir }}/server.hcl"
+ owner: "{{ nomad_user }}"
+ group: "{{ nomad_group }}"
+ mode: 0644
+ when:
+ - nomad_node_server | bool
+ tags:
+ - nomad-conf
+
+- name: Conf - Client Configuration
+ template:
+ src: client.hcl.j2
+ dest: "{{ nomad_config_dir }}/client.hcl"
+ owner: "{{ nomad_user }}"
+ group: "{{ nomad_group }}"
+ mode: 0644
+ when:
+ - nomad_node_client | bool
+ tags:
+ - nomad-conf
+
+- name: Conf - Custom Configuration
+ template:
+ src: custom.json.j2
+ dest: "{{ nomad_config_dir }}/custom.json"
+ owner: "{{ nomad_user }}"
+ group: "{{ nomad_group }}"
+ mode: 0644
+ when:
+ - nomad_config_custom is defined
+ tags:
+ - nomad-conf
+
+- name: Conf - Copy Certificates And Keys
+ copy:
+ content: "{{ item.src }}"
+ dest: "{{ item.dest }}"
+ owner: "{{ nomad_user }}"
+ group: "{{ nomad_group }}"
+ mode: 0600
+ no_log: true
+ loop: "{{ nomad_certificates | flatten(levels=1) }}"
+ tags:
+ - nomad-conf
+
+- name: Conf - System.d Script
+ template:
+ src: "nomad_systemd.service.j2"
+ dest: "/lib/systemd/system/nomad.service"
+ owner: "root"
+ group: "root"
+ mode: 0644
+ notify:
+ - "Restart Nomad"
+ tags:
+ - nomad-conf