This commit is contained in:
aynic.os
2021-06-06 16:29:54 +02:00
parent 85ffdb7096
commit 3a9ddae015
26 changed files with 183 additions and 158 deletions
+2 -2
View File
@@ -7,7 +7,7 @@ SSH_PUBLIC_HOST_KEYS ?= $(SSH_REMOTE_HOSTS) $(SSH_BASTION_HOSTNAME)
SSH_PRIVATE_IP_RANGE ?= 10.10.*
SSH_REMOTE_HOSTS ?= github.com gitlab.com
# function ssh-connect: Exec command on remote hosts with tty
# function ssh-connect: Exec command 2 on remote hosts 1 with tty
define ssh-connect
$(eval hosts := $(1))
$(eval command := $(2))
@@ -16,7 +16,7 @@ define ssh-connect
$(foreach host,$(hosts),$(call exec,ssh -t -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $(user)@$(host) "$(command)") ||) true
endef
# function ssh-exec: Exec command on remote hosts without tty
# function ssh-exec: Exec command 2 on remote hosts 1 without tty
define ssh-exec
$(eval hosts := $(1))
$(eval command := $(2))
+14 -10
View File
@@ -1,22 +1,26 @@
##
# SSH
# target ssh: Call ssh-connect with command SHELL
.PHONY: ssh
ssh: aws-ec2-get-PrivateIpAddress-$(SERVER_NAME) ## Connect to first remote host
$(call ssh-connect,$(AWS_INSTANCE_IP),$(SHELL))
# target get-PrivateIpAddress-%: Fire aws-ec2-get-instances-PrivateIpAddress-%
.PHONY: get-PrivateIpAddress-%
get-PrivateIpAddress-%: aws-ec2-get-instances-PrivateIpAddress-%;
# target ssh-connect: Call ssh-connect with command make connect
# target ssh: Call ssh-connect ARGS or SHELL
.PHONY: ssh
ssh: get-PrivateIpAddress-$(SERVER_NAME) ## Connect to first remote host
$(call ssh-connect,$(AWS_INSTANCE_IP),$(if $(ARGS),$(ARGS),$(SHELL)))
# target ssh-connect: Call ssh-connect make connect SERVICE
.PHONY: ssh-connect
ssh-connect: aws-ec2-get-PrivateIpAddress-$(SERVER_NAME)
ssh-connect: get-PrivateIpAddress-$(SERVER_NAME)
$(call ssh-connect,$(AWS_INSTANCE_IP),make connect $(if $(SERVICE),SERVICE=$(SERVICE)))
# target ssh-connect: Call ssh-connect with command make exec
# target ssh-exec: Call ssh-exec make exec SERVICE ARGS
.PHONY: ssh-exec
ssh-exec: aws-ec2-get-PrivateIpAddress-$(SERVER_NAME)
ssh-exec: get-PrivateIpAddress-$(SERVER_NAME)
$(call ssh-exec,$(AWS_INSTANCE_IP),make exec $(if $(SERVICE),SERVICE=$(SERVICE)) $(if $(ARGS),ARGS='\''"$(ARGS)"'\''))
# target ssh-run: Call ssh-connect with command make run
# target ssh-run: Call ssh-run make run SERVICE ARGS
.PHONY: ssh-run
ssh-run: aws-ec2-get-PrivateIpAddress-$(SERVER_NAME)
ssh-run: get-PrivateIpAddress-$(SERVER_NAME)
$(call ssh-exec,$(AWS_INSTANCE_IP),make run $(if $(SERVICE),SERVICE=$(SERVICE)) $(if $(ARGS),ARGS='\''"$(ARGS)"'\''))