Skip to content

Commit a1ed17d

Browse files
committed
add some docs
1 parent 701b9db commit a1ed17d

File tree

3 files changed

+60
-25
lines changed

3 files changed

+60
-25
lines changed

pre-docs/bolt_configuration_options.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@ ssh:
9292

9393
`service-options`: A hash of options to configure the Docker connection. Only necessary if using a non-default URL. See https://github.com/swipely/docker-api for supported options.
9494

95+
## Remote transport configuration options
96+
97+
*The remote transport is a new feature and currently experimental. It's configuration options and behavior may change between y releases*
98+
99+
`run-on`: The proxy target the task should execute on. Default is `localhost`
100+
101+
`conn-info`: A hash of connection info that will be passed to the device as `_target`.
102+
103+
95104
## Log file configuration options
96105

97106
Capture the results of your plan runs in a log file.

pre-docs/inventory_file.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ groups:
6161
## Override a user for a specific node
6262

6363
```
64-
nodes:
64+
nodes:
6565
- name: linux1.example.com
66-
config:
66+
config:
6767
ssh:
6868
user: me
6969
```
@@ -195,10 +195,24 @@ nodes:
195195
run-as: root
196196
```
197197
198-
- **[Generating inventory files](inventory_file_generating.md)**
198+
Configure a remote target
199+
200+
```yaml
201+
nodes:
202+
- host1.example.com
203+
- name: remote.example.com
204+
config:
205+
transport: remote
206+
remote:
207+
run-on: host1.example.com
208+
conn-info:
209+
url: https://user1:[email protected]
210+
```
211+
212+
- **[Generating inventory files](inventory_file_generating.md)**
199213
Use the `bolt-inventory-pdb` script to generate inventory files based on PuppetDB queries.
200214

201-
**Related information**
215+
**Related information**
202216

203217

204218
[Naming tasks](writing_tasks.md#)

pre-docs/writing_tasks.md

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Pattern[/\A[^\/\\]*\z/] $path
8080

8181
In addition to these task restrictions, different scripting languages each have their own ways to validate user input.
8282

83-
### PowerShell
83+
### PowerShell
8484

8585
In PowerShell, code injection exploits calls that specifically evaluate code. Do not call `Invoke-Expression` or `Add-Type` with user input. These commands evaluate strings as C\# code.
8686

@@ -129,7 +129,7 @@ Resolve file paths with `os.realpath` and confirm them to be within another path
129129

130130
For more information on the vulnerabilities of Python or how to escape variables, see Kevin London's blog post on [Dangerous Python Functions](https://www.kevinlondon.com/2015/07/26/dangerous-python-functions.html).
131131

132-
### Ruby
132+
### Ruby
133133

134134
In Ruby, command injection is introduced through commands like `eval`, `exec`, `system`, backtick \(\`\`\) or `%x()` execution, or the Open3 module. You can safely call these functions with user input by passing the input as additional arguments instead of a single string.
135135

@@ -296,7 +296,7 @@ To create a task that includes additional files pulled from modules, include the
296296

297297
- the module name
298298
- one of `lib``files`, or `tasks` for the directory within the module
299-
- the remaining path to a file or directory; directories must include a trailing slash `/`
299+
- the remaining path to a file or directory; directories must include a trailing slash `/`
300300

301301
All path separators must be forward slashes. An example would be `stdlib/lib/puppet/`.
302302

@@ -317,15 +317,15 @@ When a task includes the `files` property, all files listed in the top-level p
317317

318318
For example, you can create a task and metadata in a new module at `~/.puppetlabs/bolt/site/mymodule/tasks/task.{json,rb}`.
319319

320-
**Metadata**
320+
**Metadata**
321321

322322
```
323323
{
324324
"files": ["multi_task/files/rb_helper.rb"]
325325
}
326326
```
327327

328-
**File Resource**
328+
**File Resource**
329329

330330
`multi_task/files/rb_helper.rb`
331331

@@ -335,7 +335,7 @@ def useful_ruby
335335
end
336336
```
337337

338-
**Task**
338+
**Task**
339339

340340
```
341341
#!/usr/bin/env ruby
@@ -349,7 +349,7 @@ require_relative File.join(params['_installdir'], 'multi_task', 'files', 'rb_hel
349349
puts useful_ruby.to_json
350350
```
351351

352-
**Output**
352+
**Output**
353353

354354
```
355355
Started on localhost...
@@ -361,6 +361,18 @@ Successful on 1 node: localhost
361361
Ran on 1 node in 0.12 seconds
362362
```
363363

364+
### Remote Tasks
365+
366+
Some targets are hard or impossible to execute tasks on directly. For example a
367+
network device may have a limited shell environment or a cloud service may be
368+
driven only by HTTP APIs. In these cases it makes sense to write a task that
369+
runs on a proxy target and remotely interacts with real target. By writing a
370+
remote task Bolt allows users to specify connection information for remote
371+
targets in their inventory file and injects them into the `_target` metaparam.
372+
373+
374+
(example)[https://github.com/puppetlabs/puppetlabs-panos/pull/70]
375+
364376
### Task Helpers
365377

366378
To simplify writing tasks, Bolt includes [python\_task\_helper](https://github.com/puppetlabs/puppetlabs-python_task_helper) and [ruby\_task\_helper](https://github.com/puppetlabs/puppetlabs-ruby_task_helper). It also makes a useful demonstration of including code from another module.
@@ -369,7 +381,7 @@ To simplify writing tasks, Bolt includes [python\_task\_helper](https://github.c
369381

370382
Create task and metadata in a module at `~/.puppetlabs/bolt/site/mymodule/tasks/task.{json,py}`.
371383

372-
**Metadata**
384+
**Metadata**
373385

374386
```
375387
{
@@ -378,7 +390,7 @@ Create task and metadata in a module at `~/.puppetlabs/bolt/site/mymodule/tasks/
378390
}
379391
```
380392

381-
**Task**
393+
**Task**
382394

383395
```
384396
#!/usr/bin/env python
@@ -395,7 +407,7 @@ if __name__ == '__main__':
395407
MyTask().run()
396408
```
397409

398-
**Output**
410+
**Output**
399411

400412
```
401413
$ bolt task run mymodule::task -n localhost name='Julia'
@@ -412,7 +424,7 @@ Ran on 1 node in 0.12 seconds
412424

413425
Create task and metadata in a new module at `~/.puppetlabs/bolt/site/mymodule/tasks/mytask.{json,rb}`.
414426

415-
**Metadata**
427+
**Metadata**
416428

417429
```
418430
{
@@ -421,7 +433,7 @@ Create task and metadata in a new module at `~/.puppetlabs/bolt/site/mymodule/ta
421433
}
422434
```
423435

424-
**Task**
436+
**Task**
425437

426438
```
427439
#!/usr/bin/env ruby
@@ -430,13 +442,13 @@ require_relative '../lib/task_helper.rb'
430442
class MyTask < TaskHelper
431443
def task(name: nil, **kwargs)
432444
{ greeting: "Hi, my name is #{name}" }
433-
end
445+
end
434446
end
435447
436448
MyTask.run if __FILE__ == $0
437449
```
438450

439-
**Output**
451+
**Output**
440452

441453
```
442454
$ bolt task run mymodule::mytask -n localhost name="Robert'); DROP TABLE Students;--"
@@ -469,7 +481,7 @@ For example, to add a `message` parameter to your task, read it from the environ
469481
echo your message is $PT_message
470482
```
471483

472-
### Defining parameters in Windows
484+
### Defining parameters in Windows
473485

474486
For Windows tasks, you can pass parameters as environment variables, but it's easier to write your task in PowerShell and use named arguments. By default tasks with a `.ps1` extension use PowerShell standard argument handling.
475487

@@ -805,16 +817,16 @@ To define a parameter as sensitive within the JSON metadata, add the `"sensitive
805817

806818
The following table shows task metadata keys, values, and default values.
807819

808-
#### **Task metadata**
820+
#### **Task metadata**
809821

810822
|Metadata key|Description|Value|Default|
811823
|------------|-----------|-----|-------|
812824
|"description"|A description of what the task does.|String|None|
813-
|"input\_method"|What input method the task runner should use to pass parameters to the task.| - `environment`
825+
|"input\_method"|What input method the task runner should use to pass parameters to the task.| - `environment`
814826

815-
- `stdin`
827+
- `stdin`
816828

817-
- `powershell`
829+
- `powershell`
818830

819831

820832
| Both `environment` and `stdin` unless `.ps1` tasks, in which case `powershell`
@@ -833,7 +845,7 @@ Task metadata can accept most Puppet data types.
833845

834846
#### Common task data types
835847

836-
**Restriction:**
848+
**Restriction:**
837849

838850
Some types supported by Puppet can not be represented as JSON, such as `Hash[Integer, String]`, `Object`, or `Resource`. These should not be used in tasks, because they can never be matched.
839851

@@ -850,7 +862,7 @@ Some types supported by Puppet can not be represented as JSON, such as `Hash[Int
850862
| `Variant[Integer, Pattern[/\A\d+\Z/]]` |Matches an integer or a String of an integer|
851863
| `Boolean` |Accepts Boolean values.|
852864

853-
**Related information**
865+
**Related information**
854866

855867

856868
[Data type syntax](https://puppet.com/docs/puppet/latest/lang_data_type.html)

0 commit comments

Comments
 (0)