-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjenkins-cf.template
127 lines (127 loc) · 4.17 KB
/
jenkins-cf.template
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
{
"Description": "Effective DevOps in AWS: HelloWorld web application",
"Outputs": {
"InstancePublicIp": {
"Description": "Public IP of our instance.",
"Value": {
"Fn::GetAtt": [
"instance",
"PublicIp"
]
}
},
"WebUrl": {
"Description": "Application endpoint",
"Value": {
"Fn::Join": [
"",
[
"http://",
{
"Fn::GetAtt": [
"instance",
"PublicDnsName"
]
},
":",
"8080"
]
]
}
}
},
"Parameters": {
"KeyPair": {
"ConstraintDescription": "must be the name of an existing EC2 KeyPair.",
"Description": "Name of an existing EC2 KeyPair to SSH",
"Type": "AWS::EC2::KeyPair::KeyName"
}
},
"Resources": {
"InstanceProfile": {
"Properties": {
"Path": "/",
"Roles": [
{
"Ref": "Role"
}
]
},
"Type": "AWS::IAM::InstanceProfile"
},
"Role": {
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": [
"sts:AssumeRole"
],
"Effect": "Allow",
"Principal": {
"Service": [
"ec2.amazonaws.com"
]
}
}
]
}
},
"Type": "AWS::IAM::Role"
},
"SecurityGroup": {
"Properties": {
"GroupDescription": "Allow SSH and TCP/8080 access",
"SecurityGroupIngress": [
{
"CidrIp": "222.237.167.120/32",
"FromPort": "22",
"IpProtocol": "tcp",
"ToPort": "22"
},
{
"CidrIp": "0.0.0.0/0",
"FromPort": "8080",
"IpProtocol": "tcp",
"ToPort": "8080"
}
]
},
"Type": "AWS::EC2::SecurityGroup"
},
"instance": {
"Properties": {
"IamInstanceProfile": {
"Ref": "InstanceProfile"
},
"ImageId": "ami-00dc207f8ba6dc919",
"InstanceType": "t2.micro",
"KeyName": {
"Ref": "KeyPair"
},
"SecurityGroups": [
{
"Ref": "SecurityGroup"
}
],
"UserData": {
"Fn::Base64": {
"Fn::Join": [
"\n",
[
"#!/bin/bash",
"yum remove java-1.7.0-openjdk -y",
"yum install java-1.8.0-openjdk -y",
"yum install --enablerepo=epel -y git",
"pip install ansible",
"/usr/local/bin/ansible-pull -U https://github.com/Justin-ad-Park/ansible jenkins.yml -i localhost",
"echo '*/10 * * * * /usr/local/bin/ansible-pull -U https://github.com/Justin-ad-Park/ansible jenkins.yml -i localhost' > /etc/cron.d/ansible-pull"
]
]
}
}
},
"Type": "AWS::EC2::Instance"
}
}
}