Giter VIP home page Giter VIP logo

salt-image-builder's Introduction

Dockerfile and script to build salt images to speed up testing

https://travis-ci.com/netmanagers/salt-image-builder.svg?branch=master

This repo holds a script to build docker images with salt-minion/salt-solo pre-installed so testing Salt formulas is faster/easier, as all the basic requirements (salt, git, etc) are pre-installed in these images, allowing you to skip all the bootstrap process in the image you use.

These are based in dockerhub upstream's images for each distro supported.

The images are tested with Testinfra before commiting, to check salt got installed with the desired version and the dependencies are satisfied.

Images maintained

The distros matrix is maintained for the lastest two, not EOL'ed, major distros versions. If you need to build a version not supported in the distributed .travis.yml file, just modify it (check the env.jobs section), add the combination that suits your needs and add or reuse a suitable Dockerfile.<os_package_manager> to perform the build.

The EOLs can be checked here:

Requirements

This new version of the repo builds directly in Travis-CI. There's a silly python script to allow building the images locally if you want to. To run it, you need

  • Python3
  • Docker (ce is OK)
  • Latest Testinfra installed (>= 4.1.0)

Basic usage of the builder scripts

  1. Edit .travis.yml. Check the matrix of images to build in the section env.jobs. The generic format is
DN=distro_name DV=distro_version PI=packages_installer SV=salt_version SIM=salt_install_method PV=python_version EP="extra list of packages to install between quotes whitespace-separated"

like

- DN=amazonlinux DV=2 PI=yum SV=2018.3 SIM=stable PV=2 EP="yum-utils python-pip procps-ng"
- DN=centos DV=8 PI=rpm SV=master SIM=git PV=3 EP="epel-release python3 python3-pip python3-devel openssl-devel swig"

empty lines or lines starting with # will be ignored (you can install travis gem locally and run travis list on the file to check syntax)

  1. Run ./build.py and take a coffee while building.
  2. When it finishes, you can run docker images and you'll see the new images created, like
REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
salt-py2/centos-7       2019.2              bea6a547bd78        6 minutes ago       475MB
salt-py3/ubuntu-18.04   2019.2              b3660626bf24        11 minutes ago      329MB
salt-py3/debian-9       2019.2              5bd9384b94ee        14 minutes ago      269MB

How to use the images

Just edit your kitchen.local.yml file, and add the image you want to use, like

driver:
  name: docker
  use_sudo: false
  remove_images: true
  run_command: /lib/systemd/systemd
  privileged: true
  volume:
    - "/sys/fs/cgroup:/sys/fs/cgroup:ro"

provisioner:
  salt_install: none

platforms:
  - name: debian-9
    driver_config:
      image: salt-2019.2-py3:debian-9
  - name: ubuntu-16.04
    driver_config:
      image: salt-2018.3-py2:ubuntu-16.04

TODO

Lots. This is just an initial attempt. Any suggestion/contribution is welcomed :)

salt-image-builder's People

Contributors

baby-gnu avatar dafyddj avatar ijansky avatar itjamie avatar javierbertoli avatar jeff350 avatar myii avatar sblaisot avatar semantic-release-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

salt-image-builder's Issues

Build images for Vagrant

Hi there! It would be nice to have auto-generated Vagrant images to test with Kitchen Vagrant.

Some formulas are almost impossible to test with Docker (at least nfs and syslog-ng) so we should use Vagrant to test them. I've read that Vagrant don't work on Travis but works on Cirrus.

I'm working on a full Vagrant Kitchen file for syslog-ng formula

cc @myii

Add support for AmazonLinux/python3

It seems it can be installed using packages, so we should try to see if either the bootstrap supports it, or we should add the repo directly.

Showstopper bug in 2019.2.1

I don't know if these images are automatically rebuilt on a schedule but there is a showstopper bug in 2019.2.1 which will cause formula tests to fail when running against the latest version of Salt, (see saltstack/salt#54765) and I feel it may be best not to roll out that version.

`'pip.installed' is not available` on `centos-6`

https://travis-ci.org/myii/django-formula/jobs/616733137#L788-L794

       [DEBUG   ] Failed to import module pip:
       Traceback (most recent call last):
         File "/usr/lib/python2.7/site-packages/salt/loader.py", line 1440, in _load_module
           mod = imp.load_module(mod_namespace, fn_, fpath, desc)
         File "/usr/lib/python2.7/site-packages/salt/modules/pip.py", line 86, in <module>
           import pkg_resources
       ImportError: No module named pkg_resources

https://travis-ci.org/myii/django-formula/jobs/616733137#L950-L958

       local:
       ----------
                 ID: django_pip
           Function: pip.installed
               Name: Django
             Result: False
            Comment: State 'pip.installed' was not found in SLS 'django.pip'
              Reason: 'pip.installed' is not available.
            Changes: 

https://stackoverflow.com/questions/7446187/no-module-named-pkg-resources

  • Tried out some of the answers here but didn't make any progress

travis + opensuse repos are not playing well together

Stating with PR saltstack-formulas/postgres-formula#262 and then in the https://github.com/saltstack-formulas/template-formula/, @myii found that the opensuse instances were failing and/or timing out in travis runs but not when run locally.

Running them in debug mode, it seems that there's an issue with the GEO-repositories download.opensuse.org chooses for the US.

This is what I see:

  1. When travis runs the install command, bundle exec kitchen verify default-opensuse-leap-15-2019-2-py3, it triggers a kitchen run. Which then begins the provision of the VM via kitchen-docker
  2. kitchen-docker has a 'hardcoded' provisioning stage, which in our case is running a zypper install command before even getting to any of our kitchen-salt commands. So we cannot tweak the repos at the beginning of the provisioning because kitchen-docker does not provide any pre-provision commands
  3. When doing this initial provisioning, download.opensuse.org is trying to use some US geo-repos, which are failing (ie, us.opensuse.org was used in one case and it can't even be found with a dig command).

To verify it, I did this:

  1. Launched a debug run on job on the postgresql-formula
  2. SSH'ed to the instance
  3. Run
travis_run_before_install
  1. Edited the suspect file
cd
vi ./.rvm/gems/ruby-2.4.1/gems/kitchen-docker-2.9.0/lib/kitchen/driver/docker.rb

and added, before the RUN zypper install -y sudo openssh which curl command, the following lines:

  WORKDIR /etc/zypp/repos.d
  RUN for f in *; do sed -i "s#download.opensuse.org#mirror.23media.com/opensuse#g" $f; done
  1. Then went back to the formula dir and run the kitchen test
  cd -
  bundle exec kitchen verify default-opensuse-leap-15-2019-2-py3
  1. The test finished successfully in <2 minutes
-----> Kitchen is finished. (1m54.71s)

As we can't modify these parameters at run time, we should try to modify the opensuse/leap instances to forcedfully use another repo (ie, a .de one)

feature request

I would like to test ubuntu,16.04,2019.2,stable,3

is it possible to bring this to upstream's images ?

Thanks and Regards

`'pkgrepo' __virtual__ returned False` for `fedora-30-2017-7-py2`

Gave most of the matrix a pretty solid test:

While I got the other two working in a subsequent run, the error for default-fedora-30-2017-7-py2 is a bit deeper:

            Comment: State 'pkgrepo.managed' was not found in SLS 'varnish.ng.repo'
             Reason: 'pkgrepo' __virtual__ returned False

Not specific to fedora-30, since default-fedora-30-2018-3-py3 is working fine.

So in terms of:

- DN=fedora DV=30 PI=dnf SV=2017.7 SIM=git PV=2 EP="python-pip"

Perhaps building with stable instead?

Split travis matrix in a way that it can improve build time

As discussed with @myii , travis is currently using a VM per build so, even if we're running 3 builds at a time, we're not reusing docker layers and caches.

We should try to split the matrix either by OS or OS/SALT_VERSION/PY_VERSION to see if reusing layers improve building.

`NameError: name 'pip' is not defined` on `opensuse-leap-42-2018-3-py2`

Following on from #2, tried opensuse-leap-42-2018-3-py2 instead. Ended up with a different error, even after retrying.

https://travis-ci.com/myii/postgres-formula/builds/110123552#L1135

       [ERROR   ] Failed to import states pip_state, this is due most likely to a syntax error:
       Traceback (most recent call last):
         File "/usr/lib/python2.7/site-packages/salt/loader.py", line 1534, in _load_module
           mod = imp.load_module(mod_namespace, fn_, fpath, desc)
         File "/usr/lib/python2.7/site-packages/salt/states/pip_state.py", line 63, in <module>
           del pip
       NameError: name 'pip' is not defined

Strange, because 2017.7 is working fine:

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.