Skip to content

Commit

Permalink
neet to
Browse files Browse the repository at this point in the history
  • Loading branch information
117thDragon committed Nov 13, 2023
1 parent 1d9f0f5 commit 923caee
Show file tree
Hide file tree
Showing 17 changed files with 425 additions and 0 deletions.
210 changes: 210 additions & 0 deletions VPN/cloud-bastion.ovpn
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
#{
# "version": 1,
# "user": "test",
# "organization": "otus",
# "server": "bastion",
# "wg": false,
# "user_id": "653640609f34682cc289f2a6",
# "organization_id": "653640609f34682cc289f29e",
# "server_id": "653640989f34682cc289f2e9",
# "server_public_key": [
# "-----BEGIN RSA PUBLIC KEY-----",
# "MIICCgKCAgEAvH1qyp0WcENJj82dqp6rLYrHWL09WIhPf9IDeZMJab9QRGIX+PV+",
# "lVIeuJrnK8ubSWOMQEHDLm6Wlk5qfidYHkeYtzNGt8ozzcN6alB93buGYwNM8Wso",
# "MwdnPv/ENsEUf+XKJO+xh+eiRzEHL5b6klzy6Z4zeTVGbTZ1Puh+Jfsrv2ws7l1Y",
# "1py9vRDrmvU3q4SJmaLfUESZVsF7M3DhPMXvR1rWB9uF2v/2NCiKbqwKBcHEGZ0P",
# "A1OD+dcYfJGM66xXxEHKHTg4GHhUFQ1lb7LFt9iq2Y3vsUvxL/cl4FX9SH+Vt9Vg",
# "x0tKNKO9TsDJWC8GTt4e92CArJHzipFacO/+TgfOP/YGkChamfqzn4f8J+Di7FWN",
# "YYy3/xAdEeq7kTs/YtrBWRcUD2kRwMH8OXmwAY4JLuvwFbx4H4hz7EO4hhAt1jvL",
# "2XOu7RsKS4cW4QX0JXp/2KDMFWHt5oLduA0zJ3NQI9cRWlGNiqj8nYPJx8ZGHmIx",
# "CTwm1gJk6TIiq+qWi53x+uZNhTE7X0B3sLv/YntsAURsvy58LtKC7B4PLG8bFuvq",
# "Yksc2NzHY1GATkf293MhBOpXo+ahA135xEEcRYxlY0FLe5qwzu8DKK7ecsCbI600",
# "g+MDrIjSJXRTvLEBvYoZQ8X7jMqjUE7vzYUGdeQAKL5d53w2zCGIJmUCAwEAAQ==",
# "-----END RSA PUBLIC KEY-----"
# ],
# "server_box_public_key": "hxABB6G0nWtCS1QcZAsIOURmR+Rdqa2PvXBs0F8+Q1U=",
# "sync_hosts": [
# "https://158.160.127.176"
# ],
# "sync_hash": "d3f72d07671be799688f5068695483dc",
# "dynamic_firewall": false,
# "device_auth": false,
# "sso_auth": false,
# "password_mode": "pin",
# "push_auth": false,
# "push_auth_ttl": 2592000,
# "disable_reconnect": false,
# "token_ttl": 2592000,
# "token": true,
# "sync_token": "i37vOC16qM4WpGdcBc71ilj8vF7vMFhG",
# "sync_secret": "aJm5hZk0obOV2epSEF8QvRflTafmxTFn"
#}
setenv UV_ID fde688af91724ff0b82c66870cd45dbe
setenv UV_NAME patient-forest-8309
client
dev tun
dev-type tun
remote 158.160.127.176 15386 udp
nobind
persist-tun
cipher AES-128-CBC
auth SHA1
verb 2
mute 3
push-peer-info
ping 10
ping-restart 60
hand-window 70
server-poll-timeout 4
reneg-sec 2592000
sndbuf 393216
rcvbuf 393216
remote-cert-tls server
comp-lzo no
auth-user-pass
key-direction 1
<ca>
-----BEGIN CERTIFICATE-----
MIIFcTCCA1mgAwIBAgIIZsqit080PyswDQYJKoZIhvcNAQELBQAwRjEhMB8GA1UE
CgwYNjUzNjQwNjA5ZjM0NjgyY2MyODlmMjllMSEwHwYDVQQDDBg2NTM2NDA2MDlm
MzQ2ODJjYzI4OWYyOWYwHhcNMjMxMDIzMDk0NDAwWhcNNDMxMDE4MDk0NDAwWjBG
MSEwHwYDVQQKDBg2NTM2NDA2MDlmMzQ2ODJjYzI4OWYyOWUxITAfBgNVBAMMGDY1
MzY0MDYwOWYzNDY4MmNjMjg5ZjI5ZjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCC
AgoCggIBAL36hjWGa1nZ02eOZQxd/1WPf3ROJVCLbTZwQBPnGn/VKsNuigp5wZ+C
ow9MLVb7vb6lcxAcJDK4nauUrNm5zKbkZA4F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Wp3b1AnwLVbIyGDk5MtAaRZzAlV4RJwx5VtF7V7sQnpql9zHo3WdJI
FDyDQbyTQFcnI48rM8g0UwWsBF5VxO3I36JF/5hKOOBPk7DNwWu/fF25/MYvnOCf
NAKJWSDxcmwojipbR0699PHKIUIsSjhZDZlmUgIXYps5MgvrQwvtp+C9JE49s9n3
NakpUAlYC9kwhQdhW6Uj+qfbHQVK3z4rpjEYUV6hvN6f6Plv+6XziFyPGSlq678L
J0jZDUFB+obBR30S1sdek8CZ7MTngE+G96o0TsTUFBsbN4cPJqyOe5A/AWAFeAXA
o5pigi6ouhxxh4qhqKhJJcNC4NAPUHbbVT/G4kGdDHVaPmDZZOjT1DpXVdPP4DHa
y6nphi8=
-----END CERTIFICATE-----
</ca>
<tls-auth>
#
# 2048 bit OpenVPN static key
#
-----BEGIN OpenVPN Static key V1-----
33dee8999f8bf7448111d7f288e082d4
5e534d50386743f08f031f41dcacd978
b8eb7b87b73970a668cc44634bfd40fa
c322f847e1c76af4c9e0d051dd5eb01e
8c12d9fe06ad8e613c847d900fb53e1e
f1d916c6d17cfc35b5232b248e5fa36d
a96fbf0059fcce9da55808a101b89615
9867c42c68634f2ef1e9e66d8d3dda19
34cea54e14f9876847c14c19e7c7c32c
0329b9b20a4022c830978647688875b5
06f7b971b6b499d5d8ea34cd1020c6ec
808abb45c4dbf26b8812ea3e9f1b57c3
341152561a4e58874f61f84fc8ff9cdb
cf48b6ff4d63ef480ceebc12a55c222f
f190b52e7fc8101bdbf49d0e823650ff
ba86daadfe56998f4795541b6ac7320a
-----END OpenVPN Static key V1-----
</tls-auth>
<cert>
-----BEGIN CERTIFICATE-----
MIIFgDCCA2igAwIBAgIIZdXit05kQHMwDQYJKoZIhvcNAQELBQAwRjEhMB8GA1UE
CgwYNjUzNjQwNjA5ZjM0NjgyY2MyODlmMjllMSEwHwYDVQQDDBg2NTM2NDA2MDlm
MzQ2ODJjYzI4OWYyOWYwHhcNMjMxMDIzMDk0NDAxWhcNNDMxMDE4M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WEjeO69m
r23TmjhqDDPKHc7IP+N94/Y2SzmYoyPGSowoQ7oCXY5HzTILYUuw7CvtlPfMZ+s2
pLbXWeQ3XF2ESeFpjBnwAjPwa+rukha55EDEN5IRl/RECc9sMWPzxPiMPUtwUDFA
k9XWApMDso/vvkUQ6k8RTPjXDSxS0Rt3O23T36+NOXGUYIJltT7KgydRF/kU3fDT
oRh9In4yWID5cTLTpUAlnkcvzJxp/pe2JVDQFbg+6AQQD9tohFtvS4Pcif+bu7xu
he8HFLbLBBvkffN0p85Gu2xPXx2Soq8T661XYQQuKLF5qEDeYIUoozdtsLqbdA8O
R9sCggEAdpRdGhbxMEJ1NhSl5tQKySVWfvMVvfCIlQgqbMBiUx2ZSAKLVLPzzeN2
v+aateyVWL4Ik/chQHzTrF1zCd1oYCpl7psNRqeO1Nm94M1GyVMulOTQMyP3OVhI
QzIEQuJiBqzHC3SM4jBz55Ky1R28HGXMisf+kIcIVcjUiHDqaakIUYiEE26v3UV9
IbSMSNir0aVauqxe6Ml88yGIfKp6fEFBbRjvpEMI0Iq+olf7EyB5+RLr3wp9QO2s
/8QHgnSjBVNC/68VNWrnhRYT7X4zolrF8KRrZTCWTRrtzcAvrx8osfhHQTADWXzM
wFhntNBwEJjYa8EOkPVsezyBoEfvzQ==
-----END PRIVATE KEY-----
</key>
0 setupvpn.sh → VPN/setupvpn.sh
100644 → 100755
File renamed without changes.
6 changes: 6 additions & 0 deletions config-scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

sudo apt install git
git clone -b monolith https://github.com/express42/reddit.git
cd reddit && bundle install
puma -
4 changes: 4 additions & 0 deletions config-scripts/install_mongodb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

sudo apt install mongodb -y
sudo systemctl start mongodb && sudo systemctl enable mongod
3 changes: 3 additions & 0 deletions config-scripts/install_ruby.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

sudo apt update && sudo apt install -y ruby-full ruby-bundler build-essential
35 changes: 35 additions & 0 deletions config-scripts/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#cloud-config

users:
- name: yc-user
groups: sudo
shell: /bin/bash
sudo: 'ALL=(ALL) NOPASSWD:ALL'
ssh_authorized_keys:
- "ssh-rsa
AAAAB3NzaC1yc2EAAAADAQABAAABgQCaxRF9+4AAxAyhz6yE7riFxZyx4j+f5emRxDXw9+DzQMa0q8xp9ic6a55eYGKnNdyexn3NXQ31FDghbRw1SvzjdQeKWRDwUWA1GMcqMIApG5ogcG2cLk9igaaIrT0drJrjj9iShAvifc3ufOzCjNogao5t4U9r81twnwcPQlK6hIk/5GFhwe+JDyFTEyxYEZPR0NWlN/2frboQrRDCjKm4ttESRZUaYKz/gRzE/XSkL3JHv3eWMxrSNvYzWTeLWKE64ufG+QX7UC2Dr2t/NfOrXCU3X+g5ho70rWGY7Bv5lW+Q98Kvbbroln4MSbnPxVn/SaWE20eZX+P+Np4npOlgIdV+xhtKRUNYtFKHOAS7GB6TfY/4Jsbr2F3KVlPAi7O+Yk7AAIuNLdmdbbwiHOG5Ff94zikyyUQ3sIZhpgZU4nqfTx4yV1jbXDcu7SIqM0zhwf8+9cCK1JV1L7JAJpWV5ZbCb+NXRyQyupTQcGYE0JQ/UF9TsIicfPUlM1+u1PM=
appuser"

package_update: true

packages:
- ruby-full
- ruby-bundler
- build-essential
- mongodb
- git

write_files:
- path: /home/yc-user/startup_script.sh
permissions: "755"
content: |
#!/bin/bash
sleep 10
sudo systemctl start mongodb
sudo systemctl enable mongodb
sudo git clone -b monolith https://github.com/express42/reddit.git
cd reddit && bundle install
puma -d
runcmd:
- /home/yc-user/startup_script.sh
11 changes: 11 additions & 0 deletions config-scripts/metadata_reddit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#cloud-config

users:
- name: appuser
groups: sudo
shell: /bin/bash
sudo: 'ALL=(ALL) NOPASSWD:ALL'
ssh_authorized_keys:
- "ssh-rsa
AAAAB3NzaC1yc2EAAAADAQABAAABgQCaxRF9+4AAxAyhz6yE7riFxZyx4j+f5emRxDXw9+DzQMa0q8xp9ic6a55eYGKnNdyexn3NXQ31FDghbRw1SvzjdQeKWRDwUWA1GMcqMIApG5ogcG2cLk9igaaIrT0drJrjj9iShAvifc3ufOzCjNogao5t4U9r81twnwcPQlK6hIk/5GFhwe+JDyFTEyxYEZPR0NWlN/2frboQrRDCjKm4ttESRZUaYKz/gRzE/XSkL3JHv3eWMxrSNvYzWTeLWKE64ufG+QX7UC2Dr2t/NfOrXCU3X+g5ho70rWGY7Bv5lW+Q98Kvbbroln4MSbnPxVn/SaWE20eZX+P+Np4npOlgIdV+xhtKRUNYtFKHOAS7GB6TfY/4Jsbr2F3KVlPAi7O+Yk7AAIuNLdmdbbwiHOG5Ff94zikyyUQ3sIZhpgZU4nqfTx4yV1jbXDcu7SIqM0zhwf8+9cCK1JV1L7JAJpWV5ZbCb+NXRyQyupTQcGYE0JQ/UF9TsIicfPUlM1+u1PM=
appuser"
10 changes: 10 additions & 0 deletions config-scripts/startup_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

yc compute instance create \
--name reddit-app \
--hostname reddit-app \
--memory=4 \
--create-boot-disk image-folder-id=standard-images,image-family=ubuntu-1604-lts,size=10GB \
--network-interface subnet-name=default-ru-central1-a,nat-ip-version=ipv4 \
--metadata-from-file user-data=metadata.yaml \
--metadata serial-port-enable=1
12 changes: 12 additions & 0 deletions packer/files/puma.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=puma
After=network.target

[Service]
Type=simple
WorkingDirectory=/home/ubuntu/reddit
ExecStart=/usr/local/bin/puma
Restart=always

[Install]
WantedBy=multi-user.target
56 changes: 56 additions & 0 deletions packer/imutable.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"builders": [
{
"type": "yandex",
"service_account_key_file": "/home/admins/otus/secrets/key.json",
"folder_id": "b1g9rbhfq6ba8dfpgv37",
"subnet_id": "e9bmh97l31novt99ndqb",
"zone": "ru-central1-a",
"use_ipv4_nat": true,
"source_image_family": "ubuntu-1604-lts",
"image_name": "reddit-full-{{timestamp}}",
"image_family": "reddit-full",
"ssh_username": "ubuntu",
"platform_id": "standard-v1",
"disk_size_gb": "10"
}
],
"provisioners": [
{
"type": "shell",
"inline": [
"echo Waiting for apt-get to finish...",
"a=1; while [ -n \"$(pgrep apt-get)\" ]; do echo $a; sleep 1s; a=$(expr $a + 1); done",
"echo Done."
]
},
{
"type": "shell",
"script": "scripts/install_ruby.sh",
"execute_command": "sudo {{.Path}}"
},
{
"type": "shell",
"script": "scripts/install_mongodb.sh",
"execute_command": "sudo {{.Path}}"
},
{
"type": "shell",
"script": "scripts/install_reddit.sh",
"execute_command": "sudo {{.Path}}"
},
{
"type": "file",
"source": "files/puma.service",
"destination": "/tmp/puma.service"
},
{
"type": "shell",
"inline": [
"sudo mv /tmp/puma.service /etc/systemd/system/puma.service",
"sudo systemctl daemon-reload",
"sudo systemctl enable puma",
"sudo systemctl start puma"]
}
]
}
8 changes: 8 additions & 0 deletions packer/key.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"id": "********************",
"service_account_id": "********************",
"created_at": "2023-10-29T00:09:57.955124849Z",
"key_algorithm": "RSA_2048",
"public_key": "-----BEGIN PUBLIC KEY-----\n********************\n-----END PUBLIC KEY-----\n",
"private_key": "PLEASE DO NOT REMOVE THIS LINE! Yandex.Cloud SA Key ID \n********************\n-----END PRIVATE KEY-----\n"
}
10 changes: 10 additions & 0 deletions packer/scripts/install_mongodb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

wget -qO - https://www.mongodb.org/static/pgp/server-3.2.asc | sudo apt-key add -
echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.2.list

apt-get update
apt-get install -y mongodb-org

systemctl start mongod
systemctl enable mongod
5 changes: 5 additions & 0 deletions packer/scripts/install_reddit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apt-get update
apt-get install -y git
git clone -b monolith https://github.com/express42/reddit.git
cd reddit && bundle install
puma -d
5 changes: 5 additions & 0 deletions packer/scripts/install_ruby.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
apt-get update
apt-get install -y ruby-full ruby-bundler build-essential
4 changes: 4 additions & 0 deletions packer/scripts/puma_service.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mv /tmp/puma.service /etc/systemd/system/puma.service
systemctl enable puma
systemctl start puma
systemctl daemon-reload
Loading

0 comments on commit 923caee

Please sign in to comment.