| 
									
										
										
										
											2019-01-06 03:41:47 +00:00
										 |  |  | # import
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ## Name
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-08 00:25:17 -07:00
										 |  |  | *import* - includes files or references snippets from a Corefile. | 
					
						
							| 
									
										
										
										
											2019-01-06 03:41:47 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | ## Description
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-08 00:25:17 -07:00
										 |  |  | The *import* plugin can be used to include files into the main configuration. Another use is to | 
					
						
							| 
									
										
										
										
											2019-01-06 03:41:47 +00:00
										 |  |  | reference predefined snippets. Both can help to avoid some duplication. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-08 10:20:48 +01:00
										 |  |  | This is a unique plugin in that *import* can appear outside of a server block. In other words, it | 
					
						
							| 
									
										
										
										
											2019-01-06 03:41:47 +00:00
										 |  |  | 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/* | 
					
						
							|  |  |  | ~~~ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-28 18:56:35 +01:00
										 |  |  | ## See Also
 | 
					
						
							| 
									
										
										
										
											2019-01-06 03:41:47 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | See corefile(5). |