Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 1 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 2 | ===== |
| 3 | Usage |
| 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 | Sample Metadata |
| 14 | =============== |
| 15 | |
Ales Komarek | d768f1c | 2018-01-30 22:37:18 +0100 | [diff] [blame] | 16 | Salt Master |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 17 | ----------- |
| 18 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 19 | Salt master with base formulas and pillar metadata back end: |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 20 | |
Ales Komarek | 8ba9c0b | 2016-02-21 14:59:59 +0100 | [diff] [blame] | 21 | .. literalinclude:: tests/pillar/master_single_pillar.sls |
| 22 | :language: yaml |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 23 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 24 | Salt master with reclass ENC metadata back end: |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 25 | |
Ales Komarek | 8ba9c0b | 2016-02-21 14:59:59 +0100 | [diff] [blame] | 26 | .. literalinclude:: tests/pillar/master_single_reclass.sls |
| 27 | :language: yaml |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 28 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 29 | Salt master with Architect ENC metadata back end: |
Ales Komarek | 459407b | 2018-01-18 17:16:31 +0100 | [diff] [blame] | 30 | |
| 31 | .. code-block:: yaml |
| 32 | |
| 33 | salt: |
| 34 | master: |
| 35 | enabled: true |
| 36 | pillar: |
| 37 | engine: architect |
| 38 | project: project-name |
| 39 | host: architect-api |
| 40 | port: 8181 |
| 41 | username: salt |
| 42 | password: password |
| 43 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 44 | Salt master with multiple ``ext_pillars``: |
Petr Michalec | 1f541c4 | 2017-08-17 13:30:37 +0200 | [diff] [blame] | 45 | |
Dzmitry Stremkouski | 7b15d8a | 2018-08-11 22:02:45 +0200 | [diff] [blame] | 46 | .. code-block:: yaml |
| 47 | |
| 48 | salt: |
| 49 | master: |
| 50 | enabled: true |
| 51 | pillar: |
| 52 | engine: salt |
| 53 | source: |
| 54 | engine: local |
| 55 | ext_pillars: |
| 56 | 1: |
| 57 | module: cmd_json |
| 58 | params: '"echo {\"arg\": \"val\"}"' |
| 59 | 2: |
| 60 | module: cmd_yaml |
| 61 | params: /usr/local/bin/get_yml.sh |
Petr Michalec | 1f541c4 | 2017-08-17 13:30:37 +0200 | [diff] [blame] | 62 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 63 | Salt master with API: |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 64 | |
Ales Komarek | b2c8ff6 | 2016-08-22 00:20:01 +0200 | [diff] [blame] | 65 | .. literalinclude:: tests/pillar/master_api.sls |
| 66 | :language: yaml |
Ales Komarek | cdb280f | 2016-07-27 15:37:51 +0200 | [diff] [blame] | 67 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 68 | Salt master with defined user ACLs: |
Ales Komarek | cdb280f | 2016-07-27 15:37:51 +0200 | [diff] [blame] | 69 | |
Ales Komarek | b2c8ff6 | 2016-08-22 00:20:01 +0200 | [diff] [blame] | 70 | .. literalinclude:: tests/pillar/master_acl.sls |
| 71 | :language: yaml |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 72 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 73 | Salt master with preset minions: |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 74 | |
| 75 | .. code-block:: yaml |
| 76 | |
| 77 | salt: |
| 78 | master: |
| 79 | enabled: true |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 80 | minions: |
| 81 | - name: 'node1.system.location.domain.com' |
| 82 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 83 | Salt master with pip based installation (optional): |
Adam Tengler | caedd97 | 2016-05-04 16:44:00 +0200 | [diff] [blame] | 84 | |
| 85 | .. code-block:: yaml |
| 86 | |
| 87 | salt: |
| 88 | master: |
| 89 | enabled: true |
| 90 | ... |
| 91 | source: |
| 92 | engine: pip |
| 93 | version: 2016.3.0rc2 |
| 94 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 95 | Install formula through system package management: |
Adam Tengler | 3eb85ad | 2016-05-06 02:52:40 +0200 | [diff] [blame] | 96 | |
| 97 | .. code-block:: yaml |
| 98 | |
| 99 | salt: |
| 100 | master: |
| 101 | enabled: true |
| 102 | ... |
| 103 | environment: |
| 104 | prd: |
Petr Michalec | 7a2f1d2 | 2017-05-17 22:08:32 +0200 | [diff] [blame] | 105 | keystone: |
Adam Tengler | 3eb85ad | 2016-05-06 02:52:40 +0200 | [diff] [blame] | 106 | source: pkg |
| 107 | name: salt-formula-keystone |
Petr Michalec | 7a2f1d2 | 2017-05-17 22:08:32 +0200 | [diff] [blame] | 108 | nova: |
| 109 | source: pkg |
| 110 | name: salt-formula-keystone |
| 111 | version: 0.1+0~20160818133412.24~1.gbp6e1ebb |
| 112 | postresql: |
| 113 | source: pkg |
| 114 | name: salt-formula-postgresql |
| 115 | version: purged |
| 116 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 117 | Formula keystone is installed latest version and the formulas |
| 118 | without version are installed in one call to aptpkg module. |
| 119 | If the version attribute is present sls iterates over formulas |
| 120 | and take action to install specific version or remove it. |
| 121 | The version attribute may have these values |
| 122 | ``[latest|purged|removed|<VERSION>]``. |
Adam Tengler | 3eb85ad | 2016-05-06 02:52:40 +0200 | [diff] [blame] | 123 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 124 | Clone master branch of keystone formula as local feature branch: |
Adam Tengler | 3eb85ad | 2016-05-06 02:52:40 +0200 | [diff] [blame] | 125 | |
| 126 | .. code-block:: yaml |
| 127 | |
| 128 | salt: |
| 129 | master: |
| 130 | enabled: true |
| 131 | ... |
| 132 | environment: |
| 133 | dev: |
| 134 | formula: |
| 135 | keystone: |
| 136 | source: git |
| 137 | address: git@github.com:openstack/salt-formula-keystone.git |
| 138 | revision: master |
| 139 | branch: feature |
| 140 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 141 | Salt master with specified formula refs (for example, for Gerrit |
| 142 | review): |
Adam Tengler | 3eb85ad | 2016-05-06 02:52:40 +0200 | [diff] [blame] | 143 | |
| 144 | .. code-block:: yaml |
| 145 | |
| 146 | salt: |
| 147 | master: |
| 148 | enabled: true |
| 149 | ... |
| 150 | environment: |
| 151 | dev: |
| 152 | formula: |
| 153 | keystone: |
| 154 | source: git |
| 155 | address: https://git.openstack.org/openstack/salt-formula-keystone |
| 156 | revision: refs/changes/56/123456/1 |
| 157 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 158 | Salt master logging configuration: |
Oleksii Chupryn | 7b7102a | 2018-05-11 10:32:11 +0300 | [diff] [blame] | 159 | |
| 160 | .. code-block:: yaml |
| 161 | |
| 162 | salt: |
| 163 | master: |
| 164 | enabled: true |
| 165 | log: |
| 166 | level: warning |
| 167 | file: '/var/log/salt/master' |
| 168 | level_logfile: warning |
| 169 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 170 | Salt minion logging configuration: |
Oleksii Chupryn | 7b7102a | 2018-05-11 10:32:11 +0300 | [diff] [blame] | 171 | |
| 172 | .. code-block:: yaml |
| 173 | |
| 174 | salt: |
| 175 | minion: |
| 176 | enabled: true |
| 177 | log: |
| 178 | level: info |
| 179 | file: '/var/log/salt/minion' |
| 180 | level_logfile: warning |
| 181 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 182 | Salt master with logging handlers: |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 183 | |
| 184 | .. code-block:: yaml |
| 185 | |
| 186 | salt: |
| 187 | master: |
| 188 | enabled: true |
Ales Komarek | 8ba9c0b | 2016-02-21 14:59:59 +0100 | [diff] [blame] | 189 | handler: |
| 190 | handler01: |
| 191 | engine: udp |
| 192 | bind: |
| 193 | host: 127.0.0.1 |
| 194 | port: 9999 |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 195 | minion: |
Ales Komarek | 8ba9c0b | 2016-02-21 14:59:59 +0100 | [diff] [blame] | 196 | handler: |
| 197 | handler01: |
| 198 | engine: udp |
| 199 | bind: |
| 200 | host: 127.0.0.1 |
| 201 | port: 9999 |
| 202 | handler02: |
| 203 | engine: zmq |
| 204 | bind: |
| 205 | host: 127.0.0.1 |
| 206 | port: 9999 |
| 207 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 208 | Salt engine definition for saltgraph metadata collector: |
Ales Komarek | a9fc6e7 | 2017-09-06 15:02:40 +0200 | [diff] [blame] | 209 | |
| 210 | .. code-block:: yaml |
| 211 | |
| 212 | salt: |
| 213 | master: |
| 214 | engine: |
| 215 | graph_metadata: |
| 216 | engine: saltgraph |
| 217 | host: 127.0.0.1 |
| 218 | port: 5432 |
| 219 | user: salt |
| 220 | password: salt |
| 221 | database: salt |
| 222 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 223 | Salt engine definition for Architect service: |
Ales Komarek | 459407b | 2018-01-18 17:16:31 +0100 | [diff] [blame] | 224 | |
| 225 | .. code-block:: yaml |
| 226 | |
| 227 | salt: |
| 228 | master: |
| 229 | engine: |
| 230 | architect: |
| 231 | engine: architect |
| 232 | project: project-name |
| 233 | host: architect-api |
| 234 | port: 8181 |
| 235 | username: salt |
| 236 | password: password |
| 237 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 238 | Salt engine definition for sending events from docker events: |
Ales Komarek | a9fc6e7 | 2017-09-06 15:02:40 +0200 | [diff] [blame] | 239 | |
| 240 | .. code-block:: yaml |
| 241 | |
| 242 | salt: |
| 243 | master: |
| 244 | engine: |
| 245 | docker_events: |
| 246 | docker_url: unix://var/run/docker.sock |
| 247 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 248 | Salt master peer setup for remote certificate signing: |
Jakub Pavlik | d485984 | 2016-05-23 10:48:04 +0200 | [diff] [blame] | 249 | |
| 250 | .. code-block:: yaml |
| 251 | |
| 252 | salt: |
| 253 | master: |
| 254 | peer: |
| 255 | ".*": |
| 256 | - x509.sign_remote_certificate |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 257 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 258 | Salt master backup configuration: |
Ales Komarek | b2ada52 | 2017-12-07 11:31:32 +0100 | [diff] [blame] | 259 | |
| 260 | .. code-block:: yaml |
| 261 | |
| 262 | salt: |
| 263 | master: |
| 264 | backup: true |
| 265 | initial_data: |
| 266 | engine: backupninja |
Jiri Broulik | 3e28164 | 2018-03-02 18:17:21 +0100 | [diff] [blame] | 267 | home_dir: remote-backup-home-dir |
Ales Komarek | b2ada52 | 2017-12-07 11:31:32 +0100 | [diff] [blame] | 268 | source: backup-node-host |
| 269 | host: original-salt-master-id |
| 270 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 271 | Configure verbosity of state output (used for :command:`salt` |
| 272 | command): |
Tomáš Kukrál | 8922aef | 2017-05-10 10:27:04 +0200 | [diff] [blame] | 273 | |
| 274 | .. code-block:: yaml |
| 275 | |
| 276 | salt: |
| 277 | master: |
Tomáš Kukrál | 044667b | 2017-05-11 10:12:15 +0200 | [diff] [blame] | 278 | state_output: changes |
Tomáš Kukrál | 8922aef | 2017-05-10 10:27:04 +0200 | [diff] [blame] | 279 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 280 | Pass pillar render error to minion log: |
Ales Komarek | d768f1c | 2018-01-30 22:37:18 +0100 | [diff] [blame] | 281 | |
| 282 | .. note:: When set to `False` this option is great for debuging. |
| 283 | However it is not recomended for any production environment as it may contain |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 284 | templating data as passwords, and so on, that minion should not expose. |
Ales Komarek | d768f1c | 2018-01-30 22:37:18 +0100 | [diff] [blame] | 285 | |
| 286 | .. code-block:: yaml |
| 287 | |
| 288 | salt: |
| 289 | master: |
| 290 | pillar_safe_render_error: False |
| 291 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 292 | Enable Windows repository support: |
Ales Komarek | f44e64c | 2018-05-29 10:22:31 +0200 | [diff] [blame] | 293 | |
| 294 | .. code-block:: yaml |
| 295 | |
| 296 | salt: |
| 297 | master: |
| 298 | win_repo: |
| 299 | source: git |
| 300 | address: https://github.com/saltstack/salt-winrepo-ng |
| 301 | revision: master |
| 302 | |
Ivan Suzdal | 7e2a2ca | 2018-08-23 12:31:19 +0400 | [diff] [blame] | 303 | Configure a gitfs_remotes resource: |
| 304 | |
| 305 | .. code-block:: yaml |
| 306 | |
| 307 | salt: |
| 308 | master: |
| 309 | gitfs_remotes: |
| 310 | salt_formula: |
Pavel Cizinsky | 6b67f5f | 2018-12-12 12:03:18 +0100 | [diff] [blame] | 311 | url: https://gerrit.mcp.mirantis.com/salt-formulas/salt.git |
Ivan Suzdal | 7e2a2ca | 2018-08-23 12:31:19 +0400 | [diff] [blame] | 312 | enabled: true |
| 313 | params: |
| 314 | base: master |
| 315 | |
| 316 | Read more about gitfs resource options in the official Salt documentation. |
| 317 | |
| 318 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 319 | Event/Reactor systems |
Ales Komarek | d768f1c | 2018-01-30 22:37:18 +0100 | [diff] [blame] | 320 | ~~~~~~~~~~~~~~~~~~~~~ |
Petr Michalec | 1f541c4 | 2017-08-17 13:30:37 +0200 | [diff] [blame] | 321 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 322 | Salt to synchronize node pillar and modules after start: |
Ales Komarek | 5474068 | 2017-05-15 07:16:23 +0200 | [diff] [blame] | 323 | |
| 324 | .. code-block:: yaml |
| 325 | |
| 326 | salt: |
| 327 | master: |
| 328 | reactor: |
| 329 | salt/minion/*/start: |
Ales Komarek | e7844d1 | 2017-06-08 12:00:01 +0200 | [diff] [blame] | 330 | - salt://salt/reactor/node_start.sls |
Ales Komarek | 5474068 | 2017-05-15 07:16:23 +0200 | [diff] [blame] | 331 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 332 | Trigger basic node install: |
Ales Komarek | e7844d1 | 2017-06-08 12:00:01 +0200 | [diff] [blame] | 333 | |
| 334 | .. code-block:: yaml |
| 335 | |
| 336 | salt: |
| 337 | master: |
| 338 | reactor: |
| 339 | salt/minion/install: |
| 340 | - salt://salt/reactor/node_install.sls |
| 341 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 342 | Sample event to trigger the node installation: |
Ales Komarek | e7844d1 | 2017-06-08 12:00:01 +0200 | [diff] [blame] | 343 | |
| 344 | .. code-block:: bash |
| 345 | |
| 346 | salt-call event.send 'salt/minion/install' |
| 347 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 348 | Run any defined orchestration pipeline: |
Ales Komarek | 5c58de3 | 2017-06-06 11:49:32 +0200 | [diff] [blame] | 349 | |
| 350 | .. code-block:: yaml |
| 351 | |
| 352 | salt: |
| 353 | master: |
| 354 | reactor: |
| 355 | salt/orchestrate/start: |
| 356 | - salt://salt/reactor/orchestrate_start.sls |
| 357 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 358 | Event to trigger the orchestration pipeline: |
Ales Komarek | 5c58de3 | 2017-06-06 11:49:32 +0200 | [diff] [blame] | 359 | |
| 360 | .. code-block:: bash |
| 361 | |
Ales Komarek | e7844d1 | 2017-06-08 12:00:01 +0200 | [diff] [blame] | 362 | 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] | 363 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 364 | Synchronise modules and pillars on minion start: |
Ales Komarek | 3ed7c43 | 2017-08-24 16:15:49 +0200 | [diff] [blame] | 365 | |
| 366 | .. code-block:: yaml |
| 367 | |
| 368 | salt: |
| 369 | master: |
| 370 | reactor: |
| 371 | 'salt/minion/*/start': |
| 372 | - salt://salt/reactor/minion_start.sls |
| 373 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 374 | Add and/or remove the minion key: |
Ales Komarek | 5c58de3 | 2017-06-06 11:49:32 +0200 | [diff] [blame] | 375 | |
| 376 | .. code-block:: yaml |
| 377 | |
| 378 | salt: |
| 379 | master: |
| 380 | reactor: |
Ales Komarek | 213fbe0 | 2017-08-21 16:39:05 +0200 | [diff] [blame] | 381 | salt/key/create: |
| 382 | - salt://salt/reactor/key_create.sls |
| 383 | salt/key/remove: |
| 384 | - salt://salt/reactor/key_remove.sls |
Ales Komarek | 5c58de3 | 2017-06-06 11:49:32 +0200 | [diff] [blame] | 385 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 386 | Event to trigger the key creation: |
Ales Komarek | 5c58de3 | 2017-06-06 11:49:32 +0200 | [diff] [blame] | 387 | |
| 388 | .. code-block:: bash |
| 389 | |
Adam Tengler | 6218896 | 2017-09-04 13:34:44 +0000 | [diff] [blame] | 390 | salt-call event.send 'salt/key/create' \ |
| 391 | > "{'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] | 392 | |
Ales Komarek | 213fbe0 | 2017-08-21 16:39:05 +0200 | [diff] [blame] | 393 | .. note:: |
| 394 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 395 | You can add pass additional ``orch_pre_create``, ``orch_post_create``, |
| 396 | ``orch_pre_remove`` or ``orch_post_remove`` parameters to the event |
| 397 | to call extra orchestrate files. This can be useful for example for |
Ales Komarek | 213fbe0 | 2017-08-21 16:39:05 +0200 | [diff] [blame] | 398 | registering/unregistering nodes from the monitoring alarms or dashboards. |
| 399 | |
| 400 | The key creation event needs to be run from other machine than the one |
| 401 | being registered. |
| 402 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 403 | Event to trigger the key removal: |
Ales Komarek | 213fbe0 | 2017-08-21 16:39:05 +0200 | [diff] [blame] | 404 | |
| 405 | .. code-block:: bash |
| 406 | |
| 407 | salt-call event.send 'salt/key/remove' |
Ales Komarek | 5474068 | 2017-05-15 07:16:23 +0200 | [diff] [blame] | 408 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 409 | Control VM provisioning: |
Dzmitry Stremkouski | 7ee2340 | 2018-04-10 00:43:48 +0200 | [diff] [blame] | 410 | |
| 411 | .. code-block:: yaml |
| 412 | |
Dzmitry Stremkouski | 97927ee | 2018-08-23 23:20:38 +0200 | [diff] [blame] | 413 | _param: |
Dzmitry Stremkouski | 30c7d2f | 2019-01-16 23:40:36 +0100 | [diff] [blame] | 414 | vcp_links: &vcp_links |
| 415 | - type: phy |
| 416 | id: ens2 |
| 417 | name: ens2 |
Dzmitry Stremkouski | 97927ee | 2018-08-23 23:20:38 +0200 | [diff] [blame] | 418 | private-ipv4: &private-ipv4 |
| 419 | - id: private-ipv4 |
| 420 | type: ipv4 |
| 421 | link: ens2 |
| 422 | netmask: 255.255.255.0 |
| 423 | routes: |
| 424 | - gateway: 192.168.0.1 |
| 425 | netmask: 0.0.0.0 |
| 426 | network: 0.0.0.0 |
Dzmitry Stremkouski | 7ee2340 | 2018-04-10 00:43:48 +0200 | [diff] [blame] | 427 | virt: |
| 428 | disk: |
| 429 | three_disks: |
| 430 | - system: |
| 431 | size: 4096 |
| 432 | image: ubuntu.qcow |
| 433 | - repository_snapshot: |
| 434 | size: 8192 |
| 435 | image: snapshot.qcow |
| 436 | - cinder-volume: |
| 437 | size: 2048 |
Ondrej Smola | e6bcb29 | 2018-04-13 10:56:39 +0200 | [diff] [blame] | 438 | nic: |
| 439 | control: |
| 440 | - name: nic01 |
| 441 | bridge: br-pxe |
| 442 | model: virtio |
| 443 | - name: nic02 |
| 444 | bridge: br-cp |
| 445 | model: virtio |
| 446 | - name: nic03 |
| 447 | bridge: br-store-front |
| 448 | model: virtio |
| 449 | - name: nic04 |
| 450 | bridge: br-public |
| 451 | model: virtio |
Dzmitry Stremkouski | b8acf1f | 2018-06-28 12:56:23 +0200 | [diff] [blame] | 452 | - name: nic05 |
| 453 | bridge: br-prv |
| 454 | model: virtio |
| 455 | virtualport: |
| 456 | type: openvswitch |
Ondrej Smola | e6bcb29 | 2018-04-13 10:56:39 +0200 | [diff] [blame] | 457 | |
Dzmitry Stremkouski | 7ee2340 | 2018-04-10 00:43:48 +0200 | [diff] [blame] | 458 | salt: |
| 459 | control: |
| 460 | enabled: true |
| 461 | virt_enabled: true |
| 462 | size: |
| 463 | medium_three_disks: |
| 464 | cpu: 2 |
| 465 | ram: 4 |
| 466 | disk_profile: three_disks |
| 467 | cluster: |
| 468 | mycluster: |
| 469 | domain: neco.virt.domain.com |
| 470 | engine: virt |
Martin Horak | 9e11aa2 | 2018-09-17 06:46:59 +0200 | [diff] [blame] | 471 | # Cluster global settings |
Ondrej Smola | c7f6cfc | 2018-05-21 15:55:08 +0200 | [diff] [blame] | 472 | rng: false |
Martin Horak | 9e11aa2 | 2018-09-17 06:46:59 +0200 | [diff] [blame] | 473 | enable_vnc: True |
Andrei Danin | 996e209 | 2018-09-10 21:58:23 -0700 | [diff] [blame] | 474 | seed: cloud-init |
Dzmitry Stremkouski | 97927ee | 2018-08-23 23:20:38 +0200 | [diff] [blame] | 475 | cloud_init: |
| 476 | user_data: |
| 477 | disable_ec2_metadata: true |
| 478 | resize_rootfs: True |
| 479 | timezone: UTC |
| 480 | ssh_deletekeys: True |
| 481 | ssh_genkeytypes: ['rsa', 'dsa', 'ecdsa'] |
| 482 | ssh_svcname: ssh |
| 483 | locale: en_US.UTF-8 |
| 484 | disable_root: true |
| 485 | apt_preserve_sources_list: false |
| 486 | apt: |
| 487 | sources_list: "" |
| 488 | sources: |
| 489 | ubuntu.list: |
| 490 | source: ${linux:system:repo:ubuntu:source} |
| 491 | mcp_saltstack.list: |
| 492 | source: ${linux:system:repo:mcp_saltstack:source} |
Dzmitry Stremkouski | 7ee2340 | 2018-04-10 00:43:48 +0200 | [diff] [blame] | 493 | node: |
| 494 | ubuntu1: |
| 495 | provider: node01.domain.com |
| 496 | image: ubuntu.qcow |
| 497 | size: medium |
| 498 | img_dest: /var/lib/libvirt/ssdimages |
Martin Horak | 9e11aa2 | 2018-09-17 06:46:59 +0200 | [diff] [blame] | 499 | # Node settings override cluster global ones |
| 500 | enable_vnc: False |
Dzmitry Stremkouski | 7ee2340 | 2018-04-10 00:43:48 +0200 | [diff] [blame] | 501 | rng: |
| 502 | backend: /dev/urandom |
| 503 | model: random |
| 504 | rate: |
| 505 | period: '1800' |
| 506 | bytes: '1500' |
Alexandru Avadanii | 00f187a | 2018-06-24 20:36:44 +0200 | [diff] [blame] | 507 | # Custom per-node loader definition (e.g. for AArch64 UEFI) |
| 508 | loader: |
| 509 | readonly: yes |
| 510 | type: pflash |
| 511 | path: /usr/share/AAVMF/AAVMF_CODE.fd |
| 512 | machine: virt-2.11 # Custom per-node virt machine type |
| 513 | cpu_mode: host-passthrough |
Pavel Cizinsky | f03c4e8 | 2018-09-10 14:56:11 +0200 | [diff] [blame] | 514 | cpuset: '1-4' |
Ondrej Smola | e6bcb29 | 2018-04-13 10:56:39 +0200 | [diff] [blame] | 515 | mac: |
| 516 | nic01: AC:DE:48:AA:AA:AA |
| 517 | nic02: AC:DE:48:AA:AA:BB |
Dzmitry Stremkouski | 97927ee | 2018-08-23 23:20:38 +0200 | [diff] [blame] | 518 | # netconfig affects: hostname during boot |
| 519 | # manual interfaces configuration |
| 520 | cloud_init: |
| 521 | network_data: |
Dzmitry Stremkouski | 30c7d2f | 2019-01-16 23:40:36 +0100 | [diff] [blame] | 522 | links: *vcp_links |
Dzmitry Stremkouski | 97927ee | 2018-08-23 23:20:38 +0200 | [diff] [blame] | 523 | networks: |
| 524 | - <<: *private-ipv4 |
| 525 | ip_address: 192.168.0.161 |
Andrei Danin | 996e209 | 2018-09-10 21:58:23 -0700 | [diff] [blame] | 526 | user_data: |
| 527 | salt_minion: |
| 528 | conf: |
| 529 | master: 10.1.1.1 |
| 530 | ubuntu2: |
| 531 | seed: qemu-nbd |
| 532 | cloud_init: |
| 533 | enabled: false |
| 534 | |
| 535 | There are two methods to seed an initial Salt minion configuration to |
| 536 | Libvirt VMs: mount a disk and update a filesystem or create a ConfigDrive with |
| 537 | a Cloud-init config. This is controlled by the "seed" parameter on cluster and |
| 538 | node levels. When set to _True_ or "qemu-nbd", the old method of mounting a disk |
| 539 | will be used. When set to "cloud-init", the new method will be used. When set |
| 540 | to _False_, no seeding will happen. The default value is _True_, meaning |
| 541 | the "qemu-nbd" method will be used. This is done for backward compatibility |
| 542 | and may be changed in future. |
| 543 | |
| 544 | The recommended method is to use Cloud-init. |
| 545 | It's controlled by the "cloud_init" dictionary on cluster and node levels. |
| 546 | Node level parameters are merged on top of cluster level parameters. |
| 547 | The Salt Minion config is populated automatically based on a VM name and config |
| 548 | settings of the minion who is actually executing a state. To override them, |
| 549 | add the "salt_minion" section into the "user_data" section as shown above. |
| 550 | It is possible to disable Cloud-init by setting "cloud_init.enabled" to _False_. |
Ondrej Smola | e6bcb29 | 2018-04-13 10:56:39 +0200 | [diff] [blame] | 551 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 552 | To enable Redis plugin for the Salt caching subsystem, use the |
| 553 | below pillar structure: |
Oleh Hryhorov | ca6b917 | 2018-06-21 14:21:35 +0000 | [diff] [blame] | 554 | |
| 555 | .. code-block:: yaml |
| 556 | |
| 557 | salt: |
| 558 | master: |
| 559 | cache: |
| 560 | plugin: redis |
| 561 | host: localhost |
| 562 | port: 6379 |
| 563 | db: '0' |
| 564 | password: pass_word |
| 565 | bank_prefix: 'MCP' |
| 566 | bank_keys_prefix: 'MCPKEY' |
| 567 | key_prefix: 'KEY' |
| 568 | separator: '@' |
Ondrej Smola | e6bcb29 | 2018-04-13 10:56:39 +0200 | [diff] [blame] | 569 | |
Petr Michalec | df75d68 | 2018-02-07 13:43:53 +0100 | [diff] [blame] | 570 | Jinja options |
| 571 | ------------- |
| 572 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 573 | Use the following options to update default Jinja renderer options. |
| 574 | Salt recognize Jinja options for templates and for the ``sls`` files. |
Petr Michalec | df75d68 | 2018-02-07 13:43:53 +0100 | [diff] [blame] | 575 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 576 | For full list of options, see Jinja documentation: |
| 577 | http://jinja.pocoo.org/docs/api/#high-level-api |
Petr Michalec | df75d68 | 2018-02-07 13:43:53 +0100 | [diff] [blame] | 578 | |
| 579 | .. code-block:: yaml |
| 580 | |
Petr Michalec | df75d68 | 2018-02-07 13:43:53 +0100 | [diff] [blame] | 581 | salt: |
| 582 | renderer: |
| 583 | # for templates |
| 584 | jinja: &jina_env |
| 585 | # Default Jinja environment options |
| 586 | block_start_string: '{%' |
| 587 | block_end_string: '%}' |
| 588 | variable_start_string: '{{' |
| 589 | variable_end_string: '}}' |
| 590 | comment_start_string: '{#' |
| 591 | comment_end_string: '#}' |
| 592 | keep_trailing_newline: False |
| 593 | newline_sequence: '\n' |
| 594 | |
| 595 | # Next two are enabled by default in Salt |
| 596 | trim_blocks: True |
| 597 | lstrip_blocks: True |
| 598 | |
| 599 | # Next two are not enabled by default in Salt |
| 600 | # but worth to consider to enable in future for salt-formulas |
| 601 | line_statement_prefix: '%' |
| 602 | line_comment_prefix: '##' |
| 603 | |
| 604 | # for .sls state files |
| 605 | jinja_sls: *jinja_env |
| 606 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 607 | With the ``line_statement/comment* _prefix`` options enabled following |
| 608 | code statements are valid: |
Petr Michalec | df75d68 | 2018-02-07 13:43:53 +0100 | [diff] [blame] | 609 | |
| 610 | .. code-block:: yaml |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 611 | |
Petr Michalec | df75d68 | 2018-02-07 13:43:53 +0100 | [diff] [blame] | 612 | %- set myvar = 'one' |
| 613 | |
| 614 | ## You can mix even with '{%' |
| 615 | {%- set myvar = 'two' %} ## comment |
| 616 | %- set mylist = ['one', 'two', 'three'] ## comment |
| 617 | |
| 618 | ## comment |
| 619 | %- for item in mylist: ## comment |
| 620 | {{- item }} |
| 621 | %- endfor |
| 622 | |
Ivan Berezovskiy | 8aee992 | 2019-07-15 18:21:22 +0400 | [diff] [blame] | 623 | Provision VM with secured image source. |
| 624 | |
| 625 | .. code-block:: yaml |
| 626 | |
| 627 | salt: |
| 628 | control: |
| 629 | cluster: |
| 630 | mycluster: |
| 631 | domain: mydomain.com |
| 632 | engine: virt |
| 633 | node: |
| 634 | ubuntu01: |
| 635 | image_source: |
| 636 | secured: true |
| 637 | protocol: http |
| 638 | user: foo |
| 639 | password: bar |
| 640 | url_prefix: mirror.com |
| 641 | url_path: xenial/image.qcow2 |
| 642 | |
| 643 | Provision several VMs with same secured image source. |
| 644 | |
| 645 | salt: |
| 646 | control: |
| 647 | common_image_source: |
| 648 | protocol: https |
| 649 | user: foo |
| 650 | password: bar |
| 651 | url_prefix: mirror.com |
| 652 | cluster: |
| 653 | mycluster: |
| 654 | domain: mydomain.com |
| 655 | engine: virt |
| 656 | node: |
| 657 | ubuntu01: |
| 658 | image_source: |
| 659 | secured: true |
| 660 | url_path: xenial/ubuntu.qcow2 |
| 661 | debian01: |
| 662 | image_source: |
| 663 | secured: true |
| 664 | url_path: stretch/debian.qcow2 |
| 665 | |
Dzmitry Stremkouski | b71ada9 | 2019-04-05 22:37:59 +0200 | [diff] [blame] | 666 | MCP Cluster health checks |
| 667 | ~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 668 | |
| 669 | Swiss army knife toolset for verifying MCP cluster health. |
| 670 | |
| 671 | .. note:: Health checks are tested with salt modules >= 2017.7. |
| 672 | |
| 673 | Install health_checks module: |
| 674 | |
| 675 | .. code-block:: bash |
| 676 | |
| 677 | cp health_checks.py /usr/share/salt-formulas/env/_modules/health_checks.py |
| 678 | salt -C '*' saltutil.sync_all |
| 679 | |
| 680 | Usually exit codes are not catched and salt-call for a module |
| 681 | will always return exit 0 regardless of errors in output. |
| 682 | If you want control exit code for scripting, you should pass |
| 683 | **--retcode-passthrough** to each salt call: |
| 684 | |
| 685 | .. code-block:: bash |
| 686 | |
| 687 | salt-call health_checks.minions_check --retcode-passthrough |
| 688 | |
| 689 | Verify if minions are online. |
| 690 | Use it to determine which minions are offline. |
| 691 | |
| 692 | .. code-block:: bash |
| 693 | |
| 694 | salt-call health_checks.minions_check |
| 695 | |
| 696 | Verify time diff on your minions: |
| 697 | |
| 698 | .. code-block:: bash |
| 699 | |
| 700 | salt-call health_checks.time_diff_check |
| 701 | |
| 702 | In case of failure, dump diff JSON: |
| 703 | |
| 704 | .. code-block:: bash |
| 705 | |
| 706 | salt-call health_checks.time_diff_check debug=True --out=json |
| 707 | |
| 708 | Get JSON stats from ntpq: |
| 709 | |
| 710 | .. code-block:: bash |
| 711 | |
| 712 | salt-call health_checks.ntp_status |
| 713 | |
| 714 | Verify NTP peers status on the environment: |
| 715 | |
| 716 | .. code-block:: bash |
| 717 | |
| 718 | salt-call health_checks.ntp_check |
| 719 | salt-call health_checks.ntp_check min_peers=2 max_stratum=2 |
| 720 | |
| 721 | Verify contrail nodes contrail-status output: |
| 722 | |
| 723 | .. code-block:: bash |
| 724 | |
| 725 | salt-call health_checks.contrail_check debug=True |
| 726 | |
| 727 | Verify galera cluster status: |
| 728 | |
| 729 | .. code-block:: bash |
| 730 | |
| 731 | salt-call health_checks.galera_check debug=True |
| 732 | salt-call health_checks.galera_check cluster_size=3 debug=True |
| 733 | |
| 734 | Verify rabbitmq cluster status: |
| 735 | |
| 736 | .. code-block:: bash |
| 737 | |
| 738 | salt-call health_checks.mysql_check debug=True |
| 739 | |
| 740 | Get rabbitmq json objects on command execution. |
| 741 | |
| 742 | .. warning:: This code is experimental. It is a hack to convert erlang object to JSON. May fail. |
| 743 | |
| 744 | .. code-block:: bash |
| 745 | |
| 746 | salt-call health_checks.rabbitmq_cmd status |
| 747 | salt-call health_checks.rabbitmq_cmd cluster_status |
| 748 | salt-call health_checks.rabbitmq_cmd list_hashes |
| 749 | salt-call health_checks.rabbitmq_cmd list_ciphers |
| 750 | |
Dzmitry Stremkouski | f1bcbb5 | 2019-04-11 15:48:24 +0200 | [diff] [blame] | 751 | Get rabbitmq json dict of queues on the node (vhost '/' by default) |
| 752 | |
| 753 | .. code-block:: bash |
| 754 | |
| 755 | salt -C 's-msg01*' health_checks.rabbitmq_list_queues |
| 756 | salt -C 's-msg01*' health_checks.rabbitmq_list_queues /openstack |
| 757 | |
Dzmitry Stremkouski | b71ada9 | 2019-04-05 22:37:59 +0200 | [diff] [blame] | 758 | Verify haproxy upstream status: |
| 759 | |
| 760 | .. code-block:: bash |
| 761 | |
| 762 | salt-call health_checks.haproxy_check debug=True |
| 763 | salt-call health_checks.haproxy_check ignore_no_upstream=True |
| 764 | |
| 765 | Get haproxy JSON stats (native python calls to socket): |
| 766 | |
| 767 | .. code-block:: bash |
| 768 | |
| 769 | salt-call health_checks.haproxy_status |
| 770 | salt-call health_checks.haproxy_status socket_path='/var/run/haproxy/admin.sock' stats_filter=['status'] |
| 771 | |
| 772 | Verify disk space usage: |
| 773 | |
| 774 | .. code-block:: bash |
| 775 | |
| 776 | salt-call health_checks.df_check |
| 777 | salt-call health_checks.df_check verify=space space_limit=90 ignore_partitions=['/'] |
| 778 | |
| 779 | Verify disk inodes usage: |
| 780 | |
| 781 | .. code-block:: bash |
| 782 | |
| 783 | salt-call health_checks.df_check verify=inodes |
| 784 | salt-call health_checks.df_check verify=inodes inode_limit=10 |
| 785 | |
| 786 | Verify load average on the environment: |
| 787 | |
| 788 | .. code-block:: bash |
| 789 | |
| 790 | salt-call health_checks.load_check |
| 791 | salt-call health_checks.load_check la1=4 la5=1 la15=1 |
| 792 | |
| 793 | Verify ifaces rx/tx drops: |
| 794 | |
| 795 | .. code-block:: bash |
| 796 | |
| 797 | salt-call health_checks.netdev_check |
| 798 | salt-call health_checks.netdev_check rx_drop_limit=0 tx_drop_limit=0 |
| 799 | |
| 800 | Verify memory usage: |
| 801 | |
| 802 | .. code-block:: bash |
| 803 | |
| 804 | salt-call health_checks.mem_check |
| 805 | salt-call health_checks.mem_check used_limit=50 |
| 806 | |
Dzmitry Stremkouski | f1bcbb5 | 2019-04-11 15:48:24 +0200 | [diff] [blame] | 807 | Verify ceph health status: |
| 808 | |
| 809 | .. code-block:: bash |
| 810 | |
| 811 | salt-call health_checks.ceph_health_check |
| 812 | salt-call health_checks.ceph_health_check target=s-mon01* target_type=glob debug=True |
| 813 | |
| 814 | Execute arbitrary ceph command and get JSON output: |
| 815 | |
| 816 | .. code-block:: bash |
| 817 | |
| 818 | salt -C 'cmn01*' health_checks.ceph_cmd 'osd tree' |
| 819 | |
| 820 | Retrieve docker registry recursively: |
| 821 | |
| 822 | .. code-block:: bash |
| 823 | |
| 824 | salt-call health_checks.docker_registry_list s-apt01:5000 |
| 825 | salt-call health_checks.docker_registry_list http://127.0.0.1:5000 |
| 826 | |
Dzmitry Stremkouski | 7cd10fc | 2019-04-17 11:51:59 +0200 | [diff] [blame] | 827 | Retrieve docker containers list on target server: |
| 828 | |
| 829 | .. code-block:: bash |
| 830 | |
| 831 | salt -C 'cid01*' health_checks.docker_ps |
| 832 | salt -C 'cid01*' health_checks.docker_ps list_all=1 |
| 833 | |
Dzmitry Stremkouski | f1bcbb5 | 2019-04-11 15:48:24 +0200 | [diff] [blame] | 834 | Retrieve glusterfs pool list: |
| 835 | |
| 836 | .. code-block:: bash |
| 837 | |
| 838 | salt -C 'I@glusterfs:server and *02*' health_checks.gluster_pool_list |
| 839 | |
| 840 | Retrieve glusterfs volumes status: |
| 841 | |
| 842 | .. code-block:: bash |
| 843 | |
| 844 | salt -C 'I@glusterfs:server and *02*' health_checks.gluster_volume_status |
| 845 | |
| 846 | Check glusterfs pool health and size: |
| 847 | |
| 848 | .. code-block:: bash |
| 849 | |
| 850 | salt-call health_checks.gluster_pool_check |
| 851 | salt-call health_checks.gluster_pool_check expected_size=5 |
| 852 | |
| 853 | Check glusterfs volumes bricks health and size: |
| 854 | |
| 855 | .. code-block:: bash |
| 856 | |
| 857 | salt-call health_checks.gluster_volumes_check |
| 858 | salt-call health_checks.gluster_volumes_check expected_size=1 ignore_volumes=['/srv/volumes/aptly'] |
| 859 | |
Dzmitry Stremkouski | 7cd10fc | 2019-04-17 11:51:59 +0200 | [diff] [blame] | 860 | Retrieve entropy size for host: |
| 861 | |
| 862 | .. code-block:: bash |
| 863 | |
| 864 | salt -C 'msg02*' health_checks.get_entropy |
| 865 | |
| 866 | Check entropy size on all nodes: |
| 867 | |
| 868 | .. code-block:: bash |
| 869 | |
| 870 | salt-call health_checks.entropy_check |
| 871 | salt-call health_checks.entropy_check minimum_bits=1000 |
| 872 | |
Dzmitry Stremkouski | b71ada9 | 2019-04-05 22:37:59 +0200 | [diff] [blame] | 873 | |
Dzmitry Stremkouski | 2c709f2 | 2019-04-22 02:27:54 +0200 | [diff] [blame] | 874 | Execute zookeeper cmds via socket: |
| 875 | |
| 876 | .. code-block:: bash |
| 877 | |
| 878 | salt -C s-ntw01* health_checks.zookeeper_cmd conf |
| 879 | salt -C s-ntw01* health_checks.zookeeper_cmd envi |
| 880 | |
| 881 | Retrieve zookeeper stats: |
| 882 | |
| 883 | .. code-block:: bash |
| 884 | |
| 885 | salt -C s-ntw01* health_checks.zookeeper_stats |
| 886 | |
| 887 | Retrieve zookeeper leader: |
| 888 | |
| 889 | .. code-block:: bash |
| 890 | |
| 891 | salt-call health_checks.get_zookeeper_leader |
| 892 | |
| 893 | Fetch contrail vrouter list from control node |
| 894 | |
| 895 | .. code-block:: bash |
| 896 | |
| 897 | salt -C s-ntw01* health_checks.contrail_vrouter_list |
| 898 | |
| 899 | Fetch contrail vrouter summary from control node |
| 900 | |
| 901 | .. code-block:: bash |
| 902 | |
| 903 | salt -C s-ntw01* health_checks.contrail_vrouter_show <vr_uuid> |
| 904 | |
| 905 | Fetch contrail vrouter agent connections from compute node |
| 906 | |
| 907 | .. code-block:: bash |
| 908 | |
| 909 | salt -C cmp001* health_checks.contrail_vrouter_agent_status |
| 910 | |
Dzmitry Stremkouski | 3629020 | 2019-05-05 21:26:25 +0200 | [diff] [blame] | 911 | Retrieve contrail vrouter agent status from analyticsdb |
| 912 | |
| 913 | .. code-block:: bash |
| 914 | |
| 915 | salt-call health_checks.contrail_collector_agent_status |
| 916 | |
| 917 | Retrieve filtered contrail vrouter agent info from analyticsdb |
| 918 | |
| 919 | .. code-block:: bash |
| 920 | |
| 921 | salt-call health_checks.contrail_vrouter_agent_info cmp001 |
| 922 | |
Dzmitry Stremkouski | a78a04d | 2019-07-13 11:05:03 +0200 | [diff] [blame] | 923 | Retrieve contrail control peers summary |
| 924 | |
| 925 | .. code-block:: bash |
| 926 | |
| 927 | salt -C s-ntw01* health_checks.contrail_control_peers_summary |
| 928 | |
| 929 | Retrieve contrail control filtered peers info |
| 930 | |
| 931 | .. code-block:: bash |
| 932 | |
| 933 | salt -C s-ntw03* health_checks.contrail_control_peer_status |
| 934 | |
Dzmitry Stremkouski | 2c709f2 | 2019-04-22 02:27:54 +0200 | [diff] [blame] | 935 | Fetch libvirt supported machine types for compute node |
| 936 | |
| 937 | .. code-block:: bash |
| 938 | |
| 939 | salt -C 'I@opencontrail:compute' health_checks.libvirt_capabilities |
| 940 | |
Dzmitry Stremkouski | 88275d3 | 2019-07-23 19:42:42 +0200 | [diff] [blame] | 941 | Check keystone fernet keys are in sync |
| 942 | |
| 943 | .. code-block:: bash |
| 944 | |
| 945 | salt-call health_checks.keystone_keys_check |
| 946 | salt-call health_checks.keystone_keys_check keys_dir='/var/lib/keystone/fernet-keys' |
| 947 | |
| 948 | Check keystone credential keys are in sync |
| 949 | |
| 950 | .. code-block:: bash |
| 951 | |
| 952 | salt-call health_checks.keystone_keys_check keys_type='credential' |
| 953 | |
Dzmitry Stremkouski | 2c709f2 | 2019-04-22 02:27:54 +0200 | [diff] [blame] | 954 | |
Petr Michalec | df75d68 | 2018-02-07 13:43:53 +0100 | [diff] [blame] | 955 | Encrypted pillars |
Ales Komarek | d768f1c | 2018-01-30 22:37:18 +0100 | [diff] [blame] | 956 | ~~~~~~~~~~~~~~~~~ |
Petr Michalec | 1f541c4 | 2017-08-17 13:30:37 +0200 | [diff] [blame] | 957 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 958 | .. note:: NACL and the below configuration will be available in Salt > 2017.7. |
Petr Michalec | 1f541c4 | 2017-08-17 13:30:37 +0200 | [diff] [blame] | 959 | |
| 960 | External resources: |
| 961 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 962 | - Tutorial to configure the Salt and Reclass ``ext_pillar`` and NACL: |
| 963 | http://apealive.net/post/2017-09-salt-nacl-ext-pillar/ |
| 964 | - SaltStack documentation: |
| 965 | https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.nacl.html |
Petr Michalec | 1f541c4 | 2017-08-17 13:30:37 +0200 | [diff] [blame] | 966 | |
| 967 | Configure salt NACL module: |
| 968 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 969 | .. code-block:: bash |
Petr Michalec | 1f541c4 | 2017-08-17 13:30:37 +0200 | [diff] [blame] | 970 | |
| 971 | pip install --upgrade libnacl===1.5.2 |
| 972 | salt-call --local nacl.keygen /etc/salt/pki/master/nacl |
| 973 | |
| 974 | local: |
| 975 | saved sk_file:/etc/salt/pki/master/nacl pk_file: /etc/salt/pki/master/nacl.pub |
| 976 | |
Petr Michalec | 1f541c4 | 2017-08-17 13:30:37 +0200 | [diff] [blame] | 977 | .. code-block:: yaml |
| 978 | |
| 979 | salt: |
| 980 | master: |
| 981 | pillar: |
| 982 | reclass: *reclass |
| 983 | nacl: |
| 984 | index: 99 |
| 985 | nacl: |
| 986 | box_type: sealedbox |
| 987 | sk_file: /etc/salt/pki/master/nacl |
| 988 | pk_file: /etc/salt/pki/master/nacl.pub |
| 989 | #sk: None |
| 990 | #pk: None |
| 991 | |
| 992 | NACL encrypt secrets: |
| 993 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 994 | .. code-block:: bash |
| 995 | |
Petr Michalec | 1f541c4 | 2017-08-17 13:30:37 +0200 | [diff] [blame] | 996 | salt-call --local nacl.enc 'my_secret_value' pk_file=/etc/salt/pki/master/nacl.pub |
| 997 | hXTkJpC1hcKMS7yZVGESutWrkvzusXfETXkacSklIxYjfWDlMJmR37MlmthdIgjXpg4f2AlBKb8tc9Woma7q |
| 998 | # or |
| 999 | salt-run nacl.enc 'myotherpass' |
| 1000 | ADDFD0Rav6p6+63sojl7Htfrncp5rrDVyeE4BSPO7ipq8fZuLDIVAzQLf4PCbDqi+Fau5KD3/J/E+Pw= |
| 1001 | |
Petr Michalec | 1f541c4 | 2017-08-17 13:30:37 +0200 | [diff] [blame] | 1002 | NACL encrypted values on pillar: |
| 1003 | |
| 1004 | Use Boxed syntax `NACL[CryptedValue=]` to encode value on pillar: |
| 1005 | |
| 1006 | .. code-block:: yaml |
| 1007 | |
| 1008 | my_pillar: |
| 1009 | my_nacl: |
| 1010 | key0: unencrypted_value |
| 1011 | key1: NACL[hXTkJpC1hcKMS7yZVGESutWrkvzusXfETXkacSklIxYjfWDlMJmR37MlmthdIgjXpg4f2AlBKb8tc9Woma7q] |
| 1012 | |
| 1013 | NACL large files: |
| 1014 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 1015 | .. code-block:: bash |
| 1016 | |
Petr Michalec | 1f541c4 | 2017-08-17 13:30:37 +0200 | [diff] [blame] | 1017 | salt-call nacl.enc_file /tmp/cert.crt out=/srv/salt/env/dev/cert.nacl |
| 1018 | # or more advanced |
| 1019 | cert=$(cat /tmp/cert.crt) |
| 1020 | salt-call --out=newline_values_only nacl.enc_pub data="$cert" > /srv/salt/env/dev/cert.nacl |
| 1021 | |
Petr Michalec | 1f541c4 | 2017-08-17 13:30:37 +0200 | [diff] [blame] | 1022 | NACL within template/native pillars: |
| 1023 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 1024 | .. code-block:: yaml |
| 1025 | |
Petr Michalec | 1f541c4 | 2017-08-17 13:30:37 +0200 | [diff] [blame] | 1026 | pillarexample: |
| 1027 | user: root |
| 1028 | password1: {{salt.nacl.dec('DRB7Q6/X5gGSRCTpZyxS6hlbWj0llUA+uaVyvou3vJ4=')|json}} |
| 1029 | cert_key: {{salt.nacl.dec_file('/srv/salt/env/dev/certs/example.com/cert.nacl')|json}} |
| 1030 | cert_key2: {{salt.nacl.dec_file('salt:///certs/example.com/cert2.nacl')|json}} |
| 1031 | |
Ales Komarek | d768f1c | 2018-01-30 22:37:18 +0100 | [diff] [blame] | 1032 | Salt Syndic |
Ales Komarek | 5474068 | 2017-05-15 07:16:23 +0200 | [diff] [blame] | 1033 | ----------- |
| 1034 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 1035 | The master of masters: |
Ales Komarek | 5474068 | 2017-05-15 07:16:23 +0200 | [diff] [blame] | 1036 | |
| 1037 | .. code-block:: yaml |
| 1038 | |
| 1039 | salt: |
| 1040 | master: |
| 1041 | enabled: true |
| 1042 | order_masters: True |
| 1043 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 1044 | Lower syndicated master: |
Ales Komarek | 5474068 | 2017-05-15 07:16:23 +0200 | [diff] [blame] | 1045 | |
| 1046 | .. code-block:: yaml |
| 1047 | |
| 1048 | salt: |
| 1049 | syndic: |
| 1050 | enabled: true |
| 1051 | master: |
| 1052 | host: master-of-master-host |
| 1053 | timeout: 5 |
| 1054 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 1055 | Syndicated master with multiple master of masters: |
Ales Komarek | 5474068 | 2017-05-15 07:16:23 +0200 | [diff] [blame] | 1056 | |
| 1057 | .. code-block:: yaml |
| 1058 | |
| 1059 | salt: |
| 1060 | syndic: |
| 1061 | enabled: true |
| 1062 | masters: |
| 1063 | - host: master-of-master-host1 |
| 1064 | - host: master-of-master-host2 |
| 1065 | timeout: 5 |
| 1066 | |
Ales Komarek | d768f1c | 2018-01-30 22:37:18 +0100 | [diff] [blame] | 1067 | Salt Minion |
| 1068 | ----------- |
| 1069 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 1070 | Minion ID by default triggers dependency on Linux formula, as it uses fqdn |
| 1071 | configured from `linux.system.name` and `linux.system.domain` pillar. |
| 1072 | To override, provide exact minion ID you require. The same can be set for |
| 1073 | master ID rendered at ``master.conf``. |
Petr Michalec | cfd93e1 | 2018-06-26 18:11:44 +0200 | [diff] [blame] | 1074 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 1075 | .. code-block:: yaml |
Petr Michalec | cfd93e1 | 2018-06-26 18:11:44 +0200 | [diff] [blame] | 1076 | |
| 1077 | salt: |
| 1078 | minion: |
| 1079 | id: minion1.production |
| 1080 | master: |
| 1081 | id: master.production |
| 1082 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 1083 | Simplest Salt minion setup with central configuration node: |
Ales Komarek | d768f1c | 2018-01-30 22:37:18 +0100 | [diff] [blame] | 1084 | |
| 1085 | .. literalinclude:: tests/pillar/minion_master.sls |
| 1086 | :language: yaml |
| 1087 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 1088 | Multi-master Salt minion setup: |
Ales Komarek | d768f1c | 2018-01-30 22:37:18 +0100 | [diff] [blame] | 1089 | |
| 1090 | .. literalinclude:: tests/pillar/minion_multi_master.sls |
| 1091 | :language: yaml |
| 1092 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 1093 | Salt minion with salt mine options: |
Ales Komarek | d768f1c | 2018-01-30 22:37:18 +0100 | [diff] [blame] | 1094 | |
| 1095 | .. literalinclude:: tests/pillar/minion_mine.sls |
| 1096 | :language: yaml |
| 1097 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 1098 | Salt minion with graphing dependencies: |
Ales Komarek | d768f1c | 2018-01-30 22:37:18 +0100 | [diff] [blame] | 1099 | |
| 1100 | .. literalinclude:: tests/pillar/minion_graph.sls |
| 1101 | :language: yaml |
| 1102 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 1103 | Salt minion behind HTTP proxy: |
Ales Komarek | d768f1c | 2018-01-30 22:37:18 +0100 | [diff] [blame] | 1104 | |
| 1105 | .. code-block:: yaml |
| 1106 | |
| 1107 | salt: |
| 1108 | minion: |
| 1109 | proxy: |
| 1110 | host: 127.0.0.1 |
| 1111 | port: 3128 |
| 1112 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 1113 | Salt minion to specify non-default HTTP backend. The default |
| 1114 | tornado backend does not respect HTTP proxy settings set as |
| 1115 | environment variables. This is useful for cases where you need |
| 1116 | to set no_proxy lists. |
Ales Komarek | d768f1c | 2018-01-30 22:37:18 +0100 | [diff] [blame] | 1117 | |
| 1118 | .. code-block:: yaml |
| 1119 | |
| 1120 | salt: |
| 1121 | minion: |
| 1122 | backend: urllib2 |
| 1123 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 1124 | Salt minion with PKI certificate authority (CA): |
Ales Komarek | d768f1c | 2018-01-30 22:37:18 +0100 | [diff] [blame] | 1125 | |
| 1126 | .. literalinclude:: tests/pillar/minion_pki_ca.sls |
| 1127 | :language: yaml |
| 1128 | |
| 1129 | Salt minion using PKI certificate |
| 1130 | |
| 1131 | .. literalinclude:: tests/pillar/minion_pki_cert.sls |
| 1132 | :language: yaml |
| 1133 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 1134 | Salt minion trust CA certificates issued by salt CA on a |
| 1135 | specific host (ie: salt-master node): |
Ales Komarek | d768f1c | 2018-01-30 22:37:18 +0100 | [diff] [blame] | 1136 | |
| 1137 | .. code-block:: yaml |
| 1138 | |
| 1139 | salt: |
| 1140 | minion: |
| 1141 | trusted_ca_minions: |
| 1142 | - cfg01 |
| 1143 | |
Ales Komarek | d768f1c | 2018-01-30 22:37:18 +0100 | [diff] [blame] | 1144 | Salt Minion Proxy |
| 1145 | ~~~~~~~~~~~~~~~~~ |
Jiri Broulik | a0f4668 | 2017-04-20 22:45:01 +0200 | [diff] [blame] | 1146 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 1147 | Salt proxy pillar: |
Jiri Broulik | a0f4668 | 2017-04-20 22:45:01 +0200 | [diff] [blame] | 1148 | |
| 1149 | .. code-block:: yaml |
| 1150 | |
| 1151 | salt: |
| 1152 | minion: |
Jiri Broulik | 8827524 | 2017-05-24 17:21:17 +0200 | [diff] [blame] | 1153 | proxy_minion: |
Jiri Broulik | a0f4668 | 2017-04-20 22:45:01 +0200 | [diff] [blame] | 1154 | master: localhost |
| 1155 | device: |
| 1156 | vsrx01.mydomain.local: |
| 1157 | enabled: true |
| 1158 | engine: napalm |
| 1159 | csr1000v.mydomain.local: |
| 1160 | enabled: true |
| 1161 | engine: napalm |
| 1162 | |
| 1163 | .. note:: This is pillar of the the real salt-minion |
| 1164 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 1165 | Proxy pillar for IOS device: |
Jiri Broulik | a0f4668 | 2017-04-20 22:45:01 +0200 | [diff] [blame] | 1166 | |
| 1167 | .. code-block:: yaml |
| 1168 | |
| 1169 | proxy: |
| 1170 | proxytype: napalm |
| 1171 | driver: ios |
| 1172 | host: csr1000v.mydomain.local |
| 1173 | username: root |
| 1174 | passwd: r00tme |
| 1175 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 1176 | .. note:: This is pillar of the node thats not able to run |
| 1177 | salt-minion itself. |
Jiri Broulik | a0f4668 | 2017-04-20 22:45:01 +0200 | [diff] [blame] | 1178 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 1179 | Proxy pillar for JunOS device: |
Jiri Broulik | a0f4668 | 2017-04-20 22:45:01 +0200 | [diff] [blame] | 1180 | |
| 1181 | .. code-block:: yaml |
| 1182 | |
| 1183 | proxy: |
| 1184 | proxytype: napalm |
| 1185 | driver: junos |
| 1186 | host: vsrx01.mydomain.local |
| 1187 | username: root |
| 1188 | passwd: r00tme |
| 1189 | optional_args: |
| 1190 | config_format: set |
| 1191 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 1192 | .. note:: This pillar applies to the node that can not run |
| 1193 | salt-minion itself. |
Ales Komarek | 8fb1da8 | 2016-08-21 23:52:03 +0200 | [diff] [blame] | 1194 | |
| 1195 | Salt SSH |
Ales Komarek | d768f1c | 2018-01-30 22:37:18 +0100 | [diff] [blame] | 1196 | ~~~~~~~~ |
Ales Komarek | 8fb1da8 | 2016-08-21 23:52:03 +0200 | [diff] [blame] | 1197 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 1198 | Salt SSH with sudoer using key: |
Ales Komarek | 8fb1da8 | 2016-08-21 23:52:03 +0200 | [diff] [blame] | 1199 | |
| 1200 | .. literalinclude:: tests/pillar/master_ssh_minion_key.sls |
| 1201 | :language: yaml |
| 1202 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 1203 | Salt SSH with sudoer using password: |
Ales Komarek | 8fb1da8 | 2016-08-21 23:52:03 +0200 | [diff] [blame] | 1204 | |
| 1205 | .. literalinclude:: tests/pillar/master_ssh_minion_password.sls |
| 1206 | :language: yaml |
| 1207 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 1208 | Salt SSH with root using password: |
Ales Komarek | 8fb1da8 | 2016-08-21 23:52:03 +0200 | [diff] [blame] | 1209 | |
| 1210 | .. literalinclude:: tests/pillar/master_ssh_minion_root.sls |
| 1211 | :language: yaml |
| 1212 | |
Ales Komarek | 8ba9c0b | 2016-02-21 14:59:59 +0100 | [diff] [blame] | 1213 | Salt control (cloud/kvm/docker) |
| 1214 | ------------------------------- |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 1215 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 1216 | Salt cloud with local OpenStack provider: |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 1217 | |
Ales Komarek | 8ba9c0b | 2016-02-21 14:59:59 +0100 | [diff] [blame] | 1218 | .. literalinclude:: tests/pillar/control_cloud_openstack.sls |
| 1219 | :language: yaml |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 1220 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 1221 | Salt cloud with Digital Ocean provider: |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 1222 | |
Ales Komarek | 8ba9c0b | 2016-02-21 14:59:59 +0100 | [diff] [blame] | 1223 | .. literalinclude:: tests/pillar/control_cloud_digitalocean.sls |
| 1224 | :language: yaml |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 1225 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 1226 | Salt virt with KVM cluster: |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 1227 | |
Ales Komarek | 8ba9c0b | 2016-02-21 14:59:59 +0100 | [diff] [blame] | 1228 | .. literalinclude:: tests/pillar/control_virt.sls |
| 1229 | :language: yaml |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 1230 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 1231 | Salt virt with custom destination for image file: |
Mateusz Los | 4c7cd2d | 2018-01-09 11:46:07 +0100 | [diff] [blame] | 1232 | |
| 1233 | .. literalinclude:: tests/pillar/control_virt_custom.sls |
| 1234 | :language: yaml |
| 1235 | |
Dmitry Teselkin | 9b3097a | 2018-11-21 15:45:07 +0300 | [diff] [blame] | 1236 | Salt shared library |
| 1237 | ------------------- |
| 1238 | |
| 1239 | This formula includes 'sharedlib' execution module which is a kind |
| 1240 | of 'library' of function and / or classes to be used in Jinja templates |
| 1241 | or directly as execution module. |
| 1242 | |
| 1243 | 'sharedlib' implements a loader that is able to scan nested directories |
| 1244 | and import Python classes / functions from nested modules. Salt doesn't |
| 1245 | allow this as it only imports top-level modules: |
| 1246 | |
| 1247 | https://github.com/saltstack/salt/issues/37273 |
| 1248 | |
| 1249 | 'sharedlib' implements 4 main functions: |
| 1250 | |
| 1251 | * 'sharedlib.list' - search and print functions / classes found in nested directories |
| 1252 | * 'sharedlib.info' - print docstring of a function (if it exists) |
| 1253 | * 'sharedlib.get' - get function / class object, but not execute it immediately |
| 1254 | * 'sharedlib.call' - get function / class and execute / initialize it with |
| 1255 | arguments given. |
| 1256 | |
| 1257 | Each of the commands above also have it's own docstring so it's possible to |
| 1258 | use them on a system: |
| 1259 | |
| 1260 | .. code-block:: text |
| 1261 | |
| 1262 | # salt-call sys.doc sharedlib.list |
| 1263 | local: |
| 1264 | ---------- |
| 1265 | sharedlib.list: |
| 1266 | |
| 1267 | List available functions. |
| 1268 | |
| 1269 | .. code-block:: |
| 1270 | |
| 1271 | salt-call sharedlib.list |
| 1272 | |
| 1273 | Usage examples: |
| 1274 | |
| 1275 | .. code-block:: text |
| 1276 | |
| 1277 | # salt-call sharedlib.list |
| 1278 | local: |
| 1279 | ---------- |
| 1280 | sharedlib.list: |
| 1281 | ---------- |
| 1282 | classes: |
| 1283 | - misc.Test |
| 1284 | - misc2.Test |
| 1285 | functions: |
| 1286 | - misc.cast_dict_keys_to_int |
| 1287 | |
| 1288 | .. code-block:: text |
| 1289 | |
| 1290 | # salt-call sharedlib.info misc.cast_dict_keys_to_int |
| 1291 | local: |
| 1292 | ---------- |
| 1293 | sharedlib.info: |
| 1294 | ---------- |
| 1295 | misc.cast_dict_keys_to_int: |
| 1296 | |
| 1297 | Return a dictionary with keys casted to int. |
| 1298 | This usually is required when you want sort the dict later. |
| 1299 | |
| 1300 | Jinja example: |
| 1301 | |
| 1302 | .. code-block: jinja |
| 1303 | |
| 1304 | {%- set ruleset = salt['sharedlib.call']('misc.cast_dict_keys_to_int', c.get('ruleset', {})) %} |
| 1305 | |
| 1306 | .. code-block:: jinja |
| 1307 | |
| 1308 | {%- set func = salt['sharedlib.get']('misc.cast_dict_keys_to_int') %} |
| 1309 | {%- for c_name, c in t.chains.items() %} |
| 1310 | {%- set ruleset = func(c.get('ruleset', {})) %} |
| 1311 | {%- for rule_id, r in ruleset | dictsort %} |
| 1312 | ... |
| 1313 | {%- endfor %} |
| 1314 | |
Oleksandr Shyshko | 1717694 | 2019-02-06 17:08:23 +0200 | [diff] [blame] | 1315 | Procedure of Data model and Schemas validation. |
| 1316 | ------------------- |
| 1317 | Salt formula supports several mechanisms which allows to validate data model by jsonschema validator. |
| 1318 | It supports unversioned schemas which must be contained at: |
| 1319 | |
| 1320 | .. code-block:: text |
| 1321 | 'salt://{}/schemas/{}.yaml'.format(service, role) |
| 1322 | |
| 1323 | and/or versioned schemas which must be contained at: |
| 1324 | |
| 1325 | .. code-block:: text |
| 1326 | 'salt://{}/schemas/{}/{}.yaml'.format(service, version, role) |
| 1327 | |
| 1328 | Returns list of all defined schema files. |
| 1329 | |
| 1330 | .. code-block:: bash |
| 1331 | salt-call modelschema.schema_list |
| 1332 | |
| 1333 | Returns pillar schema for given service and role. |
| 1334 | |
| 1335 | .. code-block:: bash |
| 1336 | |
| 1337 | salt-call modelschema.schema_get ntp server |
| 1338 | .. or .. |
| 1339 | salt-call modelschema.schema_get keystone server pike |
| 1340 | |
| 1341 | Validates pillar schema itself of given service and role. |
| 1342 | |
| 1343 | .. code-block:: bash |
| 1344 | |
| 1345 | salt-call modelschema.schema_validate ntp server |
| 1346 | .. or .. |
| 1347 | salt-call modelschema.schema_validate keystone server pike |
| 1348 | |
| 1349 | Validates pillar metadata by schema for given service and role. |
| 1350 | |
| 1351 | .. code-block:: bash |
| 1352 | |
| 1353 | salt-call modelschema.model_validate ntp server |
| 1354 | .. or .. |
| 1355 | salt-call modelschema.model_validate keystone server pike |
| 1356 | |
| 1357 | Validates pillar metadata by schema for given service and role. |
| 1358 | |
| 1359 | .. code-block:: bash |
| 1360 | salt-run modelschema.data_validate {'a': 'b'} {'a': 'b'} |
| 1361 | |
| 1362 | Generate pillar schema skeleton for given service. Method iterates throught |
| 1363 | test pillars and generates schema scaffold structure in JSON format that |
| 1364 | can be passed to service like http://jsonschema.net/ to get the basic |
| 1365 | schema for the individual roles of the service. |
| 1366 | |
| 1367 | .. code-block:: bash |
| 1368 | |
| 1369 | salt-call modelschema.schema_from_tests ntp |
| 1370 | .. or .. |
| 1371 | salt-call modelschema.schema_from_tests keystone pike |
| 1372 | |
| 1373 | You can read more about it here: |
| 1374 | http://json-schema.org/implementations.html |
| 1375 | https://github.com/Julian/jsonschema |
Dmitry Teselkin | 9b3097a | 2018-11-21 15:45:07 +0300 | [diff] [blame] | 1376 | |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 1377 | Usage |
| 1378 | ===== |
| 1379 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 1380 | Working with salt-cloud: |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 1381 | |
| 1382 | .. code-block:: bash |
| 1383 | |
| 1384 | salt-cloud -m /path/to/map --assume-yes |
| 1385 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 1386 | Debug LIBCLOUD for salt-cloud connection: |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 1387 | |
| 1388 | .. code-block:: bash |
| 1389 | |
| 1390 | export LIBCLOUD_DEBUG=/dev/stderr; salt-cloud --list-sizes provider_name --log-level all |
| 1391 | |
OlgaGusarenko | f1fd82e | 2018-07-31 01:20:49 +0300 | [diff] [blame] | 1392 | Read more |
| 1393 | ========= |
Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 1394 | |
| 1395 | * http://salt.readthedocs.org/en/latest/ |
| 1396 | * https://github.com/DanielBryan/salt-state-graph |
| 1397 | * http://karlgrz.com/testing-salt-states-rapidly-with-docker/ |
| 1398 | * https://mywushublog.com/2013/03/configuration-management-with-salt-stack/ |
| 1399 | * http://russell.ballestrini.net/replace-the-nagios-scheduler-and-nrpe-with-salt-stack/ |
| 1400 | * https://github.com/saltstack-formulas/salt-formula |
| 1401 | * http://docs.saltstack.com/en/latest/topics/tutorials/multimaster.html |
| 1402 | |
| 1403 | salt-cloud |
| 1404 | ---------- |
| 1405 | |
| 1406 | * http://www.blog.sandro-mathys.ch/2013/07/setting-user-password-when-launching.html |
| 1407 | * http://cloudinit.readthedocs.org/en/latest/topics/examples.html |
| 1408 | * http://salt-cloud.readthedocs.org/en/latest/topics/install/index.html |
| 1409 | * http://docs.saltstack.com/topics/cloud/digitalocean.html |
| 1410 | * http://salt-cloud.readthedocs.org/en/latest/topics/rackspace.html |
| 1411 | * http://salt-cloud.readthedocs.org/en/latest/topics/map.html |
| 1412 | * http://docs.saltstack.com/en/latest/topics/tutorials/multimaster.html |