Giter Club home page Giter Club logo

distgen's Introduction

Distribution oriented templating system

Build Status Coverage Status Documentation Status

The problem this project tries to mitigate is "portable" scripting for variety of operating systems (currently Linux distributions only) in the wild. While writing an "universal" script, one needs to take into account small or bigger differences among operating systems (like package installation tools, versions of utilities, expected directories for binaries, libraries, etc.).

The distgen project is thus something like database of OS differences together with convenience tool-set that allows you to instantiate valid script for particular distribution. The concept is to have template file (mostly raw jinja2 template) together with "declarative" spec file (YAML file) that fulfils the needs of particular template.

You can find distgen documentation at http://distgen.readthedocs.io.

Download/Installation

Stable releases of distgen are available as RPMs in Fedora and EPEL repositories, and in pypi:

$ sudo dnf install distgen

$ pip install distgen

Development (git snapshot) RPMs are automatically built in Fedora Copr.

You can also run development version directly from git, simply use the dg shell wrapper available in this git root directory.

Example with Dockerfile

Typical example is the need to instantiate working FOO package oriented Dockerfiles for all supported Fedora/RHEL versions.

To achieve that goal with distgen, you need to write something like docker.tpl template and FOO.yaml spec file. If the system-default docker.tpl template is good enough, its enough to write proper spec file:

  1. create FOO.yaml spec:

    $ cat FOO.yaml
    maintainer: John Doe <[email protected]>
    parts:
      pkginstall:
        data:
          - type: pkg
            action: install
            packages:
              - vim
      footer:
        cmd: ["vim"]
    
  2. Run dg tool to generate Fedora 22 Dockerfile:

    $ dg --template docker.tpl \
         --spec FOO.yaml \
         --distro fedora-22-x86_64.yaml \
    > Dockerfile
    $ cat Dockerfile
    FROM index.docker.io/fedora:22
    MAINTAINER John Doe <[email protected]>
    
    ENV container="docker"
    
    RUN dnf -y --setopt=tsflags=nodocs install vim \
        && dnf -y --setopt=tsflags=nodocs clean all --enablerepo='*'
    
    CMD ["vim"]
    
  3. Run dg tool again to generate RHEL 7 dockerfile:

    $ dg --template docker.tpl \
         --spec FOO.yaml \
         --distro rhel-7-x86_64.yaml \
    > Dockerfile
    $ cat Dockerfile
    FROM registry.access.redhat.com/rhel7
    MAINTAINER John Doe <[email protected]>
    
    ENV container="docker"
    
    RUN yum -y --setopt=tsflags=nodocs install vim \
        && yum -y --setopt=tsflags=nodocs clean all --enablerepo='*'
    
    CMD ["vim"]
    

distgen's People

Contributors

praiskup avatar tomastomecek avatar mcyprian avatar ashcrow avatar dhodovsk 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.