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
--
You received this message because you are subscribed to the Google Groups "Ansible
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/f8cd200b30c9c151602d61a9fd780f0e%40olstad.com.
For more options, visit https://groups.google.com/d/optout.