Skip to content

TemplateOverrides.trim_blocks must be <class 'bool'> instead of <class 'str'> #180

@hydrandt

Description

@hydrandt

When running borgbase.ansible_role_borgbackup (v1.1.2) with:

ansible [core 2.19.0b2]
  config file = /home/hydrandt/xxx/ansible/ansible.cfg
  configured module search path = ['/home/hydrandt/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/hydrandt/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.13.3 (main, Apr 10 2025, 21:38:51) [GCC 14.2.0] (/usr/bin/python3)
  jinja version = 3.1.6
  pyyaml version = 6.0.2 (with libyaml v0.2.5)

I get following error:

[ERROR]: Task failed: Syntax error in template: TemplateOverrides.trim_blocks must be <class 'bool'> instead of <class 'str'>                                    
                                                                                                                                                                 
Task failed.                                                                                                                                                     
Origin: /home/hydrandt/.ansible/roles/borgbase.ansible_role_borgbackup/tasks/05_configure.yml:12:7                                                               
                                                                                                                                                                 
10         group: "{{ borg_group }}"                                                                                                                             
11                                                                                                                                                               
12     - name: Add Borgmatic configuration                                                                                                                       
         ^ column 7                                                                                                                                              
                                                                                                                                                                 
<<< caused by >>>                                                                                                                                                                                                                                                                                                                 
Syntax error in template: TemplateOverrides.trim_blocks must be <class 'bool'> instead of <class 'str'>                                                          
Origin: /home/hydrandt/.ansible/roles/borgbase.ansible_role_borgbackup/templates/config.yaml.j2                                                                  
                                                                                                                                                                 
fatal: [xxx]: FAILED! => {"changed": false, "msg": "Task failed: Syntax error in template: TemplateOverrides.trim_blocks must be <class 'bool'> instead
 of <class 'str'>"} 

I resolved it by editing .ansible/roles/borgbase.ansible_role_borgbackup/tasks/05_configure.yml and removing the quotes around "True" on the first line:

#jinja2: lstrip_blocks: True, trim_blocks: True

I'll create a PR with the change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions