Skip to main content

timezone resource

Use the timezone Chef InSpec audit resource to test timezone configurations of the system.

Availability

Install

This resource is distributed with Chef InSpec and is automatically available for use.

Syntax

A timezone resource block fetches the time zone configuration of a system and compares the output with the test:

describe timezone do
  its('property') { should eq 'expected value' }
end

where

  • 'property' is one of identifier , name and time_offset
  • 'expected value' tests the output of the command run on the system versus the expected output stated in the test

For example:

describe timezone do
  its('identifier') { should eq 'Asia/Kolkata' }
  its('name') { should eq 'IST' }
  its('time_offset') { should eq '+0530' }
end

Properties

identifier

The identifier property verifies the time zone name of a system.

An example of checking the identifier for the Asia/Kolkata time zone name:

its('identifier') { should eq 'Asia/Kolkata' }

name

The name property verifies the time zone of a system.

Note

The name property accepts the time zone abbreviation on Linux systems and the full time zone name on Windows systems.

An example of verifying that the time zone is set to IST on a Linux system:

its('name') { should eq 'IST' }

Note

Several time zones share the same time zone abbreviation. Use one of the other properties to verify a specific time zone with a common abbreviation.

An example of verifying that the time zone is set to India Standard Time on a Windows system:

its('name') { should eq 'India Standard Time' }

time_offset

The time_offset property verifies the time offset of a system from UTC (Coordinated Universal Time).

An example of verifying that the time_offset is UTC+05:30:

its('time_offset') { should eq '+0530' }

Matchers

For a full list of available matchers, see our Universal Matchers page.
Edit this page on GitHub

Thank you for your feedback!

×











Search Results