Filip Pytloun | b4b8059 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 1 | |
| 2 | ==== |
| 3 | Salt |
| 4 | ==== |
| 5 | |
| 6 | Salt is a new approach to infrastructure management. Easy enough to get running in minutes, scalable enough to manage tens of thousands of servers, and fast enough to communicate with them in seconds. |
| 7 | |
| 8 | Salt delivers a dynamic communication bus for infrastructures that can be used for orchestration, remote execution, configuration management and much more. |
| 9 | |
| 10 | Sample pillars |
| 11 | ============== |
| 12 | |
| 13 | Salt master |
| 14 | ----------- |
| 15 | |
| 16 | Salt master with base environment and pillar metadata source |
| 17 | |
| 18 | .. code-block:: yaml |
| 19 | |
| 20 | salt: |
| 21 | master: |
| 22 | enabled: true |
| 23 | command_timeout: 5 |
| 24 | worker_threads: 2 |
| 25 | pillar: |
| 26 | engine: salt |
| 27 | source: |
| 28 | engine: git |
| 29 | address: 'git@repo.domain.com:salt/pillar-demo.git' |
| 30 | branch: 'master' |
| 31 | base_environment: prd |
| 32 | environment: |
| 33 | prd: |
| 34 | enabled: true |
| 35 | formula: |
| 36 | linux: |
| 37 | source: git |
| 38 | address: 'git@repo.domain.com:salt/formula-linux.git' |
| 39 | branch: 'master' |
| 40 | salt: |
| 41 | source: git |
| 42 | address: 'git@repo.domain.com:salt/formula-salt.git' |
| 43 | branch: 'master' |
| 44 | openssh: |
| 45 | source: git |
| 46 | address: 'git@repo.domain.com:salt/formula-openssh.git' |
| 47 | branch: 'master' |
| 48 | |
| 49 | Simple Salt master with base environment and custom states |
| 50 | |
| 51 | .. code-block:: yaml |
| 52 | |
| 53 | salt: |
| 54 | master: |
| 55 | ... |
| 56 | environment: |
| 57 | base: |
| 58 | states: |
| 59 | - name: gitlab |
| 60 | source: git |
| 61 | address: 'git@repo.domain.cz:salt/state-gitlab.git' |
| 62 | branch: 'master' |
| 63 | formulas: |
| 64 | ... |
| 65 | |
| 66 | Salt master with reclass ENC |
| 67 | |
| 68 | .. code-block:: yaml |
| 69 | |
| 70 | salt: |
| 71 | master: |
| 72 | enabled: true |
| 73 | ... |
| 74 | pillar: |
| 75 | engine: reclass |
| 76 | data_dir: /srv/salt/reclass |
| 77 | |
| 78 | Salt master with windows repository |
| 79 | |
| 80 | .. code-block:: yaml |
| 81 | |
| 82 | salt: |
| 83 | master: |
| 84 | enabled: true |
| 85 | ... |
| 86 | windows_repo: |
| 87 | type: git |
| 88 | address: 'git@repo.domain.com:salt/win-packages.git' |
| 89 | |
| 90 | Salt master with API |
| 91 | |
| 92 | .. code-block:: yaml |
| 93 | |
| 94 | salt: |
| 95 | master: |
| 96 | ... |
| 97 | api: |
| 98 | enabled: true |
| 99 | port: 8000 |
| 100 | |
| 101 | Salt master with preset minions |
| 102 | |
| 103 | .. code-block:: yaml |
| 104 | |
| 105 | salt: |
| 106 | master: |
| 107 | enabled: true |
| 108 | ... |
| 109 | minions: |
| 110 | - name: 'node1.system.location.domain.com' |
| 111 | |
| 112 | Salt master syndicate master of masters |
| 113 | |
| 114 | .. code-block:: yaml |
| 115 | |
| 116 | salt: |
| 117 | master: |
| 118 | enabled: true |
| 119 | ... |
| 120 | syndic: |
| 121 | mode: master |
| 122 | |
| 123 | Salt master syndicate (client) master |
| 124 | |
| 125 | .. code-block:: yaml |
| 126 | |
| 127 | salt: |
| 128 | master: |
| 129 | enabled: true |
| 130 | ... |
| 131 | syndicate: |
| 132 | mode: client |
| 133 | host: master-master |
| 134 | |
| 135 | Salt master with custom handlers |
| 136 | |
| 137 | .. code-block:: yaml |
| 138 | |
| 139 | salt: |
| 140 | master: |
| 141 | enabled: true |
| 142 | command_timeout: 5 |
| 143 | worker_threads: 2 |
| 144 | environments: |
| 145 | - name: base |
| 146 | states: |
| 147 | - source: git |
| 148 | address: 'git@repo.domain.com:salt/state-ubuntu.git' |
| 149 | branch: 'master' |
| 150 | pillar: |
| 151 | source: git |
| 152 | address: 'git@repo.domain.com:salt/pillar-demo.git' |
| 153 | branch: 'master' |
| 154 | handlers: |
| 155 | name: logstash |
| 156 | type: udp |
| 157 | bind: |
| 158 | host: 127.0.0.1 |
| 159 | port: 9999 |
| 160 | minion: |
| 161 | handlers: |
| 162 | - engine: udp |
| 163 | bind: |
| 164 | host: 127.0.0.1 |
| 165 | port: 9999 |
| 166 | - engine: zmq |
| 167 | bind: |
| 168 | host: 127.0.0.1 |
| 169 | port: 9999 |
| 170 | |
| 171 | Salt minion |
| 172 | ----------- |
| 173 | |
| 174 | Simplest Salt minion |
| 175 | |
| 176 | .. code-block:: yaml |
| 177 | |
| 178 | salt: |
| 179 | minion: |
| 180 | enabled: true |
| 181 | master: |
| 182 | host: master.domain.com |
| 183 | |
| 184 | Multi-master Salt minion |
| 185 | |
| 186 | .. code-block:: yaml |
| 187 | |
| 188 | salt: |
| 189 | minion: |
| 190 | enabled: true |
| 191 | masters: |
| 192 | - host: master1.domain.com |
| 193 | - host: master2.domain.com |
| 194 | |
| 195 | Salt minion with salt mine options |
| 196 | |
| 197 | salt: |
| 198 | minion: |
| 199 | enabled: true |
| 200 | master: |
| 201 | host: master.domain.com |
| 202 | mine: |
| 203 | interval: 60 |
| 204 | module: |
| 205 | grains.items: [] |
| 206 | network.interfaces: [] |
| 207 | |
| 208 | Salt minion with graphing dependencies |
| 209 | |
| 210 | .. code-block:: yaml |
| 211 | |
| 212 | salt: |
| 213 | minion: |
| 214 | enabled: true |
| 215 | graph_states: true |
| 216 | master: |
| 217 | host: master.domain.com |
| 218 | |
| 219 | Salt control (cloud/virt) |
| 220 | ------------------------- |
| 221 | |
| 222 | Salt cloud with local OpenStack insecure (ignoring SSL cert errors) provider |
| 223 | |
| 224 | .. code-block:: yaml |
| 225 | |
| 226 | salt: |
| 227 | control: |
| 228 | enabled: true |
| 229 | provider: |
| 230 | openstack_account: |
| 231 | engine: openstack |
| 232 | insecure: true |
| 233 | region: RegionOne |
| 234 | identity_url: 'https://10.0.0.2:35357' |
| 235 | tenant: devops |
| 236 | user: user |
| 237 | password: 'password' |
| 238 | fixed_networks: |
| 239 | - 123d3332-18be-4d1d-8d4d-5f5a54456554e |
| 240 | floating_networks: |
| 241 | - public |
| 242 | ignore_cidr: 192.168.0.0/16 |
| 243 | |
| 244 | Salt cloud with Digital Ocean provider |
| 245 | |
| 246 | .. code-block:: yaml |
| 247 | |
| 248 | salt: |
| 249 | control: |
| 250 | enabled: true |
| 251 | provider: |
| 252 | dony1: |
| 253 | engine: digital_ocean |
| 254 | region: New York 1 |
| 255 | client_key: xxxxxxx |
| 256 | api_key: xxxxxxx |
| 257 | |
| 258 | Salt cloud with cluster definition |
| 259 | |
| 260 | .. code-block:: yaml |
| 261 | |
| 262 | salt: |
| 263 | control: |
| 264 | enabled: true |
| 265 | cluster: |
| 266 | devops_ase: |
| 267 | config: |
| 268 | engine: salt |
| 269 | host: 147.32.120.1 |
| 270 | node: |
| 271 | proxy1.ase.cepsos.cz: |
| 272 | provider: cepsos_devops |
| 273 | image: Ubuntu12.04 x86_64 |
| 274 | size: m1.medium |
| 275 | node1.ase.cepsos.cz: |
| 276 | provider: cepsos_devops |
| 277 | image: Ubuntu12.04 x86_64 |
| 278 | size: m1.medium |
| 279 | node2.ase.cepsos.cz: |
| 280 | provider: cepsos_devops |
| 281 | image: Ubuntu12.04 x86_64 |
| 282 | size: m1.medium |
| 283 | node3.ase.cepsos.cz: |
| 284 | provider: cepsos_devops |
| 285 | image: Ubuntu12.04 x86_64 |
| 286 | size: m1.medium |
| 287 | |
| 288 | Usage |
| 289 | ===== |
| 290 | |
| 291 | Working with salt-cloud |
| 292 | |
| 293 | .. code-block:: bash |
| 294 | |
| 295 | salt-cloud -m /path/to/map --assume-yes |
| 296 | |
| 297 | Debug LIBCLOUD for salt-cloud connection |
| 298 | |
| 299 | .. code-block:: bash |
| 300 | |
| 301 | export LIBCLOUD_DEBUG=/dev/stderr; salt-cloud --list-sizes provider_name --log-level all |
| 302 | |
| 303 | Read more |
| 304 | ========= |
| 305 | |
| 306 | * http://salt.readthedocs.org/en/latest/ |
| 307 | * https://github.com/DanielBryan/salt-state-graph |
| 308 | * http://karlgrz.com/testing-salt-states-rapidly-with-docker/ |
| 309 | * https://mywushublog.com/2013/03/configuration-management-with-salt-stack/ |
| 310 | * http://russell.ballestrini.net/replace-the-nagios-scheduler-and-nrpe-with-salt-stack/ |
| 311 | * https://github.com/saltstack-formulas/salt-formula |
| 312 | * http://docs.saltstack.com/en/latest/topics/tutorials/multimaster.html |
| 313 | |
| 314 | salt-cloud |
| 315 | ---------- |
| 316 | |
| 317 | * http://www.blog.sandro-mathys.ch/2013/07/setting-user-password-when-launching.html |
| 318 | * http://cloudinit.readthedocs.org/en/latest/topics/examples.html |
| 319 | * http://salt-cloud.readthedocs.org/en/latest/topics/install/index.html |
| 320 | * http://docs.saltstack.com/topics/cloud/digitalocean.html |
| 321 | * http://salt-cloud.readthedocs.org/en/latest/topics/rackspace.html |
| 322 | * http://salt-cloud.readthedocs.org/en/latest/topics/map.html |
| 323 | * http://docs.saltstack.com/en/latest/topics/tutorials/multimaster.html |