Check BIOS Version in Ubuntu Linux – Command

BIOS is a firmware interface between a computer’s hardware and the operating system and like any software, it can be updated.

Knowing the BIOS version can tell you if you have the most up-to-date version of the BIOS or it has to be updated.

This note shows how to check the BIOS version in Ubuntu Linux from the command-line, though these commands should work for the other Linux systems as well. (more…)

‘GRUB_TIMEOUT’ Change – Not Working [SOLVED]

If you have tried to change a timeout in GRUB by setting the GRUB_TIMEOUT but this doesn’t work and you still see the 30 second timeout, this may be related to the GRUB’s “recordfail” feature.

If the recordfail variable is being set to true, i.e. there was a failed boot attempt (or you use LVM/UEFI with which this feature doesn’t work as expected), GRUB will ignore the GRUB_TIMEOUT and will change the timeout to GRUB_RECORDFAIL_TIMEOUT (by default, 30 seconds).

In this short note i will show how to chance the timeout in GRUB if changing the GRUB_TIMEOUT doesn’t work. (more…)

Sign PDF: Add Signature Image to PDF

A PDF document can be signed by inserting an image file with a signature (e.g. scanned copy of a written signature save as a .PNG file with a transparent background).

This can be done using a handwriting note-taking software with PDF annotation support that is called Xournal++.

It is an open-source and cross-platform application that supports Linux (e.g. Ubuntu, Debian, Arch, SUSE), macOS and Windows.

In this note i will show how to install the Xournal++ and use it to sign a PDF by adding an image file with a signature. (more…)

Ansible: Default Variables Values

In Ansible it is recommended to set default values for variables to avoid undefined-variable errors:

The task includes an option with an undefined variable.

The default variables for a role can be defined in the defaults/main.yml file that might look something like this:

nginx_version: 1.20.1
nginx_service_name: "nginx.service"

Ansible will use the default values only if those variables are not defined anywhere else.

Cool Tip: Ansible Playbook – Print Variable & List All Variables! Read more →

Set Default Values for Variables in Ansible

Another option is to set the default values for the variables using the Jinja’s default filter:

"{{ some_variable | default('default_value') }}"

This is often a better approach than failing if a variable is not defined.

Passing in a true as the second parameter will return the default value if the value is defined but blank:

"{{ some_variable | default('default_value', true) }}"

Cool Tip: How to check if a file exists in Ansible! Read more →

Ansible: Run Handler Immediately (Force)

Handlers in Ansible are special tasks that only get executed when triggered by another tasks via the notify directive.

By default, handlers run not immediately but only after all the tasks in a particular play have been completed.

This makes sense, as the handler will only run one time, regardless of how many tasks have notified it.

For example, if multiple tasks update a configuration file and notify a handler to restart Nginx, Ansible will run this handler only one time to avoid unnecessary restarts.

Cool Tip: Enable DEBUG mode and increase VERBOSITY in Ansible! Read more →

Force Ansible Handlers To Run Immediately

If you want to force handlers to run immediately, without waiting for the end of the play, add a meta: flush_handlers task:

tasks:
  - name: "Some task"
    command: ...

  - name: "Flush handlers"
    meta: flush_handlers

  - name: "Some other task"
    command: ...

The meta: flush_handlers task immediately triggers any handlers that have been notified at that point in the play.

Ansible – “sudo: a password is required” [SOLVED]

If you run an Ansible task that requires a privilege escalation, i.e. with become: true, you may get an error “sudo: a password is required”.

This happens when Ansible needs to run some command with sudo but it doesn’t know the password.

In this note i will show how to make the ansible-playbook command prompt for a password at a runtime and how to pass the password non-interactively during automated deployment. (more…)

Docker Compose: Set Environment Variables

In a Docker Compose, you can set environment variables in a service’s containers or overwrite variables that are defined in the Dockerfile of the images you’re running.

To pass the environment variables to the containers, you can use the environment key in a docker-compose.yml file, that works just like a docker run -e VAR=VALUE ... command.

Alternatively, you can pass multiple environment variables from an external file with the env_file option, just like with a docker run --env-file=FILE ... command.

In this short note i will show the examples of how to set the environment variables in the Docker Compose using the environment and env_file options. (more…)