Posts

Showing posts with the label Fact

Ansible Date Variable

Answer : The command ansible localhost -m setup basically says "run the setup module against localhost", and the setup module gathers the facts that you see in the output. When you run the echo command these facts don't exist since the setup module wasn't run. A better method to testing things like this would be to use ansible-playbook to run a playbook that looks something like this: - hosts: localhost tasks: - debug: var=ansible_date_time - debug: msg="the current date is {{ ansible_date_time.date }}" Because this runs as a playbook facts for localhost are gathered before the tasks are run. The output of the above playbook will be something like this: PLAY [localhost] ************************************************** GATHERING FACTS *************************************************************** ok: [localhost] TASK: [debug var=ansible_date_time] ******************************************* ok: [localhost] => { "a...