0

In the below block of an ansible playbook, what is the meaning of the | pipe operator followed by bool ?
I get what they mean separately, but here it does not seem to make any sense to me. Why would one need to interpret a bool as a mutli-line value ?

The pipe symbol at the end of a line in YAML signifies that any indented text that follows should be interpreted as a multi-line scalar value. See the YAML spec. https://stackoverflow.com/a/18708156/8325852

- name: Remove default nginx vhost config file (if configured).
  file:
    path: "{{ nginx_default_vhost_path }}"
    state: absent
  when: nginx_remove_default_vhost | bool
  notify: restart nginx
Lou
  • 148
  • 1
  • 12
  • You are confusing the pipe operator inside an ansible jinja2 expression to apply filters and the multiline yaml literal scalar block type indicator (see https://yaml-multiline.info/). In this later case it should be present right after a key defintion following the column. – Zeitounator Apr 26 '22 at 16:05

1 Answers1

1

It just force the type to bool.

here the docs about it https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#forcing-the-data-type

Mirco
  • 212
  • 3
  • 12