FreeKB - ansible_date_time variable
Ansible - ansible_date_time variable

This assumes you have installed Ansible and are familiar with the ansible-playbook command and have created a playbook.

ansible_date_time is a built in variable that returns date/time. In this example, a date in the format of yyyy-mm-dd will be returned.

- debug: msg="{{ }}"


However, what is usually preferred is to use lookup pipe so that you can format the date and time, like this.

- debug: msg="{{ lookup('pipe','date +%Y-%m-%d-%H-%M-%S') }}"


Or even better, create a date and time variables.

  date: "{{ lookup('pipe','date +%Y-%m-%d') }}"
  time: "{{ lookup('pipe','date +%H:%M:%S') }}"


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter 3fec2 in the box below so that we can be sure you are a human.