我得到错误
{"** Failed ": true} msg:锁apt失败
FATAL: all hosts has already failed——aborting**
但是我可以成功ssh到远程主机
这是我剧本的内容
- hosts: 172.30.0.12
roles:
- java
- tomcat
sudo: True
vars:
tomcat_version: 7
java_version: 7
tomcat_jmxremote_enable: true
tomcat_jmxremote_port: 10003
请帮我解决这个问题
您需要在系统中使用root
来锁定apt或使用apt-命令,因此只需添加:
sudo: yes
到你的任务(我猜sudo: True
对角色不起作用)它会起作用
正如上文所说,"您需要使用root来锁定apt,或者在系统中使用apt-命令。"
然而,从ansible 1.9开始,sudo
已被弃用。现在需要将become
和become_user
指令添加到剧本中。
- hosts: 127.0.0.1
become: true
become_user: root