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,62 +1,72 @@
--- ---
all: all:
children: hosts:
servers: n1.thefij:
vars: nomad_node_class: ingress
nomad_network_interface: eth0 nomad_reserved_memory: 1024
hosts: # nomad_meta:
n1.thefij: # hw_transcode.device: /dev/dri
nomad_node_role: both # hw_transcode.type: intel
nomad_reserved_memory: 1024 nfs_mounts:
# nomad_meta: - src: 10.50.250.2:/srv/volumes
# hw_transcode.device: /dev/dri path: /srv/volumes/moxy
# hw_transcode.type: intel opts: proto=tcp,rw
nfs_mounts: nomad_unique_host_volumes:
- src: 10.50.250.2:/srv/volumes - name: mysql-data
path: /srv/volumes/moxy path: /srv/volumes/mysql
opts: proto=tcp,rw owner: "999"
nomad_unique_host_volumes: group: "100"
- name: mysql-data mode: "0755"
path: /srv/volumes/mysql read_only: false
owner: "999" - name: postgres-data
group: "100" path: /srv/volumes/postgres
mode: "0755" owner: "999"
read_only: false group: "999"
- name: postgres-data mode: "0755"
path: /srv/volumes/postgres read_only: false
owner: "999" n2.thefij:
group: "999" nomad_node_class: ingress
mode: "0755" nomad_reserved_memory: 1024
read_only: false nfs_mounts:
n2.thefij: - src: 10.50.250.2:/srv/volumes
nomad_node_role: both path: /srv/volumes/moxy
nomad_node_class: ingress opts: proto=tcp,rw
nomad_reserved_memory: 1024 nomad_unique_host_volumes:
nfs_mounts: - name: nextcloud-data
- src: 10.50.250.2:/srv/volumes path: /srv/volumes/nextcloud
path: /srv/volumes/moxy owner: "root"
opts: proto=tcp,rw group: "bin"
nomad_unique_host_volumes: mode: "0755"
- name: nextcloud-data read_only: false
path: /srv/volumes/nextcloud pi4:
owner: "root" nomad_node_class: ingress
group: "bin" nomad_reserved_memory: 512
mode: "0755" nomad_meta:
read_only: false hw_transcode.device: /dev/video11
pi4: hw_transcode.type: raspberry
nomad_node_role: both qnomad.thefij:
nomad_node_class: ingress ansible_host: 192.168.2.234
nomad_reserved_memory: 512 nomad_reserved_memory: 1024
nomad_meta: # This VM uses a non-standard interface
hw_transcode.device: /dev/video11 nomad_network_interface: ens3
hw_transcode.type: raspberry
qnomad.thefij:
ansible_host: 192.168.2.234
nomad_node_role: both
nomad_reserved_memory: 1024
# This VM uses a non-standard interface
nomad_network_interface: ens3
nomad_instances: nomad_instances:
children: vars:
servers: {} nomad_network_interface: eth0
children:
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