Skip to content

Commit

Permalink
boot version
Browse files Browse the repository at this point in the history
  • Loading branch information
npeditto committed Oct 27, 2021
1 parent 9b974e9 commit 28aa6e8
Show file tree
Hide file tree
Showing 40 changed files with 4,711 additions and 0 deletions.
22 changes: 22 additions & 0 deletions 0-CA/ca_create
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#! /bin/bash

BIT_ENC=2048
CA_NAME="SmartME" #same for Organization Name
EXPIRATION=18250



mkdir -p ./CA
cd ./CA

## Generate root CA key
openssl genrsa -out $CA_NAME"_CA.key" $BIT_ENC

#check
openssl rsa -in $CA_NAME"_CA.key" -check

## Generate root CA certificate
openssl req -x509 -new -nodes -key $CA_NAME"_CA.key" -sha256 -days $EXPIRATION -subj "/C=IT/O="$CA_NAME -out $CA_NAME"_CA.pem"

#check
openssl x509 -in $CA_NAME"_CA.pem" -text -noout
37 changes: 37 additions & 0 deletions 0-CA/client_cert
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#! /bin/bash

if [ "$#" -ne 1 ]; then
echo "Usage: ./client_cert <CLIENT-CN>"
exit
fi

#$1 -> CN == certificate name
BIT_ENC=2048
CA_NAME="SmartME" #same for Organization Name
EXPIRATION=18250



mkdir -p "./client_"$1
cd "./client_"$1

## Generate client key
openssl genrsa -out $1".key" $BIT_ENC

## Generate client certificate request
openssl req -new -days $EXPIRATION -subj "/C=IT/O="$CA_NAME"/CN="$1 -key $1".key" -out $1".csr"

#check
openssl req -text -noout -verify -in $1".csr"


## Generate client certificate
openssl x509 -req -in $1".csr" -CA "../CA/"$CA_NAME"_CA.pem" -CAkey "../CA/"$CA_NAME"_CA.key" -CAcreateserial -out $1".pem" -days $EXPIRATION -sha256

#check
openssl x509 -in $1".pem" -text -noout

chmod 644 $1".key"

cp ../CA/$CA_NAME"_CA.pem" CA.pem

35 changes: 35 additions & 0 deletions 0-docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#! /bin/bash

if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi

apt-get update && apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"

apt-get update && apt-get install -y docker-ce docker-ce-cli containerd.io

usermod -aG docker $USER
usermod -aG docker iotronic

systemctl enable docker

curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

docker network create iotronic_network

echo -e "\e[32mCompleted - Log out and log back in so that your group membership is re-evaluated.\e[0m"
27 changes: 27 additions & 0 deletions 1-mysql/1-mysql
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#! /bin/bash


#if [ "$EUID" -ne 0 ]
# then echo "Please run as root"
# exit
#fi

MYSQL_ROOT_PASSWORD="smartme"


docker create \
--name=felooca_test_iotronic_db\
--network=felooca_test_network \
-p 53306:3306 \
--restart unless-stopped\
-e MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD \
-v felooca_test_iotronic_db_data:/var/lib/mysql \
-v felooca_test_iotronic_db_config:/etc/mysql \
mariadb:focal

docker cp create_dbs.sql felooca_test_iotronic_db:/docker-entrypoint-initdb.d/create_dbs.sql
docker cp 99-openstack.conf felooca_test_iotronic_db:/etc/mysql/mariadb.conf.d/99-openstack.cnf

docker start felooca_test_iotronic_db

echo -e "\e[32mCompleted but wait mariadb to be ready using docker logs -f felooca_test_iotronic_db\e[0m"
8 changes: 8 additions & 0 deletions 1-mysql/99-openstack.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[mysqld]
bind-address = 0.0.0.0

default-storage-engine = innodb
innodb_file_per_table = on
max_connections = 4096
collation-server = utf8_general_ci
character-set-server = utf8
9 changes: 9 additions & 0 deletions 1-mysql/create_dbs.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CREATE DATABASE keystone;
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY 'KEYSTONE_DBPASS';
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' IDENTIFIED BY 'KEYSTONE_DBPASS';
CREATE DATABASE iotronic;
GRANT ALL PRIVILEGES ON iotronic.* TO 'iotronic'@'localhost' IDENTIFIED BY 'IOTRONIC_DBPASS';
GRANT ALL PRIVILEGES ON iotronic.* TO 'iotronic'@'%' IDENTIFIED BY 'IOTRONIC_DBPASS';
CREATE DATABASE designate;
GRANT ALL PRIVILEGES ON designate.* TO 'designate'@'localhost' IDENTIFIED BY 'DESIGNATE_DBPASS';
GRANT ALL PRIVILEGES ON designate.* TO 'designate'@'%' IDENTIFIED BY 'DESIGNATE_DBPASS';
6 changes: 6 additions & 0 deletions 1-mysql/create_dbs_FELOOCA_TEST.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CREATE DATABASE felooca_test_keystone;
GRANT ALL PRIVILEGES ON felooca_test_keystone.* TO 'fe_t_keystone'@'localhost' IDENTIFIED BY 'f3l00caTEST';
GRANT ALL PRIVILEGES ON felooca_test_keystone.* TO 'fe_t_keystone'@'%' IDENTIFIED BY 'f3l00caTEST';
CREATE DATABASE felooca_test_iotronic;
GRANT ALL PRIVILEGES ON felooca_test_iotronic.* TO 'fe_t_iotronic'@'localhost' IDENTIFIED BY 'f3l00caTEST';
GRANT ALL PRIVILEGES ON felooca_test_iotronic.* TO 'fe_t_iotronic'@'%' IDENTIFIED BY 'f3l00caTEST';
22 changes: 22 additions & 0 deletions 1-rabbitmq
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#! /bin/bash


#if [ "$EUID" -ne 0 ]
# then echo "Please run as root"
# exit
#cfi

RABBIT_PASS="smartme"

docker run -d \
--name=felooca_test_rabbitmq\
-p 5672:5672 \
--network=host \
--restart unless-stopped \
rabbitmq:3

sleep 30
docker exec felooca_test_rabbitmq rabbitmqctl add_user openstack $RABBIT_PASS
docker exec felooca_test_rabbitmq rabbitmqctl set_permissions openstack ".*" ".*" ".*"

echo -e "\e[32mCompleted \e[0m"
57 changes: 57 additions & 0 deletions 2-keystone/2-keystone
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#! /bin/bash


#if [ "$EUID" -ne 0 ]
# then echo "Please run as root"
# exit
#fi

VERSION=1.0

HOST="felooca-test-ctrl.smartme.io"
HTTPS=true
ADMIN_PASS="smartme"

OS_AUTH_URL="http://$HOST:5000/v3"
if [ "$HTTPS" = true ] ; then
OS_AUTH_URL="https://$HOST:5000/v3"
fi

echo $OS_AUTH_URL
file="conf/adminrc"

sed -i "s|OS_AUTH_URL=.*|OS_AUTH_URL=$OS_AUTH_URL|g" $file
sed -i "s|OS_PASSWORD=.*|OS_PASSWORD=$ADMIN_PASS|g" $file

echo -e "\e[32mThis is your adminrc file\n\n"

while IFS= read -r line
do
printf 'export %s\n' "$line"
done <"$file"

echo -e "\e[0m"

docker create \
--env-file conf/adminrc \
--name=felooca_test_keystone \
--restart unless-stopped\
--network=felooca_test_network \
-p 5001:5000 \
-v felooca_test_keystone_config:/etc/keystone/ \
-v felooca_test_keystone_data:/var/lib/keystone/ \
-v /var/log/keystone:/var/log/keystone \
-v /var/log/keystone-api:/var/log/apache2 \
smartmeio/keystone-stain:$VERSION


docker cp conf/keystone.conf felooca_test_keystone:/etc/keystone/

docker run --rm \
-v /var/log/keystone:/var/log/keystone \
-v /var/log/keystone-api:/var/log/apache2 \
smartmeio/keystone-stain:$VERSION \
/bin/sh -c "chown -R keystone:keystone /var/log/keystone/"

docker start felooca_test_keystone

35 changes: 35 additions & 0 deletions 2-keystone/2.5-keystone
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#! /bin/bash

HOST="felooca-test-ctrl.smartme.io"
HTTPS=true
ADMIN_PASS="smartme"

URL="http://$HOST:5000/v3"
if [ "$HTTPS" = true ] ; then
URL="https://$HOST:5000/v3"
fi

echo $URL

docker exec felooca_test_keystone /bin/sh -c "keystone-manage db_sync" keystone
echo "db_sync"
docker exec felooca_test_keystone keystone-manage fernet_setup --keystone-user keystone --keystone-group keystone
echo "fernet_setup"
docker exec felooca_test_keystone keystone-manage credential_setup --keystone-user keystone --keystone-group keystone
echo "credential_setup"


docker exec felooca_test_keystone keystone-manage bootstrap --bootstrap-password $ADMIN_PASS \
--bootstrap-admin-url $URL \
--bootstrap-internal-url $URL \
--bootstrap-public-url $URL \
--bootstrap-region-id RegionOne

echo "bootstrap"

docker restart felooca_test_keystone
echo "restarting in 5 seconds"
sleep 5

docker exec felooca_test_keystone openstack project create --domain default --description "Service Project" service
echo "project created"
21 changes: 21 additions & 0 deletions 2-keystone/build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM ubuntu:bionic
#ENV VERSION=2.3.9

RUN apt-get update \
&& apt-get install nocache -y software-properties-common \
&& add-apt-repository -y cloud-archive:stein \
&& apt-get update && apt-get -y dist-upgrade && apt-get install nocache -y python3-openstackclient nano iputils-ping net-tools

RUN apt-get install nocache keystone -y

RUN mkdir -p /var/log/keystone \
&& touch /var/log/keystone/keystone-manage.log \
&& touch /var/log/keystone/keystone-wsgi-public.log \
&& touch /var/log/keystone/keystone.log \
&& chown -R keystone:keystone /var/log/keystone/

VOLUME ["/etc/keystone"]
VOLUME ["/var/log/keystone"]

EXPOSE 5000
CMD ["/usr/sbin/apache2ctl", "-D","FOREGROUND"]
4 changes: 4 additions & 0 deletions 2-keystone/build/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#! /bin/bash

VERSION=1.0
docker build -t smartmeio/keystone-stain:$VERSION .
8 changes: 8 additions & 0 deletions 2-keystone/conf/adminrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
OS_PROJECT_DOMAIN_NAME=Default
OS_USER_DOMAIN_NAME=Default
OS_PROJECT_NAME=admin
OS_USERNAME=admin
OS_PASSWORD=smartme
OS_AUTH_URL=https://felooca-test-ctrl.smartme.io:5000/v3
OS_IDENTITY_API_VERSION=3
OS_IMAGE_API_VERSION=2
Loading

0 comments on commit 28aa6e8

Please sign in to comment.