diff --git a/ansible/roles/configure-nomad/tasks/configure.yml b/ansible/roles/configure-nomad/tasks/configure.yml new file mode 100644 index 0000000..947765c --- /dev/null +++ b/ansible/roles/configure-nomad/tasks/configure.yml @@ -0,0 +1,37 @@ +--- + +- name: Copy nomad base configuration + become: true + template: + src: nomad-base.hcl.j2 + dest: /etc/nomad.d/nomad.hcl + owner: nomad + group: nomad + mode: 0640 + +- name: Copy nomad-client configuration + become: true + template: + src: nomad-client.hcl + dest: /etc/nomad.d/nomad-client.hcl + owner: nomad + group: nomad + mode: 0640 + +- name: Copy nomad-server configuration + become: true + template: + src: nomad-server.hcl.j2 + dest: /etc/nomad.d/nomad-server.hcl + owner: nomad + group: nomad + mode: 0640 + +- name: Copy nomad systemd unit file + become: true + template: + src: nomad.service + dest: /etc/systemd/system/nomad.service + owner: root + group: root + mode: 0644 diff --git a/ansible/roles/configure-nomad/tasks/main.yml b/ansible/roles/configure-nomad/tasks/main.yml new file mode 100644 index 0000000..79e6980 --- /dev/null +++ b/ansible/roles/configure-nomad/tasks/main.yml @@ -0,0 +1,59 @@ +--- +- name: Install or update nomad + become: true + apt: + name: nomad + state: latest + update_cache: yes + +- name: Add nomad user + become: true + user: + name: nomad + shell: /bin/false + system: yes + +- name: Create nomad group + become: true + group: + name: nomad + system: yes + +- name: Create nomad directories + become: true + file: + path: '{{ item }}' + state: directory + owner: nomad + group: nomad + mode: 0750 + with_items: + - /etc/nomad.d + - /opt/nomad + +- include_tasks: configure.yml + +- name: Enable and start nomad + become: true + systemd: + name: nomad + enabled: yes + state: started + +- name: Check nomad status + become: true + shell: nomad status + register: nomad_status + +- name: Print nomad status + debug: + msg: '{{ nomad_status.stdout }}' + +- name: Check nomad members + become: true + shell: nomad members + register: nomad_members + +- name: Print nomad members + debug: + msg: '{{ nomad_members.stdout }}'