Skip to content
Permalink
Browse files

update vagrant for one node

  • Loading branch information...
naviat committed Nov 28, 2018
1 parent b119571 commit 8e653c916ca7c89ba54535b324e6f8bff4ad344b
Showing with 48 additions and 264 deletions.
  1. +38 −27 README.md
  2. +10 −15 Vagrantfile
  3. +0 −72 Vagrantfile.singapore
  4. +0 −72 Vagrantfile.tokyo
  5. +0 −72 Vagrantfile.virginia
  6. +0 −3 down.sh
  7. +0 −3 up.sh
@@ -1,38 +1,49 @@
# Step-by-step to provision infrastructure of masternodes on EC2
# Vagrant + AWS Masternode Setup - WORK IN PROGRESS (May include Ansible in the future)

## Bring up
This project aims to `vagrant up` a multi-node/multi-region Node ready-to-use within Amazon's EC2 cloud. Configure and `vagrant up --provider=aws` to get going.

1. Configuration
## Configuration

Update `config.json` file at below fields (with each region, you need to create config,json):
### AWS side

- "accessKeyId": AWS access key
- "secretAccessKey": AWS secret key
- "sshKeyName": specify your ssh key registered on DO
- "privateKeyPath": path to the private ssh key on your machine
- "coinbasePrivateKeySun": private key of the SUN masternode
- "node": put in information for each masternode
You need to have AWS setup so that

2. Join a node to testnet (select for each region)
- there is a `vagrant` security group (you can change other name edit `security_groups` parameter)
- there is a security group that allows inbound traffic to all ports used by Masternode (configured defaults are for Masternode: 30303,30301,22,9160)
- your instances receive a public DNS entry
- there is a key-pair for which you have the private key file available

```
$ ./up.sh main
```
Note that these settings are region specific in AWS, if you want to deploy to multiple regions you need to do this setup on each region. Also note that in case of multi-region deployments, you need to have *one* key-pair setup in all regions as the Vagrant combination does not support multiple keys for multiple regions.

3. Start up other masternodes
### Vagrant side

```
$ ./up.sh <region>
```
- Install Vagrant (https://vagrantup.com)
- Install the `vagrant-aws` plugin: `vagrant plugin install vagrant-aws`
- Add the `dummy` aws box, the concrete config is done in the `Vagrantfile` and config: `vagrant box add dummy https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box`

## Bring down
Configure your desired cluster topology as well as AWS credentials in the `config.json.template` and rename it to `config.json`. All configuration is done is this file.

```
$ ./down.sh main
$ ./down.sh node
```
This has at the moment only been tested under `Ubuntu 18.04.LTS`, so you should choose your AMI accordingly. (tmn tool must be use python ^3.5.2 version)

## Update code and reload
```
VAGRANT_VAGRANTFILE=Vagrantfile.main vagrant ssh -c "consul kv put tomochain/reset 1"
```
## Deploy

`vagrant up --provider=aws` and you are good to go.

## Terminate the whole cluster

`vagrant destroy` (`-f` if you don't want to ack every node.)

## What do you get

- Multi-Region/Multi-Node setup, preconfigured for...
- AWS Multi-Region usage (EC2-Multi-Region-Snitch)
- Settings optimized for SSD data storage (make sure to use an appropriate AMI)

## Concerns

## TODO

## ERROR

1. [from_keypair error when use](https://github.com/net-ssh/net-ssh/issues/638#issuecomment-441189002)
2. [tmn cannot install](!)
@@ -11,19 +11,18 @@ Vagrant.configure("2") do |config|
config.vm.define node['name'] do |config|
envFile = '.env.' + node['name']
f = File.new(envFile, 'w')
f.write('TOMOMASTER=http://' + appConfig['mainPublicIp'] + ':3001' + "\n")
f.write('RPC_URL=http://' + appConfig['mainPublicIp'] + ':8545' + "\n")
f.write('OWNER_PRIVATE_KEY=' + node['ownerPrivateKey'] + "\n")
f.write('COINBASE_PRIVATE_KEY=' + node['coinbasePrivateKey'] + "\n")
f.write('COINBASE_ADDRESS=' + node['coinbaseAddress'] + "\n")
f.close

ENV['LC_ALL']="C.UTF-8"
ENV['COINBASE_PRIVATE_KEY']=node['coinbasePrivateKey']
ENV['DEBIAN_FRONTEND']='noninteractive'
#ENV['DEBIAN_FRONTEND']='noninteractive'

config.vm.provider :aws do |aws, override|
aws.ami = 'ami-0b4d63df52bb04cb3'
aws.access_key_id = appConfig['accessKeyId']
aws.secret_access_key = appConfig['secretAccessKey']
aws.ami = node['ami']
aws.region = node['region']
aws.keypair_name = appConfig['sshKeyName']
aws.instance_type = 't2.xlarge'
@@ -38,14 +37,12 @@ Vagrant.configure("2") do |config|
aws.tags = {
'Name' => 'node-test',
}
#aws.associate_public_ip = true
override.vm.box = 'dummy'
override.ssh.private_key_path = appConfig['privateKeyPath']
override.ssh.username = 'ubuntu'
#aws.security_groups = [ 'ssh', 'masternode', 'testnet', 'bootnode' ]
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.provision "file", source: "./apply.sh", destination: "/home/ubuntu/apply.sh"
config.vm.provision "file", source: envFile, destination: "/home/ubuntu/.env"
config.vm.provision "file", source: envFile, destination: "/home/ubuntu/.env"
$post_script = <<-SCRIPT
sudo apt-get update
sudo apt-get install \
@@ -57,15 +54,13 @@ Vagrant.configure("2") do |config|
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update && sudo apt-get install -y docker-ce
sudo usermod -aG docker ubuntu
sudo apt-get update && sudo apt-get install -y python3-pip && pip3 install -U tmn
export LC_ALL=C.UTF-8
(crontab -l -u root; echo "*/2 * * * * bash /home/ubuntu/apply.sh") | crontab -u root -
sudo apt-get install -y python3 && sudo apt-get install -y python3-pip
pip3 install --user tmn
export PATH="$PATH":/home/ubuntu/.local/bin
source /home/ubuntu/.env
tmn start --name anonymous --pkey ${COINBASE_PRIVATE_KEY} --net testnet
SCRIPT
config.vm.provision "shell", inline: $post_script
config.vm.provision "shell", inline: <<-SHELL
source /home/ubuntu/.env
tmn start --name anonymous --pkey ${COINBASE_PRIVATE_KEY} --net testnet
SHELL
end
end
end

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
3 up.sh

This file was deleted.

Oops, something went wrong.

0 comments on commit 8e653c9

Please sign in to comment.
You can’t perform that action at this time.