Skip to content

Instantly share code, notes, and snippets.

@krdlab
Created November 4, 2022 11:22
Show Gist options
  • Save krdlab/5268a36508c6ebab9c59bae36eaf82ff to your computer and use it in GitHub Desktop.
Save krdlab/5268a36508c6ebab9c59bae36eaf82ff to your computer and use it in GitHub Desktop.
Ansible の when で not と default の組み合わせ
- hosts: localhost
connection: local
gather_facts: no
vars:
enabled: yes
tasks:
- debug:
msg: enabled!
when:
- "{{ enabled | default(false) }}"
- debug:
msg: not enabled!
when:
- "{{ not(enabled | default(false)) }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment