ansible-nomad/tasks/main.yml

50 lines
1.1 KiB
YAML
Raw Normal View History

2022-03-13 15:03:33 +00:00
---
- name: Include OS-specific variables
include_vars: "{{ item }}"
with_first_found:
- files:
- "{{ ansible_os_family }}-{{ ansible_distribution_major_version }}.yml"
- "{{ ansible_os_family }}.yml"
2022-10-08 07:28:44 +00:00
- name: Add hashicorp repo
2022-06-06 16:21:42 +00:00
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"
2022-10-08 07:28:44 +00:00
- name: Install package
2022-03-13 15:03:33 +00:00
package:
name: "{{ nomad_os_package }}"
state: present
2022-10-08 07:28:44 +00:00
- name: Create folder
2022-03-13 15:03:33 +00:00
file:
state: directory
mode: 0755
2022-10-08 07:28:44 +00:00
path: "{{ nomad_data_dir }}"
2022-03-13 15:03:33 +00:00
2022-10-08 07:28:44 +00:00
- name: Apply config template
notify: restart nomad
2022-03-13 15:03:33 +00:00
block:
2022-10-08 07:28:44 +00:00
- name: Server template
2022-03-13 15:03:33 +00:00
template:
src: config.hcl.j2
2022-09-18 12:52:07 +00:00
dest: /etc/nomad.d/defaults.hcl
2022-03-13 15:03:33 +00:00
mode: 0400
2022-10-08 07:28:44 +00:00
- name: Empty nomad.hcl
template:
src: empty.j2
dest: /etc/nomad.d/nomad.hcl
mode: 0400
when: ansible_os_family == "RedHat"
2022-03-13 15:03:33 +00:00
2022-10-08 07:28:44 +00:00
- name: Ensure service is started
2022-03-13 15:03:33 +00:00
systemd:
name: "{{ nomad_os_service }}"
state: started
2022-10-08 07:28:44 +00:00
enabled: true