Skip to content

Commit

Permalink
Add purge_networks arg to docker driver
Browse files Browse the repository at this point in the history
Users building containers in isolated docker networks may not want the
default docker bridge network attached.
  • Loading branch information
logan2211 committed Nov 2, 2018
1 parent db0fb68 commit 228184e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions molecule/driver/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class Docker(base.Base):
- name: foo
- name: bar
network_mode: host
purge_networks: true
docker_host: tcp://localhost:12376
env:
FOO: bar
Expand Down
3 changes: 3 additions & 0 deletions molecule/model/schema_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,9 @@ def pre_validate_base_schema(env, keep_string):
'network_mode': {
'type': 'string',
},
'purge_networks': {
'type': 'boolean',
}
}
}
},
Expand Down
1 change: 1 addition & 0 deletions molecule/provisioner/ansible/playbooks/docker/create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
ulimits: "{{ item.ulimits | default(omit) }}"
networks: "{{ item.networks | default(omit) }}"
network_mode: "{{ item.network_mode | default(omit) }}"
purge_networks: "{{ item.purge_networks | default(omit) }}"
dns_servers: "{{ item.dns_servers | default(omit) }}"
env: "{{ item.env | default(omit) }}"
restart_policy: "{{ item.restart_policy | default(omit) }}"
Expand Down
1 change: 1 addition & 0 deletions test/resources/playbooks/docker/create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
ulimits: "{{ item.ulimits | default(omit) }}"
networks: "{{ item.networks | default(omit) }}"
network_mode: "{{ item.network_mode | default(omit) }}"
purge_networks: "{{ item.purge_networks | default(omit) }}"
dns_servers: "{{ item.dns_servers | default(omit) }}"
env: "{{ item.env | default(omit) }}"
restart_policy: "{{ item.restart_policy | default(omit) }}"
Expand Down
4 changes: 4 additions & 0 deletions test/unit/model/v2/test_platforms_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ def _model_platforms_docker_section_data():
],
'network_mode':
'mode',
'purge_networks':
True,
'foo':
'bar'
}]
Expand Down Expand Up @@ -164,6 +166,7 @@ def _model_platforms_docker_errors_section_data():
},
],
'network_mode': int(),
'purge_networks': int(),
}]
}

Expand Down Expand Up @@ -216,6 +219,7 @@ def test_platforms_docker_has_errors(_config):
}]
}],
'network_mode': ['must be of string type'],
'purge_networks': ['must be of boolean type'],
'ulimits': [{
0: ['must be of string type']
}],
Expand Down

0 comments on commit 228184e

Please sign in to comment.