Team,
У меня две задачи, одна - сохранить вне для регистрации переменной, а следующая проверяет, существуют ли в ней строки. но он вызывает ошибку synatx. Есть какие-нибудь подсказки?
Нужно ли мне устанавливать факт для этого? если да, то как?
- name: "Capture DiskCache enablement event via isc pod log"
command: kubectl logs -n isc-vdiskplugin "{{ item }}" vdisk | grep \"Disk Cache Enabled\"
delegate_to: localhost
become: false
register: isc_pod_log
with_items: "{{ isc_pod.stdout }}"
ignore_errors: no
tags: tag_post_dcro
- name: check variable registered
debug:
var: isc_pod_log.stdout
- name: Validate DiskCache is enabled from isc pod logs
when: "Disk Cache Enabled" in isc_pod_log.stdout
debug: msg="Disk Cache is Enabled"
ignore_errors: no
delegate_to: localhost
become: false
tags: tag_post_dcro
вывод:
[Pipeline] }
ERROR! Syntax Error while loading YAML.
expected <block end>, but found '<scalar>'
The error appears to be in '/ansible-managed/jenkins-slave/slave0/workspace/run_ansible_playbook/k8s/baremetal/roles/diskcache_prerequisites/tasks/main.yml': line 116, column 19, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: Validate DiskCache is enabled from isc pod logs
when: "Enabled" in isc_pod_log.stdout
^ here
This one looks easy to fix. It seems that there is a value started
with a quote, and the YAML parser is expecting to see the line ended
with the same kind of quote. For instance:
when: "ok" in result.stdout
Could be written as:
when: '"ok" in result.stdout'
Or equivalently:
when: "'ok' in result.stdout"
Цитирование целиком, когда
when: "'Disk Cache Enabled' in sci_pod_log.stdout"
может быть мой стандартный вывод является списком? я не могу найти
fatal: [node1]: FAILED! => {"msg": "The conditional check ''Disk Cache Enabled' in sci_pod_log.stdout' failed. The error was: error while evaluating conditional ('Disk Cache Enabled' in sci_pod_log.stdout): Unable to look up a name or access an attribute in template string ({% if 'Disk Cache Enabled' in sci_pod_log.stdout %} True {% else %} False {% endif %}).\nMake sure your variable name does not contain invalid characters like '-': argument of type 'AnsibleUndefined' is not iterable\n\nThe error appears to be in '/home/dtlu/code/disable-fscache/tasks/main.yml': line 28, 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: Validate DiskCache is enabled from csi pod logs\n ^ here\n"}