| 1 |
# Name |
| 2 |
|
| 3 |
_import_ - includes files or references snippets from a Conffile |
| 4 |
|
| 5 |
# Description |
| 6 |
|
| 7 |
The _import_ handler can be used to include files into the main configuration. Another use is to |
| 8 |
reference predefined snippets. Both can help to avoid some duplication. |
| 9 |
|
| 10 |
This is a unique handler in that _import_ can appear outside of a handler block. In other words, it |
| 11 |
can appear at the top of a Conffile where an address would normally be. |
| 12 |
|
| 13 |
You can have a maximum of 1000 imports in the configuration, this is to prevent cycles. |
| 14 |
|
| 15 |
# Syntax |
| 16 |
|
| 17 |
``` |
| 18 |
import PATTERN |
| 19 |
``` |
| 20 |
|
| 21 |
- **PATTERN** is the file, glob pattern (`*`) or snippet to include. Its contents will replace |
| 22 |
this line, as if that file's contents appeared here to begin with. |
| 23 |
|
| 24 |
# Files |
| 25 |
|
| 26 |
You can use _import_ to include a file or files. This file's location is relative to the |
| 27 |
Conffile's location. It is an error if a specific file cannot be found, but an empty glob pattern is |
| 28 |
not an error. |
| 29 |
|
| 30 |
# Snippets |
| 31 |
|
| 32 |
You can define snippets to be reused later in your Conffile by defining a block with a single-token |
| 33 |
label surrounded by parentheses: |
| 34 |
|
| 35 |
```conffile |
| 36 |
(mysnippet) { |
| 37 |
... |
| 38 |
} |
| 39 |
``` |
| 40 |
|
| 41 |
Then you can invoke the snippet with _import_: |
| 42 |
|
| 43 |
``` |
| 44 |
import mysnippet |
| 45 |
``` |
| 46 |
|
| 47 |
# Examples |
| 48 |
|
| 49 |
Import a shared configuration: |
| 50 |
|
| 51 |
``` |
| 52 |
. { |
| 53 |
import config/common.conf |
| 54 |
} |
| 55 |
``` |
| 56 |
|
| 57 |
Where `config/common.conf` contains: |
| 58 |
|
| 59 |
``` |
| 60 |
prometheus |
| 61 |
errors |
| 62 |
log |
| 63 |
``` |
| 64 |
|
| 65 |
This imports files found in the zones directory: |
| 66 |
|
| 67 |
``` |
| 68 |
import ../zones/* |
| 69 |
``` |
| 70 |
|
| 71 |
# See Also |
| 72 |
|
| 73 |
See atomdns-conffile(5). |