If you must do this before anything else you could provide the value as a
command line extra variable to ansible-playbook

On Mon, 25 Oct 2021 at 07:00, Dhiwakar Ravikumar <
[email protected]> wrote:

> I'm trying to save the timestamp corresponding to when a playbook runs in
> a variable.
> I plan to use this variable across the playbook but I'm facing issues
> particularly since
>
> the lookup plugin runs and generates a new value each time.
>   module_defaults:
>     group/ns.col.session:
>       session_id: "{{ lookup('pipe','date \"+%Y-%m-%d-%H%M\"') }}"
>
> The value is looked up at the time that it is needed
>
> I could use set_fact: but it only works inside of the tasks: block and I'd
> like to set it to some value before any task can run i.e. right after hosts.
>
> - hosts:
>    - localhost
>
>   module_defaults:
>     group/ns.col.session:
>       session_id: .............
>
> How do I achieve this WITHOUT using set_fact OR without using the lookup()
> ?
> In other words, how to save or copy the value of a lookup to some variable
> ?
>
> Thanks
> Dhiwakar
>
> --
> 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/2a0329e7-541b-4f68-aa3e-5185b42d04efn%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/2a0329e7-541b-4f68-aa3e-5185b42d04efn%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/CAL8fbwPS4ZJsia2CF_sZmMrcWu%2BYjzSXvQ93jb-dWpqAByFFiw%40mail.gmail.com.

Reply via email to