Skip to content

Instantly share code, notes, and snippets.

@niallo
Created March 8, 2012 22:59
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niallo/2004001 to your computer and use it in GitHub Desktop.
Save niallo/2004001 to your computer and use it in GitHub Desktop.
Puppet module to install & set default Python to 2.7 on Ubuntu 10.04 LTS / Lucid
class python27 {
Package { ensure => "installed" }
$apt-base = "/etc/apt/sources.list.d/fkrull-"
Exec { require => Package["python-software-properties"] }
exec { "python-repo" :
command => "/usr/bin/add-apt-repository ppa:fkrull/deadsnakes",
creates => "${apt-base}deadsnakes-lucid.list",
}
$required-execs = [ "python-repo" ]
exec { "python-apt-ready" :
command => "/usr/bin/apt-get update",
require => Exec[$required-execs],
onlyif => "/usr/bin/test ! -x /usr/bin/python2.7"
}
package { [ "python2.7", "python2.7-dev", "build-essential", "pkg-config", "curl", "libssl-dev" ] :
require => Exec["python-apt-ready"]
}
exec { "make-default-python":
command => "/usr/sbin/update-alternatives --install /usr/bin/python python /usr/bin/python2.7 3",
require => Package["python2.7"],
onlyif => '/usr/bin/test "$(/usr/bin/python -c \'import sys; print sys.version_info[:2]\')" != "(2, 7)"'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment