Resource Model Sources provide the means to retrieve Node resources for a Project. You can implement a Resource Model Source using a Java Plugin Type or a Script Plugin Type.
The ResourceModelSource
(javadoc) service allows the plugins to be configured via the Rundeck Web GUI. You are thus able to declare configuration properties for your plugin, which will be displayed as a web form when the Project is configured, or can be manually configured in the project.properties
file.
A ResourceModelSource provider is actually a Factory class. An instance of your ResourceModelSource provider will be re-used, so each time a new ResourceModelSource with a new configuration is required, your Factory class will be invoked to produce it.
Your provider class must implement the interface ResourceModelSourceFactory:
public interface ResourceModelSourceFactory {
/**
* Return a resource model source for the given configuration
*/
public ResourceModelSource createResourceModelSource(Properties configuration)
throws ConfigurationException;
}
See Plugin Development - Java Plugins - Descriptions to learn how to create configuration properties for your ResourceModelSource plugin.
See the Script Plugin Development for the basics of developing script-based plugins for Rundeck.
Instance scoped properties for ResourceModelSources are loaded from the project's Resource Model Source entries. A project can define multiple entries, and at execution time, the Instance scoped values come from those entries.
Here is an example plugin.yaml
script-based ResourceModelSource plugin declaring a provider called "mysource" that produces resource-format resourceyaml
output. The provider declares three config properties (account, url, region) and illustrates the use of three different types (Integer, String, FreeSelect).
Example: plugin.yaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
|
The script-file
entry on line 11 references a script called "nodes.sh" referencing the plugin properties (see script below).
Example script-file: nodes.sh
#!/usr/bin/env bash
# variables set by plugin properties:
: ${RD_CONFIG_ACCOUNT:?"account plugin property not specified"}
: ${RD_CONFIG_REGION:?"region plugin property not specified"}
: ${RD_CONFIG_URL:?"url plugin property not specified"}
#
# Generate node data here.
#
exit $?
The ResourceModelSource service has expectations about the way your provider script behaves.
Exit code:
Script output:
STDOUT
will be captured and passed to a ResourceFormatParser for the specified resource-format
to create the Node definitions.