Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7686e9e

Browse files
committed
Starting micro and terminating all ec2 instances.
1 parent b1acf21 commit 7686e9e

File tree

4 files changed

+60
-2
lines changed

4 files changed

+60
-2
lines changed

devops/ec2.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
### Manage ec2 instances. Env vars AWS_ACCESS_KEY_ID and AWS_ACCESS_KEY are
2+
# required!
3+
4+
---
5+
- hosts: localhost
6+
gather_facts: False
7+
vars:
8+
key_name: aws
9+
security_group: cluster
10+
count: 3
11+
vpc_subnet_id: subnet-99ba45d4
12+
region: eu-central-1
13+
14+
tasks:
15+
- name: start instances
16+
ec2:
17+
key_name: "{{ key_name }}"
18+
instance_type: "{{ instance_type }}"
19+
image: "{{ image }}"
20+
group: "{{ security_group }}"
21+
count: "{{ count }}"
22+
vpc_subnet_id: "{{ vpc_subnet_id }}"
23+
region: "{{ region }}"
24+
wait: yes
25+
assign_public_ip: yes
26+
vars:
27+
instance_type: t2.micro
28+
image: ami-1e339e71 # basic ubuntu backed by ebs
29+
tags:
30+
- micro
31+
32+
- import_tasks: tasks/clean_ec2_cache.yml
33+
tags:
34+
- terminate
35+
36+
- name: terminate all ec2 instances
37+
ec2:
38+
state: absent
39+
region: "{{ region }}"
40+
instance_ids: "{{ hostvars[item]['ec2_id'] }}"
41+
wait: "{{ wait }}"
42+
with_items: "{{ groups.ec2 }}"
43+
vars:
44+
wait: no
45+
tags:
46+
- terminate

devops/inventory

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
localhost
1+
[localhost]
2+
# handles ec2 module bugs
3+
localhost ansible_connection=local ansible_python_interpreter=python
4+
25

36
[nodes]
47
# nodes consists of 'manual' (e.g. for local testing) and 'ec2' autogenerated
@@ -17,7 +20,7 @@ pg_repo=git://git.postgresql.org/git/postgresql.git
1720
pg_version_tag=REL_10_STABLE
1821
pg_prefix="{{ansible_env.HOME}}/pg"
1922
pg_src="{{pg_prefix}}/src"
20-
cflags="-O0"
23+
cflags="-O2"
2124
pg_dst="{{pg_prefix}}/install"
2225
pg_datadir="{{pg_prefix}}/data_{{pg_port}}"
2326
pg_logfile="{{pg_datadir}}/pg.log"

devops/readme.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ ansible-playbook -i inventory_ec2/ pgbench_prepare.yml -e "scale=10 nparts=10 re
6060
Gather logs to ./logs:
6161
ansible-playbook -i inventory_ec2/ logs.yml
6262

63+
Start micro instances:
64+
ansible-playbook -i inventory_ec2/ ec2.yml --tags "micro" -e "count=2"
65+
Terminate all ec2 instances:
66+
ansible-playbook -i inventory_ec2/ ec2.yml --tags "terminate"
67+
6368
Ubuntu images EC2 locator:
6469
https://cloud-images.ubuntu.com/locator/ec2/
6570
We need ami-4199282e.

devops/tasks/clean_ec2_cache.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
3+
- name: clean ec2 cache
4+
shell: "rm -rf ~/.ansible/tmp/ansible-ec2-*"

0 commit comments

Comments
 (0)