| 1 |
Scan |
| 2 |
===== |
| 3 |
|
| 4 |
Description |
| 5 |
----------- |
| 6 |
Runs cdist as a daemon that discover/watch on hosts and reconfigure them |
| 7 |
periodically. It is especially useful in netboot-based environment where hosts |
| 8 |
boot unconfigured, and to ensure your infrastructure stays in sync with your |
| 9 |
configuration. |
| 10 |
|
| 11 |
This feature is still consider to be in **beta** stage, and only operate on |
| 12 |
IPv6 (including link-local). |
| 13 |
|
| 14 |
Usage (Examples) |
| 15 |
---------------- |
| 16 |
|
| 17 |
Discover hosts on local network and configure those whose name is resolved by |
| 18 |
the name mapper script. |
| 19 |
|
| 20 |
.. code-block:: sh |
| 21 |
|
| 22 |
$ cdist scan --beta --interface eth0 \ |
| 23 |
--mode scan --name-mapper path/to/script \ |
| 24 |
--mode trigger --mode config |
| 25 |
|
| 26 |
List known hosts and exit. |
| 27 |
|
| 28 |
.. code-block:: sh |
| 29 |
|
| 30 |
$ cdist scan --beta --list --name-mapper path/to/script |
| 31 |
|
| 32 |
Please refer to `cdist(1)` for a detailed list of parameters. |
| 33 |
|
| 34 |
Modes |
| 35 |
----- |
| 36 |
|
| 37 |
The scanner has 3 modes that can be independently toggled. If the `--mode` |
| 38 |
parameter is not specified, only `tigger` and `scan` are enabled (= hosts are |
| 39 |
not configured). |
| 40 |
|
| 41 |
trigger |
| 42 |
Send ICMPv6 requests to specific hosts or broadcast over IPv6 link-local to |
| 43 |
trigger detection by the `scan` module. |
| 44 |
|
| 45 |
scan |
| 46 |
Watch for incoming ICMPv6 replies and optionally configure detected hosts. |
| 47 |
|
| 48 |
config |
| 49 |
Enable configuration of hosts detected by `scan`. |
| 50 |
|
| 51 |
Name Mapper Script |
| 52 |
------------------ |
| 53 |
|
| 54 |
The name mapper script takes an IPv6 address as first argument and writes the |
| 55 |
resolved name to stdout - if any. The script must be executable. |
| 56 |
|
| 57 |
Simplest script: |
| 58 |
|
| 59 |
.. code-block:: sh |
| 60 |
|
| 61 |
#!/bin/sh |
| 62 |
|
| 63 |
case "$1" in |
| 64 |
"fe80::20d:b9ff:fe57:3524") |
| 65 |
printf "my-host-01" |
| 66 |
;; |
| 67 |
"fe80::7603:bdff:fe05:89bb") |
| 68 |
printf "my-host-02" |
| 69 |
;; |
| 70 |
esac |
| 71 |
|
| 72 |
Resolving name from `PTR` DNS record: |
| 73 |
|
| 74 |
.. code-block:: sh |
| 75 |
|
| 76 |
#!/bin/sh |
| 77 |
|
| 78 |
for cmd in dig sed; do |
| 79 |
if ! command -v $cmd > /dev/null; then |
| 80 |
exit 1 |
| 81 |
fi |
| 82 |
done |
| 83 |
|
| 84 |
dig +short -x "$1" | sed -e 's/.$//' |