How to configure hostname and ip address for VMware VM provisioning


#21

@xian how do I create "Custom Specification” on Cloudforms. I can’t find “override specification values” either. I have set a static ip address on the Customize tab and I also set up a dialog to set ip address but everytime I run it, the new vm doesn’t get any ip at all and now I can’t run any playbooks on it with Ansible Tower because Ansible Tower can’t resolve the hostname or the ip.


#22

You can’t create it in CF, but in vCenter only. enosullivan has put the icon to look for, see above.


#23

I’m only working with CF. I have tried to set the hostname and ip with cloud-init but it’s not working for me. At first I worked with the default oVirt cloud-init

# Configure basic host parameeters:
host_name: <%= evm[:hostname] %>
user_name: root
root_password: <%= MiqPassword.decrypt(evm[:root_password]) %>

# Run commands to configure the network using the NetworkManager command
# line tool. Note that this expects the subnet mask in the prefix format,
# for example 24 instead of 255.255.255.0.
runcmd:
- nmcli connection down eth0
- nmcli connection modify eth0
  ip4 <%= evm[:ip_addr] %>/<%= evm[:subnet_mask] %>
  gw4 <%= evm[:gateway] %>
  ipv4.dns "<%= evm[:dns_servers] %>"
  ipv4.dns-search "<%= evm[:dns_suffixes] %>"
- nmcli connection up eth0

but every time I provision a vm, it sets it to dhcp but it does set the hostname to the desired name. I’ve tried also with this custom template using this.

#cloud-config
user: admin
password: azerty123
chpasswd: {expire: False}
ssh_pwauth: False
ssh_authorized_keys:
  - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCyZwunki4dDSXIZlGX/bSJ+37Q1E90GdmewqSfQiXXXs2MOf31s3kVuVnEeZ0ZA8M8/t5GpZGIW5odY9XWdGiEmpJpvUemCPhGRFCqCOT15HF8Tjt50751k3MglGYxfmCakuY/pHW3nUFScF6uMfgTeZ6EZjRpr72D1h9WpBuJPuCCCwmMWQNofYyfKm8n/ZDy9Bo1byLBqcv4JmtjuoBgaZovJwc+koFtfA2hd48I/7un/g8PEVwpoorVa1Qxr8dLHBKTvyXIASfqJfjwXREj48M8CcBtkGV2rdua+KjLb0mk98apCuxAlwZtVBwNgFKjdKzMaNrjwZKtfZ3Lrq0h root@ansibletower.mypfeproject.tn
network-interfaces: |
  iface eth0 inet static
  address 192.168.2.222
  network 192.168.2.0
  netmask 255.255.255.0
  broadcast 192.168.2.255
  gateway 192.168.2.44
bootcmd:
  - ifdown eth0
  - ifup eth0

but it doesn’t seem to be working either, Am I missing something?
18%20PM

This was journalctl -xe
– The start-up result is done.
May 20 19:55:06 localhost.localdomain gvfsd[1904]: dbus_mount_reply: Error from org.gtk.vfs.Mountable.mount(): Failed to retrieve share list
May 20 19:55:06 localhost.localdomain gvfsd[1904]: dbus_mount_reply: Error from org.gtk.vfs.Mountable.mount(): Failed to retrieve share list
May 20 19:55:06 localhost.localdomain gvfsd[1904]: dbus_mount_reply: Error from org.gtk.vfs.Mountable.mount(): Failed to retrieve share list
May 20 19:55:06 localhost.localdomain gvfsd[1904]: dbus_mount_reply: Error from org.gtk.vfs.Mountable.mount(): Failed to retrieve share list
May 20 19:55:06 localhost.localdomain gvfsd[1904]: dbus_mount_reply: Error from org.gtk.vfs.Mountable.mount(): Failed to retrieve share list
May 20 19:55:06 localhost.localdomain gvfsd[1904]: dbus_mount_reply: Error from org.gtk.vfs.Mountable.mount(): Failed to retrieve share list
May 20 19:55:07 localhost.localdomain dhclient[2832]: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 15 (xid=0x7399d359)
May 20 19:55:22 localhost.localdomain dhclient[2832]: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 8 (xid=0x7399d359)
May 20 19:55:29 localhost.localdomain NetworkManager[883]: [1526842529.0019] dhcp4 (eth0): request timed out
May 20 19:55:29 localhost.localdomain NetworkManager[883]: [1526842529.0022] dhcp4 (eth0): state changed unknown -> timeout
May 20 19:55:29 localhost.localdomain NetworkManager[883]: [1526842529.0045] dhcp4 (eth0): canceled DHCP transaction, DHCP client pi
May 20 19:55:29 localhost.localdomain NetworkManager[883]: [1526842529.0045] dhcp4 (eth0): state changed timeout -> done
May 20 19:55:29 localhost.localdomain NetworkManager[883]: [1526842529.0047] device (eth0): state change: ip-config -> failed (reaso
May 20 19:55:29 localhost.localdomain NetworkManager[883]: [1526842529.0048] manager: NetworkManager state is now DISCONNECTED
May 20 19:55:29 localhost.localdomain NetworkManager[883]: [1526842529.0049] device (eth0): Activation: failed for connection 'Syste
May 20 19:55:29 localhost.localdomain NetworkManager[883]: [1526842529.0051] device (eth0): state change: failed -> disconnected (re
May 20 19:55:29 localhost.localdomain avahi-daemon[648]: Withdrawing address record for fe80::21a:4aff:fe16:1a5 on eth0.
May 20 19:56:27 localhost.localdomain userhelper[3116]: pam_succeed_if(ovirt-container-list:auth): requirement “user = ovirtagent” was met b
May 20 19:56:27 localhost.localdomain userhelper[3116]: running ‘/usr/share/ovirt-guest-agent/container-list’ with root privileges on behalf
May 20 19:56:31 localhost.localdomain gnome-terminal-[2695]: Allocating size to GtkScrollbar 0x101a390 without calling gtk_widget_get_prefer
May 20 19:56:34 localhost.localdomain kernel: input: spice vdagent tablet as /devices/virtual/input/input7
May 20 19:56:34 localhost.localdomain gnome-shell[2058]: JS WARNING: [resource:///org/gnome/shell/ui/workspaceThumbnail.js 892]: reference t
May 20 19:56:34 localhost.localdomain gsd-color[2279]: unable to get EDID for xrandr-Virtual-0: unable to get EDID for output
May 20 19:56:34 localhost.localdomain gnome-terminal-[2695]: Allocating size to GtkScrollbar 0x101a390 without calling gtk_widget_get_prefer
May 20 19:56:34 localhost.localdomain gsd-color[2279]: unable to get EDID for xrandr-Virtual-0: unable to get EDID for output
May 20 19:56:34 localhost.localdomain gnome-terminal-[2695]: Allocating size to GtkScrollbar 0x101a390 without calling gtk_widget_get_prefer
May 20 19:56:34 localhost.localdomain gnome-shell[2058]: g_array_unref: assertion ‘array’ failed

Cloud-init and NetworkManager-wait-online seem to be having some issues:

● cloud-init-local.service - Initial cloud-init job (pre-networking)
   Loaded: loaded (/usr/lib/systemd/system/cloud-init-local.service; enabled; vendor preset: disabled)
   Active: active (exited) since Sun 2018-05-20 19:52:26 CET; 7min ago
  Process: 881 ExecStart=/bin/touch /run/cloud-init/network-config-ready (code=exited, status=0/SUCCESS)
  Process: 720 ExecStart=/usr/bin/cloud-init init --local (code=exited, status=0/SUCCESS)
  Process: 704 ExecStartPre=/usr/bin/touch /run/cloud-init/enabled (code=exited, status=0/SUCCESS)
  Process: 692 ExecStartPre=/sbin/restorecon /run/cloud-init (code=exited, status=0/SUCCESS)
  Process: 643 ExecStartPre=/bin/mkdir -p /run/cloud-init (code=exited, status=0/SUCCESS)
 Main PID: 881 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/cloud-init-local.service

May 20 19:52:14 localhost systemd[1]: Starting Initial cloud-init job (pre-networking)...
May 20 19:52:26 localhost systemd[1]: Started Initial cloud-init job (pre-networking).


● NetworkManager-wait-online.service - Network Manager Wait Online
   Loaded: loaded (/usr/lib/systemd/system/NetworkManager-wait-online.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sun 2018-05-20 19:52:57 CET; 8min ago
     Docs: man:nm-online(1)
  Process: 889 ExecStart=/usr/bin/nm-online -s -q --timeout=30 (code=exited, status=1/FAILURE)
 Main PID: 889 (code=exited, status=1/FAILURE)

May 20 19:52:27 localhost systemd[1]: Starting Network Manager Wait Online...
May 20 19:52:57 localhost systemd[1]: NetworkManager-wait-online.service: main process exited, code=exited, status=1/FAILURE
May 20 19:52:57 localhost systemd[1]: Failed to start Network Manager Wait Online.
May 20 19:52:57 localhost systemd[1]: Unit NetworkManager-wait-online.service entered failed state.
May 20 19:52:57 localhost systemd[1]: NetworkManager-wait-online.service failed.

journalctl -f -u cloud-init
-- Logs begin at Sun 2018-05-20 19:51:50 CET. --
May 20 20:17:08 localhost.localdomain cloud-init[4008]: ci-info: |  lo:   | True | 127.0.0.1 | 255.0.0.0 |   .   |         .         |
May 20 20:17:08 localhost.localdomain cloud-init[4008]: ci-info: |  lo:   | True |     .     |     .     |   d   |         .         |
May 20 20:17:08 localhost.localdomain cloud-init[4008]: ci-info: | eth0:  | True |     .     |     .     |   .   | 00:1a:4a:16:01:a5 |
May 20 20:17:08 localhost.localdomain cloud-init[4008]: ci-info: | eth0:  | True |     .     |     .     |   d   | 00:1a:4a:16:01:a5 |
May 20 20:17:08 localhost.localdomain cloud-init[4008]: ci-info: +--------+------+-----------+-----------+-------+-------------------+
May 20 20:17:08 localhost.localdomain cloud-init[4008]: 2018-05-20 20:17:08,524 - util.py[WARNING]: No instance datasource found! Likely bad things to come!
May 20 20:17:08 localhost.localdomain systemd[1]: cloud-init.service: main process exited, code=exited, status=1/FAILURE
May 20 20:17:08 localhost.localdomain systemd[1]: Failed to start Initial cloud-init job (metadata service crawler).
May 20 20:17:08 localhost.localdomain systemd[1]: Unit cloud-init.service entered failed state.
May 20 20:17:08 localhost.localdomain systemd[1]: cloud-init.service failed.

#24

OK this topic was about VMware VM provisioning, but apparently you use RHEV as provider, right?

Check out Adding a Customization Template and Provisioning a Virtual Machine from a Template step 15 d:

Select Customize Template for additional instance configuration. Select from the Kickstart or Cloud-Init customization templates stored on your appliance.


#25

I apologize for posting here, I thought my problem was relative to this topic since I am also dealing with configuring hostname and ip address for vm provisioning but for CF not for VMware. Thank you for your help but I have indeed done those step as mentioned but it’s not working.