Ajitabh Pandey's Soul & Syntax

Exploring systems, souls, and stories – one post at a time

Category: FLOSS

About Free/Libre/Open Source Software

  • Raspberry Pi – rsyslog fixes on Raspbian 8 (Jessie)

    Raspberry Pi – rsyslog fixes on Raspbian 8 (Jessie)

    One of my Raspberry Pi (Raspberry Pi Model B Rev 2) is running quite old versio of Rasbian – although fully updated and patched. Today while checking the syslog on my raspberry pi, I noticed the following error which was very frequently – almost every minute and thus was filling up the syslog.

    Dec 24 20:59:35 rads rsyslogd-2007: action 'action 17' suspended, next retry is Thu Dec 24 21:01:05 2020 [try http://www.rsyslog.com/e/2007 ]

    Thanks to logrotate I was not in an immediate need for action, but still I thought it will be better to fix this – atleast that will reduce the write and increase life of my SD Card.

    The URL at the end of the message was very helpful. According to the specified URL this message simply means that rsyslog.conf contains the instruction to write to the xconsole pipe, but this pipe is never read. on editing the /etc/rsyslog file, the following section can be commented out or removed completely.

    daemon.*;mail.*;\        news.err;\        *.=debug;*.=info;\        *.=notice;*.=warn       |/dev/xconsole

    A simple systemctl restart rsyslog after that will fix the issue.

    I did not see this issue on my other Raspberry Pi which runs Raspbian based on Debian Buster (Debian 10). I checked the /etc/rsyslog.conf on that and could not find the offending lines there. So my understanding is that this issue is with Raspbian based on Jessie.

  • Apt Pinning in Raspbian

    Quite sometime back I wrote a blog entry on apt-pinning to mix multiple repositories in debian and prioritize them. Recently, I felt the need to do the same on my raspberry pi.

    I use rsnapshot to backup remote systems. Rsnapshot has an associated perl script which is meant to send beautiful reports via email at the end of the backup. The script in the version which came with raspbian was broken (1.3.1-4+deb8u1) and I needed 1.4.2-1, which is available in Debian Stretch.

    Following my earlier post, I performed the following steps to perform the installation of the required version without impacting the rest of the system. As you can see that the priority of Jessie is higher than that of Stretch, which will ensure that the system does not get messed up when you do an upgrade.

    # Create the preferences file for jessie and stretch as shown below
    $ sudo vi /etc/apt/preferences.d/jessie.pref
    Package: *
    Pin: release n=jessie
    Pin-Priority: 900
    
    $ sudo vi /etc/apt/preferences.d/stretch.pref
    Package: *
    Pin: release a=stretch
    Pin-Priority: 750
    
    # Define the package sources for both jessie and stretch
    $ sudo vi /etc/apt/sources.list.d/jessie.list
    deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free rpi
    
    $ sudo vi /etc/apt/sources.list.d/stretch.list
    deb http://mirrordirector.raspbian.org/raspbian/ stretch main contrib non-free rpi
    
    # Refresh the cache and sources list
    $ sudo apt-get update
    
    # Install the desired package by specifying the repository from which 
    # it has to be installed
    $ sudo apt-get install rsnapshot -t stretch

    Please be careful before performing these steps in a production system.

  • Ansible Quirks – 3

    I was running some playbook today and realise that the command line arguments of ansible-playbook do not behaves expected.

    My playbook has the following defined –

    remote_user: root

    When I issued the following command, my expectation was that the remote user name would be considered as specified by the “-u” option

    $ ansible-playbook -u centos -i '192.168.1.192,' play.yml

    However, this does not happen and the playbook still tries to connect as the user defined in the yml file.

    So, how do we override what is in the yml file through command line. The only way seems to be possible is using the -e or --extra-vars option as follows –

    $ ansible-playbook -e "ansible_ssh_user=centos ansible_ssh_private_key_file=~/.ssh/db_hosts_id_rsa " -i '192.168.1.192,' play.yml

  • Ansible Quirks – 2

    Today I tried to upgrade my ansible to 2.2 as I wanted to use the remote_src=yes feature from the unarchive module. My operating system on this machine is Linux Mint 17.3.

    I did –

    $ pip install --upgrade --user ansible

    and lo… I got the following error –

    ImportError: No module named packaging.version

    I next tried upgrading the pip itself and that also resulted in the same error. A bit of search on the internet did not help much as different ways worked for different people. So I decided to remove python-pip package and all that was installed along with it, reinstall pip and then try upgrading ansible. In short, following sequence of commands worked for me –

    
    $ rm -rf ~/.cache/pip/*
    $ python -m pip install -U --user pip
    $ sudo apt-get purge -y python-pip
    $ sudo apt-get autoremove
    $ sudo apt-get install python-dev
    $ python -m pip install --upgrade --user packaging
    $ python -m pip install --upgrade --user appdirs
    $ python -m pip install --upgrade --user ansible
    
  • Ansible Quirks – 1

    I started on the ansible learning path about 6 months or so back and have been writing my roles for deploying / configuring various systems I manage. Today while writing a template for sshd_config, I came across a point wherein the handler failed to restart the SSH service on the target server. Fortunately I was logged in as sudo on one of the terminals, and then I checked the config file generated and pushed by ansible. I found that the line

    PermitRootLogin {{ permit_root_login }}

    was translated to

    PermitRootLogin True

    . For a while I though that the variable I defined in

    defaults/main.yml

    was wrongly having a value of True instead of Yes, but I was wrong. Looking into some of the bugs filed in ansible I realised that this is the expected behaviour. The way to prevent strings like yes/no and true/false to be converted to True/False they have to be preceded with !!str in the variable definition. So the variable definition in my case would look like –

    permit_root_login: !!str Yes