{"action":"opened","number":48021,"pull_request":{"url":"https://api.github.com/repos/ansible/ansible/pulls/48021","id":228090821,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI4MDkwODIx","html_url":"https://github.com/ansible/ansible/pull/48021","diff_url":"https://github.com/ansible/ansible/pull/48021.diff","patch_url":"https://github.com/ansible/ansible/pull/48021.patch","issue_url":"https://api.github.com/repos/ansible/ansible/issues/48021","number":48021,"state":"open","locked":false,"title":"Docker inventory service/stack groups for docker swarm","user":{"login":"sosheskaz","id":1588827,"node_id":"MDQ6VXNlcjE1ODg4Mjc=","avatar_url":"https://avatars2.githubusercontent.com/u/1588827?v=4","gravatar_id":"","url":"https://api.github.com/users/sosheskaz","html_url":"https://github.com/sosheskaz","followers_url":"https://api.github.com/users/sosheskaz/followers","following_url":"https://api.github.com/users/sosheskaz/following{/other_user}","gists_url":"https://api.github.com/users/sosheskaz/gists{/gist_id}","starred_url":"https://api.github.com/users/sosheskaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sosheskaz/subscriptions","organizations_url":"https://api.github.com/users/sosheskaz/orgs","repos_url":"https://api.github.com/users/sosheskaz/repos","events_url":"https://api.github.com/users/sosheskaz/events{/privacy}","received_events_url":"https://api.github.com/users/sosheskaz/received_events","type":"User","site_admin":false},"body":"##### SUMMARY\r\n\r\nThis adds host grouping based on \"service\" and \"stack\" to the docker inventory script.\r\n\r\n##### ISSUE TYPE\r\n\r\n- Feature Pull Request\r\n\r\n##### COMPONENT NAME\r\n\r\ndocker.py inventory\r\n\r\n##### ANSIBLE VERSION\r\n\r\n```\r\nansible 2.7.0\r\n  config file = None\r\n  configured module search path = [u'/home/eric/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']\r\n  ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible\r\n  executable location = /usr/local/bin/ansible\r\n  python version = 2.7.15rc1 (default, Apr 15 2018, 21:51:34) [GCC 7.3.0]\r\n```\r\n\r\n##### ADDITIONAL INFORMATION\r\n<!--- Include additional information to help people understand the change here -->\r\n<!--- A step-by-step reproduction of the problem is helpful if there is no related issue -->\r\n\r\nThis makes no change to existing functionality but extends the grouping of containers based on image to group on stack and service as well. This is done by conditionally keying the a host's groups off of the labels `com.docker.stack.namespace` and `com.docker.swarm.service.name`.\r\n\r\nThe derived groups are in the format `service_<service_name>` and `stack_<stack_name>`\r\n\r\nYou can find the docker-compose file I used to create these groups [here](https://github.com/sosheskaz/docker-composes/blob/c0e81091aeed6d7cf170d4b12c920354b2198c70/ansible-mock.yml).\r\n\r\nExcerpt from \"pretty\" docker.py output:\r\n```sh\r\n$ contrib/inventory/docker.py | jq .service_ansible_mock_host\r\n[\r\n  \"ansible_mock_host.2.qo2m6mrmtfy8f8zl64yogsyef\",\r\n  \"ansible_mock_host.1.hxnrh84blwmscu2pmgl4p5ann\",\r\n  \"ansible_mock_host.3.sn74oapkk5ay3la148js5z93n\",\r\n  \"ansible_mock_host.4.zi8jyrocpts7hw8x0sba9k47b\",\r\n  \"ansible_mock_host.5.i5t8il409jgua2olw1wfw5ucg\",\r\n  \"ansible_mock_host.3.ly13cxwzvibmuf6volsr8t1z8\",\r\n  \"ansible_mock_host.2.bkiiay0a48a3koxkgbvvte9me\"\r\n]\r\n\r\n$ contrib/inventory/docker.py | jq .stack_ansible_mock\r\n[\r\n  \"ansible_mock_host.2.qo2m6mrmtfy8f8zl64yogsyef\",\r\n  \"ansible_mock_host.1.hxnrh84blwmscu2pmgl4p5ann\",\r\n  \"ansible_mock_host.3.sn74oapkk5ay3la148js5z93n\",\r\n  \"ansible_mock_host.4.zi8jyrocpts7hw8x0sba9k47b\",\r\n  \"ansible_mock_host.5.i5t8il409jgua2olw1wfw5ucg\",\r\n  \"ansible_mock_host.3.ly13cxwzvibmuf6volsr8t1z8\",\r\n  \"ansible_mock_host.2.bkiiay0a48a3koxkgbvvte9me\"\r\n]\r\n\r\n# warnings omitted from output for legibility\r\n$ ansible -i contrib/inventory/docker.py 'stack_ansible_mock:&running' \\\r\n-m ping -e ansible_connection=docker -e ansible_python_interpreter=/usr/local/bin/python\r\nansible_mock_host.1.hxnrh84blwmscu2pmgl4p5ann | SUCCESS => {\r\n    \"changed\": false,\r\n    \"ping\": \"pong\"\r\n}\r\nansible_mock_host.5.i5t8il409jgua2olw1wfw5ucg | SUCCESS => {\r\n    \"changed\": false,\r\n    \"ping\": \"pong\"\r\n}\r\nansible_mock_host.3.sn74oapkk5ay3la148js5z93n | SUCCESS => {\r\n    \"changed\": false,\r\n    \"ping\": \"pong\"\r\n}\r\nansible_mock_host.4.zi8jyrocpts7hw8x0sba9k47b | SUCCESS => {\r\n    \"changed\": false,\r\n    \"ping\": \"pong\"\r\n}\r\nansible_mock_host.2.qo2m6mrmtfy8f8zl64yogsyef | SUCCESS => {\r\n    \"changed\": false,\r\n    \"ping\": \"pong\"\r\n}\r\n```","created_at":"2018-11-03T01:11:50Z","updated_at":"2018-11-03T01:11:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/ansible/ansible/pulls/48021/commits","review_comments_url":"https://api.github.com/repos/ansible/ansible/pulls/48021/comments","review_comment_url":"https://api.github.com/repos/ansible/ansible/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/48021/comments","statuses_url":"https://api.github.com/repos/ansible/ansible/statuses/b7592e4ae2fd6d800605d02d3b791ae91a188c8f","head":{"label":"sosheskaz:docker-service-groups","ref":"docker-service-groups","sha":"b7592e4ae2fd6d800605d02d3b791ae91a188c8f","user":{"login":"sosheskaz","id":1588827,"node_id":"MDQ6VXNlcjE1ODg4Mjc=","avatar_url":"https://avatars2.githubusercontent.com/u/1588827?v=4","gravatar_id":"","url":"https://api.github.com/users/sosheskaz","html_url":"https://github.com/sosheskaz","followers_url":"https://api.github.com/users/sosheskaz/followers","following_url":"https://api.github.com/users/sosheskaz/following{/other_user}","gists_url":"https://api.github.com/users/sosheskaz/gists{/gist_id}","starred_url":"https://api.github.com/users/sosheskaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sosheskaz/subscriptions","organizations_url":"https://api.github.com/users/sosheskaz/orgs","repos_url":"https://api.github.com/users/sosheskaz/repos","events_url":"https://api.github.com/users/sosheskaz/events{/privacy}","received_events_url":"https://api.github.com/users/sosheskaz/received_events","type":"User","site_admin":false},"repo":{"id":152819098,"node_id":"MDEwOlJlcG9zaXRvcnkxNTI4MTkwOTg=","name":"ansible","full_name":"sosheskaz/ansible","private":false,"owner":{"login":"sosheskaz","id":1588827,"node_id":"MDQ6VXNlcjE1ODg4Mjc=","avatar_url":"https://avatars2.githubusercontent.com/u/1588827?v=4","gravatar_id":"","url":"https://api.github.com/users/sosheskaz","html_url":"https://github.com/sosheskaz","followers_url":"https://api.github.com/users/sosheskaz/followers","following_url":"https://api.github.com/users/sosheskaz/following{/other_user}","gists_url":"https://api.github.com/users/sosheskaz/gists{/gist_id}","starred_url":"https://api.github.com/users/sosheskaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sosheskaz/subscriptions","organizations_url":"https://api.github.com/users/sosheskaz/orgs","repos_url":"https://api.github.com/users/sosheskaz/repos","events_url":"https://api.github.com/users/sosheskaz/events{/privacy}","received_events_url":"https://api.github.com/users/sosheskaz/received_events","type":"User","site_admin":false},"html_url":"https://github.com/sosheskaz/ansible","description":"Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy. Avoid writing scripts or custom code to deploy and update your applications — automate in a language that approaches plain English, using SSH, with no agents to install on remote systems. https://docs.ansible.com/ansible/","fork":true,"url":"https://api.github.com/repos/sosheskaz/ansible","forks_url":"https://api.github.com/repos/sosheskaz/ansible/forks","keys_url":"https://api.github.com/repos/sosheskaz/ansible/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sosheskaz/ansible/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sosheskaz/ansible/teams","hooks_url":"https://api.github.com/repos/sosheskaz/ansible/hooks","issue_events_url":"https://api.github.com/repos/sosheskaz/ansible/issues/events{/number}","events_url":"https://api.github.com/repos/sosheskaz/ansible/events","assignees_url":"https://api.github.com/repos/sosheskaz/ansible/assignees{/user}","branches_url":"https://api.github.com/repos/sosheskaz/ansible/branches{/branch}","tags_url":"https://api.github.com/repos/sosheskaz/ansible/tags","blobs_url":"https://api.github.com/repos/sosheskaz/ansible/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sosheskaz/ansible/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sosheskaz/ansible/git/refs{/sha}","trees_url":"https://api.github.com/repos/sosheskaz/ansible/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sosheskaz/ansible/statuses/{sha}","languages_url":"https://api.github.com/repos/sosheskaz/ansible/languages","stargazers_url":"https://api.github.com/repos/sosheskaz/ansible/stargazers","contributors_url":"https://api.github.com/repos/sosheskaz/ansible/contributors","subscribers_url":"https://api.github.com/repos/sosheskaz/ansible/subscribers","subscription_url":"https://api.github.com/repos/sosheskaz/ansible/subscription","commits_url":"https://api.github.com/repos/sosheskaz/ansible/commits{/sha}","git_commits_url":"https://api.github.com/repos/sosheskaz/ansible/git/commits{/sha}","comments_url":"https://api.github.com/repos/sosheskaz/ansible/comments{/number}","issue_comment_url":"https://api.github.com/repos/sosheskaz/ansible/issues/comments{/number}","contents_url":"https://api.github.com/repos/sosheskaz/ansible/contents/{+path}","compare_url":"https://api.github.com/repos/sosheskaz/ansible/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sosheskaz/ansible/merges","archive_url":"https://api.github.com/repos/sosheskaz/ansible/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sosheskaz/ansible/downloads","issues_url":"https://api.github.com/repos/sosheskaz/ansible/issues{/number}","pulls_url":"https://api.github.com/repos/sosheskaz/ansible/pulls{/number}","milestones_url":"https://api.github.com/repos/sosheskaz/ansible/milestones{/number}","notifications_url":"https://api.github.com/repos/sosheskaz/ansible/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sosheskaz/ansible/labels{/name}","releases_url":"https://api.github.com/repos/sosheskaz/ansible/releases{/id}","deployments_url":"https://api.github.com/repos/sosheskaz/ansible/deployments","created_at":"2018-10-13T00:00:32Z","updated_at":"2018-10-13T00:01:04Z","pushed_at":"2018-11-03T00:42:11Z","git_url":"git://github.com/sosheskaz/ansible.git","ssh_url":"git@github.com:sosheskaz/ansible.git","clone_url":"https://github.com/sosheskaz/ansible.git","svn_url":"https://github.com/sosheskaz/ansible","homepage":"https://www.ansible.com/","size":143247,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"devel"}},"base":{"label":"ansible:devel","ref":"devel","sha":"96a20e07807041845d1bc35b208de8cbbabacfc1","user":{"login":"ansible","id":1507452,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1MDc0NTI=","avatar_url":"https://avatars2.githubusercontent.com/u/1507452?v=4","gravatar_id":"","url":"https://api.github.com/users/ansible","html_url":"https://github.com/ansible","followers_url":"https://api.github.com/users/ansible/followers","following_url":"https://api.github.com/users/ansible/following{/other_user}","gists_url":"https://api.github.com/users/ansible/gists{/gist_id}","starred_url":"https://api.github.com/users/ansible/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ansible/subscriptions","organizations_url":"https://api.github.com/users/ansible/orgs","repos_url":"https://api.github.com/users/ansible/repos","events_url":"https://api.github.com/users/ansible/events{/privacy}","received_events_url":"https://api.github.com/users/ansible/received_events","type":"Organization","site_admin":false},"repo":{"id":3638964,"node_id":"MDEwOlJlcG9zaXRvcnkzNjM4OTY0","name":"ansible","full_name":"ansible/ansible","private":false,"owner":{"login":"ansible","id":1507452,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1MDc0NTI=","avatar_url":"https://avatars2.githubusercontent.com/u/1507452?v=4","gravatar_id":"","url":"https://api.github.com/users/ansible","html_url":"https://github.com/ansible","followers_url":"https://api.github.com/users/ansible/followers","following_url":"https://api.github.com/users/ansible/following{/other_user}","gists_url":"https://api.github.com/users/ansible/gists{/gist_id}","starred_url":"https://api.github.com/users/ansible/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ansible/subscriptions","organizations_url":"https://api.github.com/users/ansible/orgs","repos_url":"https://api.github.com/users/ansible/repos","events_url":"https://api.github.com/users/ansible/events{/privacy}","received_events_url":"https://api.github.com/users/ansible/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/ansible/ansible","description":"Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy. Avoid writing scripts or custom code to deploy and update your applications — automate in a language that approaches plain English, using SSH, with no agents to install on remote systems. https://docs.ansible.com/ansible/","fork":false,"url":"https://api.github.com/repos/ansible/ansible","forks_url":"https://api.github.com/repos/ansible/ansible/forks","keys_url":"https://api.github.com/repos/ansible/ansible/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ansible/ansible/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ansible/ansible/teams","hooks_url":"https://api.github.com/repos/ansible/ansible/hooks","issue_events_url":"https://api.github.com/repos/ansible/ansible/issues/events{/number}","events_url":"https://api.github.com/repos/ansible/ansible/events","assignees_url":"https://api.github.com/repos/ansible/ansible/assignees{/user}","branches_url":"https://api.github.com/repos/ansible/ansible/branches{/branch}","tags_url":"https://api.github.com/repos/ansible/ansible/tags","blobs_url":"https://api.github.com/repos/ansible/ansible/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ansible/ansible/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ansible/ansible/git/refs{/sha}","trees_url":"https://api.github.com/repos/ansible/ansible/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ansible/ansible/statuses/{sha}","languages_url":"https://api.github.com/repos/ansible/ansible/languages","stargazers_url":"https://api.github.com/repos/ansible/ansible/stargazers","contributors_url":"https://api.github.com/repos/ansible/ansible/contributors","subscribers_url":"https://api.github.com/repos/ansible/ansible/subscribers","subscription_url":"https://api.github.com/repos/ansible/ansible/subscription","commits_url":"https://api.github.com/repos/ansible/ansible/commits{/sha}","git_commits_url":"https://api.github.com/repos/ansible/ansible/git/commits{/sha}","comments_url":"https://api.github.com/repos/ansible/ansible/comments{/number}","issue_comment_url":"https://api.github.com/repos/ansible/ansible/issues/comments{/number}","contents_url":"https://api.github.com/repos/ansible/ansible/contents/{+path}","compare_url":"https://api.github.com/repos/ansible/ansible/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ansible/ansible/merges","archive_url":"https://api.github.com/repos/ansible/ansible/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ansible/ansible/downloads","issues_url":"https://api.github.com/repos/ansible/ansible/issues{/number}","pulls_url":"https://api.github.com/repos/ansible/ansible/pulls{/number}","milestones_url":"https://api.github.com/repos/ansible/ansible/milestones{/number}","notifications_url":"https://api.github.com/repos/ansible/ansible/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ansible/ansible/labels{/name}","releases_url":"https://api.github.com/repos/ansible/ansible/releases{/id}","deployments_url":"https://api.github.com/repos/ansible/ansible/deployments","created_at":"2012-03-06T14:58:02Z","updated_at":"2018-11-02T23:40:07Z","pushed_at":"2018-11-02T23:19:32Z","git_url":"git://github.com/ansible/ansible.git","ssh_url":"git@github.com:ansible/ansible.git","clone_url":"https://github.com/ansible/ansible.git","svn_url":"https://github.com/ansible/ansible","homepage":"https://www.ansible.com/","size":145267,"stargazers_count":33536,"watchers_count":33536,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":13359,"mirror_url":null,"archived":false,"open_issues_count":5646,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":13359,"open_issues":5646,"watchers":33536,"default_branch":"devel"}},"_links":{"self":{"href":"https://api.github.com/repos/ansible/ansible/pulls/48021"},"html":{"href":"https://github.com/ansible/ansible/pull/48021"},"issue":{"href":"https://api.github.com/repos/ansible/ansible/issues/48021"},"comments":{"href":"https://api.github.com/repos/ansible/ansible/issues/48021/comments"},"review_comments":{"href":"https://api.github.com/repos/ansible/ansible/pulls/48021/comments"},"review_comment":{"href":"https://api.github.com/repos/ansible/ansible/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ansible/ansible/pulls/48021/commits"},"statuses":{"href":"https://api.github.com/repos/ansible/ansible/statuses/b7592e4ae2fd6d800605d02d3b791ae91a188c8f"}},"author_association":"NONE","merged":false,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":true,"commits":2,"additions":10,"deletions":0,"changed_files":1}}
{"actor":{"display_login":"sosheskaz"}}