Network bonding

apt install -y ifenslave

# /etc/network/interfaces
...
auto eth0
iface eth0 inet manual
bond-master bond0

auto eth1
iface eth1 inet manual
bond-master bond0

auto bond0
iface bond0 inet static
address 192.168.1.225
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
dns-nameservers 192.168.1.1
bond-miimon 100
bond-downdelay 200
bond-updelay 200
bond-mode 1
bond-slaves none

# state
cat /proc/net/bonding/bond0

cat /sys/class/net/bond0/bonding/slaves
eth1 eth0

cat /sys/class

SNMP: Linux software RAID state

Compile snmp-swraid
apt-get install -y git make build-essential libsnmp-dev
export GIT_SSL_NO_VERIFY=true
git clone https://github.com/jrossi/snmp-swraid.git /tmp/snmp-swraid
cd /tmp/snmp-swraid
make

tar cjf snmp-swraid.ubuntu-$(lsb_release -sr).tar.bz2 SWRAID-MIB.txt swRaidPlugin.so

# install
apt-get install -y snmpd snmp-mibs-downloader
wget -q http://dl.panticz.de/snmp-swraid/snmp-swraid.ubuntu-$(lsb_release -sr).tar.bz2 -O /tmp/snmp-swraid.ubuntu.tar.bz2
tar xjf /tmp/snmp-swraid.ubuntu.tar.bz2 -C /tmp
cp /tmp/SWRAID-MIB.txt $(find /var/lib -name ietf)

OpenFortiGUI

Install FortiClientSSL VPN client
wget -q http://www.unibamberg.de/fileadmin/rz/vpn/Linux/VPN_Linux_FortiClient.tar.gz -O /tmp/VPN_Linux_FortiClient.tar.gz
sudo tar xzf /tmp/VPN_Linux_FortiClient.tar.gz -C /opt/
sudo /opt/forticlientsslvpn/fortisslvpn.sh

Install openfortigui
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 2FAB19E7CCB7F415
echo "deb http://styrion.at/apt/ ./" | sudo tee /etc/apt/sources.list.d/styrion.list
sudo apt-get update
sudo apt-get install openfortigui

Compile

lm-sensors and snmpd under Ubuntu

#
# on server
#
apt-get install -y lm-sensors snmp snmpd snmp-mibs-downloader

# allow access from network (unsecure)
sed -i 's|agentAddress udp:127.0.0.1:161|agentAddress udp:161|g' /etc/snmp/snmpd.conf
sed -i 's|rocommunity public default -V systemonly|rocommunity public|g' /etc/snmp/snmpd.conf

# restart snmpd server
service snmpd restart

#
# on client
#
apt install -y snmp snmp-mibs-downloader

# read data from snmpd server
snmpwalk -v 2c -c public 10.0.3.94
snmpwalk -v 2c -c public 10.0.3.94 LM-SENSORS-MIB::lmFanSensorsTable
snmpwalk -v 2c -c public 10.0.3.94

Upgrade SSH to v7.3 (with include support)

echo "deb http://archive.ubuntu.com/ubuntu yakkety main" > /etc/apt/sources.list.d/yakkety.list
apt-get update
apt-get install -y ssh
rm /etc/apt/sources.list.d/yakkety.list
apt-get update

ssh -V
OpenSSH_7.3p1 Ubuntu-1, OpenSSL 1.0.2g 1 Mar 2016

mkdir ~/.ssh/config.d
sed -i '1iInclude config.d/*' ~/.ssh/config

Links
https://superuser.com/questions/247564/is-there-a-way-for-one-ssh-config-file-to-include-another-one

OpenShift

# OpenShift on OpenStack
https://docs.openshift.com/container-platform/3.11/install_config/configuring_openstack.html

apt-get install docker-engine=1.13.1-0~ubuntu-xenial

<?php
$URL="https://raw.githubusercontent.com/panticz/installit/master/install.openshift.sh";
echo "wget -q --no-check-certificate $URL -O - | bash -";
echo "

";
$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_URL, $URL);
echo htmlspecialchars(curl_exec($c));
curl_close($c);
echo "

";
?>

# create test project
oc cluster up #--public-hostname=openshift.example.com --loglevel=10
oc login -u developer -p developer
oc whoami
oc new-app -L
oc projects
oc new-app openshift/ruby-20-centos7~https://github.com/openshift/ruby-ex
oc get all
oc get pod -w
oc logs -f ruby-ex-1-build
oc get services
oc expose service ruby-ex #--hostname=app1.example.com
oc get route

echo "192.168.178.31 ruby-ex-myproject.192.168.178.31.xip.io" >> /etc/hosts

Manage OpenShift with Ansible
https://github.com/openshift/openshift-ansible
https://www.ansible.com/blog/2013/09/19/deploying-highly-available-openshift-origin-clusters

# Ansible playbook
https://github.com/panticz/ansible/tree/master/roles/ansible

Links
https://www.openshift.org/
https://github.com/openshift/origin/blob/master/docs/cluster_up_down.md#linux
https://github.com/openshift/origin/releases/latest
https://github.com/OpenShiftDemos/openshift-cd-demo

Rundeck Ansible Plugin

https://github.com/Batix/rundeck-ansible-plugin

https://github.com/Batix/rundeck-ansible-plugin/releases/latest

wget https://github.com/Batix/rundeck-ansible-plugin/releases/download/2.0.2/ansible-plugin-2.0.2.jar -P /var/lib/rundeck/libext/

* Create a new project
http:///resources/createProject

Project Name: Ansible
Default Node Executor: "Ansible Ad-Hoc Node Executor"
Executable: /bin/bash
SSH Connection > SSH Authentication: privateKey

Default Node File Copier
SSH Connection: privateKey

apt-get install ansible

Rundeck (Job scheduler and Runbook automation)

http://rundeck.org/3.0.x-SNAPSHOT/administration/install/ubuntudebian.html

ansible-playbook rundeck-ansible.example.com.yml -i your_inventory

<?php
$URL="https://raw.githubusercontent.com/panticz/ansible/master/rundeck-ansible.example.com.yml";
echo "

";
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $URL);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
echo htmlspecialchars(curl_exec($c));
curl_close($c);
echo "

";
?>

Ansible role
https://github.com/panticz/ansible/tree/master/roles/rundeck
https://github.com/panticz/ansible/blob/master/rundeck.example.com.yml

# install
wget http://dl.bintray.com/rundeck/rundeck-deb/rundeck-2.7.1-1-GA.deb -P /tmp
sudo dpkg -i /tmp/rundeck-2.7.1-1-GA.deb
sudo /etc/init.d/rundeckd start

# Rundeck CLI
sudo apt-get install rundeck-cli
https://rundeck.github.io/rundeck-cli/
https://github.com/rundeck/rundeck-cli/issues/62

# Admin
http://localhost:4440/user/login;jsessionid=16lnsilhg9n6x38a090agwe8y
admin/admin

Configuration
# (global)
/etc/rundeck/framework.properties

# job database
/var/lib/rundeck/data/rundeckdb.mv.db

# hosts
/var/rundeck/projects/JOB_NAME/etc/resources.xml

# add user
echo "foo:bar,user,devops" >> /etc/rundeck/realm.properties

# acl
/var/rundeck/projects//acls/.aclpolicy

Configuration (project)
# configure nodes
/var/rundeck/projects//etc/resources.xml

# use native ssh agent to access host behind proxy / bastion
/var/rundeck/projects//etc/project.properties
plugin.script-exec.default.command=/usr/bin/ssh ${node.username}@${node.hostname} ${exec.command}
plugin.script-copy.default.command=/usr/bin/scp ${file-copy.file} ${node.username}@${node.hostname}\:${file-copy.destination}

Email notification
http://rundeck.org/docs/administration/email-settings.html

# /etc/rundeck/rundeck-config.properties
grails.mail.host=smtp.example.com
grails.mail.port=25
grails.mail.username=foo
grails.mail.password=bar

# restart service
service rundeckd restart

# ssh
mkdir /var/lib/rundeck/.ssh
chown rundeck:rundeck /var/lib/rundeck/.ssh
chmod 700 /var/lib/rundeck/.ssh
touch /var/lib/rundeck/.ssh/id_rsa
chown rundeck:rundeck /var/lib/rundeck/.ssh/id_rsa
chmod 600 /var/lib/rundeck/.ssh/id_rsa

# log
tail -f /var/log/rundeck/*.log

# Documentation
http://rundeck.org/
http://rundeck.org/docs/manual/getting-started.html
http://rundeck.org/2.3.2/administration/configuring-ssl.html

Plugins
https://www.rundeck.com/integrations/plugins
http://rundeck.org/plugins/ansible/2016/03/11/ansible-plugin.html
http://rundeck.org/plugins/2013/01/01/jenkins-rundeck.html
http://rundeck.org/plugins/2013/01/01/aws-ec2-nodes.html

# scm
https://docs.rundeck.com/docs/developer/scm-plugins.html
/var/rundeck/projects/PROJECT_NAME/scm

Docker
DockerHub images: https://hub.docker.com/r/rundeck/rundeck/

# Create container with shared SSH keys an forward GUI to localhost
sudo docker run --name rundeck -p 4440:4440 -v /home/${USER}/.ssh:/home/rundeck/.ssh rundeck/rundeck:SNAPSHOT

# Credentials
url: http://127.0.0.1:4440/
user: admin
pass: admin

https://github.com/x110dc/docker-rundeck

Change default admin password
https://docs.rundeck.com/docs/administration/security/authenticating-users.html
#RD_PASS=$(openssl rand -base64 16)
#echo ${RD_PASS}
#RD_PASS_MD5=$(java -cp /var/lib/rundeck/bootstrap/jetty-all-9.0.7.v20131107.jar org.eclipse.jetty.util.security.Password admin ${RD_PASS} 2>&1 | grep MD5)
#sed -i "s/^admin:admin/admin:MD5:${RD_PASS_MD5}/g" /etc/rundeck/realm.properties
java -jar /var/lib/rundeck/bootstrap/rundeck-*.war --encryptpwd Jetty
service rundeckd restart

# echo "framework.server.password = MD5:${RD_PASS_MD5}" >> /etc/rundeck/framework.properties

# Notify icinga
Local Command:
ssh monitoring.example.com '/usr/bin/printf "[%lu] SCHEDULE_FORCED_SVC_CHECK;%s;%s;%s\n" $(date +%s) ${node.name} APT $(date +%s) | tee -a /var/lib/icinga/rw/icinga.cmd'

# User authentification
http://rundeck.org/docs/administration/authenticating-users.html

Changelog
http://rundeck.org/docs/history/changelog.html

Rundeck jobs and scripts repository
https://github.com/panticz/rundeck

Job options
http://rundeck.org/2.0.0/manual/job-options.html
# use in bash
NODES=$(echo $RD_OPTION_NODES | sed 's/,/ /g')

# remote URL
https://docs.gitlab.com/ee/api/repository_files.html#get-file-from-repository
file:///tmp/foo.json
# dep # https://gitlab.example.com/foo/bar/raw/master/file.json?private_token=foo1234

https://gitlab.example.com/api/v4/projects/3/repository/files/${job.project}%2F${globals.environment}%2Foptions-hosts.json/raw?ref=master&private_token=${globals.private_token}

Pipe command
echo ${option.RSA} | tee /tmp/debug.txt

Commands
# check file size
'[[ $(find /media/backup/db.mr/ -size +50M -name exp_$(date -I)_*.dmp.bz2 ) ]]'

API call with parameter from curl
http://rundeck.org/docs/api/index.html
http://rundeck.org/docs/api/#running-a-job

curl -H "X-Rundeck-Auth-Token: ABCDEFGHIJKLMNOPRST1234567890" --data-urlencode "argString=-sku 'item1 item2 item3'" -X POST http://rundeck.example.com/api/25/job/26356713-8285-479e-860f-221559a64c23422/run

# fix Failed loading remote option values / Exception: java.lang.Exception: Unexpected content type received: text/plain; charset=utf-8 in Rundeck Allowed Values > Remote URL with currently:
# https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/23442
echo "framework.globals.environment=dev" >> /etc/rundeck/framework.properties

Output
# color
grep --color=always foo /path/to/file

CLI commands (draft)
rd projects create -p ops
rd projects configure set -p ops --file ~/project.properties
rd keys create --type privateKey --path keys/lib/rundeck/.ssh/github_rsa --file ~/github_rsa
rd projects scm setup -p ops --integration import --type git-import --file ~/scm-import.json
rd projects scm perform -p ops -i import --action initialize-tracking -f useFilePattern="true" filePattern=".*\\.yaml"
rd projects scm perform -i import -p ops --action import-all
rd projects scm perform -i import -p ops --action import-all --item "ops/my-job-file.yaml"

Fix "Import Status: Not Tracked" issue
apt install -y git
cd /var/rundeck/projects/DevOps/scm
git pull

job options
https://rundeck.org/docs/man5/resource-json.html
https://rundeck.org/docs/manual/defining-job-options.html
https://rundeck.org/2.8.2/administration/configuration-file-reference.html
https://rundeck.org/2.9.2/administration/gui-customization.html