Docker inventory service/stack groups for docker swarm (#48021)

* Adding service and stack grouping to docker inventory

* Updating documentation

* Adding changelog fragment for docker.py inventory script
pull/50021/head
Eric Miller 6 years ago committed by John R Barker
parent 87ee59b8d7
commit 4d0f2e632c

@ -0,0 +1,2 @@
minor_changes:
- inventory/docker - Group containers by docker-swarm "service" and "stack"

@ -196,6 +196,8 @@ When run in --list mode (the default), container instances are grouped by:
- container name
- container short id
- image_name (image_<image name>)
- stack_name (stack_<stack name>)
- service_name (service_<service name>)
- docker_host
- running
- stopped
@ -622,6 +624,14 @@ class DockerInventory(object):
if image_name:
self.groups["image_%s" % (image_name)].append(name)
stack_name = inspect.get('Config', dict()).get('Labels', dict()).get('com.docker.stack.namespace')
if stack_name:
self.groups["stack_%s" % stack_name].append(name)
service_name = inspect.get('Config', dict()).get('Labels', dict()).get('com.docker.swarm.service.name')
if service_name:
self.groups["service_%s" % service_name].append(name)
self.groups[id].append(name)
self.groups[name].append(name)
if short_id not in self.groups:

Loading…
Cancel
Save