|
| 1 | +.. Licensed to the Apache Software Foundation (ASF) under one |
| 2 | + or more contributor license agreements. See the NOTICE file |
| 3 | + distributed with this work for additional information |
| 4 | + regarding copyright ownership. The ASF licenses this file |
| 5 | + to you under the Apache License, Version 2.0 (the |
| 6 | + "License"); you may not use this file except in compliance |
| 7 | + with the License. You may obtain a copy of the License at |
| 8 | +
|
| 9 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +
|
| 11 | + Unless required by applicable law or agreed to in writing, |
| 12 | + software distributed under the License is distributed on an |
| 13 | + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | + KIND, either express or implied. See the License for the |
| 15 | + specific language governing permissions and limitations |
| 16 | + under the License. |
| 17 | +
|
| 18 | +.. include:: ../../common.defs |
| 19 | + |
| 20 | +=========== |
| 21 | +plugin.yaml |
| 22 | +=========== |
| 23 | + |
| 24 | +.. configfile:: plugin.yaml |
| 25 | + |
| 26 | +The :file:`plugin.yaml` file provides a YAML-based alternative to |
| 27 | +:file:`plugin.config` for configuring global plugins available to |TS|. |
| 28 | +Global plugins are loaded at startup and have global effect on all |
| 29 | +transactions. This is in contrast to plugins specified in |
| 30 | +:file:`remap.config` or :file:`remap.yaml`, whose effects are limited to |
| 31 | +specific mapping rules. |
| 32 | + |
| 33 | +Configuration File Fallback |
| 34 | +============================ |
| 35 | + |
| 36 | +|TS| will attempt to load :file:`plugin.yaml` first. If this file is |
| 37 | +not found, it will fall back to loading :file:`plugin.config`. If both |
| 38 | +files exist, only :file:`plugin.yaml` will be used. This allows for a |
| 39 | +gradual migration from the legacy configuration format to YAML. |
| 40 | + |
| 41 | +Format |
| 42 | +====== |
| 43 | + |
| 44 | +The :file:`plugin.yaml` file uses YAML syntax with a single required key: |
| 45 | + |
| 46 | +- ``plugins`` (required): A sequence of plugin entries. |
| 47 | + |
| 48 | +Each plugin entry is a YAML mapping with the following fields: |
| 49 | + |
| 50 | +``path`` |
| 51 | +-------- |
| 52 | + |
| 53 | +**Required.** Path to the ``.so`` file. This path can be absolute or |
| 54 | +relative to the plugin directory (usually |
| 55 | +``/usr/local/libexec/trafficserver``). |
| 56 | + |
| 57 | +``enabled`` |
| 58 | +----------- |
| 59 | + |
| 60 | +**Optional.** Boolean. When set to ``false``, the plugin is skipped |
| 61 | +entirely during startup — no ``dlopen``, no ``TSPluginInit``. The |
| 62 | +configuration entry remains in the file for easy re-enabling. |
| 63 | + |
| 64 | +**Default:** ``true`` |
| 65 | + |
| 66 | +``params`` |
| 67 | +---------- |
| 68 | + |
| 69 | +**Optional.** A YAML sequence of string arguments passed to the plugin's |
| 70 | +``TSPluginInit`` function as ``argc/argv``. Arguments that begin |
| 71 | +with ``$`` designate |TS| configuration variables and will be expanded |
| 72 | +to their current value before the plugin is loaded. |
| 73 | + |
| 74 | +``load_order`` |
| 75 | +-------------- |
| 76 | + |
| 77 | +**Optional.** Integer. Provides explicit control over the order in which |
| 78 | +plugins are loaded and therefore the order in which they are chained for |
| 79 | +request processing. |
| 80 | + |
| 81 | +The loading rules are: |
| 82 | + |
| 83 | +1. Plugins **with** ``load_order`` are loaded first, sorted ascending by |
| 84 | + value (lowest number loads first). |
| 85 | +2. Among plugins with the **same** ``load_order`` value, their relative |
| 86 | + order in the YAML file is preserved (stable sort). |
| 87 | +3. Plugins **without** ``load_order`` are loaded after all ordered |
| 88 | + plugins, in the order they appear in the YAML file. |
| 89 | + |
| 90 | +Most deployments do not need ``load_order`` — simply list plugins in the |
| 91 | +desired order in the YAML file. Use ``load_order`` when the file is |
| 92 | +managed by automation tools that may reorder entries, or when you want |
| 93 | +to guarantee a specific plugin loads first regardless of where it |
| 94 | +appears in the file. |
| 95 | + |
| 96 | +**Default:** Unset (YAML sequence order). |
| 97 | + |
| 98 | +Basic Structure |
| 99 | +=============== |
| 100 | + |
| 101 | +.. code-block:: yaml |
| 102 | +
|
| 103 | + plugins: |
| 104 | + - path: stats_over_http.so |
| 105 | +
|
| 106 | + - path: abuse.so |
| 107 | + params: |
| 108 | + - etc/trafficserver/abuse.config |
| 109 | +
|
| 110 | + - path: header_rewrite.so |
| 111 | + params: |
| 112 | + - etc/trafficserver/header_rewrite.config |
| 113 | +
|
| 114 | + - path: icx.so |
| 115 | + params: |
| 116 | + - etc/trafficserver/icx.config |
| 117 | + - $proxy.config.http.connect_attempts_timeout |
| 118 | +
|
| 119 | + - path: experimental_plugin.so |
| 120 | + enabled: false |
| 121 | + params: |
| 122 | + - --verbose |
| 123 | +
|
| 124 | +.. important:: |
| 125 | + |
| 126 | + **Loading order matters.** Plugins are loaded in the order they |
| 127 | + appear in the YAML file, and this is the order in which they are |
| 128 | + chained for request processing (hooks are called in load order). If |
| 129 | + you need a plugin to run before another, place it earlier in the file |
| 130 | + or assign it a lower ``load_order`` value. |
| 131 | + |
| 132 | +New Features Over plugin.config |
| 133 | +================================ |
| 134 | + |
| 135 | +:file:`plugin.yaml` introduces several features not available in the |
| 136 | +legacy :file:`plugin.config` format: |
| 137 | + |
| 138 | +* **Disable without deleting** — set ``enabled: false`` to skip a |
| 139 | + plugin without removing or commenting out the line. |
| 140 | +* **Explicit load ordering** — use ``load_order`` to control loading |
| 141 | + priority independent of file position. |
| 142 | +* **Variable expansion** — ``$record`` references in ``params`` are |
| 143 | + expanded to their current value at load time (same as |
| 144 | + :file:`plugin.config`). |
| 145 | +* **Startup logging** — each plugin produces a ``NOTE``-level log line |
| 146 | + showing its load sequence number, path, and status. |
| 147 | +* **Runtime introspection** — ``traffic_ctl plugin list`` shows the |
| 148 | + loaded plugins and their status via JSONRPC. |
| 149 | +* **Automated migration** — ``traffic_ctl config convert plugin_config`` |
| 150 | + converts an existing :file:`plugin.config` to :file:`plugin.yaml`. |
| 151 | + |
| 152 | +Examples |
| 153 | +======== |
| 154 | + |
| 155 | +Disabling a Plugin |
| 156 | +------------------ |
| 157 | + |
| 158 | +.. code-block:: yaml |
| 159 | +
|
| 160 | + plugins: |
| 161 | + - path: debug_plugin.so |
| 162 | + enabled: false |
| 163 | +
|
| 164 | +The plugin entry remains in the configuration file but is not loaded. |
| 165 | +Set ``enabled: true`` (or remove the field) to re-enable it. |
| 166 | + |
| 167 | +Plugin Loading Order |
| 168 | +--------------------- |
| 169 | + |
| 170 | +By default, plugins load in the order they appear in the YAML file — |
| 171 | +top to bottom. This is the same behavior as :file:`plugin.config` and |
| 172 | +is sufficient for most deployments: |
| 173 | + |
| 174 | +.. code-block:: yaml |
| 175 | +
|
| 176 | + plugins: |
| 177 | + - path: certifier.so # loads 1st |
| 178 | + - path: header_rewrite.so # loads 2nd |
| 179 | + - path: stats_over_http.so # loads 3rd |
| 180 | +
|
| 181 | +When ``load_order`` is set, it overrides the file order. Plugins with |
| 182 | +``load_order`` always load before plugins without it: |
| 183 | + |
| 184 | +.. code-block:: yaml |
| 185 | +
|
| 186 | + plugins: |
| 187 | + - path: stats_over_http.so |
| 188 | + load_order: 300 |
| 189 | +
|
| 190 | + - path: certifier.so |
| 191 | + load_order: 100 |
| 192 | +
|
| 193 | + - path: header_rewrite.so |
| 194 | + load_order: 200 |
| 195 | +
|
| 196 | + - path: xdebug.so |
| 197 | +
|
| 198 | +Despite the YAML sequence order, the actual load order is: |
| 199 | + |
| 200 | +1. ``certifier.so`` (load_order: 100) |
| 201 | +2. ``header_rewrite.so`` (load_order: 200) |
| 202 | +3. ``stats_over_http.so`` (load_order: 300) |
| 203 | +4. ``xdebug.so`` (no load_order — loaded last, in file order) |
| 204 | + |
| 205 | +.. tip:: |
| 206 | + |
| 207 | + Use gaps between ``load_order`` values (e.g. 100, 200, 300) so new |
| 208 | + plugins can be inserted later without renumbering. |
| 209 | + |
| 210 | +Configuration Variable Expansion |
| 211 | +--------------------------------- |
| 212 | + |
| 213 | +.. code-block:: yaml |
| 214 | +
|
| 215 | + plugins: |
| 216 | + - path: icx.so |
| 217 | + params: |
| 218 | + - etc/trafficserver/icx.config |
| 219 | + - $proxy.config.http.connect_attempts_timeout |
| 220 | +
|
| 221 | +Arguments beginning with ``$`` are expanded to the current value of the |
| 222 | +corresponding |TS| configuration variable before the plugin is loaded. |
| 223 | + |
| 224 | +Migration from plugin.config |
| 225 | +============================== |
| 226 | + |
| 227 | +.. list-table:: |
| 228 | + :header-rows: 1 |
| 229 | + :widths: 50 50 |
| 230 | + |
| 231 | + * - plugin.config |
| 232 | + - plugin.yaml |
| 233 | + * - :: |
| 234 | + |
| 235 | + stats_over_http.so |
| 236 | + - .. code-block:: yaml |
| 237 | + |
| 238 | + plugins: |
| 239 | + - path: stats_over_http.so |
| 240 | + |
| 241 | + * - :: |
| 242 | + |
| 243 | + abuse.so etc/trafficserver/abuse.config |
| 244 | + - .. code-block:: yaml |
| 245 | + |
| 246 | + plugins: |
| 247 | + - path: abuse.so |
| 248 | + params: |
| 249 | + - etc/trafficserver/abuse.config |
| 250 | + |
| 251 | + * - :: |
| 252 | + |
| 253 | + icx.so etc/trafficserver/icx.config $proxy.config.http.connect_attempts_timeout |
| 254 | + - .. code-block:: yaml |
| 255 | + |
| 256 | + plugins: |
| 257 | + - path: icx.so |
| 258 | + params: |
| 259 | + - etc/trafficserver/icx.config |
| 260 | + - $proxy.config.http.connect_attempts_timeout |
| 261 | + |
| 262 | + * - :: |
| 263 | + |
| 264 | + # header_rewrite.so etc/trafficserver/header_rewrite.config |
| 265 | + - .. code-block:: yaml |
| 266 | + |
| 267 | + plugins: |
| 268 | + - path: header_rewrite.so |
| 269 | + params: |
| 270 | + - etc/trafficserver/header_rewrite.config |
| 271 | + enabled: false |
| 272 | + |
| 273 | +Startup Logging |
| 274 | +=============== |
| 275 | + |
| 276 | +When plugins are loaded from :file:`plugin.yaml`, each plugin produces a |
| 277 | +``NOTE``-level log line showing its load sequence number, path, and status: |
| 278 | + |
| 279 | +:: |
| 280 | + |
| 281 | + [NOTE] plugin #1 loading: certifier.so (load_order: 100) |
| 282 | + [NOTE] plugin #2 loading: header_rewrite.so |
| 283 | + [NOTE] plugin #3 skipped: experimental_plugin.so (enabled: false) |
| 284 | + |
| 285 | +See Also |
| 286 | +======== |
| 287 | + |
| 288 | +:doc:`plugin.config.en`, |
| 289 | +:manpage:`TSAPI(3ts)`, |
| 290 | +:manpage:`TSPluginInit(3ts)`, |
| 291 | +:doc:`remap.config.en`, |
| 292 | +:doc:`remap.yaml.en` |
0 commit comments