Tutorial by Examples

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 [ wh...
Common use when: ansible_os_family == "CentOS" when: ansible_os_family == "Redhat" when: ansible_os_family == "Darwin" when: ansible_os_family == "Debian" when: ansible_os_family == "Windows" All Lists based on discuss here http://comments...
Basic Usage Use the when condition to control whether a task or role runs or is skipped. This is normally used to change play behavior based on facts from the destination system. Consider this playbook: - hosts: all tasks: - include: Ubuntu.yml when: ansible_os_family == "Ubunt...
We can get facts (ansible_os_family, ansible_pkg_mgr) with Ad-Hoc command of setup module and filter. ansible_os_family: $ ansible all -m setup -a 'filter=ansible_os_family' ra.local | SUCCESS => { "ansible_facts": { "ansible_os_family": "Debi...
Given: --- variable_name: True Then, these tasks with always run. - name: This is a conditional task module: src=/example/ dest=/example when: variable_name - name: This is a conditional task module: src=/example/ dest=/example when: True This task will never run. - name: T...
This is an example of using until/retries/delay to implement an alive check for a webapp that is starting up. It assumes that there will be some period of time (up to 3 minutes) where the webapp is refusing socket connections. After that, it checks the /alive page for the word "OK". It als...

Page 1 of 1