Import classes

hi,

i'm a newbie in foreman and i'd like to import all my classes from
puppet into foreman and manage them with foreman.

I don't use modules and my classes are in /etc/puppet/manifests/
classes, my files are in /etc/puppet/files and templates in /etc/
puppet/templates

how could i do this import?

thanks

Hi,

Foreman relays on using modules, as its a basic requirement if you plan on
using environments.

while its theoretically possible to let Foreman read your manifets (abusing
the $modulepath in the /etc/foreman/settings.yaml file), it is much more
recommended to convert your classes to be used in modules.

plus, I think that the puppetdoc integertaion will not work if you are not
using modules.

Ohad

··· On Wed, Jun 9, 2010 at 12:24 AM, parilyonais wrote:

hi,

i’m a newbie in foreman and i’d like to import all my classes from
puppet into foreman and manage them with foreman.

I don’t use modules and my classes are in /etc/puppet/manifests/
classes, my files are in /etc/puppet/files and templates in /etc/
puppet/templates

how could i do this import?

thanks


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To post to this group, send email to foreman-users@googlegroups.com.
To unsubscribe from this group, send email to
foreman-users+unsubscribe@googlegroups.comforeman-users%2Bunsubscribe@googlegroups.com
.
For more options, visit this group at
http://groups.google.com/group/foreman-users?hl=en.

Hi Ohad,

However, if someone decide to use the infrastructure described in
http://projects.puppetlabs.com/projects/puppet/wiki/Infrastructure_Design_Guidelinesto
use "roles",
those roles could be defined inside manifests dir and then inside the "role"
class file the module(s)
is (are) then included.

This is the example of the url

node 'www1.example42.com' inherits basenode {
include role_webserver # (the role_ prefix is arbitrary and
not strictly necessary)
}
node 'www2.example42.com' inherits basenode {
include role_webserver
}
node 'www3.example42.com' inherits basenode {
include role_webserver
}
node 'lb1.example42.com' inherits basenode {
include role_loadbalancer
}
node 'lb2.example42.com' inherits basenode {
include role_loadbalancer
}

You then define roles in normal classes, with something like:

class role_webserver {
$my_role = "webserver"
include general
include httpd::php
}
class role_loadbalancer {
$my_role = "loadbalancer"
include general
include lvs
}

I am saying this, because in the company that I work, we have adopted this
strategy. I don't know if this
was the best approach, but it was better for us this way. Thus, to import
those "roles" classes inside
foreman I have changed the file app/models/puppetclass.rb as follow:

··· * * * # scans for puppet classes # parameter is the module path # returns an array of puppetclasses objects def self.scanForClasses(path) klasses=Array.new puts "###### Path: #{path}" Dir.glob("#{path}/*/manifests/**/*.pp").each do |manifest| File.read(manifest).each_line do |line| klass=line.match(/^class (\S+).*\{/) klasses << Puppetclass.find_or_create_by_name(klass[1]) if klass end end Dir.glob("#{path}/../manifests/**/*.pp").each do |manifest| File.read(manifest).each_line do |line| klass=line.match(/^class (\S+).*\{/) klasses << Puppetclass.find_or_create_by_name(klass[1]) if klass end end return klasses end *

ok, it may be a better approach… but this worked for me :slight_smile:

Cheers,
Gus

On Tue, Jun 8, 2010 at 11:18 PM, Ohad Levy ohadlevy@gmail.com wrote:

Hi,

Foreman relays on using modules, as its a basic requirement if you plan on
using environments.

while its theoretically possible to let Foreman read your manifets (abusing
the $modulepath in the /etc/foreman/settings.yaml file), it is much more
recommended to convert your classes to be used in modules.

plus, I think that the puppetdoc integertaion will not work if you are not
using modules.

Ohad

On Wed, Jun 9, 2010 at 12:24 AM, parilyonais parilyonais@gmail.comwrote:

hi,

i’m a newbie in foreman and i’d like to import all my classes from
puppet into foreman and manage them with foreman.

I don’t use modules and my classes are in /etc/puppet/manifests/
classes, my files are in /etc/puppet/files and templates in /etc/
puppet/templates

how could i do this import?

thanks


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To post to this group, send email to foreman-users@googlegroups.com.
To unsubscribe from this group, send email to
foreman-users+unsubscribe@googlegroups.comforeman-users%2Bunsubscribe@googlegroups.com
.
For more options, visit this group at
http://groups.google.com/group/foreman-users?hl=en.


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To post to this group, send email to foreman-users@googlegroups.com.
To unsubscribe from this group, send email to
foreman-users+unsubscribe@googlegroups.comforeman-users%2Bunsubscribe@googlegroups.com
.
For more options, visit this group at
http://groups.google.com/group/foreman-users?hl=en.

Hi Gus,

I'm not sure that's really related, the patch you supplied work around the
module path structure, e.g. if your moduledir is /etc/puppet/modules and
inside you have roleA module and roleB module, then it should automatically
find any environments.
in your patch, you tell it to look for /modulepath/…/manifests ?

additionally, you might consider using hostgroups in foreman, they replace
the exact functionality you are referring here below.

Thanks for the patch :slight_smile:
Ohad

··· On Wed, Jun 9, 2010 at 10:56 AM, Gustavo Soares wrote:

Hi Ohad,

However, if someone decide to use the infrastructure described in
http://projects.puppetlabs.com/projects/puppet/wiki/Infrastructure_Design_Guidelinesto use “roles”,
those roles could be defined inside manifests dir and then inside the
"role" class file the module(s)
is (are) then included.

This is the example of the url

node ‘www1.example42.com’ inherits basenode {
include role_webserver # (the role_ prefix is arbitrary and not strictly necessary)
}
node ‘www2.example42.com’ inherits basenode {
include role_webserver
}
node ‘www3.example42.com’ inherits basenode {
include role_webserver
}
node ‘lb1.example42.com’ inherits basenode {
include role_loadbalancer
}
node ‘lb2.example42.com’ inherits basenode {
include role_loadbalancer
}

You then define roles in normal classes, with something like:

class role_webserver {
$my_role = "webserver"
include general
include httpd::php
}
class role_loadbalancer {
$my_role = "loadbalancer"
include general
include lvs
}

I am saying this, because in the company that I work, we have adopted this
strategy. I don’t know if this
was the best approach, but it was better for us this way. Thus, to import
those “roles” classes inside
foreman I have changed the file app/models/puppetclass.rb as follow:
*
*
*

scans for puppet classes

parameter is the module path

returns an array of puppetclasses objects

def self.scanForClasses(path)
klasses=Array.new
puts “###### Path: #{path}“
Dir.glob(”#{path}//manifests/**/.pp”).each do |manifest|
File.read(manifest).each_line do |line|
klass=line.match(/^class (\S+).{/)
klasses << Puppetclass.find_or_create_by_name(klass[1]) if klass
end
end
Dir.glob("#{path}/…/manifests/**/
.pp").each do |manifest|
File.read(manifest).each_line do |line|
klass=line.match(/^class (\S+).*{/)
klasses << Puppetclass.find_or_create_by_name(klass[1]) if klass
end
end
return klasses
end
*

ok, it may be a better approach… but this worked for me :slight_smile:

Cheers,
Gus

On Tue, Jun 8, 2010 at 11:18 PM, Ohad Levy ohadlevy@gmail.com wrote:

Hi,

Foreman relays on using modules, as its a basic requirement if you plan on
using environments.

while its theoretically possible to let Foreman read your manifets
(abusing the $modulepath in the /etc/foreman/settings.yaml file), it is much
more recommended to convert your classes to be used in modules.

plus, I think that the puppetdoc integertaion will not work if you are
not using modules.

Ohad

On Wed, Jun 9, 2010 at 12:24 AM, parilyonais parilyonais@gmail.comwrote:

hi,

i’m a newbie in foreman and i’d like to import all my classes from
puppet into foreman and manage them with foreman.

I don’t use modules and my classes are in /etc/puppet/manifests/
classes, my files are in /etc/puppet/files and templates in /etc/
puppet/templates

how could i do this import?

thanks


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To post to this group, send email to foreman-users@googlegroups.com.
To unsubscribe from this group, send email to
foreman-users+unsubscribe@googlegroups.comforeman-users%2Bunsubscribe@googlegroups.com
.
For more options, visit this group at
http://groups.google.com/group/foreman-users?hl=en.


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To post to this group, send email to foreman-users@googlegroups.com.
To unsubscribe from this group, send email to
foreman-users+unsubscribe@googlegroups.comforeman-users%2Bunsubscribe@googlegroups.com
.
For more options, visit this group at
http://groups.google.com/group/foreman-users?hl=en.


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To post to this group, send email to foreman-users@googlegroups.com.
To unsubscribe from this group, send email to
foreman-users+unsubscribe@googlegroups.comforeman-users%2Bunsubscribe@googlegroups.com
.
For more options, visit this group at
http://groups.google.com/group/foreman-users?hl=en.

yes thank you that's what i did and it work fine.

we don't use modules and documentation for the moment.

We made a basic installation and configuration of puppet and that
makes what we want

··· On 9 juin, 04:18, Ohad Levy wrote: > Hi, > > Foreman relays on using modules, as its a basic requirement if you plan on > using environments. > > while its theoretically possible to let Foreman read your manifets (abusing > the $modulepath in the /etc/foreman/settings.yaml file), it is much more > recommended to convert your classes to be used in modules. > > plus, I think that the puppetdoc integertaion will not work if you are not > using modules. > > Ohad > > On Wed, Jun 9, 2010 at 12:24 AM, parilyonais wrote: > > hi, > > > i'm a newbie in foreman and i'd like to import all my classes from > > puppet into foreman and manage them with foreman. > > > I don't use modules and my classes are in /etc/puppet/manifests/ > > classes, my files are in /etc/puppet/files and templates in /etc/ > > puppet/templates > > > how could i do this import? > > > thanks > > > -- > > You received this message because you are subscribed to the Google Groups > > "Foreman users" group. > > To post to this group, send email to foreman-users@googlegroups.com. > > To unsubscribe from this group, send email to > > foreman-users+unsubscribe@googlegroups.com > > . > > For more options, visit this group at > >http://groups.google.com/group/foreman-users?hl=en.

Hi,

All my modules are inside /etc/puppet/modules

I have tried to create a module to the roles, but I think that due to the
order that the modules were loaded, puppet couldn't find the "role classes".
So, I put them inside the manifest dir and worked.

Yeah, I could use the hostgroup functionality, but since I am porting my
previous install I am trying not to change this, in case I need to turn off
external nodes.

Actually I am using hostgroup to implement some node inheritance within
puppet's external node. :slight_smile:

Since we are talking about this, is there a way to import the content of
nodes.pp file inside foreman?

Cheers,
Gus

··· On Wed, Jun 9, 2010 at 12:10 AM, Ohad Levy wrote:

Hi Gus,

I’m not sure that’s really related, the patch you supplied work around the
module path structure, e.g. if your moduledir is /etc/puppet/modules and
inside you have roleA module and roleB module, then it should automatically
find any environments.
in your patch, you tell it to look for /modulepath/…/manifests ?

additionally, you might consider using hostgroups in foreman, they replace
the exact functionality you are referring here below.

Thanks for the patch :slight_smile:
Ohad

On Wed, Jun 9, 2010 at 10:56 AM, Gustavo Soares gustavosoares@gmail.comwrote:

Hi Ohad,

However, if someone decide to use the infrastructure described in
http://projects.puppetlabs.com/projects/puppet/wiki/Infrastructure_Design_Guidelinesto use “roles”,
those roles could be defined inside manifests dir and then inside the
"role" class file the module(s)
is (are) then included.

This is the example of the url

node ‘www1.example42.com’ inherits basenode {
include role_webserver # (the role_ prefix is arbitrary and not strictly necessary)
}
node ‘www2.example42.com’ inherits basenode {
include role_webserver
}
node ‘www3.example42.com’ inherits basenode {
include role_webserver
}
node ‘lb1.example42.com’ inherits basenode {
include role_loadbalancer
}
node ‘lb2.example42.com’ inherits basenode {
include role_loadbalancer
}

You then define roles in normal classes, with something like:

class role_webserver {
$my_role = "webserver"
include general
include httpd::php
}
class role_loadbalancer {
$my_role = "loadbalancer"
include general
include lvs
}

I am saying this, because in the company that I work, we have adopted this
strategy. I don’t know if this
was the best approach, but it was better for us this way. Thus, to import
those “roles” classes inside
foreman I have changed the file app/models/puppetclass.rb as follow:
*
*
*

scans for puppet classes

parameter is the module path

returns an array of puppetclasses objects

def self.scanForClasses(path)
klasses=Array.new
puts “###### Path: #{path}“
Dir.glob(”#{path}//manifests/**/.pp”).each do |manifest|
File.read(manifest).each_line do |line|
klass=line.match(/^class (\S+).{/)
klasses << Puppetclass.find_or_create_by_name(klass[1]) if klass
end
end
Dir.glob("#{path}/…/manifests/**/
.pp").each do |manifest|
File.read(manifest).each_line do |line|
klass=line.match(/^class (\S+).*{/)
klasses << Puppetclass.find_or_create_by_name(klass[1]) if klass
end
end
return klasses
end
*

ok, it may be a better approach… but this worked for me :slight_smile:

Cheers,
Gus

On Tue, Jun 8, 2010 at 11:18 PM, Ohad Levy ohadlevy@gmail.com wrote:

Hi,

Foreman relays on using modules, as its a basic requirement if you plan
on using environments.

while its theoretically possible to let Foreman read your manifets
(abusing the $modulepath in the /etc/foreman/settings.yaml file), it is much
more recommended to convert your classes to be used in modules.

plus, I think that the puppetdoc integertaion will not work if you are
not using modules.

Ohad

On Wed, Jun 9, 2010 at 12:24 AM, parilyonais parilyonais@gmail.comwrote:

hi,

i’m a newbie in foreman and i’d like to import all my classes from
puppet into foreman and manage them with foreman.

I don’t use modules and my classes are in /etc/puppet/manifests/
classes, my files are in /etc/puppet/files and templates in /etc/
puppet/templates

how could i do this import?

thanks


You received this message because you are subscribed to the Google
Groups “Foreman users” group.
To post to this group, send email to foreman-users@googlegroups.com.
To unsubscribe from this group, send email to
foreman-users+unsubscribe@googlegroups.comforeman-users%2Bunsubscribe@googlegroups.com
.
For more options, visit this group at
http://groups.google.com/group/foreman-users?hl=en.


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To post to this group, send email to foreman-users@googlegroups.com.
To unsubscribe from this group, send email to
foreman-users+unsubscribe@googlegroups.comforeman-users%2Bunsubscribe@googlegroups.com
.
For more options, visit this group at
http://groups.google.com/group/foreman-users?hl=en.


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To post to this group, send email to foreman-users@googlegroups.com.
To unsubscribe from this group, send email to
foreman-users+unsubscribe@googlegroups.comforeman-users%2Bunsubscribe@googlegroups.com
.
For more options, visit this group at
http://groups.google.com/group/foreman-users?hl=en.


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To post to this group, send email to foreman-users@googlegroups.com.
To unsubscribe from this group, send email to
foreman-users+unsubscribe@googlegroups.comforeman-users%2Bunsubscribe@googlegroups.com
.
For more options, visit this group at
http://groups.google.com/group/foreman-users?hl=en.

> Hi,
>
> All my modules are inside /etc/puppet/modules
>
> I have tried to create a module to the roles, but I think that due to the
> order that the modules were loaded, puppet couldn't find the "role classes".
> So, I put them inside the manifest dir and worked.
>
> Yeah, I could use the hostgroup functionality, but since I am porting my
> previous install I am trying not to change this, in case I need to turn off
> external nodes.
>
> Actually I am using hostgroup to implement some node inheritance within
> puppet's external node. :slight_smile:
>
> Since we are talking about this, is there a way to import the content of
> nodes.pp file inside foreman?
>
> not directly, but doing a s/node/class/g is a good starting point :slight_smile:

> Cheers,
> Gus
>
>
>
>> Hi Gus,
>>
>> I'm not sure that's really related, the patch you supplied work around the
>> module path structure, e.g. if your moduledir is /etc/puppet/modules and
>> inside you have roleA module and roleB module, then it should automatically
>> find any environments.
>> in your patch, you tell it to look for /modulepath/…/manifests ?
>>
>> additionally, you might consider using hostgroups in foreman, they replace
>> the exact functionality you are referring here below.
>>
>> Thanks for the patch :slight_smile:
>> Ohad
>>
>>
>>> Hi Ohad,
>>>
>>> However, if someone decide to use the infrastructure described in
>>> http://projects.puppetlabs.com/projects/puppet/wiki/Infrastructure_Design_Guidelinesto use "roles",
>>> those roles could be defined inside manifests dir and then inside the
>>> "role" class file the module(s)
>>> is (are) then included.
>>>
>>> This is the example of the url
>>>
>>> node 'www1.example42.com' inherits basenode {
>>> include role_webserver # (the role_ prefix is arbitrary and not strictly necessary)
>>> }
>>> node 'www2.example42.com' inherits basenode {
>>> include role_webserver
>>> }
>>> node 'www3.example42.com' inherits basenode {
>>> include role_webserver
>>> }
>>> node 'lb1.example42.com' inherits basenode {
>>> include role_loadbalancer
>>> }
>>> node 'lb2.example42.com' inherits basenode {
>>> include role_loadbalancer
>>> }
>>>
>>>
>>> You then define roles in normal classes, with something like:
>>>
>>> class role_webserver {
>>> $my_role = "webserver"
>>> include general
>>> include httpd::php
>>> }
>>> class role_loadbalancer {
>>> $my_role = "loadbalancer"
>>> include general
>>> include lvs
>>> }
>>>
>>>
>>> I am saying this, because in the company that I work, we have adopted
>>> this strategy. I don't know if this
>>> was the best approach, but it was better for us this way. Thus, to import
>>> those "roles" classes inside
>>> foreman I have changed the file app/models/puppetclass.rb as follow:
>>> *
>>> *
>>> *
>>> # scans for puppet classes
>>> # parameter is the module path
>>> # returns an array of puppetclasses objects
>>> def self.scanForClasses(path)
>>> klasses=Array.new
>>> puts "###### Path: #{path}"
>>> Dir.glob("#{path}//manifests/**/.pp").each do |manifest|
>>> File.read(manifest).each_line do |line|
>>> klass=line.match(/^class (\S+).{/)
>>> klasses << Puppetclass.find_or_create_by_name(klass[1]) if klass
>>> end
>>> end
>>> Dir.glob("#{path}/…/manifests/**/
.pp").each do |manifest|
>>> File.read(manifest).each_line do |line|
>>> klass=line.match(/^class (\S+).*{/)
>>> klasses << Puppetclass.find_or_create_by_name(klass[1]) if klass
>>> end
>>> end
>>> return klasses
>>> end
>>> *
>>>
>>> ok, it may be a better approach… but this worked for me :slight_smile:
>>>
>>> Cheers,
>>> Gus
>>>
>>>
>>>> Hi,
>>>>
>>>> Foreman relays on using modules, as its a basic requirement if you plan
>>>> on using environments.
>>>>
>>>> while its theoretically possible to let Foreman read your manifets
>>>> (abusing the $modulepath in the /etc/foreman/settings.yaml file), it is much
>>>> more recommended to convert your classes to be used in modules.
>>>>
>>>> plus, I think that the puppetdoc integertaion will not work if you are
>>>> not using modules.
>>>>
>>>> Ohad
>>>>
>>>>
>>>>
>>>>> hi,
>>>>>
>>>>> i'm a newbie in foreman and i'd like to import all my classes from
>>>>> puppet into foreman and manage them with foreman.
>>>>>
>>>>> I don't use modules and my classes are in /etc/puppet/manifests/
>>>>> classes, my files are in /etc/puppet/files and templates in /etc/
>>>>> puppet/templates
>>>>>
>>>>> how could i do this import?
>>>>>
>>>>> thanks
>>>>>
>>>>> –
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Foreman users" group.
>>>>> To post to this group, send email to foreman-users@googlegroups.com.
>>>>> To unsubscribe from this group, send email to
>>>>> foreman-users+unsubscribe@googlegroups.com<foreman-users%2Bunsubscribe@googlegroups.com>
>>>>> .
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/foreman-users?hl=en.
>>>>>
>>>>>
>>>> –
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Foreman users" group.
>>>> To post to this group, send email to foreman-users@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> foreman-users+unsubscribe@googlegroups.com<foreman-users%2Bunsubscribe@googlegroups.com>
>>>> .
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/foreman-users?hl=en.
>>>>
>>>
>>> –
>>> You received this message because you are subscribed to the Google Groups
>>> "Foreman users" group.
>>> To post to this group, send email to foreman-users@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> foreman-users+unsubscribe@googlegroups.com<foreman-users%2Bunsubscribe@googlegroups.com>
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/foreman-users?hl=en.
>>>
>>
>> –
>> You received this message because you are subscribed to the Google Groups
>> "Foreman users" group.
>> To post to this group, send email to foreman-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> foreman-users+unsubscribe@googlegroups.com<foreman-users%2Bunsubscribe@googlegroups.com>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/foreman-users?hl=en.
>>
>
> –
> You received this message because you are subscribed to the Google Groups
> "Foreman users" group.
> To post to this group, send email to foreman-users@googlegroups.com.
> To unsubscribe from this group, send email to
> foreman-users+unsubscribe@googlegroups.com<foreman-users%2Bunsubscribe@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/foreman-users?hl=en.
>

··· On Wed, Jun 9, 2010 at 9:22 PM, Gustavo Soares wrote: > On Wed, Jun 9, 2010 at 12:10 AM, Ohad Levy wrote: >> On Wed, Jun 9, 2010 at 10:56 AM, Gustavo Soares wrote: >>> On Tue, Jun 8, 2010 at 11:18 PM, Ohad Levy wrote: >>>> On Wed, Jun 9, 2010 at 12:24 AM, parilyonais wrote: