
Puppet を使用して特定のバージョンの git のインストールを自動化するにはどうすればよいですか?
apt-get update && apt-get install git-core
私の 12.04 Ubuntu サーバーでは、git バージョン 1.7.9 になります。1.7.10
以降が必要です。
2つの選択肢があります。1. PPAを追加する
2. ソースからgitをインストールする
PPA を追加する方がソースからコンパイルするよりも簡単だと思うので、それを試しています。
私は使ってみましたpuppetlabs/apt モジュールgit-core ppa をインストールしましたが、puppet の実行後も git バージョンは 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
答え1
git-core
その PPA にはパッケージが含まれていません - 代わりに必要なパッケージですgit
(おそらくgit-core
Ubuntu リポジトリから削除する必要があります)。
答え2
Shane が述べたように、パッケージ定義ではgit
の代わりにを使用する必要があります。git-core
Exec['apt-get update']
また、モジュールがすでに依存関係を処理しているため、依存関係を作成する必要はありません。
モジュールからのコード:
exec { "add-apt-repository-${name}":
...
notify => Exec['apt_update'],
...
}
したがって、git を常に最新の状態に保ちたい場合は、次のようにする必要があります。
class {'ntp': always_apt_update => true, }
そして
package {'git':
ensure => latest,
require => Apt::Ppa['ppa:git-core/ppa'],
}