Skip to content

Commit

Permalink
Fix override_command to support multiple platforms (#1785)
Browse files Browse the repository at this point in the history
Closes #1780.

Signed-off-by: Luke Murphy <[email protected]>
  • Loading branch information
decentral1se authored Feb 28, 2019
1 parent ca783e4 commit 995efc8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions molecule/provisioner/ansible/playbooks/docker/create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@
state: present
with_items: "{{ molecule_yml.platforms | molecule_get_docker_networks }}"

- name: Determine the CMD directive
- name: Determine the CMD directives
set_fact:
command_directive: "{{ item.command | default('bash -c \"while true; do sleep 10000; done\"') }}"
command_directives_dict: >-
{{ command_directives_dict | default({}) |
combine({ item.name: item.command | default('bash -c "while true; do sleep 10000; done"') })
}}
with_items: "{{ molecule_yml.platforms }}"
when: item.override_command | default(true)

Expand All @@ -70,7 +73,7 @@
state: started
recreate: false
log_driver: json-file
command: "{{ command_directive | default(omit) }}"
command: "{{ command_directives_dict[item.name] | default(omit) }}"
pid_mode: "{{ item.pid_mode | default(omit) }}"
privileged: "{{ item.privileged | default(omit) }}"
security_opts: "{{ item.security_opts | default(omit) }}"
Expand Down
9 changes: 6 additions & 3 deletions test/resources/playbooks/docker/create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@
state: present
with_items: "{{ molecule_yml.platforms | molecule_get_docker_networks }}"

- name: Determine the CMD directive
- name: Determine the CMD directives
set_fact:
command_directive: "{{ item.command | default('bash -c \"while true; do sleep 10000; done\"') }}"
command_directives_dict: >-
{{ command_directives_dict | default({}) |
combine({ item.name: item.command | default('bash -c "while true; do sleep 10000; done"') })
}}
with_items: "{{ molecule_yml.platforms }}"
when: item.override_command | default(true)

Expand All @@ -70,7 +73,7 @@
state: started
recreate: false
log_driver: json-file
command: "{{ command_directive | default(omit) }}"
command: "{{ command_directives_dict[item.name] | default(omit) }}"
pid_mode: "{{ item.pid_mode | default(omit) }}"
privileged: "{{ item.privileged | default(omit) }}"
security_opts: "{{ item.security_opts | default(omit) }}"
Expand Down

0 comments on commit 995efc8

Please sign in to comment.