bottkars / labbuildr

labbuildr is an fully automated tool to deploy windows vm´s and emc va´s and solutions using powershell on vmware workstation
90 stars 17 forks source link

install-centos.ps1: multile VMs get same IP address #66

Closed schnem4 closed 8 years ago

schnem4 commented 8 years ago

When deploying multiple VMs, they all get the same ip-address. .\install-centos.ps1 -Defaults -centos_ver 7_1_1511 -ip_startrange 100 -startnode 0 -nodes 4 -size M

Output see below. I have looked into the code and came up with a solution if you're interested.

Starting Node Configuration
 ==>Waiting for Centos0 to boot
 ==>Setting Shared Folders
 ==>enabling shared folders (hgfs) for Centos0[success]
 ==>Adding Shared Folders
 ==>adding Share Sources for Folder C:\Sources to Centos0[success]
 ==>running /usr/bin/ssh-keygen -t rsa -N '' -f /root/.ssh/id_rsa on: Centos0[success]
 ==>running cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys;chmod 0600 /root/.ssh/authorized_keys on: Centos0[success]
 ==>running grep -q '^DEVICE' /etc/sysconfig/network-scripts/ifcfg-eno16777984 && sed -i 's/^DEVICE.*/DEVICE=eno16777984/' /etc/sysconfig/network-scripts/ifcfg-eno16777984 || echo 'DEVICE=eno16777984' >> /etc/sysconfig/network-scripts/ifcfg-eno16777984 on: Centos0[success]
 ==>running grep -q '^BOOTPROTO' /etc/sysconfig/network-scripts/ifcfg-eno16777984 && sed -i 's/^BOOTPROTO.*/BOOTPROTO=static/' /etc/sysconfig/network-scripts/ifcfg-eno16777984 || echo 'BOOTPROTO=static' >> /etc/sysconfig/network-scripts/ifcfg-eno16777984 on: Centos0[success]
 ==>running grep -q '^IPADDR' /etc/sysconfig/network-scripts/ifcfg-eno16777984 && sed -i 's/^IPADDR.*/IPADDR=192.168.2.100/' /etc/sysconfig/network-scripts/ifcfg-eno16777984 || echo 'IPADDR=192.168.2.100' >> /etc/sysconfig/network-scripts/ifcfg-eno16777984 on: Centos0[success]
 ==>running grep -q '^NETMASK' /etc/sysconfig/network-scripts/ifcfg-eno16777984 && sed -i 's/^NETMASK.*/NETMASK=255.255.255.0/' /etc/sysconfig/network-scripts/ifcfg-eno16777984 || echo 'NETMASK=255.255.255.0' >> /etc/sysconfig/network-scripts/ifcfg-eno16777984 on: Centos0[success]

 ==>Waiting for Centos1 to boot
 ==>Setting Shared Folders
 ==>enabling shared folders (hgfs) for Centos1[success]
 ==>Adding Shared Folders
 ==>adding Share Sources for Folder C:\Sources to Centos1[success]
 ==>running /usr/bin/ssh-keygen -t rsa -N '' -f /root/.ssh/id_rsa on: Centos1[success]
 ==>running cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys;chmod 0600 /root/.ssh/authorized_keys on: Centos1[success]
 ==>running grep -q '^DEVICE' /etc/sysconfig/network-scripts/ifcfg-eno16777984 && sed -i 's/^DEVICE.*/DEVICE=eno16777984/' /etc/sysconfig/network-scripts/ifcfg-eno16777984 || echo 'DEVICE=eno16777984' >> /etc/sysconfig/network-scripts/ifcfg-eno16777984 on: Centos1[success]
 ==>running grep -q '^BOOTPROTO' /etc/sysconfig/network-scripts/ifcfg-eno16777984 && sed -i 's/^BOOTPROTO.*/BOOTPROTO=static/' /etc/sysconfig/network-scripts/ifcfg-eno16777984 || echo 'BOOTPROTO=static' >> /etc/sysconfig/network-scripts/ifcfg-eno16777984 on: Centos1[success]
 ==>running grep -q '^IPADDR' /etc/sysconfig/network-scripts/ifcfg-eno16777984 && sed -i 's/^IPADDR.*/IPADDR=192.168.2.100/' /etc/sysconfig/network-scripts/ifcfg-eno16777984 || echo 'IPADDR=192.168.2.100' >> /etc/sysconfig/network-scripts/ifcfg-eno16777984 on: Centos1[success]
 ==>running grep -q '^NETMASK' /etc/sysconfig/network-scripts/ifcfg-eno16777984 && sed -i 's/^NETMASK.*/NETMASK=255.255.255.0/' /etc/sysconfig/network-scripts/ifcfg-eno16777984 || echo 'NETMASK=255.255.255.0' >> /etc/sysconfig/network-scripts/ifcfg-eno16777984 on: Centos1[success]

 ==>Waiting for Centos2 to boot
 ==>Setting Shared Folders
 ==>enabling shared folders (hgfs) for Centos2[success]
 ==>Adding Shared Folders
 ==>adding Share Sources for Folder C:\Sources to Centos2[success]
 ==>running /usr/bin/ssh-keygen -t rsa -N '' -f /root/.ssh/id_rsa on: Centos2[success]
 ==>running cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys;chmod 0600 /root/.ssh/authorized_keys on: Centos2[success]
 ==>running grep -q '^DEVICE' /etc/sysconfig/network-scripts/ifcfg-eno16777984 && sed -i 's/^DEVICE.*/DEVICE=eno16777984/' /etc/sysconfig/network-scripts/ifcfg-eno16777984 || echo 'DEVICE=eno16777984' >> /etc/sysconfig/network-scripts/ifcfg-eno16777984 on: Centos2[success]
 ==>running grep -q '^BOOTPROTO' /etc/sysconfig/network-scripts/ifcfg-eno16777984 && sed -i 's/^BOOTPROTO.*/BOOTPROTO=static/' /etc/sysconfig/network-scripts/ifcfg-eno16777984 || echo 'BOOTPROTO=static' >> /etc/sysconfig/network-scripts/ifcfg-eno16777984 on: Centos2[success]
 ==>running grep -q '^IPADDR' /etc/sysconfig/network-scripts/ifcfg-eno16777984 && sed -i 's/^IPADDR.*/IPADDR=192.168.2.100/' /etc/sysconfig/network-scripts/ifcfg-eno16777984 || echo 'IPADDR=192.168.2.100' >> /etc/sysconfig/network-scripts/ifcfg-eno16777984 on: Centos2[success]
 ==>running grep -q '^NETMASK' /etc/sysconfig/network-scripts/ifcfg-eno16777984 && sed -i 's/^NETMASK.*/NETMASK=255.255.255.0/' /etc/sysconfig/network-scripts/ifcfg-eno16777984 || echo 'NETMASK=255.255.255.0' >> /etc/sysconfig/network-scripts/ifcfg-eno16777984 on: Centos2[success]

 ==>Waiting for Centos3 to boot
 ==>Setting Shared Folders
 ==>enabling shared folders (hgfs) for Centos3[success]
 ==>Adding Shared Folders
 ==>adding Share Sources for Folder C:\Sources to Centos3[success]
 ==>running /usr/bin/ssh-keygen -t rsa -N '' -f /root/.ssh/id_rsa on: Centos3[success]
 ==>running cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys;chmod 0600 /root/.ssh/authorized_keys on: Centos3[success]
 ==>running grep -q '^DEVICE' /etc/sysconfig/network-scripts/ifcfg-eno16777984 && sed -i 's/^DEVICE.*/DEVICE=eno16777984/' /etc/sysconfig/network-scripts/ifcfg-eno16777984 || echo 'DEVICE=eno16777984' >> /etc/sysconfig/network-scripts/ifcfg-eno16777984 on: Centos3[success]
 ==>running grep -q '^BOOTPROTO' /etc/sysconfig/network-scripts/ifcfg-eno16777984 && sed -i 's/^BOOTPROTO.*/BOOTPROTO=static/' /etc/sysconfig/network-scripts/ifcfg-eno16777984 || echo 'BOOTPROTO=static' >> /etc/sysconfig/network-scripts/ifcfg-eno16777984 on: Centos3[success]
 ==>running grep -q '^IPADDR' /etc/sysconfig/network-scripts/ifcfg-eno16777984 && sed -i 's/^IPADDR.*/IPADDR=192.168.2.100/' /etc/sysconfig/network-scripts/ifcfg-eno16777984 || echo 'IPADDR=192.168.2.100' >> /etc/sysconfig/network-scripts/ifcfg-eno16777984 on: Centos3[success]
 ==>running grep -q '^NETMASK' /etc/sysconfig/network-scripts/ifcfg-eno16777984 && sed -i 's/^NETMASK.*/NETMASK=255.255.255.0/' /etc/sysconfig/network-scripts/ifcfg-eno16777984 || echo 'NETMASK=255.255.255.0' >> /etc/sysconfig/network-scripts/ifcfg-eno16777984 on: Centos3[success]
schnem4 commented 8 years ago

While you're at it: I'd like to be able to supply a $Nodeprefix via a parameter.

Where do I upload my script version in which I already implemented the fix for the issue plus my feature request?

schnem4 commented 8 years ago

And maybe we could fix /etc/hosts for the VM guest as well?

bottkars commented 8 years ago

added the ip_startrangecointer according to be compliant to all other scenarios

bottkars commented 8 years ago

what do you mean by fix hosts ? centos is running systemd hostnamectl daemon for hostname. we use nmcli to generate / proagate proper hostnames for hostnamectl. all other host should be retrieved from dns image

schnem4 commented 8 years ago

Yes, I noticed that my hostname will resolve to an IPv6 address and I cannot resolve the host's IPv4 address. Will need to check if this impacts distributed ViPR SRM deploys.

Edit: created the wrong dns entry. Worked after I fixed that. Forget this.

schnem4 commented 8 years ago

Did you also add the $Nodeprefix to the parameters? Can I get wiki access to document all these parameters?