Correctly determine the server id

Due to using an undefined variable when determining the server id,
the client manifest was writing an incorrectly formatted zanata.ini
file. Furthermore, the intent of the change did not go far enough,
since it would not strip off the URI scheme or port. Due to the
complexities of parsing URIs in regular expressions, use a Puppet
function for the heavy lifting.

Change-Id: I754ee54f805c91f5548b2cf270b23c68eed3959c
This commit is contained in:
Steve Kowalik 2015-06-11 16:12:36 +10:00
parent 81545418af
commit 9e0edabed4
3 changed files with 15 additions and 5 deletions

View File

@ -0,0 +1,10 @@
require 'uri'
module Puppet::Parser::Functions
newfunction(:parse_server_id, :type => :rvalue) do |args|
uri = URI.parse(args[0])
unless uri.host.nil?
uri.host.gsub(/\./, '_')
end
end
end

View File

@ -25,7 +25,7 @@ class zanata::client(
$homedir = '/home/jenkins/',
) {
$serverid = regsubst($server, '\.', '_', 'G')
$server_id = parse_server_id($server_url)
file { '/opt/zanata':
ensure => directory,
@ -77,7 +77,7 @@ class zanata::client(
ensure => present,
}
file { "${homedir}/.config/zanata.ini": # XXX needs to be in homedir
file { "${homedir}/.config/zanata.ini":
ensure => present,
owner => $user,
group => $group,

View File

@ -1,4 +1,4 @@
[servers]
<%= @serverid -%>.url=<%= @server_url %>
<%= @serverid -%>.username=<%= @server_user %>
<%= @serverid -%>.key=<%= @server_api_key %>
<%= @server_id -%>.url=<%= @server_url %>
<%= @server_id -%>.username=<%= @server_user %>
<%= @server_id -%>.key=<%= @server_api_key %>