image facts
authorLorin Hochstein <lhochstein@netflix.com>
Sun, 5 Feb 2017 22:03:01 +0000 (14:03 -0800)
committerLorin Hochstein <lhochstein@netflix.com>
Sun, 5 Feb 2017 22:03:01 +0000 (14:03 -0800)
ch13/image-facts.yml

index d346211..0037f2f 100644 (file)
@@ -8,6 +8,21 @@
     - name: get image info
       docker_image_facts: name=ghost
       register: ghost
-    - debug:
-        msg: "Ports: {{ ghost.images[0].Config.ExposedPorts}}"
+    - name: extract ports
+      set_fact:
+        ports: "{{ ghost.images[0].Config.ExposedPorts.keys() }}"
+    - name: we expect only one port to be exposed
+      assert:
+        that: "ports|length == 1"
+    - name: output exposed port
+      debug:
+        msg: "Exposed port: {{ ports[0] }}"
+    - name: extract volumes
+      set_fact:
+        volumes: "{{ ghost.images[0].Config.Volumes.keys() }}"
+    - name: output volumes
+      debug:
+        msg: "Volume: {{ item }}"
+      with_items: "{{ volumes }}"
+