-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add consul cluster to the HashiStack
- Loading branch information
Showing
32 changed files
with
465 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,33 @@ | ||
terraform.tfvars | ||
.terraform | ||
# Compiled files | ||
*.tfstate | ||
*.tfstate.backup | ||
*.tfstate.lock.info | ||
*.lock | ||
|
||
# Directories | ||
.terraform | ||
ignored | ||
|
||
# Ignored files | ||
*gitignore*.tf | ||
terraform.tfvars | ||
provision/compute_instance_image_source_ocid.auto.tfvars | ||
*pkrvars.hcl | ||
|
||
# Ignored Ansible files | ||
hosts.ini | ||
all | ||
|
||
**/ssh_authorized_keys.txt | ||
|
||
.DS_Store | ||
.vscode | ||
|
||
packer-manifest.json | ||
|
||
*pkrvars.hcl | ||
|
||
hosts.ini | ||
all | ||
|
||
ignored | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Consul config file | ||
|
||
datacenter = "fra" | ||
data_dir = "/opt/consul" | ||
retry_join = ["172.16.1.11", "172.16.1.12", "172.16.1.13"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[Unit] | ||
Description="HashiCorp Consul - A service mesh solution" | ||
Documentation=https://www.consul.io/ | ||
Requires=network-online.target | ||
After=network-online.target | ||
ConditionFileNotEmpty=/etc/consul.d/consul.hcl | ||
|
||
[Service] | ||
Type=notify | ||
User=consul | ||
Group=consul | ||
ExecStart=/usr/local/bin/consul agent -config-dir=/etc/consul.d/ | ||
ExecReload=/bin/kill --signal HUP $MAINPID | ||
KillMode=process | ||
KillSignal=SIGTERM | ||
Restart=on-failure | ||
LimitNOFILE=65536 | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Consul config file | ||
|
||
server = true | ||
bootstrap_expect = 3 | ||
bind_addr = "{{ GetPrivateInterfaces | include \"network\" \"172.16.1.0/24\" | attr \"address\" }}" | ||
client_addr = "{{ GetPrivateInterfaces | include \"network\" \"172.16.1.0/24\" | attr \"address\" }}" | ||
ui_config = { | ||
enabled = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# Nomad config file | ||
|
||
region = "oci.eu-frankfurt-1" | ||
datacenter = "fra" | ||
data_dir = "/opt/nomad" | ||
data_dir = "/opt/nomad" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,4 @@ server { | |
retry_join = [ "172.16.1.11", "172.16.1.12", "172.16.1.13" ] | ||
retry_max = 1 | ||
retry_interval = "15s" } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[defaults] | ||
inventory = hosts.ini | ||
host_key_checking = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
|
||
- name: 1. Prepare the Operating System | consul environment | ||
hosts: all | ||
gather_facts: True | ||
become: yes | ||
become_user: root | ||
|
||
tasks: | ||
- name: Ensure base packages are present | ||
ansible.builtin.yum: | ||
name: "{{ packages }}" | ||
state: present | ||
vars: | ||
packages: | ||
- git | ||
- tree | ||
tags: global | ||
|
||
- name: Ensure service user is present | ||
ansible.builtin.user: | ||
name: consul | ||
comment: 'consul - Ansibled' | ||
state: present | ||
tags: global, user | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
--- | ||
|
||
- name: 2. Install the software | Consul | ||
hosts: all | ||
gather_facts: True | ||
become: yes | ||
become_user: root | ||
|
||
tasks: | ||
- name: Ensure Consul directories are present | ||
ansible.builtin.file: | ||
path: "{{ item }}" | ||
state: directory | ||
mode: '0755' | ||
owner: consul | ||
group: consul | ||
with_items: | ||
- /opt/consul | ||
- /etc/consul.d | ||
tags: global | ||
|
||
- name: Ensure Consul service unit file is present | ||
ansible.builtin.copy: | ||
src: ../../_files/consul_config/consul.service | ||
dest: /etc/systemd/system/consul.service | ||
owner: root | ||
group: root | ||
mode: '0664' | ||
- name: Ensure Consul service is enabled | ||
ansible.builtin.shell: systemctl enable consul | ||
|
||
- name: Ensure Consul Configuration files are present | ||
ansible.builtin.copy: | ||
src: "{{ item }}" | ||
dest: /etc/consul.d/ | ||
mode: '744' | ||
with_items: | ||
- ../../_files/consul_config/consul.hcl | ||
- ../../_files/consul_config/server.hcl | ||
|
||
- name: Configure firewalld | Consul RPC (Client) | ||
firewalld: | ||
port: 8300/tcp | ||
permanent: yes | ||
immediate: yes | ||
state: enabled | ||
become: yes | ||
become_user: root | ||
- name: Configure firewalld | Consul GOSSIP /tcp (Serf LAN) | ||
firewalld: | ||
port: 8301/tcp | ||
permanent: yes | ||
immediate: yes | ||
state: enabled | ||
become: yes | ||
become_user: root | ||
- name: Configure firewalld | Consul GOSSIP /udp (Serf LAN) | ||
firewalld: | ||
port: 8301/udp | ||
permanent: yes | ||
immediate: yes | ||
state: enabled | ||
become: yes | ||
become_user: root | ||
- name: Configure firewalld | Consul GOSSIP /tcp (Serf WAN) | ||
firewalld: | ||
port: 8302/tcp | ||
permanent: yes | ||
immediate: yes | ||
state: enabled | ||
become: yes | ||
become_user: root | ||
- name: Configure firewalld | Consul GOSSIP /udp (Serf WAN) | ||
firewalld: | ||
port: 8302/udp | ||
permanent: yes | ||
immediate: yes | ||
state: enabled | ||
become: yes | ||
become_user: root | ||
- name: Configure firewalld | Consul HTTP API | ||
firewalld: | ||
port: 8500/tcp | ||
permanent: yes | ||
immediate: yes | ||
state: enabled | ||
become: yes | ||
become_user: root | ||
- name: Configure firewalld | Consul DNS Interface | ||
firewalld: | ||
port: 8600/tcp | ||
permanent: yes | ||
immediate: yes | ||
state: enabled | ||
become: yes | ||
become_user: root | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
|
||
- name: 3. Start service | nomad | ||
hosts: all | ||
gather_facts: True | ||
become: yes | ||
become_user: root | ||
|
||
tasks: | ||
- name: Execute collect_sar_info.sh on remote targets | ||
ansible.builtin.shell: systemctl restart consul | ||
|
||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
|
||
# This playbook install a HashiCorp consul node | ||
|
||
- name: Install consul Prereqs | ||
import_playbook: consul_1_prereq.yaml | ||
|
||
- name: Install consul | ||
import_playbook: consul_2_install.yaml | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
|
||
# This playbook install a HashiCorp nomad node | ||
|
||
- name: Install nomad Prereqs | ||
import_playbook: nomad_1_prereq.yaml | ||
|
||
- name: Install nomad | ||
import_playbook: nomad_2_install.yaml | ||
... |
Oops, something went wrong.