2022-02-16 17:56:18 +00:00
|
|
|
SERVER ?= "192.168.2.41"
|
|
|
|
SSH_USER = iamthefij
|
|
|
|
SSH_KEY = ~/.ssh/id_ed25519
|
|
|
|
|
|
|
|
.PHONY: rm-nomad
|
|
|
|
rm-nomad:
|
|
|
|
hashi-up nomad uninstall \
|
|
|
|
--ssh-target-addr $(SERVER) \
|
|
|
|
--ssh-target-key $(SSH_KEY) \
|
|
|
|
--ssh-target-user $(SSH_USER) \
|
|
|
|
--ssh-target-sudo-pass $(SSH_TARGET_SUDO_PASS)
|
|
|
|
|
2022-02-17 22:03:42 +00:00
|
|
|
.PHONY: nomad-up
|
|
|
|
nomad-up:
|
2022-02-16 17:56:18 +00:00
|
|
|
hashi-up nomad install \
|
|
|
|
--ssh-target-addr $(SERVER) \
|
|
|
|
--ssh-target-key $(SSH_KEY) \
|
|
|
|
--ssh-target-user $(SSH_USER) \
|
|
|
|
--ssh-target-sudo-pass $(SSH_TARGET_SUDO_PASS) \
|
|
|
|
--server --client
|
2022-02-17 22:03:42 +00:00
|
|
|
hashi-up nomad start \
|
|
|
|
--ssh-target-addr $(SERVER) \
|
|
|
|
--ssh-target-key $(SSH_KEY) \
|
|
|
|
--ssh-target-user $(SSH_USER) \
|
|
|
|
--ssh-target-sudo-pass $(SSH_TARGET_SUDO_PASS)
|
2022-02-16 17:56:18 +00:00
|
|
|
|
|
|
|
.PHONY: rm-consul
|
|
|
|
rm-consul:
|
|
|
|
hashi-up consul uninstall \
|
|
|
|
--ssh-target-addr $(SERVER) \
|
|
|
|
--ssh-target-key $(SSH_KEY) \
|
|
|
|
--ssh-target-user $(SSH_USER) \
|
|
|
|
--ssh-target-sudo-pass $(SSH_TARGET_SUDO_PASS)
|
|
|
|
|
2022-02-17 22:03:42 +00:00
|
|
|
.PHONY: consul-up
|
|
|
|
consul-up:
|
2022-02-16 17:56:18 +00:00
|
|
|
hashi-up consul install \
|
|
|
|
--ssh-target-addr $(SERVER) \
|
|
|
|
--ssh-target-key $(SSH_KEY) \
|
|
|
|
--ssh-target-user $(SSH_USER) \
|
|
|
|
--ssh-target-sudo-pass $(SSH_TARGET_SUDO_PASS) \
|
2022-02-17 22:03:42 +00:00
|
|
|
--advertise-addr $(SERVER) \
|
|
|
|
--client-addr 0.0.0.0 \
|
|
|
|
--http-addr 0.0.0.0 \
|
2022-02-16 17:56:18 +00:00
|
|
|
--connect \
|
|
|
|
--server
|
2022-02-17 22:03:42 +00:00
|
|
|
hashi-up consul start \
|
|
|
|
--ssh-target-addr $(SERVER) \
|
|
|
|
--ssh-target-key $(SSH_KEY) \
|
|
|
|
--ssh-target-user $(SSH_USER) \
|
|
|
|
--ssh-target-sudo-pass $(SSH_TARGET_SUDO_PASS)
|
2022-02-16 17:56:18 +00:00
|
|
|
|
|
|
|
.PHONY: cluster
|
2022-05-18 21:22:21 +00:00
|
|
|
cluster: ansible-cluster
|
2022-02-17 22:03:42 +00:00
|
|
|
|
2022-02-27 22:49:00 +00:00
|
|
|
venv/bin/ansible:
|
|
|
|
python3 -m venv venv
|
|
|
|
./venv/bin/pip install ansible
|
2022-03-12 18:07:52 +00:00
|
|
|
./venv/bin/pip install python-consul
|
2022-02-27 22:49:00 +00:00
|
|
|
|
2022-02-17 22:03:42 +00:00
|
|
|
.PHONY: ansible-cluster
|
2022-02-27 22:49:00 +00:00
|
|
|
ansible-cluster: venv/bin/ansible
|
2022-03-12 18:07:52 +00:00
|
|
|
./venv/bin/ansible-galaxy install -p roles -r roles/requirements.yml
|
2022-05-25 03:07:52 +00:00
|
|
|
env VIRTUAL_ENV=/Users/ifij/workspace/iamthefij/orchestration-tests/nomad/venv ./venv/bin/ansible-playbook -K -vv \
|
2022-05-25 03:09:16 +00:00
|
|
|
$(shell test -f vault-keys.json && echo '-e "@vault-keys.json"') \
|
2022-03-15 18:57:00 +00:00
|
|
|
-i ansible_hosts.yml -M ./roles ./setup-cluster.yml
|
2022-02-16 17:56:18 +00:00
|
|
|
|
|
|
|
.PHONY: plan
|
|
|
|
plan:
|
2022-05-25 03:09:16 +00:00
|
|
|
@terraform plan \
|
|
|
|
-var "nomad_secret_id=$(shell jq -r .SecretID nomad_bootstrap.json)" \
|
|
|
|
-var "vault_token=$(shell jq -r .root_token vault-keys.json)"
|
2022-02-16 17:56:18 +00:00
|
|
|
|
|
|
|
.PHONY: apply
|
|
|
|
apply:
|
2022-05-25 03:09:16 +00:00
|
|
|
@terraform apply \
|
|
|
|
-var "nomad_secret_id=$(shell jq -r .SecretID nomad_bootstrap.json)" \
|
|
|
|
-var "vault_token=$(shell jq -r .root_token vault-keys.json)"
|
2022-02-16 17:56:18 +00:00
|
|
|
|
|
|
|
# Install CNI on hosts?
|
|
|
|
# curl -L -o cni-plugins.tgz "https://github.com/containernetworking/plugins/releases/download/v1.0.0/cni-plugins-linux-$( [ $(uname -m) = aarch64 ] && echo arm64 || echo amd64)"-v1.0.0.tgz
|
|
|
|
# sudo mkdir -p /opt/cni/bin
|
|
|
|
# sudo tar -C /opt/cni/bin -xzf cni-plugins.tgz
|