Moved ssh and redis tunneling from knox to beacon

This commit is contained in:
Amritanshu Agrawal 2022-04-26 09:03:10 +05:30
parent 09a8fdfecc
commit f9124abb6c
5 changed files with 30 additions and 55 deletions

View File

@ -24,8 +24,14 @@ curl --silent 'https://git.tanshu.com/tanshu/barker/raw/tag/latest/barker/pyproj
cd "$parent_path/docker/app" || exit
docker build --tag barker:latest .
if [ 1 -eq "$#" ]
then
docker tag barker:latest "$1"
else
echo "No version bump"
fi
cd "$parent_path/docker" || exit
docker save barker:latest | bzip2 | pv | ssh tanshu@knox.tanshu.com 'bunzip2 | sudo docker load'
ansible-playbook --limit=knox playbook-mhl.yml
ansible-playbook --limit=knox playbook-chd.yml
ansible-playbook --limit=knox playbook-pkl.yml
docker save barker:latest | bzip2 | pv | ssh tanshu@beacon.tanshu.com 'bunzip2 | sudo docker load'
ansible-playbook --limit=beacon playbook-mhl.yml
ansible-playbook --limit=beacon playbook-chd.yml
ansible-playbook --limit=beacon playbook-pkl.yml

View File

@ -59,15 +59,15 @@
line: "{{ peitho_key }}"
when: peithokey_test.stdout == "0"
- name: Check Knox public key
shell: "grep -c \"{{ knox_key }}\" /home/pi/.ssh/authorized_keys || true"
register: knoxkey_test
- name: Check Beacon public key
shell: "grep -c \"{{ beacon_key }}\" /home/pi/.ssh/authorized_keys || true"
register: beaconkey_test
- name: Add Knox public key
lineinfile:
dest: /home/pi/.ssh/authorized_keys
line: "{{ knox_key }}"
when: knoxkey_test.stdout == "0"
line: "{{ beacon_key }}"
when: beaconkey_test.stdout == "0"
- name: Check Buttercup public key
shell: "grep -c \"{{ buttercup_key }}\" /home/pi/.ssh/authorized_keys || true"
@ -146,34 +146,34 @@
groups: lp
append: yes
- name: install knox-redis-tunnel systemd unit file
- name: install beacon-redis-tunnel systemd unit file
template:
src: "files/knox-redis-tunnel.service"
dest: "/etc/systemd/system/knox-redis-tunnel.service"
src: "files/beacon-redis-tunnel.service"
dest: "/etc/systemd/system/beacon-redis-tunnel.service"
- name: enable service knox-redis-tunnel and ensure it is not masked
- name: enable service beacon-redis-tunnel and ensure it is not masked
systemd:
name: knox-redis-tunnel
name: beacon-redis-tunnel
enabled: yes
masked: no
- name: Make sure knox-redis-tunnel service is running
- name: Make sure beacon-redis-tunnel service is running
systemd:
state: started
name: knox-redis-tunnel
name: beacon-redis-tunnel
- name: install gotthard systemd unit file
- name: install leardal systemd unit file
template:
src: "files/gotthard.service"
dest: "/etc/systemd/system/gotthard.service"
src: "files/leardal.service"
dest: "/etc/systemd/system/leardal.service"
- name: enable service gotthard and ensure it is not masked
- name: enable service leardal and ensure it is not masked
systemd:
name: gotthard
name: leardal
enabled: yes
masked: no
- name: Make sure gotthard service is running
- name: Make sure leardal service is running
systemd:
state: started
name: gotthard
name: leardal

View File

@ -1,16 +0,0 @@
[Unit]
Description=Reverse SSH connection
After=network.target
[Service]
Type=simple
User=pi
ExecStart=/usr/bin/ssh -NTg -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -o ServerAliveCountMax=3 -o StrictHostKeyChecking=no -i /home/pi/.ssh/id_rsa -R {{ ssh_port }}:localhost:22 tanshu@knox.tanshu.com
# Restart every >2 seconds to avoid StartLimitInterval failure
Restart=always
RestartSec=5s
[Install]
WantedBy=default.target

View File

@ -1,15 +0,0 @@
[Unit]
Description=Keep ssh tunnel to specified remote host open
After=network.target
[Service]
User=pi
ExecStart=/usr/bin/ssh -NT -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -o ServerAliveCountMax=3 -o StrictHostKeyChecking=no -i /home/pi/.ssh/id_rsa -L 6379:localhost:6379 tanshu@knox.tanshu.com
# Restart every >2 seconds to avoid StartLimitInterval failure
RestartSec=5
Restart=always
[Install]
WantedBy=multi-user.target

View File

@ -2,5 +2,5 @@
hostname: "pkl3"
ssh_port: "22243"
peitho_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCrT4geK0hUTc/3NDVt0g3DZwdOg2dRq4MbNdVvmRVsJHXRXWkyehzDVTRmxxmUvPZgy20Qg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