gpt4 book ai didi

debian - 使用 Ansible 使用 debconf-set-selections 自动化*仅* exim4 配置

转载 作者:行者123 更新时间:2023-12-02 09:17:51 25 4
gpt4 key购买 nike

我正在尝试在 Ansible 中自动执行 Debian 上的 exim4 配置 —— 到目前为止我们一直在手动配置 —— 但我陷入了正常运行的阶段 dpkg-reconfigure exim4-配置

我可以轻松地自动化这些步骤:

  • 更新conf文件:/etc/exim4/exim4-config.conf.conf
  • 运行dpkg-reconfigure --frontend noninteractive exim4-config

它们在剧本中运行良好,但问题是,并非我在交互式提示中看到的所有选项都在此conf文件中。例如,第二个设置系统邮件名称未在conf 文件中的任何位置指定。最后一个设置根和邮件管理员邮件收件人也不是,它在第​​一次配置后也停止显示在交互式提示中(这是为什么?)

然后我看到有些人建议使用 debconf-set-selections ( here ),我尝试对此进行研究 - 我安装了 debconf-utils 软件包并然后运行 ​​debconf-get-selections - 然后我看到了那里的所有选项,但现在我想知道是否有一种方法可以使用 debconf-set-selections 而无需使用一次设置所有所有设置的文件,因为我只想更改与 exim4 关联的值。我试图避免覆盖如果我需要再次运行剧本时可能设置的任何其他值(与 exim4 无关)。

缺少将 debconf-get-selections 的输出写入文件,然后使用 Ansible 的 lineinfile/template 模块来替换值我想改变,也许有更简单的方法吗?我宁愿避免这种方法。

最佳答案

有点晚了,但我建议你使用ansible debconf module (它基本上执行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

或者这个:

- name: Debconf question mailname
debconf: name='exim4-config'
question: 'exim4/mailname'
value: '{{ inventory_hostname }}'
vtype: string

但是,如果您重新配置 exim(配置一次后),那么您必须在执行dpkg-reconfigure之前删除2个文件,这是可以完成的使用这些命令:

- name: remove exim config files
file: path={{ item }} state=absent
with_items:
- "/etc/exim4/update-exim4.conf.conf"
- "/etc/mailname"

最后,执行dpkg-reconfigure,这也会重新启动 exim。

- name: Reconfigure package exim4-config
command: dpkg-reconfigure -fnoninteractive exim4-config

关于debian - 使用 Ansible 使用 debconf-set-selections 自动化*仅* exim4 配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38454367/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com