【发布时间】:2015-09-18 02:41:03
【问题描述】:
我正在使用 ansible 进行测试,我正在尝试在另一台 ubuntu 服务器上安装 apache2,我已经使用 1 个 ip 定义了组“test”。但是发生的事情是,ansible 在执行它时给我带来了一些错误,我搜索了很多网站,很多人都遇到了这个问题,但是在不同的情况下,我开始对它感到沮丧。有人可以帮助我吗?
Ansible 剧本:
---
- hosts: test
sudo: yes
tasks:
- name: Check if Im sudo
command: echo $USER
- name: install packages
apt: name:apache2 update_cache=yes state=latest
notify: start apache2
handlers:
- name: start apache2
service: name=apache2 state=started
标准输出
root@ip-172-31-35-33:/etc/ansible/example# ansible-playbook example.yml
PLAY [test] *******************************************************************
GATHERING FACTS ***************************************************************
ok: [172.31.36.176]
TASK: [Check if Im sudo] ******************************************************
changed: [172.31.36.176]
TASK: [install packages] ******************************************************
failed: [172.31.36.176] => {"failed": true}
msg: this module requires key=value arguments (['name:apache2', 'update_cache=yes', 'state=latest'])
FATAL: all hosts have already failed -- aborting
PLAY RECAP ********************************************************************
to retry, use: --limit @/root/example.retry
172.31.36.176 : ok=2 changed=1 unreachable=0 failed=1
顺便说一句,主机是可访问的,我可以 ssh 进入它,即使使用 ansible,这就是证明
root@ip-172-31-35-33:/etc/ansible/example# ansible -m shell -a "ifconfig | grep 'inet addr'" test
172.31.36.176 | success | rc=0 >>
inet addr:172.31.36.176 Bcast:172.31.47.255 Mask:255.255.240.0
inet addr:127.0.0.1 Mask:255.0.0.0
另一件事是我可以在另一台服务器上手动安装 apache2,但它没有安装,因为我想使用 ANSIBLE 安装它
谢谢
【问题讨论】: