Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ansible Yum Module pending transactions error

Tags:

ansible

yum

I'm very new to Ansible. I am trying to follow a tutorial on the concept of Roles in Ansible. I have the following Master Playbook:

--- # Master Playbook for Webservers
- hosts: apacheweb
  user: test
  sudo: yes
  connection: ssh
  roles:
    - webservers

Which refers to the webservers role that has the following task/main.yml:

- name: Install Apache Web Server
  yum: pkg=httpd state=latest
  notify: Restart HTTPD

And a handler/main.yml:

- name: Restart HTTPD
  service: name=httpd state=started

When I execute the Master Playbook, mentioned above, I get the following error:

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"]}

I cannot understand what this error corresponds to. There does not seem to be anything similar, based on my research, that could suggest the issue with the way I am using the Yum module.

NOTE: Ansible Version:

ansible 2.2.1.0
  config file = /etc/ansible/ansible.cfg
like image 947
SSF Avatar asked Feb 04 '17 09:02

SSF


2 Answers

It seems there are unfinished / pending transactions on the target host. Try installing yum-utils package to run yum-complete-transaction to the target hosts giving the error.

# yum-complete-transaction --cleanup-only

Look at Fixing There are unfinished transactions remaining for more details.

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.

like image 181
gile Avatar answered Nov 18 '22 03:11

gile


Unfinished transaction remaining

sudo yum install yum-utils

yum-complete-transaction --cleanup-only

like image 1
ZeroDeth Avatar answered Nov 18 '22 05:11

ZeroDeth