Member-only story
How to Use Date, Time, and Timestamp in Ansible Playbook
How to use Date, Time, and Timestamp in ISO 8601 format in Ansible Playbook.
Introduction
Welcome to another episode of Ansible Pilot! I’m Luca Berton, and today we’re diving into the fascinating world of handling date, time, and timestamps in Ansible Playbooks. We’ll explore the ansible_date_time
variable, conduct a live demo, and provide you with simple Ansible code to get started.
The ansible_date_time
Variable
Ansible simplifies working with date and time information through the ansible_date_time
variable. This built-in variable comes packed with a wealth of information, neatly organized into key-value pairs. Let's take a closer look at some of the key values it provides:
"ansible_date_time": {
"date": "2022-05-18",
"day": "18",
"epoch": "1652887408",
"hour": "15",
"iso8601": "2022-05-18T15:23:28Z",
"minute": "23",
"month": "05",
"second": "28",
"time": "15:23:28",
"tz": "UTC",
"weekday": "Wednesday",
"weekday_number": "3",
"year": "2022"
}