Commit 176b7420 authored by Rafael Monnerat's avatar Rafael Monnerat

Added first official ansible playbooks for slapos.

parent 39e07b73
- name: a play that runs entirely on the ansible host
hosts: 127.0.0.1
connection: local
roles:
- erp5-standalone
- name: a play that runs entirely on the ansible host
hosts: 127.0.0.1
connection: local
vars_files:
- settings/gnet.yml
vars_prompt:
- name: "re6sttoken"
prompt: "If you have re6st token if you have (ignore if you already have a configured re6st):"
private: no
default: "notoken"
- name: "computer_name"
prompt: "What is this computer name? (ignore if you already have a configured re6st):"
private: no
default: "noname"
roles:
- re6stnet
- { role: package, package_name: ntp, package_state: present }
- name: a play that runs entirely on the ansible host
hosts: 127.0.0.1
connection: local
vars_files:
- settings/gnet.yml
vars_prompt:
- name: "re6sttoken"
prompt: "If you have re6st token if you have (ignore if you already have a configured re6st):"
private: no
default: "notoken"
- name: "computer_name"
prompt: "What is this computer name? (ignore if you already have a configured re6st and slapos):"
private: no
default: "noname"
- name: "slapostoken"
prompt: "If you have slapos token if you have (ignore if you already have a configured slapos):"
private: no
default: "notoken"
roles:
- re6stnet
- slapos
- { role: package, package_name: ntp, package_state: present }
---
base_open_build_url: http://download.opensuse.org/repositories/home:/VIFIBnexedi/
is_ubuntu: "'{{ ansible_distribution }}' == 'Ubuntu'"
is_debian: "'{{ ansible_distribution }}' == 'Debian'"
is_debian_or_ubuntu: "'{{ ansible_distribution }}' in ['Ubuntu', 'Debian']"
is_centos: "'{{ ansible_distribution }}' == 'CentOS'"
is_ubuntu_precise: "{{ is_ubuntu }} and '{{ ansible_distribution_release }}' == 'precise'"
is_ubuntu_raring: "{{ is_ubuntu }} and '{{ ansible_distribution_release }}' == 'raring'"
is_ubuntu_trusty: "{{ is_ubuntu }} and '{{ ansible_distribution_release }}' == 'trusty'"
is_redhat: "{{ ansible_os_family }} == 'RedHat'"
[targets]
localhost ansible_connection=local
- name: a play that runs entirely on the ansible host
hosts: 127.0.0.1
connection: local
vars_files:
- settings/imt.yml
vars_prompt:
- name: "re6sttoken"
prompt: "If you have re6st token if you have (ignore if you already have a configured re6st running):"
private: no
default: "notoken"
- name: "computer_name"
prompt: "What is this computer name? (ignore if you already have a configured re6st running):"
private: no
default: "noname"
roles:
- re6stnet
- name: a play that runs entirely on the ansible host
hosts: 127.0.0.1
connection: local
roles:
- { role: package, package_name: ntp, package_state: latest }
- { role: package, package_name: re6st-node, package_state: latest }
- { role: package, package_name: slapos-node, package_state: latest }
- name: a play that runs entirely on the ansible host
hosts: 127.0.0.1
connection: local
vars_files:
- settings/imt.yml
vars_prompt:
- name: "re6sttoken"
prompt: "If you have re6st token if you have (ignore if you already have a configured re6st):"
private: no
default: "notoken"
- name: "computer_name"
prompt: "What is this computer name? (ignore if you already have a configured re6st and slapos):"
private: no
default: "noname"
- name: "slapostoken"
prompt: "If you have slapos token if you have (ignore if you already have a configured slapos):"
private: no
default: "notoken"
roles:
- re6stnet
- slapos
- { role: package, package_name: ntp, package_state: present }
- name: a play that runs entirely on the ansible host
hosts: 127.0.0.1
connection: local
roles:
- vm-bootstrap
- ntp
- { role: vm-disks, vd_disk: b, data_n: 1 }
- { role: vm-disks, vd_disk: c, data_n: 2 }
- { role: vm-disks, vd_disk: d, data_n: 3 }
- { role: vm-disks, vd_disk: e, data_n: 4 }
- { role: vm-disks, vd_disk: f, data_n: 5 }
- { role: vm-disks, vd_disk: g, data_n: 6 }
- { role: vm-disks, vd_disk: h, data_n: 7 }
- { role: vm-disks, vd_disk: i, data_n: 8 }
- { role: vm-disks, vd_disk: j, data_n: 9 }
- { role: vm-disks, vd_disk: k, data_n: 10 }
- { role: vm-disks, vd_disk: l, data_n: 11 }
- { role: vm-disks, vd_disk: m, data_n: 12 }
- { role: vm-disks, vd_disk: n, data_n: 12 }
- { role: vm-disks, vd_disk: o, data_n: 12 }
- { role: vm-disks, vd_disk: p, data_n: 12 }
- { role: vm-disks, vd_disk: q, data_n: 12 }
- { role: vm-disks, vd_disk: r, data_n: 12 }
- { role: vm-disks, vd_disk: s, data_n: 12 }
- { role: vm-disks, vd_disk: t, data_n: 12 }
- { role: vm-disks, vd_disk: u, data_n: 12 }
- name: a play that runs entirely on the ansible host
hosts: 127.0.0.1
connection: local
roles:
- vm-bootstrap
- ntp
- vm-cloudera-manager
- name: a play that runs entirely on the ansible host
hosts: 127.0.0.1
connection: local
vars:
- playbook_file: https://lab.nexedi.cn/rafael/slapos.playbook/repository/archive.tar.gz?ref=master
- base_path: .
pre_tasks:
- name: Create script structure
command: mkdir -p {{ base_path }}/{{ item }}
with_items:
- install/gnet/
- install/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
roles:
- { role: "install-script", playbook_yml: "slapos.yml", script_path: "install/slapos" }
- { role: "install-script", playbook_yml: "re6stnet.yml", script_path: "install/re6st"}
- { role: "install-script", playbook_yml: "vifib.yml", script_path: "install/vifib"}
- { role: "install-script", playbook_yml: "erp5-standalone.yml", script_path: "install/erp5-standalone"}
- { role: "install-script", playbook_yml: "slapos-test-node.yml", script_path: "install/slapos-test-node"}
- { role: "install-script", playbook_yml: "gnet-re6stnet.yml", script_path: "install/gnet/re6st"}
- { role: "install-script", playbook_yml: "gnet-server.yml", script_path: "install/gnet/slapos"}
- { role: "install-script", playbook_yml: "imt-server-update.yml", script_path: "install/imt/slapos-update"}
- { role: "install-script", playbook_yml: "imt-server.yml", script_path: "install/imt/slapos"}
- { role: "install-script", playbook_yml: "imt-vm-bootstrap.yml", script_path: "install/imt/vm-bootstrap"}
- { role: "install-script", playbook_yml: "imt-vm-cloudera-manager.yml", script_path: "install/imt/vm-cloudera-manager"}
- { role: "install-script", playbook_yml: "imt-re6stnet.yml", script_path: "install/imt/re6st"}
- name: a play that runs entirely on the ansible host
hosts: 127.0.0.1
connection: local
vars_files:
- settings/vifib.yml
vars_prompt:
- name: "computer_name"
prompt: "What is this computer name? (ignore if you already have a configured re6st and slapos):"
private: no
default: "noname"
roles:
- re6stnet-legacy
- { role: package, package_name: ntp, package_state: present }
#!/usr/bin/python2.7
import os
import sys
import subprocess
import glob
import time
import getopt
import sqlite3
from xml.dom import minidom
#from slapos.proxy.db_version import DB_VERSION
import json
def fmt_date():
return time.strftime("%Y%m%d")
def get_connection_information():
conn = sqlite3.connect("/opt/slapos/slapproxy.db")
cur = conn.cursor()
qry = cur.execute("SELECT connection_xml FROM partition11 WHERE connection_xml IS NOT NULL AND software_type='create-erp5-site'")
for row in qry:
xml = str(row[0])
break
instance = minidom.parseString(xml)
try:
el = instance.getElementsByTagName('parameter')[0]
value = el.childNodes[0].nodeValue
json_text = json.loads(value)
return (json_text['family-admin'], json_text['inituser-password'])
except Exception, e:
print e
print "empty"
return (None, None)
def check_tables():
conn = sqlite3.connect("/opt/slapos/slapproxy.db")
cur = conn.cursor()
qry = cur.execut("SELECT CASE WHEN tbl_name = 'partition11' THEN 1 ELSE 0 END FROM sqlite_master WHERE tbl_name = 'partition11' AND type = 'table'")
if qry:
pass
else:
print "tables aren't ready yet, your build may have failed, check logs in /opt/slapos/log/"
sys.exit(0)
def get_build_status():
try:
f = open("/opt/slapos/log/slapos-node-software-" + fmt_date() + ".log")
except:
f = open("/opt/slapos/log/slapos-node-software.log")
lines = f.readlines()
if "Finished software releases" not in lines[-1]:
return False
if "ERROR" in lines[-3]:
return "err"
return True
# Check if the last two lines show the software finished building.
# If an error came just before this, we'll report failure.
# Otherwise it passed and we can move on.
# We want to open today's log, as it is most up to date
def status():
build = get_build_status()
if build:
zope_ip, pw = get_connection_information()
print ("Build successful, connect to:\n"
" " + zope_ip + " with\n"
" username: zope password: " + pw)
elif not build:
print "Your software is still building, be patient it can take awhile"
elif build == "err":
print "An error occurred while building, check /opt/slapos/log/slapos-node-software-" + \
fmt_date() + ".log for details"
def info():
if get_build_status():
print get_connection_information()
else:
print "Information unavailable at this time, run " + sys.argv[0] + " -s for details"
def usage():
print ("Get the status and information of your ERP5 build\n"
"Usage:")
print (" --help (-h): Print this message and exit\n"
" --status (-s): Print the status of the build\n"
" --info (-i): Print the partition tables\n"
" --dump (-d): Dump the entire database (alias for slapos proxy show)\n")
def dump():
subprocess.call(["slapos", "proxy", "show", "-u", "/opt/slapos/slapproxy.db"])
def main(argv):
# parse command line options
try:
opts, args = getopt.getopt(argv, "sihd", ["status", "info", "help", "dump"])
except getopt.error, msg:
usage()
sys.exit(2)
# process arguments
for opt, arg in opts:
if opt in ("-h", "--help"):
usage()
sys.exit()
elif opt in ("-s", "--status"):
check_tables()
status()
elif opt in ("-i", "--info"):
check_tables()
info()
elif opt in ("-d", "--dump"):
dump()
if __name__ == "__main__":
main(sys.argv[1:])
#!/bin/bash
# Reruns the ansible playbook, does nothing else
PLAYBOOK_ROOT=/opt/slapos.playbook/playbook/
PLAYBOOK_FILE=erp5-standalone.yml
cd $PLAYBOOK_ROOT # cd into the playbook directory
echo "Starting Ansible playbook:"
ansible-playbook $PLAYBOOK_FILE -i hosts --connection=local
import json
software_url = 'http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/erp5-cluster:/software/erp5/software.cfg'
# Choose a SlapOS Node
# If you are deploying SlapOS Master with Webrunner, then computer_id is 'slaprunner'
computer_id = 'local_computer'
parameter_dict = {
"timezone": "UTC",
"site-id": "erp5",
"bt5": "erp5_full_text_myisam_catalog erp5_configurator_standard",
"zope-partition-dict": {
"admin": {
"family": "admin",
"thread-amount": 4,
"port-base": 2220,
"instance-count": 1
},
"activities-node": {
"family": "activities",
"thread-amount": 4,
"instance-count": 1,
"timerserver-interval": 1,
"port-base": 2230
},
"distribution-node": {
"family": "distribution",
"thread-amount": 1,
"instance-count": 1,
"port-base": 2210,
"timerserver-interval": 1
}
}
}
# Choose a title
title = "instance-of-erp5-cluster"
request(software_url,
title,
filter_kw={'computer_guid': computer_id},
software_type='create-erp5-site',
partition_parameter_kw={
'_': json.dumps(parameter_dict, sort_keys=True, indent=2),
}
)
---
dependencies:
- slapos-proxy
---
- name: Add ipv6 to lo interface
shell: ip -6 addr add 2001::1/64 dev lo
ignore_errors: True
- name: Supply erp5 software release
shell: slapos supply http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/erp5-cluster:/software/erp5/software.cfg local_computer
- name: create partition script
copy: src=request-erp5-cluster dest=/tmp/playbook-request-erp5-cluster mode=700
- name: create erp5-show
copy: src=erp5-show dest=/usr/local/bin/erp5-show mode=755
- name: Request ERP5 Cluster
shell: cat /tmp/playbook-request-erp5-cluster | slapos console
- name: Add startup script
copy: src=erp5-startup dest=/usr/local/bin/erp5-startup mode=755
- name: Add to rc.local
lineinfile:
dest=/etc/rc.local insertbefore=BOF
line='bash /usr/local/bin/erp5-startup &'
state=present
- name: Get slapos.playbook directory name
shell: cd /tmp/tmpplaybookerp5-standalone.*/slapos.playbook.git/playbook/; echo $(pwd)/
register: tmp_dir
- name: Check if /opt/slapos.playbook already exists
stat: path=/opt/slapos.playbook/
register: playbook_state
- name: Copy slapos.playbook
copy: src={{ tmp_dir.stdout }} dest=/opt/slapos.playbook/
when: playbook_state.stat.exists == False
This diff is collapsed.
---
- name: generate scripts
template: src=install.j2 dest={{ base_path }}/{{ script_path }} mode=0666
- name: Set ansible playbook on scripts
lineinfile: dest={{ base_path }}/{{ script_path }} line="ansible-playbook {{ playbook_yml }} -i hosts --connection=local" state=present
{{ lookup('file', 'roles/install-script/files/function-common') }}
# 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
if [[ $EUID -gt 0 ]]; then
echo "####################################################"
echo "# #"
echo "# ERROR: You must be root to run this script!!!! #"
echo "# #"
echo "####################################################"
exit 1
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|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
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 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
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
ansible localhost -m easy_install -a name=slapcache
#!/bin/bash
PLAYBOOK_REPOSITORY_URL=https://lab.nexedi.cn/rafael/slapos.playbook.git
#### Setup Ansible and load few libraries #####
BASE_SETUP_SCRIPT_MD5={{ base_setup.stat.md5 }}
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
is_package_installed git || install_package git
git clone $PLAYBOOK_REPOSITORY_URL
#!/bin/bash
set -e
#### Setup Ansible and load few libraries #####
BASE_SETUP_SCRIPT_MD5={{ base_setup.stat.md5 }}
type wget >/dev/null 2>&1 || { echo >&2 "I require wget but it's not installed. Aborting."; exit 1; }
wget 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
download_playbook
clear
echo "Starting Ansible playbook:"
---
- name: restart ntpd
service: name=ntpd state=restarted
- name: Install ntp
apt: name=ntp state=latest
when: ansible_os_family == "Debian"
- name: Install ntp
yum: name=ntp state=latest
when: ansible_os_family == "RedHat"
- name: ensure ntp is runing
service: name=ntp state=running enabled=yes
---
dependencies:
- { role: repository }
- name: Install packages using apt
apt: name={{ package_name }} state={{ package_state }} update_cache=yes cache_valid_time=3600
when: ansible_os_family == "Debian"
- name: Install re6stnet on CentOS
yum: name={{ package_name }} state={{ package_state }} update_cache=yes
when: ansible_os_family == "RedHat"
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDHMFf/eh931HRskwFHRHg28Cajic6jdxVIH/gRMaxBFI+FgYOeb1ovehBa/C6vQGYqhlJf+Kuz9HsXyebVqH55yg/2BsSh6QQolgWwwwoWvTTFY2QRQwhkNSykWdHJhURNU2BGpPi0qTWnYj/jGN2hJFvOMbHtwzuMtKSLeFXh6d8A4cTWmme0FTKNqJfMYX2bOsnKWleLB25DDrs50IN2+bVThVt/70M24yervnyxhqnGpyTm9XJEI7nnLoWCK0UVr78kpQlikjSwhRggTjPRx1SrqRNNotHbbMEb5rCBTZc0s0klwKVzr77g3AOgAYRz9QM/l995Npm987AgbFuj rafael@localhost
- name: Add rafael SSH Key
authorized_key: user=root key="{{ lookup('file', 'rafael_key') }}"
- name: Add rafael SSH Key on slapos user
authorized_key: user=slapos key="{{ lookup('file', 'rafael_key') }}"
---
- name: restart re6stnet
service: name=re6stnet state=restarted
---
- name: Install GPG
command: gpg --keyserver keys.gnupg.net --recv-keys 0990BF79AC87AE42AE5329074C23BE591A716324
when: ansible_distribution == "Debian"
- name: Install Debian 7 repository key
shell: gpg --export 1A716324 | apt-key add -
when: ansible_distribution == "Debian"
- name: Install Debian 7 repository
apt_repository: repo='deb http://git.erp5.org/dist/deb ./' state=present
when: ansible_distribution == "Debian"
- name: Install re6stnet package
apt: name=babeld=1.5.1-nxd2 state=present update_cache=yes
when: ansible_distribution == "Debian"
- name: Install re6stnet package
apt: name=re6stnet state=present update_cache=yes
when: ansible_distribution == "Debian"
- name: Check if configuration exists already
stat: path=/etc/re6stnet/re6stnet.conf
register: re6stnet_conf
- name: Configure Re6st with re6st-conf
shell: "re6st-conf --registry {{ re6st_registry_url }} -r title {{ computer_name }} -d /etc/re6stnet --anonymous"
when: ansible_distribution == "Debian" and re6stnet_conf.stat.exists == False and "{{ computer_name }}" != "noname"
- name: Start re6stnet service
service: name=re6stnet state=started enabled=yes
when: ansible_distribution == "Debian" and re6stnet_conf.stat.exists == True
- name: Add table 0
lineinfile: dest=/etc/re6stnet/re6stnet.conf line="table 0"
notify:
- restart re6stnet
---
- name: restart re6stnet
service: name=re6stnet state=restarted
---
dependencies:
- { role: package, package_name: re6st-node, package_state: present }
- name: Check if configuration exists already
stat: path=/etc/re6stnet/re6stnet.conf
register: re6stnet_conf
- name: Configure Re6st with re6st-conf
shell: "re6st-conf --registry {{ re6st_registry_url }} --token {{ re6sttoken }} -r title {{ computer_name }} -d /etc/re6stnet"
when: re6stnet_conf.stat.exists == False and "{{ re6sttoken }}" != "notoken" and "{{ computer_name }}" != "noname"
- name: Start re6st-node service
service: name=re6st-node state=started enabled=yes
when: re6stnet_conf.stat.exists == True
- name: Install Debian 8 repository key
apt_key: url={{ base_open_build_url }}/Debian_8.0/Release.key state=present
when: ansible_distribution == "Debian" and ansible_distribution_major_version == "8"
- name: Install Debian 7 repository key
apt_key: url={{ base_open_build_url }}/Debian_7.0/Release.key state=present
when: ansible_distribution == "Debian" and ansible_distribution_major_version == "7"
- name: Install Debian 6 repository key
apt_key: url={{ base_open_build_url }}/Debian_6.0/Release.key state=present
when: ansible_distribution == "Debian" and ansible_distribution_major_version == "6"
- name: Install Debian 8 repository
apt_repository: repo='deb {{ base_open_build_url }}/Debian_8.0/ ./' state=present
when: ansible_distribution == "Debian" and ansible_distribution_major_version == "8"
- name: Install Debian 7 repository
apt_repository: repo='deb {{ base_open_build_url }}/Debian_7.0/ ./' state=present
when: ansible_distribution == "Debian" and ansible_distribution_major_version == "7"
- name: Install Debian 6 repository
apt_repository: repo='deb {{ base_open_build_url }}/Debian_6.0/ ./' state=present
when: ansible_distribution == "Debian" and ansible_distribution_major_version == "6"
- name: Install Ubuntu 14.04 repository key
apt_key: url={{ base_open_build_url }}/xUbuntu_14.04/Release.key state=present
when: ansible_distribution == "Ubuntu" and ansible_distribution_version == "14.04"
- name: Install Ubuntu 14.04 repository
apt_repository: repo='deb {{ base_open_build_url }}/xUbuntu_14.04/ ./' state=present
when: ansible_distribution == "Ubuntu" and ansible_distribution_version == "14.04"
- name: Install CentOS 7 Repository
get_url: url=http://download.opensuse.org/repositories/home:/VIFIBnexedi/CentOS_7/home:VIFIBnexedi.repo dest=/etc/yum.repos.d/slapos.repo mode=0440
when: ansible_distribution == "CentOS" and ansible_distribution_major_version == "7"
- name: Install CentOS 7 RPM Key
rpm_key: state=present key=http://download.opensuse.org/repositories/home:/VIFIBnexedi/CentOS_CentOS-6/repodata/repomd.xml.key
when: ansible_distribution == "CentOS" and ansible_distribution_major_version == "7"
---
dependencies:
- { role: repository }
- name: Install packages using apt
apt: name=slapos-node state=present update_cache=yes cache_valid_time=3600
when: ansible_os_family == "Debian"
- name: Install re6stnet on CentOS
yum: name=slapos.node state=present update_cache=yes
when: ansible_os_family == "RedHat"
- name: Check if configuration exists already
stat: path=/etc/opt/slapos/slapos.cfg
register: slapos_cfg
- name: Configure SlapOS with slapos configure local
shell: "slapos configure local"
when: slapos_cfg.stat.exists == False
- name: Wait for proxy
wait_for: host=127.0.0.1 port=8080 delay=10
- name: Run slapos format for initial bootstrap
service: "slapos node format --now --alter_user=True"
when: slapos_cfg.stat.exists == False
\ No newline at end of file
---
dependencies:
- { role: repository }
- name: Install packages using apt
apt: name=slapos-node state=present update_cache=yes cache_valid_time=3600
when: ansible_os_family == "Debian"
- name: Install re6stnet on CentOS
yum: name=slapos.node state=present update_cache=yes
when: ansible_os_family == "RedHat"
- name: Check if configuration exists already
stat: path=/etc/opt/slapos/slapos.cfg
register: slapos_cfg
- name: Configure SlapOS with slapos node register
shell: "slapos node register --token {{ slapostoken }} --master-url {{ slapos_master_url }} --master-url-web {{ slapos_web_master_url }} --interface-name {{ interface_name }} {{ computer_name }}"
when: slapos_cfg.stat.exists == False and "{{ slapostoken }}" != "notoken" and "{{ computer_name }}" != "noname"
- name: Check if configuration exists already
stat: path=/etc/opt/slapos/slapos.cfg
register: xslapos_cfg
- name: Run slapos format for initial bootstrap
shell: "slapos node format --now --alter_user=True"
when: xslapos_cfg.stat.exists == True
\ No newline at end of file
---
- name: Include table 0 on re6st
shell: echo "TODO"
- name: interface on re6st
shell: echo "TODO"
- name: Load kvm_intel
shell: echo "TODO if machine has support."
- name: Set 666 on /dev/kvm
shell: echo "TODO if machine has support."
- name: Increase ulimit
shell: echo "TODO"
---
dependencies:
- { role: vifib-server }
---
- name: "Load acpi_cpufreq"
shell: modprobe acpi_cpufreq > /dev/null 2>&1
- name: "Load coretemp"
shell: modprobe coretemp > /dev/null 2>&1
- name: "Load f71882fg"
shell: modprobe f71882fg > /dev/null 2>&1
- name: "Do sysctl"
shell: 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
- name: echo 1 > /sys/kernel/mm/ksm/run
shell: echo 1 > /sys/kernel/mm/ksm/run
- name: "Install firmware-realtek"
apt: name=firmware-realtek
apt: name=firmware-realtek state=latest update_cache=yes cache_valid_time=3600
when: ansible_os_family == "Debian"
#!/usr/bin/python
import sys
print sys.argv[1:]
host_content = open('/etc/hosts', 'r').read()
hpath = sys.argv[1]
domain = sys.argv[2]
with open('/etc/hosts', 'a') as hosts:
for content in open(hpath, 'r').readlines():
if content:
items = content.strip().split(' ')
entry = "%s %s.%s %s" % (items[1], items[0], domain, items[0])
print entry
if not entry in host_content:
hosts.write(entry)
hosts.write('\n')
---
- name: restart ssh
service: name=ssh state=restarted
---
- name: Download hostname
get_url: url=http://10.0.2.100/hostname dest=/etc/opt/hostname mode=666
ignore_errors: True
- name: Download ipv4
get_url: url=http://10.0.2.100/ipv4 dest=/etc/opt/ipv4 mode=666
ignore_errors: True
- name: Download cluster.hash
get_url: url=http://10.0.2.100/cluster.hash dest=/tmp/cluster.hash mode=666
ignore_errors: True
- name: stat /etc/opt/hostname
stat: path=/etc/opt/hostname
register: hostname_file
- name: stat /etc/opt/ipv4
stat: path=/etc/opt/ipv4
register: ipv4_file
- name: stat /tmp/cluster.hash
stat: path=/tmp/cluster.hash
register: cluster_hash
- name: replace /etc/hostname
copy: src=/etc/opt/hostname dest=/etc/hostname mode=666
when: hostname_file.stat.exists == True
- name: update hostname
command: hostname -F /etc/hostname
when: hostname_file.stat.exists == True
- name: managing hosts file
lineinfile: dest=/etc/hosts regexp="^127.0.1.1" line=""
when: hostname_file.stat.exists == True
- name: setting hosts special line
lineinfile: dest=/etc/hosts line="{{ lookup('file', '/etc/opt/ipv4') }} {{ lookup('file', '/etc/opt/hostname') }}.tl.teralab-datascience.fr {{ lookup('file', '/etc/opt/hostname') }}"
when: hostname_file.stat.exists == True
- name: setting cluster
get_url: url="{{ lookup('file', '/tmp/cluster.hash') }}/hosts" dest=/tmp/hosts mode=666 validate_certs=no
when: cluster_hash.stat.exists == True
- name: stat /tmp/hosts
stat: path=/tmp/hosts
register: hostname_file
- name: Format hosts
script: format_hosts /tmp/hosts tl.teralab-datascience.fr
when: cluster_hash.stat.exists == True
- name: managing resolv.conf file
lineinfile: dest=/etc/resolv.conf line="search tl.teralab-datascience.fr"
- name: adding entry from workspace
lineinfile: dest=/etc/resolv.conf line="nameserver 10.200.218.1"
- name: Create /etc/opt dir
file: dest=/etc/opt mode=775 state=directory
- name: Download configuration
get_url: url=http://10.0.2.100/netconfig.sh dest=/etc/opt/netconfig.sh mode=755
ignore_errors: True
- name: stat /etc/opt/netconfig.sh
stat: path=/etc/opt/netconfig.sh
register: netconfig_file
- name: replace /etc/rc.local
copy: src=/etc/opt/netconfig.sh dest=/etc/rc.local mode=755
when: netconfig_file.stat.exists == True
- name: call netconfig.sh
command: /etc/opt/netconfig.sh
when: netconfig_file.stat.exists == True
ignore_errors: True
- include: hostname.yml
- include: user.yml
- include: sudo.yml
- include: ssh.yml
---
- name: Create ~/.ssh
file: path=/root/.ssh state=directory mode=700
- name: Create /home/netadmin/.ssh
file: path=/home/netadmin/.ssh state=directory mode=700 owner=netadmin group=netadmin
- name: Download ssh authorized keys
get_url: url=http://10.0.2.100/authorized_keys dest=/root/.ssh/authorized_keys.download mode=755
ignore_errors: True
- name: stat /root/.ssh/authorized_keys.download
stat: path=/root/.ssh/authorized_keys.download
register: authorized_keys
- name: replace /root/.ssh/authorized_keys
copy: src=/root/.ssh/authorized_keys.download dest=/root/.ssh/authorized_keys mode=644
when: authorized_keys.stat.exists == True
- name: replace /home/netadmin/.ssh/authorized_keys
copy: src=/root/.ssh/authorized_keys.download dest=/home/netadmin/.ssh/authorized_keys mode=644 owner=netadmin group=netadmin
when: authorized_keys.stat.exists == True
- name: update /etc/ssh/sshd_config
lineinfile: dest=/etc/ssh/sshd_config regexp="^PermitRootLogin (?!no)" line="PermitRootLogin no"
notify:
- restart ssh
- name: update /etc/ssh/sshd_config
lineinfile: dest=/etc/ssh/sshd_config line="PermitRootLogin no"
notify:
- restart ssh
---
- name: Ensure sudo is installed
apt: name=sudo state=latest update_cache=yes cache_valid_time=3600
when: ansible_os_family == "Debian"
- name: Ensure sudo is installed (yum)
yum: name=sudo state=latest update_cache=yes
when: ansible_os_family == "RedHat"
- name: Ensure /etc/sudoers.d directory is present
file: path=/etc/sudoers.d state=directory
- name: Ensure /etc/sudoers.d is scanned by sudo
action: lineinfile dest=/etc/sudoers regexp="#includedir\s+/etc/sudoers.d" line="#includedir /etc/sudoers.d"
- name: Add hadoop user to the sudoers
lineinfile: dest=/etc/sudoers.d/netadmin state=present create=yes regexp="netadmin .*" line="netadmin ALL=(root) NOPASSWD:ALL"
- name: Ensure /etc/sudoers.d/netadmin file has correct permissions
action: file path=/etc/sudoers.d/netadmin mode=0440 state=file owner=root group=root
---
- name: create netadmin
user: name=netadmin shell=/bin/bash groups=root password=$6$rounds=100000$RcjiHRBJa/ORaqst$0L2hFmL5kwGpP6sY2r.hENK3DR5YLdlSDf.r57hwsLjKioYx36CdeLso.52av1UA61rhWIJWdoRYI5bFz.RAC1
- name: remove other unwanted users
user: name={{ item }} state=absent
with_items:
- slapos
- nexedi
---
- name: get CDH repository package
get_url: url=http://archive.cloudera.com/cdh5/one-click-install/wheezy/amd64/cdh5-repository_1.0_all.deb dest=~/cdh5-repository_1.0_all.deb
- name: Install CDH repository package
shell: dpkg -i ~/cdh5-repository_1.0_all.deb
- name: get ClouderaManager repo list
get_url: url=http://archive.cloudera.com/cm5/debian/wheezy/amd64/cm/cloudera.list dest=/etc/apt/sources.list.d/cloudera-manager.list
- name: update the repositories
shell: apt-get update
- name: update apt repositories
action: shell apt-get update ; true
- name: install python-apt
raw: "apt-get install -y python-apt"
- name: install sudo
apt: name=sudo state=latest
- name: install tree
apt: name=tree state=latest
- name: install curl
apt: name=curl state=latest
- name: install oracle-j2sdk1.6
apt: name=oracle-j2sdk1.7 state=latest
- name: managing hosts file
action: lineinfile dest=/etc/hosts regexp="^127.0.1.1" line=""
- name: install CM server
apt: name={{ item }} state=latest
with_items:
- cloudera-manager-daemons
- cloudera-manager-server-db
- cloudera-manager-server
- name: start cloudera-manager-server and -db
service: name={{ item }} state=started
with_items:
- cloudera-scm-server-db
- cloudera-scm-server
#!/bin/bash
DISK=$1
echo "n
p
1
w
"|fdisk $DISK
---
- name: stat /dev/vd{{ vd_disk }}
stat: path=/dev/vd{{ vd_disk }}
register: disk
- name: stat partition /dev/vd{{ vd_disk }}1
stat: path=/dev/vd{{ vd_disk }}1
register: partition_vd
- name: create partition script
copy: src=autofdisk dest=/usr/local/playbook-autofdisk mode=700
when: disk.stat.exists == True and partition_vd.stat.exists == False
- name: Create Partition
shell: /usr/local/playbook-autofdisk /dev/vd{{ vd_disk }}
when: disk.stat.exists == True and partition_vd.stat.exists == False
- name: Create Partition
filesystem: fstype=ext4 dev=/dev/vd{{ vd_disk }}1
when: disk.stat.exists == True and partition_vd.stat.exists == False
- name: stat partition /dev/vd{{ vd_disk }}1
stat: path=/dev/vd{{ vd_disk }}1
register: partition_vd_created
- name: Create directory /data{{ data_n }}
file: path=/data{{ data_n }} state=directory
when: partition_vd_created.stat.exists == True
- name: Mount /data{{ data_n }}
mount: name=/data{{ data_n }} src=/dev/vd{{ vd_disk }}1 fstype=ext4 state=mounted
when: partition_vd_created.stat.exists == True
---
re6st_registry_url: http://re6stnet.gnet.erp5.cn/
slapos_master_url: https://slap.grandenet.cn/
slapos_web_master_url: https://slapos.grandenet.cn/
interface_name: lo
---
re6st_registry_url: http://re6stnet.imt.vifib.com/
slapos_master_url: https://slap.imt.vifib.com/
slapos_web_master_url: https://imt.vifib.com/
interface_name: lo
---
re6st_registry_url: http://re6stnet.nexedi.com/
slapos_master_url: https://slap.vifib.com/
slapos_web_master_url: https://slapos.vifib.com/
interface_name: lo
\ No newline at end of file
- name: a play that runs entirely on the ansible host
hosts: 127.0.0.1
connection: local
vars_files:
- settings/vifib.yml
vars:
interface_name: eth0
vars_prompt:
- name: "computer_name"
prompt: "What is this computer name? (ignore if you already have a configured re6st and slapos):"
private: no
default: "noname"
- name: "slapostoken"
prompt: "If you have slapos token if you have (ignore if you already have a configured slapos):"
private: no
default: "notoken"
roles:
- slapos
- { role: package, package_name: ntp, package_state: present }
- rafael_ssh_key
- name: a play that runs entirely on the ansible host
hosts: 127.0.0.1
connection: local
vars_files:
- settings/vifib.yml
vars_prompt:
- name: "computer_name"
prompt: "What is this computer name? (ignore if you already have a configured re6st and slapos):"
private: no
default: "noname"
- name: "slapostoken"
prompt: "If you have slapos token if you have (ignore if you already have a configured slapos):"
private: no
default: "notoken"
roles:
- slapos
- { role: package, package_name: ntp, package_state: present }
- name: a play that runs entirely on the ansible host
hosts: 127.0.0.1
connection: local
vars_files:
- settings/vifib.yml
vars_prompt:
- name: "computer_name"
prompt: "What is this computer name? (ignore if you already have a configured re6st and slapos):"
private: no
default: "noname"
- name: "slapostoken"
prompt: "If you have slapos token if you have (ignore if you already have a configured slapos):"
private: no
default: "notoken"
roles:
- re6stnet-legacy
- slapos
- { role: package, package_name: ntp, package_state: present }
- vifib-server-shuttle
- name: a play that runs entirely on the ansible host
hosts: 127.0.0.1
connection: local
vars_files:
- settings/vifib.yml
vars_prompt:
- name: "computer_name"
prompt: "What is this computer name? (ignore if you already have a configured re6st and slapos):"
private: no
default: "noname"
- name: "slapostoken"
prompt: "If you have slapos token if you have (ignore if you already have a configured slapos):"
private: no
default: "notoken"
roles:
- re6stnet-legacy
- slapos
- { role: package, package_name: ntp, package_state: present }
- vifib-server
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