Created
June 8, 2021 18:41
-
-
Save Anthonyhawkins/fb3f6730df913858fed01ba1a6f3ec06 to your computer and use it in GitHub Desktop.
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
from src.configer import generate | |
from src.configer import Sources, Files | |
from src.configer import env | |
from src.configer import Include | |
sources = Sources({ | |
"vars": "vars.yml", | |
"other": "other_vars.yml" | |
}) | |
files = Files({ | |
"my_cert": "cert.pem" | |
}) | |
class Task(object): | |
@staticmethod | |
def cf_mgmt(command): | |
return { | |
"task": command, | |
"image": "cf-mgmt", | |
"config": { | |
"platform": "linux", | |
"inputs": [ | |
{"name": "config-repo"} | |
], | |
"params": { | |
"SYSTEM_DOMAIN": sources.grab("vars", "meta.system_domain"), | |
"USER_ID": sources.grab("vars", "meta.user_id"), | |
"PASSWORD": env("PASSWORD"), | |
"CONFIG_DIR": "config-repo/orgs/" + env("CF_ENVIRONMENT"), | |
"CLIENT_SECRET": env("CLIENT_SECRET"), | |
"LOG_LEVEL": "info", | |
"CF_MGMT_COMMAND": command | |
}, | |
"run": { | |
"path": "config-repo/ci/tasks/cf-mgmt.sh" | |
} | |
} | |
} | |
class Resource(object): | |
@staticmethod | |
def get(name, passed=[], trigger=True): | |
return { | |
"get": name, | |
} | Include.when(passed, { | |
"passed": passed | |
}) | Include.when(trigger, { | |
"trigger": True | |
}) | |
config = { | |
"resources": [ | |
{ | |
"name": "config-repo", | |
"type": "git", | |
"source": { | |
"uri": "https://corp.domain.int/gitrepo/project/config-repo.git", | |
"branch": "master", | |
"paths": [ | |
"config-repo/orgs/" + env("CF_ENVIRONMENT") | |
], | |
"username": env("GIT_USER"), | |
"password": env("GIT_PASSWORD") | |
} | |
}, | |
{ | |
"name": "cf-mgmt", | |
"type": "docker-image", | |
"source": { | |
"repository": sources.grab("vars", "meta.docker_domain") + "/cf-mgmt", | |
"tag": "1.0.48", | |
"ca_certs": [ | |
files.grab("my_cert") | |
] | |
} | |
}, | |
{ | |
"name": "time-trigger", | |
"type": "time", | |
"source": { | |
"interval": "1h" | |
} | |
} | |
], # end resources | |
"jobs": [ | |
{ | |
"name": "create-orgs", | |
"plan": [ | |
Resource.get("config-repo"), | |
Resource.get("time-trigger"), | |
Task.cf_mgmt("create-orgs") | |
] | |
}, | |
{ | |
"name": "shared-domains", | |
"plan": [ | |
Resource.get("config-repo"), | |
Resource.get("time-trigger"), | |
Task.cf_mgmt("shared-domains") | |
] | |
}, | |
{ | |
"name": "create-security-groups", | |
"plan": [ | |
Resource.get("config-repo"), | |
Resource.get("time-trigger"), | |
Task.cf_mgmt("create-security-groups") | |
] | |
}, | |
{ | |
"name": "assign-default-security-groups", | |
"plan": [ | |
Resource.get("config-repo", passed=["create-security-groups"]), | |
Resource.get("time-trigger"), | |
Task.cf_mgmt("assign-default-security-groups") | |
] | |
} | |
] | |
} | |
generate(config) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment