-
-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
125 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,5 @@ | |
.*.sw? | ||
/.yardoc/ | ||
/Guardfile | ||
bolt-debug.log | ||
.rerun.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
analytics: false | ||
name: systemd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"description": "Get systemctl show output of a unit", | ||
"input_method": "stdin", | ||
"parameters": { | ||
"bin_path": { | ||
"description": "Path to systemctl binary", | ||
"type": "String[1]", | ||
"default": "/usr/bin/systemctl" | ||
}, | ||
"properties": { | ||
"description": "Properties to retrieve from the unit", | ||
"type": "Array[String[1]]", | ||
"default": ["ActiveState", "SubState", "LoadState", "UnitFileState"] | ||
}, | ||
"unit_name": { | ||
"description": "Name of the unit", | ||
"type": "String[1]" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/opt/puppetlabs/puppet/bin/ruby | ||
# frozen_string_literal: true | ||
|
||
require 'json' | ||
require 'open3' | ||
|
||
params = JSON.parse($stdin.read) | ||
|
||
systemctl_cmd = params['bin_path'] | ||
systemctl_args = ['show', '--no-pager', '--no-legend', '--property', params['properties'].join(','), params['unit_name']] | ||
output, status = Open3.capture2(systemctl_cmd, *systemctl_args) | ||
|
||
raise "Error running systemctl show: #{output}" unless status.success? | ||
|
||
puts output.split("\n").to_h { |item| item.split('=', 2) }.to_json |