[14:54] <darkblueb> hi all - new here.. some knowledge of networking and admin.. use linux daily
[14:55] <darkblueb> 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] <darkblueb> .. I see this, will start here .. https://readthedocs.org/projects/cloudinit/downloads/pdf/latest/
[15:01] <falcojr> 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] <darkblueb> thx
[15:38] <Deckard111> Hi, I am having problems installing postfix using cloud-init.
[15:38] <Deckard111> on Ubuntu 20.04LTS
[15:39] <blackboxsw> Deckard111: what's your  #cloud-config user-data look like?
[15:40] <Deckard111> I think it is because of the interactive mode of the postfix package
[15:40] <Deckard111> basically I want the package install with 'no configuration' option
[15:41] <Deckard111> I tried setting: debconf-selections: |
[15:41] <Deckard111>     postfix postfix/main_mailer_type string 'No configuration'
[15:41] <Deckard111> but it is being ignored, it seems
[15:42] <Deckard111> log looks like this:
[15:42] <Deckard111> Setting up postfix (3.4.13-0ubuntu1) ...
[15:42] <Deckard111> Adding group `postfix' (GID 117) ...
[15:42] <Deckard111> Done.
[15:42] <Deckard111> Adding system user `postfix' (UID 111) ...
[15:42] <Deckard111> Adding new user `postfix' (UID 111) with group `postfix' ...
[15:42] <Deckard111> ERROR: ld.so: object 'libeatmydata.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
[15:42] <Deckard111> Not creating home directory `/var/spool/postfix'.
[15:42] <Deckard111> Creating /etc/postfix/dynamicmaps.cf
[15:42] <Deckard111> Adding group `postdrop' (GID 118) ...
[15:42] <Deckard111> Done.
[15:42] <Deckard111> postconf: warning: valid_hostname: numeric hostname: 0
[15:42] <Deckard111> postconf: fatal: unable to use my own hostname
[15:42] <Deckard111> postconf: warning: valid_hostname: numeric hostname: 0
[15:42] <Deckard111> postconf: fatal: unable to use my own hostname
[15:42] <Deckard111> dpkg: error processing package postfix (--configure):
[15:42] <Deckard111>  installed postfix package post-installation script subprocess returned error exit status 1
[15:42] <Deckard111> @blackboxsw: There is no postfix user in user data, if that is what you are asking
[15:44] <Deckard111> after cloud init finishes the postfix package is still stuck in unconfigured status in ap
[15:44] <Deckard111> t
[15:45] <blackboxsw> 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] <Deckard111> yes, it is a huge config with sensitive parts
[15:46] <blackboxsw> generally since postfix isn't installed I expected you probably have a #cloud-config\npackages: [postfix]\n
[15:46] <Deckard111> postfix is in ther packages module
[15:46] <Deckard111> packages:
[15:46] <Deckard111>  - postfix
[15:47] <blackboxsw> I see you mentioned " debconf-selections: |
[15:47] <blackboxsw> 09:41     postfix postfix/main_mailer_type string 'No configuration'
[15:48] <blackboxsw> 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] <Deckard111> ah I see
[15:49] <Deckard111> debconf-selections is a child of apt
[15:49] <Deckard111> thanks, will check and test
[15:49] <blackboxsw> Deckard111: something like this maybe? https://paste.ubuntu.com/p/JG7FGPkHTz/
[15:50] <Deckard111> yes, thank you
[15:50] <blackboxsw> no worries thx for the question
[16:03] <Deckard111> blackboxsw Would i see in the cloud-init log if this apt/debcon-selections key would be properly set?
[16:05] <Deckard111> my config looks like this now: https://paste.ubuntu.com/p/PtXpccYJPQ/ but it would not work, yet
[16:06] <Deckard111> found in log: 
[16:07] <Deckard111> 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] <Deckard111> 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] <Deckard111> 2021-07-02 15:55:53,125 - handlers.py[DEBUG]: finish: modules-config/config-grub-dpkg: SUCCESS: config-grub-dpkg ran successfully
[16:07] <Deckard111> still, postfix package did not fully install
[16:09] <blackboxsw> Deckard111: `debconf show postfix | grep mail`
[16:10] <blackboxsw> on my system with the pasted cloud-config from above I see this in logs
[16:10] <blackboxsw> 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] <Deckard111> I see:
[16:11] <Deckard111> 2021-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] <Deckard111> 2021-07-02 15:55:53,131 - cc_apt_configure.py[DEBUG]: debconf_selections was not set in config
[16:11] <Deckard111> 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] <blackboxsw> so you are missing the "set1:" key
[16:12] <blackboxsw> debconf_selections in not a string but a dict
[16:13] <Deckard111> ok,. thank you, will retry
[16:14] <blackboxsw> 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] <blackboxsw> 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] <Deckard111> ah, nice, good hint
[16:16] <blackboxsw> so it could give you hints if that config key is improper or others
[16:26] <Deckard111> Huh: cloudinit.config.schema.SchemaValidationError: Cloud config schema errors: apt: Additional properties are not allowed ('debconf-selections' was unexpected)
[16:33] <Deckard111> oh. it is debconf_selections 
[16:33] <Deckard111> doh
[16:43] <darkblueb> like man ssh_config  when all the others are  ssh-xyz
[16:44] <darkblueb> impressive eyeballs there blackboxsw, if I may say so
[16:44] <blackboxsw> woot woot! #achievementunlocked<sharpeyes>
[16:44] <darkblueb> :p
[16:45]  * blackboxsw ♥'s schema validation
[17:10] <Deckard111> 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] <Deckard111> so apt install still fails
[17:11] <blackboxsw> bah, ordering of pkg install vs selections
[17:11] <Deckard111> yeah, always wondered about the ordering thing
[17:12] <Deckard111> anyway to fix this unless I do the install 'manually' in the cmd section?
[17:13] <blackboxsw> checking the code now https://github.com/canonical/cloud-init/blob/main/cloudinit/config/cc_apt_configure.py 
[17:15] <blackboxsw> 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] <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:17] <blackboxsw> you can run `cloud-init analyze show` to see the order of config modules run on the last boot
[17:22] <blackboxsw> 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] <Deckard111> you are right, it runs in the same order
[17:25] <Deckard111> *correct order
[17:25] <blackboxsw> _roger
[17:27] <Deckard111> "debconf-show postfix | grep mail" shows:
[17:27] <Deckard111> debconf show postfix | grep mail
[17:28] <Deckard111>   postfix/mailname: 0
[17:28] <Deckard111> * postfix/main_mailer_type: 'No configuration'
[17:28] <Deckard111>   postfix/mailbox_limit: 0
[17:28] <Deckard111>   postfix/procmail: false
[17:28] <Deckard111> so apparently it is set
[17:29] <Deckard111> I think I need to explicelty set the system mail name, too
[17:29] <Deckard111> will try and test
[17:42] <Deckard111> blackboxsw I think I got it from here. Thank you very much for your time, patience and advice
[17:43] <Deckard111> awesome help!