with_items takes an array.
You should define $mx as an array in that case.
If you want to just execute local commands for every machine in the
group, that is actually:
hosts: whatever
tasks:
- name: blarg...
local_action: shell /usr/bin/cmk -II $inventory_hostname
And that will call "cmk" with each hostname in the group "whatever" as
a parameter.
You can also use different hosts by using "delegate_to: hostname"
instead of "local_action".
Search for "delegate_to" in the docs for more info.
Hope that helps? If not, let me know a bit more. Thanks!