2022-02-16 17:56:18 +00:00
|
|
|
---
|
|
|
|
- name: Build Consul cluster
|
|
|
|
hosts: consul_instances
|
|
|
|
any_errors_fatal: true
|
|
|
|
become: true
|
|
|
|
|
|
|
|
roles:
|
|
|
|
- name: ansible-consul
|
|
|
|
consul_version: "1.11.3"
|
2022-02-27 22:49:00 +00:00
|
|
|
consul_install_remotely: true
|
2022-02-16 17:56:18 +00:00
|
|
|
consul_install_upgrade: true
|
2022-02-27 22:49:00 +00:00
|
|
|
consul_architecture_map:
|
|
|
|
x86_64: amd64
|
|
|
|
armhfv6: arm
|
|
|
|
armv7l: arm
|
|
|
|
|
2022-02-16 17:56:18 +00:00
|
|
|
# consul_tls_enable: true
|
|
|
|
consul_connect_enabled: true
|
|
|
|
consul_ports_grpc: 8502
|
|
|
|
consul_client_address: "0.0.0.0"
|
|
|
|
|
2022-03-03 17:37:49 +00:00
|
|
|
# Enable metrics
|
|
|
|
consul_config_custom:
|
|
|
|
telemetry:
|
|
|
|
prometheus_retention_time: "2h"
|
|
|
|
|
|
|
|
|
2022-02-27 22:49:00 +00:00
|
|
|
tasks:
|
|
|
|
- name: Start Consul
|
|
|
|
systemd:
|
|
|
|
state: started
|
|
|
|
name: consul
|
|
|
|
|
|
|
|
- name: Add values
|
2022-03-03 17:37:49 +00:00
|
|
|
# TODO: This can be run from localhost by using an address
|
2022-02-27 22:49:00 +00:00
|
|
|
block:
|
|
|
|
- name: Install pip
|
|
|
|
pip:
|
|
|
|
name: python-consul
|
|
|
|
|
|
|
|
- name: Add a value to Consul
|
|
|
|
consul_kv:
|
|
|
|
key: ansible_test
|
|
|
|
value: Hello from Ansible!
|
2022-03-03 17:37:49 +00:00
|
|
|
|
2022-02-27 22:49:00 +00:00
|
|
|
run_once: true
|
2022-02-16 17:56:18 +00:00
|
|
|
|
2022-02-17 22:03:42 +00:00
|
|
|
- name: Build Nomad cluster
|
2022-02-16 17:56:18 +00:00
|
|
|
hosts: nomad_instances
|
|
|
|
any_errors_fatal: true
|
|
|
|
become: true
|
|
|
|
|
|
|
|
roles:
|
|
|
|
- name: ansible-nomad
|
|
|
|
nomad_version: "1.2.6"
|
2022-02-27 22:49:00 +00:00
|
|
|
nomad_install_remotely: true
|
2022-02-16 17:56:18 +00:00
|
|
|
nomad_install_upgrade: true
|
|
|
|
nomad_allow_purge_config: true
|
2022-02-27 22:49:00 +00:00
|
|
|
|
2022-03-03 17:37:49 +00:00
|
|
|
# Properly map install arch
|
|
|
|
nomad_architecture_map:
|
|
|
|
x86_64: amd64
|
|
|
|
armhfv6: arm
|
|
|
|
armv7l: arm
|
|
|
|
|
2022-02-16 17:56:18 +00:00
|
|
|
nomad_encrypt_enable: true
|
2022-02-27 22:49:00 +00:00
|
|
|
# nomad_use_consul: true
|
|
|
|
|
2022-03-03 17:37:49 +00:00
|
|
|
# Metrics
|
|
|
|
nomad_telemetry: true
|
|
|
|
nomad_telemetry_prometheus_metrics: true
|
|
|
|
nomad_telemetry_publish_allocation_metrics: true
|
|
|
|
nomad_telemetry_publish_node_metrics: true
|
|
|
|
|
|
|
|
# Enable container plugins
|
2022-02-16 17:56:18 +00:00
|
|
|
nomad_cni_enable: true
|
2022-02-27 22:49:00 +00:00
|
|
|
nomad_cni_version: 1.0.1
|
2022-02-16 17:56:18 +00:00
|
|
|
nomad_docker_enable: true
|
2022-02-27 22:49:00 +00:00
|
|
|
nomad_docker_dmsetup: false
|
|
|
|
|
2022-03-03 17:37:49 +00:00
|
|
|
# Customize docker plugin
|
|
|
|
nomad_plugins:
|
|
|
|
docker:
|
|
|
|
config:
|
|
|
|
volumes:
|
|
|
|
enabled: true
|
|
|
|
selinuxlabel: "z"
|
|
|
|
extra_labels:
|
|
|
|
- "job_name"
|
|
|
|
- "job_id"
|
|
|
|
- "task_group_name"
|
|
|
|
- "task_name"
|
|
|
|
- "namespace"
|
|
|
|
- "node_name"
|
|
|
|
- "node_id"
|
|
|
|
|
|
|
|
# Bind nomad
|
2022-02-17 22:03:42 +00:00
|
|
|
nomad_bind_address: 0.0.0.0
|
|
|
|
|
2022-03-03 17:37:49 +00:00
|
|
|
# Create networks for binding task ports
|
2022-02-17 22:03:42 +00:00
|
|
|
nomad_host_networks:
|
|
|
|
- name: nomad-bridge
|
|
|
|
interface: nomad
|
|
|
|
reserved_ports: "22"
|
|
|
|
- name: loopback
|
|
|
|
interface: lo
|
|
|
|
reserved_ports: "22"
|
2022-03-03 17:37:49 +00:00
|
|
|
|
2022-02-27 22:49:00 +00:00
|
|
|
tasks:
|
|
|
|
- name: Start Nomad
|
|
|
|
systemd:
|
|
|
|
state: started
|
|
|
|
name: nomad
|