This repository has been archived by the owner on Sep 24, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added an example of a Libral provider using Puppet directly
- Loading branch information
Showing
3 changed files
with
90 additions
and
3 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
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,53 @@ | ||
#! /usr/bin/env mruby | ||
# -*- ruby -*- | ||
|
||
|
||
class Group | ||
def describe(ctx) | ||
puts <<EOS | ||
--- | ||
provider: | ||
type: group | ||
desc: | | ||
Puppet group | ||
invoke: json | ||
actions: [get] | ||
suitable: true | ||
attributes: | ||
name: | ||
desc: "The name of the group" | ||
ensure: | ||
type: enum[absent, present] | ||
gid: | ||
desc: "The group ID" | ||
EOS | ||
end | ||
|
||
def get(ctx, names) | ||
output = `puppet resource group --to_yaml` | ||
lines = output.split("\n") | ||
resources = {} | ||
lines.each do |line| | ||
unless line == "group:" | ||
key, value = line.split(":", 2) | ||
if (value.nil? || value.empty?) and !key.nil? | ||
$name = key.strip | ||
resources[$name] = {} | ||
else | ||
unless $name.nil? or key.nil? | ||
resources[$name][key.strip] = value.strip.gsub("'", '') | ||
end | ||
end | ||
end | ||
end | ||
resources.collect do |name, resource| | ||
{ | ||
"name" => name, | ||
"ensure" => resource["ensure"], | ||
"gid" => resource["gid"], | ||
} | ||
end | ||
end | ||
end | ||
|
||
Ral::CLI::run(Group) |