Skip to content

Commit

Permalink
Merge pull request #185 from alemonmk/master
Browse files Browse the repository at this point in the history
[consul] Set extra cmdline options with package parameters
  • Loading branch information
flcdrg committed Sep 13, 2024
2 parents 27b5921 + 1fd095b commit 585c02e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
11 changes: 5 additions & 6 deletions consul/consul.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@ The package parameters can be set -

* `/noservice` - Disables installation of Windows service
* `/apiaddr` - Sets environment variable `CONSUL_HTTP_ADDR` for easy execute commands on remote agent
* `/agentargs` - Sets up [Consul agent options via commandline](https://developer.hashicorp.com/consul/docs/agent/config/cli-flags) for Consul agent service

These parameters can be passed to the installer with the use of `--params`.
For example: `--params="'/noservice /apiaddr=http://10.0.0.1:8500'"`.
For example:
* `--params="'/noservice /apiaddr=http://10.0.0.1:8500'"`
* `--params="'/agentargs=""-config-file %PROGRAMDATA%\consul\dsc-config\default.json -client 10.0.0.1""'"` (be cautious of quotes)

#### Installer Arguments
Consul agent runtime options can also be set via `--ia`: https://developer.hashicorp.com/consul/docs/agent/config/cli-flags

For example: `--ia='-config-file ""%PROGRAMDATA%\consul\dsc-config\default.json/"" -client 10.0.0.1'`
Or better, drop a `config.hcl` into `%PROGRAMDATA%\consul\config` with your configuration.
For setting Consul agent CLI options, it is better dropping a `config.hcl` into `%PROGRAMDATA%\consul\config` instead of setting them with package parameters.
</description><releaseNotes><![CDATA[### 1.19.2 (August 26, 2024)
SECURITY:
Expand Down
5 changes: 3 additions & 2 deletions consul/tools/chocolateyInstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ if (-not ($packageParameters["noservice"])) {
$serviceLogDirectory = "$serviceInstallationDirectory\logs"
$serviceConfigDirectory = "$serviceInstallationDirectory\config"
$serviceDataDirectory = "$serviceInstallationDirectory\data"
$packageParameters = $env:chocolateyPackageParameters

# Create Service Directories
Write-Host "Creating $serviceLogDirectory"
Expand Down Expand Up @@ -71,9 +70,11 @@ if (-not ($packageParameters["noservice"])) {
$service.delete() | Out-Null
}

$serviceArgs = $packageParameters["agentargs"]
$serviceArgs = "agent -ui -config-dir=$serviceConfigDirectory -data-dir=$serviceDataDirectory $serviceArgs"
Write-Host "Installing service: $serviceName"
# Install the service
& $wrapperExe install $serviceName $(Join-Path $toolsPath "consul.exe") "agent -ui -config-dir=$serviceConfigDirectory -data-dir=$serviceDataDirectory $packageParameters" | Out-Null
& $wrapperExe install $serviceName $(Join-Path $toolsPath "consul.exe") $serviceArgs | Out-Null
& $wrapperExe set $serviceName AppEnvironmentExtra GOMAXPROCS=$env:NUMBER_OF_PROCESSORS | Out-Null
& $wrapperExe set $serviceName ObjectName NetworkService | Out-Null
& $wrapperExe set $serviceName AppStdout "$serviceLogDirectory\consul-output.log" | Out-Null
Expand Down

0 comments on commit 585c02e

Please sign in to comment.