Commit 5556ceeb authored by Rafael Monnerat's avatar Rafael Monnerat

standarlize script, and make an easy script generator.

parent 92261576
from jinja2 import Template
template = Template(open("install.template").read())
def render(yml_name, relative_url):
content = template.render(
playbook_file="https://lab.nexedi.cn/rafael/slapos.playbook/repository/archive.tar.gz?ref=master",
playbook_yml=yml_name)
open(relative_url, "w").write(content)
render("slapos.yml", "install/slapos")
render("re6stnet.yml", "install/re6st")
# gnet
render("gnet-re6stnet.yml", "install/gnet/re6st")
render("gnet-server.yml", "install/gnet/slapos")
# imt
render("imt-server-update.yml", "install/imt/slapos-update")
render("imt-server.yml", "install/imt/slapos")
#!/bin/bash
PLAYBOOK_REPOSITORY_URL={{ playbook_file }}
PLAYBOOK_FILE={{ playbook_yml }}
#### Setup Ansible and load few libraries #####
BASE_SETUP_SCRIPT_MD5=d80faf54b390f82d03191405f3d3037c
wget --no-check-certificate https://deploy.nexedi.cn/base-setup -O /tmp/base-setup
if [ "`md5sum /tmp/base-setup | cut -f1 -d\ `" != "$BASE_SETUP_SCRIPT_MD5" ]; then
echo "ERROR: base-setup has wrong md5 `md5sum /tmp/base-setup | cut -f1 -d\ ` != $BASE_SETUP_SCRIPT_MD5"
exit 1
fi
source /tmp/base-setup
download_playbook $PLAYBOOK_REPOSITORY_URL
echo "Starting Ansible playbook:"
ansible-playbook $PLAYBOOK_FILE -i hosts --connection=local
#!/bin/bash
PLAYBOOK_REPOSITORY_URL=https://lab.nexedi.cn/rafael/slapos.playbook/repository/archive.tar.gz?ref=master
PLAYBOOK_REPOSITORY_URL=https://lab.nexedi.cn/rafael/slapos.playbook/repository/archive.tar.gz?ref=master
PLAYBOOK_FILE=gnet-re6stnet.yml
wget --no-check-certificate https://lab.nexedi.cn/rafael/slapos.playbook/raw/master/install/base-setup -O /tmp/base-setup
#### Setup Ansible and load few libraries #####
BASE_SETUP_SCRIPT_MD5=d80faf54b390f82d03191405f3d3037c
wget --no-check-certificate https://deploy.nexedi.cn/base-setup -O /tmp/base-setup
if [ "`md5sum /tmp/base-setup | cut -f1 -d\ `" != "$BASE_SETUP_SCRIPT_MD5" ]; then
echo "ERROR: base-setup has wrong md5 `md5sum /tmp/base-setup | cut -f1 -d\ ` != $BASE_SETUP_SCRIPT_MD5"
exit 1
fi
source /tmp/base-setup
download_playbook $PLAYBOOK_REPOSITORY_URL
clear
echo "Staring ansible..."
echo "Starting Ansible playbook:"
ansible-playbook re6st.yml -i hosts --connection=local
ansible-playbook $PLAYBOOK_FILE -i hosts --connection=local
#!/bin/bash
PLAYBOOK_REPOSITORY_URL=https://lab.nexedi.cn/rafael/slapos.playbook/repository/archive.tar.gz?ref=master
PLAYBOOK_REPOSITORY_URL=https://lab.nexedi.cn/rafael/slapos.playbook/repository/archive.tar.gz?ref=master
PLAYBOOK_FILE=gnet-server.yml
wget --no-check-certificate https://lab.nexedi.cn/rafael/slapos.playbook/raw/master/install/base-setup -O /tmp/base-setup
#### Setup Ansible and load few libraries #####
BASE_SETUP_SCRIPT_MD5=d80faf54b390f82d03191405f3d3037c
wget --no-check-certificate https://deploy.nexedi.cn/base-setup -O /tmp/base-setup
if [ "`md5sum /tmp/base-setup | cut -f1 -d\ `" != "$BASE_SETUP_SCRIPT_MD5" ]; then
echo "ERROR: base-setup has wrong md5 `md5sum /tmp/base-setup | cut -f1 -d\ ` != $BASE_SETUP_SCRIPT_MD5"
exit 1
fi
source /tmp/base-setup
download_playbook $PLAYBOOK_REPOSITORY_URL
clear
echo "Staring ansible..."
echo "Starting Ansible playbook:"
ansible-playbook site.yml -i hosts --connection=local
ansible-playbook $PLAYBOOK_FILE -i hosts --connection=local
\ No newline at end of file
#!/bin/bash
PLAYBOOK_REPOSITORY_URL=https://lab.nexedi.cn/rafael/slapos.playbook/repository/archive.tar.gz?ref=master
PLAYBOOK_FILE=imt-server.yml
PLAYBOOK_REPOSITORY_URL=https://lab.nexedi.cn/rafael/slapos.playbook/repository/archive.tar.gz?ref=master
PLAYBOOK_BASE_FOLDER=slapos.playbook.git
PLAYBOOK_RELATIVE_URL=$PLAYBOOK_BASE_FOLDER/playbook/slapos
PLAYBOOK_FILENAME=slapos.playbook.git.master.tar.gz
wget --no-check-certificate https://lab.nexedi.cn/rafael/slapos.playbook/raw/master/install/function-common -O /tmp/function-common
#### Setup Ansible and load few libraries #####
BASE_SETUP_SCRIPT_MD5=d80faf54b390f82d03191405f3d3037c
source /tmp/function-common
wget --no-check-certificate https://deploy.nexedi.cn/base-setup -O /tmp/base-setup
# Determine what system we are running on. This provides ``os_VENDOR``,
# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME``
# and ``DISTRO``
GetDistro
# Warn users who aren't on an explicitly supported distro, but allow them to
# override check and attempt installation with ``export FORCE=yes``
if [[ ! ${DISTRO} =~ (wheezy|trusty|rhel7) ]]; then
echo "WARNING: this script has not been tested on $DISTRO"
if [[ "$FORCE" != "yes" ]]; then
die $LINENO "If you wish to run this script anyway run with FORCE=yes"
fi
if [ "`md5sum /tmp/base-setup | cut -f1 -d\ `" != "$BASE_SETUP_SCRIPT_MD5" ]; then
echo "ERROR: base-setup has wrong md5 `md5sum /tmp/base-setup | cut -f1 -d\ ` != $BASE_SETUP_SCRIPT_MD5"
exit 1
fi
if is_fedora && [[ $DISTRO == "rhel7" ]]; then
# RHEL requires EPEL for many Open Stack dependencies
# NOTE: We always remove and install latest -- some environments
# use snapshot images, and if EPEL version updates they break
# unless we update them to latest version.
if sudo yum repolist enabled epel | grep -q 'epel'; then
uninstall_package epel-release || true
fi
# This trick installs the latest epel-release from a bootstrap
# repo, then removes itself (as epel-release installed the
# "real" repo).
#
# You would think that rather than this, you could use
# $releasever directly in .repo file we create below. However
# RHEL gives a $releasever of "6Server" which breaks the path;
# see https://bugzilla.redhat.com/show_bug.cgi?id=1150759
cat <<EOF | sudo tee /etc/yum.repos.d/epel-bootstrap.repo
[epel-bootstrap]
name=Bootstrap EPEL
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-7&arch=\$basearch
failovermethod=priority
enabled=0
gpgcheck=0
EOF
# Enable a bootstrap repo. It is removed after finishing
# the epel-release installation.
yum-config-manager --enable epel-bootstrap
yum_install epel-release || \
die $LINENO "Error installing EPEL repo, cannot continue"
# EPEL rpm has installed it's version
rm -f /etc/yum.repos.d/epel-bootstrap.repo
# ... and also optional to be enabled
is_package_installed yum-utils || install_package yum-utils
yum-config-manager --enable rhel-7-server-optional-rpms
fi
is_package_installed ansible || install_package ansible
if is_ubuntu && [[ $DISTRO == "trusty" ]]; then
is_package_installed python-apt || install_package python-apt
is_package_installed python-pycurl || install_package python-pycurl
fi
exit
rm -rf /tmp/$PLAYBOOK_FILENAME /tmp/$PLAYBOOK_BASE_FOLDER
wget $PLAYBOOK_REPOSITORY_URL -O /tmp/$PLAYBOOK_FILENAME
cd /tmp && tar -xzvf $PLAYBOOK_FILENAME
source /tmp/base-setup
cd /tmp/$PLAYBOOK_RELATIVE_URL
download_playbook $PLAYBOOK_REPOSITORY_URL
clear
echo "Staring ansible..."
echo "Starting Ansible playbook:"
ansible-playbook imtserver.yml -i hosts --connection=local
ansible-playbook $PLAYBOOK_FILE -i hosts --connection=local
\ No newline at end of file
#!/bin/bash
PLAYBOOK_REPOSITORY_URL=https://lab.nexedi.cn/rafael/slapos.playbook/repository/archive.tar.gz?ref=master
PLAYBOOK_FILE=imt-server-update.yml
#### Setup Ansible and load few libraries #####
BASE_SETUP_SCRIPT_MD5=d80faf54b390f82d03191405f3d3037c
wget --no-check-certificate https://deploy.nexedi.cn/base-setup -O /tmp/base-setup
if [ "`md5sum /tmp/base-setup | cut -f1 -d\ `" != "$BASE_SETUP_SCRIPT_MD5" ]; then
echo "ERROR: base-setup has wrong md5 `md5sum /tmp/base-setup | cut -f1 -d\ ` != $BASE_SETUP_SCRIPT_MD5"
exit 1
fi
source /tmp/base-setup
download_playbook $PLAYBOOK_REPOSITORY_URL
echo "Starting Ansible playbook:"
ansible-playbook $PLAYBOOK_FILE -i hosts --connection=local
\ No newline at end of file
#!/bin/bash
PLAYBOOK_REPOSITORY_URL=https://lab.nexedi.cn/rafael/slapos.playbook/repository/archive.tar.gz?ref=master
PLAYBOOK_REPOSITORY_URL=https://lab.nexedi.cn/rafael/slapos.playbook/repository/archive.tar.gz?ref=master
PLAYBOOK_FILE=re6stnet.yml
wget --no-check-certificate https://lab.nexedi.cn/rafael/slapos.playbook/raw/master/install/base-setup -O /tmp/base-setup
#### Setup Ansible and load few libraries #####
BASE_SETUP_SCRIPT_MD5=d80faf54b390f82d03191405f3d3037c
wget --no-check-certificate https://deploy.nexedi.cn/base-setup -O /tmp/base-setup
if [ "`md5sum /tmp/base-setup | cut -f1 -d\ `" != "$BASE_SETUP_SCRIPT_MD5" ]; then
echo "ERROR: base-setup has wrong md5 `md5sum /tmp/base-setup | cut -f1 -d\ ` != $BASE_SETUP_SCRIPT_MD5"
exit 1
fi
source /tmp/base-setup
download_playbook $PLAYBOOK_REPOSITORY_URL
clear
echo "Staring ansible..."
echo "Starting Ansible playbook:"
ansible-playbook re6st.yml -i hosts --connection=local
ansible-playbook $PLAYBOOK_FILE -i hosts --connection=local
\ No newline at end of file
#!/bin/bash
PLAYBOOK_REPOSITORY_URL=https://lab.nexedi.cn/rafael/slapos.playbook/repository/archive.tar.gz?ref=master
PLAYBOOK_REPOSITORY_URL=https://lab.nexedi.cn/rafael/slapos.playbook/repository/archive.tar.gz?ref=master
PLAYBOOK_FILE=slapos.yml
wget --no-check-certificate https://lab.nexedi.cn/rafael/slapos.playbook/raw/master/install/base-setup -O /tmp/base-setup
#### Setup Ansible and load few libraries #####
BASE_SETUP_SCRIPT_MD5=d80faf54b390f82d03191405f3d3037c
wget --no-check-certificate https://deploy.nexedi.cn/base-setup -O /tmp/base-setup
if [ "`md5sum /tmp/base-setup | cut -f1 -d\ `" != "$BASE_SETUP_SCRIPT_MD5" ]; then
echo "ERROR: base-setup has wrong md5 `md5sum /tmp/base-setup | cut -f1 -d\ ` != $BASE_SETUP_SCRIPT_MD5"
exit 1
fi
source /tmp/base-setup
download_playbook $PLAYBOOK_REPOSITORY_URL
clear
echo "Staring ansible..."
echo "Starting Ansible playbook:"
ansible-playbook site.yml -i hosts --connection=local
ansible-playbook $PLAYBOOK_FILE -i hosts --connection=local
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment