indent: "The filter plugin 'ansible.builtin.indent' failed: unsupported operand type(s)"

未关闭 适合新手
#2,862 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
ansible, python
领域
devops

调研方向

从 debops/roles/fail2ban/templates/etc/fail2ban/jail.local.d/default.local.j2 开始,检查用于默认操作和自定义操作的两个 indent 过滤器。使用 Ansible core 2.19 重现报告的问题,然后检查模板是否正确处理操作值。两份操作列表都能在没有报告的类型错误的情况下渲染模板,即为完成。

由索引模型根据 Issue 内容生成。

描述

With Debops 3.4.1 and Ansible core 2.19.11 on Debian Trixie, I get the following error:

[ERROR]: Task failed: The filter plugin 'ansible.builtin.indent' failed: unsupported operand type(s) for +=: '_AnsibleTaggedInt' and 'str'

Task failed.
Origin: /home/mathieu/dev/ansible/.collections/ansible_collections/debops/debops/roles/fail2ban/tasks/main.yml:123:3

121     mode: '0755'
122
123 - name: Configure jail default variables
      ^ column 3

<<< caused by >>>

The filter plugin 'ansible.builtin.indent' failed: unsupported operand type(s) for +=: '_AnsibleTaggedInt' and 'str'
Origin: /home/mathieu/dev/ansible/.collections/ansible_collections/debops/debops/roles/fail2ban/templates/etc/fail2ban/jail.local.d/default.local.j2

fatal: [template-ubuntu-2604]: FAILED! => {"changed": false, "msg": "Task failed: The filter plugin 'ansible.builtin.indent' failed: unsupported operand type(s) for +=: '_AnsibleTaggedInt' an
d 'str'"}

I had to modify debops/roles/fail2ban/templates/etc/fail2ban/jail.local.d/default.local.j2:

@@ -30,13 +30,13 @@ position       = {{ fail2ban_position }}

 {% if fail2ban_default_actions is defined and fail2ban_default_actions %}
 {% for name, commands in fail2ban_default_actions.items() %}
-{{ "%-14s" | format(name) }} = {{ commands | indent(17) }}
+{{ "%-14s" | format(name) }} = {{ commands | string | ansible.builtin.indent(width=17) }}

 {% endfor %}
 {% endif %}
 {% if fail2ban_custom_actions is defined and fail2ban_custom_actions %}
 {% for name, commands in fail2ban_custom_actions.items() %}
-{{ "%-14s" | format(name) }} = {{ commands | indent(17) }}
+{{ "%-14s" | format(name) }} = {{ commands | string | ansible.builtin.indent(width=17) }}

 {% endfor %}
 {% endif %}
主要语言
Python
星标
1.4k
派生
374
平均合并
2 天 22 小时
30 天内合并 PR
47

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

debops/debops 的其他 Issue

查看 debops/debops 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。