Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Userparameter with Foreman #117

Closed
georgesouzafarias opened this issue Sep 1, 2015 · 7 comments
Closed

Userparameter with Foreman #117

georgesouzafarias opened this issue Sep 1, 2015 · 7 comments

Comments

@georgesouzafarias
Copy link

I'm using your puppet module in my environment. I haven't a lot of experience with puppet, but I'm using the foreman's web interface to manager my configurations.

My questions is:

How to configure userparameter using the web interface?

For example:

userparameter=pje.available,/usr/local/sbin/test_pje

Thank you

@inspired-geek
Copy link

Hello!
@georgesouzafarias,did you find the answer?

@georgesouzafarias
Copy link
Author

No, I'm waiting for.

@inspired-geek
Copy link

Actually I found a solution.
As Dominic said here https://groups.google.com/d/msg/foreman-users/o-Sqjo-n21A/66pEAIG17PYJ

You can't instantiate resources (defined types, or native) over the
Puppet ENC interface. Maybe use create_resources instead, e.g.

define foo($a, $b) { 
 notify { "$title: got $a and $b": } 
} 

class createfoo($data){ 
create_resources(foo, $data) 
} 

Then in foreman for the createfoo class, set the data parameter to:

--- 
data: 
 first: 
   a: "param 1a" 
   b: "param 1b" 
 second: 
   a: "param 2a" 
   b: "param 2b" 

So I've created module on puppet master puppet module generate nrzabbix and in manifests/init.pp I've put

class nrzabbix($data){
        create_resources(zabbix::userparameters, $data)
}

Then in foreman UI I've imported newly created module. It has only one smart parameter data which could be overridden in foreman
image

For example my UserParameter for montoring mongodb is described as

mongo:
  source: puppet:///modules/nrzabbix/mongo.conf

And content of nrzabbix/files/mongo.conf is

UserParameter=mongo.coll.count[*],echo "db.setSlaveOk();db.getCollection('$1').count()" | /opt/mongo/bin/mongo processor | sed -n 3p
UserParameter=mongo.db.queries,echo "db.currentOp().inprog.length" | /opt/mongo/bin/mongo processor | sed -n 3p

Then I've added this class to certain config group for my mongodb servers.
In YAML for a host I've got

---
classes:
  nrzabbix:
    data:
      mongo:
        source: puppet:///modules/nrzabbix/mongo.conf

On a host:

[root@nr-db-cl-c3 ~]# puppet agent -t
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for nr-db-cl-c3.nr.voskhod.ru
Info: Applying configuration version '1443431001'
Notice: /Stage[main]/Nrzabbix/Zabbix::Userparameters[mongo]/File[/etc/zabbix/zabbix_agentd.d/mongo.conf]/ensure: defined content as '{md5}9e444bd9fecf403b518547648373c9ba'
Info: /Stage[main]/Nrzabbix/Zabbix::Userparameters[mongo]/File[/etc/zabbix/zabbix_agentd.d/mongo.conf]: Scheduling refresh of Service[zabbix-agent]
Notice: /Stage[main]/Zabbix::Agent/Service[zabbix-agent]: Triggered 'refresh' from 1 events
Notice: Finished catalog run in 3.28 seconds

and

[root@nr-db-cl-c3 ~]# cat /etc/zabbix/zabbix_agentd.d/mongo.conf
UserParameter=mongo.coll.count[*],echo "db.setSlaveOk();db.getCollection('$1').count()" | /opt/mongo/bin/mongo processor | sed -n 3p
UserParameter=mongo.db.queries,echo "db.currentOp().inprog.length" | /opt/mongo/bin/mongo processor | sed -n 3p

Hope this could help

@dj-wasabi
Copy link
Contributor

Hi @inspired-geek

Thank you for this reply.

You could use this class: 'zabbix::userparameter.pp' instead of creating your own.
(Without the s.. ;-))

Can I update the readme for using userparameters with this information you provided?

Thanks!

@inspired-geek
Copy link

@dj-wasabi, of course you could!
It's non-obvious so I felt the need to dive deep into details :)

@chernogorsky
Copy link

Hi, class zabbix::userparameter.pp has no smart class parameter
This Puppet class has no parameters in its signature.
To update the class signature, go to the Puppet Classes page and select "Import".

Foreman 1.9.2

@chernogorsky
Copy link

class zabbix::userparameterf($data) {
validate_hash($data)
create_resources('zabbix::userparameters', $data)
}

This work as expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants