我对 Ansible 很陌生。
我正在尝试遵循有关 Ansible 中角色概念的教程。
我有以下大师手册:
--- # Master Playbook for Webservers
- hosts: apacheweb
user: test
sudo: yes
connection: ssh
roles:
- webservers
它指的是具有以下任务/main.yml 的网络服务器角色:
- name: Install Apache Web Server
yum: pkg=httpd state=latest
notify: Restart HTTPD
还有一个处理程序/main.yml:
- name: Restart HTTPD
service: name=httpd state=started
当我执行上面提到的 Master Playbook 时,我收到以下错误:
TASK [webservers : Install Apache Web Server] **********************************
fatal: [test.server.com]: FAILED! => {"changed": false, "failed": true, "msg": "The following packages have pending transactions: httpd-x86_64", "rc": 128, "results": ["The following packages have pending transactions: httpd-x86_64"]}
我无法理解这个错误对应的是什么。根据我的研究,似乎没有任何类似的东西可能表明我使用 Yum 模块的方式存在问题。
注意:Ansible 版本:
ansible 2.2.1.0
config file = /etc/ansible/ansible.cfg
最佳答案
目标主机上似乎有未完成/待处理的事务。
尝试安装 yum-utils
运行包yum-complete-transaction
到给出错误的目标主机。
# yum-complete-transaction --cleanup-only
看Fixing There are unfinished transactions剩下的更多细节。
yum-complete-transaction is a program which finds incomplete or aborted yum transactions on a system and attempts to complete them. It looks at the transaction-all* and transaction-done* files which can normally be found in /var/lib/yum if a yum transaction aborted in the middle of execution.
If it finds more than one unfinished transaction it will attempt to complete the most recent one first. You can run it more than once to clean up all unfinished transactions.
关于Ansible Yum 模块挂起交易错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42038633/