错误!加载 YAML 时出现语法错误。 AWX/Ansible

ERROR! Syntax Error while loading YAML. AWX/Ansible

我正在使用 AWX 并尝试运行这个任务:

- name: cleanup
  shell: awk '{ a[ OFS] = a[ OFS] ( a[ OFS] == "" ? "" : OFS)  }END{ for (i in a){print i,a[i]} } OFS="\t" latest.txt "{{ inventory_hostname }}".txt > ./output/"{{ inventory_hostname }}".txt

但是我收到这个错误:

> ERROR! Syntax Error while loading YAML.   did not find expected key
> The error appears to be in
> '/tmp/awx_8887_nv3efn13/project/Simsek/test/test.yml': line 141,
> column 60, but may be elsewhere in the file depending on the exact
> syntax problem. The offending line appears to be:
>     - name: cleanup
>       shell: "awk '{ a[ OFS] = a[ OFS] ( a[ OFS] == "" ? "" : OFS)  }END{ for (i in a){print i,a[i]} } OFS="\t" latest.txt "{{
> inventory_hostname }}".txt > ./output/"{{ inventory_hostname }}".txt"
>                                                            ^ here We could be wrong, but this one looks like it might be an issue with
> missing quotes. Always quote template expression brackets when they
> start a value. For instance:
>     with_items:
>       - {{ foo }} Should be written as:
>     with_items:
>       - "{{ foo }}"

试试这个:

awk '{ a[ OFS] = a[ OFS] ( a[ OFS] == "" ? "" : OFS)  }END{ for (i in a){print i,a[i]} } OFS="\t"' latest.txt {{ inventory_hostname }}.txt > ./output/{{ inventory_hostname }}.txt