Skip to content

Commit

Permalink
Merge pull request #9 from kibatic/default_label
Browse files Browse the repository at this point in the history
Add docker default global labels
  • Loading branch information
eliecharra authored Dec 8, 2017
2 parents 9a050fe + 0afc423 commit 8dd34a3
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ default_volumes:
container_data_home: '/home/cloud/containers'
# Default options passed to docker run
default_docker_options: ''
# Default labels set on each container
default_docker_labels: []
# Default network name
default_network_name: default_network
# Units to be removed from system
Expand Down
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ default_volumes:
- /etc/localtime:/etc/localtime:ro
container_data_home: '/home/cloud/containers'
default_docker_options: ''
default_docker_labels: []
default_network_name: default_network
removed_units: []
1 change: 1 addition & 0 deletions templates/default.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ ExecStart=/usr/bin/docker run {{ default_docker_options }}
{%- endfor %}
{%- endif %}
{% if unit.labels is defined %}{% for label in unit.labels %}--label {{ label }} {% endfor %}{% endif %}
{% for label in default_docker_labels %}--label {{ label }} {% endfor %}
{%- if unit.links is not defined %}
{% set network = unit.network|default(default_network_name) %}
--network={{ network }}
Expand Down
1 change: 1 addition & 0 deletions tests/goss-systemd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ file:
contains: # Check file content for these patterns
- "--add-host test:8.8.8.8"
- "--volume /etc/localtime:/etc/localtime:ro"
- "--label fooLabel=barLabel"
# Cover https://github.com/kibatic/docker-systemd/issues/3
/lib/systemd/system/nginx-host.service:
exists: true
Expand Down
1 change: 1 addition & 0 deletions tests/goss.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ command:
# optional attributes
stdout:
- "\"test_label\": \"foo1234\""
- "\"fooLabel\": \"barLabel\""
stderr: []
timeout: 10000 # in milliseconds
2 changes: 2 additions & 0 deletions tests/units/nginx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ systemd_units:
network: host

default_docker_options: '--add-host test:8.8.8.8'
default_docker_labels:
- fooLabel=barLabel

0 comments on commit 8dd34a3

Please sign in to comment.