adds role to configure and start nomad

This commit is contained in:
James Hackett 2022-12-08 01:02:59 +00:00
parent b37ad31110
commit 4db8b8e050
2 changed files with 96 additions and 0 deletions

View file

@ -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

View file

@ -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 }}'