[英]Installing Exim4 in Ubuntu using 'ansible-playbook'
I am trying to install Exim4 in Ubuntu using the playbook.我正在尝试使用剧本在 Ubuntu 中安装 Exim4。 But getting error.
但是出现错误。 I am in the process of learning an
ansible-playbook
and it would be great if someone could help here how to achieve this.我正在学习一本
ansible-playbook
,如果有人可以在这里帮助实现这一目标,那就太好了。 My Ansible book look like this我的 Ansible 书看起来像这样
- name: installing exim4.
remote_user: ubuntu
become: true
hosts: sample
tasks:
- name: Update apt repo and cache on all Debian/Ubuntu boxes
apt: update_cache=yes force_apt_get=yes cache_valid_time=3600
- name: Upgrade all packages on servers
apt: upgrade=dist force_apt_get=yes
- name: Check if a reboot is needed on all servers
register: reboot_required_file
stat: path=/var/run/reboot-required get_md5=no
- name: Reboot the box if kernel updated
reboot:
msg: "Reboot initiated by Ansible for kernel updates"
connect_timeout: 5
reboot_timeout: 300
pre_reboot_delay: 0
post_reboot_delay: 30
test_command: uptime
when: reboot_required_file.stat.exists
- name: Installing Exim4.
ansible.builtin.expect:
command: dpkg-reconfigure exim4-config
responses:
General type of mail configuration: 'internet site; mail is sent and received directly using SMTP'
System mail name: 'ok-golen.yoursitetobe.com'
IP-addresses to listen on for incoming SMTP connections: '127.0.0.1 ; ::1'
Other destinations for which mail is accepted: 'golden-image'
Domains to relay mail for: ''
Machines to relay mail for: ''
Keep number of DNS-queries minimal (Dial-on-Demand)?: 'No'
Delivery method for local mail: 'Maildir format in the home directory'
Split configuration into small files?: 'No'
Root and postmaster mail recipient: 'root'
I am not sure this is the right way.我不确定这是正确的方法。 Any other alternate way is also appreciated.
任何其他替代方式也很受欢迎。 I am getting the below error.
我收到以下错误。
fatal: [server1]: FAILED! => {"changed": true, "cmd": "dpkg-reconfigure exim4-config", "delta": "0:00:29.323447", "end": "2022-02-23 16:47:09.332278", "msg": "command exceeded timeout", "rc": null, "start": "2022-02-23 16:46:40.008831", "stdout": "\u001b[?1049h\u001b[22;0;0t\u001b[1;24r\u001b[4l\u001b[?25l\u001b(B\u001b[m\u001b[37m\u001b[40m\u001b[1;24r\u001b[H\u001b[2J\u001b[1;1H\u001b[1m\u001b[37m\u001b[45m \u001b[2;1H \u001b[3;1H \u001b[4;1H \u001b[5;1H \u001b[6;1H \u001b[7;1H \u001b[8;1H \u001b[9;1H \u001b[10;1H \u001b[11;1H \u001b[12;1H \u001b[13;1H \u001b[14;1H \u001b[15;1H \u001b[16;1H \u001b[17;1H \u001b[18;1H \u001b[19;1H \u001b[20;1H \u001b[21;1H \u001b[22;1H \u001b[23;1H \u001b[24;1H \u001b[24;79H \b\u001b[4h \u001b[4l\u001b[1;1H\u001b(B\u001b[m\u001b[37m\u001b[45mPackage configuration\u001b[4;2H\u001b[30m\u001b[47m┌───────────────────────┤ \u001b[31mMail Server configuration\u001b[30m ├───────────────────────┐\u001b[5;2H│ │\u001b[1m\u001b[37m\u001b[40m \u001b[6;2H\u001b(B\u001b[m\u001b[30m\u001b[47m│ Please select the mail server configuration type that best meets your │\u001b[1m\u001b[37m\u001b[40m \u001b[7;2H\u001b(B\u001b[m\u001b[30m\u001b[47m│ needs. │\u001b[1m\u001b[37m\u001b[40m \u001b[8;2H\u001b(B\u001b[m\u001b[30m\u001b[47m│ │\u001b[1m\u001b[37m\u001b[40m \u001b[9;2H\u001b(B\u001b[m\u001b[30m\u001b[47m│ Systems with dynamic IP addresses, including dialup systems, should │\u001b[1m\u001b[37m\u001b[40m \u001b[10;2H\u001b(B\u001b[m\u001b[30m\u001b[47m│ generally be configured to send outgoing mail to another machine, called │\u001b[1m\u001b[37m\u001b[40m \u001b[11;2H\u001b(B\u001b[m\u001b[30m\u001b[47m│ a 'smarthost' for delivery because many receiving systems on the │\u001b[1m\u001b[37m\u001b[40m \u001b[12;2H\u001b(B\u001b[m\u001b[30m\u001b[47m│ Internet block incoming mail from dynamic IP addresses as spam │\u001b[1m\u001b[37m\u001b[40m \u001b[13;2H\u001b(B\u001b[m\u001b[30m\u001b[47m│ protection. │\u001b[1m\u001b[37m\u001b[40m \u001b[14;2H\u001b(B\u001b[m\u001b[30m\u001b[47m│ │\u001b[1m\u001b[37m\u001b[40m \u001b[15;2H\u001b(B\u001b[m\u001b[30m\u001b[47m│ A system with a dynamic IP address can receive its own mail, or local │\u001b[1m\u001b[37m\u001b[40m \u001b[16;2H\u001b(B\u001b[m\u001b[30m\u001b[47m│ delivery can be disabled entirely (except mail for root and postmaster). │\u001b[1m\u001b[37m\u001b[40m \u001b[17;2H\u001b(B\u001b[m\u001b[30m\u001b[47m│ │\u001b[1m\u001b[37m\u001b[40m \u001b[18;2H\u001b(B\u001b[m\u001b[30m\u001b[47m│ \u001b[37m\u001b[41m<Ok>\u001b[30m\u001b[47m │\u001b[1m\u001b[37m\u001b[40m \u001b[19;2H\u001b(B\u001b[m\u001b[30m\u001b[47m│ │\u001b[1m\u001b[37m\u001b[40m \u001b[20;2H\u001b(B\u001b[m\u001b[30m\u001b[47m└───────────────────────────────────────────────────────────────────────────┘\u001b[1m\u001b[37m\u001b[40m \u001b[21;3H \u001b[18;38H", "stdout_lines": ["\u001b[?1049h\u001b[22;0;0t\u001b[1;24r\u001b[4l\u001b[?25l\u001b(B\u001b[m\u001b[37m\u001b[40m\u001b[1;24r\u001b[H\u001b[2J\u001b[1;1H\u001b[1m\u001b[37m\u001b[45m \u001b[2;1H \u001b[3;1H \u001b[4;1H \u001b[5;1H \u001b[6;1H \u001b[7;1H \u001b[8;1H \u001b[9;1H \u001b[10;1H \u001b[11;1H \u001b[12;1H \u001b[13;1H \u001b[14;1H \u001b[15;1H \u001b[16;1H \u001b[17;1H \u001b[18;1H \u001b[19;1H \u001b[20;1H \u001b[21;1H \u001b[22;1H \u001b[23;1H \u001b[24;1H \u001b[24;79H \b\u001b[4h \u001b[4l\u001b[1;1H\u001b(B\u001b[m\u001b[37m\u001b[45mPackage configuration\u001b[4;2H\u001b[30m\u001b[47m┌───────────────────────┤ \u001b[31mMail Server configuration\u001b[30m ├───────────────────────┐\u001b[5;2H│ │\u001b[1m\u001b[37m\u001b[40m \u001b[6;2H\u001b(B\u001b[m\u001b[30m\u001b[47m│ Please select the mail server configuration type that best meets your │\u001b[1m\u001b[37m\u001b[40m \u001b[7;2H\u001b(B\u001b[m\u001b[30m\u001b[47m│ needs. │\u001b[1m\u001b[37m\u001b[40m \u001b[8;2H\u001b(B\u001b[m\u001b[30m\u001b[47m│ │\u001b[1m\u001b[37m\u001b[40m \u001b[9;2H\u001b(B\u001b[m\u001b[30m\u001b[47m│ Systems with dynamic IP addresses, including dialup systems, should │\u001b[1m\u001b[37m\u001b[40m \u001b[10;2H\u001b(B\u001b[m\u001b[30m\u001b[47m│ generally be configured to send outgoing mail to another machine, called │\u001b[1m\u001b[37m\u001b[40m \u001b[11;2H\u001b(B\u001b[m\u001b[30m\u001b[47m│ a 'smarthost' for delivery because many receiving systems on the │\u001b[1m\u001b[37m\u001b[40m \u001b[12;2H\u001b(B\u001b[m\u001b[30m\u001b[47m│ Internet block incoming mail from dynamic IP addresses as spam │\u001b[1m\u001b[37m\u001b[40m \u001b[13;2H\u001b(B\u001b[m\u001b[30m\u001b[47m│ protection. │\u001b[1m\u001b[37m\u001b[40m \u001b[14;2H\u001b(B\u001b[m\u001b[30m\u001b[47m│ │\u001b[1m\u001b[37m\u001b[40m \u001b[15;2H\u001b(B\u001b[m\u001b[30m\u001b[47m│ A system with a dynamic IP address can receive its own mail, or local │\u001b[1m\u001b[37m\u001b[40m \u001b[16;2H\u001b(B\u001b[m\u001b[30m\u001b[47m│ delivery can be disabled entirely (except mail for root and postmaster). │\u001b[1m\u001b[37m\u001b[40m \u001b[17;2H\u001b(B\u001b[m\u001b[30m\u001b[47m│ │\u001b[1m\u001b[37m\u001b[40m \u001b[18;2H\u001b(B\u001b[m\u001b[30m\u001b[47m│ \u001b[37m\u001b[41m<Ok>\u001b[30m\u001b[47m │\u001b[1m\u001b[37m\u001b[40m \u001b[19;2H\u001b(B\u001b[m\u001b[30m\u001b[47m│ │\u001b[1m\u001b[37m\u001b[40m \u001b[20;2H\u001b(B\u001b[m\u001b[30m\u001b[47m└───────────────────────────────────────────────────────────────────────────┘\u001b[1m\u001b[37m\u001b[40m \u001b[21;3H \u001b[18;38H"]}
I am not sure this is the right way.
我不确定这是正确的方法。
By using expect
- Execute a command and respond to prompt you are trying to script an interactive configuration.通过使用
expect
- 执行命令并响应提示,您正在尝试编写交互式配置脚本。 The Debian documentation describes the Exim - Configuration with a file. Debian 文档描述了Exim - 配置文件。
Any other alternate way is also appreciated.
任何其他替代方式也很受欢迎。
An simple Example , a non-interactive way of "How to make Bash the default shell".一个简单的示例,一种“如何使 Bash 成为默认 shell”的非交互式方式。
- name: Prepare Bash as default shell
shell:
cmd: 'echo "dash dash/sh boolean false" | debconf-set-selections'
- name: Make sure that default shell is set to Bash
shell:
cmd: "dpkg-reconfigure -f noninteractive dash"
register: dpkg_reconfigure
- name: STDOUT dpkg_reconfigure
debug:
var: dpkg_reconfigure.stdout_lines
... its not possible to achieve what i am looking for
...不可能实现我想要的
No, it is.不,是的。 You may proceed further with checking how
debconf-show exim4-config
works.您可以进一步检查
debconf-show exim4-config
是如何工作的。
Further Readings延伸阅读
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.