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
f98ad043
Commit
f98ad043
authored
Jun 04, 2013
by
e0d
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding simple ssh config generater
parent
d4088afb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
94 additions
and
0 deletions
+94
-0
util/vpc-tools/requirements.txt
+3
-0
util/vpc-tools/vpc-tools.py
+91
-0
No files found.
util/vpc-tools/requirements.txt
0 → 100644
View file @
f98ad043
boto
docopt
\ No newline at end of file
util/vpc-tools/vpc-tools.py
0 → 100644
View file @
f98ad043
"""VPC Tools.
Usage:
vpc-tools.py ssh-config vpc <vpc_id> identity-file <identity_file> user <user>
vpc-tools.py (-h --help)
vpc-tools.py (-v --version)
Options:
-h --help Show this screen.
-v --version Show version.
"""
import
boto
from
docopt
import
docopt
VERSION
=
"vpc tools 0.1"
DEFAULT_USER
=
"ubuntu"
JUMPBOX_CONFIG
=
"""
Host {jump_box}
HostName {ip}
IdentityFile {identity_file}
ForwardAgent yes
User {user}
"""
HOS_CONFIG
=
"""
Host {ip}
ProxyCommand ssh -W
%
h:
%
p {jump_box}
HostName {ip}
IdentityFile {identity_file}
ForwardAgent yes
User {user}
"""
def
dispatch
(
args
):
if
args
.
get
(
"ssh-config"
):
_ssh_config
(
args
)
def
_ssh_config
(
args
):
vpc
=
boto
.
connect_vpc
()
identity_file
=
args
.
get
(
"<identity_file>"
)
user
=
args
.
get
(
"<user>"
,
DEFAULT_USER
)
vpc_id
=
args
.
get
(
"<vpc_id>"
)
jump_box
=
"{vpc_id}-jumpbox"
.
format
(
vpc_id
=
vpc_id
)
reservations
=
vpc
.
get_all_instances
(
filters
=
{
'vpc-id'
:
vpc_id
})
for
reservation
in
reservations
:
for
instance
in
reservation
.
instances
:
logical_id
=
instance
.
__dict__
[
'tags'
][
'aws:cloudformation:logical-id'
]
if
logical_id
==
"BastionHost"
:
print
JUMPBOX_CONFIG
.
format
(
jump_box
=
jump_box
,
ip
=
instance
.
ip_address
,
user
=
user
,
identity_file
=
identity_file
)
else
:
print
HOS_CONFIG
.
format
(
vpc_id
=
vpc_id
,
jump_box
=
jump_box
,
ip
=
instance
.
private_ip_address
,
user
=
user
,
logical_id
=
logical_id
,
identity_file
=
identity_file
)
#duplicating for convenience with ansible
print
HOS_CONFIG
.
format
(
vpc_id
=
vpc_id
,
jump_box
=
jump_box
,
ip
=
instance
.
private_ip_address
,
user
=
user
,
logical_id
=
logical_id
,
identity_file
=
identity_file
)
if
__name__
==
'__main__'
:
args
=
docopt
(
__doc__
,
version
=
VERSION
)
dispatch
(
args
)
\ No newline at end of file
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