This repository was archived by the owner on May 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.py
executable file
·54 lines (43 loc) · 1.68 KB
/
bootstrap.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
53
54
#!/usr/bin/env python
import settings
import string
import random
import re
from scripts import fearless_github
from scripts import slack
from scripts import aws
def confirm(message):
confirmed = None
while confirmed is None:
response = (raw_input(message+" [Yn]: ").lower() or 'y')
if response.startswith('y'): confirmed = True
if response.startswith('n'): confirmed = False
return confirmed
with open('resources/fearless.txt', 'r') as fearless:
print fearless.read()
print "Let's get started!"
project_name = "devops-"+''.join(random.SystemRandom().choice(string.ascii_letters + string.digits) for _ in range(7))
project_name = raw_input( "First, give a name for your project, or hit [enter] for default name ["+project_name+"]: ") or project_name
project_name = re.sub("[^0-9a-zA-Z]","-",project_name)
create_slack = confirm("1) Should I create a SLACK channel with title '"+project_name+"'?")
create_github = confirm("2) Should I create a GITHUB repository with name '"+project_name+"'?")
create_aws = confirm("3) Should I create an EC2 instance named '"+project_name+"'?")
print "Received project name: "+project_name
response = "Here are the results:\n"
if create_slack:
print "# Creating slack channel '"+project_name+"'"
response += slack.create_channel(project_name) + "\n"
else:
print "NOT creating slack channel."
if create_github:
print "# Creating GitHub repository"
response += fearless_github.create_repo(project_name) + "\n"
else:
print "NOT creating github repo."
if create_aws:
print "# Creating EC2 instance"
response += aws.launch_ec2(project_name) + "\n"
else:
print "NOT creating EC2 instance."
print "\n\n### Completed all integrations."
print response