New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add now() jinja2 global func for getting the date/time #43792

Merged
merged 3 commits into from Dec 7, 2018

Conversation

Projects
None yet
4 participants
@sivel
Member

sivel commented Aug 7, 2018

SUMMARY

Add now() jinja2 global func for getting the date/time

See #22561

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

lib/ansible/template/init.py

ANSIBLE VERSION
2.7
ADDITIONAL INFORMATION
- hosts: localhost
  gather_facts: false
  tasks:
    - debug:
        msg: "{{ now() }}"
    - debug:
        msg: "{{ now(utc=True) }}"
    - debug:
        msg: "{{ now(fmt='%c') }}"
    - debug:
        msg: "{{ now(utc=True).isoformat() }}"
TASK [debug] *********************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": "2018-08-07 15:14:20.704361"
}

TASK [debug] *********************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": "2018-08-07 20:14:20.765310"
}

TASK [debug] *********************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": "Tue Aug  7 15:14:20 2018"
}

TASK [debug] *********************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": "2018-08-07T20:14:20.916165"
}
@sivel

This comment has been minimized.

Member

sivel commented Aug 7, 2018

TODO: docs

@bcoca

bcoca approved these changes Dec 5, 2018

@ansibot

This comment has been minimized.

Contributor

ansibot commented Dec 5, 2018

@ansibot ansibot added needs_revision and removed core_review labels Dec 6, 2018

@sivel sivel merged commit 3a4d476 into ansible:devel Dec 7, 2018

1 check passed

Shippable Run 97183 status is SUCCESS.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment