FreeKB - ansible-playbook command - date time
ansible-playbook command - date time

Home > Search


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

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="{{ ansible_date_time.date }}"

 

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.

vars:
  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 f1461 in the box below so that we can be sure you are a human.




Comments