afinando nomad para 1 servidor e 1 cliente

This commit is contained in:
serxoz 2023-09-21 09:30:39 +02:00
parent f356504138
commit d4e350ffcd
9 changed files with 34 additions and 20 deletions

View File

@ -1,4 +1,4 @@
- name: Instala Consul - name: Instala Nomad
hosts: nomad_node hosts: nomad_node
any_errors_fatal: true any_errors_fatal: true
become: true become: true

View File

@ -0,0 +1,4 @@
---
pkg_arch_map:
aarch64: arm64
x86_64: amd64

View File

@ -0,0 +1,3 @@
---
nomad_datacenter: tr4ck
network_cidr: 192.168.1.0/24

View File

@ -5,7 +5,5 @@ nomad_data_dir: /opt/nomad
nomad_datacenter: tr4ck nomad_datacenter: tr4ck
nomad_namespaces: nomad_namespaces:
admin: - admin
name: admin - client
client:
name: client

View File

@ -16,7 +16,9 @@
state: present state: present
update_cache: yes update_cache: yes
loop: loop:
- python3-pip - tar
- unzip
- py3-pip
- nomad - nomad
become: true become: true

View File

@ -1,4 +1,9 @@
--- ---
- name: clean nomad alpine distribution config
file:
state: absent
path: /etc/nomad.d/server.hcl
- name: setup nomad server/worker config - name: setup nomad server/worker config
ansible.builtin.template: ansible.builtin.template:
src: "nomad.hcl.j2" src: "nomad.hcl.j2"

View File

@ -1,32 +1,33 @@
datacenter = "{{ nomad_datacenter }}" datacenter = "{{ nomad_datacenter }}"
data_dir = "{{ nomad_data_dir }}" data_dir = "{{ nomad_data_dir }}"
bind_addr = "{{ vm_ip }}" bind_addr = "0.0.0.0"
name = "{{ vm_name }}" name = "{{ vm_name }}"
advertise {
http = "{{ vm_ip }}"
rpc = "{{ vm_ip }}"
serf = "{{ vm_ip }}"
}
{% if 'admin' in group_names %} {% if 'admin' in group_names %}
server { server {
enabled = true enabled = true
bootstrap_expect = 3 bootstrap_expect = 1
retry_join = [{% for host in groups['admin'] %}"{{ hostvars[host]['vm_ip'] }}"{% if not loop.last %},{% endif %}{% endfor %}]
# uncoment retry_join if bootstrap_expect > 1
# retry_join = [{% for host in groups['admin'] %}"{{ hostvars[host]['vm_ip'] }}"{% if not loop.last %},{% endif %}{% endfor %}]
} }
{% endif %} {% endif %}
{% if 'client' in group_names %}
client { client {
enabled = true enabled = true
servers = [{% for host in groups['admin'] %}"{{ hostvars[host]['vm_ip'] }}"{% if not loop.last %},{% endif %}{% endfor %}]
host_network "public" { host_network "public" {
cidr = "{{ network_cidr }}" cidr = "{{ network_cidr }}"
} }
meta {
admin = {{ "1" if 'admin' in group_names else "0" }}
}
} }
{% endif %}
consul { consul {
address = "{{ vm_ip}}:8500" address = "{{ vm_ip}}:8500"
} }
plugin "docker" { plugin "docker" {
config { config {
volumes { volumes {
@ -50,6 +51,7 @@ plugin "docker" {
allow_privileged = true allow_privileged = true
} }
} }
telemetry { telemetry {
collection_interval = "1s" collection_interval = "1s"
disable_hostname = true disable_hostname = true