Quellcode durchsuchen

project started

master
Commit
8a50e4d274
9 geänderte Dateien mit 107 neuen und 0 gelöschten Zeilen
  1. +1
    -0
      .gitignore
  2. +18
    -0
      deploy.yaml
  3. +3
    -0
      group_vars/ovh_vms/terraform.yaml
  4. +1
    -0
      host_vars/controller.testing.thengo.net/terraform-info.json
  5. +9
    -0
      inventory
  6. +31
    -0
      terraform/controller.testing.thengo.net.tf
  7. +7
    -0
      terraform/etcd.tf
  8. +33
    -0
      terraform/ovh.tf
  9. +4
    -0
      terraform/versions.tf

+ 1
- 0
.gitignore Datei anzeigen

@@ -0,0 +1 @@
terraform/.terraform

+ 18
- 0
deploy.yaml Datei anzeigen

@@ -0,0 +1,18 @@
---

- hosts: ovh_vms
remote_user: root
gather_facts: false
roles:
- role: terraform-vm

- hosts: localhost
tasks:
- debug:
msg: |-
to apply terraform updates run:
cd "{{playbook_dir}}/terraform"
terraform apply

# - terraform:
# project_path: "{{playbook_dir}}/terraform"

+ 3
- 0
group_vars/ovh_vms/terraform.yaml Datei anzeigen

@@ -0,0 +1,3 @@
ansible_host: "{{terraform_vm.access_ip_v4}}"
openstack_region: GRA7
openstack_flavor: s1-2

+ 1
- 0
host_vars/controller.testing.thengo.net/terraform-info.json Datei anzeigen

@@ -0,0 +1 @@
{"terraform_vm":{"access_ip_v4":"54.37.77.37","access_ip_v6":"[2001:41d0:701:1000::ad9]","admin_pass":null,"all_metadata":{},"all_tags":[],"availability_zone":"nova","block_device":[],"config_drive":null,"flavor_id":"d31419c1-8e1e-48c2-8a4c-28190650c817","flavor_name":"s1-2","floating_ip":null,"force_delete":false,"id":"cf23e031-b299-477b-af6a-989826c4c9aa","image_id":"6a27a33f-9cb9-4c65-b99c-bb904dfb43aa","image_name":"Debian 10","key_pair":"terraform-default","metadata":null,"name":"controller.testing.thengo.net","network":[{"access_network":false,"fixed_ip_v4":"54.37.77.37","fixed_ip_v6":"[2001:41d0:701:1000::ad9]","floating_ip":"","mac":"fa:16:3e:84:3d:f1","name":"Ext-Net","port":"","uuid":"ed0ab0c6-93ee-44f8-870b-d103065b1b34"}],"personality":[],"power_state":"active","region":"DE1","scheduler_hints":[],"security_groups":["default"],"stop_before_destroy":false,"tags":null,"timeouts":null,"user_data":"3670b43deeb2d5936a31f7eb5c20593fd64c7a0e","vendor_options":[],"volume":[]}}

+ 9
- 0
inventory Datei anzeigen

@@ -0,0 +1,9 @@
[ovh_vms]
controller.testing.thengo.net openstack_region=DE1
#ns.testing.thengo.net openstack_region=DE1

[controllers]
controller.testing.thengo.net

[nameservers]
ns.testing.thengo.net

+ 31
- 0
terraform/controller.testing.thengo.net.tf Datei anzeigen

@@ -0,0 +1,31 @@
resource "openstack_compute_instance_v2" "controller--testing--thengo--net" {
name = "controller.testing.thengo.net"

region = "DE1"

flavor_name = "s1-2"

key_pair = "terraform-default"
user_data = "#cloud-config\ndisable_root: false"

image_name = "Debian 10"

network {
name = "Ext-Net"
}

lifecycle {
ignore_changes = [
key_pair,
user_data
]
}
}

resource "local_file" "controller--testing--thengo--net-info" {
content = jsonencode({
"terraform_vm": openstack_compute_instance_v2.controller--testing--thengo--net
})
filename = "../host_vars/controller.testing.thengo.net/terraform-info.json"
}


+ 7
- 0
terraform/etcd.tf Datei anzeigen

@@ -0,0 +1,7 @@
terraform {
backend "etcdv3" {
endpoints = ["localhost:2379"]
lock = true
prefix = "testing/terraform-state/"
}
}

+ 33
- 0
terraform/ovh.tf Datei anzeigen

@@ -0,0 +1,33 @@
provider "ovh" {
endpoint = "ovh-eu"
}

resource "ovh_cloud_user" "user" {
project_id = "2044653399df4877a72b77333c25557e"
description = "terraform user"
}

provider "openstack" {
auth_url = "https://auth.cloud.ovh.net/v3"

user_name = ovh_cloud_user.user.username
password = ovh_cloud_user.user.password

tenant_id = ovh_cloud_user.user.project_id
}

variable "ovh_regions" {
type = list(string)
default = [
"DE1",
"GRA7",
"SBG5",
]
}

resource "openstack_compute_keypair_v2" "default" {
name = "terraform-default"
region = each.value
public_key = file("~/.ssh/id_rsa.pub")
for_each = toset(var.ovh_regions)
}

+ 4
- 0
terraform/versions.tf Datei anzeigen

@@ -0,0 +1,4 @@

terraform {
required_version = ">= 0.12"
}

Laden…
Abbrechen
Speichern