apache - 用于在本地设置 Apache 服务器的 Ansible Playbook 与主机不匹配

标签 apache ubuntu ansible

我有一个 Ansible Playbook,旨在在我的机器上本地创建一个 Apache 服务器。但是,每次我尝试运行 playbook 时,都会收到以下错误消息:

[WARNING]: Could not match supplied host pattern, ignoring: apache
skipping: no hosts matched
这就是我的 Ansible Playbook 的样子:
- hosts: apache
  tasks:
     - name: install apache2
       apt: name=apache2 update_cache=yes state=latest
这就是我的ansible.cfghosts文件看起来像:
ansible.cfg:
[defaults]
hostfile = hosts
inventory = /etc/ansible/hosts
主持人:
myserver ansible_host=127.0.0.1 ansible_user=ubuntu ansible_connection=local
如果这很重要,这一切都在 Ubuntu VM 上。我究竟做错了什么?
编辑:好的,在完成 Shraddheya 的修复后我不再收到该错误,但现在我收到此错误:
fatal: [myserver]: FAILED! => {"ansible_facts": {}, "changed": false, "failed_modules": {"ansible.legacy.setup": {"ansible_facts": {discovered_interpreter_python": "/usr/bin/python3"}, "failed": true, "module_stderr": "sudo: a password is required\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}}, "msg": "The following modules fialed to execute: ansible.legacy.setup\n"}

最佳答案

稍微修改一下你的 hosts 文件以包含 myserverapache主机组,hosts文件必须阅读:

[apache]
myserver ansible_host=127.0.0.1 ansible_user=ubuntu ansible_connection=local

关于apache - 用于在本地设置 Apache 服务器的 Ansible Playbook 与主机不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71792076/

相关文章:

azure - 无法使用 Ansible 获取 Azure VM 专用 IP

Ansible 中的 SSH 错误 : Permission denied (publickey, 密码)

amazon-web-services - 我如何在标签中的 Amazon EC2 过滤器中使用正则表达式

python - 如何在 apache 上配置 django 并在 apache 中创建 https 以便 django url 应使用 https ://<ip>:80 port 打开

apache - Tomcat Manager 能否在替代路径上安全运行?

php - xip.io 的本地设备测试问题

apache - 通过 LAN 访问多个 MAMP Pro 站点?

mongodb - 无法从本地机器连接到 docker 容器中的 mongodb

node.js - NPM安装错误: RangeError: Maximum call stack size exceeded

Linux from scratch Segmentation fault 报错