Skip to content

Commit

Permalink
Add option configure ports mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas-bednar committed Jun 13, 2017
1 parent a6d22ef commit fec7997
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 1 deletion.
1 change: 1 addition & 0 deletions tasks/inc_cloud_iface.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
command: "{{ item.command|default(omit) }}"
env: "{{ item.env|default(omit) }}"
links: "{{ item.links|default(omit) }}"
ports: "{{ item.ports|default(omit) }}"
network_mode: "{{ item.network_mode|default(provision_docker_network) }}"
with_items: "{{ provision_docker_inventory }}"

Expand Down
1 change: 1 addition & 0 deletions tasks/inc_inventory_iface.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
command: "{{ item.command|default(omit) }}"
env: "{{ item.env|default(omit) }}"
links: "{{ item.links|default(omit) }}"
ports: "{{ item.ports|default(omit) }}"
network_mode: "{{ hostvars[item].network_mode|default(provision_docker_network) }}"
with_items: "{{ provision_docker_inventory_group }}"

Expand Down
5 changes: 4 additions & 1 deletion test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

containers = provision_docker_host_one provision_docker_host_two provision_docker_host_three provision_docker_host_four provision_docker_host_five optimus ironhide megatron starscream

all: cloud inventory docker_inventory docker_cloud groups network_mode docker_links
all: cloud inventory docker_inventory docker_cloud groups network_mode docker_links docker_ports

cloud:
docker rm -f $(containers) || true
Expand Down Expand Up @@ -32,5 +32,8 @@ docker_links:
docker rm -f $(containers) || true
ansible-playbook -i inventory playbook_verify_links.yml

docker_ports: clean
ansible-playbook -i inventory playbook_verify_ports.yml

clean:
docker rm -f $(containers) || true
44 changes: 44 additions & 0 deletions test/playbook_verify_ports.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
- name: Bring up one container for ports test
hosts: localhost
vars:
inventory:
- name: provision_docker_host_one
image: "chrismeyers/centos7"
expose: 80
ports:
- 8080:80
roles:
- role: provision_docker
provision_docker_inventory: "{{ inventory }}"


- name: Deploy apache server in container
hosts: provision_docker_host_one
tasks:
- name: Install epel-release
yum:
name: epel-release
state: present
- name: Install nginx
yum:
name: nginx
state: present
- name: Start service
service:
name: nginx
state: started


- name: Verify that sevice is exposed on host's port
hosts: localhost
tasks:
- name: Wait for nginx appear on port 8080
uri:
url: "http://localhost:8080"
status_code: 200
register: result
until: result.status == 200 # Welcome page is not really welcoming
# and returns 403 status instead of 200.
retries: 10
delay: 1

0 comments on commit fec7997

Please sign in to comment.