ansible Ansible: Loops and Conditionals What kinds of conditionals to use?


Example

Use Conditionals via (syntax is in [brackets]):

  • when [when:]

    Task:
       - name: run if operating system is debian
         command: echo "I am a Debian Computer"
         when: ansible_os_family == "Debian"
    
  • loops [with_items:]

  • loops [with_dicts:]

  • Custom Facts [ when: my_custom_facts == '1234']

  • Conditional imports

  • Select files and Templates based on variables