Skip to main content

Level up your Ansible skills while having fun: Sysadmin after dark

Gaming is a great way to clear your head after a long workday, and automating game installations with Ansible means you can start playing sooner.

After a long day at work, sysadmins deserve a little downtime. But even downtime can be an opportunity to practice your sysadmin skills. For example, I created an Ansible playbook to install a classic game to help me relax and clear my mind. You can use my playbook to practice using Ansible, and you can use it as inspiration for writing your own playbooks.

LBreakoutHD is a simple, fun, and addictive game developed for Linux (thus "L" at the beginning) but now also available for other platforms. LBreakoutHD is an HD remake of LBreakout2, which is itself a remake of the classic Breakout developed in the 1970s.

The game's idea is to use a ball to break bricks at the top of the screen using a paddle at the bottom to bounce and redirect the ball. You go up a level after breaking all the bricks, and you lose the game if you let the balls fall below the paddle.

Image
LBreakoutHD intro screen
(Ricardo Gerardi, CC-BY SA 4.0)

Some bricks hide surprise boxes that can give you extra points or powers (such as a larger paddle size or exploding balls) to add to the fun. There are also bad surprises that increase the game's difficulty, such as freezing the paddle or decreasing its size.

Image
LBreakoutHD help screen
(Ricardo Gerardi, CC-BY SA 4.0)

You can find LBreakoutHD in the LGames collection. These games are developed by Michael Speck and are open source, released under the GPL license.

[ If you're living life at your terminal emulator anyway, why not have a little fun while you're there? See 5 command-line games for sysadmins .]

Installing the game using Ansible

To install LBreakoutHD on Linux, you need to compile it from its source code. You also need the GCC compiler, make, and the SDL2 development libraries. To make it easier, you can use this Ansible playbook I designed to install it on Fedora 34:

- name: Manages a local source install of lbreakouthd
  hosts: localhost
  gather_facts: yes
  vars:
    prefix_dir: "{{ ansible_env.HOME }}/.local/"
    version: "1.0.8"
    make_action: "install"
    cleanup_tmp: yes

  tasks:
    - name: Ensure requirements in place
      dnf:
        name:
          - SDL2
          - SDL2_image
          - SDL2_mixer
          - SDL2_ttf
          - SDL2-devel
          - SDL2_ttf-devel
          - SDL2_image-devel
          - SDL2_mixer-devel
          - make
          - gcc
          - gcc-c++
        update_cache: yes
        state: present
      become: yes

    - name: Create temporary directory
      file:
        path: /tmp/lbreakout
        state: directory
        mode: 0770

    - name: Download and extract source code
      unarchive:
        src: "https://sourceforge.net/projects/lgames/files/lbreakouthd/lbreakouthd-{{ version }}.tar.gz"
        dest: /tmp/lbreakout/
        remote_src: yes

    - name: Configure the build
      command: ./configure --prefix={{ prefix_dir }}
      args:
        chdir: "/tmp/lbreakout/lbreakouthd-{{ version }}"
        creates: "/tmp/lbreakout/lbreakouthd-{{ version }}/Makefile"

    - name: Make game according to defined make_action install / uninstall
      make:
        chdir: "/tmp/lbreakout/lbreakouthd-{{ version }}"
        target: "{{ make_action }}"

    - name: Ensure temporary directory is deleted
      file:
        path: /tmp/lbreakout
        state: absent
      when: cleanup_tmp | bool

This playbook installation includes dependencies; creates a temporary directory; downloads and extracts the source; and configures, compiles, and installs it using the Ansible make module with the target install. Finally, it removes the temporary directory and the source code in it to clean up the system.

Now, run the playbook to install the game. Use ansible option -K to enable privilege escalation required to install the dependencies:

$ ansible-playbook -K lbreakout.yaml
BECOME password: 
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

PLAY [Manages a local source install of lbreakouthd] ************************

TASK [Gathering Facts] ******************************************************
ok: [localhost]

TASK [Ensure requirements in place] *****************************************
ok: [localhost]

TASK [Create temporary directory] *******************************************
changed: [localhost]

TASK [Download and extract source code] *************************************
changed: [localhost]

TASK [Configure the build] **************************************************
changed: [localhost]

TASK [Make game according to defined make_action install / uninstall] *******
changed: [localhost]

TASK [Ensure temporary directory is deleted] ********************************
changed: [localhost]

PLAY RECAP ******************************************************************
localhost: ok=7 changed=5 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0   

If you want to use this playbook on other distributions, update the task Ensure requirements in place to use the correct module and package names for your distribution. By default, this playbook installs LBreakoutHD into the .local subdirectory under the current user's home directory. You can update it by changing the variable prefix_dir. If you set it to a system directory, you need to run the playbook with a privileged user. You can also change other variables to change the playbook's behavior, such as setting make_action=uninstall to uninstall the game or cleanup_tmp=no to preserve the temporary directory instead of deleting it at the end.

Playing the game

Once it's installed, ensure the directory $HOME/.local/bin is in your $PATH, and start the game by running lbreakouthd. The installation script creates a shortcut for the game in $HOME/.local/share/applications. If your system uses this location for desktop files, you can launch the game using your desktop menus.

Image
LBreakoutHD launch menu
(Ricardo Gerardi, CC-BY SA 4.0)

When the game starts, select New Game to start a new game, then select Start Original Levels to play the levels designed with the game or Start Custom Level to choose among a large number of user-contributed custom levels.

Image
LBreakoutHD custom levels
(Ricardo Gerardi, CC-BY SA 4.0)

These custom levels add extra fun to the game, as some of these levels are challenging or very creative.

Uninstalling the game

To uninstall the game, rerun the playbook, setting the variable make_action=uninstall:

$ ansible-playbook -K lbreakout.yaml -e make_action=uninstall

The playbook removes all game files from the installation directories, but it leaves any saved game data under your $HOME directory intact.

[ Want to test your sysadmin skills? Take a skills assessment today. ]

Have fun

LBreakoutHD is a fun game. It's simple enough to allow you to start playing quickly but is challenging enough that is still entertaining. There's a little bit of learning to understand what all the powers do and how they impact the game. These same powers add to the game replay factor as they change the levels every time you play.

Overall, this is an excellent game with some nostalgia while still modern with nice graphics and cool sound. It's great to refresh your mind after work and to practice your sysadmin skills while having fun.

Check out these related articles on Enable Sysadmin

Topics:   Ansible   Linux   Automation  
Author’s photo

Ricardo Gerardi

Ricardo Gerardi is a Senior Consultant at Red Hat Canada where he specializes in IT automation with Ansible and OpenShift.  More about me

On Demand: Red Hat Summit 2021 Virtual Experience

Relive our April event with demos, keynotes, and technical sessions from
experts, all available on demand.

Related Content

OUR BEST CONTENT, DELIVERED TO YOUR INBOX