Hi list, I'm working with cloud-init and I'm trying to update the /etc/hosts file via cloud-init (currently version 0.7.8 on openSUSE Leap 42.1). I know there are plenty workarounds, but as there is a module for that, I would like to use it. So I added a line in the respective template file: ---cut here--- leap1:~ # cat /etc/cloud/templates/hosts.suse.tmpl ## template:jinja [...] # The following lines are desirable for IPv4 capable hosts {{ fqdn }} {{ hostname }} 127.0.0.1 localhost set-hostname:~ # cat /etc/hosts # Your system has configured 'manage_etc_hosts' as True. # As a result, if you wish for changes to this file to persist # then you will need to either # a.) make changes to the master file in /etc/cloud/templates/hosts.suse.tmpl # b.) change or remove the value of 'manage_etc_hosts' in # /etc/cloud/cloud.cfg or cloud-config from user-data # # The following lines are desirable for IPv4 capable hosts leap1.novalocal leap1 127.0.0.1 localhost ---cut here--- This works fine, the file is updated successfully. Only it's missing the ip address, which is mandatory to make a command like "hostname -f" work without network access. But every string I have tried (e.g. "local-ipv4" from meta-data) led to an error: [...] reraise(exc_type, exc_value, tb)#012 File "<template>", line 15, in top-level template code#012TypeError: unsupported operand type(s) for -: 'StrictUndefined' and 'StrictUndefined' 2016-11-14 15:19:03,184 - main.py[WARNING]: Ran update_etc_hosts but it failed! So I searched the web and found [1], I'm not the first one who tries to use that function. Scott Moser posted a fix in 2013 [2] but it seems that it never got merged. I applied his changes and tested it successfully, is there any chance this will get to upstream? This is really useful to us. Regards, Eugen [1] https://bugs.launchpad.net/cloud-init/+bug/1020695 [2] https://code.launchpad.net/~smoser/cloud-init/lp1020695/+merge/163216 -- Eugen Block voice : +49-40-559 51 75 NDE Netzdesign und -entwicklung AG fax : +49-40-559 51 77 Postfach 61 03 15 D-22423 Hamburg e-mail : eblock@nde.ag Vorsitzende des Aufsichtsrates: Angelika Mozdzen Sitz und Registergericht: Hamburg, HRB 90934 Vorstand: Jens-U. Mozdzen USt-IdNr. DE 814 013 983 -- To unsubscribe, e-mail: opensuse-cloud+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-cloud+owner@opensuse.org