lae / ansible-role-travis-lxc

Ansible role that prepares a Travis CI environment and creates LXC containers for testing roles.
MIT License
4 stars 2 forks source link

Integrated LXC container caching #25

Closed lae closed 6 years ago

lae commented 6 years ago

This moves caching tasks that we otherwise put in install and before_cache as separate (and in my experience inefficient) steps into the role itself.

To enable it, all we really need is to add the following into .travis.yml:

cache:
  directories:
  - "$HOME/lxc"

A different directory can be specified as well, but the lxc_cache_directory role variable must be updated as well.

Caching can be configured on a per profile basis with the lxc_cache_profiles role variable. A gzipped tarball is generated for each profile and stored in the lxc_cache_directory once base containers are built. On the next build, they are extracted prior to building the base containers. If any files have been modified, other than the ones we ignore in travis_lxc_profiles[profile].rootfs_exclude, then the tarball is repackaged - Travis will see this as a change and upload the new cache. Otherwise, Travis will not reupload the cache (thus saving on build time).