1. Sharing Group_var Variables Across Ansible Inventories

    Sat 20 December 2025

    The problem

    Some time ago I worked with a customer that used Ansible to deploy a multitude of applications across their individual TAP1 environments.

    Unfortunately the Ansible inventory was setup in such a way that group_vars variables for a specific application were manually duplicated across each TAP environment.

    Ansible Inventory Hierarchy Example of inventory folder hierarchy

    Changing or adding a group_vars variable meant updating the group_vars file for each TAP environment. Making changes to group_vars in this environment is a cognitive burden: there is a high risk that one of the environments is missed by mistake.

    The different TAP environments share the vast majority of all group_var variables, except for just a few variables that are environment-specific. There should be no reason to duplicate group_vars variables for each environment.

    The solution

    A shared folder symlinked into group_vars

    Within the application inventory folder, We first create a folder called 000_shared that will contain all group_vars YAML files with variables that are shared across all TAP environments.

    Next, we symlink this folder within each group_vars folder of each environment. Each environment also contains environment-specific configuration in one or more separate files.

    Ansible Inventory Hierarchy

    With this example, any change within webserver.yaml will be applied to all TAP environments of the 'Alpha' application.

    Sharing group_vars variables across applications

    We can apply this trick one level higher: we can create a shared folder called 000_shared_global containing settings that are shared across all application environments.

    Ansible Inventory Hierarchy

    In this example, we could change the DNS configuration for all environments by changing the settings in one, single file. But the global shared group_vars can be used to assure a (security) baseline between unrelated applications that do share similar technology (All Python or PHP applications).

    Evaluation

    Implementing this solution in an existing Ansible 'code base' can be a significant undertaking, but the long-term benefits seem worth it.

    • It reduces the amount of work required for changes
    • It reduces the risk of human error
    • It reduces the cognitive load

    The good news is that you can migrate to this new style of inventory at your own pace, there is no need for a big-bang deployment. Changes can be made to one environment at a time.

    Q & A

    Why the leading 000 zeros in shared folder names?

    Ansible parses group_vars YAML files according to their order within a directory. This means that the shared folders should be named with leading zeros, to assure that they are always parsed first.

    This allows you to override shared group_vars settings for a particular environment, because these environment-specific files will be parsed later and their variable settings will be applied.

    Just use one inventory for DTAP!

    You can create a single inventory for test, acceptance and production, and separate the environments with groups. A shared group contains shared settings and environment-specific settings are put in the group_vars of the specific group. Unfortunately there is a risk:

    Ansible documentation:

    If you need to manage multiple environments, consider defining only the hosts of a single environment in each inventory. This way, it is harder to, for example, accidentally change the state of nodes inside the “test” environment when you wanted to update some “staging” servers.

    Therefore, I would recommend against this approach.

    Changes impact production?

    Changing shared group_vars variables means that all environments are changed, including production. This requires proper code review and deployment processes that assures that said changes are only deployed to production when test and acceptance environments have been changed first.


    1. Development, Test, Acceptance and Production 

    2. When an inventory contains test, acceptance and prod environments it's easy to target all three environments by mistake. 

    Tagged as : Ansible
    If you have any comments email me, see the About page for contact details.
  2. Bose SoundLink On-Ear Headphones Battery Replacement

    Tue 25 February 2025

    Skip to the bottom two paragraph for instructions on how to replace the battery.


    I bought my Bose SoundLink on-ear Bluetooth headphones for 250 Euros around 2017 and I really like them. They are small, light, comfortable and can easily fit in a coat pocket when folded.

    Up until now (about 7 years later) I have replaced the ear cushions in 2019 (€25) and 2024 (€18).

    headphones

    Early 2025, battery capacity had deteriorated to a point where it became noticeable. The battery was clearly dying.

    Unfortunately these headphones aren't designed for easy battery replacement:

    • Bose hasn't published instructions on how to replace the battery, doesn't offer a replacement battery and hasn't documented which battery type/model is used.
    • The left 'head phone' has two Torx security screws and most people won't have the appropriate screwdriver for this size
    • There is soldering involved

    I wanted to try a battery replacement anyway as I hate to throw away a perfectly good, working product just because the battery has worn out. Maybe at some point the headband needs replacing, but with a fresh battery, these headphones can last another 7 years. Let's prevent a bit of e-waste with a little bit of cost and effort.

    Most of all, the cost of this battery replacement is much lower than a new pair of headphones as the battery was €18 including taxes and shipping.

    Right to repair should include easy battery replacement

    Although my repair seemed to have worked out fine, it requires enough effort that most people won't even try. For this reason, I feel that it should be mandatory by law that:

    1. Batteries in any product must be user-replaceable (no special equipment or soldering required)
    2. Batteries must be provided by the vendor until 10 years after the last day the product was sold (unless it's a standard format like AA(A) or 18650).
    3. Batteries must be provided at max 10% of the cost of the original product
    4. The penalty for non-compliance should be high enough such that it won't be regarded as the cost of doing business

    For that matter, all components that may wear down over time should be user-replaceable.


    What you need to replace the battery

    1. Buy the exact battery type: ahb571935pct-01 (350mAh) (notice the three wires!)
    2. A Philips #0 screwdriver / bit
    3. A Torx T6H security screwdriver / bit (iFixit kits have them)
    4. A soldering iron
    5. Solder
    6. Heat shrink for 'very thin wire'
    7. Multimeter (optional)
    8. a bit of tape to 'cap off' bare battery leads

    Please note that I found another battery ahb571935pct-03 with similar specifications (capacity and voltage) but I don't know if it will fit.

    Putting the headphone ear cushion back on can actually be the hardest part of the process, you need to be firm and this process is documented by Bose.

    Battery replacement steps I took

    Make sure you don't short the wires on the old or new battery during replacement

    The battery is located in the left 'head phone'.

    headphone closeup

    1. Use a multimeter to check if your new battery isn't dead (should be 3+ volt)
    2. Remove the ear cushion from the left 'head phone' very gently as not to tear the rim
    3. Remove the two philips screws that keep the driver (speaker) in place
    4. Remove the two Torx screws (you may have to press a bit harder)
    5. Remove the speaker and be carefull not to snap the wire
    6. Gently remove the battery from the 'head phone'
    7. Cut the wires close to the old battery (one by one!) and cover the wires on the battery to prevent a short
    8. Strip the three wires from the headphones a tiny bit (just a few mm)
    9. Put a short piece of heat shrink on each of the three wires of the battery
    10. Solder each wire to the correct wire in the ear cup
    11. Adjust the location of the heat shrink over the freshly soldered joint.
    12. Use the soldering iron close to the heat shrink to shrink it (don't touch anything), this can take some time, be patient
    13. Check that the heat shrink is fixed in place and can't move
    14. Put the battery into it's specific location in the back of the 'head phone'
    15. Test the headphones briefly before reassembling the headphones
    16. Reassemble the 'head phone' (consider leaving out the two Torx screws)
    17. Dispose of the old battery in a responsible manner
    Tagged as : Hardware
    If you have any comments email me, see the About page for contact details.

Page 6 / 115