Skip to content
Snippets Groups Projects
Commit ade519a9 authored by Orosz Bence's avatar Orosz Bence
Browse files

cloud init not working

parent 6ec5c63b
No related branches found
No related tags found
No related merge requests found
### Terraform template
# Local .terraform directories
**/.terraform/*
# .tfstate files
*.tfstate
*.tfstate.*
# Crash log files
crash.log
# Exclude all .tfvars files, which are likely to contain sentitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# to change depending on the environment.
#
*.tfvars
# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json
# Include override files you do wish to add to version control using negated pattern
#
# !example_override.tf
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*
# Ignore CLI configuration files
.terraformrc
terraform.rc
# IDEs
.idea
.vscode
.code
.vs
login.tfvars
login.sh
#!/bin/bash
source login.sh
terraform destroy --var-file login.tfvars
data "vsphere_host" "NOC-A" {
name = "noc-a-test.internal"
datacenter_id = data.vsphere_datacenter.DC.id
}
data "vsphere_host" "NOC-B" {
name = "noc-b-test.internal"
datacenter_id = data.vsphere_datacenter.DC.id
}
\ No newline at end of file
terraform import --var-file login.tfvars 'vsphere_distributed_port_group.dvpg["DnPG-Internal-152"]' /NOC/network/DnPG-Internal-152
\ No newline at end of file
#!/bin/bash
source login.sh
PROJ_ID="3585"
STATE_NAME="petalinux"
terraform init \
-backend-config="address=https://git.sch.bme.hu/api/v4/projects/${PROJ_ID}/terraform/state/${STATE_NAME}" \
-backend-config="lock_address=https://git.sch.bme.hu/api/v4/projects/${PROJ_ID}/terraform/state/${STATE_NAME}/lock" \
-backend-config="unlock_address=https://git.sch.bme.hu/api/v4/projects/${PROJ_ID}/terraform/state/${STATE_NAME}/lock" \
-backend-config="username=${GITLAB_USER}" \
-backend-config="password=${GITLAB_REPO_PAT}" \
-backend-config="lock_method=POST" \
-backend-config="unlock_method=DELETE" \
-backend-config="retry_wait_min=5" \
-reconfigure
#!/bin/bash
export GITLAB_USER=kovacs_bela
export GITLAB_REPO_PAT=sokbetu_sokszam
\ No newline at end of file
vsphere_user="bela_kisnyul"
vsphere_password="almafa123"
data "vsphere_network" "DnPG-Internal-151" {
name = "DnPG-Internal-151"
datacenter_id = data.vsphere_datacenter.DC.id
}
data "vsphere_network" "DnPG-NAT-51" {
name = "DnPG-NAT-51"
datacenter_id = data.vsphere_datacenter.DC.id
}
data "vsphere_network" "DnPG-Internal-152" {
name = "DnPG-Internal-152"
datacenter_id = data.vsphere_datacenter.DC.id
}
data "vsphere_network" "DnPG-WiFi-69" {
name = "DnPG-WiFi-69"
datacenter_id = data.vsphere_datacenter.DC.id
}
data "vsphere_network" "DnPG-mgmt-lan" {
name = "DnPG-mgmt-lan"
datacenter_id = data.vsphere_datacenter.DC.id
}
data "vsphere_network" "DnPG-Vlan-172" {
name = "DnPG-Vlan-172"
datacenter_id = data.vsphere_datacenter.DC.id
}
data "vsphere_network" "DnPG-Internal-29" {
name = "DnPG-Internal-29"
datacenter_id = data.vsphere_datacenter.DC.id
}
data "vsphere_network" "DnPG-Internal-209" {
name = "DnPG-Internal-209"
datacenter_id = data.vsphere_datacenter.DC.id
}
data "vsphere_network" "DnPG-NATGWTEST-64" {
name = "DnPG-NATGWTEST-64"
datacenter_id = data.vsphere_datacenter.DC.id
}
data "vsphere_network" "DnPG-Internal-211" {
name = "DnPG-Internal-211"
datacenter_id = data.vsphere_datacenter.DC.id
}
data "vsphere_distributed_virtual_switch" "switch" {
name = "DNocSwitch"
datacenter_id = data.vsphere_datacenter.DC.id
}
data "vsphere_distributed_virtual_switch" "Switch-mgmt" {
name = "DNocSwitch-mgmt"
datacenter_id = data.vsphere_datacenter.DC.id
}
run.sh 0 → 100755
#!/bin/bash
source login.sh
terraform apply --var-file login.tfvars
\ No newline at end of file
vms.tf 0 → 100644
#https://cloud-images.ubuntu.com/releases/focal/release/ubuntu-20.04-server-cloudimg-amd64.ova
data "vsphere_virtual_machine" "ubuntu_template" {
name = "ubuntu-20.04-server-cloudimg-amd64v2"
datacenter_id = data.vsphere_datacenter.DC.id
}
data "vsphere_virtual_machine" "ubuntu_template-richard" {
name = "ubu1804-template"
datacenter_id = data.vsphere_datacenter.DC.id
}
variable "pubkeys_woranhun" {
type = string
default = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCa/EVELPE/fowuT4xPa9EpcDEOvdilmU5P8ZFmbsApF9ch6COXUv60TAOKMkTUTHswgAgaqU2zlkrFcxb/pS5N9uv8MaRNRZmdg5lZyYnbk90oY08sEyWzNUdPFo1UcpIUm/rojkW35ikWXabc6VKbn5uvM4c3cxT+ryxDXojLV/rkIW8MmrW1GndiANz047xyAPxBW7LqHIa7M8Q/dHB7rV1zEDVyiu6oe9+zV4wreU+5NFODw2+znNs5BicvxL0YAW2kp1IVg6OUVSHyPH+7eW+VYD6bDVmA+xtyIMsWZBCHki4bup1eouNO8ej5h9zj6GmANZZVV8MiHSVHpJGdT7QOLEKZo+SR4ybgfFrqmcyY54HM+PdHsrycHmVuY30lraUk1/P4yHkmuYUP1/0LdfemLPw81T/W8ndRpw2aIVjQYa97mpIj8FRaA9nbEw7hcsXlGfrVXE46lALt3cJXzS9IoW9FCGMV4/aOUWCb65k0pKlBVMrJDsogDVgO5zAvZp11WYwzjZzZkpGD3Yg4YVGm1DhBaWBuMvcb/peNFgVMItTqJe+DcgCjyyq/iDPosfuyoCkYL3NwNUcBzMXcHgLFCVTeHZlieRKajw5GO2S5toAC+gpzmr31CP8jBGlwAuHotb0CbeMR0Dynk58ewdpiwK0stppKShToyQZJbQ== woranhun@woranhunX220ubu"
}
variable "pubkeys_richard" {
type = string
default = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIONs0OwDN2sMIPotBEwm6l/g4qB0z7k31uXS3tmcZLo4 szabo_richard (git.sch.bme.hu)"
}
resource "vsphere_virtual_machine" "richardvm" {
resource_pool_id = data.vsphere_resource_pool.NOC-A.id
datastore_id = data.vsphere_datastore.NOC-A-Storage.id
name = "richardvm"
guest_id = "ubuntu64Guest"
memory = 32768
firmware = "efi"
num_cores_per_socket = 15
host_system_id = data.vsphere_host.NOC-A.id
clone {
template_uuid = data.vsphere_virtual_machine.ubuntu_template-richard.id
}
network_interface {
network_id = data.vsphere_network.DnPG-Internal-211.id
use_static_mac = true
mac_address = "00:50:56:10:3d:21"
}
disk {
thin_provisioned = false
label = "disk0"
size = 300
}
cdrom {
client_device = true
}
}
\ No newline at end of file
terraform {
required_providers {
vsphere = {
source = "hashicorp/vsphere"
version = "2.0.0"
}
}
backend "http" {}
}
# Vsphere provider config
variable "vsphere_user" {
description = "Administrator user"
type = string
sensitive = false
}
variable "vsphere_password" {
description = "Administrator password"
type = string
sensitive = true
}
provider "vsphere" {
user = var.vsphere_user
password = var.vsphere_password
vsphere_server = "horizont.sch.bme.hu"
allow_unverified_ssl = true
}
data "vsphere_datacenter" "DC" {
name = "NOC"
}
data "vsphere_datastore" "NOC-A-Storage" {
name = "NOC-A-Test-Storage1"
datacenter_id = data.vsphere_datacenter.DC.id
}
data "vsphere_datastore" "NOC-B-Storage" {
name = "NOC-B-Test-Storage1"
datacenter_id = data.vsphere_datacenter.DC.id
}
data "vsphere_resource_pool" "NOC-A" {
name = "noc-a-test.internal/Resources"
datacenter_id = data.vsphere_datacenter.DC.id
}
data "vsphere_resource_pool" "NOC-B" {
name = "noc-b-test.internal/Resources"
datacenter_id = data.vsphere_datacenter.DC.id
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment