Answers:
Yum支持插件,因此完全有可能编写一个插件来读取缓存的人偶清单并警告事务何时将覆盖人偶控制的文件。我不知道有一个现成的插件可以做到这一点,但是我可能会写一个自己写的,因为我喜欢这个想法。
该插件检查所有新安装/升级/降级的软件包,告诉您它将覆盖哪些人偶管理的文件,并要求您确认。
[root@camel ~]# yum update pam
Loaded plugins: puppet, security
Skipping security plugin, no data
Setting up Update Process
Resolving Dependencies
Skipping security plugin, no data
--> Running transaction check
---> Package pam.i386 0:0.99.6.2-12.el5 set to be updated
---> Package pam.x86_64 0:0.99.6.2-12.el5 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================================================================================================================
Package Arch Version Repository Size
===============================================================================================================================================================
Updating:
pam i386 0.99.6.2-12.el5 base 983 k
pam x86_64 0.99.6.2-12.el5 base 982 k
Transaction Summary
===============================================================================================================================================================
Install 0 Package(s)
Upgrade 2 Package(s)
Total download size: 1.9 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): pam-0.99.6.2-12.el5.x86_64.rpm | 982 kB 00:00
(2/2): pam-0.99.6.2-12.el5.i386.rpm | 983 kB 00:00
---------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 8.7 MB/s | 1.9 MB 00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing pam-0.99.6.2-12.el5.i386 overwrites puppet-managed file /etc/pam.d/system-auth
Installing pam-0.99.6.2-12.el5.i386 overwrites puppet-managed file /etc/security/access.conf
Installing pam-0.99.6.2-12.el5.i386 overwrites puppet-managed file /etc/security/limits.conf
Installing pam-0.99.6.2-12.el5.x86_64 overwrites puppet-managed file /etc/pam.d/system-auth
Installing pam-0.99.6.2-12.el5.x86_64 overwrites puppet-managed file /etc/security/access.conf
Installing pam-0.99.6.2-12.el5.x86_64 overwrites puppet-managed file /etc/security/limits.conf
Is this ok [y/N]: n
Aborting
[root@camel ~]# yum update pam
Loaded plugins: puppet, security
Skipping security plugin, no data
Setting up Update Process
Resolving Dependencies
Skipping security plugin, no data
--> Running transaction check
---> Package pam.i386 0:0.99.6.2-12.el5 set to be updated
---> Package pam.x86_64 0:0.99.6.2-12.el5 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================================================================================================================
Package Arch Version Repository Size
===============================================================================================================================================================
Updating:
pam i386 0.99.6.2-12.el5 base 983 k
pam x86_64 0.99.6.2-12.el5 base 982 k
Transaction Summary
===============================================================================================================================================================
Install 0 Package(s)
Upgrade 2 Package(s)
Total size: 1.9 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing pam-0.99.6.2-12.el5.i386 overwrites puppet-managed file /etc/pam.d/system-auth
Installing pam-0.99.6.2-12.el5.i386 overwrites puppet-managed file /etc/security/access.conf
Installing pam-0.99.6.2-12.el5.i386 overwrites puppet-managed file /etc/security/limits.conf
Installing pam-0.99.6.2-12.el5.x86_64 overwrites puppet-managed file /etc/pam.d/system-auth
Installing pam-0.99.6.2-12.el5.x86_64 overwrites puppet-managed file /etc/security/access.conf
Installing pam-0.99.6.2-12.el5.x86_64 overwrites puppet-managed file /etc/security/limits.conf
Is this ok [y/N]: y
Updating : pam 1/4
Updating : pam 2/4
Cleanup : pam 3/4
Cleanup : pam 4/4
Updated:
pam.i386 0:0.99.6.2-12.el5 pam.x86_64 0:0.99.6.2-12.el5
Complete!
该插件本身可以在我的github hacks存储库中找到。
2013年11月8日更新:
正如评论中所暗示的那样,我现在已将其变成一个更大的项目,以改善Yum和Puppet之间的交互。您可以在GitHub上找到它。
是的,有可能,但与人偶本身无关。
Linux系统支持inotify机制,该机制“可用于监视文件系统事件并对其进行操作”。除此以外,inotify-tools
还有一个incron
程序与cron类似,但它会对文件系统事件做出反应。我认为您可以使用它来接收有关更改任何文件的通知。
(顺便说一句,如果您想观看/etc/sysctl.conf
文件,我建议在执行之前检查一下-您的Linux是否支持/etc/sysctl.d
目录?)
我不知道实现此类通知的方法。通过暂存yum事务,确定可能受影响的配置文件列表,然后检查是否由puppet管理,可以进行设置。
但是,一般来说,管理将由软件包更新的文件不是一个好习惯。对于配置文件(使用rpm -qlc软件包名称查看是否被标记为此类),如果软件包包含新版本,则将其另存为filename.rpmnew。然后,您将留在自己的设备上以合并任何需要的更改。
我们遇到了一个问题,即在更新软件包时,puppet删除了一个配置文件,然后将其替换为yum。这会导致问题,直到下一个木偶运行删除文件为止。在这种情况下,我们的解决方法是将“已删除”文件的内容设置为注释,因此该文件基本上为空。处理它的另一种方法是尝试确保Package ['a']-> File ['/ etc / a'],以便只运行一次木偶。