我正在尝试在 ansible 中运行代码,但出现错误!如何解决?
剧本
---
- name: "Проверяем свободное место"
shell: "df / --output=avail|tail -1"
register: avail_size
- set_fact:
free_fs_size: "{{ avail_size.stdout|int }}"
- name: "Запускаем создание резервной копиии средствами php"
shell: '{{ make_backup }}'
register: result
when: "{{ free_fs_size > 10 }}"
failed_when: "'The backup was incorrect and it was deleted' in result.stdout_lines"
- set_fact:
backup_path: "{{result.stdout_lines | regex_search(regexp, '\\2')}}"
vars:
regexp: '(Backup started to file: )(.*)"'
错误
[WARNING]: conditional statements should not include jinja2 templating delimiters such as {{ }} or {% %}. Found: {{ free_fs_size > 10 }}
fatal: [host.dev.domain.ru]: FAILED! => {"msg": "The conditional check '{{ free_fs_size > 10 }}' failed. The error was: Unexpected templating type error occurred on ({{ free_fs_size > 10 }}): '>' not supported between instances of 'AnsibleUnsafeText' and 'int'\n\nThe error appears to be in '/opt/ansible/roles/backup_bitrix/tasks/main.yml': line 9, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: \"Запускаем создание резервной копиии средствами php\"\n ^ here\n"}```