aboutsummaryrefslogtreecommitdiff
path: root/plugin/import/README.md
blob: aaaaa1b2ae8a4765d02d3145fe14e8b1464e3b24 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# import

## Name

*import* - includes files or references snippets from a Corefile.

## Description

The *import* plugin can be used to include files into the main configuration. Another use is to
reference predefined snippets. Both can help to avoid some duplication.

This is a unique plugin in that *import* can appear outside of a server block. In other words, it
can appear at the top of a Corefile where an address would normally be.

## Syntax

~~~
import PATTERN
~~~

*   **PATTERN** is the file, glob pattern (`*`) or snippet to include. Its contents will replace
    this line, as if that file's contents appeared here to begin with.

## Files

You can use *import* to include a file or files. This file's location is relative to the
Corefile's location. It is an error if a specific file cannot be found, but an empty glob pattern is
not an error.

## Snippets

You can define snippets to be reused later in your Corefile by defining a block with a single-token
label surrounded by parentheses:

~~~ corefile
(mysnippet) {
	...
}
~~~

Then you can invoke the snippet with *import*:

~~~
import mysnippet
~~~

## Examples

Import a shared configuration:

~~~
. {
   import config/common.conf
}
~~~

Where `config/common.conf` contains:

~~~
prometheus
errors
log
~~~

This imports files found in the zones directory:

~~~
import ../zones/*
~~~

## See Also

See corefile(5).