Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/vmeoc/Tito
Browse files Browse the repository at this point in the history
  • Loading branch information
ahugla committed Jan 29, 2019
2 parents 320a023 + 49298c4 commit bbd1ade
Show file tree
Hide file tree
Showing 11 changed files with 292 additions and 5 deletions.
70 changes: 70 additions & 0 deletions asset/Deployment/CloudAssembly/Tito.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
inputs:
cloud_target:
type: string
description: choix du cloud de destination
enum:
- vSphere
- AWS
- Azure
titoVersion:
type: string
description: Version de code de Tito
enum:
- V1.9.4
- V1.8.9
- V1.7.1
- v1.5
resources:
Cloud_LoadBalancer_1:
type: Cloud.LoadBalancer
properties:
name: TitoLB
routes:
- protocol: HTTP
port: '80'
instanceProtocol: HTTP
instancePort: '80'
network: '${Cloud_Network_1.name}'
instances:
- '${Cloud_Machine_1.id}'
internetFacing: true
Cloud_Machine_1:
type: Cloud.Machine
properties:
count: 2
image: ahugla-Linux
flavor: ahugla-small
sshKeyName: keyPairIreland
constraints:
- tag: 'Zone:Ireland'
- tag: 'AZ:1A'
cloudConfig: |
#cloud-config
packages:
- git
runcmd:
- rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
- rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
- yum --enablerepo=remi,remi-php72 install -y httpd php php-common
- systemctl start httpd
- systemctl enable httpd
- cd /tmp
- git clone https://github.com/vmeoc/Tito.git /var/www/html
- cd /var/www/html
- git checkout ${input.titoVersion}
name: Tito Front End
Cloud_Machine_2:
type: Cloud.Machine
properties:
image: ahugla-Linux
flavor: ahugla-small
networks:
- name: '${Cloud_Network_1.name}'
name: Tito DB
Cloud_Network_1:
type: Cloud.Network
properties:
name: MonReseau
networkType: existing
constraints:
- tag: 'Network:application'
2 changes: 1 addition & 1 deletion asset/Deployment/K8/Ingress/tito-fe-ing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ metadata:
stage: dev
spec:
rules:
- host: tito-dev.cpod-gv.shwrfr.com #set your ingress URL here
- host: tito-dev.cpod-goodvibes.az-demo.shwrfr.com #set your ingress URL here
http:
paths:
- path: /tito/*
Expand Down
4 changes: 4 additions & 0 deletions asset/Deployment/K8/Ingress/tito-fe-rc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ spec:
env:
- name: TITO_VERSION
value: V1.9.2
- name: PROXY_NAME
value: 10.100.200.144
- name: PROXY_PORT
value: "2878"
- name: POD_NAME
valueFrom:
fieldRef:
Expand Down
2 changes: 1 addition & 1 deletion asset/Deployment/K8/LB/tito-fe-rc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ spec:
- name: TITO_VERSION
value: V1.9.2
- name: PROXY_NAME
value: 10.100.200.12
value: 10.100.200.71
- name: PROXY_PORT
value: "2878"
- name: POD_NAME
Expand Down
33 changes: 33 additions & 0 deletions asset/Deployment/Terraform/AWS/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# tito Front End in Terraform

This provides a template for running Tito on Amazon Web services.

This example will also create a new EC2 Key Pair in the specified AWS Region.
The key name and path to the public key must be specified via the
terraform command vars.
Also the private key used to install the software need to be in ~/.ssh/titan_priv

After you run `terraform apply` on this configuration, it will
automatically output the URL to connect to.

To run, configure your AWS provider as described in

https://www.terraform.io/docs/providers/aws/index.html
for example export your credentials as env variables with export AWS_ACCESS_KEY_ID

Run with a command like this:

```
terraform apply -var 'key_name={your_aws_key_name}' \
-var 'public_key_path={location_of_your_key_in_your_local_machine}'
```

For example:

```
terraform apply -var 'key_name=terraform' -var 'public_key_path=/Users/jsmith/.ssh/terraform.pub'
```

TODO Later on:
add SQL
Use more Variable
152 changes: 152 additions & 0 deletions asset/Deployment/Terraform/AWS/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# Specify the provider and access details
provider "aws" {
region = "${var.aws_region}"
}

# Create a VPC to launch our instances into
resource "aws_vpc" "default" {
cidr_block = "10.0.0.0/16"
}

# Create an internet gateway to give our subnet access to the outside world
resource "aws_internet_gateway" "default" {
vpc_id = "${aws_vpc.default.id}"
}

# Grant the VPC internet access on its main route table
resource "aws_route" "internet_access" {
route_table_id = "${aws_vpc.default.main_route_table_id}"
destination_cidr_block = "0.0.0.0/0"
gateway_id = "${aws_internet_gateway.default.id}"
}

# Create a subnet to launch our instances into
resource "aws_subnet" "default" {
vpc_id = "${aws_vpc.default.id}"
cidr_block = "10.0.1.0/24"
map_public_ip_on_launch = true
}

# A security group for the ELB so it is accessible via the web
#resource "aws_security_group" "elb" {
# name = "terraform_example_elb"
# description = "Used in the terraform"
# vpc_id = "${aws_vpc.default.id}"

# HTTP access from anywhere
# ingress {
# from_port = 80
# to_port = 80
# protocol = "tcp"
# cidr_blocks = ["0.0.0.0/0"]
# }

# outbound internet access
# egress {
# from_port = 0
# to_port = 0
# protocol = "-1"
# cidr_blocks = ["0.0.0.0/0"]
# }
#}

# Our default security group to access
# the instances over SSH and HTTP
resource "aws_security_group" "default" {
name = "terraform_example"
description = "Used in the terraform"
vpc_id = "${aws_vpc.default.id}"

# SSH access from anywhere
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}

# HTTP access from the VPC
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}

# outbound internet access
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}

#resource "aws_elb" "web" {
# name = "terraform-example-elb"

# subnets = ["${aws_subnet.default.id}"]
# security_groups = ["${aws_security_group.elb.id}"]
# instances = ["${aws_instance.web.id}"]

# listener {
# instance_port = 80
# instance_protocol = "http"
# lb_port = 80
# lb_protocol = "http"
# }
#}

resource "aws_key_pair" "auth" {
key_name = "${var.key_name}"
public_key = "${file(var.public_key_path)}"
}

resource "aws_instance" "web" {
# The connection block tells our provisioner how to
# communicate with the resource (instance)
connection {
# The default username for our AMI
user = "centos"
private_key = "${file("~/.ssh/titan_priv")}"

# The connection will use the local SSH agent for authentication.
}

instance_type = "t2.micro"

# Lookup the correct AMI based on the region
# we specified
ami = "${lookup(var.aws_amis, var.aws_region)}"

# The name of our SSH keypair we created above.
key_name = "${aws_key_pair.auth.id}"

# Our Security group to allow HTTP and SSH access
vpc_security_group_ids = ["${aws_security_group.default.id}"]

# We're going to launch into the same subnet as our ELB. In a production
# environment it's more common to have a separate private subnet for
# backend instances.
subnet_id = "${aws_subnet.default.id}"

# We run a remote provisioner on the instance after creating it.
# In this case, we just install nginx and start it. By default,
# this should be on port 80
provisioner "remote-exec" {
inline = [
"sudo yum update -y",
"sudo yum install httpd -y",
"sudo yum install ansible -y",
"sudo /usr/sbin/service httpd start",
"sudo yum install php -y",
"sudo yum install php-mysql -y",
"sudo /usr/sbin/chkconfig httpd on",
"sudo yum install firewalld -y",
# "sudo service firewalld start && sudo firewall-cmd --zone=public --add-port=80/tcp --permanent && sudo firewall-cmd --zone=public --add-port=22/tcp --permanent && sudo firewall-cmd --reload",
"cd /tmp/",
"sudo curl -O https://raw.githubusercontent.com/vmeoc/Tito/master/asset/Deployment/Ansible/tito-fe-git.yml",
"sudo ansible-playbook tito-fe-git.yml -e git_url=https://github.com/vmeoc/Tito/ -e tito_release=V1.9",
]
}
}
3 changes: 3 additions & 0 deletions asset/Deployment/Terraform/AWS/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "address" {
value = "http://${aws_instance.web.public_ip}/index.php"
}
25 changes: 25 additions & 0 deletions asset/Deployment/Terraform/AWS/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
variable "public_key_path" {
description = <<DESCRIPTION
Path to the SSH public key to be used for authentication.
Ensure this keypair is added to your local SSH agent so provisioners can
connect.
Example: ~/.ssh/terraform.pub
DESCRIPTION
}

variable "key_name" {
description = "enter the key pair name"
}

variable "aws_region" {
description = "AWS region to launch servers."
default = "eu-west-1"
}

# CentOS 7
variable "aws_amis" {
default = {
eu-west-1 = "ami-693d3483"
}
}
2 changes: 1 addition & 1 deletion asset/Deployment/vRCS/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ TITO_TEMP_DIR="/tmp/"
TITO_TEMP_DIR+=$1
TITO_PROD_DIR="/home/vince/Demo/Prod/Tito/asset/Deployment/K8/Ingress"
TITO_RC="tito-fe-rc.yml"
K8_CLUSTER="gv-prod"
K8_CLUSTER="k8s-1"

echo "lancement du script clean up"
echo -n "TITO_TEMP_DIR="
Expand Down
2 changes: 1 addition & 1 deletion asset/Deployment/vRCS/tito-dev-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ TITO_GITHUB="https://github.com/vmeoc/Tito"
VERSION=$1
STAGE="dev"
TITO_CONF="Tito/asset/Deployment/K8/Ingress/"
K8_CLUSTER="gv-prod"
K8_CLUSTER="k8s-1"

echo "lancement script deploiement Tito"
echo -n "TMP_DIR= "
Expand Down
2 changes: 1 addition & 1 deletion asset/Deployment/vRCS/tito-prod-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ NEXT_LABEL="next"
NEXT_NAME="titofe-next"
TITO_VERSION=$1
TITO_PROD_DIR="/home/vince/Demo/Prod/Tito/asset/Deployment/K8/Ingress"
K8_CLUSTER="gv-prod"
K8_CLUSTER="k8s-1"

echo "lancement du script update Prod Tito"
echo -n "TITO_PROD_DIR="
Expand Down

0 comments on commit bbd1ade

Please sign in to comment.