79274714

Date: 2024-12-12 10:30:06
Score: 0.5
Natty:
Report link

I did exactley the same thing as you have done @jeremywat, with two playbooks : one storing a variable with a cacheable=true set_fact and another playbook to read the variable and it works.

We have Ansible Automation Platform 2.5 (Automation Controller Version 4.6.3)

Reading the pseudo fact as a variable (first option) did work for us.

First playbook :

- name: "Playbook 1"
  hosts:
    - all
  tasks:
  - set_fact:
      sysops_var1: 'toto tutu tata'
      cacheable: true

Second playbook :

- name: "Playbook 2"
  hosts:
    - all
  tasks:
  - debug:
      msg: "AS A VAR : {{ sysops_var1 }}"

  - debug:
      msg: "AS A FACT : {{ ansible_facts }}"

After having run the first playbook, and then the second playbook (both with Enable Fact Storage: checked), both options are successful :

option 1 with var :

TASK [debug] *******************************************************************
task path: /runner/project/play3.yaml:8
ok: [localhost] => {
    "msg": "AS A VAR : toto tutu tata"
}

option 2 with with fact :

...
 "msg": "AS A FACT : {
...
 'lvm': 'N/A', 'sysops_var1': 'toto tutu tata', 'fips': False, 
...
Reasons:
  • Long answer (-1):
  • Has code block (-0.5):
  • User mentioned (1): @jeremywat
  • Low reputation (1):
Posted by: Bvoid