Ansible Filter Casting

From NovaOrdis Knowledge Base
Revision as of 19:28, 5 July 2021 by Ovidiu (talk | contribs) (→‎Overview)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

External

Internal

Overview

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

Use Cases

Set As Boolean whether an Installation Happened of Not

brew_install_result is a variable registered by a Homebrew module and it has a brew_install_result.changed field that is set by the module execution. The value is "true" or "false". The code below cast that value to Boolean:

- name: Setting Update Fact
  set_fact:
    brew_formula_or_cask_updated: "{{ brew_install_result.changed | bool}}"