2017-11-12 09:06:57 -08:00
|
|
|
---
|
2017-11-24 13:56:15 -08:00
|
|
|
- name: Create bootnode security group
|
2017-11-17 05:03:46 -08:00
|
|
|
hosts: localhost
|
|
|
|
gather_facts: False
|
|
|
|
tasks:
|
|
|
|
- name: Create Security group
|
|
|
|
ec2_group:
|
|
|
|
ec2_access_key: "{{ access_key }}"
|
|
|
|
ec2_secret_key: "{{ secret_key }}"
|
2017-11-24 13:56:15 -08:00
|
|
|
name: bootnode-security
|
2017-11-17 05:03:46 -08:00
|
|
|
description: "Default security group"
|
|
|
|
region: "{{ region }}"
|
2017-11-20 10:03:53 -08:00
|
|
|
# purge_rules_egress: true
|
|
|
|
# purge_rules: true
|
2017-11-17 05:03:46 -08:00
|
|
|
rules:
|
|
|
|
- proto: tcp
|
|
|
|
from_port: 22
|
|
|
|
to_port: 22
|
|
|
|
cidr_ip: 0.0.0.0/0
|
|
|
|
- proto: tcp
|
|
|
|
from_port: 443
|
|
|
|
to_port: 443
|
|
|
|
cidr_ip: 0.0.0.0/0
|
|
|
|
- proto: tcp
|
|
|
|
from_port: 8545
|
|
|
|
to_port: 8545
|
|
|
|
cidr_ip: 0.0.0.0/0
|
|
|
|
- proto: tcp
|
|
|
|
from_port: 30303
|
|
|
|
to_port: 30303
|
|
|
|
cidr_ip: 0.0.0.0/0
|
|
|
|
- proto: udp
|
|
|
|
from_port: 30303
|
|
|
|
to_port: 30303
|
|
|
|
cidr_ip: 0.0.0.0/0
|
2017-11-20 12:56:23 -08:00
|
|
|
rules_egress:
|
|
|
|
- proto: all
|
|
|
|
from_port: all
|
|
|
|
to_port: all
|
|
|
|
cidr_ip: 0.0.0.0/0
|
2017-11-24 13:56:15 -08:00
|
|
|
tags: bootnode
|
2017-11-17 05:03:46 -08:00
|
|
|
|
|
|
|
|
2017-11-24 13:56:15 -08:00
|
|
|
- name: Create bootnode
|
2017-11-12 09:06:57 -08:00
|
|
|
hosts: localhost
|
|
|
|
gather_facts: False
|
|
|
|
vars:
|
|
|
|
volumes:
|
|
|
|
- device_name: /dev/sda1
|
|
|
|
volume_size: 128
|
|
|
|
delete_on_termination: true
|
|
|
|
tasks:
|
|
|
|
- name: Launch instance
|
|
|
|
ec2:
|
|
|
|
ec2_access_key: "{{ access_key }}"
|
|
|
|
ec2_secret_key: "{{ secret_key }}"
|
2017-11-15 08:44:59 -08:00
|
|
|
key_name: "{{ awskeypair_name }}"
|
2017-11-12 09:06:57 -08:00
|
|
|
instance_tags:
|
2017-11-26 13:03:42 -08:00
|
|
|
Name: "{{ bootnode_instance_name }}"
|
2017-11-24 13:56:15 -08:00
|
|
|
group: "{{ bootnode_security_group }}"
|
2017-11-26 13:03:42 -08:00
|
|
|
instance_type: "{{ bootnode_instance_type }}"
|
2017-11-12 09:06:57 -08:00
|
|
|
image: "{{ image }}"
|
2017-11-26 13:03:42 -08:00
|
|
|
count: "{{ bootnode_count_instances }}"
|
2017-11-12 09:06:57 -08:00
|
|
|
wait: yes
|
|
|
|
region: "{{ region }}"
|
2017-11-15 08:44:59 -08:00
|
|
|
vpc_subnet_id: "{{ vpc_subnet_id }}"
|
2017-11-12 09:06:57 -08:00
|
|
|
volumes: "{{ volumes }}"
|
|
|
|
assign_public_ip: yes
|
|
|
|
register: ec2
|
|
|
|
- name: Add new instance to host group
|
|
|
|
add_host: hostname={{ item.public_ip }} groupname=launched
|
|
|
|
with_items: "{{ ec2.instances }}"
|
|
|
|
- name: Wait for SSH to come up
|
2017-11-20 13:57:26 -08:00
|
|
|
wait_for: host={{ item.public_ip }} port=22 delay=90 timeout=320 state=started
|
2017-11-12 09:06:57 -08:00
|
|
|
with_items: "{{ ec2.instances }}"
|
2017-11-24 13:56:15 -08:00
|
|
|
tags: bootnode
|
2017-11-12 09:06:57 -08:00
|
|
|
|
|
|
|
- name: Installing python
|
2017-11-15 08:44:59 -08:00
|
|
|
hosts: all
|
2017-11-12 09:06:57 -08:00
|
|
|
hosts: launched
|
2017-11-15 08:44:59 -08:00
|
|
|
gather_facts: False
|
|
|
|
user: ubuntu
|
|
|
|
become: True
|
2017-11-12 09:06:57 -08:00
|
|
|
vars:
|
|
|
|
ansible_ssh_port: 22
|
2017-11-15 08:44:59 -08:00
|
|
|
tasks:
|
|
|
|
- name: Install python
|
|
|
|
raw: test -e /usr/bin/python || (sudo apt -y update && sudo apt install -y python-minimal)
|
2017-11-12 09:06:57 -08:00
|
|
|
|
|
|
|
- name: Configure instance(s)
|
|
|
|
hosts: launched
|
2017-11-15 08:44:59 -08:00
|
|
|
user: ubuntu
|
|
|
|
become: True
|
2017-11-12 09:06:57 -08:00
|
|
|
vars:
|
|
|
|
ansible_ssh_port: 22
|
|
|
|
gather_facts: True
|
|
|
|
roles:
|
|
|
|
- preconf
|
|
|
|
tags: preconf
|
|
|
|
tasks:
|
|
|
|
- name: restart machine after setup
|
|
|
|
shell: shutdown -r 1
|