gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 18:58:44 25 4
gpt4 key购买 nike

我有一个 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com