{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/11383","labels_url":"https://api.github.com/repos/ansible/ansible/issues/11383/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/11383/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/11383/events","html_url":"https://github.com/ansible/ansible/issues/11383","id":90916518,"number":11383,"title":"v2: Add support for SQUASH_ACTIONS to AnsibleModule","user":{"login":"kustodian","id":1949229,"avatar_url":"https://avatars.githubusercontent.com/u/1949229?v=3","gravatar_id":"","url":"https://api.github.com/users/kustodian","html_url":"https://github.com/kustodian","followers_url":"https://api.github.com/users/kustodian/followers","following_url":"https://api.github.com/users/kustodian/following{/other_user}","gists_url":"https://api.github.com/users/kustodian/gists{/gist_id}","starred_url":"https://api.github.com/users/kustodian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kustodian/subscriptions","organizations_url":"https://api.github.com/users/kustodian/orgs","repos_url":"https://api.github.com/users/kustodian/repos","events_url":"https://api.github.com/users/kustodian/events{/privacy}","received_events_url":"https://api.github.com/users/kustodian/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ansible/ansible/labels/feature_idea","name":"feature_idea","color":"006b75"},{"url":"https://api.github.com/repos/ansible/ansible/labels/P3","name":"P3","color":"fef2c0"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-06-25T10:01:07Z","updated_at":"2015-06-26T13:26:21Z","closed_at":null,"body":"In v1 and now I see from the code in v2 as well, for Ansible to squash `with_*` items into a single item and pass it to the module at once, you needed to modify the core to add the module into a list of modules which support this. Currently you need to edit `lib/ansible/executor/task_executor.py`\r\n```\r\nSQUASH_ACTIONS = frozenset(('apt', 'yum', 'pkgng', 'zypper', 'dnf'))\r\n```\r\nAlso this doesn't pass a list of those items to the module, but joins those items with `join(',')`. Would it be possible that v2 adds support in the `AnsibleModule` class so you can pass an argument e.g. `squash_actions=True` which will automatically pass all the `with_*` items as a list of items to the module. This should make the execution of a lot modules (if they add support) a lot faster, but it will also make it easier to add this support to future (and old) modules since you don't have to make a separate pull request to the core to enable this for a module."},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/115684541","html_url":"https://github.com/ansible/ansible/issues/11383#issuecomment-115684541","issue_url":"https://api.github.com/repos/ansible/ansible/issues/11383","id":115684541,"user":{"login":"kustodian","id":1949229,"avatar_url":"https://avatars.githubusercontent.com/u/1949229?v=3","gravatar_id":"","url":"https://api.github.com/users/kustodian","html_url":"https://github.com/kustodian","followers_url":"https://api.github.com/users/kustodian/followers","following_url":"https://api.github.com/users/kustodian/following{/other_user}","gists_url":"https://api.github.com/users/kustodian/gists{/gist_id}","starred_url":"https://api.github.com/users/kustodian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kustodian/subscriptions","organizations_url":"https://api.github.com/users/kustodian/orgs","repos_url":"https://api.github.com/users/kustodian/repos","events_url":"https://api.github.com/users/kustodian/events{/privacy}","received_events_url":"https://api.github.com/users/kustodian/received_events","type":"User","site_admin":false},"created_at":"2015-06-26T13:26:21Z","updated_at":"2015-06-26T13:26:21Z","body":"So that should make `name=something-{{item}}` work :)\r\n\r\nNow how to make this configurable from the module itself, since there will be modules which don't use `name` argument, or they have more arguments, for example:\r\n\r\n```\r\n- name: Set up authorized_keys for user1\r\n  authorized_key: user=user1 key=\"{{ item }}\"\r\n  with_file:\r\n    - key1\r\n    - key2\r\n```\r\nor:\r\n```\r\n- name: Configure sysctl.conf\r\n  sysctl: name={{ item.key }} value={{ item.value }} state=present\r\n  with_dict: common_sysctl_entries\r\n```\r\nIn the first situation `key` argument would need to be passed as a list, while in the second two arguments `name` and `value`."}}