Puppet - So installieren Sie Git 1.8.x, das nicht in den Standardpaketen enthalten ist

Puppet - So installieren Sie Git 1.8.x, das nicht in den Standardpaketen enthalten ist

Wie würden Sie die Installation einer bestimmten Git-Version mit Puppet automatisieren?

apt-get update && apt-get install git-coreauf meinem 12.04 Ubuntu-Server ergibt sich die Git-Version 1.7.9.
Ich muss 1.7.10 oder neuer haben.

Ich sehe zwei Möglichkeiten. 1. Fügen Sie das PPA hinzu.
2. Installieren Sie Git aus der Quelle.

Ich denke, das Hinzufügen eines PPA wäre einfacher als das Kompilieren aus dem Quellcode, also versuche ich das.

Ich habe versucht, mit demPuppetlabs/Apt-Modulum das Git-Core-PPA zu installieren, dennoch ist meine Git-Version nach dem Puppet-Lauf immer noch 1.7.9.

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

Antwort1

git-coreist nicht das Paket in diesem PPA – das Sie gitstattdessen möchten (und wahrscheinlich aus dem Ubuntu-Repo entfernen möchten git-core).

Antwort2

Wie Shane erwähnt hat, sollten Sie in der Paketdefinition gitstattdessen verwenden .git-core

Außerdem muss die Exec['apt-get update']Abhängigkeit nicht erstellt werden, da das Modul dies bereits übernimmt.

Code aus dem Modul:

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

Wenn Sie Git also immer auf dem neuesten Stand halten möchten, sollten Sie so etwas tun:

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

Und

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

verwandte Informationen