jenkins-bot has submitted this change and it was merged.

Change subject: Improvements to apt bootstrapping
......................................................................


Improvements to apt bootstrapping

- Don't use stages to get PPAs and apt-get update to run first; instead rely on
  explicit relationships between resources and resource types.
- Use /vagrant/apt-cache as APT cache for quick VM re-creation.
- Make 'running' the default ensure for Service resource.

Change-Id: I19385f5e1e630af5a74cce6284e853a39fc7d62b
---
M .gitignore
M Vagrantfile
M puppet/manifests/base.pp
M puppet/manifests/roles.pp
M puppet/modules/apt/manifests/init.pp
5 files changed, 29 insertions(+), 26 deletions(-)

Approvals:
  Ori.livneh: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/.gitignore b/.gitignore
index 3edca45..98a04d4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,3 +14,5 @@
 !/puppet/manifests/manifests.d/dummy.pp
 /logs
 !/logs/puppet/.gitignore
+/apt-cache
+!/apt-cache/partial/.gitignore
diff --git a/Vagrantfile b/Vagrantfile
index 7b5a13c..efae4c4 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -95,7 +95,8 @@
 
         puppet.facter = {
             'virtualbox_version' => virtualbox_version,
-            'forwarded_port' => FORWARDED_PORT,
+            'shared_apt_cache'   => '/vagrant/apt-cache/',
+            'forwarded_port'     => FORWARDED_PORT,
         }
     end
 end
diff --git a/puppet/manifests/base.pp b/puppet/manifests/base.pp
index 008b9db..10ea5f0 100644
--- a/puppet/manifests/base.pp
+++ b/puppet/manifests/base.pp
@@ -11,15 +11,9 @@
 
 # By adding a stage => 'first' / 'last' parameter to your class
 # declaration, you can tell Puppet to instantiate the class (and its
-# resources) at the very beginning of its run or the very end. By
-# default, only the 'apt' class runs in a different stage, to ensure
-# other classes fetch the right packages. Everything else runs in 'main'.
-# For more information, see:
+# resources) at the very beginning of its run or the very end. See:
 # <http://docs.puppetlabs.com/puppet/2.7/reference/lang_run_stages.html>
-stage { 'first': }
-stage { 'last': }
-
-Stage['first'] -> Stage['main'] -> Stage['last']
+stage { 'first': } -> Stage['main'] -> stage { 'last': }
 
 # Declares a default search path for executables, allowing the path to
 # be omitted from individual resources. Also configures Puppet to log
@@ -29,7 +23,13 @@
     path      => [ '/bin', '/usr/bin', '/usr/local/bin', '/usr/sbin/' ],
 }
 
-Package { ensure => present, }
+Service {
+    ensure => running,
+}
+
+Package {
+    ensure => present,
+}
 
 # Declare default uid / gid and permissions for file resources, and
 # tells Puppet not to back up configuration files by default.
@@ -46,8 +46,10 @@
     mode   => '0755',
 }
 
-package { 'python-pip':
-    ensure => present,
-}
+package { 'python-pip': } -> Package <| provider == pip |>
 
-Package['python-pip'] -> Package <| provider == pip |>
+if $::shared_apt_cache {
+    file { '/etc/apt/apt.conf.d/20shared-cache':
+        content => "Dir::Cache::archives \"${::shared_apt_cache}\";\n",
+    } -> Package <| |>
+}
diff --git a/puppet/manifests/roles.pp b/puppet/manifests/roles.pp
index ff4f51f..83b943e 100644
--- a/puppet/manifests/roles.pp
+++ b/puppet/manifests/roles.pp
@@ -16,12 +16,10 @@
 # == Class: role::generic
 # Configures common tools and shell enhancements.
 class role::generic {
-    class { 'apt':
-        stage => first,
-    }
-    class { 'env': }
-    class { 'misc': }
-    class { 'git': }
+    include ::apt
+    include ::env
+    include ::git
+    include ::misc
 }
 
 # == Class: role::mediawiki
@@ -464,15 +462,13 @@
 
     @mediawiki::extension { 'Math':
         needs_update => true,
+        before       => Exec['compile texvc'],
     }
 
     exec { 'compile texvc':
         command => 'make',
-        cwd     => "/vagrant/mediawiki/extensions/Math/math",
-        creates => "/vagrant/mediawiki/extensions/Math/math/texvc",
-        require => [
-          Package['mediawiki-math', 'ocaml-native-compilers'],
-          Mediawiki::Extension['Math'],
-        ],
+        cwd     => '/vagrant/mediawiki/extensions/Math/math',
+        creates => '/vagrant/mediawiki/extensions/Math/math/texvc',
+        require => Package['mediawiki-math', 'ocaml-native-compilers'],
     }
 }
diff --git a/puppet/modules/apt/manifests/init.pp 
b/puppet/modules/apt/manifests/init.pp
index 18545cc..36ab772 100644
--- a/puppet/modules/apt/manifests/init.pp
+++ b/puppet/modules/apt/manifests/init.pp
@@ -21,4 +21,6 @@
         require => Exec['add wikimedia apt key'],
         notify  => Exec['apt-get update'],
     }
+
+    Apt::Ppa <| |> ~> Exec['apt-get update'] -> Package <| |>
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/85442
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I19385f5e1e630af5a74cce6284e853a39fc7d62b
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/vagrant
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to