Created
December 7, 2018 17:56
-
-
Save dassio/c814835627e67ad0f82fd231b47a22c1 to your computer and use it in GitHub Desktop.
Onos test cell setup with AWS for ubuntu 16
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
{ | |
"AWSTemplateFormatVersion" : "2010-09-09", | |
"Description" : "AWS CloudFormation Sample Template VPC_Single_Instance_In_Subnet: Sample template showing how to create a VPC and add an EC2 instance with an Elastic IP address and a security group. **WARNING** This template creates an Amazon EC2 instance. You will be billed for the AWS resources used if you create a stack from this template.", | |
"Parameters" : { | |
"InstanceType" : { | |
"Description" : "Onos Instance", | |
"Type" : "String", | |
"Default" : "t2.medium", | |
"AllowedValues" : [ "t2.medium"], | |
"ConstraintDescription" : "must be a valid EC2 instance type." | |
}, | |
"KeyName": { | |
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instance", | |
"Type": "AWS::EC2::KeyPair::KeyName", | |
"Default" : "onos-germany", | |
"ConstraintDescription" : "must be the name of an existing EC2 KeyPair." | |
}, | |
"SSHLocation" : { | |
"Description" : " The IP address range that can be used to SSH to the EC2 instances", | |
"Type": "String", | |
"MinLength": "9", | |
"MaxLength": "18", | |
"Default": "0.0.0.0/0", | |
"AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})", | |
"ConstraintDescription": "must be a valid IP CIDR range of the form x.x.x.x/x." | |
} | |
}, | |
"Mappings": { | |
"AWSInstanceType2Ubuntu": { | |
"t2.medium": {"Ubuntu": "HVM64"} | |
}, | |
"AWSRegionUbuntu2AMI": { | |
"eu-west-1": { | |
"HVM64": "ami-09f0b8b3e41191524" | |
}, | |
"eu-west-2": { | |
"HVM64": "ami-0f60b09eab2ef8366" | |
}, | |
"eu-west-3": { | |
"HVM64": "ami-02fa733c4a3cb19de" | |
}, | |
"eu-central-1": { | |
"HVM64": "ami-0cfc1cd9ab351357c" | |
} | |
} | |
}, | |
"Resources" : { | |
"VPC" : { | |
"Type" : "AWS::EC2::VPC", | |
"Properties" : { | |
"CidrBlock" : "192.168.0.0/16", | |
"Tags": [ | |
{ | |
"Key": "Name", | |
"Value": "Onos Network" | |
} | |
] | |
} | |
}, | |
"PulicSubnet" : { | |
"Type" : "AWS::EC2::Subnet", | |
"Properties" : { | |
"VpcId" : { "Ref" : "VPC" }, | |
"CidrBlock" : "192.168.55.0/24", | |
"Tags": [ | |
{ | |
"Key": "Name", | |
"Value": "Public Network" | |
} | |
] | |
} | |
}, | |
"PrivateSubnet" : { | |
"Type" : "AWS::EC2::Subnet", | |
"Properties" : { | |
"VpcId" : { "Ref" : "VPC" }, | |
"CidrBlock" : "192.168.56.0/24", | |
"Tags": [ | |
{ | |
"Key": "Name", | |
"Value": "Private Network" | |
} | |
] | |
} | |
}, | |
"InternetGateway" : { | |
"Type" : "AWS::EC2::InternetGateway", | |
"Properties" : {} | |
}, | |
"AttachGateway" : { | |
"Type" : "AWS::EC2::VPCGatewayAttachment", | |
"Properties" : { | |
"VpcId" : { "Ref" : "VPC" }, | |
"InternetGatewayId" : { "Ref" : "InternetGateway" } | |
} | |
}, | |
"NAT" : { | |
"DependsOn" : "AttachGateway", | |
"Type" : "AWS::EC2::NatGateway", | |
"Properties" : { | |
"AllocationId" : { "Fn::GetAtt" : ["NATEIP", "AllocationId"]}, | |
"SubnetId" : { "Ref" : "PulicSubnet"}, | |
"Tags": [ | |
{ | |
"Key": "Name", | |
"Value": "onos-private-nat-gateway" | |
} | |
] | |
} | |
}, | |
"NATEIP" : { | |
"Type" : "AWS::EC2::EIP", | |
"Properties" : { | |
"Domain" : "vpc" | |
} | |
}, | |
"PublicRouteTable" : { | |
"Type" : "AWS::EC2::RouteTable", | |
"Properties" : { | |
"VpcId" : {"Ref" : "VPC"}, | |
"Tags": [ | |
{ | |
"Key": "Name", | |
"Value": "Public Route Table" | |
} | |
] | |
} | |
}, | |
"PrivateRouteTable" : { | |
"Type" : "AWS::EC2::RouteTable", | |
"Properties" : { | |
"VpcId" : {"Ref" : "VPC"}, | |
"Tags": [ | |
{ | |
"Key": "Name", | |
"Value": "Private Route Table" | |
} | |
] | |
} | |
}, | |
"PublicRoute" : { | |
"Type" : "AWS::EC2::Route", | |
"DependsOn" : "AttachGateway", | |
"Properties" : { | |
"RouteTableId" : { "Ref" : "PublicRouteTable" }, | |
"DestinationCidrBlock" : "0.0.0.0/0", | |
"GatewayId" : { "Ref" : "InternetGateway" } | |
} | |
}, | |
"PrivateRoute" : { | |
"Type" : "AWS::EC2::Route", | |
"Properties" : { | |
"RouteTableId" : { "Ref" : "PrivateRouteTable" }, | |
"DestinationCidrBlock" : "0.0.0.0/0", | |
"NatGatewayId" : { "Ref" : "NAT" } | |
} | |
}, | |
"PublicSubnetRouteTableAssociation" : { | |
"Type" : "AWS::EC2::SubnetRouteTableAssociation", | |
"Properties" : { | |
"SubnetId" : { "Ref" : "PulicSubnet" }, | |
"RouteTableId" : { "Ref" : "PublicRouteTable" } | |
} | |
}, | |
"PrivateSubnetRouteTableAssociation" : { | |
"Type" : "AWS::EC2::SubnetRouteTableAssociation", | |
"Properties" : { | |
"SubnetId" : { "Ref" : "PrivateSubnet" }, | |
"RouteTableId" : { "Ref" : "PrivateRouteTable" } | |
} | |
}, | |
"NetworkAcl" : { | |
"Type" : "AWS::EC2::NetworkAcl", | |
"Properties" : { | |
"VpcId" : {"Ref" : "VPC"}, | |
"Tags": [ | |
{ | |
"Key": "Name", | |
"Value": "Public subnet ACL" | |
} | |
] | |
} | |
}, | |
"InboundHTTPNetworkAclEntry" : { | |
"Type" : "AWS::EC2::NetworkAclEntry", | |
"Properties" : { | |
"NetworkAclId" : {"Ref" : "NetworkAcl"}, | |
"RuleNumber" : "100", | |
"Protocol" : "6", | |
"RuleAction" : "allow", | |
"Egress" : "false", | |
"CidrBlock" : "0.0.0.0/0", | |
"PortRange" : {"From" : "80", "To" : "80"} | |
} | |
}, | |
"InboundSSHNetworkAclEntry" : { | |
"Type" : "AWS::EC2::NetworkAclEntry", | |
"Properties" : { | |
"NetworkAclId" : {"Ref" : "NetworkAcl"}, | |
"RuleNumber" : "101", | |
"Protocol" : "6", | |
"RuleAction" : "allow", | |
"Egress" : "false", | |
"CidrBlock" : "0.0.0.0/0", | |
"PortRange" : {"From" : "22", "To" : "22"} | |
} | |
}, | |
"InboundResponsePortsNetworkAclEntry" : { | |
"Type" : "AWS::EC2::NetworkAclEntry", | |
"Properties" : { | |
"NetworkAclId" : {"Ref" : "NetworkAcl"}, | |
"RuleNumber" : "102", | |
"Protocol" : "6", | |
"RuleAction" : "allow", | |
"Egress" : "false", | |
"CidrBlock" : "0.0.0.0/0", | |
"PortRange" : {"From" : "1024", "To" : "65535"} | |
} | |
}, | |
"OutBoundHTTPNetworkAclEntry" : { | |
"Type" : "AWS::EC2::NetworkAclEntry", | |
"Properties" : { | |
"NetworkAclId" : {"Ref" : "NetworkAcl"}, | |
"RuleNumber" : "100", | |
"Protocol" : "6", | |
"RuleAction" : "allow", | |
"Egress" : "true", | |
"CidrBlock" : "0.0.0.0/0", | |
"PortRange" : {"From" : "80", "To" : "80"} | |
} | |
}, | |
"OutBoundHTTPSNetworkAclEntry" : { | |
"Type" : "AWS::EC2::NetworkAclEntry", | |
"Properties" : { | |
"NetworkAclId" : {"Ref" : "NetworkAcl"}, | |
"RuleNumber" : "101", | |
"Protocol" : "6", | |
"RuleAction" : "allow", | |
"Egress" : "true", | |
"CidrBlock" : "0.0.0.0/0", | |
"PortRange" : {"From" : "443", "To" : "443"} | |
} | |
}, | |
"OutBoundResponsePortsNetworkAclEntry" : { | |
"Type" : "AWS::EC2::NetworkAclEntry", | |
"Properties" : { | |
"NetworkAclId" : {"Ref" : "NetworkAcl"}, | |
"RuleNumber" : "102", | |
"Protocol" : "6", | |
"RuleAction" : "allow", | |
"Egress" : "true", | |
"CidrBlock" : "0.0.0.0/0", | |
"PortRange" : {"From" : "1024", "To" : "65535"} | |
} | |
}, | |
"InboundICMP" : { | |
"Type" : "AWS::EC2::NetworkAclEntry", | |
"Properties" : { | |
"NetworkAclId" : {"Ref" : "NetworkAcl"}, | |
"RuleNumber" : "103", | |
"Icmp" : {"Code" : -1,"Type" : -1}, | |
"Protocol" : "1", | |
"RuleAction" : "allow", | |
"Egress" : "false", | |
"CidrBlock" : "0.0.0.0/0", | |
"PortRange" : {"From" : "0", "To" : "65535"} | |
} | |
}, | |
"OutboundICMP" : { | |
"Type" : "AWS::EC2::NetworkAclEntry", | |
"Properties" : { | |
"NetworkAclId" : {"Ref" : "NetworkAcl"}, | |
"RuleNumber" : "103", | |
"Icmp" : {"Code" : -1,"Type" : -1}, | |
"Protocol" : "1", | |
"RuleAction" : "allow", | |
"Egress" : "true", | |
"CidrBlock" : "0.0.0.0/0", | |
"PortRange" : {"From" : "0", "To" : "65535"} | |
} | |
}, | |
"SubnetNetworkAclAssociation" : { | |
"Type" : "AWS::EC2::SubnetNetworkAclAssociation", | |
"Properties" : { | |
"SubnetId" : { "Ref" : "PublicSubnet" }, | |
"NetworkAclId" : { "Ref" : "NetworkAcl" } | |
} | |
}, | |
"OnosNetworkAcl" : { | |
"Type" : "AWS::EC2::NetworkAcl", | |
"Properties" : { | |
"VpcId" : {"Ref" : "VPC"}, | |
"Tags": [ | |
{ | |
"Key": "Name", | |
"Value": "private subnet ACL" | |
} | |
] | |
} | |
}, | |
"TCPAllPortsInbound" : { | |
"Type" : "AWS::EC2::NetworkAclEntry", | |
"Properties" : { | |
"NetworkAclId" : {"Ref" : "OnosNetworkAcl"}, | |
"RuleNumber" : "104", | |
"Protocol" : "6", | |
"RuleAction" : "allow", | |
"Egress" : "false", | |
"CidrBlock" : "0.0.0.0/0", | |
"PortRange" : {"From" : "0", "To" : "65535"} | |
} | |
}, | |
"TCPAllPortsOutbound" : { | |
"Type" : "AWS::EC2::NetworkAclEntry", | |
"Properties" : { | |
"NetworkAclId" : {"Ref" : "OnosNetworkAcl"}, | |
"RuleNumber" : "104", | |
"Protocol" : "6", | |
"RuleAction" : "allow", | |
"Egress" : "true", | |
"CidrBlock" : "0.0.0.0/0", | |
"PortRange" : {"From" : "0", "To" : "65535"} | |
} | |
}, | |
"ICMPAllPortsInbound" : { | |
"Type" : "AWS::EC2::NetworkAclEntry", | |
"Properties" : { | |
"NetworkAclId" : {"Ref" : "OnosNetworkAcl"}, | |
"RuleNumber" : "105", | |
"Icmp" : {"Code" : -1,"Type" : -1}, | |
"Protocol" : "1", | |
"RuleAction" : "allow", | |
"Egress" : "false", | |
"CidrBlock" : "0.0.0.0/0", | |
"PortRange" : {"From" : "0", "To" : "65535"} | |
} | |
}, | |
"ICMPAllPortsOutbound" : { | |
"Type" : "AWS::EC2::NetworkAclEntry", | |
"Properties" : { | |
"NetworkAclId" : {"Ref" : "OnosNetworkAcl"}, | |
"RuleNumber" : "105", | |
"Icmp" : {"Code" : -1,"Type" : -1}, | |
"Protocol" : "1", | |
"RuleAction" : "allow", | |
"Egress" : "true", | |
"CidrBlock" : "0.0.0.0/0", | |
"PortRange" : {"From" : "0", "To" : "65535"} | |
} | |
}, | |
"SubnetNetworkAclAssociation" : { | |
"Type" : "AWS::EC2::SubnetNetworkAclAssociation", | |
"Properties" : { | |
"SubnetId" : { "Ref" : "PrivateSubnet" }, | |
"NetworkAclId" : { "Ref" : "OnosNetworkAcl" } | |
} | |
}, | |
"IPAddress" : { | |
"Type" : "AWS::EC2::EIP", | |
"DependsOn" : "AttachGateway", | |
"Properties" : { | |
"Domain" : "vpc", | |
"InstanceId" : { "Ref" : "OnosController" } | |
} | |
}, | |
"InstanceSecurityGroup" : { | |
"Type" : "AWS::EC2::SecurityGroup", | |
"Properties" : { | |
"VpcId" : { "Ref" : "VPC" }, | |
"GroupDescription" : "Enable SSH access via port 22", | |
"SecurityGroupIngress" : [ | |
{"IpProtocol" : "tcp", "FromPort" : "22", "ToPort" : "22", "CidrIp" : { "Ref" : "SSHLocation"}}, | |
{ "IpProtocol" : "tcp", "FromPort" : "80", "ToPort" : "80", "CidrIp" : "0.0.0.0/0"}, | |
{ "IpProtocol" : "tcp", "FromPort" : "0", "ToPort" : "65535", "CidrIp" : "0.0.0.0/0"}, | |
{ "IpProtocol" : "icmp", "FromPort" : "-1", "ToPort" : "-1", "CidrIp" : "0.0.0.0/0"} | |
] | |
} | |
}, | |
"OnosController" : { | |
"Type" : "AWS::EC2::Instance", | |
"Metadata": { | |
"AWS::CloudFormation::Init" : { | |
"config" : { | |
"files" : { | |
"/etc/cfn/cfn-hup.conf" : { | |
"content" : { "Fn::Join" : ["", [ | |
"[main]\n", | |
"stack=", { "Ref" : "AWS::StackId" }, "\n", | |
"region=", { "Ref" : "AWS::Region" }, "\n" | |
]]}, | |
"mode" : "000400", | |
"owner" : "root", | |
"group" : "root" | |
}, | |
"/etc/cfn/hooks.d/cfn-auto-reloader.conf" : { | |
"content": { "Fn::Join" : ["", [ | |
"[cfn-auto-reloader-hook]\n", | |
"triggers=post.update\n", | |
"path=Resources.OnosController.Metadata.AWS::CloudFormation::Init\n", | |
"action=/usr/local/bin/cfn-init -v ", | |
" --stack ", { "Ref" : "AWS::StackName" }, | |
" --resource OnosController ", | |
" --region ", { "Ref" : "AWS::Region" }, "\n", | |
"runas=root\n" | |
]]} | |
}, | |
"/lib/systemd/system/cfn-hup.service": { | |
"content": { "Fn::Join" : ["", [ | |
"[Unit]\n", | |
"Description=cfn-hup daemon\n\n", | |
"[Service]\n", | |
"Type=simple\n", | |
"ExecStart=/opt/aws/bin/cfn-hup\n", | |
"Restart=always\n\n", | |
"[Install]\n", | |
"WantedBy=multi-user.target"]]} | |
} | |
}, | |
"commands" : { | |
"01enable_cfn_hup" : { | |
"command" : "systemctl enable cfn-hup.service" | |
}, | |
"02start_cfn_hup" : { | |
"command" : "systemctl start cfn-hup.service" | |
} | |
} | |
} | |
} | |
}, | |
"DependsOn" : "AttachGateway", | |
"Properties" : { | |
"ImageId" : {"Fn::FindInMap": [ | |
"AWSRegionUbuntu2AMI", | |
{ | |
"Ref": "AWS::Region" | |
}, | |
{ | |
"Fn::FindInMap": [ | |
"AWSInstanceType2Ubuntu", | |
{ | |
"Ref": "InstanceType" | |
}, | |
"Ubuntu" | |
] | |
} | |
]}, | |
"InstanceType" : { "Ref" : "InstanceType" }, | |
"KeyName" : {"Ref": "KeyName"}, | |
"Tags" : [ {"Key" : "Name", "Value" : "Onos Controller" } ], | |
"NetworkInterfaces" : [{ | |
"GroupSet" : [{ "Ref" : "InstanceSecurityGroup" }], | |
"AssociatePublicIpAddress" : "true", | |
"DeviceIndex" : "0", | |
"DeleteOnTermination" : "true", | |
"SubnetId" : { "Ref" : "PulicSubnet" } | |
}], | |
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [ | |
"#!/bin/bash -xe\n", | |
"apt-get update -y\n", | |
"apt-get install -y python-setuptools\n", | |
"mkdir -p /opt/aws/bin\n", | |
"wget https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz\n", | |
"easy_install --script-dir /opt/aws/bin aws-cfn-bootstrap-latest.tar.gz\n", | |
"/opt/aws/bin/cfn-init -v ", | |
" --stack ", { "Ref" : "AWS::StackName" }, | |
" --resource OnosController ", | |
" --region ", { "Ref" : "AWS::Region" }, "\n", | |
"/opt/aws/bin/cfn-signal -e $? ", | |
" --stack ", { "Ref" : "AWS::StackName" }, | |
" --resource OnosController ", | |
" --region ", { "Ref" : "AWS::Region" }, "\n", | |
"# Install java8 \n", | |
"apt-get install software-properties-common -y \n", | |
"add-apt-repository ppa:webupd8team/java -y \n", | |
"apt-get update \n", | |
"echo \"oracle-java8-installer shared/accepted-oracle-license-v1-1 select true\" | debconf-set-selections \n", | |
"apt-get install oracle-java8-installer oracle-java8-set-default -y \n", | |
"# setup ssh keys \n", | |
"cd /home/ubuntu/.ssh \n", | |
"wget https://s3-us-west-1.amazonaws.com/dassio/id_rsa \n", | |
"wget https://s3-us-west-1.amazonaws.com/dassio/id_rsa.pub \n", | |
"chmod 644 id_rsa.pub\n", | |
"chmod 600 id_rsa\n", | |
"chown ubuntu:ubuntu id_rsa.pub\n", | |
"chown ubuntu:ubuntu id_rsa\n", | |
]]} | |
} | |
}, | |
"CreationPolicy" : { | |
"ResourceSignal" : { | |
"Timeout" : "PT15M" | |
} | |
} | |
}, | |
"OnosOC1" : { | |
"Type" : "AWS::EC2::Instance", | |
"Metadata": { | |
"AWS::CloudFormation::Init" : { | |
"config" : { | |
"files" : { | |
"/etc/cfn/cfn-hup.conf" : { | |
"content" : { "Fn::Join" : ["", [ | |
"[main]\n", | |
"stack=", { "Ref" : "AWS::StackId" }, "\n", | |
"region=", { "Ref" : "AWS::Region" }, "\n" | |
]]}, | |
"mode" : "000400", | |
"owner" : "root", | |
"group" : "root" | |
}, | |
"/etc/cfn/hooks.d/cfn-auto-reloader.conf" : { | |
"content": { "Fn::Join" : ["", [ | |
"[cfn-auto-reloader-hook]\n", | |
"triggers=post.update\n", | |
"path=Resources.OnosOC1.Metadata.AWS::CloudFormation::Init\n", | |
"action=/usr/local/bin/cfn-init -v ", | |
" --stack ", { "Ref" : "AWS::StackName" }, | |
" --resource OnosOC1", | |
" --region ", { "Ref" : "AWS::Region" }, "\n", | |
"runas=root\n" | |
]]} | |
}, | |
"/lib/systemd/system/cfn-hup.service": { | |
"content": { "Fn::Join" : ["", [ | |
"[Unit]\n", | |
"Description=cfn-hup daemon\n\n", | |
"[Service]\n", | |
"Type=simple\n", | |
"ExecStart=/opt/aws/bin/cfn-hup\n", | |
"Restart=always\n\n", | |
"[Install]\n", | |
"WantedBy=multi-user.target"]]} | |
} | |
}, | |
"commands" : { | |
"01enable_cfn_hup" : { | |
"command" : "systemctl enable cfn-hup.service" | |
}, | |
"02start_cfn_hup" : { | |
"command" : "systemctl start cfn-hup.service" | |
} | |
} | |
} | |
} | |
}, | |
"DependsOn" : "NAT", | |
"Properties" : { | |
"ImageId" : {"Fn::FindInMap": [ | |
"AWSRegionUbuntu2AMI", | |
{ | |
"Ref": "AWS::Region" | |
}, | |
{ | |
"Fn::FindInMap": [ | |
"AWSInstanceType2Ubuntu", | |
{ | |
"Ref": "InstanceType" | |
}, | |
"Ubuntu" | |
] | |
} | |
]}, | |
"InstanceType" : { "Ref" : "InstanceType" }, | |
"KeyName" : {"Ref": "KeyName"}, | |
"Tags" : [ {"Key" : "Name", "Value" : "Onos OC1" } ], | |
"NetworkInterfaces" : [{ | |
"GroupSet" : [{ "Ref" : "InstanceSecurityGroup" }], | |
"AssociatePublicIpAddress" : "false", | |
"DeviceIndex" : "0", | |
"DeleteOnTermination" : "true", | |
"SubnetId" : { "Ref" : "PrivateSubnet" }, | |
"PrivateIpAddress" : "192.168.56.101" | |
}], | |
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [ | |
"#!/bin/bash -xe\n", | |
"apt-get update -y\n", | |
"apt-get install -y python-setuptools\n", | |
"mkdir -p /opt/aws/bin\n", | |
"wget https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz\n", | |
"easy_install --script-dir /opt/aws/bin aws-cfn-bootstrap-latest.tar.gz\n", | |
"/opt/aws/bin/cfn-init -v ", | |
" --stack ", { "Ref" : "AWS::StackName" }, | |
" --resource OnosOC1 ", | |
" --region ", { "Ref" : "AWS::Region" }, "\n", | |
"/opt/aws/bin/cfn-signal -e $? ", | |
" --stack ", { "Ref" : "AWS::StackName" }, | |
" --resource OnosOC1 ", | |
" --region ", { "Ref" : "AWS::Region" }, "\n", | |
"# Install java8\n", | |
"apt-get install software-properties-common -y \n", | |
"add-apt-repository ppa:webupd8team/java -y \n", | |
"apt-get update \n", | |
"echo \"oracle-java8-installer shared/accepted-oracle-license-v1-1 select true\" | debconf-set-selections \n", | |
"apt-get install oracle-java8-installer oracle-java8-set-default -y \n", | |
"# add sdn user\n", | |
"useradd -m sdn \n", | |
"echo 'sdn ALL=(ALL) NOPASSWD:ALL' | sudo EDITOR='tee -a' visudo \n", | |
"mkdir /home/sdn/.ssh/ \n", | |
"touch /home/sdn/.ssh/authorized_keys \n", | |
"bash -c \"curl https://s3-us-west-1.amazonaws.com/dassio/id_rsa.pub >> /home/sdn/.ssh/authorized_keys\" \n", | |
"chmod 700 /home/sdn/.ssh \n", | |
"chmod 600 /home/sdn/.ssh/authorized_keys \n", | |
"chown sdn:sdn /home/sdn/.ssh \n", | |
"chown sdn:sdn /home/sdn/.ssh/authorized_keys \n" | |
]]} | |
} | |
}, | |
"CreationPolicy" : { | |
"ResourceSignal" : { | |
"Timeout" : "PT15M" | |
} | |
} | |
}, | |
"OnosOC2" : { | |
"Type" : "AWS::EC2::Instance", | |
"Metadata": { | |
"AWS::CloudFormation::Init" : { | |
"config" : { | |
"files" : { | |
"/etc/cfn/cfn-hup.conf" : { | |
"content" : { "Fn::Join" : ["", [ | |
"[main]\n", | |
"stack=", { "Ref" : "AWS::StackId" }, "\n", | |
"region=", { "Ref" : "AWS::Region" }, "\n" | |
]]}, | |
"mode" : "000400", | |
"owner" : "root", | |
"group" : "root" | |
}, | |
"/etc/cfn/hooks.d/cfn-auto-reloader.conf" : { | |
"content": { "Fn::Join" : ["", [ | |
"[cfn-auto-reloader-hook]\n", | |
"triggers=post.update\n", | |
"path=Resources.OnosOC2.Metadata.AWS::CloudFormation::Init\n", | |
"action=/usr/local/bin/cfn-init -v ", | |
" --stack ", { "Ref" : "AWS::StackName" }, | |
" --resource OnosOC2", | |
" --region ", { "Ref" : "AWS::Region" }, "\n", | |
"runas=root\n" | |
]]} | |
}, | |
"/lib/systemd/system/cfn-hup.service": { | |
"content": { "Fn::Join" : ["", [ | |
"[Unit]\n", | |
"Description=cfn-hup daemon\n\n", | |
"[Service]\n", | |
"Type=simple\n", | |
"ExecStart=/opt/aws/bin/cfn-hup\n", | |
"Restart=always\n\n", | |
"[Install]\n", | |
"WantedBy=multi-user.target"]]} | |
} | |
}, | |
"commands" : { | |
"01enable_cfn_hup" : { | |
"command" : "systemctl enable cfn-hup.service" | |
}, | |
"02start_cfn_hup" : { | |
"command" : "systemctl start cfn-hup.service" | |
} | |
} | |
} | |
} | |
}, | |
"DependsOn" : "NAT", | |
"Properties" : { | |
"ImageId" : {"Fn::FindInMap": [ | |
"AWSRegionUbuntu2AMI", | |
{ | |
"Ref": "AWS::Region" | |
}, | |
{ | |
"Fn::FindInMap": [ | |
"AWSInstanceType2Ubuntu", | |
{ | |
"Ref": "InstanceType" | |
}, | |
"Ubuntu" | |
] | |
} | |
]}, | |
"InstanceType" : { "Ref" : "InstanceType" }, | |
"KeyName" : {"Ref": "KeyName"}, | |
"Tags" : [ {"Key" : "Name", "Value" : "Onos OC2" } ], | |
"NetworkInterfaces" : [{ | |
"GroupSet" : [{ "Ref" : "InstanceSecurityGroup" }], | |
"AssociatePublicIpAddress" : "false", | |
"DeviceIndex" : "0", | |
"DeleteOnTermination" : "true", | |
"SubnetId" : { "Ref" : "PrivateSubnet" }, | |
"PrivateIpAddress" : "192.168.56.102" | |
}], | |
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [ | |
"#!/bin/bash -xe\n", | |
"apt-get update -y\n", | |
"apt-get install -y python-setuptools\n", | |
"mkdir -p /opt/aws/bin\n", | |
"wget https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz\n", | |
"easy_install --script-dir /opt/aws/bin aws-cfn-bootstrap-latest.tar.gz\n", | |
"/opt/aws/bin/cfn-init -v ", | |
" --stack ", { "Ref" : "AWS::StackName" }, | |
" --resource OnosOC2 ", | |
" --region ", { "Ref" : "AWS::Region" }, "\n", | |
"/opt/aws/bin/cfn-signal -e $? ", | |
" --stack ", { "Ref" : "AWS::StackName" }, | |
" --resource OnosOC2 ", | |
" --region ", { "Ref" : "AWS::Region" }, "\n", | |
"# Install java8\n", | |
"apt-get install software-properties-common -y \n", | |
"add-apt-repository ppa:webupd8team/java -y \n", | |
"apt-get update \n", | |
"echo \"oracle-java8-installer shared/accepted-oracle-license-v1-1 select true\" | debconf-set-selections \n", | |
"apt-get install oracle-java8-installer oracle-java8-set-default -y \n", | |
"# add sdn user\n", | |
"useradd -m sdn \n", | |
"echo 'sdn ALL=(ALL) NOPASSWD:ALL' | sudo EDITOR='tee -a' visudo \n", | |
"mkdir /home/sdn/.ssh/ \n", | |
"touch /home/sdn/.ssh/authorized_keys \n", | |
"bash -c \"curl https://s3-us-west-1.amazonaws.com/dassio/id_rsa.pub >> /home/sdn/.ssh/authorized_keys\" \n", | |
"chmod 700 /home/sdn/.ssh \n", | |
"chmod 600 /home/sdn/.ssh/authorized_keys \n", | |
"chown sdn:sdn /home/sdn/.ssh \n", | |
"chown sdn:sdn /home/sdn/.ssh/authorized_keys \n" | |
]]} | |
} | |
}, | |
"CreationPolicy" : { | |
"ResourceSignal" : { | |
"Timeout" : "PT15M" | |
} | |
} | |
}, | |
"Mininet" : { | |
"Type" : "AWS::EC2::Instance", | |
"Metadata": { | |
"AWS::CloudFormation::Init" : { | |
"config" : { | |
"files" : { | |
"/etc/cfn/cfn-hup.conf" : { | |
"content" : { "Fn::Join" : ["", [ | |
"[main]\n", | |
"stack=", { "Ref" : "AWS::StackId" }, "\n", | |
"region=", { "Ref" : "AWS::Region" }, "\n" | |
]]}, | |
"mode" : "000400", | |
"owner" : "root", | |
"group" : "root" | |
}, | |
"/etc/cfn/hooks.d/cfn-auto-reloader.conf" : { | |
"content": { "Fn::Join" : ["", [ | |
"[cfn-auto-reloader-hook]\n", | |
"triggers=post.update\n", | |
"path=Resources.Mininet.Metadata.AWS::CloudFormation::Init\n", | |
"action=/usr/local/bin/cfn-init -v ", | |
" --stack ", { "Ref" : "AWS::StackName" }, | |
" --resource Mininet", | |
" --region ", { "Ref" : "AWS::Region" }, "\n", | |
"runas=root\n" | |
]]} | |
}, | |
"/lib/systemd/system/cfn-hup.service": { | |
"content": { "Fn::Join" : ["", [ | |
"[Unit]\n", | |
"Description=cfn-hup daemon\n\n", | |
"[Service]\n", | |
"Type=simple\n", | |
"ExecStart=/opt/aws/bin/cfn-hup\n", | |
"Restart=always\n\n", | |
"[Install]\n", | |
"WantedBy=multi-user.target"]]} | |
} | |
}, | |
"commands" : { | |
"01enable_cfn_hup" : { | |
"command" : "systemctl enable cfn-hup.service" | |
}, | |
"02start_cfn_hup" : { | |
"command" : "systemctl start cfn-hup.service" | |
} | |
} | |
} | |
} | |
}, | |
"DependsOn" : "NAT", | |
"Properties" : { | |
"ImageId" : {"Fn::FindInMap": [ | |
"AWSRegionUbuntu2AMI", | |
{ | |
"Ref": "AWS::Region" | |
}, | |
{ | |
"Fn::FindInMap": [ | |
"AWSInstanceType2Ubuntu", | |
{ | |
"Ref": "InstanceType" | |
}, | |
"Ubuntu" | |
] | |
} | |
]}, | |
"InstanceType" : { "Ref" : "InstanceType" }, | |
"KeyName" : {"Ref": "KeyName"}, | |
"Tags" : [ {"Key" : "Name", "Value" : "Onos mininet" } ], | |
"NetworkInterfaces" : [{ | |
"GroupSet" : [{ "Ref" : "InstanceSecurityGroup" }], | |
"AssociatePublicIpAddress" : "false", | |
"DeviceIndex" : "0", | |
"DeleteOnTermination" : "true", | |
"SubnetId" : { "Ref" : "PrivateSubnet" }, | |
"PrivateIpAddress" : "192.168.56.103" | |
}], | |
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [ | |
"#!/bin/bash -xe\n", | |
"apt-get update -y\n", | |
"apt-get install -y python-setuptools\n", | |
"mkdir -p /opt/aws/bin\n", | |
"wget https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz\n", | |
"easy_install --script-dir /opt/aws/bin aws-cfn-bootstrap-latest.tar.gz\n", | |
"/opt/aws/bin/cfn-init -v ", | |
" --stack ", { "Ref" : "AWS::StackName" }, | |
" --resource Mininet ", | |
" --region ", { "Ref" : "AWS::Region" }, "\n", | |
"/opt/aws/bin/cfn-signal -e $? ", | |
" --stack ", { "Ref" : "AWS::StackName" }, | |
" --resource Mininet ", | |
" --region ", { "Ref" : "AWS::Region" }, "\n", | |
"apt-get install mininet -y \n", | |
"# add sdn user\n", | |
"useradd -m sdn \n", | |
"echo 'sdn ALL=(ALL) NOPASSWD:ALL' | sudo EDITOR='tee -a' visudo \n", | |
"mkdir /home/sdn/.ssh/ \n", | |
"touch /home/sdn/.ssh/authorized_keys \n", | |
"bash -c \"curl https://s3-us-west-1.amazonaws.com/dassio/id_rsa.pub >> /home/sdn/.ssh/authorized_keys\" \n", | |
"chmod 700 /home/sdn/.ssh \n", | |
"chmod 600 /home/sdn/.ssh/authorized_keys \n", | |
"chown sdn:sdn /home/sdn/.ssh \n", | |
"chown sdn:sdn /home/sdn/.ssh/authorized_keys \n" | |
]]} | |
} | |
}, | |
"CreationPolicy" : { | |
"ResourceSignal" : { | |
"Timeout" : "PT15M" | |
} | |
} | |
}, | |
}, | |
"Outputs" : { | |
"URL" : { | |
"Value" : { "Fn::Join" : [ "", ["http://", { "Fn::GetAtt" : ["OnosController", "PublicIp"] }]]}, | |
"Description" : "Newly created application URL" | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the onos-controller EBS volum is too small (8G), not enough for running testes