Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
configuration
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
configuration
Commits
6e85a471
Commit
6e85a471
authored
Oct 10, 2013
by
John Jarvis
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin' into jarv/deploy
parents
00a9cbda
690038ac
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
59 additions
and
33 deletions
+59
-33
playbooks/ec2.py
+6
-2
playbooks/edx-west/ec2.ini
+2
-0
playbooks/roles/edxlocal/defaults/main.yml
+6
-0
playbooks/roles/edxlocal/tasks/main.yml
+2
-8
util/jenkins/ansible-provision.sh
+1
-2
util/vpc-tools/vpc-tools.py
+30
-21
util/vpc-tools/vpcutil.py
+12
-0
No files found.
playbooks/ec2.py
View file @
6e85a471
...
@@ -137,8 +137,8 @@ class Ec2Inventory(object):
...
@@ -137,8 +137,8 @@ class Ec2Inventory(object):
self
.
index
=
{}
self
.
index
=
{}
# Read settings and parse CLI arguments
# Read settings and parse CLI arguments
self
.
read_settings
()
self
.
parse_cli_args
()
self
.
parse_cli_args
()
self
.
read_settings
()
# Cache
# Cache
if
self
.
args
.
refresh_cache
:
if
self
.
args
.
refresh_cache
:
...
@@ -177,7 +177,7 @@ class Ec2Inventory(object):
...
@@ -177,7 +177,7 @@ class Ec2Inventory(object):
''' Reads the settings from the ec2.ini file '''
''' Reads the settings from the ec2.ini file '''
config
=
ConfigParser
.
SafeConfigParser
()
config
=
ConfigParser
.
SafeConfigParser
()
config
.
read
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
+
'/ec2.ini'
)
config
.
read
(
self
.
args
.
inifile
)
# is eucalyptus?
# is eucalyptus?
self
.
eucalyptus_host
=
None
self
.
eucalyptus_host
=
None
...
@@ -230,6 +230,10 @@ class Ec2Inventory(object):
...
@@ -230,6 +230,10 @@ class Ec2Inventory(object):
help
=
'Get all the variables about a specific instance'
)
help
=
'Get all the variables about a specific instance'
)
parser
.
add_argument
(
'--refresh-cache'
,
action
=
'store_true'
,
default
=
False
,
parser
.
add_argument
(
'--refresh-cache'
,
action
=
'store_true'
,
default
=
False
,
help
=
'Force refresh of cache by making API requests to EC2 (default: False - use cache files)'
)
help
=
'Force refresh of cache by making API requests to EC2 (default: False - use cache files)'
)
default_inifile
=
os
.
environ
.
get
(
"ANSIBLE_EC2_INI"
,
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
+
'/ec2.ini'
)
parser
.
add_argument
(
'--inifile'
,
dest
=
'inifile'
,
help
=
'Path to init script to use'
,
default
=
default_inifile
)
self
.
args
=
parser
.
parse_args
()
self
.
args
=
parser
.
parse_args
()
...
...
playbooks/edx-west/ec2.ini
View file @
6e85a471
[ec2]
[ec2]
regions
=
us-west-1
regions
=
us-west-1
regions_exclude
=
us-gov-west-1
destination_variable
=
public_dns_name
destination_variable
=
public_dns_name
vpc_destination_variable
=
private_dns_name
vpc_destination_variable
=
private_dns_name
cache_path
=
/tmp
cache_path
=
/tmp
cache_max_age
=
300
cache_max_age
=
300
route53
=
False
playbooks/roles/edxlocal/defaults/main.yml
0 → 100644
View file @
6e85a471
---
edxlocal_debian_pkgs
:
-
pymongo
-
python-mysqldb
-
mysql-server-5.5
-
postfix
playbooks/roles/edxlocal/tasks/main.yml
View file @
6e85a471
...
@@ -11,14 +11,8 @@
...
@@ -11,14 +11,8 @@
# http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.62.tar.gz
# http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.62.tar.gz
#
#
---
---
-
name
:
edxlocal | install python-pymongo (req for ansible)
-
name
:
edxlocal| install packages needed for single server
pip
:
name=pymongo
apt
:
pkg={{','.join(edxlocal_debian_pkgs)}} install_recommends=yes state=present
-
name
:
edxlocal | install python-mysqldb (req for ansible)
apt
:
pkg=python-mysqldb state=present
-
name
:
edxlocal | install mysql server and recommends
apt
:
pkg=mysql-server-5.5 state=present install_recommends=yes
-
name
:
edxlocal | create a database for edxapp
-
name
:
edxlocal | create a database for edxapp
mysql_db
:
>
mysql_db
:
>
...
...
util/jenkins/ansible-provision.sh
View file @
6e85a471
...
@@ -96,8 +96,7 @@ cat $extra_vars
...
@@ -96,8 +96,7 @@ cat $extra_vars
cd
playbooks/edx-east
cd
playbooks/edx-east
# run the tasks to launch an ec2 instance from AMI
# run the tasks to launch an ec2 instance from AMI
ansible-playbook
-vvvv
edx_provision.yml
-i
inventory.ini
-e
"@
${
extra_vars
}
"
--user
ubuntu
ansible-playbook
-vvvv
edx_provision.yml
-i
inventory.ini
-e
"@
${
extra_vars
}
"
--user
ubuntu
# run tasks to update application config files that
# run tasks to update application config files for the sandbox hostname
# for the hostnames
if
[[
$server_type
==
"full_edx_installation"
]]
;
then
if
[[
$server_type
==
"full_edx_installation"
]]
;
then
ansible-playbook
-vvvv
edx_continuous_integration.yml
-i
"
${
dns_name
}
.
${
dns_zone
}
,"
-e
"@
${
extra_vars
}
"
--user
ubuntu
--tags
"lms-env,cms-env,lms-preview-env"
ansible-playbook
-vvvv
edx_continuous_integration.yml
-i
"
${
dns_name
}
.
${
dns_zone
}
,"
-e
"@
${
extra_vars
}
"
--user
ubuntu
--tags
"lms-env,cms-env,lms-preview-env"
fi
fi
...
...
util/vpc-tools/vpc-tools.py
View file @
6e85a471
...
@@ -13,6 +13,8 @@ Options:
...
@@ -13,6 +13,8 @@ Options:
import
boto
import
boto
from
docopt
import
docopt
from
docopt
import
docopt
from
vpcutil
import
vpc_for_stack_name
from
vpcutil
import
vpc_for_stack_name
from
vpcutil
import
stack_name_for_vpc
from
collections
import
defaultdict
VERSION
=
"vpc tools 0.1"
VERSION
=
"vpc tools 0.1"
...
@@ -29,6 +31,7 @@ JUMPBOX_CONFIG = """
...
@@ -29,6 +31,7 @@ JUMPBOX_CONFIG = """
"""
"""
HOST_CONFIG
=
"""
HOST_CONFIG
=
"""
# Instance ID: {instance_id}
Host {name}
Host {name}
ProxyCommand ssh {config_file} -W
%
h:
%
p {jump_box}
ProxyCommand ssh {config_file} -W
%
h:
%
p {jump_box}
HostName {ip}
HostName {ip}
...
@@ -47,6 +50,7 @@ def dispatch(args):
...
@@ -47,6 +50,7 @@ def dispatch(args):
def
_ssh_config
(
args
):
def
_ssh_config
(
args
):
if
args
.
get
(
"vpc"
):
if
args
.
get
(
"vpc"
):
vpc_id
=
args
.
get
(
"<vpc_id>"
)
vpc_id
=
args
.
get
(
"<vpc_id>"
)
stack_name
=
stack_name_for_vpc
(
vpc_id
)
elif
args
.
get
(
"stack-name"
):
elif
args
.
get
(
"stack-name"
):
stack_name
=
args
.
get
(
"<stack_name>"
)
stack_name
=
args
.
get
(
"<stack_name>"
)
vpc_id
=
vpc_for_stack_name
(
stack_name
)
vpc_id
=
vpc_for_stack_name
(
stack_name
)
...
@@ -71,17 +75,23 @@ def _ssh_config(args):
...
@@ -71,17 +75,23 @@ def _ssh_config(args):
else
:
else
:
config_file
=
""
config_file
=
""
jump_box
=
"{vpc_id}-jumpbox"
.
format
(
vpc_id
=
vpc_id
)
jump_box
=
"{stack_name}-jumpbox"
.
format
(
stack_name
=
stack_name
)
friendly
=
"{vpc_id}-{logical_id}-{instance_id}"
friendly
=
"{stack_name}-{logical_id}-{instance_number}"
id_type_counter
=
defaultdict
(
int
)
reservations
=
vpc
.
get_all_instances
(
filters
=
{
'vpc-id'
:
vpc_id
})
reservations
=
vpc
.
get_all_instances
(
filters
=
{
'vpc-id'
:
vpc_id
})
for
reservation
in
reservations
:
for
reservation
in
reservations
:
for
instance
in
reservation
.
instances
:
for
instance
in
reservation
.
instances
:
logical_id
=
instance
.
__dict__
[
'tags'
][
'aws:cloudformation:logical-id'
]
if
'group'
in
instance
.
tags
:
logical_id
=
instance
.
tags
[
'group'
]
else
:
logical_id
=
instance
.
tags
[
'aws:cloudformation:logical-id'
]
instance_number
=
id_type_counter
[
logical_id
]
id_type_counter
[
logical_id
]
+=
1
if
logical_id
==
"BastionHost"
:
if
logical_id
==
"BastionHost"
or
logical_id
==
'bastion'
:
print
JUMPBOX_CONFIG
.
format
(
print
JUMPBOX_CONFIG
.
format
(
jump_box
=
jump_box
,
jump_box
=
jump_box
,
...
@@ -90,33 +100,32 @@ def _ssh_config(args):
...
@@ -90,33 +100,32 @@ def _ssh_config(args):
identity_file
=
identity_file
,
identity_file
=
identity_file
,
strict_host_check
=
strict_host_check
)
strict_host_check
=
strict_host_check
)
else
:
# Print host config even for the bastion box because that is how
print
HOST_CONFIG
.
format
(
# ansible accesses it.
name
=
instance
.
private_ip_address
,
print
HOST_CONFIG
.
format
(
vpc_id
=
vpc_id
,
name
=
instance
.
private_ip_address
,
jump_box
=
jump_box
,
jump_box
=
jump_box
,
ip
=
instance
.
private_ip_address
,
ip
=
instance
.
private_ip_address
,
user
=
user
,
user
=
user
,
logical_id
=
logical_id
,
identity_file
=
identity_file
,
identity_file
=
identity
_file
,
config_file
=
config
_file
,
config_file
=
config_file
,
strict_host_check
=
strict_host_check
,
strict_host_check
=
strict_host_check
)
instance_id
=
instance
.
id
)
#duplicating for convenience with ansible
#duplicating for convenience with ansible
name
=
friendly
.
format
(
vpc_id
=
vpc_id
,
name
=
friendly
.
format
(
stack_name
=
stack_name
,
logical_id
=
logical_id
,
logical_id
=
logical_id
,
instance_id
=
instance
.
id
)
instance_number
=
instance_number
)
print
HOST_CONFIG
.
format
(
print
HOST_CONFIG
.
format
(
name
=
name
,
name
=
name
,
vpc_id
=
vpc_id
,
jump_box
=
jump_box
,
jump_box
=
jump_box
,
ip
=
instance
.
private_ip_address
,
ip
=
instance
.
private_ip_address
,
user
=
user
,
user
=
user
,
logical_id
=
logical_id
,
identity_file
=
identity_file
,
identity_file
=
identity_file
,
config_file
=
config_file
,
config_file
=
config_file
,
strict_host_check
=
strict_host_check
)
strict_host_check
=
strict_host_check
,
instance_id
=
instance
.
id
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
args
=
docopt
(
__doc__
,
version
=
VERSION
)
args
=
docopt
(
__doc__
,
version
=
VERSION
)
...
...
util/vpc-tools/vpcutil.py
View file @
6e85a471
...
@@ -7,3 +7,15 @@ def vpc_for_stack_name(stack_name):
...
@@ -7,3 +7,15 @@ def vpc_for_stack_name(stack_name):
if
resource
.
resource_type
==
'AWS::EC2::VPC'
:
if
resource
.
resource_type
==
'AWS::EC2::VPC'
:
return
resource
.
physical_resource_id
return
resource
.
physical_resource_id
def
stack_name_for_vpc
(
vpc_name
):
cfn_tag_key
=
'aws:cloudformation:stack-name'
vpc
=
boto
.
connect_vpc
()
resource
=
vpc
.
get_all_vpcs
(
vpc_ids
=
[
vpc_name
])[
0
]
if
cfn_tag_key
in
resource
.
tags
:
return
resource
.
tags
[
cfn_tag_key
]
else
:
msg
=
"VPC({}) is not part of a cloudformation stack."
.
format
(
vpc_name
)
raise
Exception
(
msg
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment