Update Ansible inventory to split node roles

Splits servers and clients to their own groups so that plays can target
specific roles.

Prior, everything was "both", but i want to and another server for
recovery purposes but not host containers on it.
This commit is contained in:
IamTheFij 2024-04-27 20:10:23 -07:00 committed by Ian Fijolek
parent c711c25737
commit 57efee14e9
4 changed files with 75 additions and 64 deletions

View File

@ -1,12 +1,8 @@
--- ---
all: all:
children:
servers:
vars:
nomad_network_interface: eth0
hosts: hosts:
n1.thefij: n1.thefij:
nomad_node_role: both nomad_node_class: ingress
nomad_reserved_memory: 1024 nomad_reserved_memory: 1024
# nomad_meta: # nomad_meta:
# hw_transcode.device: /dev/dri # hw_transcode.device: /dev/dri
@ -29,7 +25,6 @@ all:
mode: "0755" mode: "0755"
read_only: false read_only: false
n2.thefij: n2.thefij:
nomad_node_role: both
nomad_node_class: ingress nomad_node_class: ingress
nomad_reserved_memory: 1024 nomad_reserved_memory: 1024
nfs_mounts: nfs_mounts:
@ -44,7 +39,6 @@ all:
mode: "0755" mode: "0755"
read_only: false read_only: false
pi4: pi4:
nomad_node_role: both
nomad_node_class: ingress nomad_node_class: ingress
nomad_reserved_memory: 512 nomad_reserved_memory: 512
nomad_meta: nomad_meta:
@ -52,11 +46,27 @@ all:
hw_transcode.type: raspberry hw_transcode.type: raspberry
qnomad.thefij: qnomad.thefij:
ansible_host: 192.168.2.234 ansible_host: 192.168.2.234
nomad_node_role: both
nomad_reserved_memory: 1024 nomad_reserved_memory: 1024
# This VM uses a non-standard interface # This VM uses a non-standard interface
nomad_network_interface: ens3 nomad_network_interface: ens3
nomad_instances: nomad_instances:
vars:
nomad_network_interface: eth0
children: children:
servers: {} nomad_servers: {}
nomad_clients: {}
nomad_servers:
hosts:
nonopi.thefij:
ansible_host: 192.168.2.170
n1.thefij: {}
n2.thefij: {}
pi4: {}
qnomad.thefij: {}
nomad_clients:
hosts:
n1.thefij: {}
n2.thefij: {}
pi4: {}
qnomad.thefij: {}

View File

@ -14,7 +14,7 @@
state: restarted state: restarted
become: true become: true
- name: Start Dockee - name: Start Docker
systemd: systemd:
name: docker name: docker
state: started state: started

View File

@ -1,6 +1,6 @@
--- ---
- name: Recover Nomad - name: Recover Nomad
hosts: nomad_instances hosts: nomad_servers
any_errors_fatal: true any_errors_fatal: true
tasks: tasks:

View File

@ -14,7 +14,7 @@
line: "nameserver {{ non_nomad_dns }}" line: "nameserver {{ non_nomad_dns }}"
- name: Install Docker - name: Install Docker
hosts: nomad_instances hosts: nomad_clients
become: true become: true
vars: vars:
docker_architecture_map: docker_architecture_map:
@ -44,7 +44,7 @@
# state: present # state: present
- name: Create NFS mounts - name: Create NFS mounts
hosts: nomad_instances hosts: nomad_clients
become: true become: true
vars: vars:
shared_nfs_mounts: shared_nfs_mounts:
@ -140,6 +140,7 @@
nomad_version: "1.7.6-1" nomad_version: "1.7.6-1"
nomad_install_upgrade: true nomad_install_upgrade: true
nomad_allow_purge_config: true nomad_allow_purge_config: true
nomad_node_role: "{% if 'nomad_clients' in group_names %}{% if 'nomad_servers' in group_names %}both{% else %}client{% endif %}{% else %}server{% endif %}"
# Where nomad gets installed to # Where nomad gets installed to
nomad_bin_dir: /usr/bin nomad_bin_dir: /usr/bin
@ -213,7 +214,7 @@
enabled: true enabled: true
- name: Bootstrap Nomad ACLs and scheduler - name: Bootstrap Nomad ACLs and scheduler
hosts: nomad_instances hosts: nomad_servers
tasks: tasks:
- name: Start Nomad - name: Start Nomad