1

How would you automate the installation of a specific version of git using puppet?

apt-get update && apt-get install git-core on my 12.04 ubuntu server results in git version 1.7.9.
I must have 1.7.10 or newer.

There are two options that I can see. 1. Add the ppa
2. Install git from source

I think adding a ppa would be easier that compiling from source, so that is what I am attempting.

I've tried using the puppetlabs/apt module to install the git-core ppa, yet my git version is still 1.7.9 after the puppet run.

root@gitlab:~# puppet module list
/etc/puppet/modules
├── puppetlabs-apt (v1.2.0)
├── puppetlabs-git (v0.0.3)
├── puppetlabs-stdlib (v4.1.0)
└── ruby (???)


root@gitlab:~# cat /etc/puppet/manifests/git.pp  

class { 'apt': }
apt::ppa { 'ppa:git-core/ppa': 
  before => Exec['apt-get update'],

}

exec{'apt-get update':
  path => ['/usr/bin', '/usr/sbin'],
}

package {'git-core':
   ensure => latest,
   require => Exec['apt-get update'],
}

root@gitlab:~# puppet apply /etc/puppet/manifests/git.pp --verbose
Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/facter_dot_d.rb
Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/pe_version.rb
Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/puppet_vardir.rb
Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/root_home.rb
Warning: Config file /etc/puppet/hiera.yaml not found, using Hiera defaults
Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/facter_dot_d.rb
Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/pe_version.rb
Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/puppet_vardir.rb
Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/root_home.rb
Info: Applying configuration version '1379214336'
Notice: /Stage[main]//Exec[apt-get update]/returns: executed successfully
Notice: Finished catalog run in 5.80 seconds
root@gitlab:~# git --version
git version 1.7.9.5
1

git-core isn't the package in that PPA - you want git instead (and probably to remove git-core from the Ubuntu repo).

0

As Shane mentioned you should use git instead of git-core in the package definition.

Also there is no need to create the Exec['apt-get update'] dependency, because the module is already taking care of that.

Code from the module:

exec { "add-apt-repository-${name}":
  ...
  notify    => Exec['apt_update'],
  ...
}

So if you want to keep git up to date all the time you should do something like that:

class {'ntp': always_apt_update => true, }

and

package {'git':
 ensure => latest,
 require => Apt::Ppa['ppa:git-core/ppa'],
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.