# Attempting to yum install multiple packages using with\_items results in Python AttributeError: 'list' object has no attribute 'split'

**URL:** <https://forum.ansible.com/t/attempting-to-yum-install-multiple-packages-using-with-items-results-in-python-attributeerror-list-object-has-no-attribute-split/19854>\
**Category:** Ansible Project\
**Created:** [November 25, 2015, 5:40pm UTC](https://forum.ansible.com/t/attempting-to-yum-install-multiple-packages-using-with-items-results-in-python-attributeerror-list-object-has-no-attribute-split/19854 "2015-11-25T17:40:08Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdelaporte](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jdelaporte/32/366_2.png) [@jdelaporte](https://forum.ansible.com/u/jdelaporte)\
**Post date:** [November 25, 2015, 5:40pm UTC](https://forum.ansible.com/t/attempting-to-yum-install-multiple-packages-using-with-items-results-in-python-attributeerror-list-object-has-no-attribute-split/19854/1 "2015-11-25T17:40:08Z")

</div>

Good afternoon, I am attempting to install multiple packages on a CentOS 7 server. I am using 2.0.0-rc1. I keep running into a python error.

I tried using a yum task in a role, using with\_items like so:

- yum: name={{ item }} state=present  
with\_items:
- ypbind
- rpcbind

I think that is the way it should be done, based on documentation.  
However, I keep getting this error:

failed: [HOSTNAME] =\> (item=[u’ypbind’, u’rpcbind’]) =\> {“failed”: true, “item”: [“ypbind”, “rpcbind”], “msg”: “Traceback (most recent call last):\r\n File "/tmp/.ansible/ansible-tmp-1448471787.66-61112899447177/yum", line 2744, in \r\n main()\r\n File "/tmp/.ansible/ansible-tmp-1448471787.66-61112899447177/yum", line 833, in main\r\n disablerepo, disable\_gpg\_check)\r\n File "/tmp/.ansible/ansible-tmp-1448471787.66-61112899447177/yum", line 718, in ensure\r\n items = pkgspec.split(‘,’)\r\n **AttributeError: ‘list’ object has no attribute ‘split’** \r\n”, “parsed”: false}

---

<div class="post-metadata">

**Author:** ![David\_Karban](https://avatars.discourse-cdn.com/v4/letter/d/90db22/32.png) [@David\_Karban](https://forum.ansible.com/u/David_Karban)\
**Post date:** [November 25, 2015, 5:46pm UTC](https://forum.ansible.com/t/attempting-to-yum-install-multiple-packages-using-with-items-results-in-python-attributeerror-list-object-has-no-attribute-split/19854/2 "2015-11-25T17:46:06Z")

</div>

Hi,

if I`m looking right, it can be indentation problem,

- yum: name={{ item }} state=present  
with\_items:
- ypbind
- rpcbind

---

<div class="post-metadata">

**Author:** ![jdelaporte](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jdelaporte/32/366_2.png) [@jdelaporte](https://forum.ansible.com/u/jdelaporte)\
**Post date:** [November 25, 2015, 7:00pm UTC](https://forum.ansible.com/t/attempting-to-yum-install-multiple-packages-using-with-items-results-in-python-attributeerror-list-object-has-no-attribute-split/19854/3 "2015-11-25T19:00:42Z")

</div>

Hi David,

Thanks. I also tried it with more indentation, with the same error result:

- yum: pkg={{ item }} state=present  
with\_items:
- ypbind
- rpcbind

---

<div class="post-metadata">

**Author:** ![jdelaporte](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jdelaporte/32/366_2.png) [@jdelaporte](https://forum.ansible.com/u/jdelaporte)\
**Post date:** [November 25, 2015, 7:26pm UTC](https://forum.ansible.com/t/attempting-to-yum-install-multiple-packages-using-with-items-results-in-python-attributeerror-list-object-has-no-attribute-split/19854/4 "2015-11-25T19:26:13Z")

</div>

I have also tried the following dictionary layouts, which resulted in the same ‘list object’ python error:

- yum:  
name: “{{ item }}”  
state: present  
with\_items:
- ypbind
- rpcbind

And this:

- yum:  
name:
- ypbind
- rpcbind  
state: present

Running the task with only one item works (both of the following succeeded):

- yum:  
name=ypbind state=present

- yum:  
name: rpcbind  
state: present

---

<div class="post-metadata">

**Author:** ![jdelaporte](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jdelaporte/32/366_2.png) [@jdelaporte](https://forum.ansible.com/u/jdelaporte)\
**Post date:** [November 25, 2015, 7:32pm UTC](https://forum.ansible.com/t/attempting-to-yum-install-multiple-packages-using-with-items-results-in-python-attributeerror-list-object-has-no-attribute-split/19854/5 "2015-11-25T19:32:01Z")

</div>

Okay, so the yum module might actually be broken, because when I replaced “yum” with “package”, it started working correctly.

This works:

- package: name=“{{ item }}” state=present  
with\_items:
- ypbind
- rpcbind

This doesn’t:

- yum: name=“{{ item }}” state=present  
with\_items:

- ypbind

- rpcbind

And fails with this error:

failed: [HOSTNAME] =\> (item=[u’ypbind’, u’rpcbind’]) =\> {“failed”: true, “item”: [“ypbind”, “rpcbind”], “msg”: “Traceback (most recent call last):\r\n File "/tmp/.ansible/ansible-tmp-1448479744.44-240902329915911/yum", line 2742, in \r\n main()\r\n File "/tmp/.ansible/ansible-tmp-1448479744.44-240902329915911/yum", line 831, in main\r\n disablerepo, disable\_gpg\_check)\r\n File "/tmp/.ansible/ansible-tmp-1448479744.44-240902329915911/yum", line 716, in ensure\r\n items = pkgspec.split(‘,’)\r\nAttributeError: ‘list’ object has no attribute ‘split’\r\n”, “parsed”: false}

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [November 25, 2015, 7:53pm UTC](https://forum.ansible.com/t/attempting-to-yum-install-multiple-packages-using-with-items-results-in-python-attributeerror-list-object-has-no-attribute-split/19854/6 "2015-11-25T19:53:39Z")

</div>

package will just call yum module, the main difference is in the  
'squashing', another check you can do to confirm this is set the env  
var ANSIBLE\_SQUASH\_ACTIONS="apt,pkgng", which would avoid that in yum  
(which is part of default list).

---

<div class="post-metadata">

**Author:** ![jdelaporte](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jdelaporte/32/366_2.png) [@jdelaporte](https://forum.ansible.com/u/jdelaporte)\
**Post date:** [November 26, 2015, 12:09am UTC](https://forum.ansible.com/t/attempting-to-yum-install-multiple-packages-using-with-items-results-in-python-attributeerror-list-object-has-no-attribute-split/19854/7 "2015-11-26T00:09:19Z")

</div>

Hi Brian,

Okay, but why does my play work with package, but not yum?

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [November 26, 2015, 12:10am UTC](https://forum.ansible.com/t/attempting-to-yum-install-multiple-packages-using-with-items-results-in-python-attributeerror-list-object-has-no-attribute-split/19854/8 "2015-11-26T00:10:35Z")

</div>

if you run the test i asked, i can confirm it will be because of  
argument squashing, which is an optimization that will run on yum but  
not on package.

---

<div class="post-metadata">

**Author:** ![jdelaporte](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jdelaporte/32/366_2.png) [@jdelaporte](https://forum.ansible.com/u/jdelaporte)\
**Post date:** [November 26, 2015, 12:22am UTC](https://forum.ansible.com/t/attempting-to-yum-install-multiple-packages-using-with-items-results-in-python-attributeerror-list-object-has-no-attribute-split/19854/9 "2015-11-26T00:22:11Z")

</div>

Yes, right. Sorry for my misunderstanding. I’ll get back to you with a test run after I feed my kids dinner.

---

<div class="post-metadata">

**Author:** ![jdelaporte](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jdelaporte/32/366_2.png) [@jdelaporte](https://forum.ansible.com/u/jdelaporte)\
**Post date:** [November 26, 2015, 12:44am UTC](https://forum.ansible.com/t/attempting-to-yum-install-multiple-packages-using-with-items-results-in-python-attributeerror-list-object-has-no-attribute-split/19854/10 "2015-11-26T00:44:50Z")

</div>

Alright, it worked with that variable you requested.

I exported the env var (it didn’t work just set in the current shell):

export ANSIBLE\_SQUASH\_ACTIONS=“apt,pkgng”

And ran this play:

- yum: name=“{{ item }}” state=present  
with\_items:
- ypbind
- rpcbind

The play succeeded with this variable set.

Thanks!  
Joanna

---

<div class="post-metadata">

**Author:** ![Toshio\_Kuratomi](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@Toshio\_Kuratomi](https://forum.ansible.com/u/Toshio_Kuratomi)\
**Post date:** [November 26, 2015, 1:04am UTC](https://forum.ansible.com/t/attempting-to-yum-install-multiple-packages-using-with-items-results-in-python-attributeerror-list-object-has-no-attribute-split/19854/11 "2015-11-26T01:04:23Z")

</div>

> From the traceback you showed in your original message, it looks like

somehow you have an old version of the yum module being used with the  
current rc1 for /usr/bin/ansible-playbook. items = pkgspec.split(',')  
from the traceback message is no longer present in the yum module.  
Perhaps there's some old version of ansible present on the machine and  
its yum module is overriding the one from rc1 or you have the  
ANSIBLE\_LIBRARY environment variable set to some path where an  
alternative yum module is living.

-Toshio

---

<div class="post-metadata">

**Author:** ![jdelaporte](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jdelaporte/32/366_2.png) [@jdelaporte](https://forum.ansible.com/u/jdelaporte)\
**Post date:** [November 26, 2015, 1:19am UTC](https://forum.ansible.com/t/attempting-to-yum-install-multiple-packages-using-with-items-results-in-python-attributeerror-list-object-has-no-attribute-split/19854/12 "2015-11-26T01:19:27Z")

</div>

Hi Toshio,

ANSIBLE\_LIBRARY is unset.

$ ansible --version  
ansible 2.0.0  
config file = /etc/ansible/ansible.cfg  
configured module search path = /usr/share/ansible

With a little investigation, I see the long listing of /usr/share/ansible/packaging shows all files with a date of April 2014, even though one level up they are all dated 11/23/15.

A couple days ago, I did an untar, make, make install of the package. Today, I attempted to reinstall pip because I was having these issues:

pip install --upgrade [http://releases.ansible.com/ansible/ansible-2.0.0-0.6.rc1.tar.gz](http://releases.ansible.com/ansible/ansible-2.0.0-0.6.rc1.tar.gz)

And just now I did a pip force reinstall:

# pip install --force-reinstall [http://releases.ansible.com/ansible/ansible-2.0.0-0.6.rc1.tar.gz](http://releases.ansible.com/ansible/ansible-2.0.0-0.6.rc1.tar.gz)

The module files are still all the old ones from April 2014. How do I get the updated module files?

---

<div class="post-metadata">

**Author:** ![Toshio\_Kuratomi](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@Toshio\_Kuratomi](https://forum.ansible.com/u/Toshio_Kuratomi)\
**Post date:** [November 26, 2015, 2:55am UTC](https://forum.ansible.com/t/attempting-to-yum-install-multiple-packages-using-with-items-results-in-python-attributeerror-list-object-has-no-attribute-split/19854/13 "2015-11-26T02:55:37Z")

</div>

The modules are now installed in the ansible library directory  
(something like /usr/lib/python2.7/site-packages/ansible/ ... varies a  
little bit depending on the distribution that you are running). The  
files in /usr/share/ansible are likely from an old install. I'd try  
this:

$ sudo mv /usr/share/ansible /usr/share/ansible.bak

If you can then run your playbook/ansible commands and it still finds  
its modules (hopefully now the up-to-date modules 😉 then you should  
be able to rm -rf /usr/share/ansible.bak

-Toshio

---

<div class="post-metadata">

**Author:** ![jdelaporte](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jdelaporte/32/366_2.png) [@jdelaporte](https://forum.ansible.com/u/jdelaporte)\
**Post date:** [November 26, 2015, 4:16am UTC](https://forum.ansible.com/t/attempting-to-yum-install-multiple-packages-using-with-items-results-in-python-attributeerror-list-object-has-no-attribute-split/19854/14 "2015-11-26T04:16:49Z")

</div>

Thanks! I found the paths on my machines so I could set them in my ansible.cfg file. I appreciate the tip!

For reference, I found the modules dirs in these two locations on my current control hosts:  
/usr/local/lib/python2.7/dist-packages/ansible/modules (Ubuntu 14.04)

/usr/lib64/python2.7/site-packages/ansible/modules (Slackware 14.1)

This will probably fix several errors I have been trying to work around, mostly related to lists breaking, in 2.0.

Thanks!  
Joanna
