[14:54] hi all - new here.. some knowledge of networking and admin.. use linux daily [14:55] stumbled upon cloud-init while setting up a pair of VMs for a client (debian 10).. will read and tune a bit today.. no K8s [14:58] .. I see this, will start here .. https://readthedocs.org/projects/cloudinit/downloads/pdf/latest/ [15:01] hey darkblueb, glad you're here. Feel free to ask any questions. And yes, the readthedocs cloud-init documentation is the best place to start [15:01] thx [15:38] Hi, I am having problems installing postfix using cloud-init. [15:38] on Ubuntu 20.04LTS [15:39] Deckard111: what's your #cloud-config user-data look like? [15:40] I think it is because of the interactive mode of the postfix package [15:40] basically I want the package install with 'no configuration' option [15:41] I tried setting: debconf-selections: | [15:41] postfix postfix/main_mailer_type string 'No configuration' [15:41] but it is being ignored, it seems [15:42] log looks like this: [15:42] Setting up postfix (3.4.13-0ubuntu1) ... [15:42] Adding group `postfix' (GID 117) ... [15:42] Done. [15:42] Adding system user `postfix' (UID 111) ... [15:42] Adding new user `postfix' (UID 111) with group `postfix' ... [15:42] ERROR: ld.so: object 'libeatmydata.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored. [15:42] Not creating home directory `/var/spool/postfix'. [15:42] Creating /etc/postfix/dynamicmaps.cf [15:42] Adding group `postdrop' (GID 118) ... [15:42] Done. [15:42] postconf: warning: valid_hostname: numeric hostname: 0 [15:42] postconf: fatal: unable to use my own hostname [15:42] postconf: warning: valid_hostname: numeric hostname: 0 [15:42] postconf: fatal: unable to use my own hostname [15:42] dpkg: error processing package postfix (--configure): [15:42] installed postfix package post-installation script subprocess returned error exit status 1 [15:42] @blackboxsw: There is no postfix user in user data, if that is what you are asking [15:44] after cloud init finishes the postfix package is still stuck in unconfigured status in ap [15:44] t [15:45] I meant how are you telling cloud-init to install postfix with cloud-init userdata on the system `sudo cloudinit query userdata` on the system will tell us what you are providing as #cloud-config to setup/config postfix [15:46] yes, it is a huge config with sensitive parts [15:46] generally since postfix isn't installed I expected you probably have a #cloud-config\npackages: [postfix]\n [15:46] postfix is in ther packages module [15:46] packages: [15:46] - postfix [15:47] I see you mentioned " debconf-selections: | [15:47] 09:41 postfix postfix/main_mailer_type string 'No configuration' [15:48] from the docs https://cloudinit.readthedocs.io/en/latest/topics/modules.html?highlight=selections#apt-configure ... it seems you are missing a top level config key [15:49] ah I see [15:49] debconf-selections is a child of apt [15:49] thanks, will check and test [15:49] Deckard111: something like this maybe? https://paste.ubuntu.com/p/JG7FGPkHTz/ [15:50] yes, thank you [15:50] no worries thx for the question [16:03] blackboxsw Would i see in the cloud-init log if this apt/debcon-selections key would be properly set? [16:05] my config looks like this now: https://paste.ubuntu.com/p/PtXpccYJPQ/ but it would not work, yet [16:06] found in log: [16:07] 2021-07-02 15:55:52,889 - cc_grub_dpkg.py[DEBUG]: Setting grub debconf-set-selections with '/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi0-0-0-0','false' [16:07] 2021-07-02 15:55:52,889 - subp.py[DEBUG]: Running command ['debconf-set-selections'] with allowed return codes [0] (shell=False, capture=True) [16:07] 2021-07-02 15:55:53,125 - handlers.py[DEBUG]: finish: modules-config/config-grub-dpkg: SUCCESS: config-grub-dpkg ran successfully [16:07] still, postfix package did not fully install [16:09] Deckard111: `debconf show postfix | grep mail` [16:10] on my system with the pasted cloud-config from above I see this in logs [16:10] 2021-07-02 16:06:57,809 - cc_apt_configure.py[DEBUG]: handling apt config: {'debconf_selections': {'set1': "postfix postfix/main_mailer_type string 'No configuration'"}} [16:11] I see: [16:11] 2021-07-02 15:55:53,129 - helpers.py[DEBUG]: Running config-apt-configure using lock ( [16:11] 2021-07-02 15:55:53,131 - cc_apt_configure.py[DEBUG]: debconf_selections was not set in config [16:11] 2021-07-02 15:55:53,131 - cc_apt_configure.py[DEBUG]: handling apt config: {'debconf-selections': "postfix postfix/main_mailer_type string 'No configuration'\n"} [16:12] so you are missing the "set1:" key [16:12] debconf_selections in not a string but a dict [16:13] ok,. thank you, will retry [16:14] Deckard111: this will validate your userdata schema and I think may throw and error for you on invalid debconf_selections value type: sudo cloud-init devel schema --system --annotate [16:15] we have a start to #cloud-config schema validation and I think debconf_selections falls under one of the modules with defined schema validation [16:16] ah, nice, good hint [16:16] so it could give you hints if that config key is improper or others [16:26] Huh: cloudinit.config.schema.SchemaValidationError: Cloud config schema errors: apt: Additional properties are not allowed ('debconf-selections' was unexpected) [16:33] oh. it is debconf_selections [16:33] doh [16:43] like man ssh_config when all the others are ssh-xyz [16:44] impressive eyeballs there blackboxsw, if I may say so [16:44] woot woot! #achievementunlocked [16:44] :p [16:45] * blackboxsw ♥'s schema validation [17:10] blackboxsw Ok, now i can see that debconf_selections is properly set - however it is set AFTER the package is already installed by apt [17:10] so apt install still fails [17:11] bah, ordering of pkg install vs selections [17:11] yeah, always wondered about the ordering thing [17:12] anyway to fix this unless I do the install 'manually' in the cmd section? [17:13] checking the code now https://github.com/canonical/cloud-init/blob/main/cloudinit/config/cc_apt_configure.py [17:15] Deckard111: so package-update-upgrade-install should be run in cloud_finale_modules: (listed in order in /etc/cloud/cloud.cfg) and apt-configure module should be run during cloud_config_modules stage which occurs before cloud_finale. so I don't see how that happens afterward. [17:16] on your instance if you wanted to re-run cloud-init across a reboot from scratch you could `sudo apt remove postfix; cloud-init clean --logs --reboot` [17:17] you can run `cloud-init analyze show` to see the order of config modules run on the last boot [17:22] not sure if I lost my last msg so resending: to me it looks like anything in "debconf_selections" gets run before "packages: []" get installed in typical cloud.cfg module ordering. But if needed one could run their debconf-set-selections commands directly from bootcmd: via something like this https://cloudinit.readthedocs.io/en/latest/topics/modules.html#bootcmd [17:25] you are right, it runs in the same order [17:25] *correct order [17:25] _roger [17:27] "debconf-show postfix | grep mail" shows: [17:27] debconf show postfix | grep mail [17:28] postfix/mailname: 0 [17:28] * postfix/main_mailer_type: 'No configuration' [17:28] postfix/mailbox_limit: 0 [17:28] postfix/procmail: false [17:28] so apparently it is set [17:29] I think I need to explicelty set the system mail name, too [17:29] will try and test [17:42] blackboxsw I think I got it from here. Thank you very much for your time, patience and advice [17:43] awesome help!