-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure.py
executable file
·52 lines (38 loc) · 1.25 KB
/
configure.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python
import yaml
import string
import random
def ask_question(question, config, key):
current = ''
if key in config:
current = config[key]
question = question + ' [' + current + ']: '
try:
response = raw_input(question)
except NameError:
# Python 3
response = input(question)
if response == '':
return
config[key] = response
def random_password():
chars = string.letters
chars = chars + '0123456789'
password = ''
for i in range(0, 16):
password = password + random.choice(chars)
return password
with open("provisioning/user_vars.yml", 'r') as stream:
config = yaml.load(stream)
stream.close()
ask_question('What is your github username?', config, 'gh_user')
if 'mysql_password' not in config:
print('Generating random MySQL password')
config['mysql_password'] = random_password()
print('MySQL dw password is ' + config['mysql_password'])
if 'system_password' not in config:
print('Generating random system password')
config['system_password'] = random_password()
print('System password is ' + config['system_password'])
with open("provisioning/user_vars.yml", 'w') as f:
f.write(yaml.dump(config, default_flow_style=False))