Skip to content

Commit

Permalink
added vsphere vm
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-hermann-sva committed Feb 1, 2025
1 parent eb90fcf commit 00ae751
Show file tree
Hide file tree
Showing 8 changed files with 353 additions and 24 deletions.
8 changes: 8 additions & 0 deletions .kaeffken/ansiblerun.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@ preQuestions:
- "devmachine"
- "powerdns"

- prompt: "Hosts or Group name? (e.g. $HOSTNAME, localhost or all)"
kind: ask
name: targets
type: string
minLength: 3
maxLength: 20

questions:
- .kaeffken/surveys/ansiblerun-general.yaml
- .kaeffken/surveys/{{ .provisioning }}.yaml

templates:
Expand Down
18 changes: 0 additions & 18 deletions .kaeffken/surveys/ansiblerun.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1 @@
---
- prompt: "Target (hosts/group) name?"
kind: ask
name: targets
type: string
minLength: 3
maxLength: 20

- prompt: "Pipelinerun namespace?"
name: pipelineRunNamespace
options:
- "tekton-pipelines"

- prompt: "IP/FQDN?"
kind: ask
name: ip
type: string
minLength: 3
maxLength: 20
14 changes: 8 additions & 6 deletions .kaeffken/templates/ansiblerun-devmachine.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ spec:
inventory:
- "all+[\"{{ .ip }}\"]"
playbooks:
- "plays/prepare-env.yaml"
- "sthings.base_os.setup"
- "sthings.container.tools"
- "sthings.container.docker"
- "sthings.container.nerdctl"
- "sthings.base_os.binaries"
- "sthings.baseos.prepare_env"
- "sthings.baseos.setup"
#- "sthings.container.tools"
#- "sthings.container.docker"
#- "sthings.container.nerdctl"
#- "sthings.base_os.binaries"
ansibleVarsFile:
- manage_filesystem+-true
- update_packages+-true
Expand Down Expand Up @@ -48,3 +48,5 @@ spec:
- awx.awx:24.6.1
- community.hashi_vault:6.2.0
- ansible.netcommon:7.1.0
- https://github.com/stuttgart-things/ansible/releases/download/sthings-container-25.4.1154/sthings-container-25.4.1154.tar.gz
- https://github.com/stuttgart-things/ansible/releases/download/sthings-baseos-25.4.1100/sthings-baseos-25.4.1100.tar.gz
150 changes: 150 additions & 0 deletions configurations/vsphere-vm/apis/composition.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
---
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: vsphere-vm
labels:
crossplane.io/xrd: xvspherevms.resources.stuttgart-things.com
spec:
compositeTypeRef:
apiVersion: resources.stuttgart-things.com/v1alpha1
kind: XVsphereVM
resources:
- name: vsphere-vm
base:
kind: Workspace
apiVersion: tf.upbound.io/v1beta1
metadata:
annotations:
crossplane.io/external-name: vspherevm
spec:
providerConfigRef:
name: terraform-default
writeConnectionSecretToRef:
name: vsphere-vm-test
namespace: crossplane-system
forProvider:
source: Remote
module: git::https://github.com/stuttgart-things/vsphere-vm.git?ref=v1.7.5-2.7.0
vars:
- key: vm_count
type: integer
value: "1"
- key: vsphere_vm_name
type: string
- key: vm_memory
type: integer
value: "4096"
- key: vm_disk_size
type: integer
value: "64"
- key: vm_num_cpus
type: integer
value: "4"
- key: firmware
type: string
value: bios
- key: vsphere_vm_folder_path
type: string
- key: vsphere_datacenter
type: string
- key: vsphere_datastore
type: string
- key: vsphere_resource_pool
type: string
- key: vsphere_network
type: string
- key: vsphere_vm_template
type: string
- key: bootstrap
type: string
value: '["echo STUTTGART-THINGS"]'
- key: annotation
type: string
value: VSPHERE-VM BUILD w/ CROSSPLANE FOR STUTTGART-THINGS
- key: unverified_ssl
type: string
value: "true"
varFiles:
- source: SecretKey
secretKeyRef:
namespace: default
name: vsphere-tfvars
key: terraform.tfvars
patches:
- type: CombineFromComposite
combine:
variables:
- fromFieldPath: spec.vm.name
strategy: string
string:
fmt: "vspherevm-%s"
toFieldPath: "metadata.annotations[crossplane.io/external-name]"
- type: FromCompositeFieldPath
fromFieldPath: spec.vm.count
toFieldPath: spec.forProvider.vars[0].value
- type: FromCompositeFieldPath
fromFieldPath: spec.vm.name
toFieldPath: spec.forProvider.vars[1].value
- type: FromCompositeFieldPath
fromFieldPath: spec.vm.ram
toFieldPath: spec.forProvider.vars[2].value
- type: FromCompositeFieldPath
fromFieldPath: spec.vm.disk
toFieldPath: spec.forProvider.vars[3].value
- type: FromCompositeFieldPath
fromFieldPath: spec.vm.cpu
toFieldPath: spec.forProvider.vars[4].value
- type: FromCompositeFieldPath
fromFieldPath: spec.vm.firmware
toFieldPath: spec.forProvider.vars[5].value
- type: FromCompositeFieldPath
fromFieldPath: spec.vm.folderPath
toFieldPath: spec.forProvider.vars[6].value
- type: FromCompositeFieldPath
fromFieldPath: spec.vm.datacenter
toFieldPath: spec.forProvider.vars[7].value
- type: FromCompositeFieldPath
fromFieldPath: spec.vm.datastore
toFieldPath: spec.forProvider.vars[8].value
- type: FromCompositeFieldPath
fromFieldPath: spec.vm.resourcePool
toFieldPath: spec.forProvider.vars[9].value
- type: FromCompositeFieldPath
fromFieldPath: spec.vm.network
toFieldPath: spec.forProvider.vars[10].value
- type: FromCompositeFieldPath
fromFieldPath: spec.vm.template
toFieldPath: spec.forProvider.vars[11].value
- type: FromCompositeFieldPath
fromFieldPath: spec.vm.bootstrap
toFieldPath: spec.forProvider.vars[12].value
- type: FromCompositeFieldPath
fromFieldPath: spec.vm.annotation
toFieldPath: spec.forProvider.vars[13].value
- type: FromCompositeFieldPath
fromFieldPath: spec.vm.unverifiedSsl
toFieldPath: spec.forProvider.vars[14].value
- type: FromCompositeFieldPath
fromFieldPath: spec.tfvars.secretName
toFieldPath: spec.forProvider.varFiles[0].secretKeyRef.name
- type: FromCompositeFieldPath
fromFieldPath: spec.tfvars.secretNamespace
toFieldPath: spec.forProvider.varFiles[0].secretKeyRef.namespace
- type: FromCompositeFieldPath
fromFieldPath: spec.tfvars.secretKey
toFieldPath: spec.forProvider.varFiles[0].secretKeyRef.key
- type: FromCompositeFieldPath
fromFieldPath: spec.connectionSecret.name
toFieldPath: spec.writeConnectionSecretToRef.name
- type: FromCompositeFieldPath
fromFieldPath: spec.connectionSecret.namespace
toFieldPath: spec.writeConnectionSecretToRef.namespace
- type: FromCompositeFieldPath
fromFieldPath: spec.providerRef.name
toFieldPath: spec.providerConfigRef.name
- type: ToCompositeFieldPath
fromFieldPath: status.atProvider.outputs.ip
toFieldPath: status.share.ip
policy:
fromFieldPath: Optional
119 changes: 119 additions & 0 deletions configurations/vsphere-vm/apis/defintion.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
---
apiVersion: apiextensions.crossplane.io/v1
kind: CompositeResourceDefinition
metadata:
name: xvspherevms.resources.stuttgart-things.com
spec:
group: resources.stuttgart-things.com
names:
kind: XVsphereVM
plural: xvspherevms
claimNames:
kind: VsphereVM
plural: vspherevms
versions:
- name: v1alpha1
served: true
referenceable: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
vm:
type: object
properties:
count:
type: string
default: "1"
name:
type: string
ram:
type: string
default: "4096"
disk:
type: string
default: "64"
cpu:
type: string
default: "4"
firmware:
type: string
default: "bios"
folderPath:
type: string
datacenter:
type: string
datastore:
type: string
resourcePool:
type: string
network:
type: string
template:
type: string
bootstrap:
type: string
default: '["echo STUTTGART-THINGS"]'
annotation:
type: string
default: VSPHERE-VM BUILD w/ CROSSPLANE FOR STUTTGART-THINGS
unverifiedSsl:
type: string
default: "true"
required:
- name
- ram
- disk
- cpu
- folderPath
- datacenter
- datastore
- resourcePool
- network
- template
tfvars:
type: object
properties:
secretName:
type: string
secretNamespace:
type: string
default: default
secretKey:
type: string
default: terraform.tfvars
required:
- secretName
connectionSecret:
type: object
properties:
name:
type: string
namespace:
type: string
default: default
required:
- name
providerRef:
type: object
properties:
name:
type: string
required:
- name
required:
- vm
- tfvars
- connectionSecret
- providerRef
status:
description: A Status represents the observed state
properties:
share:
description: Freeform field containing status information
type: object
x-kubernetes-preserve-unknown-fields: true
type: object
21 changes: 21 additions & 0 deletions configurations/vsphere-vm/crossplane.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
apiVersion: meta.pkg.crossplane.io/v1
kind: Configuration
metadata:
name: vsphere-vm
annotations:
meta.crossplane.io/maintainer: [email protected]
meta.crossplane.io/source: github.com/stuttgart-things/crossplane
meta.crossplane.io/license: Apache-2.0
meta.crossplane.io/description: |
creates vsphere-vm with crossplane based on terraform (provider)
meta.crossplane.io/readme: |
creates vsphere-vm with crossplane based on terraform (provider)
spec:
crossplane:
version: ">=v1.14.1-0"
dependsOn:
- provider: xpkg.upbound.io/crossplane-contrib/provider-helm
version: ">=v0.19.0"
- provider: xpkg.upbound.io/crossplane-contrib/provider-kubernetes
version: ">=v0.14.1"
33 changes: 33 additions & 0 deletions configurations/vsphere-vm/examples/claim.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: resources.stuttgart-things.com/v1alpha1
kind: VsphereVM
metadata:
name: xplane-new
namespace: crossplane-system
spec:
providerRef:
name: vsphere-vm
vm:
count: "1"
name: xplane-new
cpu: "8"
ram: "4096"
disk: "64"
firmware: bios
folderPath: stuttgart-things/testing
datacenter: /LabUL
datastore: /LabUL/datastore/UL-ESX-SAS-01
resourcePool: /LabUL/host/Cluster-V6.5/Resources
network: /LabUL/network/LAB-10.31.103
template: sthings-u24
bootstrap: '["echo STUTTGART-THINGS"]'
annotation: VSPHERE-VM BUILD w/ CROSSPLANE FOR STUTTGART-THINGS
unverifiedSsl: "true"
tfvars:
secretName: vsphere-tfvars # pragma: allowlist secret
secretNamespace: crossplane-system # pragma: allowlist secret
secretKey: terraform.tfvars # pragma: allowlist secret
connectionSecret:
name: xplane-new
namespace: crossplane-system
compositionRef:
name: vsphere-vm
Loading

0 comments on commit 00ae751

Please sign in to comment.