Skip to content

Commit

Permalink
Make arguments param optional; update README
Browse files Browse the repository at this point in the history
This commit makes the arguments parameter optional by adding a default
value for it. It also updates the README to be clearer about how to
write tailored taskplans, and updates the test plan to use return()
instead of notice().
  • Loading branch information
reidmv committed Nov 1, 2021
1 parent 825c25b commit 3190072
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ bolt task run taskplan \

### Plan-specific tailored taskplan task

To create a plan-specific tailored taskplan task, use something like the following:
The task `taskplan` is generic, and can run any plan, but because it permits the user to pass arbitrary command line flags to Bolt, it is effectively a privileged task.

As an alternative to permitting users to run the generic privileged task, a plan-specific tailored task, built on taskplan, can be created.

To create a tailored plan-specific taskplan, use the following pattern.

tailored.json file:

```json
{
Expand All @@ -40,6 +46,8 @@ To create a plan-specific tailored taskplan task, use something like the followi
}
```

tailored.rb file:

```ruby
#!/opt/puppetlabs/puppet/bin/ruby
require 'json'
Expand Down
2 changes: 1 addition & 1 deletion plans/test.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
String $message,
) {

notice("Ran taskplan::test! Message: ${message}")
return("Ran taskplan::test! Message: ${message}")

}
9 changes: 5 additions & 4 deletions tasks/init.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
{
"description": "Run a Puppet task plan with Bolt",
"description": "A task to run a Puppet plan with Bolt",
"parameters": {
"plan": {
"type": "String[1]",
"description": "The task plan to run"
"description": "The plan to run"
},
"params": {
"type": "Hash",
"description": "Parameters to give to the task plan"
"description": "Parameters to give to the plan"
},
"arguments": {
"type": "Hash",
"description": "Hash of Bolt arguments to pass, e.g.: {modulepath=>/expl/path, ssl-verify=>false}"
"description": "Hash of Bolt arguments to pass, e.g.: {modulepath=>/expl/path, ssl-verify=>false}",
"default": { }
},
"debug": {
"type": "Optional[Boolean]",
Expand Down

0 comments on commit 3190072

Please sign in to comment.