This repository has been archived by the owner on Nov 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #168 from Icinga/feature/add-centos7-dev
Add an Icinga 2 development environment on CentOS 7
- Loading branch information
Showing
8 changed files
with
285 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
.puppet/hieradata/node/icinga2-centos7-dev.vagrant.demo.icinga.com.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node::ipaddress: "192.168.33.21" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.vagrant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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': } | ||
} |