首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用“ansible-playbook”在Ubuntu中安装Exim4

使用“ansible-playbook”在Ubuntu中安装Exim4
EN

Stack Overflow用户
提问于 2022-02-23 17:00:17
回答 1查看 216关注 0票数 -4

我正在尝试使用剧本在Ubuntu中安装Exim4。但会犯错误。我正在学习ansible-playbook,如果有人能帮助我实现这一点,那就太好了。我的书是这样的

代码语言:javascript
运行
复制
- 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'

我不确定这是不是正确的方法。任何其他替代方式也将受到赞赏。我得到了下面的错误。

代码语言:javascript
运行
复制
/*
* 提示:该行代码过长,系统自动注释不进行高亮。一键复制会移除系统注释 
* 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"]}
*/
EN

回答 1

Stack Overflow用户

发布于 2022-02-24 11:11:15

我不确定这是不是正确的方法。

通过使用-执行命令并响应提示,您正在尝试编写交互式配置的脚本。Debian文档用文件描述了进出口配置

任何其他替代方式也将受到赞赏。

一个简单的示例,一种“如何使Bash成为默认shell”的非交互式方法。

代码语言:javascript
运行
复制
- 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

..。我不可能实现我想要的

不,是这样的。您可以进一步检查debconf-show exim4-config是如何工作的。

进一步阅读

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71241135

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档