[Solved] Port Puppet inner class to Chef


#1

Hi,

I’m stuck on how to port a Puppet inner class to Chef.

Here is an example of the ‘logstashforwarder’ class :

class profile::logstash_forwarder::logstash_forwarder{
  class { 'logstashforwarder': 
     servers  => ['ip-172-26-101-244.eu-west-1.compute.internal:5000'],
     ssl_ca   => '/etc/ssl/certs/logstash.crt',
     require  => Exec['apt_update'],
  }
}

Which is used here (in another file):

class profile::logstash_forwarder::batch inherits profile::logstash_forwarder::logstash_forwarder{
      logstashforwarder::file { 'logback-bo-batch':
    paths  => [
      '/var/log/urms/cgp.bo-batch.log',
],
     fields => { 
       'type' => 'logback',
       'component' => 'bo-batch',
       'environment' => $environment,
     },
  }

  logstashforwarder::file { 'logback-lend-batch':
     paths  => [
       '/var/log/urms/cgp.lend-batch.log',
     ],
     fields => {
         'type' => 'logback',
         'component' => 'lend-batch',
         'environment' => $environment,
     },
 }
}

I appreciate any help!!

Best wishes
LDK


#2

It would probably be helpful if you described what you’re expecting to achieve, and what a “Puppet Inner Class” is - the last time I used puppet, for example, was 0.24.1, so things have changed somewhat :slight_smile:

I’d also recommend you look at https://supermarket.chef.io/cookbooks/logstash-forwarder or https://supermarket.chef.io/cookbooks/logstash , which might be of assistance.


#3

I think the logtash-forwarder from the supermarket will do, thanks!!

I mean classes like this:

class { 'sudo':
     purge               => false,
     config_file_replace => false,
}
  
sudo::conf { 'puppet':
    priority => 10,
    content  => 'ckoidl ALL=(ALL) NOPASSWD: ALL
         mwerner ALL=(ALL) NOPASSWD: ALL',
}

There is a class defined and it is used but I don’t know how to realise that in Chef…


#4

Hi I figured it out.

it gives sudo right to some users.
I use the sudo library from the chef supermarket…

Thanks :slight_smile: