Mac上 ansible playbooks 发邮件

2017-6-6 Frank 工具

[TOC]

1. hosts

local ansible_ssh_port=22 ansible_ssh_host=localhost  ansible_ssh_user=feng ansible_ssh_private_key_file=/Users/fengxuting/.ssh/id_rsa

2. mail.yml

---
- hosts: local
  tasks:
    # Sending an e-mail using 163 SMTP servers
    - mail:
        host: smtp.163.com
        port: 25
        username: fffy2366
        password: xxx
        from: fffy2366@163.com (fffy2366)
        to: Frank feng <fengxuting@qq.com>
        subject: Ansible-report
        body: 'System {{ ansible_hostname }} has been successfully provisioned.'
      delegate_to: localhost

3. 执行

ansible-playbook -i hosts mail.yml

4. 报错

ssh: connect to host localhost port 22: Connection refused

5. 解决

解决方法是选择系统偏好设置->选择共享->点击远程登录
然后再输入命令ssh localhost发现已经解决问题

加入公钥到~/.ssh/authorized_keys

ssh-copy-id feng@localhost

发表评论 登录

Top