What causes facts to become unavailable within a playbook? I'm trying to access Ansible's ansible_date_time
fact, but I can't seem to figure out how to access it. Following Ansible date variable, it should simply be available in a playbook such as:
---
# test.yml
- hosts: localhost
tasks:
- debug: var=ansible_date_time
Which when run as:
ansible-playbook test.yml
Should produce the output:
PLAY [localhost] **************************************************
GATHERING FACTS ***************************************************************
ok: [localhost]
TASK: [debug var=ansible_date_time] *******************************************
ok: [localhost] => {
"ansible_date_time": {
"date": "2015-07-09",
"day": "09",
"epoch": "1436461166",
"hour": "16",
"iso8601": "2015-07-09T16:59:26Z",
"iso8601_micro": "2015-07-09T16:59:26.896629Z",
"minute": "59",
"month": "07",
"second": "26",
"time": "16:59:26",
"tz": "UTC",
"tz_offset": "+0000",
"weekday": "Thursday",
"year": "2015"
}
}
PLAY RECAP ********************************************************************
localhost : ok=2 changed=0 unreachable=0 failed=0
However when I run the playbook, I receive:
PLAY [localhost] **************************************************************
TASK: [debug var=ansible_date_time] *******************************************
ok: [localhost] => {
"var": {
"ansible_date_time": "ansible_date_time"
}
}
PLAY RECAP ********************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0
What would cause ansible_date_time
to be unavailable?
Update: The contents of /etc/ansible/ansible.cfg
is:
[defaults]
sudo_user=root
gathering=explicit