Skip to content

Instantly share code, notes, and snippets.

@diversemix
Created June 1, 2016 11:33
Show Gist options
  • Save diversemix/1e5f46f53754aa18a4ac71a0696dd36f to your computer and use it in GitHub Desktop.
Save diversemix/1e5f46f53754aa18a4ac71a0696dd36f to your computer and use it in GitHub Desktop.
Test to see if ansible version supports switching the handler based on var
---
- hosts: balancer
sudo: yes
serial: 1
vars:
switch: False
name_of_handler: "{{ 'call_this' if switch else 'call_that' }}"
handlers:
- name: call_this
command: echo Switch is on
- name: call_that
command: echo Switch is off
- name: not_set
command: echo Not been set!
tasks:
- name: Test
command: "echo Test {{name_of_handler}}"
notify: "{{name_of_handler}}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment