安装 gitolite 时我发现:
# aptitude install gitolite
The following NEW packages will be installed:
gitolite
0 packages upgraded, 1 newly installed, 0 to remove and 29 not upgraded.
Need to get 114 kB of archives. After unpacking 348 kB will be used.
Get:1 http://security.debian.org/ squeeze/updates/main gitolite all 1.5.4-2+squeeze1 [114 kB]
Fetched 114 kB in 0s (202 kB/s)
Preconfiguring packages ...
Selecting previously deselected package gitolite.
(Reading database ... 30593 files and directories currently installed.)
Unpacking gitolite (from .../gitolite_1.5.4-2+squeeze1_all.deb) ...
Setting up gitolite (1.5.4-2+squeeze1) ...
No adminkey given - not initializing gitolite in /var/lib/gitolite.
最后一行对我来说很有趣。如果我运行,dpkg-reconfigure -plow gitolite
将出现一个对话框,可以修改:
- gitolite 的系统用户名,
- gitolite 存储库的位置和
- 提供管理员公钥。
我更喜欢使用git
系统用户并在安装时提供管理员公钥,例如:
# aptitude install gitolite --user git --admin-pubkey 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDAc7kCAi2WkvqpAL1fK1sIw6xjpatJ+Ms2nrwLJPhdovEY3MPZF7mtH+rv1CHFDn66fLGiWevOFp...'
当然,这行不通。可以做类似的事情吗?如何提前确定配置参数?这将非常有用,例如,当通过 puppet 或 chef 自动安装 gitolite 时。
答案1
dpkg-reconfigure
我还没有测试过这个,但是我相信在示例机器上运行之后,你可以运行来获取设置的内容。(如果你没有它,debconf-get-selections | egrep "^gitolite\s"
它在包中)。debconf-utils
然后在 CLI 上,debconf-set-selections $FILENAME
运行 apt 之前。
然后使用 puppet 将会是这样的:
file {
"/var/cache/debconf/gitolite.preseed":
source => '...'; # someplace with that output
}
package {
"gitolite":
require => File["/var/cache/debconf/gitolite.preseed"],
responsefile => "/var/cache/debconf/gitolite.preseed";
}
有关 puppet 网站的更多信息:
- https://projects.puppetlabs.com/projects/1/wiki/Debian_Preseed_Patterns
- https://projects.puppetlabs.com/projects/1/wiki/Debian_Patterns
- https://puppet.com/docs/puppet/7/types/package.html
我怀疑 Chef 有一个类似的机制来指定响应文件或预置文件或类似的东西,但我不是 Chef 用户。
答案2
答案3
我正在寻找一种方法来使用 Ubuntu 上的 ttf-mscorefonts-installer 包来实现这一点。使用上述说明,我得到了这个 puppet 配方:
# this is a preseed file which makes it answer the accept EULA when it asks
# got this content this way: apt install debconf-utils and then run this: debconf-get-selections | grep ttf-mscorefonts-installer
file {
"/var/cache/debconf/ttf-mscorefonts-installer.preseed":
content => "\
ttf-mscorefonts-installer msttcorefonts/baddldir error\n\
ttf-mscorefonts-installer msttcorefonts/dldir string\n\
ttf-mscorefonts-installer msttcorefonts/present-mscorefonts-eula note\n\
ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula boolean true\n\
ttf-mscorefonts-installer msttcorefonts/error-mscorefonts-eula error\n\
ttf-mscorefonts-installer msttcorefonts/dlurl string\n"
}
package { "ttf-mscorefonts-installer":
ensure => installed,
require => File["/var/cache/debconf/ttf-mscorefonts-installer.preseed"],
responsefile => "/var/cache/debconf/ttf-mscorefonts-installer.preseed"
}