Fix / update systemd in Debian Jessie LXC container

# fix Debian Jessie LXC container boot error:
Failed to install release agent, ignoring: No such file or directory
Failed to create root cgroup hierarchy: Invalid argument
Failed to allocate manager object: Invalid argument
# list all container with uses Debian Jessie:
grep -l jessie /var/lib/lxc/*/rootfs/etc/os-release
# set container name
# stop container
lxc-stop -n ${CONTAINER} -t 10
# backup container
tar -C /var/lib/lxc --use-compress-program=pbzip2 -cf ${CONTAINER}.$(date -I).tar.bz2 ${CONTAINER}
# upgrade systemd in container
echo "deb h

LXC: create Ubuntu Xenial container

wget -q --no-check-certificate -O - | bash -s


[ -z ${CONTAINER} ] && CONTAINER=xenial

# force, remove previous container
if [ "$1" == "-f" ]; then
  [ $(sudo lxc-ls ${CONTAINER} | wc -l) -gt 0 ] && sudo lxc-destroy -f -n ${CONTAINER}

# create container
sudo lxc-create -t ubuntu -n ${CONTAINER} -- template-options -r xenial $@

# workaround for "Failed to mount cgroup at /sys/fs/cgroup/systemd: Permission denied"
echo "lxc.aa_profile = unconfined" | sudo tee -a /var/lib/lxc/${CONTAINER}/config

# start container in background
sudo lxc-start -d -n ${CONTAINER}

# wait 3 seconds until network is up
sleep 3

# copy APT proxy configuration from host
APT_PROXY=$(grep -h "Acquire::http::Proxy" /etc/apt/* -r | head -1)
[ -n "${APT_PROXY}" ] && echo ${APT_PROXY} | sudo tee /var/lib/lxc/${CONTAINER}/rootfs/etc/apt/apt.conf.d/01proxy

# update packages in container
sudo lxc-attach -n ${CONTAINER} -- apt-get update
sudo lxc-attach -n ${CONTAINER} -- apt-get dist-upgrade -y

# show containers status
sudo lxc-ls ${CONTAINER} -f

Allow root SSH login with password
sed -i 's|PermitRootLogin without-password|PermitRootLogin yes|' /etc/ssh/sshd_config
sed -i 's|PasswordAuthentication no|PasswordAuthentication yes|' /etc/ssh/sshd_config
service ssh restart


# fallback: install required python2 over SSH on remote machine
ansible -i inventory -u root -m raw -a "apt-get update && apt-get install -y python-minimal"
# Ad-hoc commands
ansible all -i inventory.list -l localhost -u root -m ping
ansible all -s -m shell -a "hostname -f"
ansible all -s -m apt -a 'pkg=nginx state=installed update_cache=true'
ansible all -m shell -a uptime
ansible all -m shell -a "apt-get update"
ansible -m setup
ansible all -m setup -i inventory/ -u root > /tmp/$(date -I).txt
ansible -m 

Brother MFC-1910W

Install printer
wget -O - | bash -



# Install printer
wget -q -P /tmp
wget -q -P /tmp
dpkg -i /tmp/mfc1910*.deb
lpadmin -p Brother-MFC-1910 -E -v socket://${IP}:9100  -P /usr/share/ppd/brother/brother-MFC1910W-cups-en.ppd -o PageSize=A4

# Install scanner
wget -q -P /tmp
dpkg -i /tmp/brscan4-0.4.3-3.amd64.deb
brsaneconfig4 -a name=MFC-1910W2 model=MFC-1910W ip=${IP}

Check for newer DEB packages


Install Ansible

wget -q --no-check-certificate -O - | bash -


# install required applications 
sudo apt-get install -y software-properties-common

# add ansible repository
sudo apt-add-repository -y ppa:ansible/ansible

# update package list
sudo apt-get update

# install Ansible
sudo apt-get install -y ansible

# Ansible playbook


cat <<EOF> /etc/ansible/test.yml 
- hosts: all
    - debug: msg="{{ ansible_user_id }}@{{ inventory_hostname }}"
- hosts:
  remote_user: ubuntu
  become: yes
    - name: Update all packages
        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 playbook repository

Install Ansible Server

Ansible syntax (YAML)

Configuration files
/etc/ansible/ansible.cfg - global default configuration
~/.ansible.cfg - local global configuration
/etc/ansible/hosts - default inventory file

Ignore host key
# inventory

Icinga CLI


# schedule a service check
/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


Pulseaudio Equalizer switch

# install
if [ "$(pulseaudio-equalizer status | grep "Equalizer status" | cut -d"[" -f2 | cut -d"]" -f1)" == "enabled" ]; then
    pulseaudio-equalizer disable
    pulseaudio-equalizer enable
Syndicate content