Skip to content

Commit 99e6974

Browse files
author
olevole
committed
import facts pages
1 parent 021831b commit 99e6974

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

share/docs/general/tag_n_facts.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# CBSD: tags and custom facts
2+
3+
## facts
4+
5+
When working with command like this: [jls](../jail/wf_jls_ssi.md), [jget](../jail/wf_jget_ssi.md),
6+
[bls](../bhyve/wf_bls_ssi.md), [bget](../bhyve/wf_bget_ssi.md), [xls](../xen/wf_xls_ssi.md), [xget](../jail/wf_xget_ssi.md) and so on, you see the values of the underlying **CBSD**.
7+
However, you can supplement and create your own informative fields for your environments, thereby expanding the output of **CBSD**.
8+
9+
For these purposes, a _${workdir}/jails-system/${jname}/facts.d_ a directory is used, into which you can save an executable file under an arbitrary name.
10+
The name of this file is your custom field and the information that your script will output will be available for the above scripts
11+
will be available for the above scripts.
12+
The value in the output should be in the format of one word (digits).
13+
14+
At the same time, inside your scripts, you will be available to the internal facts of environments from **CBSD**: [CBSD variables](http://www.bsdstore.ru/en/13.0.x/wf_cbsd_variables_ssi.html).
15+
16+
For example:
17+
18+
```
19+
% cat > ~cbsd/jails-system/jail1/facts.d/mycustom1 <<EOF
20+
#!/bin/sh
21+
echo "MYCUSTOM1"
22+
EOF
23+
24+
% chmod +x /usr/jails/jails-system/jail1/facts.d/mycustom1
25+
% cbsd jls display=jname,mycustom1
26+
% cbsd jget jname=jail1 mycustom1
27+
```
28+
29+
![](http://www.bsdstore.ru/img/custom_facts1.png)
30+
31+
## tags
32+
33+
In addition to custom facts, you can use `tags` - this is a field in the SQLite3 database. This is the main difference between tags and facts - this value is static, while facts get the result in runtime.
34+
35+
Also, thanks to SQL, tags can participate in selections, e.g.:
36+
37+
38+
`cbsd jls ip4_addr=10.0.0.1` is the same: `"SELECT * FROM jails WHERE ip4_addr="10.0.0.1"`
39+
40+
or
41+
42+
`cbsd jls astart=1 display=ip4_addr` is the same: `"SELECT ip4_addr WHERE astart=1"`
43+
44+
and so on:
45+
46+
![tags.png](https://convectix.com/img/tags.png)

0 commit comments

Comments
 (0)