Jira (FACT-3125) timezone fact value is inconsistent - changes between manual and automated execution

38 views
Skip to first unread message

Timothy Mullican (Jira)

unread,
Jun 2, 2022, 6:01:02 PM6/2/22
to puppe...@googlegroups.com
Timothy Mullican created an issue
 
Facter / Bug FACT-3125
timezone fact value is inconsistent - changes between manual and automated execution
Issue Type: Bug Bug
Affects Versions: FACT 4.2.8
Assignee: Unassigned
Components: Community, Facter 4
Created: 2022/06/02 3:00 PM
Environment:

/etc/puppetlabs/code/environments/production/manifests/site.pp:

node default

{   include ::role::base_app }

----------------------------------------

/etc/puppetlabs/code/environments/production/site/role/manifests/base_app.pp:

class role::base_app

{   include profile::security::base }

----------------------------------------

/etc/puppetlabs/code/environments/production/site/profile/manifests/security/base.pp:

class profile::security::base (
) {

  $tz = $facts['timezone']
  file

{ "/tmp/timezone.txt":     content => "$tz\n"   }

  file

{ "/tmp/timezone2.txt":     content => inline_template("<%= @timezone %>\n")   }

  file

{ "/tmp/timezone3.txt":     content => inline_template("<%= Time.now.localtime.strftime('%Z') %>\n")   }

}

----------------------------------------

Manual run of puppet agent -t.

==> /tmp/timezone.txt <==
MST

==> /tmp/timezone2.txt <==
MST

==> /tmp/timezone3.txt <==
UTC

----------------------------------------

Automated agent run in the background:

==> /tmp/timezone.txt <==
UTC

==> /tmp/timezone2.txt <==
UTC

==> /tmp/timezone3.txt <==
UTC

The facter -p continues to show the timezone fact as MST, even after the automated agent runs.

[root@puppet-master production]# facter -p | grep -i timezone
timezone => MST

[root@puppet-master production]# /opt/puppetlabs/puppet/bin/ruby -e "puts Time.now.localtime.strftime('%Z')"
MST

Priority: Normal Normal
Reporter: Timothy Mullican

I have an example scenario where my server timezone is originally UTC on boot, but then changed to MST a few minutes after boot. Manual runs of puppet agent -t show the timezone fact has the current (correct) value of MST, but when the agent periodically checks in with the master (automated) it shows the original (bad) value of UTC. It seems like the automated agent check-in might be using cached facts or old facts?

--------------------------------------------

Puppet: 7.16.0

Ruby: ruby 2.7.6p219 (2022-04-12 revision c9c2245c0a) [x86_64-linux]

Distribution: CentOS 7.9.2009

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.20.2#820002-sha1:829506d)
Atlassian logo

Timothy Mullican (Jira)

unread,
Jun 2, 2022, 6:02:03 PM6/2/22
to puppe...@googlegroups.com
Timothy Mullican updated an issue
Change By: Timothy Mullican
Environment:
/etc/puppetlabs/code/environments/production/manifests/site.pp:

node default {

  include ::role::base_app

}

----------------------------------------

/etc/puppetlabs/code/environments/production/site/role/manifests/base_app.pp:

class role::base_app {

  include profile::security::base
}

----------------------------------------

/etc/puppetlabs/code/environments/production/site/profile/manifests/security/base.pp:

class profile::security::base (
) {

  $tz = $facts['timezone']
  file{ "/tmp/timezone.txt":
    content => "$tz\n"
  }

  file{ "/tmp/timezone2.txt":
    content => inline_template("<%= @timezone %>\n")
  }

  file{ "/tmp/timezone3.txt":
    content => inline_template("<%= Time.now.localtime.strftime('%Z') %>\n")
  }

}

----------------------------------------

Manual run of {*}puppet agent -t{*}.


==> /tmp/timezone.txt <==
MST

==> /tmp/timezone2.txt <==
MST

==> /tmp/timezone3.txt <==
UTC

----------------------------------------

Automated agent run in the background:

==> /tmp/timezone.txt <==
UTC

==> /tmp/timezone2.txt <==
UTC

==> /tmp/timezone3.txt <==
UTC

The *facter -p* continues to show the timezone fact as {*}MST{*}, even after the automated agent runs.


[root@puppet-master production]# facter -p | grep -i timezone
timezone => MST

[root@puppet-master production]# /opt/puppetlabs/puppet/bin/ruby -e "puts Time.now.localtime.strftime('%Z')"
MST

Timothy Mullican (Jira)

unread,
Jun 2, 2022, 6:02:03 PM6/2/22
to puppe...@googlegroups.com
Timothy Mullican updated an issue
I have an example scenario where my server timezone is originally *UTC* on boot, but then changed to *MST* a few minutes after boot. Manual runs of *puppet agent -t* show the timezone fact has the current (correct) value of {*}MST{*}, but when the agent periodically checks in with the master (automated) it shows the original (bad) value of {*}UTC{*}. It seems like the automated agent check-in might be using cached facts or old facts?

 

Puppet: 7.16.0

Ruby: ruby 2.7.6p219 (2022
- 04 - 12 revision c9c2245c0a) [x86_64 - linux]

Distribution: CentOS 7.9.2009

----------------------------------------- ---

Puppet /etc/puppetlabs/code/environments/production/manifests/site.pp : 7

node default

{   include ::role::base_app }

----------------------------------------

/etc/puppetlabs/code/environments/production/site/role/manifests/base_app . 16 pp:


class role::base_app

{   include profile::security::base }

----------------------------------------

/etc/puppetlabs/code/environments/production/site/profile/manifests/security/base . 0 pp:

Ruby class profile : ruby 2 :security::base (

) {

  $tz = $facts['timezone']
  file

{ "/tmp/timezone . 7 txt":     content => "$tz\n"   }

  file

{ "/tmp/timezone2
. 6p219 txt":     content => inline_template ( 2022 "<%= @timezone %>\n")   }


  file

{ "/tmp/timezone3.txt":     content => inline_template("<%= Time.now.localtime.strftime('%Z') %>\n")   }

}

- 04 - 12 revision c9c2245c0a) --------------------------------------


Manual run of {*}puppet agent -t{*}.

==> /tmp/timezone.txt <==
MST

==> /tmp/timezone2.txt <==
MST

==> /tmp/timezone3.txt <==
UTC

----------------------------------------

Automated agent check-in:


==> /tmp/timezone.txt <==
UTC

==> /tmp/timezone2.txt <==
UTC

==> /tmp/timezone3.txt <==
UTC

The *facter -p* continues to show the timezone fact as {*}MST{*}, even after the automated agent runs.

[ x86_64 root@puppet - linux master production ] # facter -p | grep -i timezone
timezone => MST
Distribution: CentOS 7
[root@puppet-master production]# /opt/puppetlabs/puppet/bin/ruby -e "puts Time
. 9 now . 2009 localtime.strftime('%Z')"
MST

Timothy Mullican (Jira)

unread,
Jun 2, 2022, 6:19:02 PM6/2/22
to puppe...@googlegroups.com
Timothy Mullican updated an issue
I have an example scenario where my server timezone is originally *UTC* on boot, but then changed to *MST* a few minutes after boot. Manual runs of *puppet agent -t* show the timezone fact has the current (correct) value of {*}MST{*}, but when the agent periodically checks in with the master (automated) it shows the original (bad) value of {*}UTC{*}. It seems like the automated agent check-in might be using cached facts or old facts?

 

Puppet: 7.16.0

Ruby: ruby 2.7.6p219 (2022-04-12 revision c9c2245c0a) [x86_64-linux]

Distribution: CentOS 7.9.2009

--------------------------------------------

/etc/puppetlabs/code/environments/production/manifests/site.pp:


node default

{   include ::role::base_app }

----------------------------------------

/etc/puppetlabs/code/environments/production/site/role/manifests/base_app.pp:


class role::base_app

{   include profile::security::base }

----------------------------------------

/etc/puppetlabs/code/environments/production/site/profile/manifests/security/base.pp:

class profile::security::base (

) {

  $tz = $facts['timezone']
  file

{ "/tmp/ timezone output1 .txt":     content => "$tz\n"   }

  file

{ "/tmp/
timezone2 output2 .txt":     content => inline_template("<%= @timezone %>\n")   }

  file

{ "/tmp/
timezone3 output3 .txt":     content => inline_template("<%= Time.now.localtime.strftime('%Z') %>\n")   }

}

----------------------------------------


Manual run of {*}puppet agent -t{*}.

==> /tmp/ timezone output1 .txt <==
MST

==> /tmp/
timezone2 output2 .txt <==
MST

==> /tmp/
timezone3 output3 .txt <==

UTC

----------------------------------------

Automated agent check-in:

==> /tmp/ timezone output1 .txt <==
UTC

==> /tmp/
timezone2 output2 .txt <==
UTC

==> /tmp/
timezone3 output3 .txt <==

UTC

The *facter -p* continues to show the timezone fact as {*}MST{*}, even after the automated agent runs.

[root@puppet-master production]# facter -p | grep -i timezone
timezone => MST

[root@puppet-master production]# /opt/puppetlabs/puppet/bin/ruby -e "puts Time.now.localtime.strftime('%Z')"
MST

Timothy Mullican (Jira)

unread,
Jun 2, 2022, 8:06:03 PM6/2/22
to puppe...@googlegroups.com
Timothy Mullican commented on Bug FACT-3125
 
Re: timezone fact value is inconsistent - changes between manual and automated execution

I'm not sure why calling the ruby functions below using inline_template provides the old value UTC, but facts that use them (such as https://github.com/puppetlabs/facter/blob/e5ad338bb6b5909c1d84cc7a580dc5dafed77e68/lib/facter/resolvers/timezone.rb#L16) show the correct value MST when run manually with puppet agent -t.

inline_template("<%= Time.now.localtime.strftime('%Z') %>\n")       // UTC

inline_template("<%= Time.now.zone %>\n")      // UTC

$facts['timezone']      // MST

$facts['timezone_custom']        // MST    ; This is a custom fact that outputs Time.now.zone

Timothy Mullican (Jira)

unread,
Jun 2, 2022, 8:13:02 PM6/2/22
to puppe...@googlegroups.com

Restarting the puppetserver service on the Puppet master server appears to fix this issue. Not sure why it is keeping the old value until the restart though. And only for the automated agent check-in, not the manual puppet agent -t command.

Timothy Mullican (Jira)

unread,
Jun 2, 2022, 8:23:02 PM6/2/22
to puppe...@googlegroups.com

It looks like the server facts on the Puppet master are not updated after the initial connection with the master. For instance, I just changed the server timezone to America/Chicago, but the facts still show MST.

[root@puppet-master production]# timedatectl set-timezone "America/Chicago"

[root@puppet-master production]# puppet agent -t

...

[root@puppet-master production]# cat /opt/puppetlabs/server/data/puppetserver/server_data/facts/puppet-master.test.local.json | jq | grep timezone
    "timezone": "MST",
    "timezone_custom": "MST",

[root@puppet-master production]# tail -n +1 /tmp/output*.txt
==> /tmp/output1.txt <==
CDT

==> /tmp/output2.txt <==
CDT

==> /tmp/output3.txt <==
MST

Timothy Mullican (Jira)

unread,
Jun 2, 2022, 8:43:02 PM6/2/22
to puppe...@googlegroups.com

Facter upload changes the JSON file on the Puppet master, but the issue still persists until puppetserver.service is restarted.

[root@puppet-master production]# facter upload

[root@puppet-master production]# cat /opt/puppetlabs/server/data/puppetserver/server_data/facts/puppet-master.test.local.json | jq | grep timezone

    "timezone": "CDT",
    "timezone_custom": "CDT",

==> /tmp/output1.txt <==
CDT

==> /tmp/output2.txt <==
CDT

==> /tmp/output3.txt <==
MST

Timothy Mullican (Jira)

unread,
Jun 3, 2022, 12:50:03 AM6/3/22
to puppe...@googlegroups.com

It looks like specifying a TTL for the timezone fact seems to resolve this as well. I'm not sure what the default TTL is for the timezone fact.

----------------

[root@puppet-master production]# cat /etc/puppetlabs/facter/facter.conf
facts :

{     ttls : [         \{ "timezone" : 5 minutes }

,
    ]
}

[root@puppet-master production]# systemctl restart puppet

Timothy Mullican (Jira)

unread,
Jun 3, 2022, 12:55:03 AM6/3/22
to puppe...@googlegroups.com
Timothy Mullican updated an issue
Change By: Timothy Mullican
I have an example scenario where my server timezone is originally *UTC* on boot, but then changed to *MST* a few minutes after boot. Manual runs of *puppet agent -t* show the timezone fact has the current (correct) value of {*}MST{*}, but when the agent periodically checks in with the master (automated) it shows the original (bad) value of {*}UTC{*}. It seems like the automated agent check-in might be using cached facts or old facts?

 

Puppet: 7.16.0

Ruby: ruby 2.7.6p219 (2022-04-12 revision c9c2245c0a) [x86_64-linux]

Distribution: CentOS 7.9.2009

--------------------------------------------

 
{code:java}
/etc/puppetlabs/code/environments/production/manifests/site.pp:

node default

{   include ::role::base_app }
{code}
 

----------------------------------------

 
{code:java}
/etc/puppetlabs/code/environments/production/site/role/manifests/base_app.pp:

class role::base_app

{   include profile::security::base }
{code}
 

----------------------------------------

 
{code:java}
/etc/puppetlabs/code/environments/production/site/profile/manifests/security/base.pp:

class profile::security::base (
) {

  $tz = $facts['timezone']
  file

{ "/tmp/output1.txt":     content => "$tz\n"   }

  file

{ "/tmp/output2.txt":     content => inline_template("<%= @timezone %>\n")   }

  file

{ "/tmp/output3.txt":     content => inline_template("<%= Time.now.localtime.strftime('%Z') %>\n")   }
}
{code }
 

----------------------------------------

Manual run of {*}puppet agent -t{*}.

==> /tmp/output1.txt <==
MST

==> /tmp/output2.txt <==
MST

==> /tmp/output3.txt <==

UTC

----------------------------------------

Automated agent check-in:

==> /tmp/output1.txt <==
UTC

==> /tmp/output2.txt <==
UTC

==> /tmp/output3.txt <==

UTC

The *facter -p* continues to show the timezone fact as {*}MST{*}, even after the automated agent runs.

 
{code:java}
[root@puppet-master production]# facter -p | grep -i timezone
timezone => MST

[root@puppet-master production]# /opt/puppetlabs/puppet/bin/ruby -e "puts Time.now.localtime.strftime('%Z')"
MST

{code}
 

Timothy Mullican (Jira)

unread,
Jun 3, 2022, 12:56:02 AM6/3/22
to puppe...@googlegroups.com

Timothy Mullican (Jira)

unread,
Jun 3, 2022, 12:56:02 AM6/3/22
to puppe...@googlegroups.com

Timothy Mullican (Jira)

unread,
Jun 3, 2022, 12:57:02 AM6/3/22
to puppe...@googlegroups.com
 
{code:java}
==> /tmp/output1.txt <==
MST

==> /tmp/output2.txt <==
MST

==> /tmp/output3.txt <==
UTC
{code}
 

----------------------------------------

Automated agent check-in:

 
{code:java}
==> /tmp/output1.txt <==
UTC

==> /tmp/output2.txt <==
UTC

==> /tmp/output3.txt <==
UTC
{code}
 

The *facter -p* continues to show the timezone fact as {*}MST{*}, even after the automated agent runs.
{code:java}[root@puppet-master production]# facter -p | grep -i timezone
timezone => MST
[root@puppet-master production]# /opt/puppetlabs/puppet/bin/ruby -e "puts Time.now.localtime.strftime('%Z')"
MST
{code}

Timothy Mullican (Jira)

unread,
Jun 3, 2022, 1:17:03 AM6/3/22
to puppe...@googlegroups.com
Timothy Mullican updated an issue
I have an example scenario where my server timezone is originally *UTC* on boot, but then manually changed to *MST* a few minutes after boot. Manual runs of *puppet agent -t* show the timezone fact has the current (correct) value of {*}MST{*}, but when the agent periodically checks in with the master (automated) it shows the original (bad) value of {*}UTC{*}. It seems like the automated agent check-in might be using cached facts or old facts?

Timothy Mullican (Jira)

unread,
Jun 3, 2022, 1:18:03 AM6/3/22
to puppe...@googlegroups.com

Nirupama Mantha (Jira)

unread,
Jun 7, 2022, 4:22:02 PM6/7/22
to puppe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages