# Creating a package module like the yum module

**URL:** <https://forum.ansible.com/t/creating-a-package-module-like-the-yum-module/23089>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [November 23, 2016, 8:35pm UTC](https://forum.ansible.com/t/creating-a-package-module-like-the-yum-module/23089 "2016-11-23T20:35:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peter\_Burns](https://avatars.discourse-cdn.com/v4/letter/p/ba8739/32.png) [@Peter\_Burns](https://forum.ansible.com/u/Peter_Burns)\
**Post date:** [November 23, 2016, 8:35pm UTC](https://forum.ansible.com/t/creating-a-package-module-like-the-yum-module/23089/1 "2016-11-23T20:35:18Z")

</div>

Hi there,

I’m trying to create an ansible module to install packages using a custom package management system. I want it to function like the core yum module says it does when used in a loop, i.e. “Instead of calling the module with a single package each time through the loop, ansible calls the module once with all of the package names from the loop”

How would I replicate this in my own module?

I couldn’t see anything special in the source for the yum module that would enable this behaviour.

I tried just specifying the input as type list, simplified below:

`

module = AnsibleModule(  
argument\_spec = dict(  
name=dict(type=“list”, required=True),  
),  
supports\_check\_mode = True  
)  
cmd = [‘pkg\_agent’, ‘-X’, ‘,’.join(module.params’name’]) ]  
rc, out, err = module.run\_command(cmd)

`

But when I used my module in a playbook, it didn’t work:

`

tasks:

- name: “Install packages”  
pkg\_install:  
name: “{{ item }}”  
become: True  
with\_items:
- ‘common-tests’
- ‘ops-libs’

`

Both the debug output and the resulting behaviour was it running the install on each package individually, and not bundling them together.

The expected result was that it would run `pkg_agent -X common-tests,ops-libs` but what in fact happened is it ran `pkg_agent -X common-tests` and then `pkg_agent -X ops-libs`

This was using Ansible 2.2 on Ubuntu

Any help in where I’ve gone wrong with this would be much appreciated.

- Peter
