-
Notifications
You must be signed in to change notification settings - Fork 58
/
setup.rb
106 lines (91 loc) · 3.02 KB
/
setup.rb
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
# Copyright (c) 2015 SwiftStack, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
execute "clean-up" do
command "rm /home/vagrant/postinstall.sh || true"
end
if node['extra_key'] then
keys_file = "~vagrant/.ssh/authorized_keys"
execute "add_extra_key" do
command "echo '#{node['extra_key']}' >> #{keys_file}"
not_if "grep -q '#{node['extra_key']}' #{keys_file}"
end
end
execute "enable backports" do
command "sudo sed -ie 's/# deb http:\\/\\/archive.ubuntu.com\\/ubuntu trusty-backports/deb http:\\/\\/archive.ubuntu.com\\/ubuntu trusty-backports/' /etc/apt/sources.list"
action :run
not_if "sudo grep -q '^deb .* trusty-backports' /etc/apt/sources.list"
end
execute "apt-get-update" do
command "apt-get update && touch /tmp/.apt-get-update"
if not node['full_reprovision']
creates "/tmp/.apt-get-update"
end
action :run
end
# packages
# NOTE: Ubuntu Trusty 14.04 provides Python {2.7.6, 3.4.3} out of the box.
required_packages = [
"libjerasure-dev", # required for the EC biz
"libssl-dev", # libssl-dev is required for building wheels from the cryptography package in swift.
"curl", "gcc", "memcached", "rsync", "sqlite3", "xfsprogs", "git-core",
"build-essential", "libffi-dev", "python-dev",
"libxml2-dev", "libxml2", "libxslt1-dev",
]
extra_packages = node['extra_packages']
(required_packages + extra_packages).each do |pkg|
package pkg do
action :install
end
end
# it's a brave new world
execute "install pip" do
command "curl https://bootstrap.pypa.io/get-pip.py | python"
not_if "which pip"
end
execute "upgrade pip" do
command "pip install --upgrade pip"
end
execute "fix pip warning 1" do
command "sed '/env_reset/a Defaults\talways_set_home' -i /etc/sudoers"
not_if "grep always_set_home /etc/sudoers"
end
# setup environment
execute "update-path" do
command "echo 'export PATH=/vagrant/bin:$PATH' >> /home/vagrant/.profile"
not_if "grep /vagrant/bin /home/vagrant/.profile"
action :run
end
# swift command line env setup
{
"ST_AUTH" => "http://#{node['hostname']}:8080/auth/v1.0",
"ST_USER" => "test:tester",
"ST_KEY" => "testing",
}.each do |var, value|
execute "swift-env-#{var}" do
command "echo 'export #{var}=#{value}' >> /home/vagrant/.profile"
not_if "grep #{var} /home/vagrant/.profile"
action :run
end
end
# other useful env vars
{
"NOSE_INCLUDE_EXE" => "true",
}.each do |var, value|
execute "swift-env-#{var}" do
command "echo 'export #{var}=#{value}' >> /home/vagrant/.profile"
not_if "grep #{var} /home/vagrant/.profile"
action :run
end
end