Skip to content

Commit 00cfc07

Browse files
Use pyenv to manage Vagrant Python (elastic#189)
With this commit we use pyenv to manage the Python installation for our Vagrant workflow. We also switch to Python 3.6 as our default Python version.
1 parent a71c4fe commit 00cfc07

File tree

1 file changed

+32
-18
lines changed

1 file changed

+32
-18
lines changed

night_rally/fixtures/ansible/Vagrantfile

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -102,24 +102,38 @@ def install_rally_source(rally_repo, rally_branch, rally_sha)
102102
set -eo pipefail
103103
apt-get update
104104
apt-get purge -y python3\*-pip python3\*-setuptools
105-
apt-get install -y python-virtualenv
106-
apt-get install -y python3-dev
107-
sudo -iu jenkins bash -c '
108-
cd /var/lib/jenkins;
109-
#{curl_wrapper} https://bootstrap.pypa.io/get-pip.py -o get-pip.py;
110-
python3 get-pip.py --user;
111-
rm get-pip.py;
112-
mkdir src bin;
113-
cd src;
114-
git clone #{rally_repo} --branch #{rally_branch};
115-
cd rally;
116-
if [[ ! -z \"#{rally_sha}\" ]]; then git checkout #{rally_sha}; fi;
117-
./rally configure;
118-
cd /var/lib/jenkins;
119-
ln -s $PWD/src/rally/rally $PWD/bin/rally;
120-
ln -s $PWD/src/rally/rallyd $PWD/bin/rallyd;
121-
ln -s $PWD/night_rally/night_rally.sh $PWD/bin/night_rally;
122-
'
105+
apt-get install -y build-essential curl libbz2-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev libssl-dev llvm wget xz-utils zlib1g-dev python-virtualenv
106+
cat >/rally-install.sh <<'EOF2'
107+
#!/usr/bin/env bash
108+
109+
cd /var/lib/jenkins
110+
#{curl_wrapper} https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer -o pyenv-installer
111+
bash ./pyenv-installer
112+
rm pyenv-installer
113+
echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> /var/lib/jenkins/.profile
114+
echo 'eval "\$(pyenv init -)"' >> /var/lib/jenkins/.profile
115+
echo 'eval "\$(pyenv virtualenv-init -)"' >> /var/lib/jenkins/.profile
116+
source /var/lib/jenkins/.profile
117+
pyenv install 3.6.10
118+
pyenv local 3.6.10
119+
echo 'pyenv local 3.6.10' >> /var/lib/jenkins/.profile
120+
#{curl_wrapper} https://bootstrap.pypa.io/get-pip.py -o get-pip.py
121+
python3 get-pip.py --user
122+
rm ./get-pip.py
123+
mkdir src bin
124+
cd src
125+
git clone #{rally_repo} --branch #{rally_branch}
126+
cd rally
127+
if [[ ! -z \"#{rally_sha}\" ]]; then git checkout #{rally_sha}; fi
128+
./rally configure
129+
cd /var/lib/jenkins
130+
ln -s $PWD/src/rally/rally $PWD/bin/rally
131+
ln -s $PWD/src/rally/rallyd $PWD/bin/rallyd
132+
ln -s $PWD/night_rally/night_rally.sh $PWD/bin/night_rally
133+
EOF2
134+
135+
chmod ugo+x /rally-install.sh
136+
sudo -iu jenkins /rally-install.sh
123137
EOF
124138
end
125139

0 commit comments

Comments
 (0)