Don't raise exception if docker node inspect self fails
diff --git a/_grains/docker_swarm.py b/_grains/docker_swarm.py
index 65a2270..321697d 100644
--- a/_grains/docker_swarm.py
+++ b/_grains/docker_swarm.py
@@ -10,7 +10,11 @@
output = {}
if os.path.exists('/var/lib/docker/swarm'):
- inspect = json.loads(subprocess.check_output(["docker", "node", "inspect", "self"]).strip())[0]
+ try:
+ inspect = json.loads(subprocess.check_output(["docker", "node", "inspect", "self"]).strip())[0]
+ except subprocess.CalledProcessError:
+ return None
+
output['docker_swarm_role'] = inspect["Spec"]["Role"]
try:
output['docker_swarm_leader'] = inspect["ManagerStatus"]["Leader"]