LVM: remove PV from VG

#
# Create test LV
#
for i in {1..3}; do
truncate -s 1G disk${i}.img
losetup /dev/loop${i} disk${i}.img
pvcreate /dev/loop${i}
done

pvs

vgcreate vg0 /dev/loop1 /dev/loop2 /dev/loop3

vgs

lvcreate -n lv0 -l 100%FREE vg0

lvs

mkfs.ext4 /dev/vg0/lv0

mount /dev/vg0/lv0 /mnt/

df -h /mnt/

for i in {1..15}; do
dd if=/dev/urandom of=/mnt/file${i} bs=1M count=100
done

md5sum /mnt/file?

Grafana

Install from repository
curl https://packagecloud.io/gpg.key | sudo apt-key add -
echo "deb https://packagecloud.io/grafana/stable/debian/ stretch main" | tee /etc/apt/sources.list.d/grafana_stable.list
sudo apt-get update
sudo apt install -y grafana

Credentials
http://SERVER_IP:3000/

Docker container
docker run -i -p 3000:3000 -e "GF_SERVER_ROOT_URL=http://10.0.3.164" -e "GF_SECURITY_ADMIN_PASSWORD=admin" grafana/grafana
user: admin
pass: admin

Configure Graphite datasource
Name: Graphite
Type: Graphite

Install prometheus under Ubuntu

Install from repository
sudo apt-get install -y prometheus
# optional
sudo apt-get install -y prometheus-node-exporter
sudo apt-get install -y prometheus-alertmanager
sudo apt-get install -y prometheus-pushgateway

Ansible installation
https://github.com/panticz/ansible/tree/master/roles/prometheus
- hosts: localhost
roles:
- prometheus

Login
http://SERVER_IP:9090/

Commands
avg_over_time(node_memory_MemAvailable[5m])/1024/1024

Repositroy

Install Couch DB under Ubuntu

Installation
wget https://couchdb.apache.org/repo/bintray-pubkey.asc -qO - | sudo apt-key add -
echo "deb https://apache.bintray.com/couchdb-deb $(lsb_release -cs) main" | sudo tee -a /etc/apt/sources.list.d/couchdb.list
sudo apt update

debconf-set-selections <<\EOF
couchdb couchdb/adminpass string admin
couchdb couchdb/adminpass_again string admin
couchdb couchdb/mode select standalone
couchdb couchdb/bindaddress string 0.0.0.0
EOF

sudo apt-get install -y couchdb

Login
http://SERVER_IP:5984/_utils/
user: admin
pass: admin

Build Wildfly deb package

# http://wildfly.org/downloads/
# https://github.com/mattthias/wildfly-packaging

VERSION=13.0.0.Final
REVISION=1

sudo apt-get install -y devscripts

# Download the "source" (the binary "Java EE7 Full & Web Distribution")
# wget http://download.jboss.org/wildfly/10.1.0.Final/wildfly-10.1.0.Final.tar.gz
# https://github.com/ilanddev/wildfly-debian/tree/master/debian

# download archive
mkdir /tmp/wildfly
wget http://download.jboss.org/wildfly/${VERSION}/wildfly-${VERSION}.tar.gz -q -O /tmp/wildfly/wildfly-${VERSION}.tar.gz

# create a link to archive
cd /tmp/wildfly

Install and configure autofs under Ubuntu

# install autofs package
apt-get install -y autofs

# create required directories
mkdir /etc/auto.master.d

# Configure NFS mount nas.example.com:/volume1/backup to /media/backup
echo "/media /etc/auto.media" >> /etc/auto.master.d/media.autofs
echo "backup -fstype=nfs,rw,async,vers=3 nas.example.com:/volume1/backup" >> /etc/auto.media

# check (directory will by created on access)
ll /media/backup

# debug
service autofs stop
sudo automount -f -v

Ansible playbook
https://github.com/panticz/ansible/blob/master/autofs-test.yml

Netplan

# /etc/netplan/01-netcfg.yaml
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: yes
eth1:
dhcp4: no
mtu: 9000
addresses: [10.0.1.123/24]
gateway4: 10.0.1.254
nameservers:
addresses: [10.0.1.1,8.8.8.8]
search: [example.com, dev]
routes:
- to: 10.5.0.0/16
via: 10.5.88.1
- to: 10.8.0.0/25
via: 10.5.88.1

########################################

# enable dhcp on all interfaces
# /etc/netplan/01-netcfg.yaml
network:
version: 2
renderer: networkd
e

Create VLAN bridge under Linux (trunk, IEEE 802.1Q)

# install required package
apt-get install -y vlan

# /etc/network/interfaces
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual

auto br0
iface br0 inet static
address 10.0.6.12
netmask 255.255.255.0
gateway 10.0.6.1
dns-nameservers 10.0.0.100 10.0.1.101
dns-search example.com
dns-domain example.com
bridge_ports eth0

# VLAN 10
auto vlan10
iface vlan10 inet manual
vlan-raw-device br0

auto br10
iface br10 inet manual
bridge_ports vlan10

# VLAN 22
auto vlan22
iface vlan22 inet manual
vlan-raw-device br0

oVirt

# install
https://www.ovirt.org/download/
sed -i 's|localhost|ovirt|g' /etc/hosts
sed -i 's|localdomain|dev|g' /etc/hosts
reboot
sudo yum install -y http://resources.ovirt.org/pub/yum-repo/ovirt-release42.rpm
sudo yum install -y ovirt-engine
sudo engine-setup --generate-answer=/tmp/ovirt.out

# cat /tmp/ovirt.out
# action=setup
[environment:default]
OVESETUP_DIALOG/confirmSettings=bool:True
OVESETUP_CONFIG/applicationMode=none:None
OVESETUP_CONFIG/remoteEngineSetupStyle=none:None
OVESETUP_CONFIG/sanWipeAfterDelete=bool:False
OVESETUP_CONFIG/storageIsLocal=bool:False

Nginx access control / GeoIP

cat < /etc/nginx/conf.d/geoip.conf
geoip_country /usr/share/GeoIP/GeoIP.dat;

map $geoip_country_code $allowed_country {
default no;
DE yes;
CH yes;
}

log_format allow "allow $remote_addr;";
EOF
chmod 644 /etc/nginx/conf.d/geoip.conf

cat < /usr/local/bin/nginx-allow
#!/bin/bash

while inotifywait --quiet --event create,delete --exclude "[^c][^o][^n][^f]$" /tmp
do
/usr/sbin/nginx -t && /usr/sbin/service nginx reload
done
EOF
chmod 755 /usr/local/bin/nginx-allow

cat < /etc/systemd/system/nginx-allow.service
[Unit]