-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdeploy_test.sh
More file actions
executable file
·107 lines (88 loc) · 2.88 KB
/
deploy_test.sh
File metadata and controls
executable file
·107 lines (88 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/sh
# die when a command has a nonzero exit code
set -e
while getopts "k:" opt; do
case "$opt" in
k)
keep_node="$OPTARG" ;;
esac
done
running=$([ -d hypernode-vagrant ] && cd hypernode-vagrant && vagrant status | grep running > /dev/null 2>&1 && echo 1 || echo 0)
if [ -z "$keep_node" -o "$running" -eq 0 ]; then
# make sure the required vagrant plugins are installed
vagrant plugin list | grep vagrant-vbguest || vagrant plugin install vagrant-vbguest
vagrant plugin list | grep vagrant-hostmanager || vagrant plugin install vagrant-hostmanager
# if hypernode-vagrant directory exists
if test -d hypernode-vagrant; then
cd hypernode-vagrant
# Destroy lingering instance if there is one
vagrant destroy -f
cd ../
# Remove previous Vagrant checkout if it exists
rm -Rf hypernode-vagrant
fi
# create a new checkout of the hypernode-vagrant repo
git clone https://github.com/byteinternet/hypernode-vagrant
# move into the hypernode-vagrant repository directory
cd hypernode-vagrant
# write our local.yml to the hypernode-vagrant directory
cat << EOF > local.yml
---
fs:
type: virtualbox
hostmanager:
extra-aliases:
- my-custom-store-url1.local
- my-custom-store-url2.local
default_domain: hypernode.local
magento:
version: 1
php:
version: 7.0
varnish:
state: false
firewall:
state: false
cgroup:
state: false
xdebug:
state: false
vagrant:
box: hypernode_php7
box_url: http://vagrant.hypernode.com/customer/php7/catalog.json
ubuntu_version: precise
EOF
# make sure we have the last hypernode revision
vagrant box update || /bin/true # don't fail if the box hasn't been added yet
# boot new vagrant instance
vagrant up
cd ../
fi;
# register unique hostname of booted instance
cd hypernode-vagrant
BOX_IP=$(vagrant ssh-config | grep HostName | awk '{print$NF}')
echo "Registered ip: $BOX_IP"
(cd ../ ; git checkout vars.yml)
echo "ansible_ssh_port: $(vagrant ssh-config | grep Port | awk '{print $NF}')" >> ../vars.yml
cd ../
# don't check ssh host key of vagrant box
export ANSIBLE_HOST_KEY_CHECKING=False
# apply deployment playbook
echo "Applying playbook"
ansible-playbook provisioning/community.yml --extra-vars "@vars.yml" --user=app -i "$BOX_IP," # mind the trailing comma
# test if new node was successfully provisioned
echo "Running tests"
nosetests testcase.py
# run the provisioning scripts again to ensure idempotency
echo "Running playbook again to ensure that it's idempotent"
ansible-playbook provisioning/community.yml --extra-vars "@vars.yml" --user=app -i "$BOX_IP," # mind the trailing comma
# test if new node is still ok after second run
echo "Running tests again"
nosetests testcase.py
if ! $keep_node; then
cd hypernode-vagrant
# Destroy test instance
echo "Destroying node"
vagrant destroy -f
cd ../
fi;