On 03.05.2017 13:56, kiran sangeetam wrote:
> I want to use variable that I defined in set_fact task in template. But
> it's not working. Can anyone please suggest if I'm doing anything
> wrong.
>
> Below is the syntax I am using in tasks file.
>
> - name: Setting fact for logfile
> set_fact: log_file_path="/home/log.txt" include_path="true"
> when: "'job' in inventory_hostname"
Since you haven't explained what you are trying to do some guessing is
required.
Your when will only trigger if the inventory_hostname is "job".
So for all the other hosts this fact is not set.
The in clause is normally used to find an element in a dictonary,
inventory_hostname is a string.
I guess you are looking for .find as shown in this example
https://docs.ansible.com/ansible/playbooks_conditionals.html#register-variables
--
Kai Stian Olstad