Anton on Nostr: Fun with Ansible. `defaults/main.yml`: docker_mtu: "{{ ansible_default_ipv6.mtu | ...
Fun with Ansible.
`defaults/main.yml`:
docker_mtu: "{{ ansible_default_ipv6.mtu | default(1450) | int }}"
To use this variable in another default variable, it always ends up as a string. Which the docker daemon does not really like.
Result? Let python/jinja2 handle it in the template:
{{ dict(docker_daemon_config, **{"mtu": docker_mtu|int }) | to_nice_json }}
Does someone have a better solution so the MTU is actually written out as an integer?
#ansible #jinja2 #python
Published at
2024-06-21 15:22:57Event JSON
{
"id": "98cbf95cde862eda373f562ecdc31417403e121c99b976a25a262261f4b4e351",
"pubkey": "54e636a1b5d2c651aae849c7c54d57f8706feb64fc131bfc419f752fc4037f98",
"created_at": 1718983377,
"kind": 1,
"tags": [
[
"t",
"ansible"
],
[
"t",
"jinja2"
],
[
"t",
"python"
],
[
"proxy",
"https://mastodon.social/users/antondollmaier/statuses/112655294605124368",
"activitypub"
]
],
"content": "Fun with Ansible.\n`defaults/main.yml`:\ndocker_mtu: \"{{ ansible_default_ipv6.mtu | default(1450) | int }}\"\n\nTo use this variable in another default variable, it always ends up as a string. Which the docker daemon does not really like.\n\nResult? Let python/jinja2 handle it in the template:\n\n{{ dict(docker_daemon_config, **{\"mtu\": docker_mtu|int }) | to_nice_json }}\n\nDoes someone have a better solution so the MTU is actually written out as an integer?\n\n#ansible #jinja2 #python",
"sig": "fa52c3c8c1f7010fe043a30142a88b174bace77d8e4c5289b0bd245c3c9e3f28a6f53b5dbefe795d3d14cc21a7e4d07d51ff5cae0df756db0d6c48f452cfee49"
}