mirror of
https://github.com/natelandau/ansible-homelab-config.git
synced 2025-11-17 09:23:40 -05:00
fix: revert to nomad v1.4.6
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
authelia_version: 4.37.5
|
authelia_version: 4.37.5
|
||||||
consul_version: 1.15.1
|
consul_version: 1.15.1
|
||||||
influxdb_version: 1.8.10
|
influxdb_version: 1.8.10
|
||||||
nomad_version: 1.5.0
|
nomad_version: 1.4.6
|
||||||
prometheus_verssion: 2.42.0
|
prometheus_verssion: 2.42.0
|
||||||
speedtest_cli_version: 1.2.0
|
speedtest_cli_version: 1.2.0
|
||||||
tdarr_installer_version: 2.00.13
|
tdarr_installer_version: 2.00.13
|
||||||
|
|||||||
392
tasks/nomad.yml
392
tasks/nomad.yml
@@ -4,243 +4,243 @@
|
|||||||
|
|
||||||
- name: "Set variables needed to install Nomad"
|
- name: "Set variables needed to install Nomad"
|
||||||
block:
|
block:
|
||||||
- name: "set variable: check if we have a mounted USB drive (Debian)"
|
- name: "set variable: check if we have a mounted USB drive (Debian)"
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
path: "{{ rpi_usb_drive_mount_point }}"
|
path: "{{ rpi_usb_drive_mount_point }}"
|
||||||
register: have_usb_drive
|
register: have_usb_drive
|
||||||
changed_when: false
|
changed_when: false
|
||||||
when:
|
when:
|
||||||
- ansible_os_family == 'Debian'
|
- ansible_os_family == 'Debian'
|
||||||
|
|
||||||
- name: "set variable: Use USB drive for nomad /opt (Debian)"
|
- name: "set variable: Use USB drive for nomad /opt (Debian)"
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
nomad_opt_dir_location: "{{ rpi_usb_drive_mount_point }}/opt/nomad"
|
nomad_opt_dir_location: "{{ rpi_usb_drive_mount_point }}/opt/nomad"
|
||||||
when:
|
when:
|
||||||
- ansible_os_family == 'Debian'
|
- ansible_os_family == 'Debian'
|
||||||
- have_usb_drive.stat.exists
|
- have_usb_drive.stat.exists
|
||||||
|
|
||||||
- name: "set variable: Use root dist for nomad /opt (Debian)"
|
- name: "set variable: Use root dist for nomad /opt (Debian)"
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
nomad_opt_dir_location: "/opt/nomad"
|
nomad_opt_dir_location: "/opt/nomad"
|
||||||
when:
|
when:
|
||||||
- ansible_os_family == 'Debian'
|
- ansible_os_family == 'Debian'
|
||||||
- not have_usb_drive.stat.exists
|
- not have_usb_drive.stat.exists
|
||||||
|
|
||||||
- name: "set variable: Use ~/library for /opt files (macOSX)"
|
- name: "set variable: Use ~/library for /opt files (macOSX)"
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
nomad_opt_dir_location: "/Users/{{ ansible_user }}/Library/nomad"
|
nomad_opt_dir_location: "/Users/{{ ansible_user }}/Library/nomad"
|
||||||
when:
|
when:
|
||||||
- ansible_os_family == 'Darwin'
|
- ansible_os_family == 'Darwin'
|
||||||
|
|
||||||
- name: "set variable: Set Nomad download Binary (armv7l)"
|
- name: "set variable: Set Nomad download Binary (armv7l)"
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
nomad_download_file_uri: "https://releases.hashicorp.com/nomad/{{ nomad_version }}/nomad_{{ nomad_version }}_linux_arm.zip"
|
nomad_download_file_uri: "https://releases.hashicorp.com/nomad/{{ nomad_version }}/nomad_{{ nomad_version }}_linux_arm.zip"
|
||||||
when:
|
when:
|
||||||
- ansible_os_family == 'Debian'
|
- ansible_os_family == 'Debian'
|
||||||
- ansible_architecture == 'armv7l'
|
- ansible_architecture == 'armv7l'
|
||||||
|
|
||||||
- name: "set variable: Set Nomad download Binary (aarch64)"
|
- name: "set variable: Set Nomad download Binary (aarch64)"
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
nomad_download_file_uri: "https://releases.hashicorp.com/nomad/{{ nomad_version }}/nomad_{{ nomad_version }}_linux_arm64.zip"
|
nomad_download_file_uri: "https://releases.hashicorp.com/nomad/{{ nomad_version }}/nomad_{{ nomad_version }}_linux_arm64.zip"
|
||||||
when:
|
when:
|
||||||
- ansible_os_family == 'Debian'
|
- ansible_os_family == 'Debian'
|
||||||
- ansible_architecture == 'aarch64'
|
- ansible_architecture == 'aarch64'
|
||||||
|
|
||||||
- name: "set variable: Set Nomad download Binary (MacOSX)"
|
- name: "set variable: Set Nomad download Binary (MacOSX)"
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
nomad_download_file_uri: "https://releases.hashicorp.com/nomad/{{ nomad_version }}/nomad_{{ nomad_version }}_darwin_amd64.zip"
|
nomad_download_file_uri: "https://releases.hashicorp.com/nomad/{{ nomad_version }}/nomad_{{ nomad_version }}_darwin_amd64.zip"
|
||||||
when:
|
when:
|
||||||
- mac_intel
|
- mac_intel
|
||||||
|
|
||||||
- name: Assert that we can install Nomad
|
- name: Assert that we can install Nomad
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- nomad_download_file_uri is defined
|
- nomad_download_file_uri is defined
|
||||||
- nomad_opt_dir_location is defined
|
- nomad_opt_dir_location is defined
|
||||||
fail_msg: "Unable to install Nomad on this host"
|
fail_msg: "Unable to install Nomad on this host"
|
||||||
|
|
||||||
- name: "Create Nomad user and group (Debian)"
|
- name: "Create Nomad user and group (Debian)"
|
||||||
when: ansible_os_family == 'Debian'
|
when: ansible_os_family == 'Debian'
|
||||||
block:
|
block:
|
||||||
- name: "Ensure group 'nomad' exists (Debian)"
|
- name: "Ensure group 'nomad' exists (Debian)"
|
||||||
become: true
|
become: true
|
||||||
ansible.builtin.group:
|
ansible.builtin.group:
|
||||||
name: nomad
|
name: nomad
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: "Add the user 'nomad' with group 'nomad' (Debian)"
|
- name: "Add the user 'nomad' with group 'nomad' (Debian)"
|
||||||
become: true
|
become: true
|
||||||
ansible.builtin.user:
|
ansible.builtin.user:
|
||||||
name: nomad
|
name: nomad
|
||||||
group: nomad
|
group: nomad
|
||||||
|
|
||||||
- name: "Add user 'nomad' to docker and sudo groups (Debian)"
|
- name: "Add user 'nomad' to docker and sudo groups (Debian)"
|
||||||
become: true
|
become: true
|
||||||
ansible.builtin.user:
|
ansible.builtin.user:
|
||||||
user: nomad
|
user: nomad
|
||||||
groups: docker,sudo
|
groups: docker,sudo
|
||||||
append: true
|
append: true
|
||||||
|
|
||||||
- name: "Create Nomad /opt storage"
|
- name: "Create Nomad /opt storage"
|
||||||
block:
|
block:
|
||||||
- name: "create {{ nomad_opt_dir_location }} directories"
|
- name: "create {{ nomad_opt_dir_location }} directories"
|
||||||
become: true
|
become: true
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "{{ item }}"
|
path: "{{ item }}"
|
||||||
state: directory
|
state: directory
|
||||||
recurse: true
|
recurse: true
|
||||||
mode: 0755
|
mode: 0755
|
||||||
loop:
|
loop:
|
||||||
- "{{ nomad_opt_dir_location }}/logs"
|
- "{{ nomad_opt_dir_location }}/logs"
|
||||||
- "{{ nomad_opt_dir_location }}/plugins"
|
- "{{ nomad_opt_dir_location }}/plugins"
|
||||||
- "{{ nomad_opt_dir_location }}/certs"
|
- "{{ nomad_opt_dir_location }}/certs"
|
||||||
|
|
||||||
- name: Copy server certs
|
- name: Copy server certs
|
||||||
become: true
|
become: true
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
src: "{{ item.src }}"
|
src: "{{ item.src }}"
|
||||||
dest: "{{ item.dest }}"
|
dest: "{{ item.dest }}"
|
||||||
mode: 0755
|
mode: 0755
|
||||||
loop:
|
loop:
|
||||||
- { src: certs/nomad/nomad-ca.pem, dest: "{{ nomad_opt_dir_location }}/certs/nomad-ca.pem" }
|
- { src: certs/nomad/nomad-ca.pem, dest: "{{ nomad_opt_dir_location }}/certs/nomad-ca.pem" }
|
||||||
- { src: certs/nomad/server.pem, dest: "{{ nomad_opt_dir_location }}/certs/server.pem" }
|
- { src: certs/nomad/server.pem, dest: "{{ nomad_opt_dir_location }}/certs/server.pem" }
|
||||||
- { src: certs/nomad/server-key.pem, dest: "{{ nomad_opt_dir_location }}/certs/server-key.pem" }
|
- { src: certs/nomad/server-key.pem, dest: "{{ nomad_opt_dir_location }}/certs/server-key.pem" }
|
||||||
notify: "restart nomad"
|
notify: "restart nomad"
|
||||||
when: is_nomad_server
|
when: is_nomad_server
|
||||||
|
|
||||||
- name: Copy client certs
|
- name: Copy client certs
|
||||||
become: true
|
become: true
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
src: "{{ item.src }}"
|
src: "{{ item.src }}"
|
||||||
dest: "{{ item.dest }}"
|
dest: "{{ item.dest }}"
|
||||||
mode: 0755
|
mode: 0755
|
||||||
loop:
|
loop:
|
||||||
- { src: certs/nomad/nomad-ca.pem, dest: "{{ nomad_opt_dir_location }}/certs/nomad-ca.pem" }
|
- { src: certs/nomad/nomad-ca.pem, dest: "{{ nomad_opt_dir_location }}/certs/nomad-ca.pem" }
|
||||||
- { src: certs/nomad/client.pem, dest: "{{ nomad_opt_dir_location }}/certs/client.pem" }
|
- { src: certs/nomad/client.pem, dest: "{{ nomad_opt_dir_location }}/certs/client.pem" }
|
||||||
- { src: certs/nomad/client-key.pem, dest: "{{ nomad_opt_dir_location }}/certs/client-key.pem" }
|
- { src: certs/nomad/client-key.pem, dest: "{{ nomad_opt_dir_location }}/certs/client-key.pem" }
|
||||||
notify: "restart nomad"
|
notify: "restart nomad"
|
||||||
when: is_nomad_client
|
when: is_nomad_client
|
||||||
|
|
||||||
- name: "set owner of files to nomad:nomad (debian)"
|
- name: "set owner of files to nomad:nomad (debian)"
|
||||||
become: true
|
become: true
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "{{ nomad_opt_dir_location }}"
|
path: "{{ nomad_opt_dir_location }}"
|
||||||
owner: nomad
|
owner: nomad
|
||||||
group: nomad
|
group: nomad
|
||||||
recurse: true
|
recurse: true
|
||||||
when: ansible_os_family == 'Debian'
|
when: ansible_os_family == 'Debian'
|
||||||
|
|
||||||
- name: "set owner of files to {{ ansible_user_uid }}:{{ ansible_user_gid }} (MacOSX)"
|
- name: "set owner of files to {{ ansible_user_uid }}:{{ ansible_user_gid }} (MacOSX)"
|
||||||
become: true
|
become: true
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "{{ nomad_opt_dir_location }}"
|
path: "{{ nomad_opt_dir_location }}"
|
||||||
owner: "{{ ansible_user_uid }}"
|
owner: "{{ ansible_user_uid }}"
|
||||||
group: "{{ ansible_user_gid }}"
|
group: "{{ ansible_user_gid }}"
|
||||||
recurse: true
|
recurse: true
|
||||||
when: ansible_os_family != 'Debian'
|
when: ansible_os_family != 'Debian'
|
||||||
|
|
||||||
- name: "Template out the configuration file"
|
- name: "Template out the configuration file"
|
||||||
block:
|
block:
|
||||||
- name: "create {{ nomad_configuration_dir }}"
|
- name: "create {{ nomad_configuration_dir }}"
|
||||||
become: true
|
become: true
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "{{ nomad_configuration_dir }}"
|
path: "{{ nomad_configuration_dir }}"
|
||||||
state: directory
|
state: directory
|
||||||
mode: 0755
|
mode: 0755
|
||||||
|
|
||||||
- name: copy base config file
|
- name: copy base config file
|
||||||
become: true
|
become: true
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: nomad.hcl.j2
|
src: nomad.hcl.j2
|
||||||
dest: "{{ nomad_configuration_dir }}/nomad.hcl"
|
dest: "{{ nomad_configuration_dir }}/nomad.hcl"
|
||||||
mode: 0644
|
mode: 0644
|
||||||
notify: "restart nomad"
|
notify: "restart nomad"
|
||||||
|
|
||||||
- name: "set owner of files to nomad:nomad (Debian)"
|
- name: "set owner of files to nomad:nomad (Debian)"
|
||||||
become: true
|
become: true
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "{{ nomad_configuration_dir }}"
|
path: "{{ nomad_configuration_dir }}"
|
||||||
owner: nomad
|
owner: nomad
|
||||||
group: nomad
|
group: nomad
|
||||||
recurse: true
|
recurse: true
|
||||||
when:
|
when:
|
||||||
- ansible_os_family == 'Debian'
|
- ansible_os_family == 'Debian'
|
||||||
|
|
||||||
- name: Install or Update Nomad
|
- name: Install or Update Nomad
|
||||||
block:
|
block:
|
||||||
- name: "set fact: do we need a nomad install?"
|
- name: "set fact: do we need a nomad install?"
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
need_nomad_install: false
|
need_nomad_install: false
|
||||||
|
|
||||||
- name: Check if nomad is installed
|
- name: Check if nomad is installed
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
path: /usr/local/bin/nomad
|
path: /usr/local/bin/nomad
|
||||||
register: nomad_binary_file_location
|
register: nomad_binary_file_location
|
||||||
|
|
||||||
- name: "set fact: do we need a nomad install"
|
- name: "set fact: do we need a nomad install"
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
need_nomad_install: true
|
need_nomad_install: true
|
||||||
when:
|
when:
|
||||||
- not nomad_binary_file_location.stat.exists
|
- not nomad_binary_file_location.stat.exists
|
||||||
|
|
||||||
- name: Check current version of Nomad
|
- name: Check current version of Nomad
|
||||||
ansible.builtin.shell: /usr/local/bin/nomad --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+'
|
ansible.builtin.shell: /usr/local/bin/nomad --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+'
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: current_nomad_version
|
register: current_nomad_version
|
||||||
check_mode: false
|
check_mode: false
|
||||||
changed_when: false
|
changed_when: false
|
||||||
when:
|
when:
|
||||||
- not need_nomad_install
|
- not need_nomad_install
|
||||||
|
|
||||||
- name: "set fact: do we need a nomad install"
|
- name: "set fact: do we need a nomad install"
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
need_nomad_install: true
|
need_nomad_install: true
|
||||||
when:
|
when:
|
||||||
- not need_nomad_install
|
- not need_nomad_install
|
||||||
- current_nomad_version.stdout is version(nomad_version, '<')
|
- current_nomad_version.stdout is version(nomad_version, '<')
|
||||||
|
|
||||||
- name: install Nomad
|
- name: install Nomad
|
||||||
become: true
|
become: true
|
||||||
ansible.builtin.unarchive:
|
ansible.builtin.unarchive:
|
||||||
src: "{{ nomad_download_file_uri }}"
|
src: "{{ nomad_download_file_uri }}"
|
||||||
dest: /usr/local/bin
|
dest: /usr/local/bin
|
||||||
remote_src: true
|
remote_src: true
|
||||||
notify: "restart nomad"
|
notify: "restart nomad"
|
||||||
when:
|
when:
|
||||||
- need_nomad_install
|
- need_nomad_install
|
||||||
|
|
||||||
- name: "Copy system.d or launchctrl service files"
|
- name: "Copy system.d or launchctrl service files"
|
||||||
block:
|
block:
|
||||||
- name: ensure /Library/LaunchAgents exists (MacOSX)
|
- name: ensure /Library/LaunchAgents exists (MacOSX)
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "{{ nomad_plist_macos | dirname }}"
|
path: "{{ nomad_plist_macos | dirname }}"
|
||||||
state: directory
|
state: directory
|
||||||
mode: 0755
|
mode: 0755
|
||||||
when:
|
when:
|
||||||
- ansible_os_family == 'Darwin'
|
- ansible_os_family == 'Darwin'
|
||||||
|
|
||||||
- name: create nomad launchd service (MacOSX)
|
- name: create nomad launchd service (MacOSX)
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: nomad.launchd.j2
|
src: nomad.launchd.j2
|
||||||
dest: "{{ nomad_plist_macos }}"
|
dest: "{{ nomad_plist_macos }}"
|
||||||
mode: 0644
|
mode: 0644
|
||||||
notify: "restart nomad"
|
notify: "restart nomad"
|
||||||
when:
|
when:
|
||||||
- ansible_os_family == 'Darwin'
|
- ansible_os_family == 'Darwin'
|
||||||
|
|
||||||
- name: create nomad service (Debian)
|
- name: create nomad service (Debian)
|
||||||
become: true
|
become: true
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: nomad.service.j2
|
src: nomad.service.j2
|
||||||
dest: /etc/systemd/system/nomad.service
|
dest: /etc/systemd/system/nomad.service
|
||||||
mode: 0644
|
mode: 0644
|
||||||
notify: "restart nomad"
|
notify: "restart nomad"
|
||||||
when:
|
when:
|
||||||
- ansible_os_family == 'Debian'
|
- ansible_os_family == 'Debian'
|
||||||
|
|
||||||
- name: "start nomad, if stopped"
|
- name: "start nomad, if stopped"
|
||||||
ansible.builtin.shell:
|
ansible.builtin.shell:
|
||||||
cmd: "/usr/local/bin/nomad node status -self -short | grep {{ inventory_hostname }}"
|
cmd: "/usr/local/bin/nomad node status -self -short | grep {{ inventory_hostname }}"
|
||||||
register: node_status_response
|
register: node_status_response
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
failed_when: false
|
failed_when: false
|
||||||
|
|||||||
@@ -206,9 +206,9 @@ plugin "raw_exec" {
|
|||||||
|
|
||||||
plugin "docker" {
|
plugin "docker" {
|
||||||
config {
|
config {
|
||||||
allow_caps = [ "ALL" ]
|
allow_caps = ["chown", "net_raw"]
|
||||||
allow_privileged = true
|
allow_privileged = true
|
||||||
|
extra_labels = ["job_name"]
|
||||||
volumes {
|
volumes {
|
||||||
enabled = true
|
enabled = true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user