我刚刚开始使用 puppet(和 vagrant)为我们的团队设置开发环境,该团队由 8 名以上开发人员组成,每个开发人员都有自己特定的 bash 配置等。我已经安装了所有软件系统来快速部署新的开发虚拟机,但我不确定以自动化方式为每个特定用户设置开发环境的最佳方法(我们最终将拥有多个开发环境,编写一次会很方便并完成)。
比如我想设置一个用户joe
,从 github 克隆 Joe 的配置 repo,然后在该 github 存储库中运行一个脚本来为 Joe 设置环境。对于如何为 Joe 以及 Jimmy、James、Julie、Jane、Jim、Jake 和 Jimbo 执行此操作有什么建议吗?
如果有任何帮助,开发机器几乎肯定是 ubuntu 系统。
最佳答案
除了@Matt 的建议,我还创建了一个 custom puppet module它根据每个人的 github 偏好为每个人实例化配置环境。生成的 puppet 模块 users
看起来像这样:
users/
├── manifests
│ ├── init.pp # base level configurations for all users
│ ├── jake.pp # custom setup for jake
│ ├── james.pp # custom setup for james
│ ├── jane.pp # custom setup for jane
│ ├── jim.pp # custom setup for jim
│ ├── jimbo.pp # custom setup for joe
│ ├── jimmy.pp # custom setup for jimmy
│ ├── joe.pp # custom setup for julie
│ └── julie.pp # custom setup for jimbo
└── templates
相关花絮在每个用户的自定义设置文件中。例如,这里是
jim.pp
可能看起来像:class users::jim {
# make sure that all base configuration in init.pp is set up first
require users
# add the user here
user { 'jim':
# comment => 'Dean Malmgren',
home => '/home/jim',
shell => '/bin/bash',
uid => 201,
managehome => 'true',
groups => ['sudo', 'vagrant'],
provider => 'useradd',
password => '$6$kxHLEuHW$78m3zHVLu0XUUDaU4bT.PEg./FfcloJiWml',
}
# clone the repository the first time
exec { 'jim-clone-dotfiles':
command => 'git clone git://github.com/jim/dotfiles.git && python dotfiles/create_softlinks.py',
cwd => '/home/jim',
creates => '/home/jim/dotfiles',
user => 'jim',
group => 'jim',
require => [ Package['git'] ],
}
# fetch and update if jim decides to update his dotfiles repo
exec { 'jim-update-dotfiles':
command => 'git merge --ff-only origin/master && python create_softlinks.py',
cwd => '/home/jim/dotfiles',
unless => 'git fetch && git diff --exit-code origin/master',
user => 'jim',
group => 'jim',
require => Exec['jim-clone-dotfiles'],
}
}
关于vagrant - 如何使用 puppet 为不同用户设置自定义 bash 环境?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16732644/