Code Monkey home page Code Monkey logo

podwatch's Introduction

PodWatch

PodWatch is an Ansible Playbook that examines container images on a host and updates the images if a newer version is available with the same tag (e.g. latest).

It was developed on the following infrastructure:

  • Intel NUC bare metal server

  • Fedora 33 Server

  • Ansible 2.10(.4)

The general logic flow in the playbook is:

  • Retrieve all container images on the machine

  • In a loop do the following

    • Check if there is a newer version of the image available. If so pull that image.

    • If a newer image has been found check if there is a running container using the old image. If so force restart the container to pick up the new image

  • Use podman system prune to clean up old, now unused, images.

Installation

  1. In a directory of your choice clone this repo:

    git clone https://github.com/wkulhanek/podwatch
    cd podwatch
    
    # Need to create a logs directory to use in the shell script later
    mkdir logs
  2. Determine if your podman containers are running as regular users (using the user id you just cloned the repository with) or as root. The playbook is written for the case where the playbook runs as a regular user but the containers are running as root. It only works for these two cases and does not yet support individual users for each container. If the containers are running as root no change is necessary. If running as a regular user switch the line become: true to become:false in the main podwatch.yml playbook.

  3. Create a Python3 virtual environment to run the playbook in.

    1. Make sure that Python3 and _virtualenv* are installed:

      sudo dnf -y install python3 python3-virtualenv
    2. Create a virtualenv for podwatch and install all prerequisites into the virtualenv.

mkdir $HOME/virtualenvs
virtualenv -p $(which python3) $HOME/virtualenvs/podwatch
source $HOME/virtualenvs/podwatch/bin/activate

pip install -r ./requirements.txt
  1. Install the Ansible collection(s) necessary to run the playbook.

ansible-galaxy install -r ./requirements.yml
  1. Create a crontab file pointing to the update_containers.sh script in your podwatch directory.

    0 3 * * * /home/kulhanek/podwatch/update_containers.sh
  2. And finally set the crontab to use this file:

    crontab crontab
  3. Validate that your crontab is set properly:

    crontab -l

podwatch's People

Contributors

wkulhanek avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.