Ansible Conditionals

From NovaOrdis Knowledge Base
Revision as of 07:21, 5 July 2021 by Ovidiu (talk | contribs) (Created page with "=External= * https://docs.ansible.com/ansible/latest/user_guide/playbooks_conditionals.html =Internal= * Ansible Concepts =Overview= Tasks can be co...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

External

Internal

Overview

Tasks can be conditionally executed based on facts, registered variables or playbook or inventory variables. The conditional is introduced by the task configuration keyword when:.

- name: Download Amazon Corretto
  get_url:
    url: https://corretto.aws/downloads/latest/amazon-corretto-11-x64-macos-jdk.pkg
    dest: /tmp
  when: java_vendor == "Amazon"
- name: Install Nginx
    apt:
      pkg: nginx
      state: installed
      update_cache: true
    when: ppastable|success
    notify:
     - Start Nginx