From ecbbd12e25d04010aafe45ba5a5cbe3b9b4f2c89 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Felix=20D=C3=B6rre?= Date: Tue, 14 Mar 2017 15:05:21 +0100 Subject: [PATCH] upd: copy base image instead of creating fresh This cuts down setup time from 60min to below 30min. Change-Id: I2441788336d91963328549586dd9ae8b6e481e2a --- modules/lxc/manifests/init.pp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/lxc/manifests/init.pp b/modules/lxc/manifests/init.pp index b0c64c4..07cf459 100644 --- a/modules/lxc/manifests/init.pp +++ b/modules/lxc/manifests/init.pp @@ -4,6 +4,12 @@ class lxc { } package{ 'lxc': ensure => 'installed' + }-> + exec {'lxc-base-image-created': + logoutput => on_failure, + command => '/usr/bin/lxc-create -n base-image -t debian -- -r stretch --packages=gnupg2,puppet,lsb-release,debconf-utils',# gnupg2 needed for puppet managing apt-keys + unless => '/usr/bin/test -d /var/lib/lxc/base-image', + timeout => '0' } define container ($contname, $ip, $dir = [], $bind = {}, $confline = []) { exec {"lxc-$contname-issue-cert": @@ -14,10 +20,10 @@ class lxc { exec{ "lxc-$contname-created": logoutput => on_failure, - command => "/usr/bin/lxc-create -n $contname -t debian -- -r stretch --packages=gnupg2", ## requires gnupg for puppet seed + command => "/usr/bin/lxc-copy -n base-image -N $contname", unless => "/usr/bin/test -d /var/lib/lxc/$contname", timeout => '0', - require => Package['lxc'], + require => [Package['lxc'],Exec['lxc-base-image-created']], } -> file_line {"lxc-$contname-conf1": path => "/var/lib/lxc/$contname/config", line => 'lxc.network.type = veth', -- 2.39.2