Skip to content

Commit 07cd7a1

Browse files
committed
ec2 for tests
1 parent 7317bb0 commit 07cd7a1

File tree

5 files changed

+1676
-0
lines changed

5 files changed

+1676
-0
lines changed

tests/deploy_layouts/cluster-ec2.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
- hosts: tag_Name_dtmtest
3+
user: ec2-user
4+
5+
roles:
6+
7+
- role: postgres
8+
pg_port: 15432
9+
pg_repo: https://github.com/kelvich/postgresql.git
10+
pg_version_tag: xtm_patched
11+
pg_destroy_and_init: true
12+
pg_config_role:
13+
- line: "dtm.buffer_size = 65536"
14+
15+
tasks:
16+
- name: collect private ips
17+
set_fact:
18+
pip: "{{ ec2_private_ip_address }}"
19+
20+
- name: set dtm ip
21+
set_fact:
22+
dtm_ip: "{{ hostvars[groups['tag_Name_dtmtest'][0]].pip }}"
23+
24+
- name: clone dtm sources
25+
git: repo=https://github.com/postgrespro/pg_dtm.git
26+
dest={{pg_prefix}}/pg_dtm
27+
accept_hostkey=yes
28+
update=yes
29+
force=yes
30+
register: dtm_sources
31+
32+
- name: build dtm
33+
shell: "make clean && make -j {{makejobs}} install"
34+
args:
35+
chdir: "{{pg_prefix}}/pg_dtm"
36+
environment:
37+
PG_CONFIG: "{{pg_dst}}/bin/pg_config"
38+
when: dtm_sources.changed
39+
40+
- name: enable dtm extension on datanodes
41+
lineinfile:
42+
dest: "{{pg_datadir}}/postgresql.conf"
43+
line: "{{item}}"
44+
state: present
45+
with_items:
46+
- "shared_preload_libraries = 'pg_dtm'"
47+
- "dtm.host = '{{ dtm_ip }}'"
48+
49+
- name: restart postgrespro
50+
command: "{{pg_dst}}/bin/pg_ctl restart -w -D {{pg_datadir}} -l {{pg_datadir}}/pg.log"
51+
environment:
52+
LD_LIBRARY_PATH: "{{pg_dst}}/lib/"
53+
54+
- hosts: tag_Name_dtmtest[0]
55+
user: ec2-user
56+
tasks:
57+
- name: build dtmd
58+
shell: "make clean && make -j 4"
59+
args:
60+
chdir: "~/pg_cluster/pg_dtm/dtmd"
61+
# environment:
62+
# PG_CONFIG: "~/pg_cluster/install/bin/pg_config"
63+
64+
- name: kill dtmd
65+
shell: kill -9 `cat ~/pg_cluster/dtm_data/arbiter.pid` || true
66+
67+
- name: ensure datadir for dtm exists
68+
shell: "rm -rf ~/pg_cluster/dtm_data && mkdir ~/pg_cluster/dtm_data"
69+
70+
- name: start dtm
71+
shell: >
72+
nohup ~/pg_cluster/pg_dtm/dtmd/bin/dtmd
73+
-d ~/pg_cluster/dtm_data -a 0.0.0.0 -p 5431 > ~/pg_cluster/dtm_data/log &
74+
75+
- name: wait until dtm is available
76+
wait_for: port=5431 delay=1
77+

tests/deploy_layouts/ec2.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
3+
- hosts: localhost
4+
connection: local
5+
gather_facts: False
6+
7+
tasks:
8+
9+
- name: Provision a set of instances
10+
ec2:
11+
key_name: macmini
12+
group: launch-wizard-2
13+
# instance_type: t2.micro
14+
instance_type: c3.2xlarge
15+
image: ami-60b6c60a
16+
wait: true
17+
region: us-east-1
18+
exact_count: 10
19+
count_tag:
20+
Name: dtmtest
21+
instance_tags:
22+
Name: dtmtest
23+
register: ec2
24+
25+
- name: Add all instance public IPs to host group
26+
add_host: hostname={{ item.public_ip }} groups=ec2hosts
27+
with_items: ec2.instances
28+

tests/farms/ec2.ini

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
# Ansible EC2 external inventory script settings
2+
#
3+
4+
[ec2]
5+
6+
# to talk to a private eucalyptus instance uncomment these lines
7+
# and edit edit eucalyptus_host to be the host name of your cloud controller
8+
#eucalyptus = True
9+
#eucalyptus_host = clc.cloud.domain.org
10+
11+
# AWS regions to make calls to. Set this to 'all' to make request to all regions
12+
# in AWS and merge the results together. Alternatively, set this to a comma
13+
# separated list of regions. E.g. 'us-east-1,us-west-1,us-west-2'
14+
regions = us-east-1
15+
regions_exclude = cn-north-1
16+
17+
# When generating inventory, Ansible needs to know how to address a server.
18+
# Each EC2 instance has a lot of variables associated with it. Here is the list:
19+
# http://docs.pythonboto.org/en/latest/ref/ec2.html#module-boto.ec2.instance
20+
# Below are 2 variables that are used as the address of a server:
21+
# - destination_variable
22+
# - vpc_destination_variable
23+
24+
# This is the normal destination variable to use. If you are running Ansible
25+
# from outside EC2, then 'public_dns_name' makes the most sense. If you are
26+
# running Ansible from within EC2, then perhaps you want to use the internal
27+
# address, and should set this to 'private_dns_name'. The key of an EC2 tag
28+
# may optionally be used; however the boto instance variables hold precedence
29+
# in the event of a collision.
30+
destination_variable = public_dns_name
31+
32+
# For server inside a VPC, using DNS names may not make sense. When an instance
33+
# has 'subnet_id' set, this variable is used. If the subnet is public, setting
34+
# this to 'ip_address' will return the public IP address. For instances in a
35+
# private subnet, this should be set to 'private_ip_address', and Ansible must
36+
# be run from within EC2. The key of an EC2 tag may optionally be used; however
37+
# the boto instance variables hold precedence in the event of a collision.
38+
# WARNING: - instances that are in the private vpc, _without_ public ip address
39+
# will not be listed in the inventory until You set:
40+
# vpc_destination_variable = 'private_ip_address'
41+
vpc_destination_variable = ip_address
42+
43+
# To tag instances on EC2 with the resource records that point to them from
44+
# Route53, uncomment and set 'route53' to True.
45+
route53 = False
46+
47+
# To exclude RDS instances from the inventory, uncomment and set to False.
48+
#rds = False
49+
50+
# To exclude ElastiCache instances from the inventory, uncomment and set to False.
51+
#elasticache = False
52+
53+
# Additionally, you can specify the list of zones to exclude looking up in
54+
# 'route53_excluded_zones' as a comma-separated list.
55+
# route53_excluded_zones = samplezone1.com, samplezone2.com
56+
57+
# By default, only EC2 instances in the 'running' state are returned. Set
58+
# 'all_instances' to True to return all instances regardless of state.
59+
all_instances = False
60+
61+
# By default, only EC2 instances in the 'running' state are returned. Specify
62+
# EC2 instance states to return as a comma-separated list. This
63+
# option is overriden when 'all_instances' is True.
64+
# instance_states = pending, running, shutting-down, terminated, stopping, stopped
65+
66+
# By default, only RDS instances in the 'available' state are returned. Set
67+
# 'all_rds_instances' to True return all RDS instances regardless of state.
68+
all_rds_instances = False
69+
70+
# By default, only ElastiCache clusters and nodes in the 'available' state
71+
# are returned. Set 'all_elasticache_clusters' and/or 'all_elastic_nodes'
72+
# to True return all ElastiCache clusters and nodes, regardless of state.
73+
#
74+
# Note that all_elasticache_nodes only applies to listed clusters. That means
75+
# if you set all_elastic_clusters to false, no node will be return from
76+
# unavailable clusters, regardless of the state and to what you set for
77+
# all_elasticache_nodes.
78+
all_elasticache_replication_groups = False
79+
all_elasticache_clusters = False
80+
all_elasticache_nodes = False
81+
82+
# API calls to EC2 are slow. For this reason, we cache the results of an API
83+
# call. Set this to the path you want cache files to be written to. Two files
84+
# will be written to this directory:
85+
# - ansible-ec2.cache
86+
# - ansible-ec2.index
87+
cache_path = ~/.ansible/tmp
88+
89+
# The number of seconds a cache file is considered valid. After this many
90+
# seconds, a new API call will be made, and the cache file will be updated.
91+
# To disable the cache, set this value to 0
92+
cache_max_age = 300
93+
94+
# Organize groups into a nested/hierarchy instead of a flat namespace.
95+
nested_groups = False
96+
97+
# Replace - tags when creating groups to avoid issues with ansible
98+
replace_dash_in_groups = True
99+
100+
# If set to true, any tag of the form "a,b,c" is expanded into a list
101+
# and the results are used to create additional tag_* inventory groups.
102+
expand_csv_tags = False
103+
104+
# The EC2 inventory output can become very large. To manage its size,
105+
# configure which groups should be created.
106+
group_by_instance_id = True
107+
group_by_region = True
108+
group_by_availability_zone = True
109+
group_by_ami_id = True
110+
group_by_instance_type = True
111+
group_by_key_pair = True
112+
group_by_vpc_id = True
113+
group_by_security_group = True
114+
group_by_tag_keys = True
115+
group_by_tag_none = True
116+
group_by_route53_names = True
117+
group_by_rds_engine = True
118+
group_by_rds_parameter_group = True
119+
group_by_elasticache_engine = True
120+
group_by_elasticache_cluster = True
121+
group_by_elasticache_parameter_group = True
122+
group_by_elasticache_replication_group = True
123+
124+
# If you only want to include hosts that match a certain regular expression
125+
# pattern_include = staging-*
126+
127+
# If you want to exclude any hosts that match a certain regular expression
128+
# pattern_exclude = staging-*
129+
130+
# Instance filters can be used to control which instances are retrieved for
131+
# inventory. For the full list of possible filters, please read the EC2 API
132+
# docs: http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeInstances.html#query-DescribeInstances-filters
133+
# Filters are key/value pairs separated by '=', to list multiple filters use
134+
# a list separated by commas. See examples below.
135+
136+
# Retrieve only instances with (key=value) env=staging tag
137+
# instance_filters = tag:env=staging
138+
139+
# Retrieve only instances with role=webservers OR role=dbservers tag
140+
# instance_filters = tag:role=webservers,tag:role=dbservers
141+
142+
# Retrieve only t1.micro instances OR instances with tag env=staging
143+
# instance_filters = instance-type=t1.micro,tag:env=staging
144+
145+
# You can use wildcards in filter values also. Below will list instances which
146+
# tag Name value matches webservers1*
147+
# (ex. webservers15, webservers1a, webservers123 etc)
148+
# instance_filters = tag:Name=webservers1*
149+
150+
# A boto configuration profile may be used to separate out credentials
151+
# see http://boto.readthedocs.org/en/latest/boto_config_tut.html
152+
# boto_profile = some-boto-profile-name

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy