bug 1463592 - add an /etc/pip.conf to servers. r=bhearsum
authorAki Sasaki <asasaki@mozilla.com>
Tue, 22 May 2018 18:44:18 -0700
changeset 6921 4ce48f49cd8832688f860a27cd62cb4a585dd53f
parent 6920 12c2bedb12e8390aea9e425b3348e39a93b05fba
child 6922 23db99a37be5f65f5c4a7d0d795b1f53ff5668a4
push id2778
push userasasaki@mozilla.com
push dateTue, 29 May 2018 19:35:39 +0000
reviewersbhearsum
bugs1463592
bug 1463592 - add an /etc/pip.conf to servers. r=bhearsum MozReview-Commit-ID: BRzvmshnJRx
modules/python/manifests/system_pip_conf.pp
modules/toplevel/manifests/server.pp
modules/toplevel/manifests/worker.pp
new file mode 100644
--- /dev/null
+++ b/modules/python/manifests/system_pip_conf.pp
@@ -0,0 +1,46 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+class python::system_pip_conf {
+    include config
+
+    # for the template
+    $user_python_repositories = $config::user_python_repositories
+    case $::operatingsystem {
+        "CentOS": {
+            $filename = "/etc/pip.conf"
+            $user     = "root"
+            $group    = "root"
+        }
+        "Ubuntu": {
+            $filename = "/etc/pip.conf"
+            $user     = "root"
+            $group    = "root"
+        }
+        "Darwin": {
+            $filename = "/Library/Application Support/pip/pip.conf"
+            $user     = "root"
+            $group    = "wheel"
+        }
+        "windows": {
+            $filename = $::operatingsystemrelease ? {
+                XP => "C:\\Documents and Settings\\All Users\\Application Data\\pip\\pip.ini",
+                default => "C:\\ProgramData\\pip\\pip.ini",
+            }
+            $user     = "administrator"
+            $group    = "administrator"
+        }
+        default: {
+            fail("This OS is not supported for system_pip_conf")
+        }
+    }
+    if $filename {
+        file {
+            "${filename}":
+                content => template("python/user-pip-conf.erb"),
+                owner   => $user,
+                group   => $group,
+                mode    => "0755";
+        }
+    }
+}
--- a/modules/toplevel/manifests/server.pp
+++ b/modules/toplevel/manifests/server.pp
@@ -20,16 +20,17 @@ class toplevel::server inherits toplevel
     include nrpe::check::ide_smart
     include nrpe::check::puppet_freshness
     include packages::strace
     include packages::netcat
     include users::people
     include ::config
     include packages::security_updates
     include packages::security_updates_1433165
+    include python::system_pip_conf
 
     if ($::config::enable_mig_agent) {
         case $::operatingsystem {
             # Darwin support is coming soon
             'CentOS', 'RedHat', 'Ubuntu', 'Darwin': {
                 include mig::agent::daemon
             }
         }
--- a/modules/toplevel/manifests/worker.pp
+++ b/modules/toplevel/manifests/worker.pp
@@ -4,16 +4,17 @@
 
 # All TaskCluster workers are subclasses of this class.
 
 class toplevel::worker inherits toplevel::base {
     include disableservices::slave
     include puppet::atboot
     include sudoers::reboot
     include users::builder
+    include python::system_pip_conf
 
     # apply tweaks
     include tweaks::dev_ptmx
     include tweaks::locale
 
     # common packages
     include packages::curl
     include packages::virtualenv