Commit d2d7f706 authored by Kerim Satirli's avatar Kerim Satirli

refactoring Terraform resources

parent d62e7490
......@@ -4,11 +4,11 @@ If you want to have a look at puppetised code for OpsTheater, you can check that
Please follow the below steps for contributing :
On your development machine (local machine) clone the opstheater control repository using command :
On your development machine clone the `opstheater` repository using command :
```sh
git clone git@gitlab.olindata.com:opstheater/opstheater.git
```
This will create a directory called opstheater on your current location.
This will create a directory called `opstheater` in your current directory.
You can contribute your code in this local directory and push it to a new branch
```sh
checkout -b <author>/[fixes|features]/<name>
......
resource "digitalocean_ssh_key" "opstheater" {
name = "OpsTheater"
public_key = "${file(concat(var.meta_key_material.global, ".pub"))}"
}
resource "digitalocean_droplet" "host" {
image = "centos-7-0-x64"
name = "${var.host}.${var.domain}"
region = "ams2"
image = "${var.do_droplet_images.centos}"
name = "${var.meta_opstheater_host}.${var.meta_opstheater_domain}"
region = "${var.do_regions.global}"
size = "512mb"
private_networking = true
backups = "${var.do_droplet_settings.backups}"
ipv6 = "${var.do_droplet_settings.ipv6}"
private_networking = "${var.do_droplet_settings.private_networking}"
ssh_keys = [
"${var.ssh_fingerprint}"
"${digitalocean_ssh_key.opstheater.fingerprint}"
]
connection {
user = "root"
user = "${var.do_droplet_ssh_users.centos}"
type = "ssh"
key_file = "${var.pvt_key}"
timeout = "2m"
key_file = "${file(var.meta_key_material.global)}"
timeout = "${var.do_droplet_settings.private_networking}"
}
provisioner "remote-exec" {
inline = [
"export PATH=$PATH:/usr/bin",
"sudo yum update -y -q",
"/bin/yum install -y -q epel-release http://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm",
"/bin/yum install -y -q puppet-agent",
"/opt/puppetlabs/bin/puppet config set --section main server ${var.host}.${var.domain}",
"/opt/puppetlabs/bin/puppet agent -t || true"
"yum update --assumeyes --quiet",
"yum install --assumeyes --quiet epel-release https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm",
"yum install --assumeyes --quiet puppet-agent",
"/opt/puppetlabs/bin/puppet config set --section main server ${var.meta_opstheater_host}.${var.meta_opstheater_domain}",
"/opt/puppetlabs/bin/puppet agent --test || true"
]
}
}
variable "do_token" {}
variable "pub_key" {}
variable "pvt_key" {}
variable "ssh_fingerprint" {}
variable "host" {
default = "puppet"
}
variable "domain" {
default = "opstheater.vm"
}
provider "digitalocean" {
token = "${var.do_token}"
}
# DO: generic variables
do_token = "..."
# Section: Digital Ocean
# These variables contain DO-specific data and settings
# see https://terraform.io/docs/providers/do/index.html for more information
variable "do_token" {
description = "Token to work with"
default = ""
}
variable "do_regions" {
description = "Region to work with"
default = {
global = "ams2"
}
}
variable "do_droplet_settings" {
description = "Droplet-specific settings"
default = {
backups = false
ipv6 = false
private_networking = true
timeout = "1m"
}
}
variable "do_droplet_images" {
description = "Droplet Images"
default = {
centos = "centos-7-x64" # CentOS 7.2
}
}
variable "do_droplet_ssh_users" {
description = "Droplet-specific SSH users"
default = {
centos = "root"
}
}
# Section: meta settings
variable "meta_key_material" {
description = "Material for private key (SSH)"
default = {
global = "../../certificates/terraform-20160805"
}
}
variable "meta_opstheater_domain" {
description = "Domain to use for OpsTheater"
default = "opstheater.vm"
}
variable "meta_opstheater_host" {
description = "Host to use for OpsTheater"
default = "puppet"
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment