Skip to content

Commit

Permalink
handle presence of pool in the service name
Browse files Browse the repository at this point in the history
  • Loading branch information
camara-tech committed Nov 20, 2019
1 parent d837fbc commit 80eb948
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions manifests/agent.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# The name of the Azure Pipelines or VSTS account.
# @param agent_name
# Unique name to identify the agent
# @param package_src
# @param package_src
# Source of the agent installation package. Supports all URIs supported by the archive module.
# @param package_sha512
# SHA-512 hash of the installation package, for verification.
Expand Down Expand Up @@ -78,7 +78,7 @@
# @param deployment_group_tags
# Tags for a deployment group agent.
# @param archive_name
# Destination filename for agent installation package.
# Destination filename for agent installation package.
# @param config_script
# Name of script file used to install the agent.
# @param manage_service
Expand Down Expand Up @@ -355,14 +355,18 @@
require => Archive["${install_path}/${archive_name}"],
}
if $facts['kernel'] == 'Linux' and $run_as_service {
$service_name_part = $pool ? {
undef => "${instance_name}.${agent_name}",
default => "${instance_name}.${pool}.${agent_name}"
}
exec {"${install_path}/svc.sh install ${service_user}":
onlyif => "systemctl list-unit-files \"$(systemd-escape --path vsts.agent.${instance_name}.${agent_name}.service)\" | grep \"$(systemd-escape --path vsts.agent.${instance_name}.${agent_name}.service)\"",
onlyif => "/bin/systemctl list-unit-files \"$(/bin/systemd-escape --path vsts.agent.${service_name_part}.service)\" | /bin/grep \"$(/bin/systemd-escape --path vsts.agent.${service_name_part}.service)\"",
user => 'root',
cwd => $install_path,
require => Exec["${install_path}/${config_script}"],
}
if $manage_service {
$escaped_dashes_in_service_name = regsubst("vsts.agent.${instance_name}.${agent_name}.service", '-', '\x2d', 'G')
$escaped_dashes_in_service_name = regsubst("vsts.agent.${service_name_part}.service", '-', '\x2d', 'G')
$escaped_spaces_in_service_name = regsubst($escaped_dashes_in_service_name, ' ', '\x20', 'G')
$escaped_slashes_in_service_name = regsubst($escaped_spaces_in_service_name, '/', '-', 'G')
$escaped_service_name = $escaped_slashes_in_service_name
Expand Down

0 comments on commit 80eb948

Please sign in to comment.