<div dir="ltr">Per the script, i'll change that, probably just wasnt paying attention to where i ran chkconfig<div><br></div><div>Per cloud-init YAML, not sure. It was in a previous reply so i gave it a shot. But i can't find that usage anywhere either so i gave up on it.</div><div><br></div><div>Per troubleshooting:</div><div><br></div><div>Spinning up a VM with dns_servers and dns_search:</div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div> 66: vm_configuration[:initialization][:dns_servers] = iface_options[:dns_servers] unless iface_options[:dns_servers].nil?</div></div><div><div> 67: vm_configuration[:initialization][:dns_search] = iface_options[:dns_search] unless iface_options[:dns_search].nil?</div></div><div><div> 68: require 'pry'</div></div><div><div> 69: binding.pry</div></div><div><div> 70:</div></div><div><div> => 71: machine.start(</div></div><div><div> 72: use_cloud_init: true,</div></div><div><div> 73: vm: vm_configuration</div></div><div><div> 74: )</div></div><div><div> 75:</div></div><div><div> 76: @app.call(env)</div></div><div><div><br></div></div><div><div>[1] pry(#<VagrantPlugins::OVirtProvider::Action::StartVM>)> vm_configuration</div></div><div><div>=> {:initialization=></div></div><div><div> {:host_name=>"test",</div></div><div><div> :nic_configurations=>[{:name=>"eth0", :on_boot=>true, :boot_protocol=>"static", :ip=>{:version=>"v4", :address=>"192.168.2.200", :gateway=>"192.168.2.1", :netmask=>"255.255.255.0"}}],</div></div><div><div> :custom_script=></div></div><div><div> "manage-resolv-conf: true\n\nresolv_conf:\n nameservers: ['8.8.4.4', '8.8.8.8']\n searchdomains:\n - <a href="http://foo.example.com">foo.example.com</a>\n - <a href="http://bar.example.com">bar.example.com</a>\n domain: <a href="http://example.com">example.com</a>\n options:\n rotate: true\n timeout: 1\n",</div></div><div><div> :dns_servers=>"192.168.2.1",</div></div><div><div> :dns_search=>"test.local"}}</div></div><div><div>[2] pry(#<VagrantPlugins::OVirtProvider::Action::StartVM>)></div></div><div><div>==> default: Waiting for VM to get an IP address...</div></div><div><div>==> default: Machine is booted and ready for use!</div></div><div><div>==> default: Rsyncing folder: /home/myoung/repos/github/vagrant-ovirt4/ => /vagrant</div></div><div><div>==> default: Setting hostname...</div></div><div><div> default:</div></div><div><div> default: Vagrant insecure key detected. Vagrant will automatically replace</div></div><div><div> default: this with a newly generated keypair for better security.</div></div><div><div> default:</div></div><div><div> default: Inserting generated public key within guest...</div></div><div><div> default: Removing insecure key from the guest if it's present...</div></div><div><div> default: Key inserted! Disconnecting and reconnecting using new SSH key...</div></div></blockquote><div><br></div>now ill ssh in and look around<br><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div> myoung dev ~ repos github vagrant-ovirt4 feature/gh65 ✎ 5❓ 1 $ vagrant ssh</div></div><div><div>You appear to be running Vagrant outside of the official installers.</div></div><div><div>Note that the installers are what ensure that Vagrant has all required</div></div><div><div>dependencies, and Vagrant assumes that these dependencies exist. By</div></div><div><div>running outside of the installer environment, Vagrant may not function</div></div><div><div>properly. To remove this warning, install Vagrant using one of the</div></div><div><div>official packages from <a href="http://vagrantup.com">vagrantup.com</a>.</div></div><div><div><br></div></div><div><div>Last login: Thu Feb 16 23:04:00 2017 from 192.168.2.198</div></div><div><div>[vagrant@test ~]$ sudo cat /var/lib/cloud/instance/user-data.txt</div></div><div><div>#cloud-config</div></div><div><div>output:</div></div><div><div> all: '>> /var/log/cloud-init-output.log'</div></div><div><div>disable_root: 0</div></div><div><div>runcmd:</div></div><div><div>- 'sed -i ''/^datasource_list: /d'' /etc/cloud/cloud.cfg; echo ''datasource_list:</div></div><div><div> ["NoCloud", "ConfigDrive"]'' >> /etc/cloud/cloud.cfg'</div></div><div><div>ssh_pwauth: true</div></div><div><div>chpasswd:</div></div><div><div> expire: false</div></div><div><div>user: root</div></div><div><div>manage-resolv-conf: true</div></div><div><div><br></div></div><div><div>resolv_conf:</div></div><div><div> nameservers: ['8.8.4.4', '8.8.8.8']</div></div><div><div> searchdomains:</div></div><div><div> - <a href="http://foo.example.com">foo.example.com</a></div></div><div><div> - <a href="http://bar.example.com">bar.example.com</a></div></div><div><div> domain: <a href="http://example.com">example.com</a></div></div><div><div> options:</div></div><div><div> rotate: true</div></div><div><div> timeout: 1</div></div><div><div>[vagrant@test ~]$ sudo cat /etc/resolv.conf</div></div><div><div># Generated by NetworkManager</div></div><div><div>search localdomain</div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>[vagrant@test ~]$ cat /etc/sysconfig/network-scripts/ifcfg-eth0</div><div>NM_CONTROLLED=no</div><div>NETMASK=255.255.255.0</div><div>BOOTPROTO=static</div><div>DEVICE=eth0</div><div>IPADDR=192.168.2.200</div><div>GATEWAY=192.168.2.1</div><div>ONBOOT=yes</div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>[vagrant@test ~]$ sudo cat /var/log/cloud-init* | grep -i dns</div></div><div><div>[vagrant@test ~]$ sudo cat /var/log/cloud-init* | grep -i local</div></div><div><div>Feb 14 23:16:45 vagrant cloud-init: Cloud-init v. 0.7.5 running 'init-local' at Wed, 15 Feb 2017 05:16:45 +0000. Up 11.00 seconds.</div></div><div><div>Feb 16 23:03:35 test cloud-init: Cloud-init v. 0.7.5 running 'init-local' at Fri, 17 Feb 2017 05:03:35 +0000. Up 5.23 seconds.</div></div><div><div>Cloud-init v. 0.7.5 running 'init-local' at Thu, 09 Feb 2017 03:45:01 +0000. Up 1310.61 seconds.</div></div><div><div>Cloud-init v. 0.7.5 running 'init-local' at Wed, 15 Feb 2017 05:16:45 +0000. Up 11.00 seconds.</div></div><div><div>Cloud-init v. 0.7.5 running 'init-local' at Fri, 17 Feb 2017 05:03:35 +0000. Up 5.23 seconds.</div></div><div><div>Cloud-init v. 0.7.5 finished at Fri, 17 Feb 2017 05:03:45 +0000. Datasource DataSourceConfigDrive [local,ver=2][source=/dev/sr1]. Up 15.37 seconds</div></div></blockquote><div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><br></div></blockquote>On the vm host running that VM:<br><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><br></div><div><div>[myoung@ovirt ~]$ sudo ps -ef | grep qemu-kvm | grep test</div></div><div><div>qemu 12456 1 9 05:03 ? 00:00:19 /usr/libexec/qemu-kvm -name ...snipped</div></div><div><div>[myoung@ovirt ~]$ sudo cp /var/run/vdsm/payload/c65751c3-431d-44e4-836c-963b81b1f846.20fc2db0517e8c06579d7719d8f3fb35.img .</div></div><div><div>[myoung@ovirt ~]$ sudo mount -o loop,ro c65751c3-431d-44e4-836c-963b81b1f846.20fc2db0517e8c06579d7719d8f3fb35.img /mnt</div></div><div><div>[myoung@ovirt ~]$ find /mnt -type f</div></div><div><div>find: ‘/mnt’: Permission denied</div></div><div><div>[myoung@ovirt ~]$ sudo find /mnt -type f</div></div><div><div>/mnt/openstack/content/0000</div></div><div><div>/mnt/openstack/latest/meta_data.json</div></div><div><div>/mnt/openstack/latest/user_data</div></div><div><div>[myoung@ovirt ~]$ sudo cat /mnt/openstack/content/0000</div></div><div><div>auto eth0</div></div><div><div>iface eth0 inet static</div></div><div><div> address 192.168.2.200</div></div><div><div> netmask 255.255.255.0</div></div><div><div> gateway 192.168.2.1</div></div><div><div> dns-nameservers 192.168.2.1</div></div><div><div> dns-search test.local</div></div><div><div>[myoung@ovirt ~]$ sudo umount c65751c3-431d-44e4-836c-963b81b1f846.20fc2db0517e8c06579d7719d8f3fb35.img</div></div><div><br></div></blockquote>Cloud-init definitely isn't working right away with resolv.conf, but I'm definitely passing it correctly to the API, it shows up on the floppy as you described but it's not making its way to /etc/sysconfig/network-scripts/ifcfg-eth0 even though the other settings for sure are (such as address, netmask,)</div><div><br></div><div>If i add that information to /etc/sysconfig/network-scripts/ifcfg-eth0 and bounce network it all works:</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div>[vagrant@test ~]$ ping -c 3 <a href="http://www.google.com">www.google.com</a></div></div><div><div>ping: <a href="http://www.google.com">www.google.com</a>: Name or service not known</div></div><div><div>[vagrant@test ~]$ echo $'DNS1=192.168.2.113\nDNS2=192.168.2.1' | sudo tee -a /etc/sysconfig/network-scripts/ifcfg-eth0 >/dev/null</div></div><div><div>[vagrant@test ~]$ ping -c 3 <a href="http://www.google.com">www.google.com</a></div></div><div><div>ping: <a href="http://www.google.com">www.google.com</a>: Name or service not known</div></div><div><div>[vagrant@test ~]$ sudo service network restart</div></div><div><div>Restarting network (via systemctl): [ OK ]</div></div><div><div>[vagrant@test ~]$ ping -c 3 <a href="http://www.google.com">www.google.com</a></div></div><div><div>PING <a href="http://www.google.com">www.google.com</a> (216.58.217.4) 56(84) bytes of data.</div></div><div><div>64 bytes from <a href="http://den03s09-in-f4.1e100.net">den03s09-in-f4.1e100.net</a> (216.58.217.4): icmp_seq=1 ttl=54 time=55.8 ms</div></div><div><div>64 bytes from <a href="http://den03s09-in-f4.1e100.net">den03s09-in-f4.1e100.net</a> (216.58.217.4): icmp_seq=2 ttl=54 time=43.9 ms</div></div><div><div>^C</div></div><div><div>--- <a href="http://www.google.com">www.google.com</a> ping statistics ---</div></div><div><div>2 packets transmitted, 2 received, 0% packet loss, time 1001ms</div></div><div><div>rtt min/avg/max/mdev = 43.939/49.916/55.894/5.981 ms</div></div><div><div>[vagrant@test ~]$ sudo cat /etc/resolv.conf</div></div><div><div># Generated by NetworkManager</div></div><div><div>search localdomain</div></div><div><div>nameserver 192.168.2.113</div></div><div><div>nameserver 192.168.2.1</div></div></blockquote><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 17, 2017 at 2:21 AM, Juan Hernández <span dir="ltr"><<a href="mailto:jhernand@redhat.com" target="_blank">jhernand@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 02/17/2017 06:00 AM, Marc Young wrote:<br>
> I'm apparently really bad at email, I replied only to Shahar, not the<br>
> whole thread.<br>
><br>
> Vinzenz your email slipped first, so to answer your question:<br>
><br>
> It's the latest Centos 7 with these installed:<br>
><br>
> cloud-init-0.7.5-10.el7.<wbr>centos.1<br>
</span>> kernel-<a href="tel:3.10.0-514" value="+13100514">3.10.0-514</a> <tel:<a href="tel:3.10.0-514" value="+13100514">3.10.0-514</a>>.el7<br>
<span class="">> ovirt-guest-agent-common-1.0.<wbr>13-1.20161220085008.<wbr>git165fff1.el7.centos<br>
><br>
> The setup script I use to create a template is here:<br>
> <a href="https://github.com/myoung34/vagrant-ovirt4/blob/master/tools/prepare_redhat_for_box.sh" rel="noreferrer" target="_blank">https://github.com/myoung34/<wbr>vagrant-ovirt4/blob/master/<wbr>tools/prepare_redhat_for_box.<wbr>sh</a><br>
</span>> <<a href="https://github.com/myoung34/vagrant-ovirt4/blob/master/tools/prepare_redhat_for_box.sh" rel="noreferrer" target="_blank">https://github.com/myoung34/<wbr>vagrant-ovirt4/blob/master/<wbr>tools/prepare_redhat_for_box.<wbr>sh</a>><br>
><br>
<br>
In that script you run "chkconfig cloud-init on" *before* installing the<br>
cloud-init package. That is irrelevant, as the cloud-init services are<br>
enabled by default when the package is installed. But worth changing.<br>
<div><div class="h5"><br>
> The engine-host is oVirt Engine Version: 4.1.0.4-1.el7.centos<br>
> The ruby SDK i'm working with is 4.1.2<br>
><br>
> Halfway through I realized that it's actually supported in the API:<br>
><br>
> custom_script String<br>
> dns_search String<br>
> dns_servers String<br>
><br>
><br>
> It also shows usage here:<br>
> <a href="https://github.com/oVirt/ovirt-engine-sdk-ruby/blob/master/sdk/examples/start_vm_with_cloud_init.rb" rel="noreferrer" target="_blank">https://github.com/oVirt/<wbr>ovirt-engine-sdk-ruby/blob/<wbr>master/sdk/examples/start_vm_<wbr>with_cloud_init.rb</a><br>
> <<a href="https://github.com/oVirt/ovirt-engine-sdk-ruby/blob/master/sdk/examples/start_vm_with_cloud_init.rb" rel="noreferrer" target="_blank">https://github.com/oVirt/<wbr>ovirt-engine-sdk-ruby/blob/<wbr>master/sdk/examples/start_vm_<wbr>with_cloud_init.rb</a>><br>
><br>
> Here's some verification:<br>
><br>
> 66: vm_configuration[:<wbr>initialization][:dns_servers] =<br>
> iface_options[:dns_servers] unless iface_options[:dns_servers].<wbr>nil?<br>
> 67: vm_configuration[:<wbr>initialization][:dns_search] =<br>
> iface_options[:dns_search] unless iface_options[:dns_search].<wbr>nil?<br>
> 68: require 'pry'<br>
> 69: binding.pry<br>
> 70:<br>
> => 71: machine.start(<br>
> 72: use_cloud_init: true,<br>
> 73: vm: vm_configuration<br>
> 74: )<br>
> 75:<br>
> 76: @app.call(env)<br>
><br>
> [1] pry(#<VagrantPlugins::<wbr>OVirtProvider::Action::<wbr>StartVM>)><br>
> vm_configuration<br>
> => {:initialization=><br>
> {:host_name=>"test",<br>
> :nic_configurations=>[{:name=><wbr>"eth0", :on_boot=>true,<br>
> :boot_protocol=>"static", :ip=>{:version=>"v4",<br>
> :address=>"192.168.2.200", :gateway=>"192.168.2.1",<br>
> :netmask=>"255.255.255.0"}}],<br>
> :custom_script=>nil,<br>
> :dns_servers=>"192.168.2.1",<br>
> :dns_search=>"test.local"}}<br>
><br>
><br>
> But it didn't do anything:<br>
><br>
> [vagrant@test ~]$ cat /etc/resolv.conf<br>
> # Generated by NetworkManager<br>
> search localdomain<br>
><br>
> [vagrant@test ~]$ cat /etc/sysconfig/network-<wbr>scripts/ifcfg-eth0<br>
> NM_CONTROLLED=no<br>
> NETMASK=255.255.255.0<br>
> BOOTPROTO=static<br>
> DEVICE=eth0<br>
> IPADDR=192.168.2.200<br>
> GATEWAY=192.168.2.1<br>
> ONBOOT=yes<br>
><br>
><br>
> The same is also true using cloud_init:<br>
><br>
> ovirt.cloud_init =<<EOF<br>
> write_files:<br>
> - content: |<br>
> wat<br>
> path: /tmp/something.txt<br>
> permissions: '0644'<br>
> network-interfaces: |<br>
> auto eth0<br>
> iface eth0 inet static<br>
> address 192.168.2.201<br>
> network 192.168.2.0<br>
> netmask 255.255.255.0<br>
> gateway 192.168.2.1<br>
> dns-nameservers 192.168.2.113 192.168.2.1<br>
> EOF<br>
><br>
<br>
</div></div>Is this ^ supposed to work in cloud-init? I didn't find it in the<br>
documentation. I thought that the only way to provide network interface<br>
configuration is via the 'openstack/content/whatever' file within the<br>
generated floppy.<br>
<div><div class="h5"><br>
><br>
> and inspection:<br>
><br>
> 66: vm_configuration[:<wbr>initialization][:dns_servers] =<br>
> iface_options[:dns_servers] unless iface_options[:dns_servers].<wbr>nil?<br>
> 67: vm_configuration[:<wbr>initialization][:dns_search] =<br>
> iface_options[:dns_search] unless iface_options[:dns_search].<wbr>nil?<br>
> 68: require 'pry'<br>
> 69: binding.pry<br>
> 70:<br>
> => 71: machine.start(<br>
> 72: use_cloud_init: true,<br>
> 73: vm: vm_configuration<br>
> 74: )<br>
> 75:<br>
> 76: @app.call(env)<br>
> [1] pry(#<VagrantPlugins::<wbr>OVirtProvider::Action::<wbr>StartVM>)><br>
> vm_configuration<br>
> => {:initialization=><br>
> {:host_name=>"test",<br>
> :nic_configurations=>[{:name=><wbr>"eth0", :on_boot=>true,<br>
> :boot_protocol=>"static", :ip=>{:version=>"v4",<br>
> :address=>"192.168.2.200", :gateway=>"192.168.2.1",<br>
> :netmask=>"255.255.255.0"}}],<br>
> :custom_script=><br>
> "write_files:\n - content: |\n wat\n path:<br>
> /tmp/something.txt\n permissions: '0644'\nnetwork-interfaces: |\n<br>
> auto eth0\n iface eth0 inet static\n address 192.168.2.201\n<br>
> network 192.168.2.0\n netmask 255.255.255.0\n gateway<br>
> 192.168.2.1\n dns-nameservers 192.168.2.113 192.168.2.1\n",<br>
> :dns_servers=>"192.168.2.1",<br>
> :dns_search=>"test.local"}}<br>
><br>
><br>
> And here's my debugging after it comes up:<br>
><br>
> [vagrant@test ~]$ cat /etc/resolv.conf<br>
> # Generated by NetworkManager<br>
> search localdomain<br>
> [vagrant@test ~]$ cat /etc/sysconfig/network-<wbr>scripts/ifcfg-eth0<br>
> NM_CONTROLLED=no<br>
> NETMASK=255.255.255.0<br>
> BOOTPROTO=static<br>
> DEVICE=eth0<br>
> IPADDR=192.168.2.200<br>
> GATEWAY=192.168.2.1<br>
> ONBOOT=yes<br>
> [vagrant@test ~]$ cat /tmp/something.txt<br>
> wat<br>
> [vagrant@test ~]$ ping -c 3 <a href="http://www.google.com" rel="noreferrer" target="_blank">www.google.com</a><br>
</div></div>> <<a href="http://www.google.com/" rel="noreferrer" target="_blank">http://www.google.com/</a>>ping: <a href="http://www.google.com" rel="noreferrer" target="_blank">www.google.com</a><br>
> <<a href="http://www.google.com/" rel="noreferrer" target="_blank">http://www.google.com/</a>>: Name or service not known<br>
<span class="">> [vagrant@test ~]$ echo $'nameserver 192.168.2.113\nnameserver<br>
> 192.168.2.1' | sudo tee -a /etc/resolv.conf >/dev/null<br>
> [vagrant@test ~]$ ping -c 3 <a href="http://www.google.com" rel="noreferrer" target="_blank">www.google.com</a><br>
</span>> <<a href="http://www.google.com/" rel="noreferrer" target="_blank">http://www.google.com/</a>>PING <a href="http://www.google.com" rel="noreferrer" target="_blank">www.google.com</a><br>
> <<a href="http://www.google.com/" rel="noreferrer" target="_blank">http://www.google.com/</a>> (216.58.217.4) 56(84) bytes of data.<br>
> 64 bytes from <a href="http://den03s09-in-f4.1e100.net" rel="noreferrer" target="_blank">den03s09-in-f4.1e100.net</a><br>
> <<a href="http://den03s09-in-f4.1e100.net/" rel="noreferrer" target="_blank">http://den03s09-in-f4.1e100.<wbr>net/</a>> (216.58.217.4): icmp_seq=1<br>
<span class="">> ttl=54 time=47.5 ms<br>
> 64 bytes from <a href="http://den03s09-in-f4.1e100.net" rel="noreferrer" target="_blank">den03s09-in-f4.1e100.net</a><br>
</span>> <<a href="http://den03s09-in-f4.1e100.net/" rel="noreferrer" target="_blank">http://den03s09-in-f4.1e100.<wbr>net/</a>> (216.58.217.4): icmp_seq=2<br>
<span class="">> ttl=54 time=46.9 ms<br>
> 64 bytes from <a href="http://den03s09-in-f4.1e100.net" rel="noreferrer" target="_blank">den03s09-in-f4.1e100.net</a><br>
</span>> <<a href="http://den03s09-in-f4.1e100.net/" rel="noreferrer" target="_blank">http://den03s09-in-f4.1e100.<wbr>net/</a>> (216.58.217.4): icmp_seq=3<br>
> ttl=54 time=44.3 ms<br>
> --- <a href="http://www.google.com" rel="noreferrer" target="_blank">www.google.com</a> <<a href="http://www.google.com/" rel="noreferrer" target="_blank">http://www.google.com/</a>> ping statistics ---<br>
<span class="">> 3 packets transmitted, 3 received, 0% packet loss, time 2002ms<br>
> rtt min/avg/max/mdev = 44.385/46.307/47.555/1.390 ms<br>
><br>
<br>
</span>Not sure if you did that already, but is very useful to check the<br>
content of the floppy that the oVirt engine creates and attaches to the<br>
virtual machine. To do so run the virtual machine, then go to the<br>
hypervisor where it is running and locate the corresponding 'qemu-kvm'<br>
process:<br>
<br>
# ps -ef | grep qemu-kvm | grep myvm<br>
<br>
That will have a very long command line, and should have a 'payload'<br>
option that points to the generated floppy, something like this:<br>
<br>
-drive file=/var/run/vdsm/payload/<wbr>ae3a9cd4-....img<br>
<br>
Copy that file somewhere, and mount it:<br>
<br>
# mount -o loop,ro that_file.img /mnt<br>
<br>
Then explore the content:<br>
<br>
# find /mnt -type f<br>
/mnt/openstack/content/0000<br>
/mnt/openstack/latest/meta_<wbr>data.json<br>
/mnt/openstack/latest/user_<wbr>data<br>
<br>
The 'openstack/content/0000' file should contain your network<br>
configuration. Is it what you expected?<br>
<br>
The 'openstack/latest/user_data' file should contain the cloud-init<br>
ocnfiguration generated by oVirt, which your custom script appended.<br>
Does it look correct?<br>
<br>
(Remember to "umount /mnt" when done.)<br>
<br>
<br>
<br>
</blockquote></div><br></div>