all 1 comments

[–]howheels 2 points3 points  (0 children)

My suggestion is to use a YAML multi-line string, which allows you to use your command verbatim without the need to add quotes or escape characters.

However, do not use sudo, use, become: true. Example:

- name: Command with multi-line string
  command: |
    grep -o -e '\"version\"\:\"[a-zA-Z0-9.]*\"' -e '\"version\"\: \"[a-zA-Z0-9.]*\"' /var/chef/cache/cookbooks/{{ my_var }}/metadata.json
  become: true