/srv/irclogs.ubuntu.com/2020/11/11/#cloud-init.txt

amansi26Hi, just a general query: If we use manage_etc_host: true in cloud.cfg . It will add hostname mapped with localhost like http://paste.openstack.org/show/799923/ in /etc/hosts. Which make sense if we do with private NIC deployment, it helps to ping the hostname from that very same system. But in case of public NIC deployment, if we map a fqdn with localhost, that's not correct . Right?  Ideally in case of Public NIC hostname should be mapped with15:29
amansi26IPv4/IPv6 IP assigned to the system15:29
amansi26Generally how are we handling this condition?15:30
meenawho's idea was hirsute??15:52
muhahaguys? how can i get metadata public ip from azure datasource in cloud-init ?17:05
amansi26smoser: blackboxsw: Odd_Bloke: Can you help me with the above query?17:08
muhahahow to query variable from datasource ?17:15
blackboxswamansi26: muhaha was just looking that up to see if it is exposed by the cached Azure datasource. Unfortunately it is not preserved.17:16
blackboxswthe only way to get that for azure is python3 -c "from cloudinit.sources.DataSourceAzure import IMDS_URL; print(IMDS_URL)"17:16
blackboxswon AWS instances, cloud-init does preserve the metadata version queried  under the key "_metadata_api_version"17:17
muhahablackboxsw: I just want to pass ip address to config file in write_files section17:17
amansi26blackboxsw: I think there is a bit confusion. muhaha and my query are different I guess17:18
amansi26My  query: If we use manage_etc_host: true in cloud.cfg . It will add hostname mapped with localhost like http://paste.openstack.org/show/799923/ in /etc/hosts. Which make sense if we do with private NIC deployment, it helps to ping the hostname from that very same system. But in case of public NIC deployment, if we map a fqdn with localhost, that's not correct . Right?  Ideally in case of Public NIC hostname should be mapped with IPv4/IPv6 IP17:19
amansi26assigned to the system. Generally how are we handling this condition?17:19
blackboxswI'd like to see all datasources grow and present that information so you could run `cloud-init query ds._meta_data_api_version`17:19
blackboxswmuhaha, so to query the datasource specifically you could run  sudo python3 -c 'from cloudinit.stages import _pkl_load; ds = _pkl_load("/var/lib/cloud/instance/obj.pkl"); dir(ds)'17:20
blackboxswor alternately (some metadata in formation is saved in /run/cloud-init/instance-data.json which can be queried with 'cloud-init query ds'17:21
blackboxswamansi26: checking your question now17:21
muhahawhat is difference between querying this data via curl like IP=$(curl -s -H Metadata:true --noproxy "*" "http://169.254.169.254/metadata/instance/network/interface/0/ipv4/ipAddress/0/privateIpAddress?api-version=2017-08-01&format=text") , and using  /run/cloud-init/instance-data.json file ?17:22
muhahai am cloud-init newbie17:23
blackboxswmuhaha: instance-data.json  is seeded by what cloud-init consumes on the instance. specifcally if you look in /var/log/cloud-init.log you can see that on Azure cloud-init read from "Read from http://169.254.169.254/metadata/instance?api-version=2017-12-01"17:24
blackboxswso your version you curled will be different as17:24
blackboxswthe version you specified was 2017-08-0117:25
amansi26blackboxsw: Just an additional data. /etc/hosts data for private nic deployed VM: http://paste.openstack.org/show/799931/17:25
blackboxswmuhaha: cloud-init only preserves what it had read, so you may have data missing if you rely on other metadata routes besides http://169.254.169.254/metadata/instance or different api versions than 2017-12-0117:26
muhahablackboxsw: I see, can you please point me, how to replace $IP in https://pastebin.com/raw/tBC6R3Rb to be able to resolve this variable as actuall ip address of instance ?17:27
blackboxswthx for the paste amansi26 looking17:27
blackboxswugh muhaha, Azure needs to better surface public ips under instance-data.json 'v1' key heading. if you feel like filing a bug requesting instance-metadata v1.public_ip athttps://bugs.launchpad.net/cloud-init/+filebug I'd happily +1 that feature request17:31
blackboxswmuhaha: as it is. here's what your user-data would need.17:31
blackboxsw1. add this line before the #cloud-config   "## template: jinja" 2. replace $IP with {{ds.meta_data.imds.network.interface[0].ipv4.ipAddress[0].publicIpAddress}}17:34
blackboxswmuhaha: how to use jinja templates to render instance-data: https://cloudinit.readthedocs.io/en/latest/topics/instancedata.html#using-instance-data17:35
blackboxswto find out what types are instance-data vars are available: `cloud-init query --all`17:36
muhahablackboxsw thanks ! I will try asap. One more question, as a newbie.. , if I want to change file content in write_files, how should I (re)provisioning it ?  This cloud-init will run on every boot and if I want to manually reprovisioning it, do I need to run some cloud-init --rerun command? thanks17:39
blackboxswhrm amansi26, so are you saying public fqdn is being listed alongside 127.0.0.1 on the host system?17:40
amansi26yes, blackboxsw. public fqdn is mapping with 127.0.0.117:42
blackboxswmuhaha: if you are testing out new cloud-config and want to re-run write-files, typically the cloud platform would change the instance-id it exposes to indicate to cloud-init that it should re-run any config modules that are run PER_INSTANCE, which is what cc_write_files is set to run as https://github.com/canonical/cloud-init/blob/master/cloudinit/config/cc_write_files.py#L2017:43
blackboxswmuhaha: if you are manually developing, changing user-data on a system ;sudo cloud-init clean --logs --reboot' will rerun cloud-init on your system as if it were completely fresh17:44
blackboxswamansi26: hrm wouldn't you want to hit the local IP address 127.0.0.1 to avoid the "external" roundtrip to the public IP?17:46
blackboxswI guess that would block anything if iptables were setup uniquely for public fqdn ip address handling. hrm. I'm not sure honestly if that is *not* desired behavior17:47
amansi26blackboxsw: Thanks. I raised this query bcz it was not making any sense to me to map public ip hostname( which is already pingable ) with localhost . Anyone else has some comment on this?17:52
amansi26It is like pinging loopback17:54
muhahablackboxsw: thanks ! its working !17:55
blackboxswgood to hear muhaha17:56
blackboxswamansi26: yes definitely I think someone else more knowledgeable than me whether the fqdn should *not*  be listed linked  to 127.0.0.1. That said, this config setting has been in cloud-init since pre 2013. So I would've thought a concern like this would have come up before now.18:20
=== ijohnson is now known as ijohnson|lunch
=== dionysus70 is now known as dionysus69
=== ijohnson|lunch is now known as ijohnson
split-brainhi there, can i ask about this bug/feature, please? i'm trying to get cloud-init to handle secondary ip for my aws ec2 instance in vpc. i found that it should be working now, but after i've upraded to the last version, still there is no secondary ipv4 configured. running centos 8, cloud-init 20.3+603.gca266d38-1.el8.21:04
split-brainhttps://github.com/canonical/cloud-init/pull/11421:04
=== vrubiolo1 is now known as vrubiolo
=== dionysus70 is now known as dionysus69

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