[19:59] had an issue today trying to understand: ami amazon/amzn2-ami-minimal-hvm-2.0.20220207.1-x86_64-ebs cloud init ran a user data script as expected, with a newer ami amzn2-ami-minimal-hvm-2.0.20220218.0-x86_64-ebs it did not work - I found a cat /var/lib/cloud/instance/user-data.txt.i which looked like: [19:59] Content-Type: multipart/mixed; boundary="===============2079083206506282502==" [19:59] MIME-Version: 1.0 [19:59] Number-Attachments: 1 [19:59] Number-Attachments: 1 [19:59] --===============2079083206506282502== [19:59] MIME-Version: 1.0 [19:59] Content-Type: text/x-not-multipart [19:59] Content-Disposition: attachment; filename="part-001" [19:59] --===============2079083206506282502==-- [20:00] any ideas? [20:09] ? === paride1 is now known as paride === meena9 is now known as meena === falcojr9 is now known as falcojr === bahamat_ is now known as bahamat [22:52] hello all. I just started using cloud-init through terraform for Azure. In poc mode right now and passing 64bitencoded shell file with template: jinja declaration. I can get basic jinja working but when trying to us the jinja 'do' statement I'm getting python stack trace. TemplateSyntaxError: Encountered unknown tag 'do'. Jinja was looking for the [22:52] following tags: 'endfor' or 'else'. The innermost block that needs to be closed is 'for'.  The do statement is nested within a for statement like so.......{% set private_ips = [] %} {% for i in ds.meta_data.imds.network.interface[0].ipv4 %}   {% do private_ips.append(i.privateIpAddress) %} {% endfor %} [22:54] Is this possible in user-data processing? [22:55] toolsmith: can you paste the "fullish" user-data to paste.ubuntu.com or https://paste.opendev.org/ ? [22:57] blackboxsw pasted, Paste #b9ydAg0GtZV8GRWvc5Vp [23:01] toolsmith: thanks. trying to peek at it now and execise in a LXD. we should be able to iterate on this a bit locally using cloud-init cmdline of your azure instance with something like the following `sudo cloud-init query --format '{% ... your template syntax %}' . I'm playing with something like your example now [23:02] ok, i'll see about running the cli tool on my instance as well [23:02] for instance we can easily just construct a simple for loop and render the content of a list w/ `cloud-init query --format "{% set private_ips = [1, 2, 3] %} {% for i in private_ips %} {{ i }} {% endfor %}"` [23:03] yeah, it's the 'do' statement that is not being honored it seems. [23:03] but yeah, I'm trying to understand your 'do' operations. I think we don't need/want the "do" but I'm checking [23:04] My experience with jinja has been mostly with Saltstack and this is something I did in salt states all the time, so i figured i see if it's possible in cloud-init. [23:05] A pattern i use is 1. set empty array var 2. iterate some runtime data 3. append to the array 4. dump the array to a file or process some more. [23:06] At least that is how I had to do it within Saltstack states [23:11] this seems to work for me to extend the list iteself, but it still emits the None return value for each iteration in the loop. cloud-init query --format "{% set private_ips = [1, 2, 3] %} {% for i in private_ips %} {{ i }} {% endfor %}" [23:11] wrong paste. sorry [23:12] here: cloud-init query --format "{% set private_ips = [] %} {% for i in [1, 2, 3] %} {{ private_ips.append(i) }} {% endfor %} {{private_ips }}" [23:13] for some reason if I just use {% private_ips.append(i) %} around the operation we'll get that "Encountered unknown tag 'private_ips'... expected "endfor" etc [23:15] yup, i get the same. [23:15] Thanks for the tip on cli query too ;-), that will save me time [23:19] could mangle it a bit more with a jinja default() like so: cloud-init query --format "{% set private_ips = [] %} {% for i in [1, 2, 3] %} {{ private_ips.append(i) }} {% endfor %} {{private_ips }}" [23:20] anyhow I'm going to have to head out here, sorry just lobbing weak suggestions your way [23:20] cloud-init query --format "{% set private_ips = [] %} {% for i in [1, 2, 3] %}{{ private_ips.append(i)|default('', True)}}{% endfor %} {{private_ips }}" [23:21] no problem. thanks for helping out.