Skip to content

Commit 814cb69

Browse files
author
Tom Bamford
committed
Act I
0 parents commit 814cb69

File tree

12 files changed

+2956
-0
lines changed

12 files changed

+2956
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.pyc

ansible.cfg

Lines changed: 476 additions & 0 deletions
Large diffs are not rendered by default.

ansible.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
DIR="$(cd `dirname $0` && pwd)"
4+
5+
ANSIBLE_VERSION="$(ansible --version | head -1 | awk '{print $2}')"
6+
[[ "${ANSIBLE_VERSION:0:3}" != "2.5" ]] && echo -e "Supported Ansible version: 2.5\nYou are using version: ${ANSIBLE_VERSION:0:3}\n\nPlease install the supported version" >&2 && exit 1
7+
8+
[[ -z "${ANSIBLE_CONFIG}" ]] && export ANSIBLE_CONFIG="${DIR}/ansible.cfg"
9+
[[ -z "${ANSIBLE_INVENTORY}" ]] && export ANSIBLE_INVENTORY="${DIR}/inventory"
10+
[[ -z "${EC2_INI_PATH}" ]] && export EC2_INI_PATH="${DIR}/inventory/ec2.ini"
11+
[[ -z "${ANSIBLE_ROLES_PATH}" ]] && export ANSIBLE_ROLES_PATH="${DIR}/roles"
12+
[[ -z "${ANSIBLE_VARS_PLUGINS}" ]] && export ANSIBLE_VARS_PLUGINS="${DIR}/vars_plugins"
13+
[[ -z "${AWS_CONFIG_FILE}" ]] && export AWS_CONFIG_FILE="$(readlink -f "${DIR}/aws.ini")"
14+
15+
echo Running from directory: ${DIR}
16+
echo AWS configuration: ${AWS_CONFIG_FILE}
17+
echo Using inventory from: ${ANSIBLE_INVENTORY}
18+
echo EC2 inventory config: ${EC2_INI_PATH}
19+
echo
20+
21+
ansible "$@"
22+
exit $?
23+
24+
# vim: set ts=2 sts=2 sw=2 et:

aws.ini

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[profile ops]
2+
region = us-east-1
3+
role_arn = <ROLE-ARN-HERE>
4+
credential_source = Ec2InstanceMetadata
5+
6+
[profile staging]
7+
region = us-east-1
8+
role_arn = <ROLE-ARN-HERE>
9+
credential_source = Ec2InstanceMetadata
10+
11+
[profile production]
12+
region = us-east-1
13+
role_arn = <ROLE-ARN-HERE>
14+
credential_source = Ec2InstanceMetadata

ec2.ini

Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
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' and do not
14+
# provide the 'regions_exclude' option. If this is set to 'auto', AWS_REGION or
15+
# AWS_DEFAULT_REGION environment variable will be read to determine the region.
16+
regions = all
17+
regions_exclude = us-gov-west-1, cn-north-1
18+
19+
# When generating inventory, Ansible needs to know how to address a server.
20+
# Each EC2 instance has a lot of variables associated with it. Here is the list:
21+
# http://docs.pythonboto.org/en/latest/ref/ec2.html#module-boto.ec2.instance
22+
# Below are 2 variables that are used as the address of a server:
23+
# - destination_variable
24+
# - vpc_destination_variable
25+
26+
# This is the normal destination variable to use. If you are running Ansible
27+
# from outside EC2, then 'public_dns_name' makes the most sense. If you are
28+
# running Ansible from within EC2, then perhaps you want to use the internal
29+
# address, and should set this to 'private_dns_name'. The key of an EC2 tag
30+
# may optionally be used; however the boto instance variables hold precedence
31+
# in the event of a collision.
32+
destination_variable = public_dns_name
33+
34+
# This allows you to override the inventory_name with an ec2 variable, instead
35+
# of using the destination_variable above. Addressing (aka ansible_ssh_host)
36+
# will still use destination_variable. Tags should be written as 'tag_TAGNAME'.
37+
#hostname_variable = tag_Name
38+
39+
# For server inside a VPC, using DNS names may not make sense. When an instance
40+
# has 'subnet_id' set, this variable is used. If the subnet is public, setting
41+
# this to 'ip_address' will return the public IP address. For instances in a
42+
# private subnet, this should be set to 'private_ip_address', and Ansible must
43+
# be run from within EC2. The key of an EC2 tag may optionally be used; however
44+
# the boto instance variables hold precedence in the event of a collision.
45+
# WARNING: - instances that are in the private vpc, _without_ public ip address
46+
# will not be listed in the inventory until You set:
47+
# vpc_destination_variable = private_ip_address
48+
vpc_destination_variable = ip_address
49+
50+
# The following two settings allow flexible ansible host naming based on a
51+
# python format string and a comma-separated list of ec2 tags. Note that:
52+
#
53+
# 1) If the tags referenced are not present for some instances, empty strings
54+
# will be substituted in the format string.
55+
# 2) This overrides both destination_variable and vpc_destination_variable.
56+
#
57+
#destination_format = {0}.{1}.example.com
58+
#destination_format_tags = Name,environment
59+
60+
# To tag instances on EC2 with the resource records that point to them from
61+
# Route53, set 'route53' to True.
62+
route53 = False
63+
64+
# To use Route53 records as the inventory hostnames, uncomment and set
65+
# to equal the domain name you wish to use. You must also have 'route53' (above)
66+
# set to True.
67+
# route53_hostnames = .example.com
68+
69+
# To exclude RDS instances from the inventory, uncomment and set to False.
70+
#rds = False
71+
72+
# To exclude ElastiCache instances from the inventory, uncomment and set to False.
73+
#elasticache = False
74+
75+
# Additionally, you can specify the list of zones to exclude looking up in
76+
# 'route53_excluded_zones' as a comma-separated list.
77+
# route53_excluded_zones = samplezone1.com, samplezone2.com
78+
79+
# By default, only EC2 instances in the 'running' state are returned. Set
80+
# 'all_instances' to True to return all instances regardless of state.
81+
all_instances = False
82+
83+
# By default, only EC2 instances in the 'running' state are returned. Specify
84+
# EC2 instance states to return as a comma-separated list. This
85+
# option is overridden when 'all_instances' is True.
86+
# instance_states = pending, running, shutting-down, terminated, stopping, stopped
87+
88+
# By default, only RDS instances in the 'available' state are returned. Set
89+
# 'all_rds_instances' to True return all RDS instances regardless of state.
90+
all_rds_instances = False
91+
92+
# Include RDS cluster information (Aurora etc.)
93+
include_rds_clusters = False
94+
95+
# By default, only ElastiCache clusters and nodes in the 'available' state
96+
# are returned. Set 'all_elasticache_clusters' and/or 'all_elastic_nodes'
97+
# to True return all ElastiCache clusters and nodes, regardless of state.
98+
#
99+
# Note that all_elasticache_nodes only applies to listed clusters. That means
100+
# if you set all_elastic_clusters to false, no node will be return from
101+
# unavailable clusters, regardless of the state and to what you set for
102+
# all_elasticache_nodes.
103+
all_elasticache_replication_groups = False
104+
all_elasticache_clusters = False
105+
all_elasticache_nodes = False
106+
107+
# API calls to EC2 are slow. For this reason, we cache the results of an API
108+
# call. Set this to the path you want cache files to be written to. Two files
109+
# will be written to this directory:
110+
# - ansible-ec2.cache
111+
# - ansible-ec2.index
112+
cache_path = ~/.ansible/tmp
113+
114+
# The number of seconds a cache file is considered valid. After this many
115+
# seconds, a new API call will be made, and the cache file will be updated.
116+
# To disable the cache, set this value to 0
117+
cache_max_age = 300
118+
119+
# Organize groups into a nested/hierarchy instead of a flat namespace.
120+
nested_groups = False
121+
122+
# Replace - tags when creating groups to avoid issues with ansible
123+
replace_dash_in_groups = True
124+
125+
# If set to true, any tag of the form "a,b,c" is expanded into a list
126+
# and the results are used to create additional tag_* inventory groups.
127+
expand_csv_tags = False
128+
129+
# The EC2 inventory output can become very large. To manage its size,
130+
# configure which groups should be created.
131+
group_by_instance_id = True
132+
group_by_region = True
133+
group_by_availability_zone = True
134+
group_by_aws_account = False
135+
group_by_ami_id = True
136+
group_by_instance_type = True
137+
group_by_instance_state = False
138+
group_by_platform = True
139+
group_by_key_pair = True
140+
group_by_vpc_id = True
141+
group_by_security_group = True
142+
group_by_tag_keys = True
143+
group_by_tag_none = True
144+
group_by_route53_names = True
145+
group_by_rds_engine = True
146+
group_by_rds_parameter_group = True
147+
group_by_elasticache_engine = True
148+
group_by_elasticache_cluster = True
149+
group_by_elasticache_parameter_group = True
150+
group_by_elasticache_replication_group = True
151+
152+
# If you only want to include hosts that match a certain regular expression
153+
# pattern_include = staging-*
154+
155+
# If you want to exclude any hosts that match a certain regular expression
156+
# pattern_exclude = staging-*
157+
158+
# Instance filters can be used to control which instances are retrieved for
159+
# inventory. For the full list of possible filters, please read the EC2 API
160+
# docs: http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeInstances.html#query-DescribeInstances-filters
161+
# Filters are key/value pairs separated by '=', to list multiple filters use
162+
# a list separated by commas. To "AND" criteria together, use "&". Note that
163+
# the "AND" is not useful along with stack_filters and so such usage is not allowed.
164+
# See examples below.
165+
166+
# If you want to apply multiple filters simultaneously, set stack_filters to
167+
# True. Default behaviour is to combine the results of all filters. Stacking
168+
# allows the use of multiple conditions to filter down, for example by
169+
# environment and type of host.
170+
stack_filters = False
171+
172+
# Retrieve only instances with (key=value) env=staging tag
173+
# instance_filters = tag:env=staging
174+
175+
# Retrieve only instances with role=webservers OR role=dbservers tag
176+
# instance_filters = tag:role=webservers,tag:role=dbservers
177+
178+
# Retrieve only t1.micro instances OR instances with tag env=staging
179+
# instance_filters = instance-type=t1.micro,tag:env=staging
180+
181+
# You can use wildcards in filter values also. Below will list instances which
182+
# tag Name value matches webservers1*
183+
# (ex. webservers15, webservers1a, webservers123 etc)
184+
# instance_filters = tag:Name=webservers1*
185+
186+
# Retrieve only instances of type t1.micro that also have tag env=stage
187+
# instance_filters = instance-type=t1.micro&tag:env=stage
188+
189+
# Retrieve instances of type t1.micro AND tag env=stage, as well as any instance
190+
# that are of type m3.large, regardless of env tag
191+
# instance_filters = instance-type=t1.micro&tag:env=stage,instance-type=m3.large
192+
193+
# An IAM role can be assumed, so all requests are run as that role.
194+
# This can be useful for connecting across different accounts, or to limit user
195+
# access
196+
# iam_role = role-arn
197+
198+
# A boto configuration profile may be used to separate out credentials
199+
# see http://boto.readthedocs.org/en/latest/boto_config_tut.html
200+
# boto_profile = some-boto-profile-name
201+
202+
203+
[credentials]
204+
205+
# The AWS credentials can optionally be specified here. Credentials specified
206+
# here are ignored if the environment variable AWS_ACCESS_KEY_ID or
207+
# AWS_PROFILE is set, or if the boto_profile property above is set.
208+
#
209+
# Supplying AWS credentials here is not recommended, as it introduces
210+
# non-trivial security concerns. When going down this route, please make sure
211+
# to set access permissions for this file correctly, e.g. handle it the same
212+
# way as you would a private SSH key.
213+
#
214+
# Unlike the boto and AWS configure files, this section does not support
215+
# profiles.
216+
#
217+
# aws_access_key_id = AXXXXXXXXXXXXXX
218+
# aws_secret_access_key = XXXXXXXXXXXXXXXXXXX
219+
# aws_security_token = XXXXXXXXXXXXXXXXXXXXXXXXXXXX

0 commit comments

Comments
 (0)