-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve docs with latest changes (#134)
* Add varios scripts to improve ansible workflow * Fix text * Fix var * Update settings * Changed references of 0.0.x to master * Start docker containers on reboot (#128) * Changed script to down and timeout only for one second, added restart always * Added tool terraform-do-uashield (#122) * added tool terraform-do-uashield * added readme * Changed script to restart always and don't wait too much on docker compose down Co-authored-by: Roman Demachkovych <[email protected]> Co-authored-by: adam <[email protected]> * Create README.MD Co-authored-by: Denys Butenko <[email protected]> Co-authored-by: vtinkerer <[email protected]> Co-authored-by: rdemachkovych <[email protected]> Co-authored-by: Roman Demachkovych <[email protected]>
- Loading branch information
1 parent
4b0184b
commit d5d1389
Showing
23 changed files
with
256 additions
and
24 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
version: '3' | ||
services: | ||
uashield: | ||
image: ghcr.io/opengs/uashield:0.0.x | ||
image: ghcr.io/opengs/uashield:master | ||
restart: always | ||
environment: | ||
WORKERS: '512' | ||
WORKERS: '256' | ||
USEPROXY: 'false' | ||
deploy: | ||
replicas: 6 | ||
replicas: 3 | ||
|
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,7 @@ | ||
# COMMUNITY CREATED | ||
|
||
Fortunately or unfortunately these tools are created by community. | ||
|
||
They can be not up to date, but we are trying our best. | ||
|
||
If you see any issue - make an issue or contact us via Discord. |
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,5 @@ | ||
[defaults] | ||
deprecation_warnings=False | ||
host_key_checking=False | ||
strategy=linear ; default | ||
; strategy=free ; do not wait for complete all hosts |
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,18 @@ | ||
#!/bin/bash | ||
# Usage example | ||
# ./create-vm.sh eastus2 | ||
|
||
# Variables | ||
INPUT=$1 | ||
LOCATION="${INPUT:-'norwayeast'}" | ||
RESOURCE_GROUP='STOPWAR' | ||
USER='azureuser' | ||
IMAGE='UbuntuLTS' | ||
for i in {1..4} | ||
do | ||
NAME=uashield-$LOCATION-unit-$i | ||
echo "$NAME : Initializing vm..." | ||
az vm create --admin-user=$USER --location=$LOCATION --name $NAME --resource-group $RESOURCE_GROUP --image $IMAGE --generate-ssh-keys | ||
done | ||
|
||
bash ./update-hosts.sh |
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,6 +1,6 @@ | ||
- name: Get stats | ||
shell: echo $(docker logs uashield | grep '| 200' -c) | ||
shell: echo $(docker ps -q | xargs -L 1 docker logs | grep '| 200' -c) | ||
register: echo_content | ||
|
||
- debug: | ||
msg: "Hits {{ echo_content.stdout }} requests." | ||
msg: "Hit {{ echo_content.stdout }} requests." |
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,30 +1,52 @@ | ||
--- | ||
- name: Clone uashield repo | ||
- name: Check if repo is exist | ||
stat: | ||
path: "{{uashield_work_dir}}" | ||
failed_when: false | ||
changed_when: false | ||
register: check_uashield_repo | ||
|
||
- name: Clone repo | ||
git: | ||
repo: "{{uashield_git_url}}" | ||
dest: "{{uashield_work_dir}}" | ||
accept_hostkey: true | ||
force: true | ||
version: "master" | ||
when: not check_uashield_repo.stat.exists | ||
|
||
- name: Stop all containers | ||
shell: "docker-compose down" | ||
- name: Pull Latest Changes | ||
shell: "git pull" | ||
args: | ||
chdir: "{{uashield_work_dir}}" | ||
when: check_uashield_repo.stat.exists | ||
|
||
- name: Get Running Docker Containers | ||
shell: "docker ps -aq" | ||
register: docker_info | ||
|
||
- name: Stop Running Docker Containers | ||
shell: "docker stop $(docker ps -aq)" | ||
when: docker_info.stdout | ||
|
||
- name: Remove Docker Containers | ||
shell: "docker rm $(docker ps -aq)" | ||
when: docker_info.stdout | ||
|
||
- name: Remove old uashield images | ||
- name: Remove Old Docker Image | ||
shell: "docker rmi -f uashield" | ||
|
||
- name: Run uashield | ||
shell: "docker-compose up -d" | ||
- name: Build Docker Image | ||
shell: "docker build . -t uashield" | ||
args: | ||
chdir: "{{uashield_work_dir}}" | ||
|
||
- name: Check docker started | ||
shell: "docker ps" | ||
args: | ||
chdir: "{{uashield_work_dir}}" | ||
- name: Run Instance | ||
shell: "docker run -d uashield {{ uashield_threads }} {{ uashield_proxy }}" | ||
|
||
- name: Check Docker is started | ||
command: "docker ps" | ||
register: output | ||
|
||
- ansible.builtin.debug: | ||
var: output | ||
var: output.stdout_lines |
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,5 +1,7 @@ | ||
--- | ||
- hosts: servers | ||
strategy: linear | ||
gather_facts: no | ||
become: yes | ||
become_user: root | ||
vars_files: | ||
|
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,14 @@ | ||
#!/bin/bash | ||
|
||
PUBLIC_IP_ADDRESSES="$(az vm list-ip-addresses --query '[*].virtualMachine.network.publicIpAddresses[0].ipAddress' | sed '1d;$d' | cut -d'"' -f2)" | ||
for IP in $PUBLIC_IP_ADDRESSES | ||
do | ||
EXIST="$(cat hosts | awk '{print $1}' | grep $IP)" | ||
if [ "$EXIST" == "$IP" ] | ||
then | ||
echo "[Skipping] $IP already exist" | ||
else | ||
echo $IP >> hosts | ||
echo "[Changed] $IP is added to hosts" | ||
fi | ||
done |
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 @@ | ||
--- | ||
- hosts: servers | ||
become: yes | ||
become_user: root | ||
vars_files: | ||
- vars/vars.yaml | ||
roles: | ||
- uashield | ||
handlers: | ||
- include: handlers/main.yml |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
[![DigitalOcean Referral Badge](https://web-platforms.sfo2.cdn.digitaloceanspaces.com/WWW/Badge%201.svg)](https://www.digitalocean.com/?refcode=4e29ef6429c9&utm_campaign=Referral_Invite&utm_medium=Referral_Program&utm_source=badge) | ||
|
||
[Get $100 to try DigitalOcean, link for sing in above](https://try.digitalocean.com/freetrialoffer/) | ||
|
||
|
||
## Requirements | ||
- [Instal terraform](https://www.terraform.io/downloads) | ||
- [Add SSH key](https://docs.digitalocean.com/products/droplets/how-to/add-ssh-keys/to-account/) to DO with name `ssh` | ||
|
||
|
||
## Export environment vars | ||
Extra logs | ||
``` | ||
export TF_LOG=INFO | ||
``` | ||
## Create and export DO PAT | ||
- [DO PAT](https://docs.digitalocean.com/reference/api/create-personal-access-token/) | ||
``` | ||
export DO_PAT="<your_pat>" | ||
``` | ||
## Init terraform | ||
``` | ||
terraform init | ||
``` | ||
|
||
``` | ||
terraform apply \ | ||
-var "do_token=${DO_PAT}" \ | ||
-var "pvt_key=$HOME/.ssh/id_ed25519" | ||
``` | ||
|
||
``` | ||
terraform destroy \ | ||
-var "do_token=${DO_PAT}" \ | ||
-var "pvt_key=$HOME/.ssh/id_ed25519" | ||
``` |
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,16 @@ | ||
terraform { | ||
required_providers { | ||
digitalocean = { | ||
source = "digitalocean/digitalocean" | ||
version = "~> 2.0" | ||
} | ||
} | ||
} | ||
|
||
provider "digitalocean" { | ||
token = var.do_token | ||
} | ||
|
||
data "digitalocean_ssh_key" "ssh" { | ||
name = "drvdo" | ||
} |
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,39 @@ | ||
#!/bin/sh | ||
|
||
sudo apt-get install -y \ | ||
ca-certificates \ | ||
curl \ | ||
gnupg \ | ||
lsb-release \ | ||
wget | ||
|
||
curl -sSL https://repos.insights.digitalocean.com/install.sh | sudo bash | ||
|
||
wget -O - https://get.docker.com/ | bash | ||
|
||
sudo systemctl enable docker.service | ||
sudo systemctl start docker.service | ||
|
||
mkdir -p ~/.docker/cli-plugins/ | ||
curl -SL https://github.com/docker/compose/releases/download/v2.2.3/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose | ||
chmod +x ~/.docker/cli-plugins/docker-compose | ||
sudo chown $USER /var/run/docker.sock | ||
|
||
sudo echo " | ||
version: \"3.3\" | ||
services: | ||
worker: | ||
image: ghcr.io/opengs/uashield:latest | ||
restart: always | ||
command: | ||
- \"7500\" | ||
- \"true\"" >> /home/docker-compose.yaml | ||
|
||
sudo apt install -y docker-compose | ||
|
||
cd /home/ | ||
|
||
sudo docker-compose pull && sudo docker-compose up -d --scale worker=$(grep -c ^processor /proc/cpuinfo) | ||
|
||
sudo echo "*/30 * * * * cd /home/ && sudo docker-compose down -t 1 && sudo docker-compose pull && sudo docker-compose up -d --scale worker=$(grep -c ^processor /proc/cpuinfo)" >> /home/cronjob | ||
crontab /home/cronjob |
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,33 @@ | ||
resource "digitalocean_droplet" "uashield" { | ||
count = var.droplet_instance_number | ||
image = "ubuntu-20-04-x64" | ||
name = "uashield-${count.index}" | ||
region = "nyc3" | ||
size = var.droplet_instance_size | ||
monitoring = true | ||
|
||
ssh_keys = [ | ||
data.digitalocean_ssh_key.ssh.id | ||
] | ||
|
||
connection { | ||
host = self.ipv4_address | ||
user = "root" | ||
type = "ssh" | ||
private_key = file(var.pvt_key) | ||
timeout = "2m" | ||
} | ||
|
||
provisioner "file" { | ||
source = "scripts/uashield.sh" | ||
destination = "/opt/uashield.sh" | ||
} | ||
|
||
provisioner "remote-exec" { | ||
inline = [ | ||
"chmod +x /opt/uashield.sh", | ||
"/opt/uashield.sh", | ||
] | ||
} | ||
} | ||
|
Oops, something went wrong.