2 # file: tasks/main.yaml
4 - name: Update Repositories Cache
8 - ansible_os_family == 'Debian'
14 name: "{{ packages | flatten(levels=1) }}"
16 cache_valid_time: 3600
17 install_recommends: false
19 - ansible_os_family == 'Debian'
21 - nomad-inst-dependencies
23 - name: Add Nomad Group
24 ansible.builtin.group:
25 name: "{{ nomad_group }}"
30 - name: Add Nomad user
32 name: "{{ nomad_user }}"
33 group: "{{ nomad_group }}"
39 - name: Download Nomad
40 ansible.builtin.get_url:
41 url: "{{ nomad_zip_url }}"
42 dest: "{{ nomad_inst_dir }}/{{ nomad_pkg }}"
49 path: "{{ nomad_inst_dir }}/nomad"
52 - nomad_force_update | bool
56 - name: Unarchive Nomad
57 ansible.builtin.unarchive:
58 src: "{{ nomad_inst_dir }}/{{ nomad_pkg }}"
59 dest: "{{ nomad_inst_dir }}/"
66 src: "{{ nomad_inst_dir }}/nomad"
67 dest: "{{ nomad_bin_dir }}"
68 owner: "{{ nomad_user }}"
69 group: "{{ nomad_group }}"
76 - name: Create Directories
80 owner: "{{ nomad_user }}"
81 group: "{{ nomad_group }}"
84 - "{{ nomad_data_dir }}"
85 - "{{ nomad_config_dir }}"
86 - "{{ nomad_ssl_dir }}"
90 - name: Base Configuration
91 ansible.builtin.template:
92 src: "{{ item }}.hcl.j2"
93 dest: "{{ nomad_config_dir }}/{{ item }}.hcl"
94 owner: "{{ nomad_user }}"
95 group: "{{ nomad_group }}"
108 - name: Conf - Copy Certificates And Keys
109 ansible.builtin.copy:
110 content: "{{ item.src }}"
111 dest: "{{ item.dest }}"
112 owner: "{{ nomad_user }}"
113 group: "{{ nomad_group }}"
116 loop: "{{ nomad_certificates | flatten(levels=1) }}"
118 - nomad_certificates is defined
122 - name: Nomad CLI Environment Variables
123 ansible.builtin.lineinfile:
124 path: "/etc/profile.d/nomad.sh"
129 - "export NOMAD_ADDR=https://nomad-server.service.consul:4646"
130 - "export NOMAD_CACERT={{ nomad_tls_ca_file }}"
131 - "export NOMAD_CLIENT_CERT={{ nomad_tls_cli_cert_file }}"
132 - "export NOMAD_CLIENT_KEY={{ nomad_tls_cli_key_file }}"
136 - name: System.d Script
137 ansible.builtin.template:
138 src: "nomad_systemd.service.j2"
139 dest: "/lib/systemd/system/nomad.service"
146 - nomad_service_mgr == "systemd"
150 - name: Meta - Flush handlers
151 ansible.builtin.meta: flush_handlers