blob: 57c0417c1c1ae124c109c8ca1dd096ca14ae82de [file] [log] [blame]
Dennis Dmitrievab83ea42017-05-12 16:52:45 +03001{% from 'virtual-mcp10-ovs/map.jinja' import HOSTNAME_CFG01 with context %}
Dennis Dmitriev5ec4d572017-09-27 00:47:54 +03002{% from 'virtual-mcp10-ovs/map.jinja' import LAB_CONFIG_NAME with context %}
3{% from 'virtual-mcp10-ovs/map.jinja' import DOMAIN_NAME with context %}
Tatyana Leontovich055b5062017-04-03 13:17:25 +03004
Sergii Golovatiuk50f91892017-08-04 18:11:06 +02005{% set SALT_MODELS_REPOSITORY = os_env('SALT_MODELS_REPOSITORY','https://gerrit.mcp.mirantis.net/salt-models/mcp-virtual-lab') %}
6# Other salt model repository parameters see in shared-salt.yaml
Tatyana Leontovich055b5062017-04-03 13:17:25 +03007
Sergii Golovatiuk50f91892017-08-04 18:11:06 +02008{% import 'shared-salt.yaml' as SHARED with context %}
9
10# Install salt to the config node
Tatyana Leontovich055b5062017-04-03 13:17:25 +030011
Tatyana Leontovich5fd6ed62017-04-04 15:08:29 +030012- description: Configure repository on the cfg01 node
13 cmd:
Tatyana Leontovich3c6aa452017-04-25 15:04:40 +030014 echo "nameserver 172.18.208.44" >> /etc/resolv.conf;
Tatyana Leontovich5fd6ed62017-04-04 15:08:29 +030015 which wget >/dev/null || (apt-get update; apt-get install -y wget);
obutenko89aedf82017-08-04 12:50:37 +030016 echo "deb [arch=amd64] http://apt.mirantis.com/xenial nightly salt extra" > /etc/apt/sources.list.d/mcp_salt.list;
17 wget -O - http://apt.mirantis.com/public.gpg | apt-key add -;
Tatyana Leontovich055b5062017-04-03 13:17:25 +030018 echo "deb http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3 xenial main" > /etc/apt/sources.list.d/saltstack.list;
19 wget -O - https://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3/SALTSTACK-GPG-KEY.pub | apt-key add -;
Tatyana Leontovich055b5062017-04-03 13:17:25 +030020 node_name: {{ HOSTNAME_CFG01 }}
21 retry: {count: 1, delay: 1}
22 skip_fail: false
23
Tatyana Leontovich055b5062017-04-03 13:17:25 +030024- description: Update packages on cfg01
Tatyana Leontovich2dde4aa2017-04-04 13:06:10 +030025 cmd: apt-get clean; apt-get update
Tatyana Leontovich055b5062017-04-03 13:17:25 +030026 node_name: {{ HOSTNAME_CFG01 }}
Tatyana Leontovich2dde4aa2017-04-04 13:06:10 +030027 retry: {count: 1, delay: 1}
Tatyana Leontovich055b5062017-04-03 13:17:25 +030028 skip_fail: false
29
Tatyana Leontovich2dde4aa2017-04-04 13:06:10 +030030- description: Install common packages on cfg01
31 cmd: apt-get install -y python-pip wget curl tmux byobu iputils-ping traceroute htop tree
32 node_name: {{ HOSTNAME_CFG01 }}
33 retry: {count: 1, delay: 1}
Tatyana Leontovich055b5062017-04-03 13:17:25 +030034 skip_fail: false
35
Dennis Dmitriev492813e2017-08-09 15:08:58 +030036{{ SHARED.MACRO_INSTALL_SALT_MASTER() }}
Tatyana Leontovich055b5062017-04-03 13:17:25 +030037
Dennis Dmitriev492813e2017-08-09 15:08:58 +030038{{ SHARED.MACRO_CLONE_RECLASS_MODELS() }}
Tatyana Leontovich30a9db12017-04-06 14:28:39 +030039
Dennis Dmitriev492813e2017-08-09 15:08:58 +030040{{ SHARED.MACRO_CONFIGURE_RECLASS(FORMULA_SERVICES='"linux" "reclass" "salt" "openssh" "ntp" "git" "nginx" "collectd" "sensu" "heka" "sphinx" "keystone" "mysql" "grafana" "haproxy" "rsyslog" "horizon"') }}
Tatyana Leontovich055b5062017-04-03 13:17:25 +030041
42- description: Configure salt-minion on cfg01
43 cmd: |
44 [ ! -d /etc/salt/minion.d ] && mkdir -p /etc/salt/minion.d;
45 cat << "EOF" >> /etc/salt/minion.d/minion.conf
46 id: {{ HOSTNAME_CFG01 }}
Tatyana Leontovich5fd6ed62017-04-04 15:08:29 +030047 master: 127.0.0.1
Tatyana Leontovich055b5062017-04-03 13:17:25 +030048 EOF
Tatyana Leontovich2dde4aa2017-04-04 13:06:10 +030049 apt-get install -y salt-minion;
Tatyana Leontovich055b5062017-04-03 13:17:25 +030050 node_name: {{ HOSTNAME_CFG01 }}
51 retry: {count: 1, delay: 1}
52 skip_fail: false
53
Tatyana Leontovich14f6a1a2017-04-04 17:30:58 +030054
Tatyana Leontovich2dde4aa2017-04-04 13:06:10 +030055- description: Restart services
56 cmd: |
57 systemctl restart salt-master;
58 systemctl restart salt-minion;
59 echo "Showing system info and metadata ...";
60 salt-call --no-color grains.items;
61 salt-call --no-color pillar.data;
Tatyana Leontovich055b5062017-04-03 13:17:25 +030062 node_name: {{ HOSTNAME_CFG01 }}
Tatyana Leontovich81128412017-04-05 18:46:29 +030063 retry: {count: 1, delay: 5}
Tatyana Leontovich055b5062017-04-03 13:17:25 +030064 skip_fail: false
65
Dennis Dmitriev492813e2017-08-09 15:08:58 +030066{{ SHARED.MACRO_RUN_SALT_MASTER_UNDERLAY_STATES() }}
Tatyana Leontovich2dde4aa2017-04-04 13:06:10 +030067
Dennis Dmitriev492813e2017-08-09 15:08:58 +030068{{ SHARED.MACRO_GENERATE_INVENTORY() }}
Tatyana Leontovich055b5062017-04-03 13:17:25 +030069
Dennis Dmitriev492813e2017-08-09 15:08:58 +030070{{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }}
Tatyana Leontovich055b5062017-04-03 13:17:25 +030071
Tatyana Leontovich4d0d8942017-04-06 19:10:56 +030072- description: Hack gtw node
73 cmd: salt 'gtw*' cmd.run "ip addr del 172.16.10.110/24 dev ens4; ip addr flush dev ens4";
74 node_name: {{ HOSTNAME_CFG01 }}
75 retry: {count: 1, delay: 10}
76 skip_fail: false
77
78- description: Hack cmp01 node
79 cmd: salt 'cmp01*' cmd.run "ip addr del 172.16.10.105/24 dev ens4; ip addr flush dev ens4";
80 node_name: {{ HOSTNAME_CFG01 }}
81 retry: {count: 1, delay: 10}
82 skip_fail: false
83
84- description: Hack cmp02 node
85 cmd: salt 'cmp02*' cmd.run "ip addr del 172.16.10.106/24 dev ens4; ip addr flush dev ens4";
86 node_name: {{ HOSTNAME_CFG01 }}
87 retry: {count: 1, delay: 10}
88 skip_fail: false
89