File tree Expand file tree Collapse file tree 4 files changed +60
-2
lines changed Expand file tree Collapse file tree 4 files changed +60
-2
lines changed Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change 1
- localhost
1
+ [localhost]
2
+ # handles ec2 module bugs
3
+ localhost ansible_connection=local ansible_python_interpreter=python
4
+
2
5
3
6
[nodes]
4
7
# 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
17
20
pg_version_tag=REL_10_STABLE
18
21
pg_prefix="{{ansible_env.HOME}}/pg"
19
22
pg_src="{{pg_prefix}}/src"
20
- cflags="-O0 "
23
+ cflags="-O2 "
21
24
pg_dst="{{pg_prefix}}/install"
22
25
pg_datadir="{{pg_prefix}}/data_{{pg_port}}"
23
26
pg_logfile="{{pg_datadir}}/pg.log"
Original file line number Diff line number Diff line change @@ -60,6 +60,11 @@ ansible-playbook -i inventory_ec2/ pgbench_prepare.yml -e "scale=10 nparts=10 re
60
60
Gather logs to ./logs:
61
61
ansible-playbook -i inventory_ec2/ logs.yml
62
62
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
+
63
68
Ubuntu images EC2 locator:
64
69
https://cloud-images.ubuntu.com/locator/ec2/
65
70
We need ami-4199282e.
Original file line number Diff line number Diff line change
1
+ ---
2
+
3
+ - name : clean ec2 cache
4
+ shell : " rm -rf ~/.ansible/tmp/ansible-ec2-*"
You can’t perform that action at this time.
0 commit comments