getvar and case

16 views
Skip to first unread message

Ugo Bellavance

unread,
Jun 22, 2017, 11:03:31 PM6/22/17
to Puppet Users
Hi,

I'm fetching some data in facts using getvar, but as soon as there is a capital letter in the result, the result doesn't go in the variable.

For example, this never returns anything:

  $directive_value_fact       = getvar("::zend_directive_fileValue_${name}")

The generated fact that I'm looking for contains "fileValue" so I don't really have the choice, except to maybe edit the fact-gathering script to do replace, but it may cause other problems.

I'm on stdlib 4.16 and I don't see any bugfixes for that in the changelog of more recent versions.

Another example... This works, as long as "name" doesn't contain a capital letter. And some extensions start with a capital letter (like Phar).

  $extension_status_fact       = getvar("::zend_extension_status_${name}")

Final example.  This works, as long as ${user_app_name} doesn't contain a capital letter.

  $app_name_fact       = getvar("::zend_application_name_${user_app_name}")

Actually, from my testing I found that that if ${user_app_name} is all caps, it would work.

Any ideas welcome.  For ${user_app_name}, the workaround would be to only use all-lowercase application names, but since we don't decide the exact name of PHP extensions, the workaround doesn't work.

As you can see in the facts, the only way to get the data that we need is to get the zend_directive_fileValue to the the current value of the directive.

zend_directive_name_upload_max_filesize=upload_max_filesize
zend_directive_section_upload_max_filesize=
zend_directive_fileValue_upload_max_filesize=32M
zend_directive_defaultValue_upload_max_filesize=32M
zend_directive_isMemoryOnly_upload_max_filesize=0
zend_directive_previousValue_upload_max_filesize=
zend_directive_description_upload_max_filesize=The maximum size of an uploaded file
zend_directive_type_upload_max_filesize=shorthand
zend_directive_listValues_upload_max_filesize=
zend_directive_context_upload_max_filesize=Extension
zend_directive_contextName_upload_max_filesize=Filesystem and Streams
zend_directive_units_upload_max_filesize=


Thanks,

Ugo

R.I. Pienaar

unread,
Jun 23, 2017, 2:01:46 AM6/23/17
to puppet...@googlegroups.com
You don't mention your versions but on the last 2 years of versions - i.e. 4 - do:

$facts["zend_application_name_${user_app_name}"]

---
R.I.Pienaar

> On 23 Jun 2017, at 05:03, Ugo Bellavance <ug...@lubik.ca> wrote:
>
> zend_application_name_${user_app_name}

Ugo Bellavance

unread,
Jun 23, 2017, 7:04:44 AM6/23/17
to Puppet Users


On Friday, June 23, 2017 at 2:01:46 AM UTC-4, R.I. Pienaar wrote:
You don't mention your versions but on the last 2 years of versions - i.e. 4 - do:

$facts["zend_application_name_${user_app_name}"]

Unfortunately, I'm still on Puppet 3.8.  I know that Puppet 3 is EOL and Puppet 5 is already available (at least as beta), but I've been swamped with work and didn't have time to start to plan my migration yet. I have installed Puppet 4 on a server, but that's about how far I could go for now.  If I could solve this specific problem, I'll have about 98% of this task done so I'm just about to be able to start to work with a more recent version of puppet.

Thanks,

Ugo Bellavance

unread,
Jun 23, 2017, 8:14:59 AM6/23/17
to Puppet Users


On Friday, June 23, 2017 at 2:01:46 AM UTC-4, R.I. Pienaar wrote:
You don't mention your versions but on the last 2 years of versions - i.e. 4 - do:

$facts["zend_application_name_${user_app_name}"]


It looks like the facts are all forced downcase (https://tickets.puppetlabs.com/browse/FACT-777).

I changed

$directive_value_fact       = getvar("::zend_directive_fileValue_${name}")

to

$directive_value_fact       = getvar("::zend_directive_filevalue_${name}")

and it seems to be working.

I'll have to find a way to do a downcase on the variables and I think it'll be ok.

I'll try to think about posting my final results for the community's benefit.

Thanks,

Ugo Bellavance

unread,
Jun 28, 2017, 9:20:59 AM6/28/17
to Puppet Users
I confirm that using stdlib's downcase() worked.
Reply all
Reply to author
Forward
0 new messages