mirror of
https://github.com/natelandau/ansible-homelab-config.git
synced 2025-11-17 09:23:40 -05:00
style: pass ansible-lint
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
---
|
||||
repos:
|
||||
- repo: "https://github.com/commitizen-tools/commitizen"
|
||||
rev: v2.42.1
|
||||
rev: 3.0.1
|
||||
hooks:
|
||||
- id: "commitizen"
|
||||
|
||||
@@ -31,7 +31,7 @@ repos:
|
||||
args: [--markdown-linebreak-ext=md]
|
||||
|
||||
- repo: "https://github.com/adrienverge/yamllint.git"
|
||||
rev: v1.29.0
|
||||
rev: v1.31.0
|
||||
hooks:
|
||||
- id: yamllint
|
||||
files: \.(yaml|yml)$
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
cmd: automount -cv
|
||||
register: automount_output
|
||||
failed_when: automount_output.rc > 0
|
||||
changed_when: automount_output.rc == 0
|
||||
when:
|
||||
- "'macs' in group_names"
|
||||
- not ansible_check_mode
|
||||
@@ -17,6 +18,7 @@
|
||||
cmd: automount -cvu
|
||||
register: automount_output
|
||||
failed_when: automount_output.rc > 0
|
||||
changed_when: automount_output.rc == 0
|
||||
when:
|
||||
- "'macs' in group_names"
|
||||
- not ansible_check_mode
|
||||
@@ -28,6 +30,9 @@
|
||||
ansible.builtin.service:
|
||||
name: telegraf
|
||||
state: restarted
|
||||
register: telegraf_service
|
||||
failed_when: telegraf_service.rc > 0
|
||||
changed_when: telegraf_service.rc == 0
|
||||
when:
|
||||
- ansible_os_family == 'Debian'
|
||||
listen: restart_telegraf
|
||||
@@ -37,46 +42,57 @@
|
||||
cmd: /usr/local/bin/brew services restart telegraf
|
||||
executable: /usr/local/bin/bash
|
||||
ignore_errors: true
|
||||
register: telegraf_service
|
||||
failed_when: telegraf_service.rc > 0
|
||||
changed_when: telegraf_service.rc == 0
|
||||
when:
|
||||
- ansible_os_family == 'Darwin'
|
||||
listen: restart_telegraf
|
||||
|
||||
##################################### NOMAD
|
||||
|
||||
- name: restart nomad (Debian)
|
||||
- name: Restart nomad (Debian)
|
||||
become: true
|
||||
ansible.builtin.systemd:
|
||||
name: nomad
|
||||
enabled: true
|
||||
state: restarted
|
||||
register: nomad_service
|
||||
failed_when: nomad_service.rc > 0
|
||||
changed_when: nomad_service.rc == 0
|
||||
when:
|
||||
- ansible_os_family == 'Debian'
|
||||
- "'nostart' not in ansible_run_tags"
|
||||
listen: "restart nomad"
|
||||
|
||||
- name: "unload nomad agent (MacOSX)"
|
||||
- name: "Unload nomad agent (MacOSX)"
|
||||
ansible.builtin.command:
|
||||
cmd: "launchctl unload -w {{ nomad_plist_macos }}"
|
||||
failed_when: false
|
||||
register: nomad_service
|
||||
changed_when: nomad_service.rc == 0
|
||||
failed_when: nomad_service.rc > 0
|
||||
when:
|
||||
- ansible_os_family == 'Darwin'
|
||||
- "'nostart' not in ansible_run_tags"
|
||||
listen: "restart nomad"
|
||||
|
||||
- name: "load the nomad agent (MacOSX)"
|
||||
- name: "Load the nomad agent (MacOSX)"
|
||||
ansible.builtin.command:
|
||||
cmd: "launchctl load -w {{ nomad_plist_macos }}"
|
||||
register: nomad_service
|
||||
changed_when: nomad_service.rc == 0
|
||||
failed_when: nomad_service.rc > 0
|
||||
when:
|
||||
- ansible_os_family == 'Darwin'
|
||||
- "'nostart' not in ansible_run_tags"
|
||||
listen: "restart nomad"
|
||||
|
||||
- name: "ensure nomad is really running"
|
||||
- name: "Ensure nomad is really running"
|
||||
ansible.builtin.shell:
|
||||
cmd: "sleep 10 && /usr/local/bin/nomad node status -self -short | grep {{ inventory_hostname }}"
|
||||
cmd: "set -o pipefail && sleep 10 && /usr/local/bin/nomad node status -self -short | grep {{ inventory_hostname }}"
|
||||
register: node_status_response
|
||||
failed_when: node_status_response.rc > 0
|
||||
changed_when: false
|
||||
changed_when: node_status_response.rc == 0
|
||||
when: "'nostart' not in ansible_run_tags"
|
||||
listen: "restart nomad"
|
||||
# - name: "Ensure sure Nomad service is really running"
|
||||
|
||||
4
main.yml
4
main.yml
@@ -11,13 +11,13 @@
|
||||
- name: Run sanity checks
|
||||
ansible.builtin.import_tasks: tasks/sanity.yml
|
||||
tags: ["always", "sanity"]
|
||||
- name: populate service facts
|
||||
- name: Populate service facts
|
||||
ansible.builtin.service_facts:
|
||||
tags: ["nomad", "consul"]
|
||||
- name: Run debug tasks
|
||||
ansible.builtin.import_tasks: tasks/debug.yml
|
||||
tags: [never, debug]
|
||||
- name: populate device specific variables
|
||||
- name: Populate device specific variables
|
||||
ansible.builtin.import_tasks: tasks/interpolated_variables.yml
|
||||
tags: ["always"]
|
||||
- name: Ensure we have up-to-date packages
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
# 1. Copies a backup and restore shellscript to /usr/local/bin
|
||||
# 2. Edits the sudoers file to allow the script to be invoked with sudo privileges
|
||||
|
||||
- name: copy backup shellscript to server
|
||||
- name: Copy backup shellscript to server
|
||||
become: true
|
||||
ansible.builtin.template:
|
||||
src: scripts/service_backups.sh.j2
|
||||
@@ -15,7 +15,7 @@
|
||||
when:
|
||||
- is_nomad_client or is_nomad_server
|
||||
|
||||
- name: copy restore shellscript to server
|
||||
- name: Copy restore shellscript to server
|
||||
become: true
|
||||
ansible.builtin.template:
|
||||
src: scripts/service_restore.sh.j2
|
||||
@@ -24,7 +24,7 @@
|
||||
when:
|
||||
- is_nomad_client or is_nomad_server
|
||||
|
||||
- name: ensure nomad user can run sudo with the restore script
|
||||
- name: Ensure nomad user can run sudo with the restore script
|
||||
become: true
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/sudoers
|
||||
@@ -35,7 +35,7 @@
|
||||
- is_nomad_client or is_nomad_server
|
||||
- "'pis' in group_names"
|
||||
|
||||
- name: ensure my user can run sudo with the restore script
|
||||
- name: Ensure my user can run sudo with the restore script
|
||||
become: true
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/sudoers
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
- name: "Mount storage on Raspberry Pis"
|
||||
when: "'pis' in group_names"
|
||||
block:
|
||||
- name: ensure local mount points exist
|
||||
- name: Ensure local mount points exist
|
||||
become: true
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.local }}"
|
||||
@@ -16,7 +16,7 @@
|
||||
# group: "{{ ansible_user_gid }}"
|
||||
loop: "{{ rpi_nfs_mounts_list }}"
|
||||
|
||||
- name: remove old nfs drives
|
||||
- name: Remove old nfs drives
|
||||
become: true
|
||||
ansible.posix.mount:
|
||||
path: "{{ item.local }}"
|
||||
@@ -26,7 +26,7 @@
|
||||
state: absent
|
||||
loop: "{{ rpi_nfs_mounts_remove }}"
|
||||
|
||||
- name: mount all nfs drives
|
||||
- name: Mount all nfs drives
|
||||
become: true
|
||||
ansible.posix.mount:
|
||||
path: "{{ item.local }}"
|
||||
@@ -42,7 +42,7 @@
|
||||
- name: "Mount storage on Macs"
|
||||
when: "'macs' in group_names"
|
||||
block:
|
||||
- name: create mount_point
|
||||
- name: Create mount_point
|
||||
become: true
|
||||
ansible.builtin.file:
|
||||
path: "{{ mac_storage_mount_point }}"
|
||||
@@ -52,10 +52,10 @@
|
||||
# I ran into problems getting this to run successfully. If errors occur, add the line manually using:
|
||||
# $ sudo nano /private/etc/auto_master
|
||||
|
||||
- name: add NFS shared drives to macs
|
||||
- name: Add NFS shared drives to macs
|
||||
when: mac_autofs_type == 'nfs'
|
||||
block:
|
||||
- name: add auto_nfs to "/private/etc/auto_master"
|
||||
- name: Add auto_nfs to "/private/etc/auto_master"
|
||||
become: true
|
||||
ansible.builtin.lineinfile:
|
||||
path: /private/etc/auto_master
|
||||
@@ -63,7 +63,7 @@
|
||||
line: "/- auto_nfs -nobrowse,nosuid"
|
||||
unsafe_writes: true
|
||||
|
||||
- name: add mounts to /etc/auto_nfs
|
||||
- name: Add mounts to /etc/auto_nfs
|
||||
become: true
|
||||
ansible.builtin.lineinfile:
|
||||
create: true
|
||||
@@ -76,7 +76,7 @@
|
||||
loop: "{{ mac_nfs_mounts_list if mac_nfs_mounts_list is iterable else [] }}"
|
||||
notify: mac_run_automount
|
||||
|
||||
- name: remove old mounts from /etc/auto_nfs
|
||||
- name: Remove old mounts from /etc/auto_nfs
|
||||
become: true
|
||||
ansible.builtin.lineinfile:
|
||||
create: true
|
||||
@@ -89,10 +89,10 @@
|
||||
notify: mac_run_automount_unmount
|
||||
loop: "{{ mac_nfs_mounts_remove if mac_nfs_mounts_remove is iterable else [] }}"
|
||||
|
||||
- name: add AFP shared drives to macs
|
||||
- name: Add AFP shared drives to macs
|
||||
when: mac_autofs_type == 'afp'
|
||||
block:
|
||||
- name: add auto_afp to "/private/etc/auto_master"
|
||||
- name: Add auto_afp to "/private/etc/auto_master"
|
||||
become: true
|
||||
ansible.builtin.lineinfile:
|
||||
path: /private/etc/auto_master
|
||||
@@ -100,7 +100,7 @@
|
||||
line: "/- auto_afp -nobrowse,nosuid"
|
||||
unsafe_writes: true
|
||||
|
||||
- name: add mounts to /etc/auto_afp
|
||||
- name: Add mounts to /etc/auto_afp
|
||||
become: true
|
||||
ansible.builtin.lineinfile:
|
||||
create: true
|
||||
@@ -113,7 +113,7 @@
|
||||
loop: "{{ mac_afp_or_smb_mounts_list if mac_afp_or_smb_mounts_list is iterable else [] }}"
|
||||
notify: mac_run_automount
|
||||
|
||||
- name: remove mounts from /etc/auto_afp
|
||||
- name: Remove mounts from /etc/auto_afp
|
||||
become: true
|
||||
ansible.builtin.lineinfile:
|
||||
create: true
|
||||
@@ -126,10 +126,10 @@
|
||||
loop: "{{ mac_afp_or_smb_mounts_remove if mac_afp_or_smb_mounts_remove is iterable else [] }}"
|
||||
notify: mac_run_automount_unmount
|
||||
|
||||
- name: add SMB shared drives to macs
|
||||
- name: Add SMB shared drives to macs
|
||||
when: mac_autofs_type == 'smb'
|
||||
block:
|
||||
- name: add auto_smb to "/private/etc/auto_master"
|
||||
- name: Add auto_smb to "/private/etc/auto_master"
|
||||
become: true
|
||||
ansible.builtin.lineinfile:
|
||||
path: /private/etc/auto_master
|
||||
@@ -137,7 +137,7 @@
|
||||
line: "/- auto_smb -noowners,nosuid"
|
||||
unsafe_writes: true
|
||||
|
||||
- name: add mounts to /etc/auto_smb
|
||||
- name: Add mounts to /etc/auto_smb
|
||||
become: true
|
||||
ansible.builtin.lineinfile:
|
||||
create: true
|
||||
@@ -150,7 +150,7 @@
|
||||
loop: "{{ mac_afp_or_smb_mounts_list if mac_afp_or_smb_mounts_list is iterable else [] }}"
|
||||
notify: mac_run_automount
|
||||
|
||||
- name: remove mounts from /etc/auto_smb
|
||||
- name: Remove mounts from /etc/auto_smb
|
||||
become: true
|
||||
ansible.builtin.lineinfile:
|
||||
create: true
|
||||
|
||||
@@ -92,6 +92,9 @@
|
||||
become: true
|
||||
ansible.builtin.command:
|
||||
cmd: "launchctl unload {{ consul_plist_macos }}"
|
||||
register: consul_unload
|
||||
failed_when: consul_unload.rc != 0
|
||||
changed_when: consul_unload.rc == 0
|
||||
when:
|
||||
- ansible_os_family == 'Darwin'
|
||||
- consul_file.stat.exists
|
||||
@@ -308,6 +311,9 @@
|
||||
- name: Load the Consul agent (MacOSX)
|
||||
ansible.builtin.command:
|
||||
cmd: "launchctl load -w {{ consul_plist_macos }}"
|
||||
register: consul_loaded
|
||||
changed_when: consul_loaded.rc == 0
|
||||
failed_when: consul_loaded.rc > 0
|
||||
when:
|
||||
- mac_intel or mac_arm
|
||||
- "'nostart' not in ansible_run_tags"
|
||||
|
||||
@@ -33,5 +33,5 @@
|
||||
# when:
|
||||
# - ansible_facts['system_vendor'] is search("Synology")
|
||||
|
||||
- name: "end play"
|
||||
- name: "End play"
|
||||
ansible.builtin.meta: end_play
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
changed_when: docker_command_result.rc == 1
|
||||
failed_when: false
|
||||
|
||||
- name: install docker on Debian
|
||||
- name: Install docker on Debian
|
||||
when: ansible_os_family == 'Debian'
|
||||
block:
|
||||
- name: "Add docker local filesystem storage directory"
|
||||
@@ -29,6 +29,9 @@
|
||||
ansible.builtin.command: /tmp/get-docker.sh
|
||||
environment:
|
||||
CHANNEL: stable
|
||||
register: docker_install
|
||||
failed_when: docker_install.rc > 0
|
||||
changed_when: docker_install.rc == 0
|
||||
when: docker_command_result.rc == 1
|
||||
|
||||
- name: Make sure Docker CE is the version specified
|
||||
@@ -51,7 +54,7 @@
|
||||
append: true
|
||||
when: docker_command_result.rc == 1
|
||||
|
||||
- name: install docker on macOS
|
||||
- name: Install docker on macOS
|
||||
when: "'macs' in group_names"
|
||||
block:
|
||||
- name: "Add docker directory to ~/Library"
|
||||
@@ -60,7 +63,7 @@
|
||||
mode: 0755
|
||||
state: directory
|
||||
|
||||
- name: install base homebrew packages
|
||||
- name: Install base homebrew packages
|
||||
community.general.homebrew:
|
||||
name: docker
|
||||
state: present
|
||||
@@ -68,9 +71,12 @@
|
||||
upgrade_all: false
|
||||
when: docker_command_result.rc == 1
|
||||
|
||||
- name: open docker application
|
||||
- name: Open docker application
|
||||
ansible.builtin.command:
|
||||
cmd: open /Applications/Docker.app
|
||||
register: docker_open_app
|
||||
failed_when: docker_open_app.rc > 0
|
||||
changed_when: docker_open_app.rc == 0
|
||||
when: docker_command_result.rc == 1
|
||||
|
||||
- name: Must install Docker manually
|
||||
@@ -83,6 +89,6 @@
|
||||
- add '{{ mac_storage_mount_point }}' to mountable file system directories
|
||||
when: docker_command_result.rc == 1
|
||||
|
||||
- name: end play
|
||||
- name: End play
|
||||
ansible.builtin.meta: end_play
|
||||
when: docker_command_result.rc == 1
|
||||
|
||||
@@ -34,19 +34,19 @@
|
||||
when:
|
||||
- "'macs' in group_names"
|
||||
|
||||
- name: "set consul configuration directory (synology)"
|
||||
- name: "Set consul configuration directory (synology)"
|
||||
ansible.builtin.set_fact:
|
||||
interpolated_consul_configuration_dir: "{{ synology_consul_configuration_dir }}"
|
||||
when:
|
||||
- inventory_hostname == 'synology'
|
||||
|
||||
- name: "set consul configuration directory (pis)"
|
||||
- name: "Set consul configuration directory (pis)"
|
||||
ansible.builtin.set_fact:
|
||||
interpolated_consul_configuration_dir: "{{ rpi_consul_configuration_dir }}"
|
||||
when:
|
||||
- "'pis' in group_names"
|
||||
|
||||
- name: "set consul configuration directory (macs)"
|
||||
- name: "Set consul configuration directory (macs)"
|
||||
ansible.builtin.set_fact:
|
||||
interpolated_consul_configuration_dir: "{{ mac_consul_configuration_dir }}"
|
||||
when:
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# NOTE: This task exists due to the arillso.logrotate failing completely on macOS
|
||||
|
||||
- name: add service_backups.log to logrotate
|
||||
- name: Add service_backups.log to logrotate
|
||||
become: true
|
||||
vars:
|
||||
logrotate_applications:
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
- name: "Set variables needed to install Nomad"
|
||||
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:
|
||||
path: "{{ rpi_usb_drive_mount_point }}"
|
||||
register: have_usb_drive
|
||||
@@ -12,41 +12,41 @@
|
||||
when:
|
||||
- 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:
|
||||
nomad_opt_dir_location: "{{ rpi_usb_drive_mount_point }}/opt/nomad"
|
||||
when:
|
||||
- ansible_os_family == 'Debian'
|
||||
- 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:
|
||||
nomad_opt_dir_location: "/opt/nomad"
|
||||
when:
|
||||
- ansible_os_family == 'Debian'
|
||||
- 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:
|
||||
nomad_opt_dir_location: "/Users/{{ ansible_user }}/Library/nomad"
|
||||
when:
|
||||
- ansible_os_family == 'Darwin'
|
||||
|
||||
- name: "set variable: Set Nomad download Binary (armv7l)"
|
||||
- name: "Set variable: Set Nomad download Binary (armv7l)"
|
||||
ansible.builtin.set_fact:
|
||||
nomad_download_file_uri: "https://releases.hashicorp.com/nomad/{{ nomad_version }}/nomad_{{ nomad_version }}_linux_arm.zip"
|
||||
when:
|
||||
- ansible_os_family == 'Debian'
|
||||
- ansible_architecture == 'armv7l'
|
||||
|
||||
- name: "set variable: Set Nomad download Binary (aarch64)"
|
||||
- name: "Set variable: Set Nomad download Binary (aarch64)"
|
||||
ansible.builtin.set_fact:
|
||||
nomad_download_file_uri: "https://releases.hashicorp.com/nomad/{{ nomad_version }}/nomad_{{ nomad_version }}_linux_arm64.zip"
|
||||
when:
|
||||
- ansible_os_family == 'Debian'
|
||||
- ansible_architecture == 'aarch64'
|
||||
|
||||
- name: "set variable: Set Nomad download Binary (MacOSX)"
|
||||
- name: "Set variable: Set Nomad download Binary (MacOSX)"
|
||||
ansible.builtin.set_fact:
|
||||
nomad_download_file_uri: "https://releases.hashicorp.com/nomad/{{ nomad_version }}/nomad_{{ nomad_version }}_darwin_amd64.zip"
|
||||
when:
|
||||
@@ -83,7 +83,7 @@
|
||||
|
||||
- name: "Create Nomad /opt storage"
|
||||
block:
|
||||
- name: "create {{ nomad_opt_dir_location }} directories"
|
||||
- name: "Create {{ nomad_opt_dir_location }} directories"
|
||||
become: true
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
@@ -121,7 +121,7 @@
|
||||
notify: "restart nomad"
|
||||
when: is_nomad_client
|
||||
|
||||
- name: "set owner of files to nomad:nomad (debian)"
|
||||
- name: "Set owner of files to nomad:nomad (debian)"
|
||||
become: true
|
||||
ansible.builtin.file:
|
||||
path: "{{ nomad_opt_dir_location }}"
|
||||
@@ -130,7 +130,7 @@
|
||||
recurse: true
|
||||
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
|
||||
ansible.builtin.file:
|
||||
path: "{{ nomad_opt_dir_location }}"
|
||||
@@ -141,14 +141,14 @@
|
||||
|
||||
- name: "Template out the configuration file"
|
||||
block:
|
||||
- name: "create {{ nomad_configuration_dir }}"
|
||||
- name: "Create {{ nomad_configuration_dir }}"
|
||||
become: true
|
||||
ansible.builtin.file:
|
||||
path: "{{ nomad_configuration_dir }}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
|
||||
- name: copy base config file
|
||||
- name: Copy base config file
|
||||
become: true
|
||||
ansible.builtin.template:
|
||||
src: nomad.hcl.j2
|
||||
@@ -156,7 +156,7 @@
|
||||
mode: 0644
|
||||
notify: "restart nomad"
|
||||
|
||||
- name: "set owner of files to nomad:nomad (Debian)"
|
||||
- name: "Set owner of files to nomad:nomad (Debian)"
|
||||
become: true
|
||||
ansible.builtin.file:
|
||||
path: "{{ nomad_configuration_dir }}"
|
||||
@@ -168,7 +168,7 @@
|
||||
|
||||
- name: Install or Update Nomad
|
||||
block:
|
||||
- name: "set fact: do we need a nomad install?"
|
||||
- name: "Set fact: do we need a nomad install?"
|
||||
ansible.builtin.set_fact:
|
||||
need_nomad_install: false
|
||||
|
||||
@@ -177,7 +177,7 @@
|
||||
path: /usr/local/bin/nomad
|
||||
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:
|
||||
need_nomad_install: true
|
||||
when:
|
||||
@@ -192,14 +192,14 @@
|
||||
when:
|
||||
- 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:
|
||||
need_nomad_install: true
|
||||
when:
|
||||
- not need_nomad_install
|
||||
- current_nomad_version.stdout is version(nomad_version, '<')
|
||||
|
||||
- name: install Nomad
|
||||
- name: Install Nomad
|
||||
become: true
|
||||
ansible.builtin.unarchive:
|
||||
src: "{{ nomad_download_file_uri }}"
|
||||
@@ -211,7 +211,7 @@
|
||||
|
||||
- name: "Copy system.d or launchctrl service files"
|
||||
block:
|
||||
- name: ensure /Library/LaunchAgents exists (MacOSX)
|
||||
- name: Ensure /Library/LaunchAgents exists (MacOSX)
|
||||
ansible.builtin.file:
|
||||
path: "{{ nomad_plist_macos | dirname }}"
|
||||
state: directory
|
||||
@@ -219,7 +219,7 @@
|
||||
when:
|
||||
- ansible_os_family == 'Darwin'
|
||||
|
||||
- name: create nomad launchd service (MacOSX)
|
||||
- name: Create nomad launchd service (MacOSX)
|
||||
ansible.builtin.template:
|
||||
src: nomad.launchd.j2
|
||||
dest: "{{ nomad_plist_macos }}"
|
||||
@@ -228,7 +228,7 @@
|
||||
when:
|
||||
- ansible_os_family == 'Darwin'
|
||||
|
||||
- name: create nomad service (Debian)
|
||||
- name: Create nomad service (Debian)
|
||||
become: true
|
||||
ansible.builtin.template:
|
||||
src: nomad.service.j2
|
||||
@@ -238,7 +238,7 @@
|
||||
when:
|
||||
- ansible_os_family == 'Debian'
|
||||
|
||||
- name: "start nomad, if stopped"
|
||||
- name: "Start nomad, if stopped"
|
||||
ansible.builtin.shell:
|
||||
cmd: "/usr/local/bin/nomad node status -self -short | grep {{ inventory_hostname }}"
|
||||
register: node_status_response
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
- is_nomad_client or is_nomad_server or ("'macs' in group_names")
|
||||
- "'nas' not in group_names"
|
||||
|
||||
- name: synchronize nomad job templates (jinja)
|
||||
- name: Synchronize nomad job templates (jinja)
|
||||
ansible.builtin.template:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ nomad_jobfile_location }}/{{ item | basename | regex_replace('.j2$', '') }}"
|
||||
@@ -37,7 +37,7 @@
|
||||
- is_nomad_client or is_nomad_server or ("'macs' in group_names")
|
||||
- "'nas' not in group_names"
|
||||
|
||||
- name: synchronize nomad job templates (hcl)
|
||||
- name: Synchronize nomad job templates (hcl)
|
||||
ansible.builtin.template:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ nomad_jobfile_location }}/{{ item | basename }}"
|
||||
@@ -59,16 +59,16 @@
|
||||
- is_nomad_client or is_nomad_server
|
||||
loop: "{{ service_localfs_dirs }}"
|
||||
|
||||
- name: "Sync docker compose files"
|
||||
- name: Sync docker compose files
|
||||
when: is_docker_compose_client
|
||||
block:
|
||||
- name: confirm compose file dir exists
|
||||
- name: Confirm compose file dir exists
|
||||
ansible.builtin.file:
|
||||
path: "{{ docker_compose_file_location }}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
|
||||
- name: synchronize docker-compose files
|
||||
- name: Synchronize docker-compose files
|
||||
ansible.builtin.template:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ docker_compose_file_location }}/{{ item | basename | regex_replace('.j2$', '') }}"
|
||||
|
||||
@@ -7,18 +7,18 @@
|
||||
- ansible_os_family != 'Darwin'
|
||||
- manage_apt_packages_list
|
||||
block:
|
||||
- name: update APT package cache
|
||||
- name: Update APT package cache
|
||||
become: true
|
||||
ansible.builtin.apt:
|
||||
update_cache: true
|
||||
cache_valid_time: 3600
|
||||
|
||||
- name: "upgrade APT to the latest packages (this may take a while)"
|
||||
- name: "Upgrade APT to the latest packages (this may take a while)"
|
||||
become: true
|
||||
ansible.builtin.apt:
|
||||
upgrade: safe
|
||||
|
||||
- name: "install/upgrade APT packages (this may take a while)"
|
||||
- name: "Install/upgrade APT packages (this may take a while)"
|
||||
become: true
|
||||
ansible.builtin.apt:
|
||||
pkg: "{{ item }}"
|
||||
@@ -31,14 +31,14 @@
|
||||
- manage_homebrew_package_list
|
||||
- ansible_os_family == 'Darwin'
|
||||
block:
|
||||
- name: upgrade homebrew and all packages
|
||||
- name: Upgrade homebrew and all packages
|
||||
community.general.homebrew:
|
||||
update_homebrew: true
|
||||
upgrade_all: true
|
||||
register: homebrew_output
|
||||
ignore_errors: true
|
||||
|
||||
- name: install base homebrew packages
|
||||
- name: Install base homebrew packages
|
||||
community.general.homebrew:
|
||||
name: "{{ homebrew_package_list | join(',') }}"
|
||||
state: present
|
||||
@@ -46,15 +46,15 @@
|
||||
upgrade_all: false
|
||||
register: homebrew_output
|
||||
|
||||
- name: homebrew packages updated or installed
|
||||
- name: Homebrew packages updated or installed
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ homebrew_output.changed_pkgs }}"
|
||||
|
||||
- name: unchanged homebrew packages
|
||||
- name: Unchanged homebrew packages
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ homebrew_output.unchanged_pkgs }}"
|
||||
|
||||
- name: install homebrew casks
|
||||
- name: Install homebrew casks
|
||||
community.general.homebrew_cask:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
check_mode: false
|
||||
register: repos_directory_check
|
||||
|
||||
- name: "run pull_all_repos script"
|
||||
- name: "Run pull_all_repos script"
|
||||
ansible.builtin.command:
|
||||
cmd: "~/bin/pull_all_repos --directory ~/repos"
|
||||
register: pull_script_output
|
||||
@@ -27,6 +27,7 @@
|
||||
- repos_directory_check.stat.isdir
|
||||
- repos_directory_check.stat.writeable
|
||||
failed_when: pull_script_output.rc > 1
|
||||
changed_when: pull_script_output.rc == 0
|
||||
|
||||
- name: "Output from pull_all_repos"
|
||||
ansible.builtin.debug:
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
---
|
||||
# TASK DESCRIPTION:
|
||||
# Always runs fist. Confirms we can actually use Ansible
|
||||
- name: sanity - user mode
|
||||
- name: Sanity - user mode
|
||||
become: false
|
||||
ansible.builtin.debug:
|
||||
msg: "sanity check: user mode"
|
||||
msg: "Sanity check: user mode"
|
||||
|
||||
- name: sanity - become mode
|
||||
- name: Sanity - become mode
|
||||
become: true
|
||||
ansible.builtin.debug:
|
||||
msg: "sanity check: become mode"
|
||||
msg: "Sanity check: become mode"
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
#
|
||||
# NOTE: This is depreciated, I no longer use Prometheus and have migrated to Telegraf
|
||||
|
||||
- name: populate service facts
|
||||
- name: Populate service facts
|
||||
ansible.builtin.service_facts:
|
||||
|
||||
- name: stop node_exporter
|
||||
- name: Stop node_exporter
|
||||
become: true
|
||||
ansible.builtin.systemd:
|
||||
name: node_exporter
|
||||
@@ -29,7 +29,7 @@
|
||||
append: true
|
||||
|
||||
# --------------- Install or Update Prometheus
|
||||
- name: "set fact: need to install Prometheus?"
|
||||
- name: "Set fact: need to install Prometheus?"
|
||||
ansible.builtin.set_fact:
|
||||
need_prometheus_install: false
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
path: /usr/local/bin/node_exporter
|
||||
register: prometheus_binary_file_location
|
||||
|
||||
- name: "set fact: need to install Prometheus?"
|
||||
- name: "Set fact: need to install Prometheus?"
|
||||
ansible.builtin.set_fact:
|
||||
need_prometheus_install: true
|
||||
when:
|
||||
@@ -48,18 +48,20 @@
|
||||
ansible.builtin.shell: /usr/local/bin/node_exporter --version 3>&1 1>&2 2>&3 | head -n1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+'
|
||||
ignore_errors: true
|
||||
register: current_prometheus_version
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
check_mode: false
|
||||
when:
|
||||
- need_prometheus_install is false
|
||||
|
||||
- name: "set fact: need to install Prometheus?"
|
||||
- name: "Set fact: need to install Prometheus?"
|
||||
ansible.builtin.set_fact:
|
||||
need_prometheus_install: true
|
||||
when:
|
||||
- need_prometheus_install is false
|
||||
- current_prometheus_version.stdout != prometheus_verssion
|
||||
|
||||
- name: install node_exporter
|
||||
- name: Install node_exporter
|
||||
become: true
|
||||
ansible.builtin.unarchive:
|
||||
src: "https://github.com/prometheus/node_exporter/releases/download/v{{ prometheus_verssion }}/node_exporter-{{ prometheus_verssion }}.linux-armv7.tar.gz"
|
||||
@@ -75,14 +77,14 @@
|
||||
when:
|
||||
- need_prometheus_install is true
|
||||
|
||||
- name: create node_exporter service
|
||||
- name: Create node_exporter service
|
||||
become: true
|
||||
ansible.builtin.template:
|
||||
src: node_exporter.service.j2
|
||||
dest: /etc/systemd/system/node_exporter.service
|
||||
mode: 0644
|
||||
|
||||
- name: start node_exporter
|
||||
- name: Start node_exporter
|
||||
become: true
|
||||
ansible.builtin.systemd:
|
||||
name: node_exporter
|
||||
|
||||
@@ -18,26 +18,26 @@
|
||||
when:
|
||||
- "'macs' in group_names"
|
||||
|
||||
- name: "set variable: Set tdarr download Binary (armv7l)"
|
||||
- name: "Set variable: Set tdarr download Binary (armv7l)"
|
||||
ansible.builtin.set_fact:
|
||||
tdarr_download_uri: "https://f000.backblazeb2.com/file/tdarrs/versions/{{ tdarr_installer_version }}/linux_arm/Tdarr_Updater.zip"
|
||||
when:
|
||||
- ansible_os_family == 'Debian'
|
||||
- ansible_architecture == 'armv7l'
|
||||
|
||||
- name: "set variable: Set tdarr download Binary (MacOSX) - Intel"
|
||||
- name: "Set variable: Set tdarr download Binary (MacOSX) - Intel"
|
||||
ansible.builtin.set_fact:
|
||||
tdarr_download_uri: "https://f000.backblazeb2.com/file/tdarrs/versions/{{ tdarr_installer_version }}/darwin_x64/Tdarr_Updater.zip"
|
||||
when:
|
||||
- mac_intel
|
||||
|
||||
- name: "set variable: Set tdarr download Binary (MacOSX) - ARM"
|
||||
- name: "Set variable: Set tdarr download Binary (MacOSX) - ARM"
|
||||
ansible.builtin.set_fact:
|
||||
tdarr_download_uri: "https://f000.backblazeb2.com/file/tdarrs/versions/{{ tdarr_installer_version }}/darwin_arm64/Tdarr_Updater.zip"
|
||||
when:
|
||||
- mac_arm
|
||||
|
||||
- name: "set fact: do we need a tdarr install?"
|
||||
- name: "Set fact: do we need a tdarr install?"
|
||||
ansible.builtin.set_fact:
|
||||
need_tdarr_install: false
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
|
||||
- name: "Install ffmpeg and HandbrakeCLI"
|
||||
block:
|
||||
- name: "ensure ffmpeg and handbrake are installed (Debian)"
|
||||
- name: "Ensure ffmpeg and handbrake are installed (Debian)"
|
||||
become: true
|
||||
ansible.builtin.apt:
|
||||
pkg: "{{ item }}"
|
||||
@@ -60,7 +60,7 @@
|
||||
- handbrake
|
||||
when: "'pis' in group_names"
|
||||
|
||||
- name: "ensure ffmpeg and handbrake are installed (MacOS)"
|
||||
- name: "Ensure ffmpeg and handbrake are installed (MacOS)"
|
||||
community.general.homebrew:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
@@ -71,7 +71,7 @@
|
||||
- handbrake
|
||||
when: "'macs' in group_names"
|
||||
|
||||
- name: "ensure tdarr directory exists"
|
||||
- name: "Ensure tdarr directory exists"
|
||||
become: true
|
||||
ansible.builtin.file:
|
||||
path: "{{ interpolated_tdarr_dir }}"
|
||||
@@ -82,14 +82,14 @@
|
||||
|
||||
- name: "Install tdarr"
|
||||
block:
|
||||
- name: "set_fact: need Tdarr install?"
|
||||
- name: "Set fact: need Tdarr install?"
|
||||
ansible.builtin.stat:
|
||||
path: "{{ interpolated_tdarr_dir }}/configs"
|
||||
register: tdarr_exists
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
|
||||
- name: "set fact: do we need a tdarr install?"
|
||||
- name: "Set fact: do we need a tdarr install?"
|
||||
ansible.builtin.set_fact:
|
||||
need_tdarr_install: true
|
||||
when: not tdarr_exists.stat.exists
|
||||
@@ -119,6 +119,7 @@
|
||||
cmd: "{{ interpolated_tdarr_dir }}/Tdarr_Updater"
|
||||
register: tdarr_install
|
||||
failed_when: tdarr_install.rc > 0
|
||||
changed_when: tdarr_install.rc == 0
|
||||
when: need_tdarr_install
|
||||
|
||||
- name: Ensure correct permissions on server/node executables
|
||||
@@ -130,23 +131,23 @@
|
||||
- Tdarr_Node/Tdarr_Node
|
||||
when: need_tdarr_install
|
||||
|
||||
- name: "configure tdarr"
|
||||
- name: "Configure tdarr"
|
||||
block:
|
||||
- name: update server configuration file
|
||||
- name: Update server configuration file
|
||||
ansible.builtin.template:
|
||||
src: Tdarr_Server_Config.json.j2
|
||||
dest: "{{ interpolated_tdarr_dir }}/configs/Tdarr_Server_Config.json"
|
||||
mode: 0644
|
||||
when: is_tdarr_server
|
||||
|
||||
- name: update node configuration file
|
||||
- name: Update node configuration file
|
||||
ansible.builtin.template:
|
||||
src: Tdarr_Node_Config.json.j2
|
||||
dest: "{{ interpolated_tdarr_dir }}/configs/Tdarr_Node_Config.json"
|
||||
mode: 0644
|
||||
when: is_tdarr_node
|
||||
|
||||
- name: check if consul is installed?
|
||||
- name: Check if consul is installed?
|
||||
ansible.builtin.stat:
|
||||
path: "{{ interpolated_consul_configuration_dir }}"
|
||||
register: consul_installed
|
||||
@@ -155,7 +156,7 @@
|
||||
when:
|
||||
- is_tdarr_server
|
||||
|
||||
- name: move consul service config into place
|
||||
- name: Move consul service config into place
|
||||
become: true
|
||||
ansible.builtin.template:
|
||||
src: consul_services/tdarr_service.json.j2
|
||||
@@ -177,7 +178,7 @@
|
||||
- is_tdarr_server
|
||||
- consul_installed.stat.exists
|
||||
|
||||
- name: debug when consul agent reload fails
|
||||
- name: Debug when consul agent reload fails
|
||||
ansible.builtin.debug:
|
||||
var: consul_agent_reload_http_response.msg
|
||||
when:
|
||||
@@ -185,5 +186,5 @@
|
||||
- consul_installed.stat.exists
|
||||
- consul_agent_reload_http_response.status != 200
|
||||
|
||||
- name: mount shared storage
|
||||
- name: Mount shared storage
|
||||
ansible.builtin.import_tasks: cluster_storage.yml
|
||||
|
||||
@@ -5,31 +5,31 @@
|
||||
# --------------------------------- Set variables depending on system type
|
||||
- name: "Configure variables"
|
||||
block:
|
||||
- name: "set variable: telegraph_binary_location (Debian)"
|
||||
- name: "Set variable: telegraph_binary_location (Debian)"
|
||||
ansible.builtin.set_fact:
|
||||
telegraph_binary_location: "/usr/bin/telegraf"
|
||||
when:
|
||||
- ansible_os_family == 'Debian'
|
||||
|
||||
- name: "set variable: telegraph_binary_location (MacOS)"
|
||||
- name: "Set variable: telegraph_binary_location (MacOS)"
|
||||
ansible.builtin.set_fact:
|
||||
telegraph_binary_location: "/usr/local/bin/telegraf"
|
||||
when:
|
||||
- ansible_os_family == 'Darwin'
|
||||
|
||||
- name: "set fact: telegraph_config_location (Debian)"
|
||||
- name: "Set fact: telegraph_config_location (Debian)"
|
||||
ansible.builtin.set_fact:
|
||||
telegraph_config_location: "/etc/telegraf"
|
||||
when:
|
||||
- ansible_os_family == 'Debian'
|
||||
|
||||
- name: "set fact: telegraph_config_location (macOS)"
|
||||
- name: "Set fact: telegraph_config_location (macOS)"
|
||||
ansible.builtin.set_fact:
|
||||
telegraph_config_location: "/usr/local/etc"
|
||||
when:
|
||||
- ansible_os_family == 'Darwin'
|
||||
|
||||
- name: "set fact: telegraph_config_location (macOS)"
|
||||
- name: "Set fact: telegraph_config_location (macOS)"
|
||||
ansible.builtin.set_fact:
|
||||
telegraph_config_location: "/volume1/docker/telegraf/config"
|
||||
when:
|
||||
@@ -43,14 +43,14 @@
|
||||
- not mac_arm
|
||||
fail_msg: "Unable to install Telegraf on this host"
|
||||
|
||||
- name: "set variable: Set speedtest download Binary (armv7l)"
|
||||
- name: "Set variable: Set speedtest download Binary (armv7l)"
|
||||
ansible.builtin.set_fact:
|
||||
speedtest_download_file_uri: "https://install.speedtest.net/app/cli/ookla-speedtest-{{ speedtest_cli_version }}-linux-armhf.tgz"
|
||||
when:
|
||||
- ansible_os_family == 'Debian'
|
||||
- ansible_architecture == 'armv7l'
|
||||
|
||||
- name: "set variable: Set speedtest download Binary (aarch64)"
|
||||
- name: "Set variable: Set speedtest download Binary (aarch64)"
|
||||
ansible.builtin.set_fact:
|
||||
speedtest_download_file_uri: "https://install.speedtest.net/app/cli/ookla-speedtest-{{ speedtest_cli_version }}-linux-aarch64.tgz"
|
||||
when:
|
||||
@@ -59,7 +59,7 @@
|
||||
|
||||
- name: "Install/upgrade Telegraf"
|
||||
block:
|
||||
- name: "set fact: Need telegraf install?"
|
||||
- name: "Set fact: Need telegraf install?"
|
||||
ansible.builtin.set_fact:
|
||||
need_telegraf_install: false
|
||||
when: telegraph_binary_location is defined
|
||||
@@ -71,7 +71,7 @@
|
||||
register: telegraf_binary_exists
|
||||
when: telegraph_binary_location is defined
|
||||
|
||||
- name: "set fact: Need telegraf install?"
|
||||
- name: "Set fact: Need telegraf install?"
|
||||
ansible.builtin.set_fact:
|
||||
need_telegraf_install: true
|
||||
check_mode: false
|
||||
@@ -89,7 +89,7 @@
|
||||
- not need_telegraf_install
|
||||
- telegraph_binary_location is defined
|
||||
|
||||
- name: "set fact: Need telegraf install?"
|
||||
- name: "Set fact: Need telegraf install?"
|
||||
ansible.builtin.set_fact:
|
||||
need_telegraf_install: true
|
||||
when:
|
||||
@@ -97,7 +97,7 @@
|
||||
- not need_telegraf_install
|
||||
- current_telegraf_version.stdout is version(telegraf_version, '<')
|
||||
|
||||
- name: install telegraf (MacOS)
|
||||
- name: Install telegraf (MacOS)
|
||||
community.general.homebrew:
|
||||
name: telegraf
|
||||
state: present
|
||||
@@ -106,7 +106,7 @@
|
||||
- ansible_os_family == 'Darwin'
|
||||
- need_telegraf_install
|
||||
|
||||
- name: install base apt-transport (Debian)
|
||||
- name: Install base apt-transport (Debian)
|
||||
become: true
|
||||
ansible.builtin.apt:
|
||||
pkg: apt-transport-https
|
||||
@@ -134,7 +134,7 @@
|
||||
- ansible_os_family == 'Debian'
|
||||
- need_telegraf_install
|
||||
|
||||
- name: install telegraf (Debian)
|
||||
- name: Install telegraf (Debian)
|
||||
become: true
|
||||
ansible.builtin.apt:
|
||||
pkg: telegraf
|
||||
@@ -162,7 +162,7 @@
|
||||
- name: "Install speedtest"
|
||||
when: "'pis' in group_names"
|
||||
block:
|
||||
- name: "set fact: do we need speedtest installed?"
|
||||
- name: "Set fact: do we need speedtest installed?"
|
||||
ansible.builtin.set_fact:
|
||||
need_speedtest_install: false
|
||||
|
||||
@@ -171,7 +171,7 @@
|
||||
path: /usr/local/bin/speedtest
|
||||
register: speedtest_binary_file_location
|
||||
|
||||
- name: "set fact: do we need a speedtest install"
|
||||
- name: "Set fact: do we need a speedtest install"
|
||||
ansible.builtin.set_fact:
|
||||
need_speedtest_install: true
|
||||
when:
|
||||
@@ -186,7 +186,7 @@
|
||||
when:
|
||||
- not need_speedtest_install
|
||||
|
||||
- name: "set fact: do we need a speedtest install"
|
||||
- name: "Set fact: do we need a speedtest install"
|
||||
ansible.builtin.set_fact:
|
||||
need_speedtest_install: true
|
||||
when:
|
||||
@@ -216,7 +216,7 @@
|
||||
- "{{ telegraph_config_location }}"
|
||||
- "{{ telegraph_config_location }}/telegraf.d"
|
||||
|
||||
- name: template config files to server
|
||||
- name: Template config files to server
|
||||
become: true
|
||||
ansible.builtin.template:
|
||||
src: "{{ item.src }}"
|
||||
@@ -229,7 +229,7 @@
|
||||
- { src: "telegraf/docker.conf.j2", dest: "{{ telegraph_config_location }}/telegraf.d/docker.conf" }
|
||||
notify: restart_telegraf
|
||||
|
||||
- name: template leader configs (ie, configs that should be placed on a single server)
|
||||
- name: Template leader configs (ie, configs that should be placed on a single server)
|
||||
become: true
|
||||
ansible.builtin.template:
|
||||
src: "{{ item.src }}"
|
||||
|
||||
Reference in New Issue
Block a user