Hello
I have an Ubuntu blueprint With vmware tools install all thé customisation IS ok but i tries to add a custom propertie to enter a user n'aime and password and add thème to a New user on thé déployed serveur With no success
Can you help me
Are you using and Ubuntu template with Cloud-Init?
I use Ubuntu template With the vmware tools and all the network config and os config IS throught vmware tools and vsphere customisation file
I should say that is possible to add a new user to an ubuntu server through VMware Tools in post provision. But let me tell you, with Cloud-Init this is by far more simple.
With cloud-init you just need to add a couple of lines in the Cloud Template.
With only vmware tools, you need a subscription to vRealize Orchestrator workflow, use an Action with PowerShell and you also need vCenter Credentials + Ubuntu credentials to execute the commands.
I will install it and try With i will search how to do
This is my Template which adds a user to an Ubuntu server:
formatVersion: 1
inputs:
username:
type: string
title: Username
description: Default user
password:
type: string
title: Password
description: Ingrese una contraseña
writeOnly: true
resources:
Cloud_Machine_1:
type: Cloud.Machine
properties:
image: Ubuntu 20.04 Cloud
flavor: small
constraints:
- tag: 'env:dev'
cloudConfig: |
#cloud-config
hostname: ubuntu-dev
ssh_pwauth: yes
groups:
- ${input.username}
users:
- default
- name: ${input.username}
primary-group: ${input.username}
groups: [sudo]
lock_passwd: false
sudo: ['ALL=(ALL) NOPASSWD:ALL']
shell: '/bin/bash'
chpasswd:
list: |
${input.username}:${input.password}
expire: false
runcmd:
- echo "Defaults:${input.username} !requiretty" >> /etc/sudoers.d/${input.username}
Hello
I think i have an issue but i don't understand where
My deployment IS ok but on the VM console i have an error no finger print find for the user vra
IS my local user so thé cloud config not apply
I understand, my advice is: make a lab with an Ubuntu Cloud Image. Download the OVA file and put it in a Content Library, then use this image in the Image Mapping.
Create the template and remember to use Dynamic IP. Test it, if it works, we can go forward.
hello,
So I downloaded the cloud image and configure the network with the DHCp
all is ok network ok rename hostname ok and create user ok
now I tried to configured to used my IPAM but I can't reach a network ip
regards
As I told you before, cloud-init do not support static IP. So you have 2 choices to change the IP:
I've tested option 2 with a Windows template. Just create a new ConfigurationSpec for your OS, take your template, change dynamic for static IP and add the ConfigSpec. I havent tested on Ubuntu dough.
ok but when I use the vcenter customspec the cloud-init doen't work
perhaps i miss a config
regards
I've tested it with a Windows template. I will try with Ubuntu.
ok so i had somes tests
all is ok.
I had forgot one parameter on cloud.cfg
thanks for your help
So Cloud-init and Custom Specs are in-compatible. The problem is that the cust spec will reboot the VM while cloud-init is still working. And, cloud-init only runs once. So you may loose some setup. If you want to know how to get cloud-init to set the IP,
https://vnuggets.com/2020/01/29/vra-with-cloud-init-and-static-networking/
Good article.
Carl L.
Hi Carl,
That solution doesn't work with Ubuntu.
I add the static IP Address to Ubuntu 1804 and later with the cloud-init "write_files" module and write the netplan config to the machine. It is important to set the property: customizeGuestOs to false, so the vCenter GuestCustomization will not run.
See the example here (with some code for accessing and speedup):
resources:
ubuntu:
type: Cloud.vSphere.Machine
properties:
name: '${input.name}'
image: Ubunut_2004_LTS_OP
flavor: Bronce
customizeGuestOs: false
cloudConfig: |
#cloud-config
write_files:
- path: /etc/netplan/99-installer-config.yaml
content: |
network:
version: 2
renderer: networkd
ethernets:
ens192:
addresses:
- ${resource.ubuntu.networks[0].address}/${resource.Cloud_NSX_Network_1.prefixLength}
gateway4: ${resource.Cloud_NSX_Network_1.gateway}
nameservers:
search: ${resource.Cloud_NSX_Network_1.dnsSearchDomains}
addresses: ${resource.Cloud_NSX_Network_1.dns}
hostname: ${resource.ubuntu.resourceName}
ssh_pwauth: yes
users:
- name: ${input.username}
groups: users
passwd: ${input.password}
chpasswd:
list: |
root:xyz
expire: false
runcmd:
- netplan apply
- sudo sed -e 's/.*PasswordAuthentication no.*/PasswordAuthentication yes/' -i /etc/ssh/sshd_config
- sudo sed -e '/^#PermitRootLogin/s/^.*$/PermitRootLogin yes/' -i /etc/ssh/sshd_config
- sudo service sshd restart
- sudo sed -e 's/.*ExecStart=\/lib\/systemd\/systemd-networkd-wait-online.*/ExecStart=\/lib\/systemd\/systemd-networkd-wait-online --timeout 1/' -i /lib/systemd/system/systemd-networkd-wait-online.service
- sudo cp /lib/systemd/system/systemd-networkd-wait-online.service /etc/systemd/system/
- touch /etc/cloud/cloud-init.disabled
networks:
- network: '${resource.Cloud_NSX_Network_1.id}'
assignment: static