Is possible keep variable beetween roles?

this is an example that i want… in this task i set in a pretask the variable INSTALL_TIME: “{{ ansible_date_time }}”
i whant to use this variable in other role (Check_logs)

how can i do that?

  • name: ‘Deploy’
    hosts: APP
    pre_tasks:

  • set_fact:
    INSTALL_TIME: “{{ ansible_date_time }}”
    roles:

  • role: install_block

  • name: ‘[Global] Check Logs’

hosts: LOG
become: false
roles:

  • role: check_logs

That is not between roles as much as 'between plays', the variables
you use `set_fact` with are set PER HOST which means they DO survive
across plays.

But, since you target different hosts in the 2nd play you need to use
`hostvars[<a host in APP group>]['INSTALL_TIME']` to access it.