diff --git a/lib/puppet/parser/functions/parse_server_id.rb b/lib/puppet/parser/functions/parse_server_id.rb new file mode 100644 index 0000000..be131d1 --- /dev/null +++ b/lib/puppet/parser/functions/parse_server_id.rb @@ -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 diff --git a/manifests/client.pp b/manifests/client.pp index 64a8aab..11a8296 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -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, diff --git a/templates/zanata.ini.erb b/templates/zanata.ini.erb index ca65567..d90e3fd 100644 --- a/templates/zanata.ini.erb +++ b/templates/zanata.ini.erb @@ -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 %>