Hi Folks,
I’m new to ansible and I have got some confusion in when the statement
here is my playbook -
hosts: localhost
gather_facts: false
vars:
nodetype: “DI”
tasks:
- name: concatenate
set_fact:
argu: “DI=1,DC=0,DP=0”
when: “{{ nodetype }}” == “DI”
register: argu
set_fact:
argu: “DI=0,DC=1,DP=0”
when: “{{ nodetype }}” == “DC”
register: argu - debug:
msg: “{{ argu }}”
This is just defining variable “argu” based on when condition ,I want to just build variable based on the input nodetype . but this is not working and always it prints the second argu(DI=0,DC=1,DP=0) value
Is this the right way or simpler way to achieve this?