Add server override feature for cobbler

Needed for cobbler, which requires a local
IP in server field for its own operations,
but connecting clients need IP of master host.

blueprint fuel-containerization-of-services

Change-Id: I6ba03ca7f74ebc2b1175aa07369d580b29472693
This commit is contained in:
Matthew Mosesohn 2014-04-13 19:37:34 +04:00
parent 101f3645ea
commit a4b02fccdd
6 changed files with 25 additions and 5 deletions

View File

@ -33,6 +33,14 @@ Puppet::Type.type(:cobbler_profile).provide(:default) do
end
end
def server
if @resource[:server].size > 0
"--server=#{@resource[:server]}"
else
""
end
end
def kickstart
if @resource[:kickstart].size > 0
"--kickstart=#{@resource[:kickstart]}"
@ -50,7 +58,7 @@ Puppet::Type.type(:cobbler_profile).provide(:default) do
end
def find_profile_full
profile, stderr = Open3.popen3("cobbler profile find --name=#{@resource[:name]} --distro=#{@resource[:distro]} --enable-menu=#{enable_menu} --kopts=\"#{@resource[:kopts]}\" #{kickstart} #{ksmeta}")[1,2]
profile, stderr = Open3.popen3("cobbler profile find --name=#{@resource[:name]} --distro=#{@resource[:distro]} --enable-menu=#{enable_menu} --kopts=\"#{@resource[:kopts]}\" #{server} #{kickstart} #{ksmeta}")[1,2]
if err = stderr.gets
raise Pupppet::Error, err
else
@ -69,7 +77,7 @@ Puppet::Type.type(:cobbler_profile).provide(:default) do
def update_profile
subcommand = find_profile_name ? 'edit' : 'add'
stderr = Open3.popen3("cobbler profile #{subcommand} --name=#{@resource[:name]} --distro=#{@resource[:distro]} --enable-menu=#{enable_menu} --kopts=\"#{@resource[:kopts]}\" #{kickstart} #{ksmeta}")[2]
stderr = Open3.popen3("cobbler profile #{subcommand} --name=#{@resource[:name]} --distro=#{@resource[:distro]} --enable-menu=#{enable_menu} --kopts=\"#{@resource[:kopts]}\" #{server} #{kickstart} #{ksmeta}")[2]
if err = stderr.gets
raise Pupppet::Error, err
end

View File

@ -34,6 +34,11 @@ Puppet::Type.newtype(:cobbler_profile) do
newvalues(:true, :false)
end
newparam(:server) do
desc "Override server address"
newvalues(/^\S+$/)
end
newparam(:kickstart) do
desc "Path to kickstart file"
newvalues(/^(\/[^\/]+)*$/)

View File

@ -220,7 +220,7 @@ gem install rethtool --version 0.0.3 --source <%= @gem_source %> --no-ri --no
mkdir -p /etc/nailgun-agent/
cat > /etc/nailgun-agent/config.yaml << EOA
---
url: '<%= scope.lookupvar('nailgun::nailgun_api_url') %>'
url: '<%= scope.lookupvar('nailgun::cobbler::nailgun_api_url') %>'
EOA
# COBBLER EMBEDDED SNIPPET: 'kernel_lt_if_enabled'

View File

@ -118,7 +118,7 @@ $SNIPPET('ntp_to_masternode_ubuntu')
echo -e "nf_conntrack_ipv4\nnf_conntrack_ipv6" >> /target/etc/modules && \
echo -e "net.nf_conntrack_max=1048576" >> /target/etc/sysctl.conf && \
mkdir -p /target/etc/nailgun-agent && \
echo -e "---\nurl: '<%= @nailgun_api_url %>'" > /target/etc/nailgun-agent/config.yaml && \
echo -e "---\nurl: '<%= scope.lookupvar('nailgun::cobbler::nailgun_api_url') %>'" > /target/etc/nailgun-agent/config.yaml && \
echo target > /target/etc/nailgun_systemtype && \
echo 'APT::Get::AllowUnauthenticated 1;' > /target/etc/apt/apt.conf.d/02mirantis-allow-unsigned && \
echo 'deb http://@@server@@:8080/ubuntu/fuelweb/x86_64 precise main' > /target/etc/apt/sources.list && \

View File

@ -29,6 +29,7 @@ node default {
$cobbler_url = "http://${::fuel_settings['ADMIN_NETWORK']['ipaddress']}/cobbler_api"
$cobbler_user = "cobbler"
$cobbler_password = "cobbler"
$nailgun_api_url = "http://${::fuel_settings['ADMIN_NETWORK']['ipaddress']}:8000/api"
if $production == "docker-build" {
$cobbler_host = $::ipaddress
} else {

View File

@ -14,7 +14,7 @@ class nailgun::cobbler(
$dhcp_netmask,
$dhcp_gateway = $ipaddress,
$dhcp_interface,
$nailgun_api_url = $::ipaddress,
$nailgun_api_url = "http://${::ipaddress}:8000/api",
# default password is 'r00tme'
$ks_encrypted_root_password = "\$6\$tCD3X7ji\$1urw6qEMDkVxOkD33b4TpQAjRiCeDZx0jmgMhDYhfB9KuGfqO9OcMaKyUxnGGWslEDQ4HxTw7vcAMP85NxQe61",
@ -27,6 +27,9 @@ class nailgun::cobbler(
Class["::cobbler"] ->
Anchor<| title == "nailgun-cobbler-end" |>
#Set real_server so Cobbler identifies its own IP correctly in Docker
$real_server = $next_server
class { "::cobbler":
server => $server,
production => $production,
@ -139,6 +142,7 @@ class nailgun::cobbler(
distro => "centos-x86_64",
ksmeta => "",
menu => true,
server => $real_server,
require => Cobbler_distro["centos-x86_64"],
}
@ -148,6 +152,7 @@ class nailgun::cobbler(
distro => "ubuntu_1204_x86_64",
ksmeta => "",
menu => true,
server => $real_server,
require => Cobbler_distro["ubuntu_1204_x86_64"],
}
@ -168,6 +173,7 @@ class nailgun::cobbler(
kickstart => "",
kopts => "biosdevname=0 url=http://${::fuel_settings['ADMIN_NETWORK']['ipaddress']}:8000/api",
ksmeta => "",
server => $real_server,
require => Cobbler_distro["bootstrap"],
}