ansible.yml

cat <<EOF> /etc/ansible/test.yml 
---
- hosts: all
  tasks:
    - debug: msg="{{ ansible_user_id }}@{{ inventory_hostname }}"
EOF
 
---
- hosts:
    srv.example.com
  remote_user: ubuntu
  become: yes
  tasks:
    - name: Update all packages
      apt:
        update_cache: yes
        upgrade: dist
 
    - name: Show command output
      command: id
      register: out
    - debug: var=out.stdout_lines
 
    - name: print to stdout
      command: id
      register: print
    - debug: msg="{{ print.stdout }}"
    - debug: msg="{{ print.stderr }}"
 
 
- hosts: all
#  p

Ansible

Ansible playbook repository
https://github.com/panticz/ansible

Install Ansible Server
http://www.panticz.de/install-ansible

Ansible syntax (YAML)
http://docs.ansible.com/ansible/YAMLSyntax.html

Configuration files
http://docs.ansible.com/ansible/intro_configuration.html#host-key-checking
/etc/ansible/ansible.cfg - global default configuration
~/.ansible.cfg - local global configuration
/etc/ansible/hosts - default inventory file

Ignore host key
# inventory
[all:vars]

Icinga CLI

NAGIOS_CMD_SOCKET=/var/lib/icinga/rw/icinga.cmd

# schedule a service check
HOST_NAME=www.example.com
SERVICE_NAME=APT
/usr/bin/printf "[%lu] SCHEDULE_FORCED_SVC_CHECK;%s;%s;%s\n" $(date +%s) "${HOST_NAME}" "${SERVICE_NAME}" $(date +%s) | tee -a "${NAGIOS_CMD_SOCKET}"

# schedule a host check
/usr/bin/printf "[%lu] SCHEDULE_HOST_CHECK;%s;%s\n" \
$(date +%s) \
"host_name" \
$(date +%s) | tee -a $NAGIOS_CMD_SOCKET

# URL

Pulseaudio Equalizer switch

#!/bin/bash
 
# install
# https://raw.githubusercontent.com/panticz/installit/master/install.pulseaudio-equalizer.sh
 
if [ "$(pulseaudio-equalizer status | grep "Equalizer status" | cut -d"[" -f2 | cut -d"]" -f1)" == "enabled" ]; then
    pulseaudio-equalizer disable
else
    pulseaudio-equalizer enable
fi

iDRAC

<strong>Key mapping for console redirection</strong>
Use the <ESC><1> key sequence for <F1>
Use the <ESC><2> key sequence for <F2> (System Setup)
Use the <ESC><3> key sequence for <F3>
Use the <ESC><0> key sequence for <F10> (Lifecycle Controller)
Use the <ESC><!> key sequence for <F11> (Boot Manager)
Use the <ESC><@> key sequence for <F12> (PXE Boot)
 
<strong>Management</strong>
# install ipmitool package on client (OPTIONAL)
sudo apt-get install -y ipmitool
 
# connect over SOL (Serial over LAN)
ipmitool -I lanplus -H <IP> -U <USER> -P <PASS> sol activate
 
# power on
ipmitool

Install OpenRA (Command & Conquer Red Alert) under Ubuntu

wget https://raw.githubusercontent.com/panticz/installit/master/install.openra.sh -O - | bash -s

#!/bin/bash

sudo apt-get install libmono-i18n4.0-all
wget -q https://github.com/OpenRA/OpenRA/releases/download/release-20161019/openra_release.20161019_all.deb -O /tmp/openra_release_all.deb
sudo dpkg -i /tmp/openra_release_all.deb
sudo apt-get install -f

Check for latest version
http://www.openra.net/download/

letsencrypt

#
# install
#
# Ubuntu Xenial package
apt-get install lets-encrypt

apt-get install -y git
git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt
/opt/letsencrypt-auto --help all

#
# create letsencrypt certificate
#
HOSTS="
www1.example.com
www2.example.com
www3.example.com
mail.example.com
"

TXT=yuvAtjoicipsOvkashonFurkithsOtPeopNoHewtud4.chacnabvotfueHadgikthisDydsecCeowIkChirnuby
for HOST in ${HOSTS}; do
ssh ${HOST} "mkdir -p /var/www/.well-known/acme-challenge && echo ${TXT} > /var/www/.well-known/acme-challenge/${TXT%.*}"
done

Create XEN LXC DomU

DOMAIN_NAME=lxc
DOMAIN_MAC=00:00:00:ef:11:cc
DOMAIN_RAM=2Gb
DOMAIN_HDD=128Gb
 
xen-create-image \
    --hostname=${DOMAIN_NAME} \
    --dist=xenial  \
    --lvm=vg1 \
    --fs=ext4 \
    --dhcp \
    --pygrub \
    --mac=${DOMAIN_MAC} \
    --mirror=http://archive.ubuntu.com/ubuntu \
    --size=${DOMAIN_HDD} \
    --memory=${DOMAIN_RAM} \
    --swap=${DOMAIN_RAM} \
    --genpass=0 \
    --password=t00r \
    --vcpus $(cat /proc/cpuinfo | grep processor | wc -l)
 
mv /etc/xen/${DOMAIN_NAME}.cfg /etc/xen/${DOMAIN_NAME}
ln -s /etc/xen/${DOMAIN_NAME} /etc/xen/auto/12_lxc
 
mou

Json / jq

# processing Icinga warning Json list
PASSWORD=terceS
URL="http://monitoring.example.com/cgi-bin/icinga/status.cgi?servicestatustypes=20&noheader=1&servicestatustypes=29&sorttype=2&sortoption=3&scroll=963&jsonoutput"

wget -q --user=${USER} --password=${PASSWORD} "${URL}" -O - | jq --raw-output ' .status.service_status

 | select(.host_name | contains("integration")) | select(.status_information | contains("Apache", "Java")) | .host_name'
 
 
jq 'select(.geo != null)' all.json
jq '[ .devices | select(.key | startswith("dimmer")) | .value = .value.state ] | from_entries' filename.json

LTSP update kernel module

# on client: download driver
# Intel ixgbe (10G NIC)
wget https://downloadmirror.intel.com/14687/eng/ixgbe-4.4.6.tar.gz -qP /tmp
 
# Intel e1000e (1G NIC)
wget https://downloadmirror.intel.com/15817/eng/e1000e-3.3.4.tar.gz -qP /tmp
tar xzf /tmp/e1000e-3.3.4.tar.gz -C /tmp/
 
# install required packages
apt-get install build-essential linux-headers-$(uname -r)
 
# on client: compile
cd /tmp/e1000e-3.3.4/src/
make
 
# copy /tmp/e1000e-3.3.4/src/e1000e.ko to LTSP server
 
# debug on server
# make install
# rmmod e1000e
# modprobe e1000e
# update-initramfs -u
 
 
# backup original
Syndicate content