I want to add a var of testing to my playbook, and when that var is set to 
true i want var1 to be used but if its nor set to true, i want it to use 
var2. Is this possible?

below is a non working example but  I hope it illustrates what i want it to 
do.
-----------------------------------------------------------------------------------

- name: Check logs and report to slack
  hosts: 
  become: yes
  remote_user: "{{ platform_user }}"

 * vars:*
*    testing: true*

  vars_files:
    - "../../vault/slack.yml"

  tasks:

    - name: check logs for step took
      shell: "some command"
      register: command_output

    - name: sucess notification message via Slack
      slack:
        token: *"{% if {{ testing }} == 'true' %}{{ slack_slacktesting }}{% 
else %}{{ slack_devops }}{% endif %}"*
        msg: "*{ command_output.stdout }}"
        channel: *"{% if {{ testing }} == 'true' %}#slacktesting{% else 
%}#devops{% endif %}"*
        username: 'Ansible'
        link_names: 0
        parse: 'full'
        color: 'good'
      delegate_to: localhost
      when: command_output_completed.stdout | search("COMPLETED")
      ignore_errors: yes

------------------------------------------------------------------------------------------------

Hope you can help or at least point me in the right direction.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/68efe8ab-05ab-45be-a2b4-0fd0e65d1737%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to