Ales Komarek | 1b37311 | 2017-08-08 08:48:56 +0200 | [diff] [blame] | 1 | ============== |
| 2 | Deploy scripts |
| 3 | ============== |
| 4 | |
| 5 | This ``deploy/scripts`` serve as shared common place to link any deployment tools. |
| 6 | |
| 7 | |
| 8 | **bootstrap-salt.sh** |
| 9 | **bootstrap-salt.ps1** |
| 10 | |
| 11 | Salt bootstrap scripts. Local copy of upstream `https://bootstrap.saltstack.com/`_. |
| 12 | |
Petr Michalec | c7dabcf | 2017-08-30 16:30:13 +0200 | [diff] [blame] | 13 | **bootstrap.sh** |
Ales Komarek | 1b37311 | 2017-08-08 08:48:56 +0200 | [diff] [blame] | 14 | |
Petr Michalec | c7dabcf | 2017-08-30 16:30:13 +0200 | [diff] [blame] | 15 | Script with function library to |
| 16 | * install and configure *salt master* and *minions* |
| 17 | * bootstrap *salt master* with *salt-formulas* common prerequisites in mind |
| 18 | * validate reclass the model / pillar for all nodes |
Ales Komarek | 1b37311 | 2017-08-08 08:48:56 +0200 | [diff] [blame] | 19 | |
Petr Michalec | c7dabcf | 2017-08-30 16:30:13 +0200 | [diff] [blame] | 20 | TL;DR: |
Petr Michalec | e07cd0b | 2017-11-15 11:41:57 +0100 | [diff] [blame] | 21 | ====== |
Ales Komarek | 1b37311 | 2017-08-08 08:48:56 +0200 | [diff] [blame] | 22 | |
Petr Michalec | d0cebae | 2017-08-31 12:40:42 +0200 | [diff] [blame] | 23 | Bootstrap salt-minion: |
| 24 | |
| 25 | .. code-block:: bash |
| 26 | |
| 27 | export HTTPS_PROXY="http://proxy.your.corp:8080"; export HTTP_PROXY=$HTTPS_PROXY |
| 28 | |
| 29 | export MASTER_HOSTNAME=cfg01.infra.ci.local || export MASTER_IP=10.0.0.10 |
| 30 | export MINION_ID=$(hostname -f) || export HOSTNAME=prx01 DOMAIN=infra.ci.local |
| 31 | source <(curl -qL https://raw.githubusercontent.com/salt-formulas/salt-formulas-scripts/master/bootstrap.sh) |
| 32 | install_salt_minion_pkg |
| 33 | |
| 34 | |
Petr Michalec | e07cd0b | 2017-11-15 11:41:57 +0100 | [diff] [blame] | 35 | Common procedure |
| 36 | ================ |
| 37 | |
| 38 | Download the deploy scripts to the ``/srv/salt/scripts`` directory: |
| 39 | |
| 40 | .. code-block:: bash |
| 41 | |
| 42 | git clone https://github.com/salt-formulas/salt-formulas-scripts /srv/salt/scripts |
| 43 | |
| 44 | Install reclass (optional): |
| 45 | |
| 46 | .. note:: For bootstrap you may wish to use the forked version with some nice features (as ignore_class_notfound) from |
| 47 | master or develop branch of https://github.com/salt-formulas/reclass. |
| 48 | |
| 49 | .. code-block:: bash |
| 50 | |
| 51 | RECLASS_VERSION=dev |
| 52 | cd /srv/salt/scripts |
| 53 | source /srv/salt/scripts.bootstrap.sh |
| 54 | install_reclass |
| 55 | |
| 56 | .. note:: To ignore missing classes on bootstrap export the following variables |
| 57 | ``export RECLASS_IGNORE_CLASS_NOTFOUND=True; export RECLASS_IGNORE_CLASS_REGEXP="service.*"`` |
| 58 | |
| 59 | If you are not using forked reclass (with ingnore_class_notfound option enabled) you have to set |
| 60 | environment variable FORMULAS_SALT_MASTER containing list of all formulas required on salt master. |
| 61 | For example you may require to pre-install the following: |
| 62 | |
| 63 | .. code-block:: bash |
| 64 | |
| 65 | export FORMULAS_SALT_MASTER="linux salt reclass maas memcached openssh ntp sphinx \ |
| 66 | grafana libvirt rsyslog glusterfs postfix xtrabackup freeipa prometheus telegraf \ |
| 67 | elasticsearch kibana rundeck devops-portal rsync docker keepalived aptly jenkins \ |
| 68 | gerrit artifactory influxdb horizon nginx collectd heka mysql" |
| 69 | |
| 70 | |
| 71 | Run the ``bootstrap.sh`` script from ``/srv/salt/scripts`` with the ``MASTER_HOSTNAME=$SALT_MASTER_FQDN`` parameter to |
Petr Michalec | d0cebae | 2017-08-31 12:40:42 +0200 | [diff] [blame] | 72 | Bootstrap salt-master: |
| 73 | |
Ales Komarek | 1b37311 | 2017-08-08 08:48:56 +0200 | [diff] [blame] | 74 | .. code-block:: bash |
| 75 | |
| 76 | cd /srv/salt/scripts |
Ondrej Smola | b9f8a85 | 2017-09-18 19:43:51 +0200 | [diff] [blame] | 77 | CLUSTER_NAME=regionOne HOSTNAME=cfg01 DOMAIN=infra.ci.local ./bootstrap.sh |
Ales Komarek | 1b37311 | 2017-08-08 08:48:56 +0200 | [diff] [blame] | 78 | |
Petr Michalec | e07cd0b | 2017-11-15 11:41:57 +0100 | [diff] [blame] | 79 | .. note:: Creates /srv/salt/scripts/.salt-master-setup.sh.passed if succesfully passed the "setup script" |
| 80 | with the aim to avoid subsequent setup. |
Petr Michalec | c7dabcf | 2017-08-30 16:30:13 +0200 | [diff] [blame] | 81 | |
| 82 | |
Ales Komarek | 1b37311 | 2017-08-08 08:48:56 +0200 | [diff] [blame] | 83 | **formula-fetch.sh** |
| 84 | |
| 85 | Script to install formulas with dependencies. |
| 86 | |
| 87 | |
| 88 | **salt-state-apply-trend.sh** |
| 89 | |
| 90 | Simple script to invoking highstate on whole infrastructure with ``test=true``. Json output is aggregated with `jq` |
| 91 | (Failed/Success/Changes/Errors) and compared with previous run. |
| 92 | |
| 93 | |
| 94 | Bootstrap the Salt Master node |
| 95 | ============================== |
| 96 | (expects salt-formulas reclass model repo) |
| 97 | |
| 98 | .. code-block:: bash |
| 99 | |
Petr Michalec | 4a11f9d | 2017-08-08 14:15:56 +0200 | [diff] [blame] | 100 | git clone https://github.com/salt-formulas/salt-formulas-scripts /srv/salt/scripts |
Ales Komarek | 1b37311 | 2017-08-08 08:48:56 +0200 | [diff] [blame] | 101 | |
| 102 | git clone <model-repository> /srv/salt/reclass |
Petr Michalec | c7dabcf | 2017-08-30 16:30:13 +0200 | [diff] [blame] | 103 | cd /srv/salt/reclass |
Ales Komarek | 1b37311 | 2017-08-08 08:48:56 +0200 | [diff] [blame] | 104 | git submodule update --init --recursive |
Petr Michalec | c7dabcf | 2017-08-30 16:30:13 +0200 | [diff] [blame] | 105 | |
| 106 | # OR (if system level is not add yet) |
Ales Komarek | 1b37311 | 2017-08-08 08:48:56 +0200 | [diff] [blame] | 107 | git submodule add https://github.com/Mirantis/reclass-system-salt-model \ |
| 108 | /srv/salt/reclass/classes/system/ |
| 109 | |
| 110 | cd /srv/salt/scripts |
Petr Michalec | d0cebae | 2017-08-31 12:40:42 +0200 | [diff] [blame] | 111 | HOSTNAME=cfg01 DOMAIN=infra.ci.local ./bootstrap.sh |
Petr Michalec | c7dabcf | 2017-08-30 16:30:13 +0200 | [diff] [blame] | 112 | |
| 113 | |
Petr Michalec | 4c98182 | 2017-08-30 16:47:08 +0200 | [diff] [blame] | 114 | Verify |
| 115 | ------ |
| 116 | Get the *verify.sh* script from https://github.com/salt-formulas/salt-formulas/tree/master/deploy/model |
| 117 | |
| 118 | .. code-block:: bash |
| 119 | |
| 120 | cd /srv/salt/reclass |
Petr Michalec | d0cebae | 2017-08-31 12:40:42 +0200 | [diff] [blame] | 121 | HOSTNAME=cfg01 DOMAIN=infra.ci.local ./verify.sh # or just ./verify.sh |
| 122 | |
Petr Michalec | c7dabcf | 2017-08-30 16:30:13 +0200 | [diff] [blame] | 123 | |
Petr Michalec | d0cebae | 2017-08-31 12:40:42 +0200 | [diff] [blame] | 124 | # individuall minions, if minions get generated under nodes/_generated |
Petr Michalec | 4c98182 | 2017-08-30 16:47:08 +0200 | [diff] [blame] | 125 | ./verify.sh ctl01.k8s-cis-virtual.local |
| 126 | |
| 127 | |
| 128 | Additional bootstrap ENV variables |
| 129 | ---------------------------------- |
| 130 | (for full list of options see the *bootstrap.sh* source) |
| 131 | |
| 132 | .. code-block:: bash |
Petr Michalec | c7dabcf | 2017-08-30 16:30:13 +0200 | [diff] [blame] | 133 | |
| 134 | # reclass |
| 135 | export RECLASS_ADDRESS=<repo url> ## if not already cloned in /srv/salt/reclass > |
Petr Michalec | e07cd0b | 2017-11-15 11:41:57 +0100 | [diff] [blame] | 136 | export RECLASS_VERSION=dev |
Petr Michalec | c7dabcf | 2017-08-30 16:30:13 +0200 | [diff] [blame] | 137 | |
| 138 | # formula |
| 139 | export FORMULAS_BRANCH=master |
| 140 | export FORMULAS_SOURCE=git |
| 141 | |
| 142 | # system / host / salt master minion id |
| 143 | export HOSTNAME=cfg01 |
| 144 | export DOMAIN=infra.ci.local |
Petr Michalec | d0cebae | 2017-08-31 12:40:42 +0200 | [diff] [blame] | 145 | # Following variables are calculated from the above if not provided |
Petr Michalec | c7dabcf | 2017-08-30 16:30:13 +0200 | [diff] [blame] | 146 | #export MINION_ID |
Petr Michalec | d0cebae | 2017-08-31 12:40:42 +0200 | [diff] [blame] | 147 | #export MASTER_HOSTNAME |
| 148 | #export MASTER_IP |
Petr Michalec | c7dabcf | 2017-08-30 16:30:13 +0200 | [diff] [blame] | 149 | |
| 150 | # salt |
| 151 | export BOOTSTRAP_SALTSTACK_OPTS=" -dX stable 2016.3" |
| 152 | export EXTRA_FORMULAS="prometeus" |
| 153 | SALT_SOURCE=${SALT_SOURCE:-pkg} |
| 154 | SALT_VERSION=${SALT_VERSION:-latest} |
| 155 | |
| 156 | # bootstrap |
| 157 | export SALT_MASTER_BOOTSTRAP_MINIMIZED=False |
| 158 | export CLUSTER_NAME=<%= cluster %> |
| 159 | |
| 160 | # workarounds |
Petr Michalec | e07cd0b | 2017-11-15 11:41:57 +0100 | [diff] [blame] | 161 | export RECLASS_IGNORE_CLASS_NOTFOUND=True |
| 162 | export RECLASS_IGNORE_CLASS_REGEXP="service.*" |
Petr Michalec | c7dabcf | 2017-08-30 16:30:13 +0200 | [diff] [blame] | 163 | export EXTRA_FORMULAS="prometheus telegraph" |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | |
Ales Komarek | 1b37311 | 2017-08-08 08:48:56 +0200 | [diff] [blame] | 169 | |
| 170 | |