• This repository has been archived on 24/Aug/2021
  • Stars
    star
    192
  • Rank 202,019 (Top 4 %)
  • Language
    Python
  • License
    Other
  • Created about 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A cloud-init datasource for VMware vSphere's GuestInfo interface

Cloud-Init Datasource for VMware GuestInfo

This project provides a cloud-init datasource for pulling meta, user, and vendor data from VMware vSphere's GuestInfo interface.


โ—โ— This repository is deprecated โ—โ—

This datasource has been merged into cloud-init as DataSourceVMware (canonical/cloud-init#953):

Component Source Tests
Datasource DataSourceVMware.py test_vmware.py
Identification ds-identify test_ds_identify.py
Documentation vmware.rst

Despite the name change, the new datasource is backwards compatible with all configurations for the datasource in this repository. Still, anyone with build scripts or tooling that packages DataSourceVMwareGuestInfo into images should stop once cloud-init 21.3 is released with DataSourceVMware. In order to participate in the growth of this datasource moving forward, please:

Once again, many thanks to the wonderful community that has grown around this datasource, and I look forward to seeing everyone in the new cloud-init forums!


Installation

There are multiple methods of installing the data source.

Installing on RHEL/CentOS 7

There is an RPM available for installing on RedHat/CentOS:

yum install https://github.com/vmware/cloud-init-vmware-guestinfo/releases/download/v1.1.0/cloud-init-vmware-guestinfo-1.1.0-1.el7.noarch.rpm

Installing on other Linux distributions

The VMware GuestInfo datasource can be installed on any Linux distribution where cloud-init is already present. To do so, simply execute the following:

curl -sSL https://raw.githubusercontent.com/vmware/cloud-init-vmware-guestinfo/master/install.sh | sh -

Configuration

The data source is configured by setting guestinfo properties on a VM's extraconfig data or a customizable vApp's properties data.

Property Description
guestinfo.metadata A YAML or JSON document containing the cloud-init metadata.
guestinfo.metadata.encoding The encoding type for guestinfo.metadata.
guestinfo.userdata A YAML document containing the cloud-init user data.
guestinfo.userdata.encoding The encoding type for guestinfo.userdata.
guestinfo.vendordata A YAML document containing the cloud-init vendor data.
guestinfo.vendordata.encoding The encoding type for guestinfo.vendordata.

All guestinfo.*.encoding property values may be set to base64 or gzip+base64.

Walkthrough

The following series of steps is a demonstration on how to configure a VM with cloud-init and the VMX GuestInfo datasource.

Create a metadata file

First, create the metadata file for the VM. Save the following YAML to a file named metadata.yaml:

instance-id: cloud-vm
local-hostname: cloud-vm
network:
  version: 2
  ethernets:
    nics:
      match:
        name: ens*
      dhcp4: yes

Create a userdata file

Finally, create the userdata file userdata.yaml:

#cloud-config

users:
  - default
  - name: akutz
    primary_group: akutz
    sudo: ALL=(ALL) NOPASSWD:ALL
    groups: sudo, wheel
    ssh_import_id: None
    lock_passwd: true
    ssh_authorized_keys:
    - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDE0c5FczvcGSh/tG4iw+Fhfi/O5/EvUM/96js65tly4++YTXK1d9jcznPS5ruDlbIZ30oveCBd3kT8LLVFwzh6hepYTf0YmCTpF4eDunyqmpCXDvVscQYRXyasEm5olGmVe05RrCJSeSShAeptv4ueIn40kZKOghinGWLDSZG4+FFfgrmcMCpx5YSCtX2gvnEYZJr0czt4rxOZuuP7PkJKgC/mt2PcPjooeX00vAj81jjU2f3XKrjjz2u2+KIt9eba+vOQ6HiC8c2IzRkUAJ5i1atLy8RIbejo23+0P4N2jjk17QySFOVHwPBDTYb0/0M/4ideeU74EN/CgVsvO6JrLsPBR4dojkV5qNbMNxIVv5cUwIy2ThlLgqpNCeFIDLCWNZEFKlEuNeSQ2mPtIO7ETxEL2Cz5y/7AIuildzYMc6wi2bofRC8HmQ7rMXRWdwLKWsR0L7SKjHblIwarxOGqLnUI+k2E71YoP7SZSlxaKi17pqkr0OMCF+kKqvcvHAQuwGqyumTEWOlH6TCx1dSPrW+pVCZSHSJtSTfDW2uzL6y8k10MT06+pVunSrWo5LHAXcS91htHV1M1UrH/tZKSpjYtjMb5+RonfhaFRNzvj7cCE1f3Kp8UVqAdcGBTtReoE8eRUT63qIxjw03a7VwAyB2w+9cu1R9/vAo8SBeRqw== [email protected]

Assigning the userdate data to the VM's GuestInfo

Please note that this step requires that the VM be powered off. All of the commands below use the VMware CLI tool, govc.

Go ahead and assign the path to the VM to the environment variable VM:

export VM="/inventory/path/to/the/vm"

Next, power off the VM:

govc vm.power -off "${VM}"

Export the environment variables that contain the cloud-init metadata and userdata:

export METADATA=$(gzip -c9 <metadata.yaml | { base64 -w0 2>/dev/null || base64; }) \
       USERDATA=$(gzip -c9 <userdata.yaml | { base64 -w0 2>/dev/null || base64; })

Assign the metadata and userdata to the VM's extra configuration dictionary, guestinfo:

govc vm.change -vm "${VM}" \
  -e guestinfo.metadata="${METADATA}" \
  -e guestinfo.metadata.encoding="gzip+base64" \
  -e guestinfo.userdata="${USERDATA}" \
  -e guestinfo.userdata.encoding="gzip+base64"

Please note the above commands include specifying the encoding for the properties. This is important as it informs the datasource how to decode the data for cloud-init. Valid values for metadata.encoding and userdata.encoding include:

  • base64
  • gzip+base64

Using the cloud-init VMX GuestInfo datasource

Power the VM back on.

govc vm.power -vm "${VM}" -on

If all went according to plan, the CentOS box is:

  • Locked down, allowing SSH access only for the user in the userdata
  • Configured for a dynamic IP address via DHCP
  • Has a hostname of cloud-vm

Examples

This section reviews common configurations:

Setting the hostname

The hostname is set by way of the metadata key local-hostname.

Setting the instance ID

The instance ID may be set by way of the metadata key instance-id. However, if this value is absent then then the instance ID is read from the file /sys/class/dmi/id/product_uuid.

Providing public SSH keys

The public SSH keys may be set by way of the metadata key public-keys-data. Each newline-terminated string will be interpreted as a separate SSH public key, which will be placed in distro's default user's ~/.ssh/authorized_keys. If the value is empty or absent, then nothing will be written to ~/.ssh/authorized_keys.

Configuring the network

The network is configured by setting the metadata key network with a value consistent with Network Config Versions 1 or 2, depending on the Linux distro's version of cloud-init.

The metadata key network.encoding may be used to indicate the format of the metadata key "network". Valid encodings are base64 and gzip+base64.

Cleaning up the guestinfo keys

Sometimes the cloud-init userdata might contain sensitive information, and it may be desirable to have the guestinfo.userdata key (or other guestinfo keys) cleared as soon as its data is read by the datasource. This is possible by adding the following to the metadata:

cleanup-guestinfo:
- userdata
- vendordata

When the above snippet is added to the metadata, the datasource will iterate over the elements in the cleanup-guestinfo array and clear each of the keys. For example, the above snippet will cause the following commands to be executed:

vmware-rpctool "info-set guestinfo.userdata ---"
vmware-rpctool "info-set guestinfo.userdata.encoding  "
vmware-rpctool "info-set guestinfo.vendordata ---"
vmware-rpctool "info-set guestinfo.vendordata.encoding  "

Please note that keys are set to the valid YAML string --- as it is not possible remove an existing key from the guestinfo key-space. A key's analogous encoding property will be set to a single white-space character, causing the datasource to treat the actual key value as plain-text, thereby loading it as an empty YAML doc (hence the aforementioned ---).

Reading the local IP addresses

This datasource automatically discovers the local IPv4 and IPv6 addresses for a guest operating system based on the default routes. However, when inspecting a VM externally, it's not possible to know what the default IP address is for the guest OS. That's why this datasource sets the discovered, local IPv4 and IPv6 addresses back in the guestinfo namespace as the following keys:

  • guestinfo.local-ipv4
  • guestinfo.local-ipv6

It is possible that a host may not have any default, local IP addresses. It's also possible the reported, local addresses are link-local addresses. But these two keys may be used to discover what this datasource determined were the local IPv4 and IPv6 addresses for a host.

Waiting on the network

Sometimes cloud-init may bring up the network, but it will not finish coming online before the datasource's setup function is called, resulting in an /var/run/cloud-init/instance-data.json file that does not have the correct network information. It is possible to instruct the datasource to wait until an IPv4 or IPv6 address is available before writing the instance data with the following metadata properties:

wait-on-network:
  ipv4: true
  ipv6: true

If either of the above values are true, then the datasource will sleep for a second, check the network status, and repeat until one or both addresses from the specified families are available.

Building the RPM

Building the RPM locally is handled via Docker. Simple execute the following command:

make rpm

The resulting RPMs are located in rpmbuild/$OS/RPMS/noarch/. The list of supported $OS platforms are:

  • el7 (RHEL/CentOS 7)

Conclusion

To learn more about how to use cloud-init with CentOS, please see the cloud-init documentation for more examples and reference information for the cloud-config files.

More Repositories

1

kubeless

Kubernetes Native Serverless Framework
Go
6,867
star
2

clarity

Clarity is a scalable, accessible, customizable, open source design system built with web components. Works with any JavaScript framework, built for enterprises, and designed to be inclusive.
TypeScript
6,456
star
3

octant

Highly extensible platform for developers to better understand the complexity of Kubernetes clusters.
Go
6,247
star
4

kubewatch

Watch k8s events and trigger Handlers
Go
2,448
star
5

scripted

The Scripted code editor
JavaScript
1,564
star
6

eventrouter

A simple introspective kubernetes service that forwards events to a specified sink.
Go
873
star
7

tgik

Official repository for TGI Kubernetes (TGIK)!
Shell
828
star
8

kube-prod-runtime

A standard infrastructure environment for Kubernetes
Jsonnet
776
star
9

healthcheck

A library for implementing Kubernetes liveness and readiness probe handlers in your Go application.
Go
675
star
10

pivotal_workstation

A cookbook of recipes for an OSX workstation
662
star
11

cabin

The Mobile Dashboard for Kubernetes
JavaScript
659
star
12

dispatch

Dispatch is a framework for deploying and managing serverless style applications.
Go
535
star
13

buildkit-cli-for-kubectl

BuildKit CLI for kubectl is a tool for building container images with your Kubernetes cluster
Go
491
star
14

haret

A strongly consistent distributed coordination system, built using proven protocols & implemented in Rust.
Rust
462
star
15

concourse-pipeline-samples

Sample code and recipes for Concourse CI pipelines and deployments.
Shell
447
star
16

cascade

A Just-In-Time Compiler for Verilog from VMware Research
C++
430
star
17

projectmonitor

Big Visible Chart CI aggregator
Ruby
427
star
18

kubeless-ui

Graphical User Interface for Kubeless
JavaScript
417
star
19

halite

DEPRECATED: A client-side web application interface to a running Salt infrastructure
Python
413
star
20

gangway

An application that can be used to easily enable authentication flows via OIDC for a kubernetes cluster.
Go
407
star
21

salty-vagrant

Use Salt as a Vagrant provisioner.
Shell
373
star
22

liota

Python
336
star
23

lightwave

Identity services for traditional infrastructure, applications and containers.
C
321
star
24

rbvmomi

Ruby interface to the VMware vSphere API.
Ruby
302
star
25

git_scripts

Developer workflow convenience scripts
Ruby
279
star
26

pcfdev

This is the depricated version of PCF Dev - please visit the current Github repository https://github.com/cloudfoundry-incubator/cfdev for the latest updates
Go
273
star
27

springsource-cloudfoundry-samples

Samples for Cloud Foundry
Java
259
star
28

admiral

Container management solution with an accent on modeling containerized applications and provide placement based on dynamic policy allocation
Java
254
star
29

vsphere-storage-for-docker

vSphere Storage for Docker
Python
254
star
30

salt-vim

Vim files for editing Salt files
Vim Script
246
star
31

rvc

RVC is a Linux console UI for vSphere, built on the RbVmomi bindings to the vSphere API.
Ruby
238
star
32

xenon

Xenon - Decentralized Control Plane Framework
Java
226
star
33

database-stream-processor

Streaming and Incremental Computation Framework
Rust
222
star
34

raet

Reliable Asynchronous Event Transport Protocol
Python
208
star
35

salt-cloud

Salt Cloud Working group.
200
star
36

vsphere-automation-sdk-rest

REST (Postman and JavaScript) samples and API reference documentation for vSphere using the VMware REST API
197
star
37

jsunit

The original unit-testing framework for JavaScript. These days we use Jasmine (http://github.com/pivotal/jasmine) by default for JS testing; JsUnit is not actively developed or supported.
Java
173
star
38

sql_magic

Magic functions for using Jupyter Notebook with Apache Spark and a variety of SQL databases.
Jupyter Notebook
171
star
39

purser

Kubernetes Cloud Native Applications visibility
Go
171
star
40

pyvcloud

Python SDK for VMware vCloud Director
Python
170
star
41

salt-contrib

Salt Module Contributions
Python
170
star
42

powernsx

PowerShell module that abstracts the VMware NSX-v API to a set of easily used PowerShell functions
PowerShell
170
star
43

p4c-xdp

Backend for the P4 compiler targeting XDP
C
166
star
44

webcommander

Powerful, flexible, intuitive and most importantly simple. That is what a real automation solution should be. No matter how complicated the task is, we'd like to turn it into a single click. Is that possible? Not without webcommander :)
PowerShell
166
star
45

vcd-cli

Command Line Interface for VMware vCloud Director
Python
164
star
46

wardroom

A tool for creating Kubernetes-ready base operating system images.
Python
162
star
47

pcf-pipelines

PCF Pipelines
Shell
158
star
48

spring-boot-cities

A Spring Boot + Spring Data + Spring Cloud Connectors demo app
Java
149
star
49

kube-manifests

A collection of misc Kubernetes configs for various jobs, as used in Bitnami's production clusters.
Jsonnet
136
star
50

ktx

manage kubernetes cluster configs
Shell
133
star
51

pg_rewind

Tool for resynchronizing a Postgres database after failover
125
star
52

AndroidIntelliJStarter

An IntelliJ template project for android developers, pre-configured to work with Robolectric, Roboguice, an other common, useful Android libraries.
Java
125
star
53

vctl-docs

VMware vctl Docs
124
star
54

cimonitor

This project has been renamed to ProjectMonitor - http://github.com/pivotal/projectmonitor
121
star
55

tmux-config

Configuration and tools for tmux. Can be used as a Vim plugin.
Shell
121
star
56

PivotalMySQLWeb

PivotalMySQL*Web is a free Pivotal open source project, intended to handle the administration of a Pivotal MySQL Service Instance over the Web
JavaScript
120
star
57

salt-api

RETIRED: Generic, modular network access system
Python
112
star
58

atc

old - now lives in https://github.com/concourse/concourse
111
star
59

nsxansible

A set of example Ansible Modules using the above two projects as the basis
Python
110
star
60

pg2mysql

Tool for safely migrating from PostgreSQL to MySQL
Go
107
star
61

clarity-seed

This is a repository for a seed project that includes Clarity Design System's dependencies.
TypeScript
104
star
62

helm-crd

Experimental CRD controller for managing Helm releases
Go
103
star
63

fly

old - now lives in https://github.com/concourse/concourse
100
star
64

declarative-cluster-management

Declarative cluster management using constraint programming, where constraints are described using SQL.
Java
99
star
65

hillview

Big data spreadsheet
Java
99
star
66

cbapi

Carbon Black API Resources
Python
94
star
67

vmware-vcenter

VMware vCenter Module
Ruby
87
star
68

ModSecurity-envoy

ModSecurity V3 Envoy Filter
C++
86
star
69

springtrader

JavaScript
83
star
70

tic

Bit9 + Carbon Black Threat Intelligence
Python
80
star
71

runtimes

Kubeless function runtimes: https://kubeless.io/docs/runtimes/
C#
79
star
72

pyvmomi-tools

Additional community developed python packages to help you work with pyvmomi
Python
77
star
73

gpdb-sandbox-tutorials

76
star
74

salt-windows-install

Open source installer for Windows
75
star
75

vagrant-vmware-appcatalyst

Vagrant provider for VMware AppCatalystยฎ
Ruby
73
star
76

transport-go

Transport is a full stack, simple, fast, expandable application event bus for your applications. It provides a standardized and simple API, implemented in multiple languages, to allow any individual component inside your applications to talk to one another. This is the Golang implementation of the Transport library.
Go
72
star
77

concord

๐Ÿงฑโ›“๏ธ A scalable decentralized blockchain
C++
71
star
78

terraforming-gcp

use terraform, deploy yourself a pcf
HCL
71
star
79

functions

Functions Repository for Kubeless
Python
70
star
80

Pivotal-Preferences-RubyMine

This repo is deprecated. Use the "Pivotal IDE Prefs" repo instead.
70
star
81

IoT-ConnectedCar

HTML
69
star
82

ironclad

Web Application Firewall (WAF) on Kubernetes
Go
69
star
83

vsphere-automation-sdk-.net

[DEPRECATED] Please see README. C# samples, language bindings, and API reference documentation for vSphere, VMC, and NSX-T using the VMware REST API
C#
67
star
84

pymadlib

A Python wrapper for MADlib(http://madlib.net) - an open source library for scalable in-database machine learning algorithms
Jupyter Notebook
65
star
85

chaperone

Python
64
star
86

bin

old - now lives in https://github.com/concourse/concourse
64
star
87

terraforming-aws

Templates to deploy PCF and PKS
HCL
64
star
88

legacy-terraform-provider-vra7

Terraform provider for vRealize Automation 7
Go
62
star
89

tutorials

PHP
59
star
90

nsxraml

A RAML Specification Describing the NSX for vSphere API
HTML
59
star
91

vra-api-samples-for-postman

API use case samples in Postman Rest Client collection format.
58
star
92

simple-k8s-test-env

For developers building and testing Kubernetes and core Kubernetes components
Shell
58
star
93

vm-operator-api

A client API for the VM Operator project, designed to allow for integration with vSphere 7 with Kubernetes
Go
58
star
94

gcp-pcf-quickstart

Install Pivotal Cloud Foundry on Google Cloud Platform With One Command
Go
56
star
95

sunspot_matchers

RSpec matchers for testing Sunspot searches
Ruby
56
star
96

ansible-security-hardening

ansible playbooks for linux distro security hardening
56
star
97

lobot

This project has been renamed to ciborg. Please visit the ciborg page for more info.
Ruby
56
star
98

salt-pack

Salt Package Builder
Shell
55
star
99

sublime-text

Salt-related syntax highlighting and snippets for Sublime Text
JavaScript
54
star
100

pynsxv

PyNSXv is a high level python based library and CLI tool to control NSX for vSphere
Python
54
star