Now() function in AWX

,

Getting some weird behavior from the now() function under AWX 22.6.0, ee 2.14.7. A template with the following:

Generated {{ now(fmt='%a %Y-%m-%d %I:%M%p', utc=false) }}

produces the correct “local” time from the CLI (also 2.14.7), but under AWX it produces UTC times. utc=false is the default; I only added that in an attempt to get local times. It made no difference. The time stamps AWX puts on the tasks in the job log are local. (Or at least they are displayed as local times in the GUI; trying not to assume too much!)

This isn’t urgent, just annoying. We’re planning to upgrade our AWX Real Soon Now, and bump up to later execution environments. I can live with the 5 hours difference until then. (We’re on the U.S. east coast: EST.) Maybe these planned upgrades will magically fix it.

Or, maybe we’ve got something set wrong (or unset?) in our EE. If you know of a quick fix or something to check, I’d love the hear about it. Thanks.

Ouch. I got a follow-up from our AWXpert (see what I did there). He said:

this happens because the AWX containers have their timezone set to UTC, which we can’t change. So even though you are setting utc=false , the local time is already UTC.

Surely there’s more to the story. The now() function is sweet, clean, and needed. Please don’t tell me it works everywhere except where it counts: in production in AWX. (I’m going to go have a sad.)

You can certainly change the timezone in your Execution Environments.
You can set environment variables in AWX Operator to set:

TZ=America/Chicago

Which could be applied to AWX Operator, eg:

ee_extra_env: |-
  - name: TZ
    value: America/Chicago

Or if you are using localtime via /etc/localtime, you could do something like:

ee_extra_env: |-
  - name: TZ
    value: :/etc/localtime

As long at that file exists and is set correctly to your intended timezone (usually a symlink).

4 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.