{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/1146","labels_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/1146/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/1146/comments","events_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/1146/events","html_url":"https://github.com/ansible/ansible-modules-core/issues/1146","id":68896146,"number":1146,"title":"Docker: Support using name and count together","user":{"login":"Endron","id":3518245,"avatar_url":"https://avatars.githubusercontent.com/u/3518245?v=3","gravatar_id":"","url":"https://api.github.com/users/Endron","html_url":"https://github.com/Endron","followers_url":"https://api.github.com/users/Endron/followers","following_url":"https://api.github.com/users/Endron/following{/other_user}","gists_url":"https://api.github.com/users/Endron/gists{/gist_id}","starred_url":"https://api.github.com/users/Endron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Endron/subscriptions","organizations_url":"https://api.github.com/users/Endron/orgs","repos_url":"https://api.github.com/users/Endron/repos","events_url":"https://api.github.com/users/Endron/events{/privacy}","received_events_url":"https://api.github.com/users/Endron/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ansible/ansible-modules-core/labels/feature_idea","name":"feature_idea","color":"006b75"},{"url":"https://api.github.com/repos/ansible/ansible-modules-core/labels/P3","name":"P3","color":"fef2c0"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-16T10:37:58Z","updated_at":"2015-12-12T04:27:33Z","closed_at":null,"body":"As stated in the documentation it is currently not possible to use the options \"name\" and \"count\" of the Docker module in combination. This is limiting. I need to use name to have a unique identifier to be able to use ansible to replace a started container with a new image:\r\n```\r\ntasks:\r\n  - name: deploy jenkins\r\n    docker: \r\n      name: \"jenkins\"\r\n      image: \"jenkins:1.593\" # <-- Change image here\r\n      detach: true\r\n      pull: always\r\n      state: reloaded\r\n```\r\nThis works for container that are only ever deployed once.\r\nBut not being able to give a count (other than 1) limits usability when working with micro services: In this case I am likely to have multiple instances of each service deployed and I want to use ansible to change the number of deployed services.\r\n\r\nI could define each service as its own task but this will not scale very well and would probably make the playbook hard to read. Just setting an appropriate count would yield a much clearer playbook.\r\n\r\nThis could properly be implemented by using a template for container names. All container would be named service_1 to service_n so ansible can figure out they belong together. This could be improved by using customizable templates.\r\n\r\nCustomizable templates would open up even more usecases as users might be able to do interesting things by stopping containers that happen to match with the template.\r\n"},"comment":{"url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/comments/164109433","html_url":"https://github.com/ansible/ansible-modules-core/issues/1146#issuecomment-164109433","issue_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/1146","id":164109433,"user":{"login":"wangyun","id":222225,"avatar_url":"https://avatars.githubusercontent.com/u/222225?v=3","gravatar_id":"","url":"https://api.github.com/users/wangyun","html_url":"https://github.com/wangyun","followers_url":"https://api.github.com/users/wangyun/followers","following_url":"https://api.github.com/users/wangyun/following{/other_user}","gists_url":"https://api.github.com/users/wangyun/gists{/gist_id}","starred_url":"https://api.github.com/users/wangyun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wangyun/subscriptions","organizations_url":"https://api.github.com/users/wangyun/orgs","repos_url":"https://api.github.com/users/wangyun/repos","events_url":"https://api.github.com/users/wangyun/events{/privacy}","received_events_url":"https://api.github.com/users/wangyun/received_events","type":"User","site_admin":false},"created_at":"2015-12-12T04:27:33Z","updated_at":"2015-12-12T04:27:33Z","body":"+1"}}