Use set_fact as the first task in the playbook. You disqualified that, but tbh I don't understand the reasoning behind that? Can you elaborate?
On Mon, 25 Oct 2021 at 10:02, Dhiwakar Ravikumar < [email protected]> wrote: > Thank you, so from that reply, I'm assuming there isn't any viable > alternative ? > > On Monday, October 25, 2021 at 1:11:24 PM UTC+5:30 [email protected] > wrote: > >> 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/a1294e55-8e2b-4ac4-a628-e6331ac454d8n%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/a1294e55-8e2b-4ac4-a628-e6331ac454d8n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- Dick Visser Trust & Identity Service Operations Manager GÉANT -- 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/CAL8fbwNDp%2B%2B82WyyJiDEzstnbF3eiPQKQgaLC6G9FvoncKwHTg%40mail.gmail.com.
