Last active
November 27, 2017 19:39
-
-
Save s4l1h/b29e81c866bcb740153e1ff404dc367a to your computer and use it in GitHub Desktop.
Terraform Kullanımı https://medium.com/@s4l1h/terraform-kullan%C4%B1m%C4%B1-b9719e96d609
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
acl CONNECT method CONNECT | |
# line 919: add (define ACL for internal) | |
acl lan src 10.0.0.0/24 | |
http_access allow localhost | |
# line 1058: add (set ACL for internal) | |
http_access allow lan | |
http_access allow all | |
http_port 3120 | |
via off | |
forwarded_for delete | |
cache deny all |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# squid.tf dosyası | |
# https://medium.com/@s4l1h/terraform-kullan%C4%B1m%C4%B1-b9719e96d609 | |
variable "do_token" { | |
default = "<<<<<<digitalocean token>>>>>>>>" | |
} | |
# ssh-keygen -t rsa -f ./id_rsa | |
variable "pub_key" { | |
default = "./id_rsa.pub" | |
} | |
variable "pvt_key" { | |
default="./id_rsa" | |
} | |
variable "ssh_fingerprint" { | |
default="f2:73:1b:f7:4a:54:2e:e0:f4:84:f8:b2:e6:fd:75:71" # ssh-keygen -E md5 -lf ./id_rsa | awk '{print $2}' | |
} | |
provider "digitalocean" { | |
token = "${var.do_token}" | |
} | |
resource "digitalocean_droplet" "squid" { | |
image = "debian-9-x64" | |
name="squid" | |
region = "lon1" | |
size = "512mb" | |
private_networking = true | |
ssh_keys = [ | |
"${var.ssh_fingerprint}" | |
] | |
connection { | |
user = "root" | |
type = "ssh" | |
private_key = "${file(var.pvt_key)}" | |
timeout = "2m" | |
} | |
provisioner "remote-exec" { | |
inline = [ | |
# update and install ntp,curl,htop,squid | |
"sudo apt-get update", | |
"sudo apt-get -y install ntp curl htop squid" | |
] | |
} | |
provisioner "file" { | |
source = "squid.conf" | |
destination = "/etc/squid/squid.conf" | |
} | |
provisioner "remote-exec" { | |
inline = [ | |
"systemctl restart squid" | |
] | |
} | |
provisioner "local-exec" { | |
command="rm ip.txt" #eski ip.txt dosyasını sil | |
on_failure = "continue" # hata verirse devam et | |
} | |
provisioner "local-exec" { | |
command="echo ${self.ipv4_address} >> ip.txt" # ip adresini ip.txt yaz. | |
} | |
} | |
output "ip" { | |
value = "${digitalocean_droplet.squid.ipv4_address}" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# squidMulti.tf dosyası Count kullanarak çoklu sunucu oluşturmak için | |
# https://medium.com/@s4l1h/terraform-kullan%C4%B1m%C4%B1-b9719e96d609 | |
variable "do_token" { | |
default = "<<<<<<digitalocean token>>>>>>>>" | |
} | |
# ssh-keygen -t rsa -f ./id_rsa | |
variable "pub_key" { | |
default = "./id_rsa.pub" | |
} | |
variable "pvt_key" { | |
default="./id_rsa" | |
} | |
variable "ssh_fingerprint" { | |
default="f2:73:1b:f7:4a:54:2e:e0:f4:84:f8:b2:e6:fd:75:71" # ssh-keygen -E md5 -lf ./id_rsa | awk '{print $2}' | |
} | |
provider "digitalocean" { | |
token = "${var.do_token}" | |
} | |
resource "digitalocean_droplet" "squid" { | |
count=10 | |
image = "debian-9-x64" | |
name="squid-${count.index}" | |
region = "lon1" | |
size = "512mb" | |
private_networking = true | |
ssh_keys = [ | |
"${var.ssh_fingerprint}" | |
] | |
connection { | |
user = "root" | |
type = "ssh" | |
private_key = "${file(var.pvt_key)}" | |
timeout = "2m" | |
} | |
provisioner "remote-exec" { | |
inline = [ | |
# update and install ntp,curl,htop,squid | |
"sudo apt-get update", | |
"sudo apt-get -y install ntp curl htop squid" | |
] | |
} | |
provisioner "file" { | |
source = "squid.conf" | |
destination = "/etc/squid/squid.conf" | |
} | |
provisioner "remote-exec" { | |
inline = [ | |
"systemctl restart squid" | |
] | |
} | |
provisioner "local-exec" { | |
command="rm ip.txt" #eski ip.txt dosyasını sil | |
on_failure = "continue" # hata verirse devam et | |
} | |
provisioner "local-exec" { | |
command="echo ${self.ipv4_address} >> ip.txt" # ip adresini ip.txt yaz. | |
} | |
} | |
output "ip" { | |
value = "${digitalocean_droplet.squid.*.ipv4_address}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment