Skip to content

cephclient: drop the template nested in a string - #337

Draft
ideaship wants to merge 1 commit into
mainfrom
cephclient-keyring-inline
Draft

ideaship wants to merge 1 commit into
mainfrom
cephclient-keyring-inline

Conversation

@ideaship

Copy link
Copy Markdown
Contributor

cephclient_keyring names the configuration directory as a template inside a string literal of the outer template:

lookup('file', '{{ configuration_directory }}/environments/...')

ansible-core 2.19 and later warn on every use of it:

[WARNING]: Jinja constant strings should not contain embedded templates. This feature will be disabled by default in ansible-core 2.23.
Origin: /ansible/inventory/fast/group_vars/all/099-infrastructure.yml:6:21

This builds the path by concatenation instead: lookup('file', configuration_directory ~ '/environments/...').

Testing

A playbook defining both forms, run in the osism-ansible 0.20261111.0 image and in images derived from it that only replace ansible-core:

ansible-core keyring file present keyring file missing
2.18.18 identical content (trailing newline kept) both forms fail the same way
2.19.15 identical content; warning only from the old form —
2.20.10 identical content; warning only from the old form both forms fail the same way

default('', true) does not catch a failing file lookup with either form; this change leaves that as it is.

The warning was seen on an OSISM 11.0.3 deploy with an osism-ansible image on ansible-core 2.20.10, in the osism.services.cephclient tasks. Released osism-ansible images run ansible-core 2.18, which does not warn.

Other occurrences

Scanning the YAML and Jinja sources of the OSISM Ansible repositories (defaults, generics, cfg-cookiecutter, ansible-playbooks, and the collections and container images that carry plays) with Jinja's lexer for string literals that contain a template found this as the only case. The one other hit, {{ '{{.Image}}' }} in the manager role's check-service-manager-versions.sh.j2, is meant to emit a literal Docker format string. On the 2.20 deploy, this variable was the only source of the warning.

🤖 Generated with Claude Code

cephclient_keyring named the configuration directory as a template
inside a string literal of the outer template:

  lookup('file', '{{ configuration_directory }}/environments/...')

ansible-core 2.19 and later warn on every use of it:

  Jinja constant strings should not contain embedded templates. This
  feature will be disabled by default in ansible-core 2.23.

On a deploy of OSISM 11.0.3 with an osism-ansible image on ansible-core
2.20.10 the warning came from the osism.services.cephclient tasks, with
its origin at all/099-infrastructure.yml:6.

Build the path by concatenation instead:

  lookup('file', configuration_directory ~ '/environments/...')

A playbook defining both forms against a test keyring file gets
identical content, trailing newline included, on ansible-core 2.18.18,
2.19.15 and 2.20.10, and the new form causes no warning. With the
keyring file missing, both forms fail the same way on 2.18.18 and
2.20.10: default('', true) does not catch a failing file lookup, and
this change leaves that as it is.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Roger Luethi <luethi@osism.tech>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

1 participant