Commit a85fd1a1 authored by Rafael Monnerat's avatar Rafael Monnerat

slapprepare: Removed Slapprepare from this repository

 If still required, slapprepare is present on several tags.
parent 815699aa
Changes
=======
1.2.3 (2013-04-24)
------------------
Fixes:
* Remove the "is it a VM" question, misleading and blocking. This allows to have a second disk (or... a VM) inside of your VM.
1.2.2 (2013-04-24)
------------------
Fixes:
* Correctly chown() SlapOS directories: don't try to chown links.
1.2.1 (2013-04-16)
------------------
Fixes:
* Start VPN if required before registering to SlapOS Master.
1.2.0 (2013-04-16)
------------------
Note: it is no longer possible to run slapprepare without either registering Node or having an existing Node configuration.
New features:
* Add support for any SlapOS Master, not only slapos.org
Fixes:
* Don't force install slapos if already installed.
* Only ask bridge question if it is not a VM.
1.1.2 (2013-04-15)
------------------
Fix:
* Don't raise if impossible to find slapos configuration while trying to setup bridge (bug introduced in 1.0).
1.1.1 (2013-04-15)
------------------
This is a re-release of 1.1.0, including correct "iniparse" dependency.
1.1.0 (2013-04-12)
------------------
New features:
* Will autoreboot after two minutes in case of a kernel panic.
* Ask if machine will host VMs.
1.0.0 (2013-03-07)
------------------
Initial stable release!
New features:
* Chown all files in software root and instance root when doing slapprepare.
It allows easier USB key replacement.
* Completely disable root password. Won't create random password.
1.0a7 (2013-01-24)
------------------
* Fixed a bug where the hostname would contain a newline.
1.0a6 (2013-01-15)
------------------
* Machine tweaks: raise max AIO NR and nofile, set semaphore limits. This
allows to run many instances of apache/mysql/zope on the same machine.
* Mount /var/log on disk in order not to touch USB key.
* When running slapupdate, will update slapprepare as well.
* update crontab so that it calls slapupdate randomly. It means: not all
nodes in the same timezone will try to update at the same time (thus not
kill cache system).
1.0a5 (2013-01-07)
------------------
* autoupdate through easy_install before running slapprepare
* Force start of VPN if defined
* Add limits.conf file preventing fork bombs and ensuring root can spawn lot
of processes
1.0a4 (2012-11-22)
------------------
* Re-release previous version with correct changes.
1.0a3 (2012-11-13)
------------------
* Minor release: doesn't show scary error when modprobe of some monitoring
module can't be done. [Cédric de Saint Martin]
* Change references of VIFIB to slapos.org.
1.0a2 (2012-11-12)
------------------
* Don't crash when we don't want to create slapos.cfg file. [Cédric de Saint
Martin]
1.0a1 (2012-10-30)
------------------
* Initial release on Pypi.
recursive-include slapprepare/template *.in
include slapprepare/script/slapos
include slapprepare/script/slapos_firstboot
include slapprepare/script/slapos.service
include slapprepare/script/run_slapformat
include CHANGES.txt
slapprepare
***********
Slapprepare is the script responsible of preparing an openSUSE computer to run slapos as a dedicated machine.
Process
-------------------------------------------
1. Will parse option and set basic parameters
2. Add slapos repositories with zypper
3. Install latest version of slapos but will deactivate slapos-node service
(Wait till everything is ready)
4. If option --update (-u) is given, it will skip the initial configuration step (disk formatting, etc)
5. Will ask a few questions:
* "Automatically register new computer to Vifib?" (Default is yes)
is yes choosen two more question will follow:
* "Define a unique name for this computer:"
* "Number of SlapOS partitions for this computer? Default is 20 :"
* "Is this a virtual Machine?" (Default is False)
* If not a virtual machine:
* "Do you want to use SlapOS with a second disk?" (Default is True)
If True selected the script slapos_firstboot will be run searching
for second a second disk.
* "Do you want to use vpn to provide ipv6?" (Default is Yes)
If False selected will remove openvpn-needed file in config directory
* "Do you want to force the use lxc on this computer?" (Default is No)
If Yes choosen will run "# touch /etc/opt/slapos/SlapContainer-needed"
* "Do you want a remote ssh access?" (Default is Yes)
If yes is choosen, will later ask for a web address
to download user' public ssh key and put it in root authorized_keys
6. If automatically register to vifib was choosen, it will run slapos node register which prepare slapos configuration
7. Display computer's reference ("Your Computer is : COMP-1234")
8. If remote ssh access was choosen will ask for public key address and download it.
9. Will prepare computer:
* Setting hostname
* Adding the hostname as a valid address
* Creating safe sshd_config
* Creating default bridge config
* If remote ssh: Writing ssh key
* Adding slapos_firstboot in case of MultiDisk usage
10. If multi-disk usage it will run slapos_firstboot and reinstall slapos
11. It will install boot script that are not included in package
* Boot script in "/usr/sbin/slapos-boot-dedicated" and its associated service in:
"/etc/systemd/system/slapos-boot-dedicated.service"
* clientipv4 (openvpn conf)
* Remove script form older versions of slapprepare
12. Configure NTP daemon
13. Will enable an start slapos-boot-dedicated service
About slapos-boot-dedicated
-------------------------------------------
It is in slapprepare/script/slapos
Process
+++++++
1. Deactivate slapos-node.service (daemon from package) to prepare quietly
2. Check ipv4-ipv6 and start openvpn if needed or asked
3. Reset root password
4. Check if slapos is installed (if not reinstall it)
5. Create PKI repository
6. If slapos.cfg is not in /etc/opt/slapos/ it correct path in package
script and cron file
7. Set dedicated cron file "/etc/cron.d/slapos"
- If SlapContainer-needed file in configuration directory will add a line to use it
8. Set various parameters to improve running performance of slapos
How to update you old Suse Image (Suse 12.1 or sooner)
------------------------------------------------------
Run this whole command as root:
# wget zypper remove -y slapos.node; rm -f /etc/opt/slapos/slapos.node*.rpm; easy_install slapparepare && slapprepare -u ;
Check your config
-------------------------------------------
Check your config file and your cron file
+++++++++++++++++++++++++++++++++++++++++
You can use the slapos.cfg.example config file as reference for slapos.cfg.
http://git.erp5.org/gitweb/slapos.core.git/blob_plain/HEAD:/slapos.cfg.example
Check dedicated cron file
+++++++++++++++++++++++++
::
# less /etc/cron.d/slapos
It should contain a call to slapupdate
Check your configuration directory
++++++++++++++++++++++++++++++++++
::
# ls /etc/opt/slapos/
It should only contain your slapos configuration files and \*-needed files
Configure your machine:
-------------------------------------------
LXC
++++
If you want to run lxc on you machine run these command:
# touch /etc/opt/slapos/SlapContainer-needed ; systemctl restart slapos-boot-dedicated.service
from setuptools import setup
version = '1.2.1'
name = 'slapprepare'
long_description = open("README.txt").read() + "\n" + \
open("CHANGES.txt").read() + "\n"
setup(name=name,
version=version,
description="SlapOS Setup kit for dedicated SuSE machines.",
long_description=long_description,
classifiers=[
"Programming Language :: Python",
],
keywords='slapos Setup Kit',
license='GPLv3',
url='http://www.slapos.org',
author='VIFIB',
packages=['slapprepare'],
include_package_data=True,
install_requires=[
'slapos.libnetworkcache',
'iniparse',
],
zip_safe=False,
entry_points={
'console_scripts': [
'slapprepare = slapprepare.autoupdate:main',
'slapprepare-raw = slapprepare.slapprepare:main',
'slapupdate = slapprepare.slapupdate:main',
]
},
)
# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
try:
__import__('pkg_resources').declare_namespace(__name__)
except ImportError:
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
import os
import subprocess
import sys
def do_update():
print 'Updating slapprepare'
subprocess.call(['easy_install', '-U', 'slapprepare'])
def main():
if '--no-update' in sys.argv:
sys.argv.remove('--no-update')
else:
do_update()
args = [
os.path.join(os.path.dirname(sys.argv[0]), 'slapprepare-raw')
] + sys.argv[1:]
subprocess.call(args)
#!/bin/sh
sleep 15
SLAPOS_CONFIGURATION='%(slapos_configuration)s'
i=0
false
while [[ $? != 0 ]]; do
sleep $(($i*60))
if [[ $i < 20 ]]; then
let i++
fi
echo "Retrying slapformat"
/opt/slapos/bin/slapformat --verbose --console $SLAPOS_CONFIGURATION/slapos.cfg
done
\ No newline at end of file
#!/bin/sh
##############################################################################
#
# Copyright (c) 2010 Vifib SARL and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly advised to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
systemctl stop slapos-node.service
systemctl disable slapos-node.service
# clean the system
for service in rpcbind network-remotefs postfix ; do
chkconfig --del $service
/etc/init.d/$service stop
done
IPV6CHECK=ipv6.google.com
IPV4CHECK=google.com
IPV6WAITTIME=5
SLAPOS_CONFIGURATION='%(slapos_configuration)s'
ping -c 2 $IPV4CHECK
while [ $? != 0 ]; do
sleep 5
ping -c 2 $IPV4CHECK
done
echo """Ipv4 connection ok"""
# Wait for native ipv6 connection to be ready
i=0
ping6 -c 2 $IPV6CHECK
while [[ $? != 0 ]] && [[ $i < $IPV6WAITTIME ]]
do
let i++
sleep 1
ping6 -c 2 $IPV6CHECK
done
SLAP_INSTALL_LOG=/opt/slapos/slapos-install.log
while :; do
if [ -f /opt/slapos/bin/slapformat ] && [ -f /opt/slapos/bin/bang ]; then
zypper search -i slapos.node | grep slapos.node > /dev/null
if [ $? != 0 ]; then
echo -n "Installing SlapOS"
zypper --gpg-auto-import-keys install -fy slapos.node
fi
# slapos tools available, nothing to do
break
fi
# software not detected, force forever installation
echo -n "Installing SlapOS"
zypper --gpg-auto-import-keys install -fy slapos.node
done
# Create PKI repository
repo=`egrep ^certificate_repository_path $SLAPOS_CONFIGURATION/slapos.cfg | sed 's/^certificate_repository_path.*= *//'`
mkdir -v -p -m 0755 $repo
# Fix path in case of old config:
SLAPOS_GOOD_CONFIGURATION=/etc/opt/slapos/
if [ $SLAPOS_GOOD_CONFIGURATION != $SLAPOS_CONFIGURATION ]; then
sed -i "s|$SLAPOS_GOOD_CONFIGURATION|$SLAPOS_CONFIGURATION|g" /etc/cron.d/slapos-node
sed -i "s|$SLAPOS_GOOD_CONFIGURATION|$SLAPOS_CONFIGURATION|g" /usr/sbin/slapos-start
fi
# Set up cron
let HOUR=$RANDOM%%23;
let MINUTE=$RANDOM%%60;
echo """# BEWARE: This file will be automatically regenerated on each boot
SHELL=/bin/sh
PATH=/usr/bin:/usr/sbin:/sbin:/bin:/usr/lib/news/bin
MAILTO=""
$MINUTE $HOUR * * * root /usr/local/bin/slapupdate -v --slapos-configuration $SLAPOS_CONFIGURATION/slapos.cfg >> /opt/slapos/slapupdate.log 2>&1
"""> /etc/cron.d/slapos
if [ -f ${SLAPOS_CONFIGURATION}/SlapContainer-needed ]; then
echo """
# XXX: SlapContainer
*/5 * * * * root if [ -x /opt/slapgrid/843c2b4de8c5579427b072d00ec2ec9e/bin/slapcontainer ] ; then /opt/slapgrid/843c2b4de8c5579427b072d00ec2ec9e/bin/slapcontainer --pid /opt/slapos/slapcontainer.pid ${SLAPOS_CONFIGURATION}slapos.cfg /opt/slapos/slapcontainer.db > /opt/slapos/slapcontainer.log 2>&1 ; fi
""" >> /etc/cron.d/slapos
fi
# Setup more server like network parameters in order to avoid
# "Neighbour table overflow."
# Those machines are itself has a lot of interfaces and are in
# heavily networked environment, so limit of ARP cache for IPv4
# and IPv6 is 4x higher then default
# More tuning can be applied from: http://www.enigma.id.au/linux_tuning.txt
sysctl -w \
net.ipv4.neigh.default.gc_thresh1=512 \
net.ipv4.neigh.default.gc_thresh2=1024 \
net.ipv4.neigh.default.gc_thresh3=2048 \
net.ipv6.neigh.default.gc_thresh1=512 \
net.ipv6.neigh.default.gc_thresh2=1024 \
net.ipv6.neigh.default.gc_thresh3=2048
# software detected, ready to run
systemctl enable slapos-node.service
systemctl start slapos-node.service
# Increase default aio-max-nr for sql servers
sysctl -w fs.aio-max-nr=16777216
# Increase semaphore limits
sysctl -w kernel.sem="1250 256000 100 1024"
# Force reboot after kernel panic
sysctl -w kernel.panic=120
# Enable noop scheduler for disk which have SLAPOS labeled partition
disk=`blkid -L SLAPOS | sed -r -e 's/(\/dev\/|[0-9]*$)//g'`
echo noop > /sys/block/$disk/queue/scheduler
# Set kvm up
modprobe kvm_intel
sleep 1
chmod 666 /dev/kvm
# Set power saving
modprobe acpi_cpufreq > /dev/null 2>&1
# Set hardware monitoring tools (for Shuttle xh61 machines)
modprobe coretemp > /dev/null 2>&1
modprobe f71882fg > /dev/null 2>&1
# Activate KSM (shared memory for KVM)
echo 1 > /sys/kernel/mm/ksm/run
[Unit]
Description=SlapOs Boot script
Requires=basic.target
Wants=network.target remote-fs.target
After=basic.target network.target remote-fs.target
Before=slapos-node.service
[Service]
Type=simple
ExecStart=/usr/sbin/slapos-boot-dedicated
StandardOutput=tty
TTYPath=/dev/console
[Install]
WantedBy=multi-user.target
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#
# hosts This file describes a number of hostname-to-address
# mappings for the TCP/IP subsystem. It is mostly
# used at boot time, when no name servers are running.
# On small systems, this file can be used instead of a
# "named" name server.
# Syntax:
#
# IP-Address Full-Qualified-Hostname Short-Hostname
#
127.0.0.1 %(computer_id)s localhost
# special IPv6 addresses
::1 %(computer_id)s localhost ipv6-localhost ipv6-loopback
fe00::0 ipv6-localnet
ff00::0 ipv6-mcastprefix
ff02::1 ipv6-allnodes
ff02::2 ipv6-allrouters
ff02::3 ipv6-allhosts
BOOTPROTO='dhcp'
BRIDGE='yes'
BRIDGE_FORWARDDELAY='0'
BRIDGE_PORTS='eth0'
BRIDGE_STP='off'
BROADCAST=''
ETHTOOL_OPTIONS=''
IPADDR=''
MTU=''
NAME=''
NETMASK=''
NETWORK=''
REMOTE_IPADDR=''
STARTMODE='auto'
USERCONTROL='no'
* hard nproc 8096
* soft nproc 1024
* hard nofile 32768
* soft nofile 32768
root hard nofile 65535
root soft nofile 65535
PermitRootLogin without-password
AllowUsers root
AddressFamily any
RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile %h/.ssh/authorized_keys
# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no
PasswordAuthentication no
X11Forwarding yes
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL
Subsystem sftp /usr/lib64/ssh/sftp-server
UsePAM yes
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