Giter Club home page Giter Club logo

pod-template's Introduction

Pod playbook template

Template for an Ansible playbook that creates a pod systemd service and is easily extendable to make a good pod and container management system.

Roles

The main and only role in the playbook is pod which can be renamed to anything else. It creates a pod service and is has handlers for enabling and restarting the service. You can easily add tasks to the role in order to start containers in said pod.

A recommended way to create unit files is to generate them using podman cli.

Tasks

Makes sure the units directory is present. This is done in case you wan't to deploy the pod in user scope (in rootless mode). It also sets SELinux context for the directory.

Sets the context for units directory in using semanage so default contenxt for all files created there would be proper.

Creates a pod service (systemd unit file) from a template. I'd recommend doing it this way so variables from ansible playbook could be used in the unit file.

Container task example

In order to start containers inside a pod, you'll need to create service files for that container. Here is an example task for doing that including necessary notifications to make sure all configurations are reloaded on any change:

- name: create container service
  ansible.builtin.template:
    src: container.j2
    dest: "{{ units_path }}/container-{{ container_name }}.service"
    mode: 0644
  notify:
    - reload daemon
    - restart pod service

Handlers

Reloads systemd daemon in order to load changes.

Makes sure the pod service is enabled so it starts on boot.

Restart the pod service. If unit files are generated using podman cli, all services for containers in the pod are dependant on pod service so when it restarts, so do container services. That way you can easily restart the whole pod with it's containers when some configuration is changed.

License

This template is licensed under the MIT license.

pod-template's People

Contributors

dusansimic avatar

Watchers

James Cloos 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.