-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjenkins.tf
47 lines (42 loc) · 1.49 KB
/
jenkins.tf
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
resource "aws_instance" "jenkins" {
ami = ami-00399ec92321828f5
instance_type = "t2.micro"
security_groups = [aws_security_group.web_traffic.name]
key_name = "kluu"
provisioner "remote-exec" {
inline = [
"wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -",
"sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'",
"sudo apt update -qq",
"sudo apt install -y default-jre",
"sudo apt install -y jenkins",
"sudo systemctl start jenkins",
"sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080",
"sudo sh -c \"iptables-save > /etc/iptables.rules\"",
"echo iptables-persistent iptables-persistent/autosave_v4 boolean true | sudo debconf-set-selections",
"echo iptables-persistent iptables-persistent/autosave_v6 boolean true | sudo debconf-set-selections",
"sudo apt-get -y install iptables-persistent",
"sudo ufw allow 8080",
]
}
connection {
type = "ssh"
host = self.public_ip
user = "ubuntu"
private_key = file("~/kluu.pem")
}
tags = {
"Name" = "Jenkins_Server"
"Terraform" = "true"
}
}
resource "aws_instance" "web" {
# puppet instalation
provisioner "puppet" {
server = aws_instance.puppetmaster.public-subnet
server_user = "ec2-user"
extension_requests = {
pp_role = "webserver"
}
}
}