Ansible Yum 模块挂起事务错误
Ansible Yum Module pending transactions error
我是 Ansible 的新手。
我正在尝试遵循有关 Ansible 中角色概念的教程。
我有以下大师剧本:
--- # Master Playbook for Webservers
- hosts: apacheweb
user: test
sudo: yes
connection: ssh
roles:
- webservers
指的是具有以下task/main.yml:
的webservers角色
- name: Install Apache Web Server
yum: pkg=httpd state=latest
notify: Restart HTTPD
还有一个handler/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
我正在为剧本使用这种类型的配置:
- name: Install Apache Web Server
yum: name=httpd state=latest
notify: Restart HTTPD
据我所知,yum 模块的 ansbile 中没有 yum: pkg=httpd
这样的选项(如果我没记错的话,pkg=httpd 是对于 apt-get 基于 debian 的发行版)
如果你需要安装多个包,你可以使用类似的东西:
- name: "Install httpd packages"
yum: name={{ item }} state=present
with_items:
- httpd
- httpd-devel
- httpd-tools
当然,您可以将 state=present 更改为 state=latest 或任何最适合您的选项
http://docs.ansible.com/ansible/yum_module.html - yum 模块的 ansible 文档
目标主机上似乎有未完成/待处理的事务。
尝试将 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.
剩余未完成的交易
sudo yum 安装 yum-utils
yum-complete-transaction --cleanup-only
我是 Ansible 的新手。 我正在尝试遵循有关 Ansible 中角色概念的教程。 我有以下大师剧本:
--- # Master Playbook for Webservers
- hosts: apacheweb
user: test
sudo: yes
connection: ssh
roles:
- webservers
指的是具有以下task/main.yml:
的webservers角色- name: Install Apache Web Server
yum: pkg=httpd state=latest
notify: Restart HTTPD
还有一个handler/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
我正在为剧本使用这种类型的配置:
- name: Install Apache Web Server
yum: name=httpd state=latest
notify: Restart HTTPD
据我所知,yum 模块的 ansbile 中没有 yum: pkg=httpd
这样的选项(如果我没记错的话,pkg=httpd 是对于 apt-get 基于 debian 的发行版)
如果你需要安装多个包,你可以使用类似的东西:
- name: "Install httpd packages"
yum: name={{ item }} state=present
with_items:
- httpd
- httpd-devel
- httpd-tools
当然,您可以将 state=present 更改为 state=latest 或任何最适合您的选项
http://docs.ansible.com/ansible/yum_module.html - yum 模块的 ansible 文档
目标主机上似乎有未完成/待处理的事务。
尝试将 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.
剩余未完成的交易
sudo yum 安装 yum-utils
yum-complete-transaction --cleanup-only