Skip to content

Commit 2703e8e

Browse files
authored
Merge pull request #121 from jpogran/GH-120-configurable-puppet-agent-dir
(GH-120) Configurable Puppet Agent directory
2 parents b13f210 + 682e795 commit 2703e8e

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

client/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@
166166
"type": "string",
167167
"default": "normal",
168168
"description": "Set the minimum log level that the user will see on the Puppet OutputChannel (Allowed values: verbose, debug, normal, warning, error)"
169+
},
170+
"puppet.puppetAgentDir": {
171+
"type": "string",
172+
"default": "normal",
173+
"description": "The fully qualified path to the Puppet agent install directory. For example: 'C:\\Program Files\\Puppet Labs\\Puppet' or '/opt/puppetlabs/puppet'"
169174
}
170175
}
171176
}

client/src/connection.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export interface IConnectionConfiguration {
3131
timeout: number;
3232
preLoadPuppet: boolean;
3333
debugFilePath: string;
34+
puppetAgentDir: string;
3435
}
3536

3637
export interface IConnectionManager {
@@ -214,7 +215,12 @@ export class ConnectionManager implements IConnectionManager {
214215
comspec = path.join(process.env["WINDIR"],"sysnative","cmd.exe");
215216
programFiles = process.env["ProgramW6432"];
216217
}
217-
let puppetDir : string = path.join(programFiles,"Puppet Labs","Puppet")
218+
let puppetDir: string = undefined;
219+
if (this.connectionConfiguration.puppetAgentDir == undefined) {
220+
puppetDir = path.join(programFiles, "Puppet Labs", "Puppet");
221+
} else {
222+
puppetDir = this.connectionConfiguration.puppetAgentDir;
223+
}
218224
let environmentBat : string = path.join(puppetDir,"bin","environment.bat")
219225

220226
if (!fs.existsSync(puppetDir)) {
@@ -233,8 +239,12 @@ export class ConnectionManager implements IConnectionManager {
233239
default:
234240
this.logger.debug('Starting language server')
235241

236-
// Try and find the puppet-agent ruby
237-
let rubyPath : string = '/opt/puppetlabs/puppet/bin/ruby';
242+
let rubyPath: string = undefined;
243+
if (this.connectionConfiguration.puppetAgentDir == undefined) {
244+
rubyPath = '/opt/puppetlabs/puppet/bin/ruby';
245+
} else {
246+
rubyPath = path.join(this.connectionConfiguration.puppetAgentDir, "bin", "ruby");
247+
}
238248
if (fs.existsSync(rubyPath)) { cmd = rubyPath }
239249

240250
// Default to ruby on the path

client/src/extension.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export class ConnectionConfiguration implements IConnectionConfiguration {
2020
public timeout: number = undefined;
2121
public preLoadPuppet: boolean = undefined;
2222
public debugFilePath: string = undefined;
23+
public puppetAgentDir: string = undefined;
2324

2425
constructor(context: vscode.ExtensionContext) {
2526
let config = vscode.workspace.getConfiguration('puppet');
@@ -29,6 +30,8 @@ export class ConnectionConfiguration implements IConnectionConfiguration {
2930
this.timeout = config['languageserver']['timeout'];
3031
this.preLoadPuppet = config['languageserver']['preLoadPuppet'];
3132
this.debugFilePath = config['languageserver']['debugFilePath'];
33+
34+
this.puppetAgentDir = config['puppetAgentDir'];
3235
}
3336
}
3437

0 commit comments

Comments
 (0)