How to import simple class.pp (not a module) and use it with foreman?

Hello,

1.Attached a foreman debug file.

2.There are many issues with similar topic here… but none of them has a
short walk through of how to take a simple "class.pp" , import it to
foreman and apply it on hosts.

3. Env Details:

OS: redhat
RELEASE: CentOS release 6.6 (Final)
FOREMAN: 1.7.1
RUBY: ruby 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux]
PUPPET: 2.7.25
DENIALS: 0

4. Issue:

Trying to import this simple class to foreman and apply it on managed hosts.

class install-zabbix-agent {
yumrepo { "zabbix":
baseurl =>
"http://repo.zabbix.com/zabbix/2.2/rhel/6/x86_64/",
descr => "zabbix repository",
enabled => 1,
gpgcheck => 0
}

    file { "/etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX":
            mode    => 600,
            owner   => "root",
            group   => "root",
            source => 

"puppet:///files/etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX",
require => yumrepo["zabbix"]
}

    package {
            "zabbix-agent-2.2.1-1.el6.x86_64": 
            ensure => installed,
            require => file["/etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX"],
    }

    service { "zabbix-agent":
            ensure => running,
            enable => true,
            require => Package["zabbix-agent-2.2.1-1.el6.x86_64"],
    }

    file { "/etc/zabbix/zabbix_agentd.conf":
            notify  => Service["zabbix-agent"],  
            mode    => 600,
            owner   => "root",
            group   => "root",
            content => template('zabbix_agentd.conf.erb')
    }

}

  1. This class works just fine on all of the puppet registered hosts ( if
    i use it manually via puppet agent ).

  2. What is the correct way to import it to foreman and apply it on other
    hosts ?

Thanks

foreman-debug-MutMp.tar.xz (8.33 KB)

So far the only way i found to imort and apply such a class with foreman is
by creating a module with the same name of the class

··· On Monday, January 12, 2015 at 1:04:43 PM UTC+2, imneo wrote: > > Hello, > > 1.Attached a foreman debug file. > > 2.There are many issues with similar topic here... but none of them has a > short walk through of how to take a simple "class.pp" , import it to > foreman and apply it on hosts. > > *3. Env Details:* > > OS: redhat > RELEASE: CentOS release 6.6 (Final) > FOREMAN: 1.7.1 > RUBY: ruby 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux] > PUPPET: 2.7.25 > DENIALS: 0 > > *4. Issue:* > > Trying to import this simple class to foreman and apply it on managed > hosts. > > class install-zabbix-agent { > yumrepo { "zabbix": > baseurl => " > http://repo.zabbix.com/zabbix/2.2/rhel/6/x86_64/", > descr => "zabbix repository", > enabled => 1, > gpgcheck => 0 > } > > > file { "/etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX": > mode => 600, > owner => "root", > group => "root", > source => > "puppet:///files/etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX", > require => yumrepo["zabbix"] > } > > package { > "zabbix-agent-2.2.1-1.el6.x86_64": > ensure => installed, > require => file["/etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX"], > } > > service { "zabbix-agent": > ensure => running, > enable => true, > require => Package["zabbix-agent-2.2.1-1.el6.x86_64"], > } > > file { "/etc/zabbix/zabbix_agentd.conf": > notify => Service["zabbix-agent"], > mode => 600, > owner => "root", > group => "root", > content => template('zabbix_agentd.conf.erb') > } > > } > > > 5. This class *works just fine* on all of the puppet registered hosts ( > if i use it manually via puppet agent ). > > 6. What is the correct way to import it to foreman and apply it on other > hosts ? > > Thanks > > > >

Just to be clear , if i have a simple class i should port it to be a module
and import it to foreman ?
That is the recommended way ?

Thank you for your help

··· On Monday, January 12, 2015 at 1:04:43 PM UTC+2, imneo wrote: > > Hello, > > 1.Attached a foreman debug file. > > 2.There are many issues with similar topic here... but none of them has a > short walk through of how to take a simple "class.pp" , import it to > foreman and apply it on hosts. > > *3. Env Details:* > > OS: redhat > RELEASE: CentOS release 6.6 (Final) > FOREMAN: 1.7.1 > RUBY: ruby 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux] > PUPPET: 2.7.25 > DENIALS: 0 > > *4. Issue:* > > Trying to import this simple class to foreman and apply it on managed > hosts. > > class install-zabbix-agent { > yumrepo { "zabbix": > baseurl => " > http://repo.zabbix.com/zabbix/2.2/rhel/6/x86_64/", > descr => "zabbix repository", > enabled => 1, > gpgcheck => 0 > } > > > file { "/etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX": > mode => 600, > owner => "root", > group => "root", > source => > "puppet:///files/etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX", > require => yumrepo["zabbix"] > } > > package { > "zabbix-agent-2.2.1-1.el6.x86_64": > ensure => installed, > require => file["/etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX"], > } > > service { "zabbix-agent": > ensure => running, > enable => true, > require => Package["zabbix-agent-2.2.1-1.el6.x86_64"], > } > > file { "/etc/zabbix/zabbix_agentd.conf": > notify => Service["zabbix-agent"], > mode => 600, > owner => "root", > group => "root", > content => template('zabbix_agentd.conf.erb') > } > > } > > > 5. This class *works just fine* on all of the puppet registered hosts ( > if i use it manually via puppet agent ). > > 6. What is the correct way to import it to foreman and apply it on other > hosts ? > > Thanks > > > >

The smart proxy only scans manifests in the modulepath, it doesn't check
the manifestdir, which is why it won't be imported automatically -
though conceivably it could.

That isn't a recommended or usual approach to using Puppet, so using a
module layout is a far better idea.

Note that hyphens in a class name are invalid and may cause problems, so
use underscores instead:
https://docs.puppetlabs.com/puppet/3/reference/lang_reserved.html#classes-and-types

··· -- Dominic Cleal Red Hat Engineering

On 12/01/15 12:29, imneo wrote:

So far the only way i found to imort and apply such a class with foreman
is by creating a module with the same name of the class

On Monday, January 12, 2015 at 1:04:43 PM UTC+2, imneo wrote:

Hello,

1.Attached a foreman debug file.

2.There are many issues with similar topic here... but none of them
has a short walk through of how to take a simple "class.pp" , import
it to foreman and apply it on hosts.

*_3. Env Details:_*
 
  OS: redhat
  RELEASE: CentOS release 6.6 (Final)
  FOREMAN: 1.7.1
  RUBY: ruby 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux]
  PUPPET: 2.7.25
  DENIALS: 0

*_4. Issue:_*
*_
_*
Trying to import this simple class to foreman and apply it on
managed hosts.

>
class install-zabbix-agent {
        yumrepo { "zabbix":
                baseurl =>
"http://repo.zabbix.com/zabbix/2.2/rhel/6/x86_64/
<http://repo.zabbix.com/zabbix/2.2/rhel/6/x86_64/>",
                descr => "zabbix repository",
                enabled => 1,
                gpgcheck => 0
        }


        file { "/etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX":
                mode    => 600,
                owner   => "root",
                group   => "root",
                source =>
"puppet:///files/etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX",
                require => yumrepo["zabbix"]
        }

        package {
                "zabbix-agent-2.2.1-1.el6.x86_64": 
                ensure => installed,
                require => file["/etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX"],
        }

        service { "zabbix-agent":
                ensure => running,
                enable => true,
                require => Package["zabbix-agent-2.2.1-1.el6.x86_64"],
        }

        file { "/etc/zabbix/zabbix_agentd.conf":
                notify  => Service["zabbix-agent"],  
                mode    => 600,
                owner   => "root",
                group   => "root",
                content => template('zabbix_agentd.conf.erb')
        }

}
>


5. This class *works just fine* on all of the puppet registered
hosts ( if i use it manually via puppet agent ). 

6. What is the correct way to import it to foreman and apply it on
other hosts ?

Thanks 


You received this message because you are subscribed to the Google
Groups “Foreman users” group.
To unsubscribe from this group and stop receiving emails from it, send
an email to foreman-users+unsubscribe@googlegroups.com
mailto:foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com
mailto:foreman-users@googlegroups.com.
Visit this group at http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.

Yes, exactly.

··· -- Dominic Cleal Red Hat Engineering

On 12/01/15 13:53, imneo wrote:

Just to be clear , if i have a simple class i should port it to be a
module and import it to foreman ?
That is the recommended way ?

Thank you for your help

On Monday, January 12, 2015 at 1:04:43 PM UTC+2, imneo wrote:

Hello,

1.Attached a foreman debug file.

2.There are many issues with similar topic here... but none of them
has a short walk through of how to take a simple "class.pp" , import
it to foreman and apply it on hosts.

*_3. Env Details:_*
 
  OS: redhat
  RELEASE: CentOS release 6.6 (Final)
  FOREMAN: 1.7.1
  RUBY: ruby 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux]
  PUPPET: 2.7.25
  DENIALS: 0

*_4. Issue:_*
*_
_*
Trying to import this simple class to foreman and apply it on
managed hosts.

>
class install-zabbix-agent {
        yumrepo { "zabbix":
                baseurl =>
"http://repo.zabbix.com/zabbix/2.2/rhel/6/x86_64/
<http://repo.zabbix.com/zabbix/2.2/rhel/6/x86_64/>",
                descr => "zabbix repository",
                enabled => 1,
                gpgcheck => 0
        }


        file { "/etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX":
                mode    => 600,
                owner   => "root",
                group   => "root",
                source =>
"puppet:///files/etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX",
                require => yumrepo["zabbix"]
        }

        package {
                "zabbix-agent-2.2.1-1.el6.x86_64": 
                ensure => installed,
                require => file["/etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX"],
        }

        service { "zabbix-agent":
                ensure => running,
                enable => true,
                require => Package["zabbix-agent-2.2.1-1.el6.x86_64"],
        }

        file { "/etc/zabbix/zabbix_agentd.conf":
                notify  => Service["zabbix-agent"],  
                mode    => 600,
                owner   => "root",
                group   => "root",
                content => template('zabbix_agentd.conf.erb')
        }

}
>


5. This class *works just fine* on all of the puppet registered
hosts ( if i use it manually via puppet agent ). 

6. What is the correct way to import it to foreman and apply it on
other hosts ?

Thanks 


You received this message because you are subscribed to the Google
Groups “Foreman users” group.
To unsubscribe from this group and stop receiving emails from it, send
an email to foreman-users+unsubscribe@googlegroups.com
mailto:foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com
mailto:foreman-users@googlegroups.com.
Visit this group at http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.