Ask Your Question
0

max length of names of variables

asked 2017-12-12 13:06:15 -0600

KenB gravatar image

updated 2017-12-13 07:49:34 -0600

Is there an upper limit on length of variables?

For our Windows deployment, I'm planning on using the local_security_policy module and so we can easily define unique values for windows systems, I was going to use Hiera to assign values (so we can have per-node differences). I was planning on using variable names similar to the "policy" name (without spaces or special characters) to make it easier to read what is happening but the variables are getting pretty long.

I couldn't find an article that talks about how long variables names (ok, they are "constants" :) ) can be.

Here is an example (sorry for the formatting...I couldn't get the preview to look right): update by KB: thanks for the edit so preview looks like the code should!

The code today I've been testing looks like this:

  local_security_policy { 'User Account Control: Behavior of the elevation prompt for administrators in Admin Approval Mode':
    ensure         => 'present',
    policy_setting => 'MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\ConsentPromptBehaviorAdmin',
    policy_type    => 'Registry Values',
    policy_value   => '4,5',   
}

what I'd like to change that to is along these lines:

What Hiera yaml file would contains (something like this):

profile::base::useraccountcontrolbehavioroftheelevationpromptforadministratorsinadminapprovalmode: '4,5'

Then in the module, doing A lookup from Hiera:

  $useraccountcontrolbehavioroftheelevationpromptforadministratorsinadminapprovalmode=      lookup('useraccountcontrolbehavioroftheelevationpromptforadministratorsinadminapprovalmode')

Then using it in the code:

  local_security_policy { 'User Account Control: Behavior of the elevation prompt for administrators in Admin Approval Mode':
    ensure         => 'present',
    policy_setting => 'MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\ConsentPromptBehaviorAdmin',
    policy_type    => 'Registry Values',
    policy_value   => $useraccountcontrolbehavioroftheelevationpromptforadministratorsinadminapprovalmode,
  }
edit retag flag offensive close merge delete

Comments

Since the Puppet language is a Ruby domain-specific language, I'd search for Ruby's limitations. Anyhow, having identifiers their length's greater than, let's say 32 characters, borders on ridiculousness.

Kai Burghardt gravatar imageKai Burghardt ( 2017-12-13 18:55:36 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2018-02-04 04:33:39 -0600

Henrik Lindberg gravatar image

The only limit are the limits imposed by Ruby String, and serialization technology limits on the same, as well as hard limits like available memory. If a variable is a parameter that shows up in PDB, there are limits on the length of strings there.

Then there is sanity to consider....

edit flag offensive delete link more
0

answered 2017-12-28 15:06:08 -0600

KenB gravatar image

I had some time to do a quick test. At least with Puppet 5, the variable names can be 76 characters in length.

This works as expected and the 3 values are shown in the notify in the puppet run output.

Redacted some items specific to our environment

image description

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-12-12 13:06:15 -0600

Seen: 115 times

Last updated: Feb 04