Hello Dave,

 

as far as I can tell, Augeas is not involved in this issue at all. That is, 
unless the sysctl Puppet module falls back to augeas Puppet resources, but in 
this case it doesn’t get that far to make it matter. Therefor I propose to no 
longer have the Augeas-devel list in CC (after this reply).

 

Anyway, what Puppet version are you using (since you use a recourse type for 
iteration, it might by Puppet 3.x w/o future parser)? And which sysctl module 
(since it doesn’t belong to the standard Puppet tool set)?

 

And please make sure the brackets are not omitted from your pasted code 
snippets, since they’re essential for the syntax.

 

This is what I understand from the code what you’re trying to do:

 

·        In init.pp you want to iterate through all keys of $sysctl_settings, 
creating a new rh7config::sysctlconfig resource for each of them. Hoewever, at 
the same time you give all of them the same complete hash as value to the 
porthash parameter?!

·        In the rh7config::sysctlconfig resource type, you create a new sysctl 
resource with a title taken from the $porthash parameter and $name as the 
search key. Note that $porthash = $sysctl_settings and $name = 
“net.ipv4.tcp_keepalive_time”. That’s why the title for that resource becomes 
“val=>3600” (a hash converted to string) and, judging from the error message, 
the title it required to be a sysctl parameter, in this situation it should 
have been “net.ipv4.tcp_keepalive_time”.

 

In case you do have Puppet 4.x+ or the future parser, have a look at the 
advanced constructs for looping (in particular “each”). Otherwise, a small 
change to rh7config::sysctlconfig might be all you need:

 

“””

define rh7config::sysctlconfig ($porthash) {

  sysctl { $title:

    ensure => present,

    value  => $porthash[$title][$val],

    target => "/usr/lib/sysctl.d/00-system.conf",

  }

}

“””

 

·        The title for the sysctl resource is changed to be the same as for 
rh7config::sysctlconfig (“net.ipv4.tcp_keepalive_time” or any other key).

·        Value should be assigned the value of the “val” key (and not the bare 
word “val” as it was before).

 

Ciao,

Xavier.

 

 

 

From: [email protected] <[email protected]> On 
Behalf Of Dave Green
Sent: Monday, May 21, 2018 4:50 PM
To: [email protected]
Subject: [augeas-devel] augeasproviders_sysctl usage help

 

Hi

 

I’m trying to use your module to control sysctl settings thought puppet, and to 
be honest I’m struggling. Not sure if it’s specifically how I’m using your 
module, or the fact that I am not passing hash values to it (I’m very new to 
perl and puppet).

 

This is my init.pp code

 

        $sysctlkeys = keys($sysctl_settings)

        rh7config::sysctlconfig  $sysctlkeys:

            porthash => $sysctl_settings

        

 

And the sysctlconfig definition looks like this…

 

define rh7config::sysctlconfig ($porthash) 

sysctl  $porthash[$name]:

                ensure => present,

                value  => $porthash[$name][val],

                target => "/usr/lib/sysctl.d/00-system.conf",

                

        

 

The parameter sysctl_settings (defined as a hash as I want to set several 
sysctl values) is set to 

 

net.ipv4.tcp_keepalive_time:

  val: 3600

 

but I am receiving the following error when puppet checks in on the host

 

Error: 
/Stage[main]/Rh7config/Rh7config::Sysctlconfig[net.ipv4.tcp_keepalive_time]/Sysctl["val"=>3600]:
 Could not evaluate: Error: `"val"=>3600` is not a valid sysctl key

 

I’m not sure if it the code I’m using to pass the hash value or the syntax of 
the parameter which is incorrect. Any help you could give me would be very 
gratefully received

 

Regards

Dave

 

 

 

Dave Green 

Technical Consultant 

Sword Apak 

 <http://www.sword-apak.com> www.sword-apak.com 

 

d +44 1454 871120 

t +44 1454 871000 

f +44 1454 871199 

e  <mailto:[email protected]> [email protected] 

 

Nibley Court

3 Turner Drive 

Westerleigh Business Park 

Bristol 

BS37 5YX. United Kingdom 

 <http://www.sword-group.com> www.sword-group.com  

 

 

Apak Group Limited, Registered in England No. 01451033. 

Registered Office: Nibley Court, 3 Turner Drive, Westerleigh Business Park, 
Bristol, BS37 5YX.

 

 

The information contained in this message or any of its attachments may be 
privileged and confidential and intended for the exclusive use of the 
addressee.  The views expressed may not be Apak policy but the personal views 
of the originator.  If you have received this message in error, please advise 
the sender immediately by reply e-mail and delete this message and any 
attachments without retaining a copy.  This footnote also confirms that this 
email has been swept for the presence of known computer viruses before being 
sent. 

 

 

 

Dave Green 

Technical Consultant 

Sword Apak 

www.sword-apak.com <http://www.sword-apak.com>  

 

d +44 1454 871120 

t +44 1454 871000 

f +44 1454 871199 

e [email protected] <mailto:[email protected]>  

 

Nibley Court

3 Turner Drive 

Westerleigh Business Park 

Bristol 

BS37 5YX. United Kingdom 

www.sword-group.com <http://www.sword-group.com>   

 

 

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
augeas-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/augeas-devel

Reply via email to