Commit fa8b44d3 authored by Alain Takoudjou's avatar Alain Takoudjou Committed by Rafael Monnerat

playbook: generate vm-bootstrap full install script

parent 958254c7
......@@ -66,6 +66,7 @@
- { 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-bootstrap.yml", script_path: "install/imt/generic-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"}
......
# 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
......@@ -3,10 +3,18 @@
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 == "stable" 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"
......@@ -16,4 +24,4 @@
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
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
{{ 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