我正在通过 Ansible 设置 UFW 规则。我能够安装它,启动它并拒绝一切。然后我尝试允许来自 http、https 和 ssh 的连接。所有为这些项目添加允许的尝试都会遇到如下错误:
failed: [lempy1] (item={u'service': u'http'}) => {"failed": true, "item": {"service": "http"}, "msg": "ERROR: Could not find a profile matching 'http'\n"}
failed: [lempy1] (item={u'service': u'https'}) => {"failed": true, "item": {"service": "https"}, "msg": "ERROR: Could not find a profile matching 'https'\n"}
failed: [lempy1] (item={u'service': u'ssh'}) => {"failed": true, "item": {"service": "ssh"}, "msg": "ERROR: Could not find a profile matching 'ssh'\n"}
整个角色是这样的:
任务/main.yml
---
- name: Install ufw
apt: name=ufw state=present
tags:
- security
- name: Allow webservery things
ufw:
rule: allow
name: '{{item.service}}'
with_items:
- service: http
- service: https
- service: ssh
tags:
- security
- name: Start ufw
ufw: state=enabled policy=deny
tags:
- security
知道为什么我不能允许这些服务吗?sudo ufw allow http
当 ssh 进入服务器并运行等时,我能够正确添加服务。