3ch*_*eel 5 debian exim4 configuration-files ansible
我正在尝试在 Ansible 中对 Debian 上的 exim4 配置进行自动化——到目前为止我们一直在手动配置——但我被困在我正常运行的阶段dpkg-reconfigure exim4-config。
我可以很容易地自动化这些步骤:
/etc/exim4/exim4-config.conf.conf dpkg-reconfigure --frontend noninteractive exim4-config它们在剧本中运行良好,但问题是并非我在交互式提示中看到的所有选项都在此 conf 文件中。例如,第二个设置System mail name没有在 conf 文件中的任何地方指定。也不是最后一个设置,Root and postmaster mail recipient在第一次配置后也不再显示在交互式提示中(为什么?)
然后我看到有些人建议使用debconf-set-selections(here),我尝试调查 - 我安装了debconf-utils软件包然后运行debconf-get-selections- 然后我看到了那里的所有选项,但现在我想知道是否有一种方法可以debconf-set-selections不用不必使用文件组所有的一次性设置,因为我只是想改变的话用exim4关联的值。如果我需要再次运行剧本,我试图避免覆盖可能设置的任何其他值(与 exim4 无关)。
除了将 的输出写入debconf-get-selections文件然后使用 Ansible 的lineinfile/template模块替换我想要更改的值之外,是否有更简单的方法来解决这个问题?我宁愿避免这种方法。
小智 5
有点晚了,但我建议您使用 ansible debconf 模块(它基本上是一个debconf-set-selections)。
像这个例子:
- name: Debconf question dc_eximconfig_configtype
debconf: name='exim4-config'
question: 'exim4/dc_eximconfig_configtype'
value: 'internet site; mail is sent and received directly using SMTP'
vtype: select
Run Code Online (Sandbox Code Playgroud)
或者这个:
- name: Debconf question mailname
debconf: name='exim4-config'
question: 'exim4/mailname'
value: '{{ inventory_hostname }}'
vtype: string
Run Code Online (Sandbox Code Playgroud)
但是,如果您正在重新配置exim(在您配置一次之后),那么您必须在执行 a 之前删除 2 个文件dpkg-reconfigure,可以使用以下命令来完成:
- name: remove exim config files
file: path={{ item }} state=absent
with_items:
- "/etc/exim4/update-exim4.conf.conf"
- "/etc/mailname"
Run Code Online (Sandbox Code Playgroud)
最后,执行 a dpkg-reconfigure,它也重新启动 exim。
- name: Reconfigure package exim4-config
command: dpkg-reconfigure -fnoninteractive exim4-config
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1748 次 |
| 最近记录: |