動機

有2種辦法

  1. yq + trim

有點偏bash流

- name: Read yaml
  shell: "cat values.yaml | yq e -o=j '.tag' -"
  register: tag
- name: Parse tag
  set_fact:
    tag: "{{ tag.stdout | trim }}"
  1. from_yaml
- name: Read yaml
  shell: "cat values.yaml"
  register: tag
- name: Parse tag
  set_fact:
    tag: "{{ (tag.stdout | from_yaml)['tag'] }}"