| Andrey Shestakov | b31da5c | 2017-05-03 15:57:12 +0000 | [diff] [blame] | 1 | wget -O - https://repo.saltstack.com/apt/ubuntu/16.04/amd64/latest/SALTSTACK-GPG-KEY.pub | sudo apt-key add - | 
|  | 2 | add-apt-repository http://repo.saltstack.com/apt/ubuntu/16.04/amd64/latest | 
|  | 3 | apt update | 
|  | 4 | apt install -y salt-master salt-minion reclass make | 
|  | 5 |  | 
| Andrey Shestakov | 9f03a48 | 2017-05-16 17:00:08 +0300 | [diff] [blame] | 6 | sed -i '/^::1/ s/$/ all01/' /etc/hosts | 
|  | 7 |  | 
| Andrey Shestakov | b31da5c | 2017-05-03 15:57:12 +0000 | [diff] [blame] | 8 | rm /etc/salt/minion_id | 
|  | 9 | rm -f /etc/salt/pki/minion/minion_master.pub | 
|  | 10 | echo "id: all01.local" > /etc/salt/minion | 
|  | 11 | echo "master: localhost" >> /etc/salt/minion | 
|  | 12 |  | 
|  | 13 | [ ! -d /etc/salt/master.d ] && mkdir -p /etc/salt/master.d | 
|  | 14 | cat <<-EOF > /etc/salt/master.d/master.conf | 
|  | 15 | file_roots: | 
|  | 16 | base: | 
|  | 17 | - /usr/share/salt-formulas/env | 
|  | 18 | pillar_opts: False | 
|  | 19 | open_mode: True | 
|  | 20 | reclass: &reclass | 
|  | 21 | storage_type: yaml_fs | 
|  | 22 | inventory_base_uri: /srv/salt/reclass | 
|  | 23 | ext_pillar: | 
|  | 24 | - reclass: *reclass | 
|  | 25 | master_tops: | 
|  | 26 | reclass: *reclass | 
|  | 27 | EOF | 
|  | 28 |  | 
|  | 29 | [ ! -d /etc/reclass ] && mkdir /etc/reclass | 
|  | 30 | cat <<-EOF > /etc/reclass/reclass-config.yml | 
|  | 31 | storage_type: yaml_fs | 
|  | 32 | pretty_print: True | 
|  | 33 | output: yaml | 
|  | 34 | inventory_base_uri: /srv/salt/reclass | 
|  | 35 | EOF | 
|  | 36 |  | 
|  | 37 | service salt-master restart | 
|  | 38 | service salt-minion restart | 
|  | 39 |  | 
|  | 40 | git clone https://github.com/andreyshestakov/mcp-aio /srv/salt/reclass | 
|  | 41 | cd /srv/salt/reclass | 
|  | 42 | git clone https://gerrit.mcp.mirantis.net/p/salt-models/reclass-system.git classes/system | 
|  | 43 | ln -s /usr/share/salt-formulas/reclass/service classes/service | 
|  | 44 |  | 
|  | 45 | export FORMULAS_BASE=https://gerrit.mcp.mirantis.net/salt-formulas | 
|  | 46 | export FORMULAS_PATH=/root/formulas | 
|  | 47 | export FORMULAS_BRANCH=master | 
|  | 48 |  | 
|  | 49 | mkdir -p ${FORMULAS_PATH} | 
| Your Name | d6512c7 | 2017-05-12 15:39:21 +0000 | [diff] [blame] | 50 | declare -a formula_services=("linux" "reclass" "salt" "openssh" "ntp" "git" "nginx" "collectd" "sensu" "heka" "sphinx" "mysql" "grafana" "libvirt" "rsyslog" "memcached" "rabbitmq" "apache" "keystone" "glance" "nova" "neutron" "cinder" "heat" "horizon") | 
| Andrey Shestakov | b31da5c | 2017-05-03 15:57:12 +0000 | [diff] [blame] | 51 | for formula_service in "${formula_services[@]}"; do | 
|  | 52 | _BRANCH=${FORMULAS_BRANCH} | 
|  | 53 | [ ! -d "${FORMULAS_PATH}/${formula_service}" ] && { | 
|  | 54 | if ! git ls-remote --exit-code --heads ${FORMULAS_BASE}/${formula_service}.git ${_BRANCH};then | 
|  | 55 | # Fallback to the master branch if the branch doesn't exist for this repository | 
|  | 56 | _BRANCH=master | 
|  | 57 | fi | 
|  | 58 | git clone ${FORMULAS_BASE}/${formula_service}.git ${FORMULAS_PATH}/${formula_service} -b ${_BRANCH} | 
|  | 59 | } || { | 
|  | 60 | cd ${FORMULAS_PATH}/${formula_service}; | 
|  | 61 | git fetch ${_BRANCH} || git fetch --all | 
|  | 62 | git checkout ${_BRANCH} && git pull || git pull; | 
|  | 63 | cd - | 
|  | 64 | } | 
|  | 65 | cd ${FORMULAS_PATH}/${formula_service} | 
|  | 66 | make install | 
|  | 67 | cd - | 
|  | 68 | done | 
|  | 69 |  | 
| Your Name | d6512c7 | 2017-05-12 15:39:21 +0000 | [diff] [blame] | 70 | fallocate -l 10G /lvm.img | 
|  | 71 | losetup /dev/loop0 /lvm.img | 
|  | 72 | echo -e '#!/bin/bash\nlosetup /dev/loop0 /lvm.img' > /etc/rc.local | 
|  | 73 |  | 
| Andrey Shestakov | 9f03a48 | 2017-05-16 17:00:08 +0300 | [diff] [blame] | 74 | # Apply all | 
| Andrey Shestakov | f12dde9 | 2017-05-17 14:19:52 +0300 | [diff] [blame] | 75 | salt-call state.apply # minimum two times or until success | 
| Andrey Shestakov | 9f03a48 | 2017-05-16 17:00:08 +0300 | [diff] [blame] | 76 |  | 
|  | 77 | # or apply one by one (when fail on some step - repeat or ignore): | 
| Your Name | d6512c7 | 2017-05-12 15:39:21 +0000 | [diff] [blame] | 78 | #salt-call state.apply salt | 
| Andrey Shestakov | 9f03a48 | 2017-05-16 17:00:08 +0300 | [diff] [blame] | 79 | #salt-call state.apply linux,ntp,openssh | 
|  | 80 | #salt-call state.apply memcached | 
|  | 81 | #salt-call state.apply rabbitmq | 
|  | 82 | #salt-call state.apply mysql | 
|  | 83 | #salt-call state.apply keystone | 
|  | 84 | #salt-call state.apply glance | 
|  | 85 | #salt-call state.apply neutron | 
|  | 86 | #salt-call state.apply nova.controller | 
|  | 87 | #salt-call state.apply nova.compute | 
|  | 88 | #salt-call state.apply cinder | 
|  | 89 | #salt-call state.apply heat | 
|  | 90 | #salt-call state.apply horizon | 
| Your Name | d6512c7 | 2017-05-12 15:39:21 +0000 | [diff] [blame] | 91 |  | 
| Andrey Shestakov | 9f03a48 | 2017-05-16 17:00:08 +0300 | [diff] [blame] | 92 | service nova* restart | 
| Your Name | b50e563 | 2017-05-12 14:18:03 +0000 | [diff] [blame] | 93 |  | 
| Andrey Shestakov | b31da5c | 2017-05-03 15:57:12 +0000 | [diff] [blame] | 94 | . /root/keystonercv3 | 
|  | 95 |  | 
|  | 96 | wget http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img | 
|  | 97 | glance image-create --name cirros --visibility public --disk-format qcow2 --container-format bare --file cirros-0.3.5-x86_64-disk.img --progress | 
|  | 98 |  | 
|  | 99 | neutron net-create test | 
|  | 100 | neutron subnet-create test 192.168.1.0/24 | 
|  | 101 |  | 
|  | 102 | nova flavor-create m1.extra_tiny auto 256 0 1 | 
|  | 103 |  | 
|  | 104 | nova boot --flavor m1.extra_tiny --image cirros --nic net-id=d23f9845-cbce-47a6-be15-0603f6a31365 test # UUID of internal network | 
| Your Name | b50e563 | 2017-05-12 14:18:03 +0000 | [diff] [blame] | 105 |  | 
|  | 106 | cinder create --name test 1 | 
|  | 107 | nova volume-attach test 49a471ec-2e6d-4810-9161-6c191e1370f5 # UUID of volume | 
| Your Name | d6512c7 | 2017-05-12 15:39:21 +0000 | [diff] [blame] | 108 |  | 
|  | 109 | # Horizon is available on port :8078 |