blob: 7aca6506afebda29c70cd2dd1be4696fd9af68f4 [file] [log] [blame]
Ales Komarek1b373112017-08-08 08:48:56 +02001==============
2Deploy scripts
3==============
4
5This ``deploy/scripts`` serve as shared common place to link any deployment tools.
6
7
8**bootstrap-salt.sh**
9**bootstrap-salt.ps1**
10
11Salt bootstrap scripts. Local copy of upstream `https://bootstrap.saltstack.com/`_.
12
Petr Michalecc7dabcf2017-08-30 16:30:13 +020013**bootstrap.sh**
Ales Komarek1b373112017-08-08 08:48:56 +020014
Petr Michalecc7dabcf2017-08-30 16:30:13 +020015Script 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 Komarek1b373112017-08-08 08:48:56 +020019
Petr Michalecc7dabcf2017-08-30 16:30:13 +020020TL;DR:
Petr Michalece07cd0b2017-11-15 11:41:57 +010021======
Ales Komarek1b373112017-08-08 08:48:56 +020022
Petr Michalecd0cebae2017-08-31 12:40:42 +020023Bootstrap 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 Michalece07cd0b2017-11-15 11:41:57 +010035Common procedure
36================
37
38Download 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
44Install 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
59If you are not using forked reclass (with ingnore_class_notfound option enabled) you have to set
60environment variable FORMULAS_SALT_MASTER containing list of all formulas required on salt master.
61For 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
71Run the ``bootstrap.sh`` script from ``/srv/salt/scripts`` with the ``MASTER_HOSTNAME=$SALT_MASTER_FQDN`` parameter to
Petr Michalecd0cebae2017-08-31 12:40:42 +020072Bootstrap salt-master:
73
Ales Komarek1b373112017-08-08 08:48:56 +020074.. code-block:: bash
75
76 cd /srv/salt/scripts
Ondrej Smolab9f8a852017-09-18 19:43:51 +020077 CLUSTER_NAME=regionOne HOSTNAME=cfg01 DOMAIN=infra.ci.local ./bootstrap.sh
Ales Komarek1b373112017-08-08 08:48:56 +020078
Petr Michalece07cd0b2017-11-15 11:41:57 +010079.. 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 Michalecc7dabcf2017-08-30 16:30:13 +020081
82
Ales Komarek1b373112017-08-08 08:48:56 +020083**formula-fetch.sh**
84
85Script to install formulas with dependencies.
86
87
88**salt-state-apply-trend.sh**
89
90Simple 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
94Bootstrap the Salt Master node
95==============================
96(expects salt-formulas reclass model repo)
97
98.. code-block:: bash
99
Petr Michalec4a11f9d2017-08-08 14:15:56 +0200100 git clone https://github.com/salt-formulas/salt-formulas-scripts /srv/salt/scripts
Ales Komarek1b373112017-08-08 08:48:56 +0200101
102 git clone <model-repository> /srv/salt/reclass
Petr Michalecc7dabcf2017-08-30 16:30:13 +0200103 cd /srv/salt/reclass
Ales Komarek1b373112017-08-08 08:48:56 +0200104 git submodule update --init --recursive
Petr Michalecc7dabcf2017-08-30 16:30:13 +0200105
106 # OR (if system level is not add yet)
Ales Komarek1b373112017-08-08 08:48:56 +0200107 git submodule add https://github.com/Mirantis/reclass-system-salt-model \
108 /srv/salt/reclass/classes/system/
109
110 cd /srv/salt/scripts
Petr Michalecd0cebae2017-08-31 12:40:42 +0200111 HOSTNAME=cfg01 DOMAIN=infra.ci.local ./bootstrap.sh
Petr Michalecc7dabcf2017-08-30 16:30:13 +0200112
113
Petr Michalec4c981822017-08-30 16:47:08 +0200114Verify
115------
116Get 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 Michalecd0cebae2017-08-31 12:40:42 +0200121 HOSTNAME=cfg01 DOMAIN=infra.ci.local ./verify.sh # or just ./verify.sh
122
Petr Michalecc7dabcf2017-08-30 16:30:13 +0200123
Petr Michalecd0cebae2017-08-31 12:40:42 +0200124 # individuall minions, if minions get generated under nodes/_generated
Petr Michalec4c981822017-08-30 16:47:08 +0200125 ./verify.sh ctl01.k8s-cis-virtual.local
126
127
128Additional bootstrap ENV variables
129----------------------------------
130(for full list of options see the *bootstrap.sh* source)
131
132.. code-block:: bash
Petr Michalecc7dabcf2017-08-30 16:30:13 +0200133
134 # reclass
135 export RECLASS_ADDRESS=<repo url> ## if not already cloned in /srv/salt/reclass >
Petr Michalece07cd0b2017-11-15 11:41:57 +0100136 export RECLASS_VERSION=dev
Petr Michalecc7dabcf2017-08-30 16:30:13 +0200137
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 Michalecd0cebae2017-08-31 12:40:42 +0200145 # Following variables are calculated from the above if not provided
Petr Michalecc7dabcf2017-08-30 16:30:13 +0200146 #export MINION_ID
Petr Michalecd0cebae2017-08-31 12:40:42 +0200147 #export MASTER_HOSTNAME
148 #export MASTER_IP
Petr Michalecc7dabcf2017-08-30 16:30:13 +0200149
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 Michalece07cd0b2017-11-15 11:41:57 +0100161 export RECLASS_IGNORE_CLASS_NOTFOUND=True
162 export RECLASS_IGNORE_CLASS_REGEXP="service.*"
Petr Michalecc7dabcf2017-08-30 16:30:13 +0200163 export EXTRA_FORMULAS="prometheus telegraph"
164
165
166
167
168
Ales Komarek1b373112017-08-08 08:48:56 +0200169
170