ansible-nomad/tasks/main.yml
2022-10-08 09:28:44 +02:00

50 lines
1.1 KiB
YAML

---
- name: Include OS-specific variables
include_vars: "{{ item }}"
with_first_found:
- files:
- "{{ ansible_os_family }}-{{ ansible_distribution_major_version }}.yml"
- "{{ ansible_os_family }}.yml"
- name: Add hashicorp repo
get_url:
url: "https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo"
dest: '/etc/yum.repos.d/hashicorp.repo'
owner: root
group: root
mode: 0644
when: ansible_os_family == "RedHat"
- name: Install package
package:
name: "{{ nomad_os_package }}"
state: present
- name: Create folder
file:
state: directory
mode: 0755
path: "{{ nomad_data_dir }}"
- name: Apply config template
notify: restart nomad
block:
- name: Server template
template:
src: config.hcl.j2
dest: /etc/nomad.d/defaults.hcl
mode: 0400
- name: Empty nomad.hcl
template:
src: empty.j2
dest: /etc/nomad.d/nomad.hcl
mode: 0400
when: ansible_os_family == "RedHat"
- name: Ensure service is started
systemd:
name: "{{ nomad_os_service }}"
state: started
enabled: true