mirror of
https://github.com/telekom-security/tpotce.git
synced 2025-07-02 01:27:27 -04:00
Initial commit for Open Telekom Cloud Showcase
- ECS creation via Open Telekom Cloud API - T-Pot deployment with Ansible playbook
This commit is contained in:
57
cloud/deploy_ansible_otc_t-pot.sh
Executable file
57
cloud/deploy_ansible_otc_t-pot.sh
Executable file
@ -0,0 +1,57 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Import ECS settings
|
||||
source .ecs_settings.sh
|
||||
|
||||
# Import OTC authentication credentials
|
||||
source .otc_env.sh
|
||||
|
||||
# Password is later used by Ansible
|
||||
export LINUX_PASS=$linuxpass
|
||||
|
||||
# Ignore ssh host keys as they are new anyway
|
||||
export ANSIBLE_HOST_KEY_CHECKING=False
|
||||
|
||||
# Create hosts directory
|
||||
mkdir -p hosts
|
||||
|
||||
# Create random ID
|
||||
HPNAME=t-pot-otc-$(pwgen -ns 6 -1)
|
||||
|
||||
# Get otc-tools
|
||||
echo "### Cloning otc-tools..."
|
||||
git clone https://github.com/OpenTelekomCloud/otc-tools.git 2>/dev/null
|
||||
|
||||
# Create ECS via OTC API
|
||||
echo "### Creating new ECS host via OTC API..."
|
||||
./otc-tools/otc.sh ecs create \
|
||||
--instance-type $instance\
|
||||
--instance-name $HPNAME\
|
||||
--image-name Standard_Debian_9_latest\
|
||||
--subnet-name $subnet\
|
||||
--vpc-name $vpcname\
|
||||
--security-group-name $secgroup\
|
||||
--admin-pass $linuxpass\
|
||||
--key-name $keyname\
|
||||
--public true\
|
||||
--disksize 128\
|
||||
--disktype SATA\
|
||||
--az $az\
|
||||
--wait \
|
||||
2> /dev/null
|
||||
|
||||
if [ "$(uname)" == "Darwin" ]; then
|
||||
PUBIP=$(./otc-tools/otc.sh ecs list 2>/dev/null | grep $HPNAME|cut -d "," -f2 |cut -d "\"" -f 2)
|
||||
else
|
||||
PUBIP=$(./otc-tools/otc.sh ecs list 2>/dev/null | grep $HPNAME|cut -d " " -f17)
|
||||
fi
|
||||
|
||||
echo "[TPOT]" > ./hosts/$HPNAME
|
||||
echo $PUBIP HPNAME=$HPNAME>> ./hosts/$HPNAME
|
||||
echo "### NEW HOST $HPNAME ON IP $PUBIP"
|
||||
|
||||
ansible-playbook -i ./hosts/$HPNAME ./ansible/install.yaml
|
||||
echo "***********************************************"
|
||||
echo "***** SSH TO TARGET: "
|
||||
echo "***** ssh linux@$PUBIP -p 64295"
|
||||
echo "***********************************************"
|
Reference in New Issue
Block a user