before move to three hosts

This commit is contained in:
Neil Hanlon 2021-10-25 19:26:18 -04:00
parent 984726bf3d
commit ec8a24cefa
Signed by: neil
GPG Key ID: 705BC21EC3C70F34
12 changed files with 330 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
id_ed25519
.terraform/
.envrc

View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
doctl ()
{
/home/neil/bin/doctl --context advancedlsa $@
}
doctl

21
terraform/.terraform.lock.hcl generated Executable file
View File

@ -0,0 +1,21 @@
# This file is maintained automatically by "terraform init".
# Manual edits may be lost in future updates.
provider "registry.terraform.io/digitalocean/digitalocean" {
version = "1.22.2"
constraints = "1.22.2"
hashes = [
"h1:VNz0Gte3Rmd/yhUh96FuStEXJWRYx8x2LMolm54U7Rw=",
"zh:406d8f4704f7ff17a5b60c394674e4e85910c86a0090c9f4bb4b33196e132d2b",
"zh:476d9600a13e1d425540c3750a6966d5867ea5d6d5dbfa2d8c8dc6a6ea07b1ac",
"zh:56f56d312ec707e9f33db833876a5086af4f07043eb0c471e002b42339a31bf5",
"zh:669cf9c9dd7e9c812e8896fae34a22cdc938854f6d91778ad74a12083744f4ae",
"zh:714ed181254a95f774de372fac3afdf6ae9658f18b5fe13324df31cb12892f76",
"zh:7762077125a6df36b28cdd4966356d2a7fddb187d010d06aca05a8ecf7ce1612",
"zh:877cb27bf81c56c2e863d9574e34716e1eb49bcb0de0a48578c828bef1863d87",
"zh:92049f21072b76fe5bb9a49842d820eda3ca86098e01bd936ef031b44f0d0207",
"zh:b4fec336c0fa22fd2a053cf3c6a9a4b8622557c18aba622127c86d0f14a1bf52",
"zh:d4df235797896ba7efb16ace5a8f5e27e5751b7bddc102a4f2617d80f71c0cb2",
"zh:ea5ca95527064e3740183f997aecd6e39313bd63d155447d338e2aa7818209b6",
]
}

View File

@ -0,0 +1,4 @@
---
lxc_container_base_name: "rocky-8-amd64"
lxc_hosts_container_build_command: "dnf --assumeyes --installroot=/var/lib/machines/{{ lxc_container_base_name }} install --setopt=install_weak_deps=False --nodocs rootfiles coreutils dnf rocky-release rocky-repos --releasever=8"

1
terraform/id_ed25519.pub Normal file
View File

@ -0,0 +1 @@
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINjvRik77vZm9Uy8mxnQakfsWLrkpwYLoVT/TdxScoWj advancedlsa_terraform

3
terraform/project.tf Normal file
View File

@ -0,0 +1,3 @@
data "digitalocean_project" "advancedlsa" {
name = "advanced linux sysadmin"
}

19
terraform/provider.tf Normal file
View File

@ -0,0 +1,19 @@
terraform {
required_providers {
digitalocean = {
source = "digitalocean/digitalocean"
version = "1.22.2"
}
}
}
variable "do_token" {}
variable "pvt_key" {}
provider "digitalocean" {
token = var.do_token
}
data "digitalocean_ssh_key" "terraform" {
name = "advancedlsa-ed25519"
}

59
terraform/resourse.tf Normal file
View File

@ -0,0 +1,59 @@
resource "digitalocean_droplet" "openstackaio-1" {
image = "rockylinux-8-x64"
name = "openstackaio-1"
region = "nyc3"
size = "g-8vcpu-32gb"
private_networking = true
ssh_keys = [
data.digitalocean_ssh_key.terraform.id
]
connection {
host = self.ipv4_address
user = "root"
type = "ssh"
private_key = file(var.pvt_key)
timeout = "2m"
}
provisioner "remote-exec" {
inline = [
"export PATH=$PATH:/usr/bin",
"dnf -y upgrade",
"dnf -y install git-core",
"systemctl stop firewalld",
"systemctl mask firewalld",
"sed -i 's/enforcing/disabled/' /etc/sysconfig/selinux",
"dnf -y install git wget python36",
"pip3 install virtualenv",
"git clone https://github.com/NeilHanlon/openstack-ansible.git /opt/openstack-ansible",
"cd /opt/openstack-ansible && git checkout feature/rocky8",
"/opt/openstack-ansible/scripts/bootstrap-ansible.sh",
"/opt/openstack-ansible/scripts/bootstrap-aio.sh",
]
}
provisioner "file" {
source = "files/user_lxc.yml"
destination = "/etc/openstack_deploy/user_lxc.yml"
}
}
resource "digitalocean_project_resources" "openstackaio-1" {
project = data.digitalocean_project.advancedlsa.id
resources = [
digitalocean_droplet.openstackaio-1.urn,
digitalocean_volume.openstackdata.urn
]
}
resource "digitalocean_volume" "openstackdata" {
region = "nyc3"
name = "kvmdata"
size = 100
initial_filesystem_type = "xfs"
description = "volume for openstack shit"
}
resource "digitalocean_volume_attachment" "openstackaio_volume1" {
droplet_id = digitalocean_droplet.openstackaio-1.id
volume_id = digitalocean_volume.openstackdata.id
}

View File

@ -0,0 +1,8 @@
{
"version": 4,
"terraform_version": "1.0.8",
"serial": 72,
"lineage": "9cbca1f8-8910-c707-3b0a-5c03c8621271",
"outputs": {},
"resources": []
}

View File

@ -0,0 +1,178 @@
{
"version": 4,
"terraform_version": "1.0.8",
"serial": 65,
"lineage": "9cbca1f8-8910-c707-3b0a-5c03c8621271",
"outputs": {},
"resources": [
{
"mode": "data",
"type": "digitalocean_project",
"name": "advancedlsa",
"provider": "provider[\"registry.terraform.io/digitalocean/digitalocean\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"created_at": "2021-09-19T03:03:37Z",
"description": "",
"environment": "Development",
"id": "a6b1a713-5a17-40d7-bed1-af2a22d0cd98",
"is_default": false,
"name": "advanced linux sysadmin",
"owner_id": 257793,
"owner_uuid": "797bee93c6f37b206a6194466f1a107df45998a8",
"purpose": "book",
"resources": [],
"updated_at": "2021-09-19T03:26:37Z"
},
"sensitive_attributes": []
}
]
},
{
"mode": "data",
"type": "digitalocean_ssh_key",
"name": "terraform",
"provider": "provider[\"registry.terraform.io/digitalocean/digitalocean\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"fingerprint": "c5:82:99:8d:c3:e8:f0:dd:ef:81:3c:6e:72:a8:e4:43",
"id": "31322665",
"name": "advancedlsa-ed25519",
"public_key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINjvRik77vZm9Uy8mxnQakfsWLrkpwYLoVT/TdxScoWj advancedlsa_terraform\n"
},
"sensitive_attributes": []
}
]
},
{
"mode": "managed",
"type": "digitalocean_droplet",
"name": "openstackaio-1",
"provider": "provider[\"registry.terraform.io/digitalocean/digitalocean\"]",
"instances": [
{
"schema_version": 1,
"attributes": {
"backups": false,
"created_at": "2021-10-25T01:09:36Z",
"disk": 100,
"id": "270730066",
"image": "rockylinux-8-x64",
"ipv4_address": "165.227.69.34",
"ipv4_address_private": "10.132.0.4",
"ipv6": false,
"ipv6_address": "",
"ipv6_address_private": null,
"locked": false,
"memory": 32768,
"monitoring": false,
"name": "openstackaio-1",
"price_hourly": 0.35714,
"price_monthly": 240,
"private_networking": true,
"region": "nyc3",
"resize_disk": true,
"size": "g-8vcpu-32gb",
"ssh_keys": [
"31322665"
],
"status": "active",
"tags": null,
"urn": "do:droplet:270730066",
"user_data": null,
"vcpus": 8,
"volume_ids": [],
"vpc_uuid": "9be75620-dc84-11e8-80bc-3cfdfea9fba1"
},
"sensitive_attributes": [],
"private": "eyJzY2hlbWFfdmVyc2lvbiI6IjEifQ==",
"dependencies": [
"data.digitalocean_ssh_key.terraform"
]
}
]
},
{
"mode": "managed",
"type": "digitalocean_project_resources",
"name": "openstackaio-1",
"provider": "provider[\"registry.terraform.io/digitalocean/digitalocean\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"id": "a6b1a713-5a17-40d7-bed1-af2a22d0cd98",
"project": "a6b1a713-5a17-40d7-bed1-af2a22d0cd98",
"resources": [
"do:droplet:270730066",
"do:volume:38c6ab8b-3530-11ec-864d-0a58ac147386"
]
},
"sensitive_attributes": [],
"private": "bnVsbA==",
"dependencies": [
"data.digitalocean_project.advancedlsa",
"data.digitalocean_ssh_key.terraform",
"digitalocean_droplet.openstackaio-1",
"digitalocean_volume.openstackdata"
]
}
]
},
{
"mode": "managed",
"type": "digitalocean_volume",
"name": "openstackdata",
"provider": "provider[\"registry.terraform.io/digitalocean/digitalocean\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"description": "volume for openstack shit",
"droplet_ids": [],
"filesystem_label": null,
"filesystem_type": "xfs",
"id": "38c6ab8b-3530-11ec-864d-0a58ac147386",
"initial_filesystem_label": null,
"initial_filesystem_type": "xfs",
"name": "kvmdata",
"region": "nyc3",
"size": 100,
"snapshot_id": null,
"tags": null,
"urn": "do:volume:38c6ab8b-3530-11ec-864d-0a58ac147386"
},
"sensitive_attributes": [],
"private": "bnVsbA=="
}
]
},
{
"mode": "managed",
"type": "digitalocean_volume_attachment",
"name": "openstackaio_volume1",
"provider": "provider[\"registry.terraform.io/digitalocean/digitalocean\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"droplet_id": 270730066,
"id": "270730066-38c6ab8b-3530-11ec-864d-0a58ac147386-20211025011232355200000001",
"volume_id": "38c6ab8b-3530-11ec-864d-0a58ac147386"
},
"sensitive_attributes": [],
"private": "bnVsbA==",
"dependencies": [
"data.digitalocean_ssh_key.terraform",
"digitalocean_droplet.openstackaio-1",
"digitalocean_volume.openstackdata"
]
}
]
}
]
}

28
terraform/test.key Normal file
View File

@ -0,0 +1,28 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEAsr2EgUSPeC7O9FLL5snjdP21/0gGaKiFrBlQs4kXkxPY6QYR
FuwArDEGsoPizKNXmoBSEah3NBT9n5jzyQagH3YM7Ugu6JHPwDHuuSr/mGDYyPmN
INGXa+HRHmP1waMCfq3F+P+qx8VBBZCKzuH/dDMy4+Z4dhB3Hi1mJ85hZU06Txmi
DJqEVfo+eOwY0pOt4U2xVCk0YsiZ5c28oDRTvirvtntw9fpVfCQwKlYjTb4WcD+V
bv+/sIjs2A17Z7KvG9ZGAjL/GQOPcvhxras3EVwtqN+w138YH+1Zc+jevf+2gIA8
RcACpCOM7OGD/6fxgEHjzOBlDLoIGz/1WFLGiwIDAQABAoIBAQCQXBaf3QLO+2c0
14ZNgPNPcvZCFybt8mX76HpQdsHujRIcqkS1MakdaX9SQMi1pJtFcqxWDK0yCF4L
P5pt2wcKQesQ3cLdHZ8gSHPZY8wJgvaz4zHDtuPIQxsFo5BCc2i5bZo+kCebr0nj
t6kUjF0ouY05mdPi70t1uQ8PyVTKXiqtIur/sHaq4wEQTms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