deployment-playbooks/bootnode.yml

106 lines
2.8 KiB
YAML
Raw Normal View History

2017-11-12 09:06:57 -08:00
---
- name: Create bootnode security group
2017-11-17 05:03:46 -08:00
hosts: localhost
gather_facts: False
tasks:
2017-11-17 05:03:46 -08:00
- name: Create Security group
ec2_group:
ec2_access_key: "{{ access_key }}"
ec2_secret_key: "{{ secret_key }}"
2018-02-21 12:18:08 -08:00
name: "{{ bootnode_security_group }}"
2017-11-17 05:03:46 -08:00
description: "Default security group"
region: "{{ region }}"
2018-02-21 12:18:08 -08:00
purge_rules_egress: false
purge_rules: false
2017-11-17 05:03:46 -08:00
rules:
- proto: tcp
from_port: 22
to_port: 22
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
tags: bootnode
2017-11-17 05:03:46 -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 }}"
key_name: "{{ awskeypair_name }}"
instance_tags:
Name: "{{ bootnode_instance_name }}"
group: "{{ bootnode_security_group }}"
instance_type: "{{ bootnode_instance_type }}"
2017-11-12 09:06:57 -08:00
image: "{{ image }}"
count: "{{ bootnode_count_instances }}"
2017-11-12 09:06:57 -08:00
wait: yes
region: "{{ region }}"
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 }}"
tags: bootnode
2017-11-12 09:06:57 -08:00
- name: Installing python
hosts: all
2017-11-12 09:06:57 -08:00
hosts: launched
gather_facts: False
user: ubuntu
become: True
2017-11-12 09:06:57 -08:00
vars:
ansible_ssh_port: 22
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
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
- name: Create bootnode elastic ip
hosts: localhost
gather_facts: False
tasks:
- name: associate elastic ip for bootnode
ec2_eip:
ec2_access_key: "{{ access_key }}"
ec2_secret_key: "{{ secret_key }}"
region: "{{ region }}"
reuse_existing_ip_allowed: yes
state: present
in_vpc: yes
device_id: "{{ ec2.instance_ids[0] }}"
register: instance_elastic_ip
when: associate_bootnode_elastic_ip == true
- debug: var=instance_elastic_ip.public_ip
when: associate_bootnode_elastic_ip == true