<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Cloudinit does not work correctly]]></title><description><![CDATA[<p dir="auto">I'm using Xenserver 7.1 and XenOrchestra (xo-server 5.62.0 and xo-web 5.63.0).<br />
I'm following this <a href="https://xen-orchestra.com/blog/centos-cloud-template-for-xenserver/" target="_blank" rel="noopener noreferrer nofollow ugc">tutorial</a> and installed a CentOS 7.0 minimal to create a cloudinit template from scratch.<br />
When trying to upload a VM from the created template, it can only load the cloud drive if I use the SSH-Key option (the first option below).<br />
<img src="https://xen-orchestra.com/blog/content/images/2016/02/cloudinit.png" alt="alt text" class=" img-fluid img-markdown" /></p>
<p dir="auto">However, if I put the same configuration in the custom config option it doesn't work. Below is the configuration I am using (replacing with my corresponding key in <code>ssh-rsa &lt;myKey&gt;</code>). for example, following this <a href="https://xen-orchestra.com/blog/full-cloudinit-power-in-xenserver/" target="_blank" rel="noopener noreferrer nofollow ugc">tutorial</a>.</p>
<pre><code># cloud-config
hostname: proxy
ssh_authorized_keys:
   - ssh-rsa &lt;myKey&gt;
</code></pre>
<p dir="auto">When I try to connect via ssh to the newly created VM, it gives a permission error.</p>
<pre><code>ssh -i ~/.ssh/mykey centos@10.xx.xx.109
</code></pre>
<p dir="auto">so...</p>
<pre><code>Warning: Permanently added '10.xx.xx.109 '(ECDSA) to the list of known hosts.
centos@10.xx.xx.109: Permission denied (publickey, gssapi-keyex, gssapi-with-mic).
</code></pre>
<p dir="auto">Right after that I connect to the VM via root and go to /home/centos/.ssh/authorized_keys and there's nothing inside.<br />
I tested it by also putting parameters for changing the hostname and installing some packages in the custom config and none of them worked for me.</p>
<p dir="auto">I looked at <code>/var/log/cloud-init</code> to check for something strange and saw nothing that could indicate an error. He can even mount the disk containing the settings (config drive) <code>/dev/xvdb</code>. Here is a part of a part of the attempt to connect to the config drive and read the files.</p>
<pre><code>2020-07-15 22:12:06,723 - util.py[DEBUG]: Running command ['mount', '-o', 'ro,sync', '-t', 'auto', u'/dev/xvdb', '/run/cloud-init/tmp/tmplcFFJh'] with allowed return codes [0] (shell=False, capture=True)
2020-07-15 22:12:06,801 - util.py[DEBUG]: Reading from /run/cloud-init/tmp/tmplcFFJh//user-data (quiet=False)
2020-07-15 22:12:06,802 - util.py[DEBUG]: Read 232 bytes from /run/cloud-init/tmp/tmplcFFJh//user-data
2020-07-15 22:12:06,802 - util.py[DEBUG]: Reading from /run/cloud-init/tmp/tmplcFFJh//meta-data (quiet=False)
2020-07-15 22:12:06,803 - util.py[DEBUG]: Read 50 bytes from /run/cloud-init/tmp/tmplcFFJh//meta-data
2020-07-15 22:12:06,803 - util.py[DEBUG]: Reading from /run/cloud-init/tmp/tmplcFFJh//vendor-data (quiet=False)
2020-07-15 22:12:06,803 - util.py[DEBUG]: Reading from /run/cloud-init/tmp/tmplcFFJh//network-config (quiet=False)
2020-07-15 22:12:06,805 - util.py[DEBUG]: Read 104 bytes from /run/cloud-init/tmp/tmplcFFJh//network-config
2020-07-15 22:12:06,805 - util.py[DEBUG]: Running command ['umount', '/run/cloud-init/tmp/tmplcFFJh'] with allowed return codes [0] (shell=False, capture=True)
2020-07-15 22:12:06,825 - util.py[DEBUG]: Attempting to load yaml from string of length 50 with allowed root types (&lt;type 'dict'&gt;,)
2020-07-15 22:12:06,826 - util.py[DEBUG]: Attempting to load yaml from string of length 104 with allowed root types (&lt;type 'dict'&gt;,)
2020-07-15 22:12:06,827 - util.py[DEBUG]: loaded blob returned None, returning default.
2020-07-15 22:12:06,827 - handlers.py[DEBUG]: finish: init-local/search-NoCloud: FAIL: no local data found from DataSourceNoCloud
2020-07-15 22:12:06,827 - util.py[WARNING]: Getting data from &lt;class 'cloudinit.sources.DataSourceNoCloud.DataSourceNoCloud'&gt; failed
2020-07-15 22:12:06,828 - util.py[DEBUG]: Getting data from &lt;class 'cloudinit.sources.DataSourceNoCloud.DataSourceNoCloud'&gt; failed
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/cloudinit/sources/__init__.py", line 743, in find_source
    if s.update_metadata([EventType.BOOT_NEW_INSTANCE]):
  File "/usr/lib/python2.7/site-packages/cloudinit/sources/__init__.py", line 632, in update_metadata
    result = self.get_data()
  File "/usr/lib/python2.7/site-packages/cloudinit/sources/__init__.py", line 256, in get_data
    return_value = self._get_data()
  File "/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceNoCloud.py", line 126, in _get_data
    mydata = _merge_new_seed(mydata, seeded)
  File "/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceNoCloud.py", line 353, in _merge_new_seed
    util.load_yaml(seeded.get('network-config')))
  File "/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceNoCloud.py", line 324, in _maybe_remove_top_network
    network_val = cfg.get('network', nullval)
AttributeError: 'NoneType' object has no attribute 'get'
2020-07-15 22:12:06,842 - main.py[DEBUG]: No local datasource found
</code></pre>
<p dir="auto">The full <code>cloud-init.log</code> file is <a href="https://bin.disroot.org/?74b86fcc81ebeba0#7Rt4LEqBn7Z1t7kdpuHhkARDKUYboAANccpvxBcJk6uf" target="_blank" rel="noopener noreferrer nofollow ugc">here</a>.</p>
<p dir="auto">What is the explanation for the ssh key config drive to work and the xen orchestra custom config not?</p>
]]></description><link>https://xcp-ng.org/forum/topic/3302/cloudinit-does-not-work-correctly</link><generator>RSS for Node</generator><lastBuildDate>Mon, 15 Jun 2026 07:42:34 GMT</lastBuildDate><atom:link href="https://xcp-ng.org/forum/topic/3302.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 15 Jul 2020 22:53:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Cloudinit does not work correctly on Thu, 16 Jul 2020 16:24:22 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/olivierlambert" aria-label="Profile: olivierlambert">@<bdi>olivierlambert</bdi></a> said in <a href="/forum/post/29204">Cloudinit does not work correctly</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/mlustosa" aria-label="Profile: mlustosa">@<bdi>mlustosa</bdi></a> said in <a href="/forum/post/29203">Cloudinit does not work correctly</a>:</p>
<blockquote>
<p dir="auto">ssh-ed25519</p>
</blockquote>
<p dir="auto">This is probably the issue. Are you sure you added correctly your key manually?</p>
</blockquote>
<p dir="auto">it's correct. I have two keys, one id_ed25519 and the other id_rsa.</p>
]]></description><link>https://xcp-ng.org/forum/post/29206</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/29206</guid><dc:creator><![CDATA[mlustosa]]></dc:creator><pubDate>Thu, 16 Jul 2020 16:24:22 GMT</pubDate></item><item><title><![CDATA[Reply to Cloudinit does not work correctly on Thu, 16 Jul 2020 16:23:20 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/olivierlambert" aria-label="Profile: olivierlambert">@<bdi>olivierlambert</bdi></a><br />
I found out where the error is. For some reason it doesn't load the user-data file (cloud-config) if the network-config has something written, even commented out (starting with #).</p>
<p dir="auto">I removed the file out of the config drive and restarted the VM and then it worked! It managed to add the public key ssh and install some packages on the system. If in the act of creating the VM in the Xen Orchestra I leave the network-config blank also works.</p>
<p dir="auto">Why doesn't he accept the commented network-config file?</p>
<p dir="auto">As in the act of creation the file is commented (network-config), so I thought that keeping it that way would not influence anything.</p>
]]></description><link>https://xcp-ng.org/forum/post/29205</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/29205</guid><dc:creator><![CDATA[mlustosa]]></dc:creator><pubDate>Thu, 16 Jul 2020 16:23:20 GMT</pubDate></item><item><title><![CDATA[Reply to Cloudinit does not work correctly on Thu, 16 Jul 2020 16:16:55 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/mlustosa" aria-label="Profile: mlustosa">@<bdi>mlustosa</bdi></a> said in <a href="/forum/post/29203">Cloudinit does not work correctly</a>:</p>
<blockquote>
<p dir="auto">ssh-ed25519</p>
</blockquote>
<p dir="auto">This is probably the issue. Are you sure you added correctly your key manually?</p>
]]></description><link>https://xcp-ng.org/forum/post/29204</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/29204</guid><dc:creator><![CDATA[olivierlambert]]></dc:creator><pubDate>Thu, 16 Jul 2020 16:16:55 GMT</pubDate></item><item><title><![CDATA[Reply to Cloudinit does not work correctly on Thu, 16 Jul 2020 16:15:04 GMT]]></title><description><![CDATA[<p dir="auto"><code>/mnt/dados -&gt; /dev/xvdb (config drive with SSH-key)</code><br />
<code>/mnt/dados2 -&gt; /dev/xvdc (config drive with custom config)</code></p>
<pre><code class="language-bash">[centos@localhost ~]$ blkid /dev/xvdb
/dev/xvdb: SEC_TYPE="msdos" LABEL="cidata" UUID="355A-4FC2" TYPE="vfat"

[centos@localhost ~]$ blkid /dev/xvdc
/dev/xvdc: SEC_TYPE="msdos" LABEL="cidata" UUID="355A-4FC2" TYPE="vfat" 
</code></pre>
<pre><code class="language-bash">[centos@localhost ~]$ fdisk -l

Disk /dev/xvdb: 10 MB, 10485760 bytes, 20480 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x00000000

    Device Boot      Start         End      Blocks   Id  System

Disk /dev/xvdc: 10 MB, 10485760 bytes, 20480 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x00000000

    Device Boot      Start         End      Blocks   Id  System
</code></pre>
<pre><code class="language-bash">[centos@localhost ~]$ diff /mnt/dados /mnt/dados2

diff /mnt/dados/meta-data /mnt/dados2/meta-data
1c1
&lt; instance-id: 88d79afd-2970-176a-e9e9-916540d993c2
---
&gt; instance-id: 9a9aad16-b51e-cd6c-4f6e-5afe9b757d4e
Only in /mnt/dados: network-config
Common subdirectories: /mnt/dados/openstack and /mnt/dados2/openstack
diff /mnt/dados/user-data /mnt/dados2/user-data
2c2
&lt; hostname: centos7-xentools0
---
&gt; hostname: CentOS-7-cloudinit-withxentools
4c4,5
&lt;    - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIM2eZQHBkRY7BUZ+sJG9JH9nngFOmednoMG6Gxn7Trrq local marllus
---
&gt;   - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIM2eZQHBkRY7BUZ+sJG9JH9nngFOmednoMG6Gxn7Trrq local marllus
&gt;   - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDwklFtEWwv6frHY3RtzLzV4Cjk42Z6e+DoSSVo2Oc5BVRBUAgQ0TcjdJQKxQt5VxZs7inRlFcOJ/TU8PYveb0n7uPNDQRXHKKFFq/G6ByGORiMWsfGrA7CQe7lTLFmcDprqqxEuhfMNjC5wL9kegTS2boU+u8PyKFKnTT91ivPuaOCwhHM0k2N6Q+PIsuBj6UsrAt08XQHCwup2jvM+MrtQVRju+kHMhXHvUeOP19gCBkSFgU+jKJoHFQ14Fce4z9K+TvYqyBIlHJh/aTV9iTfsnbb3KHRCMu2hxD0V2TPCrlz24xajuKqQxAWieNbhcquRKPuU58jeegZ8VwzbaV3 marllus@peba
</code></pre>
]]></description><link>https://xcp-ng.org/forum/post/29203</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/29203</guid><dc:creator><![CDATA[mlustosa]]></dc:creator><pubDate>Thu, 16 Jul 2020 16:15:04 GMT</pubDate></item><item><title><![CDATA[Reply to Cloudinit does not work correctly on Thu, 16 Jul 2020 14:02:42 GMT]]></title><description><![CDATA[<p dir="auto">That's why I asked in the first place, <strong>to compare the generated files in the cloud init disk</strong>.</p>
]]></description><link>https://xcp-ng.org/forum/post/29194</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/29194</guid><dc:creator><![CDATA[olivierlambert]]></dc:creator><pubDate>Thu, 16 Jul 2020 14:02:42 GMT</pubDate></item><item><title><![CDATA[Reply to Cloudinit does not work correctly on Thu, 16 Jul 2020 13:57:12 GMT]]></title><description><![CDATA[<p dir="auto">I took a new test. I saved the VDI created (config drive) by Xen Orchestra using the SSH-Key option. I created a VM with cloud-init installed and before loading it I connected this VDI to it. It worked, including the packages option, as shown below:</p>
<pre><code>#cloud-config
hostname: centos-app
ssh_authorized_keys:
  - ssh-rsa &lt;myKey&gt;
packages:
  - vim
  - git
  - tcpdump
</code></pre>
<p dir="auto">When the VM starts, the public key ssh is in <code>~/.ssh/authorized_keys</code> and the <code>vim</code>, <code>git</code> and <code>tcpdump</code> packages are installed.</p>
<p dir="auto">Which generates the following hypothesis: The problem is in the generation of the VDI config drive (with custom config) using Xen Orchestra.</p>
<p dir="auto">Any direction?</p>
]]></description><link>https://xcp-ng.org/forum/post/29192</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/29192</guid><dc:creator><![CDATA[mlustosa]]></dc:creator><pubDate>Thu, 16 Jul 2020 13:57:12 GMT</pubDate></item><item><title><![CDATA[Reply to Cloudinit does not work correctly on Thu, 16 Jul 2020 12:50:07 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/olivierlambert" aria-label="Profile: olivierlambert">@<bdi>olivierlambert</bdi></a><br />
I compared and as I said, really with SSH-key only he can read the data and with custom config not.</p>
<p dir="auto"><code>/var/log/cloud-init.log</code> after applying SSH-key:</p>
<pre><code>2020-07-16 11:56:48,074 - util.py[DEBUG]: Running command ['mount', '-o', 'ro,sync', '-t', 'auto', u'/dev/xvdb', '/run/cloud-init/tmp/tmpmejw9b'] with allowed return codes [0] (shell=False, capture=True)
2020-07-16 11:56:48,141 - util.py[DEBUG]: Reading from /run/cloud-init/tmp/tmpmejw9b//user-data (quiet=False)
2020-07-16 11:56:48,143 - util.py[DEBUG]: Read 475 bytes from /run/cloud-init/tmp/tmpmejw9b//user-data
2020-07-16 11:56:48,143 - util.py[DEBUG]: Reading from /run/cloud-init/tmp/tmpmejw9b//meta-data (quiet=False)
2020-07-16 11:56:48,144 - util.py[DEBUG]: Read 50 bytes from /run/cloud-init/tmp/tmpmejw9b//meta-data
2020-07-16 11:56:48,144 - util.py[DEBUG]: Reading from /run/cloud-init/tmp/tmpmejw9b//vendor-data (quiet=False)
2020-07-16 11:56:48,144 - util.py[DEBUG]: Reading from /run/cloud-init/tmp/tmpmejw9b//network-config (quiet=False)
2020-07-16 11:56:48,144 - util.py[DEBUG]: Running command ['umount', '/run/cloud-init/tmp/tmpmejw9b'] with allowed return codes [0] (shell=False, capture=True)
2020-07-16 11:56:48,159 - util.py[DEBUG]: Attempting to load yaml from string of length 50 with allowed root types (&lt;type 'dict'&gt;,)
2020-07-16 11:56:48,160 - DataSourceNoCloud.py[DEBUG]: Using data from /dev/xvdb
2020-07-16 11:56:48,161 - util.py[DEBUG]: Reading from /etc/hosts (quiet=False)
2020-07-16 11:56:48,161 - util.py[DEBUG]: Read 158 bytes from /etc/hosts
2020-07-16 11:56:48,164 - handlers.py[DEBUG]: finish: init-local/search-NoCloud: SUCCESS: found local data from DataSourceNoCloud
2020-07-16 11:56:48,164 - stages.py[INFO]: Loaded datasource DataSourceNoCloud - DataSourceNoCloud [seed=/dev/xvdb][dsmode=net]
</code></pre>
<p dir="auto"><code>/var/log/cloud-init.log</code> after applying custom config:</p>
<pre><code>2020-07-15 22:12:06,723 - util.py[DEBUG]: Running command ['mount', '-o', 'ro,sync', '-t', 'auto', u'/dev/xvdb', '/run/cloud-init/tmp/tmplcFFJh'] with allowed return codes [0] (shell=False, capture=True)
2020-07-15 22:12:06,801 - util.py[DEBUG]: Reading from /run/cloud-init/tmp/tmplcFFJh//user-data (quiet=False)
2020-07-15 22:12:06,802 - util.py[DEBUG]: Read 232 bytes from /run/cloud-init/tmp/tmplcFFJh//user-data
2020-07-15 22:12:06,802 - util.py[DEBUG]: Reading from /run/cloud-init/tmp/tmplcFFJh//meta-data (quiet=False)
2020-07-15 22:12:06,803 - util.py[DEBUG]: Read 50 bytes from /run/cloud-init/tmp/tmplcFFJh//meta-data
2020-07-15 22:12:06,803 - util.py[DEBUG]: Reading from /run/cloud-init/tmp/tmplcFFJh//vendor-data (quiet=False)
2020-07-15 22:12:06,803 - util.py[DEBUG]: Reading from /run/cloud-init/tmp/tmplcFFJh//network-config (quiet=False)
2020-07-15 22:12:06,805 - util.py[DEBUG]: Read 104 bytes from /run/cloud-init/tmp/tmplcFFJh//network-config
2020-07-15 22:12:06,805 - util.py[DEBUG]: Running command ['umount', '/run/cloud-init/tmp/tmplcFFJh'] with allowed return codes [0] (shell=False, capture=True)
2020-07-15 22:12:06,825 - util.py[DEBUG]: Attempting to load yaml from string of length 50 with allowed root types (&lt;type 'dict'&gt;,)
2020-07-15 22:12:06,826 - util.py[DEBUG]: Attempting to load yaml from string of length 104 with allowed root types (&lt;type 'dict'&gt;,)
2020-07-15 22:12:06,827 - util.py[DEBUG]: loaded blob returned None, returning default.
2020-07-15 22:12:06,827 - handlers.py[DEBUG]: finish: init-local/search-NoCloud: FAIL: no local data found from DataSourceNoCloud
2020-07-15 22:12:06,827 - util.py[WARNING]: Getting data from &lt;class 'cloudinit.sources.DataSourceNoCloud.DataSourceNoCloud'&gt; failed
2020-07-15 22:12:06,828 - util.py[DEBUG]: Getting data from &lt;class 'cloudinit.sources.DataSourceNoCloud.DataSourceNoCloud'&gt; failed
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/cloudinit/sources/__init__.py", line 743, in find_source
    if s.update_metadata([EventType.BOOT_NEW_INSTANCE]):
  File "/usr/lib/python2.7/site-packages/cloudinit/sources/__init__.py", line 632, in update_metadata
    result = self.get_data()
  File "/usr/lib/python2.7/site-packages/cloudinit/sources/__init__.py", line 256, in get_data
    return_value = self._get_data()
  File "/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceNoCloud.py", line 126, in _get_data
    mydata = _merge_new_seed(mydata, seeded)
  File "/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceNoCloud.py", line 353, in _merge_new_seed
    util.load_yaml(seeded.get('network-config')))
  File "/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceNoCloud.py", line 324, in _maybe_remove_top_network
    network_val = cfg.get('network', nullval)
AttributeError: 'NoneType' object has no attribute 'get'
2020-07-15 22:12:06,842 - main.py[DEBUG]: No local datasource found
</code></pre>
<p dir="auto">In summary, in the first case I have:<br />
<code>Loaded datasource DataSourceNoCloud - DataSourceNoCloud [seed=/dev/xvdb][dsmode=net]</code></p>
<p dir="auto">And in the second I have:<br />
<code>handlers.py[DEBUG]: finish: init-local/search-NoCloud: FAIL: no local data found from DataSourceNoCloud</code></p>
<p dir="auto">Another question, according to this tutorial, besides the possibility of configuring the public key, the config drive (SSH-key) also changes the hostname to the name defined in the template, however, even with SSH-key enabled it changes the name for localhost (and not for the name fixed in the template).<br />
Below is a demonstration after booting the VM with SSH-key cloud drive enabled.</p>
<pre><code>[root@localhost cloud] cat /var/lib/cloud/data/set-hostname 
{
 "fqdn": "localhost", 
 "hostname": "centos-app"
}

[root@localhost cloud] hostname
localhost
</code></pre>
]]></description><link>https://xcp-ng.org/forum/post/29184</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/29184</guid><dc:creator><![CDATA[mlustosa]]></dc:creator><pubDate>Thu, 16 Jul 2020 12:50:07 GMT</pubDate></item><item><title><![CDATA[Reply to Cloudinit does not work correctly on Thu, 16 Jul 2020 07:14:28 GMT]]></title><description><![CDATA[<p dir="auto">Have you compared the two generated files using the two different methods? That would be helpful to spot a difference (or not)</p>
]]></description><link>https://xcp-ng.org/forum/post/29181</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/29181</guid><dc:creator><![CDATA[olivierlambert]]></dc:creator><pubDate>Thu, 16 Jul 2020 07:14:28 GMT</pubDate></item></channel></rss>