Thanks, John.   I didn't have another purpose for the shm_size variable. 
Wasn't using the mount because I'm a rookie and still learning. 

Bob

On Thursday, May 14, 2015 at 10:13:13 AM UTC-4, jcbollinger wrote:
>
>
>
> On Wednesday, May 13, 2015 at 2:55:03 PM UTC-5, Bob Vergeer wrote:
>>
>> Two issues, removing the decimal places and appending a character.
>> Trying to generate a  /dev/shm line in /etc/fstab that is set to 1G less 
>> than available RAM. 
>>
>> The line should appear as follows in /etc/fstab:
>> ...
>> none     /dev/shm     tmpfs    rw,exec,size=2048M    0   0
>> ...
>>
>> 1) How do I convert something like this to integer?  The floating point 
>> fails
>>     $shm_size = $memorysize_mb - 1024 
>>
>>
>
> Puppet 3's DSL does not have a mechanism for explicitly specifying data 
> types or converting between them (but such a system is introduced in Puppet 
> 4).  Nevertheless, you have posed the wrong question: the issue is not so 
> much about the type of $shm_size's value, but about how that value is used 
> in assembling some string.  That could be addressed either by assigning a 
> value whose interpolation yields the desired result (which value doesn't 
> have to be of integer type specifically), or by assembling the target 
> string by some means other than interpolating the variable's value.  I 
> guess your current approach is presented in the next question.
>
>  
>
>> 2) Used file_line to insert the string in /etc/fstab.  How do I append 
>> the M to the $shm_size variable without a space between?
>>     line  => 'none    /dev/shm    tmpfs    rw,exec,size=$shm_sizeM       
>> 0     0'
>>
>>
>
> In direct answer to the question, this should work:
>
> line  => "none    /dev/shm    tmpfs     rw,exec,size=${shm_size}M      0 
>     0"
>
> Note the double quotes instead of single, and especially the curly braces 
> around the variable name.
>
> That begs the question, however, of why you are managing /etc/fstab via 
> File_line resources, when you could instead do it more reliably via the 
> standard "Mount" resource type.  Switching to a Mount won't in itself solve 
> your problem with expressing the mount options, but it is nevertheless far 
> superior.  For example, if you don't need $shm_size for anything else, then 
> this Mount resource would probably serve your whole need:
>
> mount { '/dev/shm':
>   ensure => 'present',
>   device => 'none',
>   fstype => 'tmpfs',
>   options => inline_template('rw,exec,size=<%= @memorysize_mb.to_i - 1024 
> %>M'),
>   dump => '0',
>   pass => '0'
> }
>
>
> John
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/c78e508d-8447-4502-8322-9568f0044ace%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to