VMware Aria Automation Tools

 View Only
Expand all | Collapse all

Add user to Ubuntu blueprint

  • 1.  Add user to Ubuntu blueprint

    Posted Sep 14, 2021 03:24 PM

    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

     

     

     

     



  • 2.  RE: Add user to Ubuntu blueprint

    Posted Sep 14, 2021 05:11 PM

    Are you using and Ubuntu template with Cloud-Init?



  • 3.  RE: Add user to Ubuntu blueprint

    Posted Sep 14, 2021 05:16 PM

    I use Ubuntu template With the vmware tools and all the network config and os config IS throught vmware tools and vsphere customisation file



  • 4.  RE: Add user to Ubuntu blueprint

    Posted Sep 14, 2021 06:01 PM

    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.



  • 5.  RE: Add user to Ubuntu blueprint

    Posted Sep 14, 2021 08:21 PM


  • 6.  RE: Add user to Ubuntu blueprint

    Posted Sep 14, 2021 08:22 PM

    I will install it and try With i will search how to do 



  • 7.  RE: Add user to Ubuntu blueprint

    Posted Sep 14, 2021 09:01 PM

    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}


  • 8.  RE: Add user to Ubuntu blueprint

    Posted Sep 17, 2021 02:23 PM

    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



  • 9.  RE: Add user to Ubuntu blueprint

    Posted Sep 17, 2021 03:58 PM

    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.



  • 10.  RE: Add user to Ubuntu blueprint

    Posted Sep 28, 2021 08:50 AM

    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



  • 11.  RE: Add user to Ubuntu blueprint

    Posted Sep 28, 2021 12:18 PM

    As I told you before, cloud-init do not support static IP. So you have 2 choices to change the IP:

    1. Use an external configuration tool like Ansible, Puppet or Saltstack
    2. Try to combine your template with a ConfigurationSpec from vCenter. 

    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.



  • 12.  RE: Add user to Ubuntu blueprint

    Posted Sep 28, 2021 12:21 PM

    ok but when I use the vcenter customspec the cloud-init doen't work

    perhaps i miss a config

    regards



  • 13.  RE: Add user to Ubuntu blueprint

    Posted Sep 28, 2021 12:25 PM

    I've tested it with a Windows template. I will try with Ubuntu.



  • 14.  RE: Add user to Ubuntu blueprint

    Posted Sep 29, 2021 02:02 PM

    ok so i had somes tests

    all is ok.

    I had forgot one parameter on cloud.cfg

     

    thanks for your help



  • 15.  RE: Add user to Ubuntu blueprint

    Posted Oct 05, 2021 01:38 AM

    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.



  • 16.  RE: Add user to Ubuntu blueprint

    Posted Oct 05, 2021 12:11 PM

    Hi Carl,

    That solution doesn't work with Ubuntu.



  • 17.  RE: Add user to Ubuntu blueprint

    Posted Oct 14, 2021 06:17 PM

    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