Created
January 20, 2017 16:32
-
-
Save DavidS/3f9fe51ea79c219dc12176d96927bb8d to your computer and use it in GitHub Desktop.
The simplest possible resource type implementation: talking to a external API
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
Puppet::SimpleResource.define( | |
name: 'iis_application_pool', | |
docs: 'Manage an IIS application pool through a powershell proxy.', | |
attributes: { | |
ensure: { | |
type: 'Enum[present, absent]', | |
docs: 'Whether this ApplicationPool should be present or absent on the target system.' | |
}, | |
name: { | |
type: 'String', | |
docs: 'The name of the ApplicationPool.', | |
namevar: true, | |
}, | |
state: { | |
type: 'Enum[running, stopped]', | |
docs: 'The state of the ApplicationPool.', | |
default: 'running', | |
}, | |
managedpipelinemode: { | |
type: 'String', | |
docs: 'The managedPipelineMode of the ApplicationPool.', | |
}, | |
managedruntimeversion: { | |
type: 'String', | |
docs: 'The managedRuntimeVersion of the ApplicationPool.', | |
}, | |
} | |
) do | |
require 'puppet/provider/iis_powershell' | |
include Puppet::Provider::IIS_PowerShell | |
def get | |
result = run('fetch_application_pools.ps1', logger) # call out to powershell to talk to the API | |
# returns an array of hashes with data according to the schema above | |
JSON.parse(result) | |
end | |
def set(goals, noop = false) | |
result = run('enforce_application_pools.ps1', goals, logger, noop) # call out to powershell to talk to the API | |
# returns an array of hashes with status data from the changes | |
JSON.parse(result) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment