From 754d3c15396fdcc9f05214434e25f1922bab8f96 Mon Sep 17 00:00:00 2001 From: Yolanda Robla Date: Fri, 27 Mar 2015 13:02:38 +0100 Subject: [PATCH] Add the ability to set pip.conf and configure it Create an initial pip.conf file and allow passing several settings such as index url and trusted hosts. Change-Id: I78962555c9a9ec1a96ce19810a463a5d619b04f9 --- manifests/init.pp | 16 +++++++++++++++- templates/pip.conf.erb | 8 ++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 templates/pip.conf.erb diff --git a/manifests/init.pp b/manifests/init.pp index 731691e..1e210f1 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,10 +1,24 @@ # Class: pip # -class pip { +class pip ( + $index_url = 'https://pypi.python.org/simple', + $trusted_hosts = [], + $manage_pip_conf = false, +) { include pip::params + validate_array($trusted_hosts) package { $::pip::params::python_devel_package: ensure => present, } + if $manage_pip_conf { + file { '/etc/pip.conf': + owner => 'root', + group => 'root', + mode => '0444', + content => template('pip/pip.conf.erb'), + replace => true, + } + } } diff --git a/templates/pip.conf.erb b/templates/pip.conf.erb new file mode 100644 index 0000000..c0b957d --- /dev/null +++ b/templates/pip.conf.erb @@ -0,0 +1,8 @@ +[global] +index-url = <%= @index_url %> +<% if trusted_hosts.length > 0 -%> +trusted-host = +<% @trusted_hosts.each do |trusted_host| -%> + <%= trusted_host %> +<% end -%> +<% end -%>