Ansible Yum Module pending transactions error

SSF picture SSF · Feb 4, 2017 · Viewed 11.5k times · Source

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

Answer

gile picture gile · Feb 4, 2017

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.