/dev/blog/ID10T

Advertisement

OpenWRT: Upgrade all packages with opkg

OpenWRT, Codebites Comments

Update April 2020: J. Reis rightfully mentioned in the comments this is not a good way. OpenWRT recommends flashing a sysupgrade.

There seems to be some indication that this may be a terrible idea and isn’t actually supported by OpenWRT in any official way (which may account for the lack of any simple GUI way of performing this function): https://forum.openwrt.org/t/okpg-upgrade-safeguards/30326

https://forum.openwrt.org/t/opkg-upgrade-vs-flashing-sysupgrade/58906 https://forum.openwrt.org/t/sysupgrade-instead-of-opkg-upgrade/32897/4

Original Post

I’m using OpenWRT on my Linksys WRT3200ACM. As the integrated package manager opkg does not have a pendant to apt-get dist-upgrade, this is the command I regularly execute, to upgrade the system:

opkg update && opkg list-upgradable| awk '{print $1}'| tr '\n' ' '| xargs -r opkg upgrade

I recommend running this command in a session detached from SSH. This way you’re safe in case your machine or the router get network problems. I’ve ran into that problem once which cost me a couple of hours for debuggin. Therefor I run the command in a detached tmux session:

tmux new -d "opkg update && opkg list-upgradable| awk '{print $1}'| tr '\n' ' '| xargs -r opkg upgrade"

If you are brave, you can automate this via cron. I prefer doing supervised updates regularly, as my router is a rather critical part of my infrastructure.

Using Python Virtual Environments for Ansible Nodes

Ansible, Linux Comments

Did you ever need a different Python version on an Ansible Node? Or a different Python module version? I did.

The Ansible modules openssl_certificate and openssl_csr require pyOpenSSL >= 0.15. This is not the case for Red Hat Enterprise Linux 6 servers. The Python installation I wanted to use with Ansible needed to have an enabled Python SCL and an activated Python Virtual Environment (because I didn’t want to fiddle with the original SCL modules) before running its commands.

Therefore I created the small shell script python36-starter.sh:

#!/bin/bash
. /opt/rh/rh-python36/enable
. /opt/python-venv/bin/activate
exec python "$@"

It’s pretty much self-explanatory. By sourcing the enable and activate files of SCL and Virtual Environment, the correct pathes for Python binaries and libraries are set. Then the “new” Python binary is executed with all arguments the script was called with.

By adding the ansible_python_interpreter configuration parameter to the according host in the inventory this script will be used by Ansible in future runs.

[webservers]
prodweb
simuweb
testweb
webcert ansible_python_interpreter=/usr/local/bin/python36-starter.sh
xweb

This small hack could be extended even further. You could export environment variables in it or do some logging or auditing stuff. But keep in mind this is a dirty hack. Do not give up the freedom and clarity Ansible provides by overextending “quick and dirty” hacks.

Ansible: Global defaults with local overwrites via conditional chaining

Ansible, Codebites Comments

Playbook:

- hosts: localhost
  connection: local
  gather_facts: no

  vars:
    global_bool: "Global fallback"

  tasks:
    - debug:
        msg: "This uses the global value."
      when: (local_bool is defined and local_bool) or
            (global_bool and local_bool is not defined)
    - set_fact:
        local_bool: True
        global_bool: False
    - debug:
        msg: "This uses the local value."
      when: (local_bool is defined and local_bool) or
            (global_bool and local_bool is not defined)

Output:

$ ansible-playbook conditional_chaining.yml
 [WARNING]: Unable to parse /etc/ansible/hosts as an inventory source

 [WARNING]: No inventory was parsed, only implicit localhost is available

 [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'


PLAY [localhost] *******************************************************************************************************************************************

TASK [debug] ***********************************************************************************************************************************************
ok: [localhost] => {
    "msg": "This uses the global value."
}

TASK [set_fact] ********************************************************************************************************************************************
ok: [localhost]

TASK [debug] ***********************************************************************************************************************************************
ok: [localhost] => {
    "msg": "This uses the local value."
}

PLAY RECAP *************************************************************************************************************************************************
localhost                  : ok=3    changed=0    unreachable=0    failed=0

Subnautica: Fix 0000000e Access Violation crash

Gaming, Windows Comments

Subnautica Banner Small

Subnautica is available for free on the Epic Game Store until 27th December. It was on my radar for quite some time, so I decided to try it out. Unfortunately on my PC the game crashed before even starting properly. At least it creates crash logs. While most of those were useless to me, one part was constant in all my tries:

Read from location 0000000e caused an access violation

This seems to be an error common in many Unity Engine games, not exclusive to Subnautica. Therefore a lot of people experienced this crash issue. Most search results on the Internet recommend disabling overlays. I did that for Steam, Discord, Riva Tuner and f.lux, to no avail.

Introducing Codebites

Blog Comments

Update May 2020: Codebites have been integrated in the normal flow of the site, so this post is not accurate anymore.

YAML CodebiteThere is very little post activity on my Blog. Creating posts is no cakewalk, additionally I often don’t see the public interest for a lot of topics. That’s why I added a new feature to the Blog today, Codebites. Codebites are intended to be more “Memo like” posts than real Blog posts. As such, they will be “low detail” creations, the default Codebites site is thusly sorted by category. Little or even no explanatory text, just copy and pastes of solutions and - perhaps - the problem in itself. I hope to put out more of these bites than my current 12 blog posts per year.
As Codebites are a drastically different approach to normal blog posts, I don’t want to bother my current RSS feed subscribers with it (side note: I don’t know if anybody is even reading my RSS feed, I didn’t bother to add any tracking). The current “default feed” will stay the same, only containing full fledged Blog posts. I created two new feeds, one for Codebites only and one containing everything.

The first (rather trivial) Codebite is already online: Ansible: Add two lists, then filter with third list

In other news: I’m aware of the oversized Google Ads, I’ll look into solving that issue in the near future.

Advertisement