Skip to content

Commit

Permalink
Merge pull request #38 from chrismeyersfsu/revert-36-patch-2
Browse files Browse the repository at this point in the history
Revert "Improve retrieving ip of container"
  • Loading branch information
chrismeyersfsu authored Feb 22, 2017
2 parents 8aba74b + fbc4797 commit 7d33d60
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 2 additions & 0 deletions files/docker_inspect.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
docker inspect --format='{{.NetworkSettings.IPAddress}}' $1
13 changes: 11 additions & 2 deletions tasks/inc_cloud_iface.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,22 @@

- name: Get IP of container
local_action:
module: "command"
args: "docker inspect --format '{{ '{{' }} .NetworkSettings.IPAddress {{ '}}' }}' {{ item.name }}"
module: "shell"
args: "{{ role_path }}/files/docker_inspect.sh {{ item.name }}"
register: provision_docker_ip
with_items: "{{ provision_docker_inventory }}"
changed_when: false

- block:
# Note: We had to move the invocation of the docker inspect command into a bash
# script because it involces a command line parameter with {{ }}. Registering
# the results puts the command line params into invocation. Referencing the
# results variable fails because Ansible runs the invocation through jinja2
# template engine and the {{.NetworkSettings.IPAddress}} variable does not
# exist
# TODO: Check if no results (i.e. results.stdout_lines length) returned from
# docker_inspect.sh

# TODO: copy ALL host vars in the inventory
- name: "Associate ip address with hosts"
local_action:
Expand Down
6 changes: 4 additions & 2 deletions tasks/inc_inventory_iface.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@

- name: Get IP of container
local_action:
module: "command"
args: "docker inspect --format '{{ '{{' }} .NetworkSettings.IPAddress {{ '}}' }}' {{ item }}"
module: "shell"
args: "{{ role_path }}/files/docker_inspect.sh {{ item }}"
register: provision_docker_ip
with_items: "{{ provision_docker_inventory_group }}"
changed_when: false

- debug: msg="{{provision_docker_ip}}"

- block:
- name: "Associate ip address with hosts"
set_fact:
Expand Down

0 comments on commit 7d33d60

Please sign in to comment.