Created
November 10, 2015 10:09
-
-
Save bmoussaud/1c2247df94871b0fefee to your computer and use it in GitHub Desktop.
Custom Personal Crendential plugins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mappings(): | |
mapping = {} | |
mapping['tomcat.VirtualHost']=(lambda c: c.server.host) | |
mapping['was.Cluster']=(lambda c: c.getHost()) | |
mapping['wls.Cluster']=(lambda c: c.getHost()) | |
mapping['wls.JmsServer']=(lambda c: c.getHost()) | |
mapping['cyber-ark.SshHost']=(lambda c: c) | |
mapping['overthere.SshHost']=(lambda c: c) | |
mapping['overthere.LocalHost']=(lambda c: c) | |
mapping['overthere.CifsHost']=(lambda c: c) | |
return mapping | |
def to_host(delta): | |
container = delta.deployedOrPrevious.container | |
if container.hasProperty('host'): | |
return container.host | |
else: | |
return mappings()[str(container.type)](container) | |
def hosts(candidate_filter): | |
return set(map(to_host, filter(candidate_filter, specification.deltas))) | |
def secured_hosts(): | |
return hosts(lambda delta : to_host(delta).type == "cyber-ark.SshHost") | |
def deployedApp(): | |
if specification.operation == 'DESTROY': | |
return previousDeployedApplication | |
else: | |
return deployedApplication | |
def generate_steps(host): | |
context.addStep(steps.jython( | |
description="Inject credential information '%s' using the '%s' vault server" % (host.name, host.vault.name), | |
order=20, | |
script_path="cyberark/fetch_credentials.py", | |
jython_context={'host': host, 'deployedApp': deployedApp()}) | |
) | |
print "-----------------------------------" | |
print specification | |
print specification.operation | |
print "-----------------------------------" | |
#map(generate_steps, secured_hosts()) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<rule name="personal.inject.crendentials" scope="pre-plan"> | |
<planning-script-path>personal/inject.py</planning-script-path> | |
</rule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment