cloudconfig not writing maas data source
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cloud-init |
Invalid
|
Undecided
|
Unassigned | ||
curtin |
Invalid
|
Undecided
|
Unassigned |
Bug Description
further background https:/
I'm deploying a debian 10 buster image using MAAS. No errors are reported in MAAS or curtin install but on the final boot cloud-init reports `Failed to load metadata and userdata`. checking the config for the machine in maas shows all the cloudconfig: to connect to maas but the files with oauth credentials etc dont seem to have been copied to the target.
Chris Norman (cbnorman) wrote : | #1 |
James Falcon (falcojr) wrote : | #2 |
Changed in cloud-init: | |
status: | New → Incomplete |
Scott Moser (smoser) wrote : | #3 |
When I looked at this, the most obvious thing to me was that curtin did not write a file in /etc/cloud/
A quick look at curtin didn't remind me how that file gets written in ubuntu.
https:/
The 'cloud-config' entries provided by MAAS (https:/
Chris Norman (cbnorman) wrote : | #4 |
thanks for looking into this and agreed the root problem seems to be the files are not written by curtin. I dont see any errors in the curtin log, do you know why that handle_cloudconfig function would not be run?
Ryan Harper (raharper) wrote : Re: [Bug 1927020] Re: cloudconfig not writing maas data source | #5 |
On Thu, May 6, 2021 at 5:15 AM Chris Norman <email address hidden>
wrote:
> thanks for looking into this and agreed the root problem seems to be the
> files are not written by curtin. I dont see any errors in the curtin
> log, do you know why that handle_cloudconfig function would not be run?
>
MAAS sends this information through the debconf_selections curtin config:
https:/
And the Ubuntu cloud-init package has a postinst which parses these
values and writes them out:
https:/
> --
> You received this bug notification because you are subscribed to cloud-
> init.
> https:/
>
> Title:
> cloudconfig not writing maas data source
>
> To manage notifications about this bug go to:
> https:/
>
Lee Trager (ltrager) wrote : | #6 |
As per discourse it looks like the bug is in Curtin. /etc/cloud/
Applying debconf selections
Running command ['unshare', '--fork', '--pid', '--', 'chroot', '/tmp/tmpihv32o
Running command ['unshare', '--fork', '--pid', '--', 'chroot', '/tmp/tmpihv32o
unconfiguring cloud-init
cleaning cloud-init config from: ['/tmp/
Ryan Harper (raharper) wrote : | #7 |
> As per discourse it looks like the bug is in Curtin.
No
The point of removing any files in /etc/cloud/
So the two questions are:
1) in the maas config sent to this image does it include debconf_selections (I assume yes)
2) does the cloud-init package in the target filesystem include the cloudinit.
Ryan Harper (raharper) wrote : | #8 |
Let's confirm whether the debian buster cloud-init package in the image contains a postinstall like upstream cloud-init. If not, then that's the bug. If it's present, can we confirm the MAAS curtin config included the debconf_selections.
Changed in curtin: | |
status: | New → Incomplete |
Chris Norman (cbnorman) wrote : | #9 |
i believe the maas config is sent to the image. here is the output from the maas server:
```
#maas admin machine get-curtin-config ykfy3r
Success.
Machine-readable output follows:
apt:
preserve_
proxy: http://
sources_list: 'deb http://
deb-src http://
deb http://
deb-src http://
'
cloudconfig:
maas-
content: "#cloud-
\ metadata_url: http://
\ token_secret: 8tJ8wUJNp6HxKSE
path: /etc/cloud/
maas-datasource:
content: 'datasource_list: [ MAAS ]'
path: /etc/cloud/
maas-reporting:
content: "#cloud-
\ endpoint: http://
\ M7VUBVr5KQwgVH3
\ type: webhook\n"
path: /etc/cloud/
maas-ubuntu-sso:
content: "#cloud-
path: /etc/cloud/
debconf_selections:
grub2: grub2 grub2/update_nvram boolean false
maas: 'cloud-init cloud-init/
cloud-init cloud-init/
cloud-init cloud-init/
cloud-init cloud-init/
true\
http://
8tJ8wUJNp6H
'
install:
error_tarfile: /tmp/curtin-
log_file: /tmp/install.log
post_files:
- /tmp/install.log
- /tmp/curtin-
kernel:
fallback-package: linux-image-amd64
package: linux-image-amd64
late_commands:
datasource:
- curtin
- in-target
- --
- sh
- -c
- 'echo "datasource_list: [ MAAS ]" > /etc/cloud/
maas:
- wget
- --no-proxy
- http://
- --post-data
- op=netboot_off
- -O
- /dev/null
network:
config:
- id: ens33
mac_address: 00:0c:29:d7:99:89
mtu: 1500
name: ens33
subnets:
- address: 192.168.50.34/24
dns_
- 192.168.50.10
- 8.8.8.8
dns_search: &id001
- maas
type: static
type: physical
- address:
- 192.168.50.10
search: *id001
type: nameserver
version: 1
network_commands:
builtin:
- curtin
- net-meta
...
Chris Norman (cbnorman) wrote : | #10 |
here is from the finished deployment
root@debian:~# cloud-init --version
/usr/bin/cloud-init 20.2
root@debian:~# apt list cloud-init
Listing... Done
cloud-init/stable 20.2-2~deb10u2 all [upgradable from: 20.2-2~deb10u1]
N: There is 1 additional version. Please use the '-a' switch to see it
Ryan Harper (raharper) wrote : | #11 |
@Chris
Thanks for the info. I see maas is sending the debconf selections I would expect.
For the postinst, you can view it on an installed system with cloud-init here:
/var/lib/
And if this node was deployed by maas, you can also query the debconf database to see what's set:
debconf-show cloud-init
Chris Norman (cbnorman) wrote : | #12 |
both seem to exist on the deployed machine
buster@debian:~$ ls /var/lib/
/var/lib/
buster@debian:~$ debconf-show cloud-init
debconf: DbDriver "passwords" warning: could not open /var/cache/
* cloud-init/
manual_cache_clean: true
reporting:
maas:
consumer_key: V2j8cUq5WsPfHJTZtn
endpoint: http://
token_key: xAHTmw5FGknNAx8Lev
token_secret: HA2ybunRP54ewHE
type: webhook
* cloud-init/
* cloud-init/
* cloud-init/
Ryan Harper (raharper) wrote : | #13 |
What happens when you do:
sudo dpkg-reconfigure cloud-init --frontend=
do you see /etc/cloud/
if not you can modify /var/lib/
#!/bin/sh -x
Then re-run the command and capture the output. Maybe we can see why that's not rendering the maas cloud config files.
FWIW, I've extracted the debconf_selections into a file, populated debconf, then re-run dpkg-reconfigure cloud-init and see that it does write out these files in /etc/cloud/
Chris Norman (cbnorman) wrote : | #14 |
not sure this is helpful?
root@debian:~# dpkg-reconfigure cloud-init --frontend=
root@debian:~# ls /etc/cloud/
00_debian.cfg 00-users.cfg 05_logging.cfg 50-curtin-
root@debian:~# vi /var/lib/
# changed shebang to #!/bin/sh -x
root@debian:~# dpkg-reconfigure cloud-init --frontend=
+ . /usr/share/
+ [ ! 1 ]
+ [ -z ]
+ exec
+ [ ]
+ exec
+ DEBCONF_REDIR=1
+ export DEBCONF_REDIR
+ set -f
+ db_capb escape
+ _db_cmd CAPB escape
+ _db_internal_IFS=
+ IFS=
+ printf %s\n CAPB escape
+ IFS=
+ read -r _db_internal_line
+ IFS=
+ RET=multiselect escape
+ return 0
+ [ configure = configure ]
+ [ -z 20.2-2~deb10u1 ]
+ [ configure = configure ]
+ deb-systemd-helper unmask cloud-config.
+ deb-systemd-helper --quiet was-enabled cloud-config.
+ deb-systemd-helper update-state cloud-config.
+ [ configure = configure ]
+ deb-systemd-helper unmask cloud-final.service
+ deb-systemd-helper --quiet was-enabled cloud-final.service
+ deb-systemd-helper update-state cloud-final.service
+ [ configure = configure ]
+ deb-systemd-helper unmask cloud-init-
+ deb-systemd-helper --quiet was-enabled cloud-init-
+ deb-systemd-helper update-state cloud-init-
+ [ configure = configure ]
+ deb-systemd-helper unmask cloud-init.service
+ deb-systemd-helper --quiet was-enabled cloud-init.service
+ deb-systemd-helper update-state cloud-init.service
+ which py3compile
+ py3compile -p cloud-init
+ which pypy3compile
+ [ configure = configure ]
+ [ -x /etc/init.
+ update-rc.d cloud-init-local defaults
+ [ configure = configure ]
+ [ -x /etc/init.
+ update-rc.d cloud-init defaults
+ [ configure = configure ]
+ [ -x /etc/init.
+ update-rc.d cloud-config defaults
+ [ configure = configure ]
+ [ -x /etc/init.
+ update-rc.d cloud-final defaults
root@debian:~# ls /etc/cloud/
00_debian.cfg 00-users.cfg 05_logging.cfg 50-curtin-
Ryan Harper (raharper) wrote : | #15 |
Yeah, that sure looks like the maas preseed code in postinst isn't in the debian package, can you compare your file with:
https:/
specifically, does it have the handle_
Alternatively, if maas does not send the debconf_selections, then the clean-up and dpkg-reconfigure path won't be taken in curtin.
Chris Norman (cbnorman) wrote : | #16 |
ok this is definetly the problem. the handle_
Ryan Harper (raharper) wrote : | #17 |
> ok this is definetly the problem. the handle_
\o/
> what package contains the /var/lib/
cloud-init itself. It looks like you should file a bug against debian's cloud-init package and mention that it's not tracking what upstream cloud-init (upstream cloud-init uses release branches to keep their debian/ directory changes for packaging).
> I use http://
You could install cloud-init from Ubuntu, there's a daily PPA from which you could pull a deb
Ryan Harper (raharper) wrote : | #18 |
I'm marking the curtin task invalid; after getting config and logs we confirmed that the cloud-init package in the Debian image does not contain a recent handle_
Changed in curtin: | |
status: | Incomplete → Invalid |
Ryan Harper (raharper) wrote : | #19 |
I'm marking the cloud-init task invalid. After getting config and logs we confirmed that the cloud-init package in the Debian image does not contain a recent handle_
Changed in cloud-init: | |
status: | Incomplete → Invalid |
Scott Moser (smoser) wrote : | #20 |
>> what package contains the /var/lib/
> cloud-init itself. It looks like you should file a bug against debian's
> cloud-init package and mention that it's not tracking what upstream
> cloud-init (upstream cloud-init uses release branches to keep their
> debian/ directory changes for packaging).
That really doesn't seem like the right option to me. Using dpkg preseed
"should work", but that seems like an arcane mechanism for
providing configuration data. It was a solution that was put in place in
ubuntu very early on (probably 12.04) when there wasn't a better option.
There now *is* a better option: the cloud-config files.
The better path forward would be to change curtin to write the
cloud-config files itself as is done in Centos or Ubuntu core.
I suggest that the bug here is in curtin (curtin-hooks). They needed to be
aware of this and write the files.
Ryan Harper (raharper) wrote : | #21 |
> I suggest that the bug here is in curtin (curtin-hooks). They needed to be
aware of this and write the files.
This is really orchestrated by maas...
MAAS can choose to send debconf_selections *OR* cloud-config; but it sends both.
It's been sending both for quite some time. I'd like to see MAAS decide to no longer send debconf_selections and curtin could write out cloudconfig if present in the default curtin-hooks. In fact the maas images created by maas-image-builder include a curtin-hook which already writes out cloudconfig if present.
The decision to not render cloudconfig from curtin's default curthook has always been controlled by MAAS. I don't recall exactly why but I suspect that MAAS might not decide what config to send on a per image basis; ie they send a superset of config which works for all images (old an new) and for a range of curtin releases which don't render cloud-config for ubuntu but expect debconf_selections to do so.
Chris Norman (cbnorman) wrote : | #22 |
i believe that when you set
apt:
preserve_
in the curtin_userdata then debconf is not sent by maas, this is where i initially started. I'm not sure how to confirm this though?
Ryan Harper (raharper) wrote : | #23 |
On Fri, May 14, 2021 at 10:16 AM Chris Norman <email address hidden>
wrote:
> i believe that when you set
> apt:
> preserve_
> in the curtin_userdata then debconf is not sent by maas, this is where i
> initially started. I'm not sure how to confirm this though?
>
I don't think so, maybe some MAAS folks can confirm this. Looking at the
preseeds, it's in the template.
MAAS always sends debconf_selections for cloud-init as that originally was
the only way MAAS had to configure a cloud-init
datasource. Over time curtin added support for writing out cloudconfig
into the target image. For various reasons MAAS
hasn't stopped sending debconf_selections to configure cloud-init in the
target image and the Ubuntu cloud-init package has
always had support for setting up the MAAS datasource via that method.
There's not much logic on versions or anything; I think it's just been part
of the template.
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https:/
>
> Title:
> cloudconfig not writing maas data source
>
> To manage notifications about this bug go to:
> https:/
>
Albert Valiev (artscout) wrote (last edit ): | #24 |
Just in case anyone looking for answer, I managed to find solution, not elegant one but it works:
I defined node_distribution earlier in code:
{{py:
node_distribution = node.get_
}}
1. cloud-init should be already installed in the image used for custom install. Both buster/bullseye
2. in case of bullseye python2 should be installed and made to provide /usr/bin/python, also pyyaml should be installed for python2. I did that with this late commands:
{{if node_distribution == "bullseye"}}
27_install_
28_install_
{{endif}}
3. netplan.io should be installed, while it's not used MaaS expects one to be installed on host so we install it:
34_add_neplan: ["curtin", "in-target", "--", "sh", "-c", "DEBIAN_
4. postinstall action for cloud-init package should be fired in late commands, no other way (like dpkg-reconfigure or new install of cloud-init works normally, latter adding maas datasource but deleting network config sadly). And as datasource for maas defined in debconf we have to fire it so handle_maas function do it's magic:
{{if node_distribution == "bullseye" or node_distribution == "buster"}}
35_reconfigur
{{endif}}
with this steps debian buster and bullseye installed successfully with MaaS 3.2.4
James Falcon (falcojr) wrote : | #25 |
Tracked in Github Issues as https:/
Looking at the logs, a few things stand out: cloud.cfg is practically empty. This is usually baked into the image, so to me this suggests a problem happening before we get to cloud-init. /github. com/canonical/ cloud-init/ blob/master/ tools/ds- identify# L784).
* /etc/cloud/
* ds-identify.log shows it couldn't detect a datasource. This means this check returned false, but it should be returning true on MAAS (https:/
* The cloud-init code could also not detect a datasource. This again seems to suggest a problem with the image or fabric itself, not cloud-init.
I'm going to set the state of this bug to Incomplete for now. If you can provide more information to show that cloud-init isn't doing what you expected, feel free to set the status back to New.