Skip to content

Commit 5bf9a58

Browse files
committed
Add string filters to template lookups in cloud-init base template
Added | string filters to lookup() calls in the cloud-init base template to ensure consistent string handling across all cloud providers. The Vultr startup_script module requires all values to be JSON-serializable strings, and lookup() can return bytes in some contexts. This change ensures that both the SSH config template lookup and the SSH public key file lookup explicitly return strings. This is a defensive fix that improves compatibility with strict JSON serialization requirements in some Ansible modules, while remaining backward compatible with existing cloud providers. Related to: vultr.cloud.startup_script JSON serialization requirements
1 parent ec5c459 commit 5bf9a58

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

files/cloud-init/base.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ users:
3030
shell: /bin/bash
3131
lock_passwd: true
3232
ssh_authorized_keys:
33-
- "{{ lookup('file', SSH_keys.public) }}"
33+
- "{{ lookup('file', SSH_keys.public) | string }}"
3434

3535
write_files:
3636
- path: /etc/ssh/sshd_config
3737
content: |
38-
{{ lookup('template', 'files/cloud-init/sshd_config') | indent(width=6, first=True) }}
38+
{{ lookup('template', 'files/cloud-init/sshd_config') | string | indent(width=6, first=True) }}
3939

4040
runcmd:
4141
- set -x

0 commit comments

Comments
 (0)