Skip to content

Fixed network interface settings handling and updated documentation #3

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
170 changes: 168 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* [Setup requirements](#setup-requirements)
* [Beginning with cobbler](#beginning-with-cobbler)
4. [Usage](#usage)
* [Sample Hiera YAML configuration file](#sample-hiera-yaml-configuration-file)
5. [Reference](#reference)
5. [Limitations](#limitations)

Expand Down Expand Up @@ -142,9 +143,175 @@ $systems = {
hostname => 'testhost01',
}

create_resources('cobble_system', $systems)
create_resources('cobbler_system', $systems)
```

### Sample Hiera YAML configuration file

The Hiera configuration file typically looks like the following:

```yaml
cobbler::settings:
auth_token_expiration: 3600
bind_master: '127.0.0.1'
client_use_https: 0
client_use_localhost: 0
default_name_servers: '192.168.1.100'
default_password_crypted: '$1$alongpas$dd8QvxAdUttv/EO43ZxMy0'
http_port: 80
next_server: '192.168.1.1'
puppet_auto_setup: 1
puppet_server: '192.168.1.1'
puppet_version: 3
pxe_just_once: 0
restart_dhcp: 1
restart_dns: 1
server: '192.168.1.1'
xmlrpc_port: 25151

cobbler::modules_settings:
authentication:
module: 'authn_configfile'
authorization:
module: 'authz_allowall'
dhcp:
module: 'manage_isc'
dns:
module: 'manage_bind'
tftpd:
module: 'manage_in_tftpd'

cobbler::distros:
CentOS6:
initrd: '/var/lib/cobbler/pxeboot/initrd.img'
kernel: '/var/lib/cobbler/pxeboot/vmlinuz'
ksmeta:
tree: 'http://192.168.1.1/mirror.centos.org/6/os/x86_64/'
name: 'CentOS6'

cobbler::repos:
CentOS-6-Base:
breed: 'yum'
mirror: 'http://192.168.1.1/mirror.centos.org/6/os/x86_64/'
mirror_locally: "false"
name: 'CentOS-6-Base'
CentOS-6-Extras:
breed: 'yum'
mirror: 'http://192.168.1.1/mirror.centos.org/6/extras/x86_64/'
mirror_locally: "false"
name: 'CentOS-6-Extras'
CentOS-6-Updates:
breed: 'yum'
mirror: 'http://192.168.1.1/mirror.centos.org/6/updates/x86_64/'
mirror_locally: "false"
name: 'CentOS-6-Updates'
Extra-Packages-for-Enterprise-Linux-6:
breed: 'yum'
mirror: 'http://192.168.1.1/dl.fedoraproject.org/pub/epel/6/x86_64'
mirror_locally: "false"
name: 'Extra-Packages-for-Enterprise-Linux-6'
IUS-Community-Packages-for-Enterprise-Linux-6:
breed: 'yum'
mirror: 'http://192.168.1.1/ius/stable/Redhat/6/x86_64'
mirror_locally: "false"
name: 'IUS-Community-Packages-for-Enterprise-Linux-6'
Puppet-Labs-Dependencies-El-6:
breed: 'yum'
mirror: 'http://192.168.1.1/yum.puppetlabs.com/el/6/dependencies/x86_64'
mirror_locally: "false"
name: 'Puppet-Labs-Dependencies-El-6'
Puppet-Labs-Devel-El-6:
breed: 'yum'
mirror: 'http://192.168.1.1/yum.puppetlabs.com/el/6/devel/x86_64'
mirror_locally: "false"
name: 'Puppet-Labs-Devel-El-6'
Puppet-Labs-Products-El-6:
breed: 'yum'
mirror: 'http://192.168.1.1/yum.puppetlabs.com/el/6/products/x86_64'
mirror_locally: "false"
name: 'Puppet-Labs-Products-El-6'
RPMFusion-free-6:
breed: 'yum'
mirror: 'http://192.168.1.1/rpmfusion/free/el/updates/6/x86_64'
mirror_locally: "false"
name: 'RPMFusion-free-6'

cobbler::images: []

cobbler::profiles:
server:
dhcp_tag: 'default'
distro: 'CentOS6'
kickstart: '/var/lib/cobbler/kickstarts/sample.ks'
kopts:
ksdevice: 'link'
ksmeta:
puppet_server: '192.168.1.123'
tree: 'http://192.168.1.1/mirror.centos.org/6/os/x86_64'
name: 'server'
name_servers:
- '192.168.1.100'
- '192.168.1.200'
name_servers_search:
- 'testdomain.com'
repos:
- 'CentOS-6-Base'
- 'CentOS-6-Extras'
- 'CentOS-6-Updates'
- 'IUS-Community-Packages-for-Enterprise-Linux-6'
- 'RPMFusion-free-6'
- 'Puppet-Labs-Dependencies-El-6'
- 'Puppet-Labs-Devel-El-6'
- 'Puppet-Labs-Products-El-6'

cobbler::systems:
server1.testdomain.com:
gateway: '192.168.1.1'
interfaces:
eth0:
ip_address: '192.168.1.2'
mac_address: '00:11:22:33:44:55'
netmask: '255.255.255.0'
name: 'server1.testdomain.com'
profile: 'server'
server2.testdomain.com:
gateway: '192.168.1.1'
interfaces:
eth0:
ip_address: '192.168.1.3'
mac_address: '11:22:33:44:55:66'
netmask: '255.255.255.0'
static_routes: '192.168.2.0/24:192.168.1.1,192.168.3.0/24:192.168.1.1'
name: 'server2.testdomain.com'
profile: 'server'
```

Then the Puppet code is calling those settings via Cobbler Puppet provider:

```puppet
$cobbler_settings = hiera('cobbler::settings')
$cobbler_modules_settings = hiera('cobbler::modules_settings')
$cobbler_distros = hiera('cobbler::distros')
$cobbler_repos = hiera('cobbler::repos')
$cobbler_profiles = hiera('cobbler::profiles')
$cobbler_systems = hiera('cobbler::systems')

class { 'cobbler':
cobbler_config => $cobbler_settings,
cobbler_modules_config => $cobbler_modules_settings,
}

create_resources('cobbler_distro', $cobbler_distros)

create_resources('cobbler_repo', $cobbler_repos)

create_resources('cobbler_profile', $cobbler_profiles)

create_resources('cobbler_system', $cobbler_systems)

```


## Reference

That module contains:
Expand All @@ -161,4 +328,3 @@ That module contains:
* setsebool -P httpd_can_network_connect_cobbler 1
* setsebool -P httpd_serve_cobbler_files 1
* semanage fcontext -a -t cobbler_var_lib_t "/var/lib/tftpboot/boot(/.*)?"

3 changes: 0 additions & 3 deletions lib/puppet/provider/cobbler_distro/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ def create
end
end

cobbler("sync")
@property_hash[:ensure] = :present
end

Expand All @@ -95,7 +94,6 @@ def destroy
"--name=#{@resource[:name]}"
]
)
cobbler('sync')
@property_hash.clear
end

Expand Down Expand Up @@ -127,7 +125,6 @@ def set_field(what, value)
"--#{what.tr('_','-')}=" + value.to_s
]
)
cobbler('sync')
@property_hash[what] = value
end

Expand Down
2 changes: 0 additions & 2 deletions lib/puppet/provider/cobbler_profile/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ def create
end
end

cobbler("sync")
@property_hash[:ensure] = :present
end

Expand All @@ -106,7 +105,6 @@ def set_field(what, value)
"--#{what.tr('_','-')}=" + value.to_s
]
)
cobbler('sync')
@property_hash[what] = value
end

Expand Down
2 changes: 0 additions & 2 deletions lib/puppet/provider/cobbler_repo/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ def create
end
end

cobbler("sync")
self.reposync
@property_hash[:ensure] = :present
end
Expand All @@ -97,7 +96,6 @@ def set_field(what, value)
"--#{what.tr('_','-')}=" + value.to_s
]
)
cobbler('sync')
@property_hash[what] = value
end

Expand Down
3 changes: 0 additions & 3 deletions lib/puppet/provider/cobbler_system/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ def create
self.interfaces = @resource.should(:interfaces)
end

cobbler("sync")
@property_hash[:ensure] = :present
end

Expand All @@ -94,7 +93,6 @@ def set_field(what, value)
"--#{what.tr('_','-')}=" + value.to_s
]
)
cobbler('sync')
@property_hash[what] = value
end

Expand Down Expand Up @@ -148,7 +146,6 @@ def interfaces=(value)
end
cobbler(cmd_args)
end
cobbler('sync')
end

end
7 changes: 7 additions & 0 deletions lib/puppet/type/cobbler_distro.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@

ensurable

def initialize(*args)
super
self[:notify] = [
"Class[Cobbler::Service]",
].select { |ref| catalog.resource(ref) }
end

# Parameters
newparam(:name, :namevar => true) do
desc "A string identifying the distribution"
Expand Down
7 changes: 7 additions & 0 deletions lib/puppet/type/cobbler_profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@

ensurable

def initialize(*args)
super
self[:notify] = [
"Class[Cobbler::Service]",
].select { |ref| catalog.resource(ref) }
end

# Parameters
newparam(:name, :namevar => true) do
desc "A string identifying the profile"
Expand Down
13 changes: 9 additions & 4 deletions lib/puppet/type/cobbler_repo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@

ensurable

def initialize(*args)
super
self[:notify] = [
"Class[Cobbler::Service]",
].select { |ref| catalog.resource(ref) }
end

# Parameters
newparam(:name, :namevar => true) do
desc "A string identifying the repo"
munge do |value|
value.downcase
end

def insync?(is)
is.downcase == should.downcase
is == should
end
end

Expand Down
11 changes: 10 additions & 1 deletion lib/puppet/type/cobbler_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@

ensurable

def initialize(*args)
super
self[:notify] = [
"Class[Cobbler::Service]",
].select { |ref| catalog.resource(ref) }
end

# Parameters
newparam(:name, :namevar => true) do
desc "A string identifying the system"
Expand Down Expand Up @@ -49,7 +56,9 @@ def insync?(is)
end
# Check interface parameters
params.each do |param, value|
unless is[interface][param] == value
# Ignore interface key name, used only as cobbler argument
next if param == "interface"
unless is[interface][param].to_s == value
return false
end
end
Expand Down
4 changes: 4 additions & 0 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,8 @@
ensure => $service_ensure,
enable => $service_enable,
}
exec {'cobbler_sync':
refreshonly => true,
command => "/usr/bin/cobbler sync",
}
}