Adjusting script and file names
parent
e5f4c413a3
commit
996e347a6f
|
|
@ -0,0 +1,12 @@
|
|||
EMEA_PROD:
|
||||
- environments: [E2E,PROD]
|
||||
EMEA_PREPROD:
|
||||
- environments: [TEST,INT]
|
||||
NA_PROD:
|
||||
- environments: [E2E,PROD]
|
||||
NA_PREPROD:
|
||||
- environments: [TEST,INT]
|
||||
CN_PROD:
|
||||
- environments: [E2E,PROD]
|
||||
CN_PREPROD:
|
||||
- environments: [TEST,INT]
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
EMEA_PROD:
|
||||
- environments: ["E2E","PROD"]
|
||||
EMEA_PREPROD:
|
||||
- environments: ["TEST","INT"]
|
||||
NA_PROD:
|
||||
- environments: ["E2E","PROD"]
|
||||
NA_PREPROD:
|
||||
- environments: ["TEST","INT"]
|
||||
CD_PROD:
|
||||
- environments: ["E2E","PROD"]
|
||||
CN_PREPROD:
|
||||
- environments: ["TEST","INT"]
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
import yaml
|
||||
from decouple import config
|
||||
import argparse
|
||||
import os
|
||||
parser = argparse.ArgumentParser(description="Generate predefined Dynatrace configuration via Terraform",
|
||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
||||
|
||||
parser.add_argument("-A", "--appname", type=str,required=True, help="Your app_name")
|
||||
parser.add_argument('-C', "--compassid", type=str,required=True, help="Your compass_id")
|
||||
args = parser.parse_args()
|
||||
|
||||
#Config options for onboarding. Will be extended with other configuration options in future
|
||||
configoptions = ["management_zone"]
|
||||
envconfigoptions = ["alerting","dashboard"]
|
||||
def main(slo_path):
|
||||
print("Generating tf files...")
|
||||
if args.appname and args.compassid:
|
||||
|
||||
with open('./environment.yaml') as file:
|
||||
doc = yaml.safe_load(file)
|
||||
|
||||
for item, doc in doc.items():
|
||||
envs = dict(doc[0])
|
||||
for configoption in configoptions:
|
||||
with open('./_templates/_template_'+configoption+'.tf') as file:
|
||||
data = file.read()
|
||||
data = data.replace("<APPNAME>", args.appname)
|
||||
data = data.replace("<COMPASSID>", args.compassid.lower())
|
||||
#print('./'+item+'/'+configoption+'/'+args.appname+'.tf')
|
||||
with open('./'+item+'/'+configoption+'/'+args.appname+'.tf', 'w') as file:
|
||||
file.write(data)
|
||||
for envconfigoption in envconfigoptions:
|
||||
for env in envs.get("environments"):
|
||||
with open('./_templates/_template_'+envconfigoption+'.tf') as file:
|
||||
data = file.read()
|
||||
data = data.replace("<APPNAME>", args.appname)
|
||||
data = data.replace("<COMPASSID>", args.compassid.lower())
|
||||
data = data.replace("<APPENV>", env)
|
||||
#print('./'+item+'/'+envconfigoption+'/'+args.appname+'_'+env+'.tf')
|
||||
with open('./'+item+'/'+envconfigoption+'/'+args.appname+'_'+env+'.tf', 'w') as file:
|
||||
file.write(data)
|
||||
else:
|
||||
print("ERROR: No appname/compassid specified")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main('')
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
# Dynatrace onboarding repo / Terreform config
|
||||
This repository holds the Dynatrace configuration for onboarding purposes
|
||||
|
||||
# Prerequisites
|
||||
|
||||
## Python packages
|
||||
Before executing scripts, python requirements have to be satisfied. To do so, execute following command:
|
||||
pip install -r requirements.txt
|
||||
|
||||
# Usage
|
||||
|
||||
1. Clone template:
|
||||
git clone --branch template ssh://git@git.bmwgroup.net:7999/opapm/coco_apm_terraform_onboarding.git
|
||||
2. Create branch:
|
||||
git checkout -b CD_<appname>
|
||||
3.Install python dependencies:
|
||||
pip install -r requirements.txt
|
||||
4.Run onboarding script:
|
||||
python ./onboarding.py -A CD_<app_name> -C <compass_id>
|
||||
5. Review created files:
|
||||
git status
|
||||
6. Commit your changes:
|
||||
git add <changes>
|
||||
|
||||
git commit -m "<OPMAAS-XXX> - Add initial configuration of application <app_name> to Dynatrace"
|
||||
|
||||
git push -u origin CD_<app_name>
|
||||
7. Create pull request from CD_<app_name> to master
|
||||
# Files
|
||||
|
||||
## onboarding.py
|
||||
|
||||
This scripts generates predefined configuration basing on your app_name and compass ids
|
||||
|
||||
## requirements.txt
|
||||
|
||||
File containing required python packages
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
python-decouple
|
||||
pyyaml
|
||||
argparse
|
||||
Loading…
Reference in New Issue