Commit b2fd7c04 authored by Rafael Monnerat's avatar Rafael Monnerat

playbook: Remove install-install script

  The implementation was moved to slapos master as a website.
parent fd225231
Pipeline #3385 skipped
- name: a play that runs entirely on the ansible host
hosts: 127.0.0.1
connection: local
vars:
- base_path: .
pre_tasks:
- name: Create script structure
command: mkdir -p {{ base_path }}/{{ item }}
with_items:
- install/gnet/
- install/unstable/gnet/
- install/testing/gnet/
- install/imt/
- install/unstable/imt/
- name: generate scripts
template: src=roles/install-script/templates/base_setup.j2 dest={{ base_path }}/install/base-setup mode=0666
- name: Register base-setup md5
stat: path={{ base_path }}/install/base-setup
register: base_setup
- name: generate scripts
template: src=roles/install-script/templates/dev.j2 dest={{ base_path }}/install/devbook mode=0666
- name: generate ansible-only
template: src=roles/install-script/templates/ansible-only.j2 dest={{ base_path }}/install/ansible mode=0666
- name: generate main index.html
copy: src=roles/install-script/files/main_index.html dest={{ base_path }}/install/index.html mode=0666
- name: generate index.html
copy: src=roles/install-script/files/index.html dest={{ base_path }}/{{ item }}/index.html mode=0666
with_items:
- install/gnet
- install/imt
- install/unstable
- install/unstable/imt
- install/testing/gnet
- install/testing
post_tasks:
- shell: tree | grep -v index.html | grep -v \ directories > map.txt
args:
chdir: install/
roles:
- { role: "install-script", channel: "slapos", playbook_yml: "slapos.yml", script_path: "install/slapos" }
- { role: "install-script", channel: "slapos", playbook_yml: "re6stnet.yml", script_path: "install/re6st"}
- { role: "install-script", channel: "slapos", playbook_yml: "vifib.yml", script_path: "install/vifib"}
- { role: "install-script", channel: "slapos", playbook_yml: "vifib-shuttle.yml", script_path: "install/vifib-shuttle"}
- { role: "install-script", channel: "slapos", playbook_yml: "erp5-standalone.yml", script_path: "install/erp5-standalone"}
- { role: "install-script", channel: "slapos", playbook_yml: "wendelin-standalone.yml", script_path: "install/wendelin-standalone"}
- { role: "install-script", channel: "slapos", playbook_yml: "slapos-test-node.yml", script_path: "install/slapos-test-node"}
- { role: "install-script", channel: "slapos", playbook_yml: "gnet-re6stnet.yml", script_path: "install/gnet/re6st"}
- { role: "install-script", channel: "slapos", playbook_yml: "gnet-server.yml", script_path: "install/gnet/slapos"}
- { role: "install-script", channel: "slapos", playbook_yml: "gnet-upgrader-install.yml", script_path: "install/gnet/upgrader-install"}
- { role: "install-script", channel: "slapos", playbook_yml: "test-suite.yml", script_path: "install/test-suite"}
- { role: "install-script", channel: "slapos", playbook_yml: "vifib-upgrader-install.yml", script_path: "install/vifib-upgrader-install"}
- { role: "install-script", channel: "slapos", playbook_yml: "webrunner-standalone.yml", script_path: "install/webrunner-standalone"}
- { role: "install-script", channel: "slapos", playbook_yml: "slapos-master-standalone.yml", script_path: "install/slapos-master-standalone"}
- { role: "install-script", channel: "stable", playbook_yml: "imt-server-update.yml", script_path: "install/imt/slapos-update"}
- { role: "install-script", channel: "stable", playbook_yml: "imt-server.yml", script_path: "install/imt/slapos"}
- { role: "install-script", channel: "stable", playbook_yml: "imt-vm-bootstrap.yml", script_path: "install/imt/vm-bootstrap"}
- { role: "install-script", channel: "stable", playbook_yml: "imt-vm-cloudera-manager.yml", script_path: "install/imt/vm-cloudera-manager"}
- { role: "install-script", channel: "stable", playbook_yml: "imt-re6stnet.yml", script_path: "install/imt/re6st"}
- { role: "install-script", channel: "stable2", playbook_yml: "imt-vm-bootstrap.yml", script_path: "install/imt/generic-vm-bootstrap"}
- { role: "install-script", channel: "slapos_testing", playbook_yml: "slapos.yml", script_path: "install/testing/slapos" }
- { role: "install-script", channel: "slapos_testing", playbook_yml: "re6stnet.yml", script_path: "install/testing/re6st"}
- { role: "install-script", channel: "slapos_testing", playbook_yml: "vifib.yml", script_path: "install/testing/vifib"}
- { role: "install-script", channel: "slapos_testing", playbook_yml: "vifib-shuttle.yml", script_path: "install/testing/vifib-shuttle"}
- { role: "install-script", channel: "slapos_testing", playbook_yml: "erp5-standalone.yml", script_path: "install/testing/erp5-standalone"}
- { role: "install-script", channel: "slapos_testing", playbook_yml: "wendelin-standalone.yml", script_path: "install/testing/wendelin-standalone"}
- { role: "install-script", channel: "slapos_testing", playbook_yml: "slapos-test-node.yml", script_path: "install/testing/slapos-test-node"}
- { role: "install-script", channel: "slapos_testing", playbook_yml: "gnet-re6stnet.yml", script_path: "install/testing/gnet/re6st"}
- { role: "install-script", channel: "slapos_testing", playbook_yml: "gnet-server.yml", script_path: "install/testing/gnet/slapos"}
- { role: "install-script", channel: "slapos_testing", playbook_yml: "test-suite.yml", script_path: "install/testing/test-suite"}
- { role: "install-script", channel: "slapos_testing", playbook_yml: "webrunner-standalone.yml", script_path: "install/testing/webrunner-standalone"}
- { role: "install-script", channel: "slapos_testing", playbook_yml: "slapos-master-standalone.yml", script_path: "install/testing/slapos-master-standalone"}
- { role: "install-script", channel: "unstable", playbook_yml: "imt-server-update.yml", script_path: "install/unstable/imt/slapos-update"}
- { role: "install-script", channel: "unstable", playbook_yml: "imt-server.yml", script_path: "install/unstable/imt/slapos"}
- { role: "install-script", channel: "unstable", playbook_yml: "imt-vm-bootstrap.yml", script_path: "install/unstable/imt/vm-bootstrap"}
- { role: "install-script", channel: "unstable", playbook_yml: "imt-vm-bootstrap.yml", script_path: "install/imt-dev-bootstrap"}
- { role: "install-script", channel: "unstable", playbook_yml: "imt-vm-cloudera-manager.yml", script_path: "install/unstable/imt/vm-cloudera-manager"}
- { role: "install-script", channel: "unstable", playbook_yml: "imt-re6stnet.yml", script_path: "install/unstable/imt/re6st"}
- { role: "install-script", channel: "unstable", playbook_yml: "test-suite.yml", script_path: "install/unstable/test-suite"}
The installation scripts are splited on 4 diferent keys or channels:
- `slapos-global-key` Fully stable playbook, Dedicated to KVM cluster autosetup images and
computers who host KVM clusters on IMT infraestructure.
- `slapos-global-unstable-key` Unstable or Development playbook alternative for
slapos-global-key.
- `slapos-global-vifib-official-key` Official VIFIB and Grandenet Stable Playbook, it include
either stable versions of the Cluster/Standalone servers.
- `slapos-global-vifib-testing-key` Testing Playbook VIFIB and Grandenet Stable Playbook, it
include unstable (or more recently versions) of the Cluster/Standalone servers.
Developers channels (or keys) are not included on this list, only official ones.
This diff is collapsed.
<html>
<head>
<meta http-equiv="refresh" content="0; url=http://deploy.erp5.cn/" />
<title></tile>
</head>
<body>
Redirectng to https://deploy.erp5.cn/
</body>
</html>
/bin/cat << EOF > $ANSIBLE_PLUGIN_LOCATION/log_parse.py
import os
import time
import json
import ansible
baseModule = object
ANSIBLE_VERSION = 1
if hasattr(ansible, 'plugins') and hasattr(ansible.plugins, 'callback'):
baseModule = ansible.plugins.callback.CallbackBase
ANSIBLE_VERSION = 2
class CallbackModule(baseModule):
"""
logs playbook results, per host, in /var/log/ansible/hosts
"""
log_path = '/var/log/ansible/hosts'
fd_list = {}
def __init__(self):
if ANSIBLE_VERSION > 1:
super(CallbackModule, self).__init__()
if not os.path.exists(self.log_path):
os.makedirs(self.log_path)
else:
for filename in os.listdir(self.log_path):
filepath = os.path.join(self.log_path, filename)
if os.path.exists(filepath) and os.path.isfile(filepath):
os.unlink(filepath)
def writeLog(self, host, category, content):
if not self.fd_list.has_key(category):
self.fd_list[category] = open(
os.path.join(self.log_path, '%s_%s' % (host, category)), "a"
)
self.fd_list[category].write(content + '\n')
def log(self, host, category, data, ignore_errors=False):
if host == "localhost":
host = "127.0.0.1" # keep compatibility
if type(data) == dict:
if '_ansible_verbose_override' in data:
# avoid logging extraneous data
return
data = data.copy()
content = json.dumps(data)
if ignore_errors:
category = '%s_IGNORED' % category
self.writeLog(host, category, content)
def _stats(self, stats):
for key in self.fd_list:
self.fd_list[key].close()
def runner_on_failed(self, host, res, ignore_errors=False):
self.log(host, 'FAILED', res, ignore_errors)
def runner_on_ok(self, host, res):
self.log(host, 'OK', res)
def runner_on_skipped(self, host, item=None):
pass
def runner_on_unreachable(self, host, res):
self.log(host, 'UNREACHABLE', res)
def runner_on_async_failed(self, host, res, jid):
self.log(host, 'ASYNC_FAILED', res)
def playbook_on_import_for_host(self, host, imported_file):
self.log(host, 'IMPORTED', imported_file)
def playbook_on_not_import_for_host(self, host, missing_file):
self.log(host, 'NOTIMPORTED', missing_file)
def playbook_on_stats(self, stats):
self._stats(stats)
EOF
<html>
<head>
<title></tile>
</head>
<body>
<h1> Quick Installation Scripts for Nexedi's Related Open Source Projects </h1>
<p> Please use the full url for download the right script... </p>
</body>
</html>
# Check if playbook has been correctly extracted
ANSIBLE_CRON_FILE="/etc/cron.d/ansible-vm-bootstrap"
COUNT=$(ls /opt/slapos.playbook | wc -l)
if [[ ! $COUNT -gt 1 ]]
then
rm -f $ANSIBLE_CRON_FILE
rm -f /opt/slapos.playbook/playbook.tar.gz
exit 1
fi
# check if Ansible cron task was added
if [[ ! -s "$ANSIBLE_CRON_FILE" ]]
then
exit 1
fi
exit 0
# Configure network interface
rm -rf /tmp/dropcmd
wget -O /etc/opt/netconfigure http://10.0.2.100/netconfig.sh
wget -O /tmp/dropcmd -q http://10.0.2.100/delDefaultIface
if [[ -s "/tmp/dropcmd" ]]
then
echo "nameserver 8.8.8.8" > /etc/resolv.conf
/sbin/ip route del default
fi
bash /etc/opt/netconfigure
---
- name: generate scripts
template: src=install.j2 dest={{ base_path }}/{{ script_path }} mode=0666
when: channel == "stable"
- name: generate scripts
template: src=vm_bootstrap.j2 dest={{ base_path }}/{{ script_path }} mode=0666
when: channel == "stable2" and "generic-vm-bootstrap" in script_path
- name: generate scripts
template: src=install_unstable.j2 dest={{ base_path }}/{{ script_path }} mode=0666
when: channel == "unstable"
- name: generate scripts
template: src=vm_bootstrap_unstable.j2 dest={{ base_path }}/{{ script_path }} mode=0666
when: channel == "unstable" and "vm-bootstrap" in script_path
- name: generate scripts
template: src=install_slapos.j2 dest={{ base_path }}/{{ script_path }} mode=0666
when: channel == "slapos"
- name: generate scripts
template: src=install_slapos_testing.j2 dest={{ base_path }}/{{ script_path }} mode=0666
when: channel == "slapos_testing"
- name: Set ansible playbook on scripts
lineinfile: dest={{ base_path }}/{{ script_path }} line="ansible-playbook {{ playbook_yml }} -i hosts --connection=local" state=present insertafter="echo\s+\"Starting Ansible playbook:.*"
#!/bin/bash
#### Setup Ansible and load few libraries #####
BASE_SETUP_SCRIPT_MD5={{ base_setup.stat.md5 }}
wget --no-check-certificate https://deploy.erp5.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
{{ lookup('file', 'roles/install-script/files/function-common') }}
if [[ $EUID -gt 0 ]]; then
echo "####################################################"
echo "# #"
echo "# ERROR: You must be root to run this script!!!! #"
echo "# #"
echo "####################################################"
exit 1
fi
export PATH=$PATH:/usr/local/bin:/usr/local/sbin
# XXX a bit brutal but otherwise it cannot work, without tty enabled.
if [ -f /etc/sudoers ]; then
sed -i "/requiretty/d" /etc/sudoers
fi
# Include Additional Functions
function download_playbook {
if [ ! -f /etc/opt/slapcache.cfg ]; then
slapcache-conf
fi
DFILE="/tmp/tmpplaybook$(basename $0).$$/"
TFILE="archive.tar.gz"
mkdir -p $DFILE
cd $DFILE
slapcache-download --destination=$TFILE
tar -xzvf $TFILE
rm $TFILE
}
# Determine what system we are running on. This provides ``os_VENDOR``,
# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME``
# and ``DISTRO``
GetDistro
if [[ ${DISTRO} =~ (-.) ]] && [[ -f /etc/debian_version ]]; then
apt_get install lsb-release
GetDistro
fi
# 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|jessie|trusty|vivid|xenial|rhel7|rhel6|LinuxMint-17.2) ]]; 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
fi
# Make sure wheezy backports are available.
if [[ $DISTRO == "wheezy" ]]; then
echo "deb http://ftp.debian.org/debian wheezy-backports main contrib " > /etc/apt/sources.list.d/wheezy-backports.list
fi
if is_fedora && [[ $DISTRO == "rhel7" ]]; then
# RHEL requires EPEL for many Ansible 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
yum update -y
yum_install yum-utils
# 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
if is_fedora && [[ $DISTRO == "rhel6" ]]; then
sed -i "/requiretty/d" /etc/sudoers
if sudo yum repolist enabled epel | grep -q 'epel'; then
uninstall_package epel-release || true
fi
cat <<EOF | sudo tee /etc/yum.repos.d/epel-bootstrap.repo
[epel-bootstrap]
name=Bootstrap EPEL
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-6&arch=\$basearch
failovermethod=priority
enabled=0
gpgcheck=0
EOF
yum update -y
yum_install yum-utils
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
is_package_installed yum-utils || install_package yum-utils
yum-config-manager --enable rhel-6-server-optional-rpms
is_package_installed libselinux-python || install_package libselinux-python
fi
is_package_installed openssl || install_package openssl
# stick to a specific ansible package version
if is_ubuntu; then
# is_ubuntu also handle debian distro
is_package_installed ansible || install_package ansible=1.*
elif is_fedora; then
# is_fedora also handle CentOS distro
is_package_installed ansible || install_package ansible1.9.noarch
else
is_package_installed ansible || install_package ansible
fi
is_package_installed python-setuptools || install_package python-setuptools
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
if is_ubuntu && [[ $DISTRO == "vivid" ]]; then
is_package_installed python-apt || install_package python-apt
is_package_installed python-pycurl || install_package python-pycurl
fi
if [[ $DISTRO == "LinuxMint-17.2" ]]; then
is_package_installed python-apt || install_package python-apt
is_package_installed python-pycurl || install_package python-pycurl
fi
ANSIBLE_PLUGIN_LOCATION="/usr/share/ansible_plugins/callback_plugins/"
mkdir -p $ANSIBLE_PLUGIN_LOCATION
{{ lookup('file', 'roles/install-script/files/log_parse') }}
ansible localhost -m easy_install -a name=slapcache --connection=local
ansible localhost -m easy_install -a name=requests --connection=local
#!/bin/bash
set -e
#
# Paste content of function-common
# https://lab.nexedi.com/nexedi/slapos.package/blob/master/playbook/roles/install-script/files/function-common
#
{{ lookup('file', base_path+'/install/base-setup') }}
#### Setup Ansible and load few libraries #####
PLAYBOOK_REPOSITORY_URL=https://lab.nexedi.com/nexedi/slapos.package.git
is_package_installed git || install_package git
git clone $PLAYBOOK_REPOSITORY_URL
#!/bin/bash
set -e
#
# Paste content of function-common
# https://lab.nexedi.com/nexedi/slapos.package/blob/master/playbook/roles/install-script/files/function-common
#
{{ lookup('file', base_path+'/install/base-setup') }}
download_playbook
clear
echo "Starting Ansible playbook:"
#!/bin/bash
set -e
#
# Paste content of function-common
# https://lab.nexedi.com/nexedi/slapos.package/blob/master/playbook/roles/install-script/files/function-common
#
{{ lookup('file', base_path+'/install/base-setup') }}
# Include Additional Functions
if [ ! -f /etc/opt/slapcache.cfg ]; then
slapcache-conf
fi
sed -i "s/key = slapos-global-key/key = slapos-global-official-vifib-key/g" /etc/opt/slapcache.cfg
DFILE="/tmp/tmpplaybook_unstable$(basename $0).$$/"
TFILE="archive.tar.gz"
mkdir -p $DFILE
cd $DFILE
slapcache-download --destination=$TFILE
tar -xzvf $TFILE
rm $TFILE
clear
echo "Starting Ansible playbook:"
#!/bin/bash
set -e
#
# Paste content of function-common
# https://lab.nexedi.com/nexedi/slapos.package/blob/master/playbook/roles/install-script/files/function-common
#
{{ lookup('file', base_path+'/install/base-setup') }}
# Include Additional Functions
if [ ! -f /etc/opt/slapcache.cfg ]; then
slapcache-conf
fi
sed -i "s/key = slapos-global-key/key = slapos-global-official-vifib-testing-key/g" /etc/opt/slapcache.cfg
DFILE="/tmp/tmpplaybook_unstable$(basename $0).$$/"
TFILE="archive.tar.gz"
mkdir -p $DFILE
cd $DFILE
slapcache-download --destination=$TFILE
tar -xzvf $TFILE
rm $TFILE
clear
echo "Starting Ansible playbook:"
#!/bin/bash
set -e
#
# Paste content of function-common
# https://lab.nexedi.com/nexedi/slapos.package/blob/master/playbook/roles/install-script/files/function-common
#
{{ lookup('file', base_path+'/install/base-setup') }}
# Include Additional Functions
if [ ! -f /etc/opt/slapcache.cfg ]; then
slapcache-conf
fi
sed -i "s/key = slapos-global-key/key = slapos-global-unstable-key/g" /etc/opt/slapcache.cfg
DFILE="/tmp/tmpplaybook_unstable$(basename $0).$$/"
TFILE="archive.tar.gz"
mkdir -p $DFILE
cd $DFILE
slapcache-download --destination=$TFILE
tar -xzvf $TFILE
rm $TFILE
clear
echo "Starting Ansible playbook:"
#!/bin/bash
{{ lookup('file', base_path+'/roles/install-script/files/vm_bootstrap_network') }}
set -e
### Include Bootstrap VM script
### Contain function-common
## https://lab.nexedi.com/nexedi/slapos.package/blob/master/playbook/roles/install-script/files/function-common
{{ lookup('file', base_path+'/install/base-setup') }}
download_playbook
clear
echo "Starting Ansible playbook:"
{{ lookup('file', base_path+'/roles/install-script/files/vm_bootstrap_check') }}
#!/bin/bash
{{ lookup('file', base_path+'/roles/install-script/files/vm_bootstrap_network') }}
set -e
#
# Paste content of function-common
# https://lab.nexedi.com/nexedi/slapos.package/blob/master/playbook/roles/install-script/files/function-common
#
{{ lookup('file', base_path+'/install/base-setup') }}
# Include Additional Functions
if [ ! -f /etc/opt/slapcache.cfg ]; then
slapcache-conf
fi
sed -i "s/key = slapos-global-key/key = slapos-global-unstable-key/g" /etc/opt/slapcache.cfg
DFILE="/tmp/tmpplaybook_unstable$(basename $0).$$/"
TFILE="archive.tar.gz"
mkdir -p $DFILE
cd $DFILE
slapcache-download --destination=$TFILE
tar -xzvf $TFILE
rm $TFILE
clear
echo "Starting Ansible playbook:"
{{ lookup('file', base_path+'/roles/install-script/files/vm_bootstrap_check') }}
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