Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 1 | |
Ales Komarek | 5474068 | 2017-05-15 07:16:23 +0200 | [diff] [blame] | 2 | ============ |
| 3 | Salt Formula |
| 4 | ============ |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 5 | |
Ales Komarek | 5474068 | 2017-05-15 07:16:23 +0200 | [diff] [blame] | 6 | Salt is a new approach to infrastructure management. Easy enough to get |
| 7 | running in minutes, scalable enough to manage tens of thousands of servers, |
| 8 | and fast enough to communicate with them in seconds. |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 9 | |
Ales Komarek | 5474068 | 2017-05-15 07:16:23 +0200 | [diff] [blame] | 10 | Salt delivers a dynamic communication bus for infrastructures that can be used |
| 11 | for orchestration, remote execution, configuration management and much more. |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 12 | |
Ales Komarek | 5474068 | 2017-05-15 07:16:23 +0200 | [diff] [blame] | 13 | |
| 14 | Sample Metadata |
| 15 | =============== |
| 16 | |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 17 | |
Ales Komarek | d768f1c | 2018-01-30 22:37:18 +0100 | [diff] [blame] | 18 | Salt Master |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 19 | ----------- |
| 20 | |
Ales Komarek | 5474068 | 2017-05-15 07:16:23 +0200 | [diff] [blame] | 21 | Salt master with base formulas and pillar metadata backend |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 22 | |
Ales Komarek | 8ba9c0b | 2016-02-21 14:59:59 +0100 | [diff] [blame] | 23 | .. literalinclude:: tests/pillar/master_single_pillar.sls |
| 24 | :language: yaml |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 25 | |
Ales Komarek | 5474068 | 2017-05-15 07:16:23 +0200 | [diff] [blame] | 26 | Salt master with reclass ENC metadata backend |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 27 | |
Ales Komarek | 8ba9c0b | 2016-02-21 14:59:59 +0100 | [diff] [blame] | 28 | .. literalinclude:: tests/pillar/master_single_reclass.sls |
| 29 | :language: yaml |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 30 | |
Ales Komarek | 459407b | 2018-01-18 17:16:31 +0100 | [diff] [blame] | 31 | Salt master with Architect ENC metadata backend |
| 32 | |
| 33 | .. code-block:: yaml |
| 34 | |
| 35 | salt: |
| 36 | master: |
| 37 | enabled: true |
| 38 | pillar: |
| 39 | engine: architect |
| 40 | project: project-name |
| 41 | host: architect-api |
| 42 | port: 8181 |
| 43 | username: salt |
| 44 | password: password |
| 45 | |
Petr Michalec | 1f541c4 | 2017-08-17 13:30:37 +0200 | [diff] [blame] | 46 | Salt master with multiple ext_pillars |
| 47 | |
| 48 | .. literalinclude:: tests/pillar/master_single_extpillars.sls |
| 49 | :language: yaml |
| 50 | |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 51 | Salt master with API |
| 52 | |
Ales Komarek | b2c8ff6 | 2016-08-22 00:20:01 +0200 | [diff] [blame] | 53 | .. literalinclude:: tests/pillar/master_api.sls |
| 54 | :language: yaml |
Ales Komarek | cdb280f | 2016-07-27 15:37:51 +0200 | [diff] [blame] | 55 | |
| 56 | Salt master with defined user ACLs |
| 57 | |
Ales Komarek | b2c8ff6 | 2016-08-22 00:20:01 +0200 | [diff] [blame] | 58 | .. literalinclude:: tests/pillar/master_acl.sls |
| 59 | :language: yaml |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 60 | |
| 61 | Salt master with preset minions |
| 62 | |
| 63 | .. code-block:: yaml |
| 64 | |
| 65 | salt: |
| 66 | master: |
| 67 | enabled: true |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 68 | minions: |
| 69 | - name: 'node1.system.location.domain.com' |
| 70 | |
Ales Komarek | 5474068 | 2017-05-15 07:16:23 +0200 | [diff] [blame] | 71 | Salt master with pip based installation (optional) |
Adam Tengler | caedd97 | 2016-05-04 16:44:00 +0200 | [diff] [blame] | 72 | |
| 73 | .. code-block:: yaml |
| 74 | |
| 75 | salt: |
| 76 | master: |
| 77 | enabled: true |
| 78 | ... |
| 79 | source: |
| 80 | engine: pip |
| 81 | version: 2016.3.0rc2 |
| 82 | |
Ales Komarek | 5474068 | 2017-05-15 07:16:23 +0200 | [diff] [blame] | 83 | Install formula through system package management |
Adam Tengler | 3eb85ad | 2016-05-06 02:52:40 +0200 | [diff] [blame] | 84 | |
| 85 | .. code-block:: yaml |
| 86 | |
| 87 | salt: |
| 88 | master: |
| 89 | enabled: true |
| 90 | ... |
| 91 | environment: |
| 92 | prd: |
Petr Michalec | 7a2f1d2 | 2017-05-17 22:08:32 +0200 | [diff] [blame] | 93 | keystone: |
Adam Tengler | 3eb85ad | 2016-05-06 02:52:40 +0200 | [diff] [blame] | 94 | source: pkg |
| 95 | name: salt-formula-keystone |
Petr Michalec | 7a2f1d2 | 2017-05-17 22:08:32 +0200 | [diff] [blame] | 96 | nova: |
| 97 | source: pkg |
| 98 | name: salt-formula-keystone |
| 99 | version: 0.1+0~20160818133412.24~1.gbp6e1ebb |
| 100 | postresql: |
| 101 | source: pkg |
| 102 | name: salt-formula-postgresql |
| 103 | version: purged |
| 104 | |
| 105 | Formula keystone is installed latest version and the formulas without version are installed in one call to aptpkg module. |
| 106 | If the version attribute is present sls iterates over formulas and take action to install specific version or remove it. |
| 107 | The version attribute may have these values ``[latest|purged|removed|<VERSION>]``. |
Adam Tengler | 3eb85ad | 2016-05-06 02:52:40 +0200 | [diff] [blame] | 108 | |
| 109 | Clone master branch of keystone formula as local feature branch |
| 110 | |
| 111 | .. code-block:: yaml |
| 112 | |
| 113 | salt: |
| 114 | master: |
| 115 | enabled: true |
| 116 | ... |
| 117 | environment: |
| 118 | dev: |
| 119 | formula: |
| 120 | keystone: |
| 121 | source: git |
| 122 | address: git@github.com:openstack/salt-formula-keystone.git |
| 123 | revision: master |
| 124 | branch: feature |
| 125 | |
| 126 | Salt master with specified formula refs (for example for Gerrit review) |
| 127 | |
| 128 | .. code-block:: yaml |
| 129 | |
| 130 | salt: |
| 131 | master: |
| 132 | enabled: true |
| 133 | ... |
| 134 | environment: |
| 135 | dev: |
| 136 | formula: |
| 137 | keystone: |
| 138 | source: git |
| 139 | address: https://git.openstack.org/openstack/salt-formula-keystone |
| 140 | revision: refs/changes/56/123456/1 |
| 141 | |
Oleksii Chupryn | 7b7102a | 2018-05-11 10:32:11 +0300 | [diff] [blame] | 142 | Salt master logging configuration |
| 143 | |
| 144 | .. code-block:: yaml |
| 145 | |
| 146 | salt: |
| 147 | master: |
| 148 | enabled: true |
| 149 | log: |
| 150 | level: warning |
| 151 | file: '/var/log/salt/master' |
| 152 | level_logfile: warning |
| 153 | |
| 154 | Salt minion logging configuration |
| 155 | |
| 156 | .. code-block:: yaml |
| 157 | |
| 158 | salt: |
| 159 | minion: |
| 160 | enabled: true |
| 161 | log: |
| 162 | level: info |
| 163 | file: '/var/log/salt/minion' |
| 164 | level_logfile: warning |
| 165 | |
Ales Komarek | 5474068 | 2017-05-15 07:16:23 +0200 | [diff] [blame] | 166 | Salt master with logging handlers |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 167 | |
| 168 | .. code-block:: yaml |
| 169 | |
| 170 | salt: |
| 171 | master: |
| 172 | enabled: true |
Ales Komarek | 8ba9c0b | 2016-02-21 14:59:59 +0100 | [diff] [blame] | 173 | handler: |
| 174 | handler01: |
| 175 | engine: udp |
| 176 | bind: |
| 177 | host: 127.0.0.1 |
| 178 | port: 9999 |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 179 | minion: |
Ales Komarek | 8ba9c0b | 2016-02-21 14:59:59 +0100 | [diff] [blame] | 180 | handler: |
| 181 | handler01: |
| 182 | engine: udp |
| 183 | bind: |
| 184 | host: 127.0.0.1 |
| 185 | port: 9999 |
| 186 | handler02: |
| 187 | engine: zmq |
| 188 | bind: |
| 189 | host: 127.0.0.1 |
| 190 | port: 9999 |
| 191 | |
Ales Komarek | a9fc6e7 | 2017-09-06 15:02:40 +0200 | [diff] [blame] | 192 | Salt engine definition for saltgraph metadata collector |
| 193 | |
| 194 | .. code-block:: yaml |
| 195 | |
| 196 | salt: |
| 197 | master: |
| 198 | engine: |
| 199 | graph_metadata: |
| 200 | engine: saltgraph |
| 201 | host: 127.0.0.1 |
| 202 | port: 5432 |
| 203 | user: salt |
| 204 | password: salt |
| 205 | database: salt |
| 206 | |
Ales Komarek | 459407b | 2018-01-18 17:16:31 +0100 | [diff] [blame] | 207 | Salt engine definition for Architect service |
| 208 | |
| 209 | .. code-block:: yaml |
| 210 | |
| 211 | salt: |
| 212 | master: |
| 213 | engine: |
| 214 | architect: |
| 215 | engine: architect |
| 216 | project: project-name |
| 217 | host: architect-api |
| 218 | port: 8181 |
| 219 | username: salt |
| 220 | password: password |
| 221 | |
Ales Komarek | a9fc6e7 | 2017-09-06 15:02:40 +0200 | [diff] [blame] | 222 | Salt engine definition for sending events from docker events |
| 223 | |
| 224 | .. code-block:: yaml |
| 225 | |
| 226 | salt: |
| 227 | master: |
| 228 | engine: |
| 229 | docker_events: |
| 230 | docker_url: unix://var/run/docker.sock |
| 231 | |
Ales Komarek | 5474068 | 2017-05-15 07:16:23 +0200 | [diff] [blame] | 232 | Salt master peer setup for remote certificate signing |
Jakub Pavlik | d485984 | 2016-05-23 10:48:04 +0200 | [diff] [blame] | 233 | |
| 234 | .. code-block:: yaml |
| 235 | |
| 236 | salt: |
| 237 | master: |
| 238 | peer: |
| 239 | ".*": |
| 240 | - x509.sign_remote_certificate |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 241 | |
Ales Komarek | b2ada52 | 2017-12-07 11:31:32 +0100 | [diff] [blame] | 242 | |
| 243 | Salt master backup configuration |
| 244 | |
| 245 | .. code-block:: yaml |
| 246 | |
| 247 | salt: |
| 248 | master: |
| 249 | backup: true |
| 250 | initial_data: |
| 251 | engine: backupninja |
Jiri Broulik | 3e28164 | 2018-03-02 18:17:21 +0100 | [diff] [blame] | 252 | home_dir: remote-backup-home-dir |
Ales Komarek | b2ada52 | 2017-12-07 11:31:32 +0100 | [diff] [blame] | 253 | source: backup-node-host |
| 254 | host: original-salt-master-id |
| 255 | |
Tomáš Kukrál | 8922aef | 2017-05-10 10:27:04 +0200 | [diff] [blame] | 256 | Configure verbosity of state output (used for `salt` command) |
| 257 | |
| 258 | .. code-block:: yaml |
| 259 | |
| 260 | salt: |
| 261 | master: |
Tomáš Kukrál | 044667b | 2017-05-11 10:12:15 +0200 | [diff] [blame] | 262 | state_output: changes |
Tomáš Kukrál | 8922aef | 2017-05-10 10:27:04 +0200 | [diff] [blame] | 263 | |
Ales Komarek | d768f1c | 2018-01-30 22:37:18 +0100 | [diff] [blame] | 264 | Pass pillar render error to minion log |
| 265 | |
| 266 | .. note:: When set to `False` this option is great for debuging. |
| 267 | However it is not recomended for any production environment as it may contain |
| 268 | templating data as passwords, etc... , that minion should not expose. |
| 269 | |
| 270 | .. code-block:: yaml |
| 271 | |
| 272 | salt: |
| 273 | master: |
| 274 | pillar_safe_render_error: False |
| 275 | |
Ales Komarek | f44e64c | 2018-05-29 10:22:31 +0200 | [diff] [blame] | 276 | Enable Windows repo support |
| 277 | |
| 278 | .. code-block:: yaml |
| 279 | |
| 280 | salt: |
| 281 | master: |
| 282 | win_repo: |
| 283 | source: git |
| 284 | address: https://github.com/saltstack/salt-winrepo-ng |
| 285 | revision: master |
| 286 | |
Ales Komarek | d768f1c | 2018-01-30 22:37:18 +0100 | [diff] [blame] | 287 | |
| 288 | Event/Reactor Systems |
| 289 | ~~~~~~~~~~~~~~~~~~~~~ |
Petr Michalec | 1f541c4 | 2017-08-17 13:30:37 +0200 | [diff] [blame] | 290 | |
Ales Komarek | e7844d1 | 2017-06-08 12:00:01 +0200 | [diff] [blame] | 291 | Salt synchronise node pillar and modules after start |
Ales Komarek | 5474068 | 2017-05-15 07:16:23 +0200 | [diff] [blame] | 292 | |
| 293 | .. code-block:: yaml |
| 294 | |
| 295 | salt: |
| 296 | master: |
| 297 | reactor: |
| 298 | salt/minion/*/start: |
Ales Komarek | e7844d1 | 2017-06-08 12:00:01 +0200 | [diff] [blame] | 299 | - salt://salt/reactor/node_start.sls |
Ales Komarek | 5474068 | 2017-05-15 07:16:23 +0200 | [diff] [blame] | 300 | |
Ales Komarek | e7844d1 | 2017-06-08 12:00:01 +0200 | [diff] [blame] | 301 | Trigger basic node install |
| 302 | |
| 303 | .. code-block:: yaml |
| 304 | |
| 305 | salt: |
| 306 | master: |
| 307 | reactor: |
| 308 | salt/minion/install: |
| 309 | - salt://salt/reactor/node_install.sls |
| 310 | |
| 311 | Sample event to trigger the node installation |
| 312 | |
| 313 | .. code-block:: bash |
| 314 | |
| 315 | salt-call event.send 'salt/minion/install' |
| 316 | |
Ales Komarek | 213fbe0 | 2017-08-21 16:39:05 +0200 | [diff] [blame] | 317 | Run any defined orchestration pipeline |
Ales Komarek | 5c58de3 | 2017-06-06 11:49:32 +0200 | [diff] [blame] | 318 | |
| 319 | .. code-block:: yaml |
| 320 | |
| 321 | salt: |
| 322 | master: |
| 323 | reactor: |
| 324 | salt/orchestrate/start: |
| 325 | - salt://salt/reactor/orchestrate_start.sls |
| 326 | |
Ales Komarek | e7844d1 | 2017-06-08 12:00:01 +0200 | [diff] [blame] | 327 | Event to trigger the orchestration pipeline |
Ales Komarek | 5c58de3 | 2017-06-06 11:49:32 +0200 | [diff] [blame] | 328 | |
| 329 | .. code-block:: bash |
| 330 | |
Ales Komarek | e7844d1 | 2017-06-08 12:00:01 +0200 | [diff] [blame] | 331 | salt-call event.send 'salt/orchestrate/start' "{'orchestrate': 'salt/orchestrate/infra_install.sls'}" |
Ales Komarek | 5c58de3 | 2017-06-06 11:49:32 +0200 | [diff] [blame] | 332 | |
Ales Komarek | 3ed7c43 | 2017-08-24 16:15:49 +0200 | [diff] [blame] | 333 | Synchronise modules and pillars on minion start. |
| 334 | |
| 335 | .. code-block:: yaml |
| 336 | |
| 337 | salt: |
| 338 | master: |
| 339 | reactor: |
| 340 | 'salt/minion/*/start': |
| 341 | - salt://salt/reactor/minion_start.sls |
| 342 | |
Ales Komarek | 213fbe0 | 2017-08-21 16:39:05 +0200 | [diff] [blame] | 343 | Add and/or remove the minion key |
Ales Komarek | 5c58de3 | 2017-06-06 11:49:32 +0200 | [diff] [blame] | 344 | |
| 345 | .. code-block:: yaml |
| 346 | |
| 347 | salt: |
| 348 | master: |
| 349 | reactor: |
Ales Komarek | 213fbe0 | 2017-08-21 16:39:05 +0200 | [diff] [blame] | 350 | salt/key/create: |
| 351 | - salt://salt/reactor/key_create.sls |
| 352 | salt/key/remove: |
| 353 | - salt://salt/reactor/key_remove.sls |
Ales Komarek | 5c58de3 | 2017-06-06 11:49:32 +0200 | [diff] [blame] | 354 | |
Ales Komarek | 213fbe0 | 2017-08-21 16:39:05 +0200 | [diff] [blame] | 355 | Event to trigger the key creation |
Ales Komarek | 5c58de3 | 2017-06-06 11:49:32 +0200 | [diff] [blame] | 356 | |
| 357 | .. code-block:: bash |
| 358 | |
Adam Tengler | 6218896 | 2017-09-04 13:34:44 +0000 | [diff] [blame] | 359 | salt-call event.send 'salt/key/create' \ |
| 360 | > "{'node_id': 'id-of-minion', 'node_host': '172.16.10.100', 'orch_post_create': 'kubernetes.orchestrate.compute_install', 'post_create_pillar': {'node_name': 'id-of-minion'}}" |
Ales Komarek | 5c58de3 | 2017-06-06 11:49:32 +0200 | [diff] [blame] | 361 | |
Ales Komarek | 213fbe0 | 2017-08-21 16:39:05 +0200 | [diff] [blame] | 362 | .. note:: |
| 363 | |
| 364 | You can add pass additional `orch_pre_create`, `orch_post_create`, |
| 365 | `orch_pre_remove` or `orch_post_remove` parameters to the event to call |
| 366 | extra orchestrate files. This can be useful for example for |
| 367 | registering/unregistering nodes from the monitoring alarms or dashboards. |
| 368 | |
| 369 | The key creation event needs to be run from other machine than the one |
| 370 | being registered. |
| 371 | |
| 372 | Event to trigger the key removal |
| 373 | |
| 374 | .. code-block:: bash |
| 375 | |
| 376 | salt-call event.send 'salt/key/remove' |
Ales Komarek | 5474068 | 2017-05-15 07:16:23 +0200 | [diff] [blame] | 377 | |
Dzmitry Stremkouski | 7ee2340 | 2018-04-10 00:43:48 +0200 | [diff] [blame] | 378 | Control VM provisioning |
| 379 | |
| 380 | .. code-block:: yaml |
| 381 | |
| 382 | virt: |
| 383 | disk: |
| 384 | three_disks: |
| 385 | - system: |
| 386 | size: 4096 |
| 387 | image: ubuntu.qcow |
| 388 | - repository_snapshot: |
| 389 | size: 8192 |
| 390 | image: snapshot.qcow |
| 391 | - cinder-volume: |
| 392 | size: 2048 |
Ondrej Smola | e6bcb29 | 2018-04-13 10:56:39 +0200 | [diff] [blame] | 393 | nic: |
| 394 | control: |
| 395 | - name: nic01 |
| 396 | bridge: br-pxe |
| 397 | model: virtio |
| 398 | - name: nic02 |
| 399 | bridge: br-cp |
| 400 | model: virtio |
| 401 | - name: nic03 |
| 402 | bridge: br-store-front |
| 403 | model: virtio |
| 404 | - name: nic04 |
| 405 | bridge: br-public |
| 406 | model: virtio |
Dzmitry Stremkouski | b8acf1f | 2018-06-28 12:56:23 +0200 | [diff] [blame] | 407 | - name: nic05 |
| 408 | bridge: br-prv |
| 409 | model: virtio |
| 410 | virtualport: |
| 411 | type: openvswitch |
Ondrej Smola | e6bcb29 | 2018-04-13 10:56:39 +0200 | [diff] [blame] | 412 | |
Dzmitry Stremkouski | 7ee2340 | 2018-04-10 00:43:48 +0200 | [diff] [blame] | 413 | |
| 414 | salt: |
| 415 | control: |
| 416 | enabled: true |
| 417 | virt_enabled: true |
| 418 | size: |
| 419 | medium_three_disks: |
| 420 | cpu: 2 |
| 421 | ram: 4 |
| 422 | disk_profile: three_disks |
| 423 | cluster: |
| 424 | mycluster: |
| 425 | domain: neco.virt.domain.com |
| 426 | engine: virt |
Ondrej Smola | c7f6cfc | 2018-05-21 15:55:08 +0200 | [diff] [blame] | 427 | #Option to set rng globaly |
| 428 | rng: false |
Dzmitry Stremkouski | 7ee2340 | 2018-04-10 00:43:48 +0200 | [diff] [blame] | 429 | node: |
| 430 | ubuntu1: |
| 431 | provider: node01.domain.com |
| 432 | image: ubuntu.qcow |
| 433 | size: medium |
| 434 | img_dest: /var/lib/libvirt/ssdimages |
Ondrej Smola | c7f6cfc | 2018-05-21 15:55:08 +0200 | [diff] [blame] | 435 | #Rng defined on node will have higher priority then global one |
Dzmitry Stremkouski | 7ee2340 | 2018-04-10 00:43:48 +0200 | [diff] [blame] | 436 | rng: |
| 437 | backend: /dev/urandom |
| 438 | model: random |
| 439 | rate: |
| 440 | period: '1800' |
| 441 | bytes: '1500' |
Ondrej Smola | e6bcb29 | 2018-04-13 10:56:39 +0200 | [diff] [blame] | 442 | mac: |
| 443 | nic01: AC:DE:48:AA:AA:AA |
| 444 | nic02: AC:DE:48:AA:AA:BB |
| 445 | |
Oleh Hryhorov | ca6b917 | 2018-06-21 14:21:35 +0000 | [diff] [blame] | 446 | To enable Redis plugin for the Salt caching subsystem. The below pillar structure should be used |
| 447 | |
| 448 | .. code-block:: yaml |
| 449 | |
| 450 | salt: |
| 451 | master: |
| 452 | cache: |
| 453 | plugin: redis |
| 454 | host: localhost |
| 455 | port: 6379 |
| 456 | db: '0' |
| 457 | password: pass_word |
| 458 | bank_prefix: 'MCP' |
| 459 | bank_keys_prefix: 'MCPKEY' |
| 460 | key_prefix: 'KEY' |
| 461 | separator: '@' |
Ondrej Smola | e6bcb29 | 2018-04-13 10:56:39 +0200 | [diff] [blame] | 462 | |
Petr Michalec | 1f541c4 | 2017-08-17 13:30:37 +0200 | [diff] [blame] | 463 | |
Petr Michalec | df75d68 | 2018-02-07 13:43:53 +0100 | [diff] [blame] | 464 | Jinja options |
| 465 | ------------- |
| 466 | |
| 467 | Use following options to update default jinja renderer options. Salt recognize Jinja options for templates and for sls files. |
| 468 | |
| 469 | For full list of options check jinja documentation: http://jinja.pocoo.org/docs/api/#high-level-api. |
| 470 | |
| 471 | .. code-block:: yaml |
| 472 | |
| 473 | |
| 474 | salt: |
| 475 | renderer: |
| 476 | # for templates |
| 477 | jinja: &jina_env |
| 478 | # Default Jinja environment options |
| 479 | block_start_string: '{%' |
| 480 | block_end_string: '%}' |
| 481 | variable_start_string: '{{' |
| 482 | variable_end_string: '}}' |
| 483 | comment_start_string: '{#' |
| 484 | comment_end_string: '#}' |
| 485 | keep_trailing_newline: False |
| 486 | newline_sequence: '\n' |
| 487 | |
| 488 | # Next two are enabled by default in Salt |
| 489 | trim_blocks: True |
| 490 | lstrip_blocks: True |
| 491 | |
| 492 | # Next two are not enabled by default in Salt |
| 493 | # but worth to consider to enable in future for salt-formulas |
| 494 | line_statement_prefix: '%' |
| 495 | line_comment_prefix: '##' |
| 496 | |
| 497 | # for .sls state files |
| 498 | jinja_sls: *jinja_env |
| 499 | |
| 500 | |
| 501 | |
| 502 | With the line_statement/comment* _prefix options enabled following code statements are valid: |
| 503 | |
| 504 | .. code-block:: yaml |
| 505 | %- set myvar = 'one' |
| 506 | |
| 507 | ## You can mix even with '{%' |
| 508 | {%- set myvar = 'two' %} ## comment |
| 509 | %- set mylist = ['one', 'two', 'three'] ## comment |
| 510 | |
| 511 | ## comment |
| 512 | %- for item in mylist: ## comment |
| 513 | {{- item }} |
| 514 | %- endfor |
| 515 | |
| 516 | |
| 517 | Encrypted pillars |
Ales Komarek | d768f1c | 2018-01-30 22:37:18 +0100 | [diff] [blame] | 518 | ~~~~~~~~~~~~~~~~~ |
Petr Michalec | 1f541c4 | 2017-08-17 13:30:37 +0200 | [diff] [blame] | 519 | |
| 520 | Note: NACL + below configuration will be available in Salt > 2017.7. |
| 521 | |
| 522 | External resources: |
| 523 | |
| 524 | - Tutorial to configure salt + reclass ext_pillar and nacl: http://apealive.net/post/2017-09-salt-nacl-ext-pillar/ |
| 525 | - Saltstack documentation: https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.nacl.html |
| 526 | |
| 527 | Configure salt NACL module: |
| 528 | |
| 529 | .. code-block:: shell |
| 530 | |
| 531 | pip install --upgrade libnacl===1.5.2 |
| 532 | salt-call --local nacl.keygen /etc/salt/pki/master/nacl |
| 533 | |
| 534 | local: |
| 535 | saved sk_file:/etc/salt/pki/master/nacl pk_file: /etc/salt/pki/master/nacl.pub |
| 536 | |
| 537 | |
| 538 | .. code-block:: yaml |
| 539 | |
| 540 | salt: |
| 541 | master: |
| 542 | pillar: |
| 543 | reclass: *reclass |
| 544 | nacl: |
| 545 | index: 99 |
| 546 | nacl: |
| 547 | box_type: sealedbox |
| 548 | sk_file: /etc/salt/pki/master/nacl |
| 549 | pk_file: /etc/salt/pki/master/nacl.pub |
| 550 | #sk: None |
| 551 | #pk: None |
| 552 | |
| 553 | NACL encrypt secrets: |
| 554 | |
| 555 | salt-call --local nacl.enc 'my_secret_value' pk_file=/etc/salt/pki/master/nacl.pub |
| 556 | hXTkJpC1hcKMS7yZVGESutWrkvzusXfETXkacSklIxYjfWDlMJmR37MlmthdIgjXpg4f2AlBKb8tc9Woma7q |
| 557 | # or |
| 558 | salt-run nacl.enc 'myotherpass' |
| 559 | ADDFD0Rav6p6+63sojl7Htfrncp5rrDVyeE4BSPO7ipq8fZuLDIVAzQLf4PCbDqi+Fau5KD3/J/E+Pw= |
| 560 | |
| 561 | |
| 562 | NACL encrypted values on pillar: |
| 563 | |
| 564 | Use Boxed syntax `NACL[CryptedValue=]` to encode value on pillar: |
| 565 | |
| 566 | .. code-block:: yaml |
| 567 | |
| 568 | my_pillar: |
| 569 | my_nacl: |
| 570 | key0: unencrypted_value |
| 571 | key1: NACL[hXTkJpC1hcKMS7yZVGESutWrkvzusXfETXkacSklIxYjfWDlMJmR37MlmthdIgjXpg4f2AlBKb8tc9Woma7q] |
| 572 | |
| 573 | NACL large files: |
| 574 | |
| 575 | .. code-block:: shell |
| 576 | salt-call nacl.enc_file /tmp/cert.crt out=/srv/salt/env/dev/cert.nacl |
| 577 | # or more advanced |
| 578 | cert=$(cat /tmp/cert.crt) |
| 579 | salt-call --out=newline_values_only nacl.enc_pub data="$cert" > /srv/salt/env/dev/cert.nacl |
| 580 | |
| 581 | |
| 582 | NACL within template/native pillars: |
| 583 | |
| 584 | pillarexample: |
| 585 | user: root |
| 586 | password1: {{salt.nacl.dec('DRB7Q6/X5gGSRCTpZyxS6hlbWj0llUA+uaVyvou3vJ4=')|json}} |
| 587 | cert_key: {{salt.nacl.dec_file('/srv/salt/env/dev/certs/example.com/cert.nacl')|json}} |
| 588 | cert_key2: {{salt.nacl.dec_file('salt:///certs/example.com/cert2.nacl')|json}} |
| 589 | |
Ales Komarek | d768f1c | 2018-01-30 22:37:18 +0100 | [diff] [blame] | 590 | |
| 591 | Salt Syndic |
Ales Komarek | 5474068 | 2017-05-15 07:16:23 +0200 | [diff] [blame] | 592 | ----------- |
| 593 | |
| 594 | The master of masters |
| 595 | |
| 596 | .. code-block:: yaml |
| 597 | |
| 598 | salt: |
| 599 | master: |
| 600 | enabled: true |
| 601 | order_masters: True |
| 602 | |
| 603 | Lower syndicated master |
| 604 | |
| 605 | .. code-block:: yaml |
| 606 | |
| 607 | salt: |
| 608 | syndic: |
| 609 | enabled: true |
| 610 | master: |
| 611 | host: master-of-master-host |
| 612 | timeout: 5 |
| 613 | |
| 614 | Syndicated master with multiple master of masters |
| 615 | |
| 616 | .. code-block:: yaml |
| 617 | |
| 618 | salt: |
| 619 | syndic: |
| 620 | enabled: true |
| 621 | masters: |
| 622 | - host: master-of-master-host1 |
| 623 | - host: master-of-master-host2 |
| 624 | timeout: 5 |
| 625 | |
| 626 | |
Ales Komarek | d768f1c | 2018-01-30 22:37:18 +0100 | [diff] [blame] | 627 | Salt Minion |
| 628 | ----------- |
| 629 | |
Petr Michalec | cfd93e1 | 2018-06-26 18:11:44 +0200 | [diff] [blame] | 630 | Minion ID by default trigger dependency on linux formula, as it uses fqdn configured from `linux.system.name` and |
| 631 | `linux.system.domain` pillar. To override, provide exact minion ID you require. The same can be sate for master id rendered |
| 632 | at `master.conf`. |
| 633 | |
| 634 | .. code-block:: yaml |
| 635 | |
| 636 | salt: |
| 637 | minion: |
| 638 | id: minion1.production |
| 639 | master: |
| 640 | id: master.production |
| 641 | |
Ales Komarek | d768f1c | 2018-01-30 22:37:18 +0100 | [diff] [blame] | 642 | Simplest Salt minion setup with central configuration node |
| 643 | |
| 644 | .. code-block:: yaml |
| 645 | |
| 646 | .. literalinclude:: tests/pillar/minion_master.sls |
| 647 | :language: yaml |
| 648 | |
| 649 | Multi-master Salt minion setup |
| 650 | |
| 651 | .. literalinclude:: tests/pillar/minion_multi_master.sls |
| 652 | :language: yaml |
| 653 | |
| 654 | Salt minion with salt mine options |
| 655 | |
| 656 | .. literalinclude:: tests/pillar/minion_mine.sls |
| 657 | :language: yaml |
| 658 | |
| 659 | Salt minion with graphing dependencies |
| 660 | |
| 661 | .. literalinclude:: tests/pillar/minion_graph.sls |
| 662 | :language: yaml |
| 663 | |
| 664 | Salt minion behind HTTP proxy |
| 665 | |
| 666 | .. code-block:: yaml |
| 667 | |
| 668 | salt: |
| 669 | minion: |
| 670 | proxy: |
| 671 | host: 127.0.0.1 |
| 672 | port: 3128 |
| 673 | |
| 674 | Salt minion to specify non-default HTTP backend. The default tornado backend |
| 675 | does not respect HTTP proxy settings set as environment variables. This is |
| 676 | useful for cases where you need to set no_proxy lists. |
| 677 | |
| 678 | .. code-block:: yaml |
| 679 | |
| 680 | salt: |
| 681 | minion: |
| 682 | backend: urllib2 |
| 683 | |
| 684 | |
| 685 | Salt minion with PKI certificate authority (CA) |
| 686 | |
| 687 | .. literalinclude:: tests/pillar/minion_pki_ca.sls |
| 688 | :language: yaml |
| 689 | |
| 690 | Salt minion using PKI certificate |
| 691 | |
| 692 | .. literalinclude:: tests/pillar/minion_pki_cert.sls |
| 693 | :language: yaml |
| 694 | |
| 695 | Salt minion trust CA certificates issued by salt CA on a specific host (ie: salt-master node) |
| 696 | |
| 697 | .. code-block:: yaml |
| 698 | |
| 699 | salt: |
| 700 | minion: |
| 701 | trusted_ca_minions: |
| 702 | - cfg01 |
| 703 | |
| 704 | |
| 705 | Salt Minion Proxy |
| 706 | ~~~~~~~~~~~~~~~~~ |
Jiri Broulik | a0f4668 | 2017-04-20 22:45:01 +0200 | [diff] [blame] | 707 | |
| 708 | Salt proxy pillar |
| 709 | |
| 710 | .. code-block:: yaml |
| 711 | |
| 712 | salt: |
| 713 | minion: |
Jiri Broulik | 8827524 | 2017-05-24 17:21:17 +0200 | [diff] [blame] | 714 | proxy_minion: |
Jiri Broulik | a0f4668 | 2017-04-20 22:45:01 +0200 | [diff] [blame] | 715 | master: localhost |
| 716 | device: |
| 717 | vsrx01.mydomain.local: |
| 718 | enabled: true |
| 719 | engine: napalm |
| 720 | csr1000v.mydomain.local: |
| 721 | enabled: true |
| 722 | engine: napalm |
| 723 | |
| 724 | .. note:: This is pillar of the the real salt-minion |
| 725 | |
| 726 | |
| 727 | Proxy pillar for IOS device |
| 728 | |
| 729 | .. code-block:: yaml |
| 730 | |
| 731 | proxy: |
| 732 | proxytype: napalm |
| 733 | driver: ios |
| 734 | host: csr1000v.mydomain.local |
| 735 | username: root |
| 736 | passwd: r00tme |
| 737 | |
| 738 | .. note:: This is pillar of the node thats not able to run salt-minion itself |
| 739 | |
| 740 | |
| 741 | Proxy pillar for JunOS device |
| 742 | |
| 743 | .. code-block:: yaml |
| 744 | |
| 745 | proxy: |
| 746 | proxytype: napalm |
| 747 | driver: junos |
| 748 | host: vsrx01.mydomain.local |
| 749 | username: root |
| 750 | passwd: r00tme |
| 751 | optional_args: |
| 752 | config_format: set |
| 753 | |
| 754 | .. note:: This is pillar of the node thats not able to run salt-minion itself |
| 755 | |
Ales Komarek | 8fb1da8 | 2016-08-21 23:52:03 +0200 | [diff] [blame] | 756 | |
| 757 | Salt SSH |
Ales Komarek | d768f1c | 2018-01-30 22:37:18 +0100 | [diff] [blame] | 758 | ~~~~~~~~ |
Ales Komarek | 8fb1da8 | 2016-08-21 23:52:03 +0200 | [diff] [blame] | 759 | |
| 760 | Salt SSH with sudoer using key |
| 761 | |
| 762 | .. literalinclude:: tests/pillar/master_ssh_minion_key.sls |
| 763 | :language: yaml |
| 764 | |
| 765 | Salt SSH with sudoer using password |
| 766 | |
| 767 | .. literalinclude:: tests/pillar/master_ssh_minion_password.sls |
| 768 | :language: yaml |
| 769 | |
| 770 | Salt SSH with root using password |
| 771 | |
| 772 | .. literalinclude:: tests/pillar/master_ssh_minion_root.sls |
| 773 | :language: yaml |
| 774 | |
Ales Komarek | 8ba9c0b | 2016-02-21 14:59:59 +0100 | [diff] [blame] | 775 | Salt control (cloud/kvm/docker) |
| 776 | ------------------------------- |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 777 | |
Ales Komarek | 8ba9c0b | 2016-02-21 14:59:59 +0100 | [diff] [blame] | 778 | Salt cloud with local OpenStack provider |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 779 | |
Ales Komarek | 8ba9c0b | 2016-02-21 14:59:59 +0100 | [diff] [blame] | 780 | .. literalinclude:: tests/pillar/control_cloud_openstack.sls |
| 781 | :language: yaml |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 782 | |
| 783 | Salt cloud with Digital Ocean provider |
| 784 | |
Ales Komarek | 8ba9c0b | 2016-02-21 14:59:59 +0100 | [diff] [blame] | 785 | .. literalinclude:: tests/pillar/control_cloud_digitalocean.sls |
| 786 | :language: yaml |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 787 | |
Ales Komarek | 8fb1da8 | 2016-08-21 23:52:03 +0200 | [diff] [blame] | 788 | Salt virt with KVM cluster |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 789 | |
Ales Komarek | 8ba9c0b | 2016-02-21 14:59:59 +0100 | [diff] [blame] | 790 | .. literalinclude:: tests/pillar/control_virt.sls |
| 791 | :language: yaml |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 792 | |
Mateusz Los | 4c7cd2d | 2018-01-09 11:46:07 +0100 | [diff] [blame] | 793 | salt virt with custom destination for image file |
| 794 | |
| 795 | .. literalinclude:: tests/pillar/control_virt_custom.sls |
| 796 | :language: yaml |
| 797 | |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 798 | |
| 799 | Usage |
| 800 | ===== |
| 801 | |
| 802 | Working with salt-cloud |
| 803 | |
| 804 | .. code-block:: bash |
| 805 | |
| 806 | salt-cloud -m /path/to/map --assume-yes |
| 807 | |
| 808 | Debug LIBCLOUD for salt-cloud connection |
| 809 | |
| 810 | .. code-block:: bash |
| 811 | |
| 812 | export LIBCLOUD_DEBUG=/dev/stderr; salt-cloud --list-sizes provider_name --log-level all |
| 813 | |
Ales Komarek | 8ba9c0b | 2016-02-21 14:59:59 +0100 | [diff] [blame] | 814 | |
Ales Komarek | d768f1c | 2018-01-30 22:37:18 +0100 | [diff] [blame] | 815 | References |
| 816 | ========== |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 817 | |
| 818 | * http://salt.readthedocs.org/en/latest/ |
| 819 | * https://github.com/DanielBryan/salt-state-graph |
| 820 | * http://karlgrz.com/testing-salt-states-rapidly-with-docker/ |
| 821 | * https://mywushublog.com/2013/03/configuration-management-with-salt-stack/ |
| 822 | * http://russell.ballestrini.net/replace-the-nagios-scheduler-and-nrpe-with-salt-stack/ |
| 823 | * https://github.com/saltstack-formulas/salt-formula |
| 824 | * http://docs.saltstack.com/en/latest/topics/tutorials/multimaster.html |
| 825 | |
Ales Komarek | 8ba9c0b | 2016-02-21 14:59:59 +0100 | [diff] [blame] | 826 | |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 827 | salt-cloud |
| 828 | ---------- |
| 829 | |
| 830 | * http://www.blog.sandro-mathys.ch/2013/07/setting-user-password-when-launching.html |
| 831 | * http://cloudinit.readthedocs.org/en/latest/topics/examples.html |
| 832 | * http://salt-cloud.readthedocs.org/en/latest/topics/install/index.html |
| 833 | * http://docs.saltstack.com/topics/cloud/digitalocean.html |
| 834 | * http://salt-cloud.readthedocs.org/en/latest/topics/rackspace.html |
| 835 | * http://salt-cloud.readthedocs.org/en/latest/topics/map.html |
| 836 | * http://docs.saltstack.com/en/latest/topics/tutorials/multimaster.html |
Ales Komarek | 8ba9c0b | 2016-02-21 14:59:59 +0100 | [diff] [blame] | 837 | |
Filip Pytloun | 954dbd6 | 2017-02-02 13:02:03 +0100 | [diff] [blame] | 838 | |
| 839 | Documentation and Bugs |
| 840 | ====================== |
| 841 | |
| 842 | To learn how to install and update salt-formulas, consult the documentation |
| 843 | available online at: |
| 844 | |
| 845 | http://salt-formulas.readthedocs.io/ |
| 846 | |
| 847 | In the unfortunate event that bugs are discovered, they should be reported to |
| 848 | the appropriate issue tracker. Use Github issue tracker for specific salt |
| 849 | formula: |
| 850 | |
| 851 | https://github.com/salt-formulas/salt-formula-salt/issues |
| 852 | |
| 853 | For feature requests, bug reports or blueprints affecting entire ecosystem, |
| 854 | use Launchpad salt-formulas project: |
| 855 | |
| 856 | https://launchpad.net/salt-formulas |
| 857 | |
| 858 | You can also join salt-formulas-users team and subscribe to mailing list: |
| 859 | |
| 860 | https://launchpad.net/~salt-formulas-users |
| 861 | |
| 862 | Developers wishing to work on the salt-formulas projects should always base |
| 863 | their work on master branch and submit pull request against specific formula. |
| 864 | |
| 865 | https://github.com/salt-formulas/salt-formula-salt |
| 866 | |
| 867 | Any questions or feedback is always welcome so feel free to join our IRC |
| 868 | channel: |
| 869 | |
| 870 | #salt-formulas @ irc.freenode.net |