diff --git a/.puppet/hieradata/node/icinga2-centos7-dev.vagrant.demo.icinga.com.yaml b/.puppet/hieradata/node/icinga2-centos7-dev.vagrant.demo.icinga.com.yaml new file mode 100644 index 00000000..bae3fd0c --- /dev/null +++ b/.puppet/hieradata/node/icinga2-centos7-dev.vagrant.demo.icinga.com.yaml @@ -0,0 +1 @@ +node::ipaddress: "192.168.33.21" diff --git a/.puppet/modules/profiles/manifests/base/dev.pp b/.puppet/modules/profiles/manifests/base/dev.pp new file mode 100644 index 00000000..6ed369e9 --- /dev/null +++ b/.puppet/modules/profiles/manifests/base/dev.pp @@ -0,0 +1,56 @@ +class profiles::base::dev ( +){ + $icinga_dev_tools = [ 'rpmdevtools', 'ccache', + 'cmake', 'make', 'gcc-c++', 'flex', 'bison', + 'openssl-devel', 'boost-devel', 'systemd-devel', + 'mysql-devel', 'postgresql-devel', 'libedit-devel', + 'libstdc++-devel' ] + package { $icinga_dev_tools: + ensure => 'installed', + } + -> + group { [ 'icinga', 'icingacmd']: + ensure => 'present' + } + -> + user { 'icinga': + groups => [ 'icinga', 'icingacmd' ] + } + -> + vcsrepo { '/root/icinga2': + ensure => 'present', + provider => git, + source => 'https://github.com/icinga/icinga2.git' + } + -> + vcsrepo { '/root/icingaweb2': + ensure => 'present', + provider => git, + source => 'https://github.com/icinga/icingaweb2.git' + } + -> + file { [ '/root/icinga2/debug', '/root/icinga2/release']: + ensure => 'directory' + } + -> + file { '/etc/profile.d/env_dev.sh': + content => template("profiles/base/env_dev.sh.erb") + } + -> + exec { 'update-icinga-build-env': + provider => shell, + command => '. /etc/profile', + subscribe => File['/etc/profile.d/env_dev.sh'], + refreshonly => true + } + -> + file { '/usr/local/bin/gcc': + ensure => 'link', + source => '/bin/ccache' + } + -> + file { '/usr/local/bin/g++': + ensure => 'link', + source => '/bin/ccache' + } +} diff --git a/.puppet/modules/profiles/templates/base/env_dev.sh.erb b/.puppet/modules/profiles/templates/base/env_dev.sh.erb new file mode 100644 index 00000000..7457555d --- /dev/null +++ b/.puppet/modules/profiles/templates/base/env_dev.sh.erb @@ -0,0 +1,14 @@ +export I2_GENERIC="-DCMAKE_INSTALL_PREFIX=/usr/local/icinga2" +#export I2_GENERIC="-DCMAKE_INSTALL_PREFIX=/usr/local/icinga2 -DICINGA2_LTO_BUILD=ON -DICINGA2_WITH_TESTS=OFF" + +export I2_DEBUG="-DCMAKE_BUILD_TYPE=Debug -DICINGA2_UNITY_BUILD=OFF $I2_GENERIC" +export I2_RELEASE="-DCMAKE_BUILD_TYPE=RelWithDebInfo -DICINGA2_WITH_TESTS=ON -DICINGA2_UNITY_BUILD=ON $I2_GENERIC" + +alias i2_debug="cd /root/icinga2; mkdir -p debug; cd debug; cmake $I2_DEBUG ..; make -j2; sudo make -j2 install; cd .." +alias i2_release="cd /root/icinga2; mkdir -p release; cd release; cmake $I2_RELEASE ..; make -j2; sudo make -j2 install; cd .." + +export PATH=/usr/local/icinga2/sbin/:$PATH + +if [ -e "/usr/local/icinga2/etc/bash_completion.d/icinga2" ]; then + source /usr/local/icinga2/etc/bash_completion.d/icinga2 +fi diff --git a/centos7-dev/.gitignore b/centos7-dev/.gitignore new file mode 100644 index 00000000..8000dd9d --- /dev/null +++ b/centos7-dev/.gitignore @@ -0,0 +1 @@ +.vagrant diff --git a/centos7-dev/README.md b/centos7-dev/README.md new file mode 100644 index 00000000..d8e91230 --- /dev/null +++ b/centos7-dev/README.md @@ -0,0 +1,70 @@ +# CentOS 7 Development Vagrant Box + +This Vagrant VM comes pre-installed with CentOS 7 and +all build requirements for Icinga 2. + +* ccache +* gdb +* Build environment with scripts + +## SSH + +Copy your SSH key into the box: + +``` +ssh-copy-id vagrant@192.168.33.21 +vagrant +``` + +Use agent-forwarding to ssh into the box and become root. +``` +ssh -A vagrant@192.168.33.21 +sudo -i +``` + +## Build Environment + +``` +vim /etc/profile.d/env_dev.sh + +source /etc/profile.d/env_dev.sh +``` + +## Builds + +The source is cloned from GitHub into `/root`. + +``` +cd /root/icinga2 +``` + +Debug builds: +``` +i2_debug +``` + +Release builds: +``` +i2_release +``` + +### Compile & Install + +``` +make -j2 install -C debug +``` + +### Run + +``` +/usr/local/icinga2/lib/icinga2/prepare-dirs /usr/local/icinga2/etc/sysconfig/icinga2 + +icinga2 daemon +``` + +### GDB + +``` +gdb --args /usr/local/icinga2/lib64/icinga2/sbin/icinga2 daemon +``` + diff --git a/centos7-dev/Vagrantfile b/centos7-dev/Vagrantfile new file mode 100644 index 00000000..da6aac76 --- /dev/null +++ b/centos7-dev/Vagrantfile @@ -0,0 +1,104 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +VAGRANT_HOME = File.dirname(__FILE__) unless defined? VAGRANT_HOME +require VAGRANT_HOME + "/../tools/vagrant_helper" + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + $nodes.each_pair do |name, options| + config.vm.define name do |node_config| + node_config.vm.box = options[:box_virtualbox] + node_config.vm.hostname = name + "." + options[:net] + node_config.vm.box_url = options[:url] if options[:url] + if options[:forwarded] + options[:forwarded].each_pair do |guest, local| + node_config.vm.network "forwarded_port", guest: guest, host: local, auto_correct: true + end + end + + if options[:synced_folders] + options[:synced_folders].each_pair do |source, target| + node_config.vm.synced_folder source, target, nfs_udp: false + end + end + + node_config.vm.network :private_network, ip: options[:hostonly] if options[:hostonly] + + # provider: parallels + node_config.vm.provider :parallels do |p, override| + override.vm.box = options[:box_parallels] + override.vm.boot_timeout = 600 + + p.name = "Icinga 2: #{name.to_s}" + p.update_guest_tools = false + p.linked_clone = true if Gem::Version.new(Vagrant::VERSION) >= Gem::Version.new(VAGRANT_REQUIRED_LINKED_CLONE_VERSION) + + # Set power consumption mode to "Better Performance" + p.customize ["set", :id, "--longer-battery-life", "off"] + + p.memory = options[:memory] if options[:memory] + p.cpus = options[:cpus] if options[:cpus] + end + + # provider: virtualbox + node_config.vm.provider :virtualbox do |vb, override| + if Vagrant.has_plugin?("vagrant-vbguest") + node_config.vbguest.auto_update = false + end + vb.linked_clone = true if Gem::Version.new(Vagrant::VERSION) >= Gem::Version.new(VAGRANT_REQUIRED_LINKED_CLONE_VERSION) + vb.name = name + vb.gui = options[:gui] if options[:gui] + vb.customize ["modifyvm", :id, + "--groups", "/Icinga Vagrant/" + options[:net], + "--memory", "512", + "--cpus", "1", + "--audio", "none", + "--usb", "on", + "--usbehci", "off", + "--natdnshostresolver1", "on" + ] + vb.memory = options[:memory] if options[:memory] + vb.cpus = options[:cpus] if options[:cpus] + end + + # provider: libvirt + node_config.vm.provider :libvirt do |lv, override| + override.vm.box = options[:box_libvirt] + lv.memory = options[:memory] if options[:memory] + lv.cpus = options[:cpus] if options[:cpus] + end + + # provisioner: ensure that hostonly network is up + # + # workaround for Vagrant >1.8.4-1.9.1 not bringing up eth1 properly + # https://github.com/mitchellh/vagrant/issues/8096 + node_config.vm.provision "shell", inline: "service network restart", run: "always" + + # provisioner: install requirements + node_config.vm.provision :shell, :path => "../.puppet/scripts/shell_provisioner_pre.sh" + + # sync generic hiera data + node_config.vm.synced_folder "../.puppet/hieradata", "/hieradata", nfs_udp: false + + # provisioner: install box using puppet manifest + node_config.vm.provision :puppet do |puppet| + puppet.hiera_config_path = "../.puppet/hieradata/hiera.yaml" + puppet.module_path = "../.puppet/modules" + puppet.environment_path = "environments" + puppet.environment = "vagrant" + + #puppet.options = "--verbose --debug" + end + + # provisioner: post script + node_config.vm.provision :shell, :path => "../.puppet/scripts/shell_provisioner_post.sh", run: "always" + + # print a friendly message + node_config.vm.provision "shell", inline: <<-SHELL + echo "Finished installing the Vagrant box '#{name}'." + echo "Navigate to http://#{options[:hostonly]}" + SHELL + end + end +end + diff --git a/centos7-dev/Vagrantfile.nodes b/centos7-dev/Vagrantfile.nodes new file mode 100644 index 00000000..987637d1 --- /dev/null +++ b/centos7-dev/Vagrantfile.nodes @@ -0,0 +1,28 @@ +# General box configuration +# +# If you want to override these settings, +# copy this file to `Vagrantfile.local` +# and modify it for your own needs. +# +# The Vagrantfile will automatically +# load the overridden settings. + +nodes = { + 'icinga2-centos7-dev' => { + :box_virtualbox => 'bento/centos-7', + :box_parallels => 'bento/centos-7', + :box_libvirt => 'centos/7', + :net => 'vagrant.demo.icinga.com', + :hostonly => '192.168.33.21', # keep in sync with hieradata + :memory => '4096', + :cpus => '4', + :mac => '020027000500', + :forwarded => { + '443' => '8445', + '80' => '8085', + '22' => '2085', + '8003' => '8085' + } + } +} + diff --git a/centos7-dev/environments/vagrant/manifests/default.pp b/centos7-dev/environments/vagrant/manifests/default.pp new file mode 100644 index 00000000..2938ab69 --- /dev/null +++ b/centos7-dev/environments/vagrant/manifests/default.pp @@ -0,0 +1,11 @@ +node default { + class { '::profiles::base::system': + icinga_repo => lookup('icinga::repo::type') + } + -> + class { '::profiles::base::mysql': } + -> + class { '::profiles::base::apache': } + -> + class { '::profiles::base::dev': } +}