Hi,

Yes, i run them against the same host. But both these playbooks are 
executed separately.

Regards,
Vikram

On Monday, 21 June, 2021 at 10:57:01 pm UTC+5:30 [email protected] wrote:

> Are these plays run against the same host?
>
> On Mon, 21 Jun 2021 at 19:09, Vikram S <[email protected]> wrote:
>
>> Ansible documentation for set_fact module says "Set cacheable to yes to 
>> save variables across executions using a fact cache". So my understanding 
>> is that setting 'cacheable: yes' would make the contents of custom variable 
>> available across differnt playbooks (as opposed to default behaviour of 
>> custom variable output being available only for current playbook).
>>
>> However when i tried to use a custom variable saved in 1 playbook in 
>> another playbook, it didn't work. So i wonder if my understanding is 
>> correct? Below is playbook:
>>
>>
>> *PLAYBOOK 1:* I define a custom variable called 'my_name' and save it in 
>> fact cache using cacheable: yes
>>
>> tasks:
>>
>>     - name: GATHER INTERFACE INFO
>>
>>       ios_command:
>>
>>         commands: "show ip int brief"
>>
>>
>>       register: show_ip
>>
>>
>>     - set_fact:
>>
>>         my_name: "{{ show_ip }}"
>>
>>         cacheable: yes
>>
>>
>> *PLAYBOOK 2:* I reference earlier custom variable in 2nd playbook for 
>> comparison but doesn't work.
>>
>>  tasks: 
>>
>>      - name: GATHER INTERFACE INFO AFTER RELOAD
>>
>>       ios_command:
>>
>>         commands: "show ip int brief"
>>
>>
>>       register: show_ip_new
>>
>>
>>     - assert:
>>
>>         that:
>>
>>         - show_ip.stdout[0] | regex_findall('up') | length == 
>> show_ip_new.stdout[0] | regex_findall('up') | length
>>
>>         fail_msg: "THERE IS INTERFACE MISMATCH. PLAYBOOK IS ENDING FOR 
>> CURRENT HOST."
>>
>>         success_msg: "INTERFACE STATUS MATCHED"
>>
>> Thanks,
>> Vikram
>>
>> -- 
>> 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 view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/14fc7b95-754f-4ca4-a85f-a7ff1978b79an%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/14fc7b95-754f-4ca4-a85f-a7ff1978b79an%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> -- 
> Sent from a mobile device - please excuse the brevity, spelling and 
> punctuation.
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/769eef9e-a947-45da-9f6a-b61709dbab25n%40googlegroups.com.

Reply via email to