Browse Source

first commit

master
Christian Pape 7 years ago
commit
b4910dac50
  1. 4
      .gitignore
  2. 43
      gns3-qemu.json
  3. 47
      gns3-vmware.json
  4. 36
      http/ks.cfg
  5. 3
      scripts/base.sh
  6. 3
      scripts/cleanup.sh
  7. 8
      scripts/grafana.sh
  8. 77
      scripts/opennms.sh
  9. 1
      scripts/vmware.sh
  10. 3
      scripts/zerodisk.sh

4
.gitignore

@ -0,0 +1,4 @@
output-vmware-iso
output-qemu
packer_cache
.DS_Store

43
gns3-qemu.json

@ -0,0 +1,43 @@
{
"variables": {
"iso_mirror": "mirror.informatik.hs-fulda.de",
"opennms_release": "stable",
"onms-version": "22.0.0-1"
},
"builders": [
{
"type": "qemu",
"accelerator": "kvm",
"boot_command": [
"<tab> text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg<enter><wait>"
],
"boot_wait": "10s",
"disk_size": 20000,
"headless": true,
"http_directory": "http",
"iso_checksum": "714acc0aefb32b7d51b515e25546835e55a90da9fb00417fbee2d03a62801efd",
"iso_checksum_type": "sha256",
"iso_url": "https://{{user `iso_mirror`}}/centos/7.5.1804/isos/x86_64/CentOS-7-x86_64-Minimal-1804.iso",
"ssh_username": "root",
"ssh_password": "secret",
"ssh_port": 22,
"ssh_wait_timeout": "10000s",
"shutdown_command": "/sbin/halt -h -p"
}
],
"provisioners": [
{
"type": "shell",
"override": {
"vmware-iso": {
"scripts": [
"scripts/base.sh",
"scripts/opennms.sh",
"scripts/grafana.sh",
"scripts/cleanup.sh"
]
}
}
}
]
}

47
gns3-vmware.json

@ -0,0 +1,47 @@
{
"variables": {
"iso_mirror": "mirror.informatik.hs-fulda.de",
"opennms_release": "stable",
"onms-version": "22.0.0-1"
},
"builders": [
{
"type": "vmware-iso",
"boot_command": [
"<tab> text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg<enter><wait>"
],
"boot_wait": "10s",
"disk_size": 20000,
"headless": true,
"http_directory": "http",
"iso_checksum": "714acc0aefb32b7d51b515e25546835e55a90da9fb00417fbee2d03a62801efd",
"iso_checksum_type": "sha256",
"iso_url": "https://{{user `iso_mirror`}}/centos/7.5.1804/isos/x86_64/CentOS-7-x86_64-Minimal-1804.iso",
"ssh_username": "root",
"ssh_password": "secret",
"ssh_port": 22,
"ssh_wait_timeout": "10000s",
"shutdown_command": "/sbin/halt -h -p",
"vmx_data_post": {
"memsize": "8192",
"numvcpus": "2"
}
}
],
"provisioners": [
{
"type": "shell",
"override": {
"vmware-iso": {
"scripts": [
"scripts/base.sh",
"scripts/vmware.sh",
"scripts/opennms.sh",
"scripts/grafana.sh",
"scripts/cleanup.sh"
]
}
}
}
]
}

36
http/ks.cfg

@ -0,0 +1,36 @@
install
cdrom
lang en_US.UTF-8
keyboard us
network --onboot yes --device eth0 --bootproto dhcp --noipv6
rootpw --plaintext secret
firewall --enabled --service=ssh
authconfig --enableshadow --passalgo=sha512
selinux --disabled
timezone Europe/Berlin
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
text
skipx
zerombr
clearpart --all --initlabel
autopart
auth --useshadow --enablemd5
firstboot --disabled
reboot
%packages --ignoremissing
@core
bzip2
kernel-devel
kernel-headers
-ipw2100-firmware
-ipw2200-firmware
-ivtv-firmware
%end
%post
/usr/bin/yum -y install sudo
%end

3
scripts/base.sh

@ -0,0 +1,3 @@
sed -i "s/^.*requiretty/#Defaults requiretty/" /etc/sudoers
yum -y install gcc make gcc-c++ kernel-devel-`uname -r` perl

3
scripts/cleanup.sh

@ -0,0 +1,3 @@
yum -y clean all
rm -rf /tmp/rubygems-*

8
scripts/grafana.sh

@ -0,0 +1,8 @@
yum install -y opennms-helm
systemctl enable grafana-server
systemctl start grafana-server
firewall-cmd --zone=public --permanent --add-port=3000/tcp
sleep 10
curl 'http://admin:admin@localhost:3000/api/datasources' -X POST -H 'Content-Type:application/json;charset=UTF-8' --data-binary '{"name":"OpenNMS","type":"opennms","access":"proxy","url":"http://localhost:8980/opennms","isDefault":true,"basicAuth":true,"basicAuthUser":"admin","basicAuthPassword":"admin"}'

77
scripts/opennms.sh

@ -0,0 +1,77 @@
# Install some tools
yum -y install net-tools wget htop iftop sysstat tcpdump vim git tar unzip psmisc
# Additional packages
yum -y install net-snmp-utils net-snmp
yum -y install bind-utils mailx
# Install OpenNMS repository
rpm -Uvh http://yum.opennms.org/repofiles/opennms-repo-stable-rhel7.noarch.rpm
rpm --import http://yum.opennms.org/OPENNMS-GPG-KEY
# Install OpenNMS without any setup
yum -y install rrdtool
yum -y install opennms
yum -y install jrrd2
yum clean all
# Set Java
/opt/opennms/bin/runjava -s
# Initialize PostgreSQL database
postgresql-setup initdb
# Set authentication from ident to md5
sed -i 's/all 127\.0\.0\.1\/32 ident/all 127.0.0.1\/32 md5/g' /var/lib/pgsql/data/pg_hba.conf
sed -i 's/all ::1\/128 ident/all ::1\/128 md5/g' /var/lib/pgsql/data/pg_hba.conf
# Enable and start PostgreSQL with systemd
systemctl start postgresql
systemctl enable postgresql
# Create opennms user with password and database
sudo -u postgres psql -c "CREATE USER opennms WITH PASSWORD 'opennms';"
sudo -u postgres psql -c "CREATE DATABASE opennms;"
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE opennms to opennms;"
# Create OpenNMS database configuration
printf '<?xml version="1.0" encoding="UTF-8"?>
<datasource-configuration>
<connection-pool factory="org.opennms.core.db.C3P0ConnectionFactory"
idleTimeout="600"
loginTimeout="3"
minPool="50"
maxPool="50"
maxSize="50" />
<jdbc-data-source name="opennms"
database-name="opennms"
class-name="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/opennms"
user-name="%s"
password="%s" />
<jdbc-data-source name="opennms-admin"
database-name="template1"
class-name="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/template1"
user-name="%s"
password="%s" />
</datasource-configuration>' opennms opennms opennms opennms \
> /opt/opennms/etc/opennms-datasources.xml
# Initialize OpenNMS database schema
/opt/opennms/bin/install -dis
echo "org.opennms.rrd.storeByForeignSource=true" >> /opt/opennms/etc/opennms.properties
# Configure OpenNMS to use RRDtool
echo "org.opennms.rrd.strategyClass=org.opennms.netmgt.rrd.rrdtool.MultithreadedJniRrdStrategy" >> /opt/opennms/etc/rrd-configuration.properties
echo "org.opennms.rrd.interfaceJar=/usr/share/java/jrrd2.jar" >> /opt/opennms/etc/rrd-configuration.properties
echo "opennms.library.jrrd2=/usr/lib64/libjrrd2.so" >> /opt/opennms/etc/rrd-configuration.properties
# Enable and start OpenNMS with systemd
systemctl start opennms
systemctl enable opennms
firewall-cmd --zone=public --permanent --add-port=8980/tcp

1
scripts/vmware.sh

@ -0,0 +1 @@
yum install -y fuse-libs open-vm-tools

3
scripts/zerodisk.sh

@ -0,0 +1,3 @@
dd if=/dev/zero of=/EMPTY bs=1M
rm -f /EMPTY
sync
Loading…
Cancel
Save