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
93874949
Commit
93874949
authored
Dec 01, 2014
by
Fred Smith
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1592 from edx/derf/remove_jump_box_ssh_config
make jump box specifiable and overridable
parents
7d443bf9
b8a05faf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
26 deletions
+65
-26
util/vpc-tools/vpc-tools.py
+65
-26
No files found.
util/vpc-tools/vpc-tools.py
View file @
93874949
"""VPC Tools.
Usage:
vpc-tools.py ssh-config (vpc <vpc_id> | stack-name <stack_name>) [(identity-file <identity_file>)] user <user> [(config-file <config_file>)] [(strict-host-check <strict_host_check>)]
vpc-tools.py ssh-config (vpc <vpc_id> | stack-name <stack_name>) [(identity-file <identity_file>)] user <user> [(config-file <config_file>)] [(strict-host-check <strict_host_check>)]
[(jump-box <jump_box>)]
vpc-tools.py (-h --help)
vpc-tools.py (-v --version)
...
...
@@ -39,6 +39,16 @@ Host {name}
{identity_line}
"""
DIRECT_HOST_CONFIG
=
"""# Instance ID: {instance_id}
Host {name}
HostName {ip}
ForwardAgent yes
User {user}
StrictHostKeyChecking {strict_host_check}
{identity_line}
"""
BASTION_HOST_CONFIG
=
"""# Instance ID: {instance_id}
Host {name}
HostName {ip}
...
...
@@ -88,7 +98,11 @@ def _ssh_config(args):
else
:
config_file
=
""
jump_box
=
"{stack_name}-bastion"
.
format
(
stack_name
=
stack_name
)
if
args
.
get
(
"jump-box"
):
jump_box
=
args
.
get
(
"<jump_box>"
)
else
:
jump_box
=
"{stack_name}-bastion"
.
format
(
stack_name
=
stack_name
)
friendly
=
"{stack_name}-{logical_id}-{instance_number}"
id_type_counter
=
defaultdict
(
int
)
...
...
@@ -144,30 +158,55 @@ def _ssh_config(args):
else
:
# Print host config even for the bastion box because that is how
# ansible accesses it.
print
HOST_CONFIG
.
format
(
name
=
instance
.
private_ip_address
,
jump_box
=
jump_box
,
ip
=
instance
.
private_ip_address
,
user
=
user
,
config_file
=
config_file
,
strict_host_check
=
strict_host_check
,
instance_id
=
instance
.
id
,
identity_line
=
identity_line
)
#duplicating for convenience with ansible
name
=
friendly
.
format
(
stack_name
=
stack_name
,
logical_id
=
logical_id
,
instance_number
=
instance_number
)
print
HOST_CONFIG
.
format
(
name
=
name
,
jump_box
=
jump_box
,
ip
=
instance
.
private_ip_address
,
user
=
user
,
config_file
=
config_file
,
strict_host_check
=
strict_host_check
,
instance_id
=
instance
.
id
,
identity_line
=
identity_line
)
if
jump_box
==
"none"
:
print
DIRECT_HOST_CONFIG
.
format
(
name
=
instance
.
private_ip_address
,
ip
=
instance
.
private_ip_address
,
user
=
user
,
config_file
=
config_file
,
strict_host_check
=
strict_host_check
,
instance_id
=
instance
.
id
,
identity_line
=
identity_line
)
#duplicating for convenience with ansible
name
=
friendly
.
format
(
stack_name
=
stack_name
,
logical_id
=
logical_id
,
instance_number
=
instance_number
)
print
DIRECT_HOST_CONFIG
.
format
(
name
=
name
,
ip
=
instance
.
private_ip_address
,
user
=
user
,
config_file
=
config_file
,
strict_host_check
=
strict_host_check
,
instance_id
=
instance
.
id
,
identity_line
=
identity_line
)
else
:
print
HOST_CONFIG
.
format
(
name
=
instance
.
private_ip_address
,
jump_box
=
jump_box
,
ip
=
instance
.
private_ip_address
,
user
=
user
,
config_file
=
config_file
,
strict_host_check
=
strict_host_check
,
instance_id
=
instance
.
id
,
identity_line
=
identity_line
)
#duplicating for convenience with ansible
name
=
friendly
.
format
(
stack_name
=
stack_name
,
logical_id
=
logical_id
,
instance_number
=
instance_number
)
print
HOST_CONFIG
.
format
(
name
=
name
,
jump_box
=
jump_box
,
ip
=
instance
.
private_ip_address
,
user
=
user
,
config_file
=
config_file
,
strict_host_check
=
strict_host_check
,
instance_id
=
instance
.
id
,
identity_line
=
identity_line
)
if
__name__
==
'__main__'
:
args
=
docopt
(
__doc__
,
version
=
VERSION
)
...
...
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