-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/vmeoc/Tito
- Loading branch information
Showing
11 changed files
with
292 additions
and
5 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
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' |
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,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 |
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,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", | ||
] | ||
} | ||
} |
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,3 @@ | ||
output "address" { | ||
value = "http://${aws_instance.web.public_ip}/index.php" | ||
} |
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,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" | ||
} | ||
} |
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