Regression in 'package' module?

Hi,

I recently migrated from OS specific modules to the 'package' module to
reduce the number of tasks [1].

At the time I used ansible 2.0 (and IIRC it worked but I'm not 100% sure).

Now I'm running ansible 2.2 and apparently the package module on OpenBSD
targets does not seem to use the openbsd_pkg module(?) and package
installation fails because it looks for ports to build even though build
is set to false (default) ?:

    "failed": true,
    "invocation": {
        "module_args": {
            "build": false,
            "name": "['tor']",
            "ports_dir": "/usr/ports",
            "state": "present"
        }
    },
    "item": [
        "tor"
    ],
    "msg": "Can't find [tor]\n"

Doesn't the 'package' module use openbsd_pkg on OpenBSD targets?
(installing the tor package with the openbsd_pkg works fine)

Have there been any major changes in the package module between ansible
2.0 and 2.2?

thanks,
nusenu

https://github.com/nusenu/ansible-relayor/issues/85

[1]
https://github.com/nusenu/ansible-relayor/commit/550d656a2c5ec8f2b588b32d9cf256aab2743bb7

turns out this role commit introduced the problem,
it replaces the static string "tor" with the generic "{{ item }}".

https://github.com/nusenu/ansible-relayor/commit/06eaad05443f5282b4ac74af688a5f6e60e45b83#diff-2444ad0870f91f17ca6c2a5e96b26823

    "failed": true,
    "invocation": {
        "module_args": {
            "build": false,
            "name": "['tor']",
            "ports_dir": "/usr/ports",
            "state": "present"
        }
    },
    "item": [
        "tor"
    ],
    "msg": "Can't find [tor]\n"

I'm wondering why is name set to "['tor']" and not "tor"

even after changing tor_packages from:

tor_packages: tor

to

tor_packages:
  - tor

or

tor_packages: ['tor']

when an argument is defined as a list, it is always a list, even if you only supply one element.

Brian Coca:

when an argument is defined as a list, it is always a list, even if you
only supply one element.

Yes, that is what I actually expect.

and that is why I do not understand that name is set to the entire list
instead of the first (and only) item of the list if I use it in a
with_items loop:

https://github.com/nusenu/ansible-relayor/blob/master/tasks/main.yml#L43

Or am I misreading the error message?

can you run with -vvv and show that output? also can you check the value of asnible_pkg_mgr?

The task executes once per item, I’m guessing it failed on the first one.

Brian Coca:

The task executes once per item, I'm guessing it failed on the first one.

After further tests I've come to the conclusion that this is actually a bug.

I filed the bug report here:
https://github.com/ansible/ansible-modules-core/issues/5708

Looking forward to your comments and a fix.