On 24.07.2017 12:09, JS wrote:
> Hello
>
> I am trying to gather facts (date and time) on the local machine
> (Ansible
> Host) using (local_action) before the rest of the playbook continues:
>
> - name: Gathering and setting Facts for this deploy
> local_action:
> set_fact:
> date_time: '{{ ansible_date_time.date }}_{{
> ansible_date_time.time }}'
>
The correct syntax is
- name: Gathering and setting Facts for this deploy
local_action:
module: set_fact
date_time: '{{ ansible_date_time.date }}_{{ ansible_date_time.time
}}'
But this will not do what you are trying to do.
Since lookup is executed on the localhost you can use this task instead.
- name: Gathering and setting Facts for this deploy
set_fact:
date_time: '{{ lookup('pipe', 'date') }}'
With this task every host will have the variable date_time set to the
time of the Ansible control machine.
--
Kai Stian Olstad