add vagrantfile for compass-install

compass can be installed on libvirt backed vagrant box.
easier to manage to lifecycle.
add test option to inject pxeboot mac to compass db.

Change-Id: I779e3d6860d54dee4bd1687fc473e5c38c30e6ca
This commit is contained in:
Jerry Zhao 2015-03-25 03:45:44 +00:00
parent 8b761cfd9b
commit 1a109ea8a7
10 changed files with 103 additions and 26 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
install/inventories
.vagrant

15
Vagrantfile vendored Normal file
View File

@ -0,0 +1,15 @@
Vagrant.configure("2") do |config|
config.vm.define :test_vm do |test_vm|
test_vm.vm.box = "precise64"
test_vm.vm.network :private_network, :ip=>"10.1.0.11", :libvirt__dhcp_enabled=>false
test_vm.vm.provider :libvirt do |domain|
domain.memory = 2048
domain.cpus =2
domain.nested =true
domain.graphics_ip="0.0.0.0"
end
test_vm.vm.provision "ansible" do |ansible|
ansible.playbook="install/allinone_nochef.yml"
end
end
end

23
ci/mac_generator.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/bash
function mac_address_part() {
hex_number=$(printf '%02x' $RANDOM)
number_length=${#hex_number}
number_start=$(expr $number_length - 2)
echo ${hex_number:$number_start:2}
}
function mac_address() {
echo "00:00:$(mac_address_part):$(mac_address_part):$(mac_address_part):$(mac_address_part)"
}
machines=''
for i in `seq $1`; do
mac=$(mac_address)
if [[ -z $machines ]]; then
machines="${mac}"
else
machines="${machines}, ${mac}"
fi
done
echo ${machines}

View File

@ -5,8 +5,8 @@ rebuild: True
# Auto-generated IP values
chef_server: "10.145.81.208"
cobbler_server: "10.145.81.208"
compass-server: "10.145.81.208"
cobbler_server: "10.1.0.11"
compass-server: "10.1.0.11"
# Auto-generated
dockerized_cobbler: True
@ -43,16 +43,16 @@ compass0_router: "192.168.101.1"
compass0_dhcp_range: "192.168.101.150 192.168.101.160"
# management subnet ip of the cluster you want to deploy
mgmt_subnet_ip: "10.145.88.0"
mgmt_subnet_ip: "10.1.0.0"
# management subnet router ip
mgmt_router: "10.145.88.1"
mgmt_router: "10.1.0.1"
# management subnet subnet mask
mgmt_subnet_mask: "255.255.255.0"
# management subnet dhcp range
mgmt_dhcp_range: "10.145.88.150 10.145.88.160"
mgmt_dhcp_range: "10.1.0.50 10.1.0.100"
@ -163,3 +163,7 @@ compass_volume_mapping: "-v {{ compass_host_log_dir }}:{{ compass_container_log_
# install docker on ubuntu
docker_apt_key_server: hkp://keyserver.ubuntu.com:80
docker_apt_key: 36A1D7869245C8950F966E92D8576A8BA88D21E9
# pxe boot macs
pxe_boot_macs: ['00:00:37:ed:95:4e', '00:00:79:ad:ce:6b', '00:00:0a:f6:6e:d7']
test: true

View File

@ -1,19 +0,0 @@
FROM compassindocker/cobbler
ADD files/dhcp.template /etc/cobbler/dhcp.template
ADD files/start.sh /root/start.sh
ADD files/admin.pem /etc/cobbler/admin.pem
ADD files/chef-validator.pem /etc/cobbler/chef-validator.pem
ADD files/fix_ks_server.py /var/lib/cobbler/triggers/sync/post/fix_ks_server.py
RUN chmod +x /root/start.sh
CMD ["/root/start.sh"]
EXPOSE 80
EXPOSE 67 67/udp
EXPOSE 69 69/udp
EXPOSE 53 53/udp
EXPOSE 25151
EXPOSE 443
EXPOSE 873

View File

@ -7,7 +7,7 @@ ADD files/start.sh /root/start.sh
ADD files/admin.pem /etc/cobbler/admin.pem
ADD files/chef-validator.pem /etc/cobbler/chef-validator.pem
{% endif %}
ADD files/fix_ks_server.py /var/lib/cobbler/sync/post/fix_ks_server.py
ADD files/fix_ks_server.py /var/lib/cobbler/triggers/sync/post/fix_ks_server.py
RUN chmod +x /root/start.sh
CMD ["/root/start.sh"]

View File

@ -15,8 +15,12 @@
- name: copy Dockerfile
template: src=Dockerfile.j2 dest=~/docker-compass/Dockerfile mode=0644
- name: copy switch machines file
template: src=switch_machines_file.j2 dest=~/docker-compass/files/switch_machines_file mode=0644
when: test
- name: copy start script
copy: src=start.sh
template: src=start.sh.j2
dest=~/docker-compass/files/start.sh
mode=0755

View File

@ -3,6 +3,9 @@ FROM compassindocker/compass
ADD files/start.sh /root/start.sh
ADD files/compass.setting /etc/compass/setting
ADD files/cobbler.conf /etc/compass/os_installer/cobbler.conf
{% if test%}
ADD files/switch_machines_file /etc/compass/switch_machines_file
{% endif %}
{% if 'chef' in pkg_installer %}
ADD files/chef-icehouse.conf /etc/compass/package_installer/chef-icehouse.conf
ADD files/compass.pem /etc/compass.pem

View File

@ -0,0 +1,42 @@
#!/bin/bash
# activate virtualenv
source `which virtualenvwrapper.sh`
workon compass-core
# start mysqld service, push it to bg
/usr/bin/mysqld_safe > /dev/null 2>&1 &
RET=1
while [[ RET -ne 0 ]]; do
echo "waiting for mariadb to startup"
sleep 5
mysql -uroot -e "status" > /dev/null 2>&1
RET=$?
done
echo "mariadb started"
# set mysql with default username and password
mysqladmin -h127.0.0.1 --port=3306 -u root password root
# create db 'compass'
mysql -h127.0.0.1 --port=3306 -uroot -proot -e "create database compass"
# start compass services
/opt/compass/bin/manage_db.py createdb
# insert pxe boot machines for test
{% if test %}
/opt/compass/bin/manage_db.py set_switch_machines --switch_machines_file /etc/compass/switch_machines_file
{% endif %}
/usr/sbin/apachectl -k start
/usr/sbin/rabbitmq-server &
/usr/bin/redis-server &
/usr/sbin/ntpd &
ln -s /root/.virtualenvs/compass-core/bin/celery /opt/compass/bin/celery
CELERY_CONFIG_MODULE=compass.utils.celeryconfig_wrapper C_FORCE_ROOT=1 /opt/compass/bin/celery worker &> /tmp/celery-worker.log &
/opt/compass/bin/progress_update.py &> /tmp/progress_update.log &
touch /var/log/compass/celery.log
tail -f /var/log/compass/celery.log

View File

@ -0,0 +1,4 @@
switch,1.1.1.1,huawei,2c,public,under_monitoring
{% for mac in pxe_boot_macs %}
machine,1.1.1.1,8,{{ mac }}
{% endfor %}