Skip to content

Commit

Permalink
update site and man pages
Browse files Browse the repository at this point in the history
  • Loading branch information
umputun committed Apr 28, 2024
1 parent ca4ade3 commit 452ee90
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
21 changes: 21 additions & 0 deletions site/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,27 @@ commands:
copy: {src: $FILE_NAME, dest: /tmp/file2}
```

Another unique feature of the registered variables is that they can be used not only in the subsequent commands for the current task but also in the subsequent tasks. This allows users to pass variables between tasks. In other words, the registered variables are populated to the environment of all the tasks in the playbook, automatically.

example:

```yaml
tasks:
- name: set_register_var
commands:
- name: some command
script: |
echo good command 1
len=$(echo "file content" | wc -c)
register: [len]

- name: use_register_var
commands:
- name: some command
script: |
echo "len: $len"
```

### Setting environment variables

Environment variables can be set with `--env` / `-e` cli option. For example: `-e VAR1:VALUE1 -e VAR2:VALUE2`. Environment variables can also be set in the environment file (default `env.yml` can be changed with `--env-file` / `-E` cli flag). For example:
Expand Down
28 changes: 27 additions & 1 deletion spot.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "SPOT" 1 20240422T175052 spot manual
.TH "SPOT" 1 20240427T195838 spot manual
.\" Automatically generated by Pandoc 3.1.13
.\"
.SH Spot
Expand Down Expand Up @@ -827,6 +827,32 @@ commands\f[B]:\f[R]
\f[B]\-\f[R] name\f[B]:\f[R] third command
copy\f[B]:\f[R] \f[B]{\f[R]src\f[B]:\f[R] $FILE_NAME\f[B],\f[R] dest\f[B]:\f[R] /tmp/file2\f[B]}\f[R]
.EE
.PP
Another unique feature of the registered variables is that they can be
used not only in the subsequent commands for the current task but also
in the subsequent tasks.
This allows users to pass variables between tasks.
In other words, the registered variables are populated to the
environment of all the tasks in the playbook, automatically.
.PP
example:
.IP
.EX
tasks\f[B]:\f[R]
\f[B]\-\f[R] name\f[B]:\f[R] set_register_var
commands\f[B]:\f[R]
\f[B]\-\f[R] name\f[B]:\f[R] some command
script\f[B]: \f[R]|
echo good command 1
len=$(echo \[dq]file content\[dq] | wc \-c)
register\f[B]:\f[R] \f[B][\f[R]len\f[B]]\f[R]
\f[B]\-\f[R] name\f[B]:\f[R] use_register_var
commands\f[B]:\f[R]
\f[B]\-\f[R] name\f[B]:\f[R] some command
script\f[B]: \f[R]|
echo \[dq]len: $len\[dq]
.EE
.SS Setting environment variables
Environment variables can be set with \f[CR]\-\-env\f[R] /
\f[CR]\-e\f[R] cli option.
Expand Down

0 comments on commit 452ee90

Please sign in to comment.