forked from project-sunbird/sunbird-devops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateConfigYml.py
36 lines (32 loc) · 1.69 KB
/
createConfigYml.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
configVars = ['env','implementation_name','ssh_ansible_user','ansible_private_key_path','application_host','app_address_space','dns_name','proto','database_host','database_password','keycloak_admin_password','sso_password','trampoline_secret','backup_storage_key','badger_admin_password','badger_admin_email','ekstep_api_key','sunbird_image_storage_url','sunbird_azure_storage_key','sunbird_azure_storage_account']
configToWrite = []
contentToCreateCurl = []
with open('config_templet','r') as fp:
lines = fp.readlines()
for line in lines:
for key in configVars:
if key in line:
keyName = key+ ':'
keyValue = keyName +' '+ os.getenv(key)
line = line.replace(keyName, keyValue)
contentToCreateCurl.insert(len(contentToCreateCurl),keyValue)
configToWrite.insert(len(configToWrite),line)
fp.close()
with open('config','w') as fp:
fp.writelines(configToWrite)
fp.close()
with open('confValue.yml','w') as fp:
fp.writelines(contentToCreateCurl)
fp.close()
# import yaml
# # import os
# # fname = "config"
# # configElement = ['env','implementation_name','ssh_ansible_user','sudo_passwd','ansible_private_key_path','application_host','app_address_space','dns_name','proto','database_host','database_password','keycloak_admin_password','sso_password','trampoline_secret','backup_storage_key','badger_admin_password','badger_admin_email','ekstep_api_key','sunbird_image_storage_url','sunbird_azure_storage_key','sunbird_azure_storage_account']
# # with open(fname, "w") as f:
# # for key in configElement:
# # configLine = key + ': ' + "NULL \n" if os.getenv(key) is None else key + ': ' + os.getenv(key)+'\n'
# # print configLine
# # f.write(configLine)
# #
# #