Dennis Dmitriev | ab83ea4 | 2017-05-12 16:52:45 +0300 | [diff] [blame] | 1 | {% from 'virtual-mcp10-ovs/map.jinja' import HOSTNAME_CFG01 with context %} |
Tatyana Leontovich | 055b506 | 2017-04-03 13:17:25 +0300 | [diff] [blame] | 2 | |
Sergii Golovatiuk | 50f9189 | 2017-08-04 18:11:06 +0200 | [diff] [blame] | 3 | {% set SALT_MODELS_REPOSITORY = os_env('SALT_MODELS_REPOSITORY','https://gerrit.mcp.mirantis.net/salt-models/mcp-virtual-lab') %} |
| 4 | # Other salt model repository parameters see in shared-salt.yaml |
Tatyana Leontovich | 055b506 | 2017-04-03 13:17:25 +0300 | [diff] [blame] | 5 | |
Sergii Golovatiuk | 50f9189 | 2017-08-04 18:11:06 +0200 | [diff] [blame] | 6 | {% import 'shared-salt.yaml' as SHARED with context %} |
| 7 | |
| 8 | # Install salt to the config node |
Tatyana Leontovich | 055b506 | 2017-04-03 13:17:25 +0300 | [diff] [blame] | 9 | |
Tatyana Leontovich | 5fd6ed6 | 2017-04-04 15:08:29 +0300 | [diff] [blame] | 10 | - description: Configure repository on the cfg01 node |
| 11 | cmd: |
Tatyana Leontovich | 3c6aa45 | 2017-04-25 15:04:40 +0300 | [diff] [blame] | 12 | echo "nameserver 172.18.208.44" >> /etc/resolv.conf; |
| 13 | echo "nameserver 8.8.8.8" >> /etc/resolv.conf; |
Tatyana Leontovich | 5fd6ed6 | 2017-04-04 15:08:29 +0300 | [diff] [blame] | 14 | which wget >/dev/null || (apt-get update; apt-get install -y wget); |
obutenko | 89aedf8 | 2017-08-04 12:50:37 +0300 | [diff] [blame] | 15 | echo "deb [arch=amd64] http://apt.mirantis.com/xenial nightly salt extra" > /etc/apt/sources.list.d/mcp_salt.list; |
| 16 | wget -O - http://apt.mirantis.com/public.gpg | apt-key add -; |
Tatyana Leontovich | 055b506 | 2017-04-03 13:17:25 +0300 | [diff] [blame] | 17 | echo "deb http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3 xenial main" > /etc/apt/sources.list.d/saltstack.list; |
| 18 | wget -O - https://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3/SALTSTACK-GPG-KEY.pub | apt-key add -; |
Tatyana Leontovich | 055b506 | 2017-04-03 13:17:25 +0300 | [diff] [blame] | 19 | node_name: {{ HOSTNAME_CFG01 }} |
| 20 | retry: {count: 1, delay: 1} |
| 21 | skip_fail: false |
| 22 | |
Tatyana Leontovich | 055b506 | 2017-04-03 13:17:25 +0300 | [diff] [blame] | 23 | - description: Update packages on cfg01 |
Tatyana Leontovich | 2dde4aa | 2017-04-04 13:06:10 +0300 | [diff] [blame] | 24 | cmd: apt-get clean; apt-get update |
Tatyana Leontovich | 055b506 | 2017-04-03 13:17:25 +0300 | [diff] [blame] | 25 | node_name: {{ HOSTNAME_CFG01 }} |
Tatyana Leontovich | 2dde4aa | 2017-04-04 13:06:10 +0300 | [diff] [blame] | 26 | retry: {count: 1, delay: 1} |
Tatyana Leontovich | 055b506 | 2017-04-03 13:17:25 +0300 | [diff] [blame] | 27 | skip_fail: false |
| 28 | |
Tatyana Leontovich | 2dde4aa | 2017-04-04 13:06:10 +0300 | [diff] [blame] | 29 | - description: Install common packages on cfg01 |
| 30 | cmd: apt-get install -y python-pip wget curl tmux byobu iputils-ping traceroute htop tree |
| 31 | node_name: {{ HOSTNAME_CFG01 }} |
| 32 | retry: {count: 1, delay: 1} |
Tatyana Leontovich | 055b506 | 2017-04-03 13:17:25 +0300 | [diff] [blame] | 33 | skip_fail: false |
| 34 | |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame^] | 35 | {{ SHARED.MACRO_INSTALL_SALT_MASTER() }} |
Tatyana Leontovich | 055b506 | 2017-04-03 13:17:25 +0300 | [diff] [blame] | 36 | |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame^] | 37 | {{ SHARED.MACRO_CLONE_RECLASS_MODELS() }} |
Tatyana Leontovich | 30a9db1 | 2017-04-06 14:28:39 +0300 | [diff] [blame] | 38 | |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame^] | 39 | {{ SHARED.MACRO_CONFIGURE_RECLASS(FORMULA_SERVICES='"linux" "reclass" "salt" "openssh" "ntp" "git" "nginx" "collectd" "sensu" "heka" "sphinx" "keystone" "mysql" "grafana" "haproxy" "rsyslog" "horizon"') }} |
Tatyana Leontovich | 055b506 | 2017-04-03 13:17:25 +0300 | [diff] [blame] | 40 | |
| 41 | - description: Configure salt-minion on cfg01 |
| 42 | cmd: | |
| 43 | [ ! -d /etc/salt/minion.d ] && mkdir -p /etc/salt/minion.d; |
| 44 | cat << "EOF" >> /etc/salt/minion.d/minion.conf |
| 45 | id: {{ HOSTNAME_CFG01 }} |
Tatyana Leontovich | 5fd6ed6 | 2017-04-04 15:08:29 +0300 | [diff] [blame] | 46 | master: 127.0.0.1 |
Tatyana Leontovich | 055b506 | 2017-04-03 13:17:25 +0300 | [diff] [blame] | 47 | EOF |
Tatyana Leontovich | 2dde4aa | 2017-04-04 13:06:10 +0300 | [diff] [blame] | 48 | apt-get install -y salt-minion; |
Tatyana Leontovich | 055b506 | 2017-04-03 13:17:25 +0300 | [diff] [blame] | 49 | node_name: {{ HOSTNAME_CFG01 }} |
| 50 | retry: {count: 1, delay: 1} |
| 51 | skip_fail: false |
| 52 | |
Tatyana Leontovich | 14f6a1a | 2017-04-04 17:30:58 +0300 | [diff] [blame] | 53 | |
Tatyana Leontovich | 2dde4aa | 2017-04-04 13:06:10 +0300 | [diff] [blame] | 54 | - description: Restart services |
| 55 | cmd: | |
| 56 | systemctl restart salt-master; |
| 57 | systemctl restart salt-minion; |
| 58 | echo "Showing system info and metadata ..."; |
| 59 | salt-call --no-color grains.items; |
| 60 | salt-call --no-color pillar.data; |
Tatyana Leontovich | 055b506 | 2017-04-03 13:17:25 +0300 | [diff] [blame] | 61 | node_name: {{ HOSTNAME_CFG01 }} |
Tatyana Leontovich | 8112841 | 2017-04-05 18:46:29 +0300 | [diff] [blame] | 62 | retry: {count: 1, delay: 5} |
Tatyana Leontovich | 055b506 | 2017-04-03 13:17:25 +0300 | [diff] [blame] | 63 | skip_fail: false |
| 64 | |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame^] | 65 | {{ SHARED.MACRO_RUN_SALT_MASTER_UNDERLAY_STATES() }} |
Tatyana Leontovich | 2dde4aa | 2017-04-04 13:06:10 +0300 | [diff] [blame] | 66 | |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame^] | 67 | {{ SHARED.MACRO_GENERATE_INVENTORY() }} |
Tatyana Leontovich | 055b506 | 2017-04-03 13:17:25 +0300 | [diff] [blame] | 68 | |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame^] | 69 | {{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }} |
Tatyana Leontovich | 055b506 | 2017-04-03 13:17:25 +0300 | [diff] [blame] | 70 | |
Tatyana Leontovich | 4d0d894 | 2017-04-06 19:10:56 +0300 | [diff] [blame] | 71 | - description: Hack gtw node |
| 72 | cmd: salt 'gtw*' cmd.run "ip addr del 172.16.10.110/24 dev ens4; ip addr flush dev ens4"; |
| 73 | node_name: {{ HOSTNAME_CFG01 }} |
| 74 | retry: {count: 1, delay: 10} |
| 75 | skip_fail: false |
| 76 | |
| 77 | - description: Hack cmp01 node |
| 78 | cmd: salt 'cmp01*' cmd.run "ip addr del 172.16.10.105/24 dev ens4; ip addr flush dev ens4"; |
| 79 | node_name: {{ HOSTNAME_CFG01 }} |
| 80 | retry: {count: 1, delay: 10} |
| 81 | skip_fail: false |
| 82 | |
| 83 | - description: Hack cmp02 node |
| 84 | cmd: salt 'cmp02*' cmd.run "ip addr del 172.16.10.106/24 dev ens4; ip addr flush dev ens4"; |
| 85 | node_name: {{ HOSTNAME_CFG01 }} |
| 86 | retry: {count: 1, delay: 10} |
| 87 | skip_fail: false |
| 88 | |