New paste Repaste Download
> podman run --name debian-bookworm -it --rm debian:bookworm
root@5f208e7062e4:/# apt update
Get:1 http://deb.debian.org/debian bookworm InRelease [151 kB]
Get:2 http://deb.debian.org/debian bookworm-updates InRelease [55.4 kB]
Get:3 http://deb.debian.org/debian-security bookworm-security InRelease [48.0 kB]
Get:4 http://deb.debian.org/debian bookworm/main amd64 Packages [8793 kB]
Get:5 http://deb.debian.org/debian bookworm-updates/main amd64 Packages [6924 B]
Get:6 http://deb.debian.org/debian-security bookworm-security/main amd64 Packages [274 kB]
Fetched 9329 kB in 1s (9260 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
root@5f208e7062e4:/# apt install ansible
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  ansible-core ca-certificates ieee-data krb5-locales libbsd0 libcbor0.8 libedit2 libexpat1
...
Setting up ansible (7.7.0+dfsg-3+deb12u1) ...
Processing triggers for libc-bin (2.36-9+deb12u10) ...
Processing triggers for ca-certificates (20230311+deb12u1) ...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
root@5f208e7062e4:/# cd $(mktemp -d)
root@5f208e7062e4:/tmp/tmp.hdaDLZqsNa# cat >playbook.yaml <<EOF
> - name: Sample playbook
  hosts: localhost
  tasks:
    - name: Debug print success
      ansible.builtin.debug:
        msg: "{{ template_data }}"
      vars:
        template_data: "{{ lookup('template', 'template.txt') }}"
        template_opts: "{{ sample_var['sample_key'] | default('sample_default') }}"
        sample_var:
          sample_key: "sample_value"
    - name: Debug print failure
      ansible.builtin.debug:
        msg: "{{ template_data }}"
      vars:
        template_data: "{{ lookup('template', 'template.txt') }}"
        template_opts: "{{ sample_var['sample_key2'] | default('sample_default') }}"
        sample_var:
          sample_key: "sample_value"
> EOF
root@5f208e7062e4:/tmp/tmp.hdaDLZqsNa# cat >template.txt <<EOF
> # Sample template
{{ template_opts }}
> EOF
root@5f208e7062e4:/tmp/tmp.hdaDLZqsNa# ansible-playbook playbook.yaml
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
PLAY [Sample playbook] ***********************************************************************************************************************************************************************************
TASK [Gathering Facts] ***********************************************************************************************************************************************************************************
ok: [localhost]
TASK [Debug print success] *******************************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": "# Sample template\nsample_value\n"
}
TASK [Debug print failure] *******************************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": "# Sample template\nsample_default\n"
}
PLAY RECAP ***********************************************************************************************************************************************************************************************
localhost                  : ok=3    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
Filename: debian-bookworm.txt. Size: 4kb. View raw, , hex, or download this file.
> podman run --name debian-trixie -it --rm debian:trixie
root@6e69c6fab585:/# apt update
Get:1 http://deb.debian.org/debian trixie InRelease [138 kB]
Get:2 http://deb.debian.org/debian trixie-updates InRelease [47.1 kB]
Get:3 http://deb.debian.org/debian-security trixie-security InRelease [43.4 kB]
Get:4 http://deb.debian.org/debian trixie/main amd64 Packages [9668 kB]
Get:5 http://deb.debian.org/debian trixie-updates/main amd64 Packages [2432 B]
Get:6 http://deb.debian.org/debian-security trixie-security/main amd64 Packages [8780 B]
Fetched 9907 kB in 1s (10.3 MB/s)
All packages are up to date.
root@6e69c6fab585:/# apt install ansible
Installing:
  ansible
...
Setting up ansible (12.0.0~a6+dfsg-1) ...
Processing triggers for libc-bin (2.41-12) ...
Processing triggers for ca-certificates (20250419) ...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
root@6e69c6fab585:/# cd $(mktemp -d)
root@6e69c6fab585:/tmp/tmp.i1gsojt4Qs# cat >playbook.yaml <<EOF
> - name: Sample playbook
  hosts: localhost
  tasks:
    - name: Debug print success
      ansible.builtin.debug:
        msg: "{{ template_data }}"
      vars:
        template_data: "{{ lookup('template', 'template.txt') }}"
        template_opts: "{{ sample_var['sample_key'] | default('sample_default') }}"
        sample_var:
          sample_key: "sample_value"
    - name: Debug print failure
      ansible.builtin.debug:
        msg: "{{ template_data }}"
      vars:
        template_data: "{{ lookup('template', 'template.txt') }}"
        template_opts: "{{ sample_var['sample_key2'] | default('sample_default') }}"
        sample_var:
          sample_key: "sample_value"
> EOF
root@6e69c6fab585:/tmp/tmp.i1gsojt4Qs# cat >template.txt <<EOF
> # Sample template
{{ template_opts }}
> EOF
root@6e69c6fab585:/tmp/tmp.i1gsojt4Qs# ansible-playbook playbook.yaml
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
PLAY [Sample playbook] ***********************************************************************************************************************************************************************************
TASK [Gathering Facts] ***********************************************************************************************************************************************************************************
ok: [localhost]
TASK [Debug print success] *******************************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": "# Sample template\nsample_value\n"
}
TASK [Debug print failure] *******************************************************************************************************************************************************************************
[ERROR]: Task failed: Finalization of task args for 'ansible.builtin.debug' failed: Error while resolving value for 'msg': The lookup plugin 'template' failed: object of type 'dict' has no attribute 'sample_key2'
Task failed.
Origin: /tmp/tmp.i1gsojt4Qs/playbook.yaml:13:7
11           sample_key: "sample_value"
12
13     - name: Debug print failure
         ^ column 7
<<< caused by >>>
Finalization of task args for 'ansible.builtin.debug' failed.
Origin: /tmp/tmp.i1gsojt4Qs/playbook.yaml:14:7
12
13     - name: Debug print failure
14       ansible.builtin.debug:
         ^ column 7
<<< caused by >>>
Error while resolving value for 'msg'.
Origin: /tmp/tmp.i1gsojt4Qs/playbook.yaml:15:14
13     - name: Debug print failure
14       ansible.builtin.debug:
15         msg: "{{ template_data }}"
                ^ column 14
<<< caused by >>>
The lookup plugin 'template' failed.
Origin: /tmp/tmp.i1gsojt4Qs/playbook.yaml:17:24
15         msg: "{{ template_data }}"
16       vars:
17         template_data: "{{ lookup('template', 'template.txt') }}"
                          ^ column 24
<<< caused by >>>
object of type 'dict' has no attribute 'sample_key2'
Origin: /tmp/tmp.i1gsojt4Qs/playbook.yaml:18:24
16       vars:
17         template_data: "{{ lookup('template', 'template.txt') }}"
18         template_opts: "{{ sample_var['sample_key2'] | default('sample_default') }}"
                          ^ column 24
fatal: [localhost]: FAILED! => {"msg": "Task failed: Finalization of task args for 'ansible.builtin.debug' failed: Error while resolving value for 'msg': The lookup plugin 'template' failed: object of type 'dict' has no attribute 'sample_key2'"}
PLAY RECAP ***********************************************************************************************************************************************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0
Filename: debian-trixie.txt. Size: 5kb. View raw, , hex, or download this file.

This paste expires on 2025-09-14 16:20:47.262086. Pasted through web.