/srv/irclogs.ubuntu.com/2021/07/02/#cloud-init.txt

darkbluebhi all - new here.. some knowledge of networking and admin.. use linux daily14:54
darkbluebstumbled upon cloud-init while setting up a pair of VMs for a client (debian 10).. will read and tune a bit today.. no K8s14:55
darkblueb.. I see this, will start here .. https://readthedocs.org/projects/cloudinit/downloads/pdf/latest/14:58
falcojrhey darkblueb, glad you're here. Feel free to ask any questions. And yes, the readthedocs cloud-init documentation is the best place to start15:01
darkbluebthx15:01
Deckard111Hi, I am having problems installing postfix using cloud-init.15:38
Deckard111on Ubuntu 20.04LTS15:38
blackboxswDeckard111: what's your  #cloud-config user-data look like?15:39
Deckard111I think it is because of the interactive mode of the postfix package15:40
Deckard111basically I want the package install with 'no configuration' option15:40
Deckard111I tried setting: debconf-selections: |15:41
Deckard111    postfix postfix/main_mailer_type string 'No configuration'15:41
Deckard111but it is being ignored, it seems15:41
Deckard111log looks like this:15:42
Deckard111Setting up postfix (3.4.13-0ubuntu1) ...15:42
Deckard111Adding group `postfix' (GID 117) ...15:42
Deckard111Done.15:42
Deckard111Adding system user `postfix' (UID 111) ...15:42
Deckard111Adding new user `postfix' (UID 111) with group `postfix' ...15:42
Deckard111ERROR: ld.so: object 'libeatmydata.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.15:42
Deckard111Not creating home directory `/var/spool/postfix'.15:42
Deckard111Creating /etc/postfix/dynamicmaps.cf15:42
Deckard111Adding group `postdrop' (GID 118) ...15:42
Deckard111Done.15:42
Deckard111postconf: warning: valid_hostname: numeric hostname: 015:42
Deckard111postconf: fatal: unable to use my own hostname15:42
Deckard111postconf: warning: valid_hostname: numeric hostname: 015:42
Deckard111postconf: fatal: unable to use my own hostname15:42
Deckard111dpkg: error processing package postfix (--configure):15:42
Deckard111 installed postfix package post-installation script subprocess returned error exit status 115:42
Deckard111@blackboxsw: There is no postfix user in user data, if that is what you are asking15:42
Deckard111after cloud init finishes the postfix package is still stuck in unconfigured status in ap15:44
Deckard111t15:44
blackboxswI 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 postfix15:45
Deckard111yes, it is a huge config with sensitive parts15:46
blackboxswgenerally since postfix isn't installed I expected you probably have a #cloud-config\npackages: [postfix]\n15:46
Deckard111postfix is in ther packages module15:46
Deckard111packages:15:46
Deckard111 - postfix15:46
blackboxswI see you mentioned " debconf-selections: |15:47
blackboxsw09:41     postfix postfix/main_mailer_type string 'No configuration'15:47
blackboxswfrom the docs https://cloudinit.readthedocs.io/en/latest/topics/modules.html?highlight=selections#apt-configure      ... it seems you are missing a top level config key15:48
Deckard111ah I see15:49
Deckard111debconf-selections is a child of apt15:49
Deckard111thanks, will check and test15:49
blackboxswDeckard111: something like this maybe? https://paste.ubuntu.com/p/JG7FGPkHTz/15:49
Deckard111yes, thank you15:50
blackboxswno worries thx for the question15:50
Deckard111blackboxsw Would i see in the cloud-init log if this apt/debcon-selections key would be properly set?16:03
Deckard111my config looks like this now: https://paste.ubuntu.com/p/PtXpccYJPQ/ but it would not work, yet16:05
Deckard111found in log: 16:06
Deckard1112021-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
Deckard1112021-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
Deckard1112021-07-02 15:55:53,125 - handlers.py[DEBUG]: finish: modules-config/config-grub-dpkg: SUCCESS: config-grub-dpkg ran successfully16:07
Deckard111still, postfix package did not fully install16:07
blackboxswDeckard111: `debconf show postfix | grep mail`16:09
blackboxswon my system with the pasted cloud-config from above I see this in logs16:10
blackboxsw2021-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:10
Deckard111I see:16:11
Deckard1112021-07-02 15:55:53,129 - helpers.py[DEBUG]: Running config-apt-configure using lock (<FileLock using file '/var/lib/cloud/instances/12908318/sem/config_apt_configu>16:11
Deckard1112021-07-02 15:55:53,131 - cc_apt_configure.py[DEBUG]: debconf_selections was not set in config16:11
Deckard1112021-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:11
blackboxswso you are missing the "set1:" key16:12
blackboxswdebconf_selections in not a string but a dict16:12
Deckard111ok,. thank you, will retry16:13
blackboxswDeckard111: 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 --annotate16:14
blackboxswwe have a start to #cloud-config schema validation and I think debconf_selections falls under one of the modules with defined schema validation 16:15
Deckard111ah, nice, good hint16:16
blackboxswso it could give you hints if that config key is improper or others16:16
Deckard111Huh: cloudinit.config.schema.SchemaValidationError: Cloud config schema errors: apt: Additional properties are not allowed ('debconf-selections' was unexpected)16:26
Deckard111oh. it is debconf_selections 16:33
Deckard111doh16:33
darkblueblike man ssh_config  when all the others are  ssh-xyz16:43
darkbluebimpressive eyeballs there blackboxsw, if I may say so16:44
blackboxswwoot woot! #achievementunlocked<sharpeyes>16:44
darkblueb:p16:44
* blackboxsw ♥'s schema validation16:45
Deckard111blackboxsw Ok, now i can see that  debconf_selections is properly set - however it is set AFTER the package is already installed by apt17:10
Deckard111so apt install still fails17:10
blackboxswbah, ordering of pkg install vs selections17:11
Deckard111yeah, always wondered about the ordering thing17:11
Deckard111anyway to fix this unless I do the install 'manually' in the cmd section?17:12
blackboxswchecking the code now https://github.com/canonical/cloud-init/blob/main/cloudinit/config/cc_apt_configure.py 17:13
blackboxswDeckard111: 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:15
blackboxsw 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:16
blackboxswyou can run `cloud-init analyze show` to see the order of config modules run on the last boot17:17
blackboxswnot 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#bootcmd17:22
Deckard111you are right, it runs in the same order17:25
Deckard111*correct order17:25
blackboxsw_roger17:25
Deckard111"debconf-show postfix | grep mail" shows:17:27
Deckard111debconf show postfix | grep mail17:27
Deckard111  postfix/mailname: 017:28
Deckard111* postfix/main_mailer_type: 'No configuration'17:28
Deckard111  postfix/mailbox_limit: 017:28
Deckard111  postfix/procmail: false17:28
Deckard111so apparently it is set17:28
Deckard111I think I need to explicelty set the system mail name, too17:29
Deckard111will try and test17:29
Deckard111blackboxsw I think I got it from here. Thank you very much for your time, patience and advice17:42
Deckard111awesome help!17:43

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!