#6 standard-test-docker/tasks/main: add var 'my_docker_pre_args'
Closed by bxue. Opened by bxue.
bxue/standard-test-roles localdev  into  master

Download 6.patch

My test makes heavily use of loop devices, which are only available if "docker run" is passed arguments "-v /dev:/dev --privileged"[1] AFAIK. I've failed to utilize var "my_docker_extra_args" for this purpose.

With this commit, assigning 'my_docker_pre_args' in test_docker.yml as following does the trick:
...
vars:
artifacts: ./artifacts
playbooks: ./test_local.yml
my_docker_pre_args: "-v /dev:/dev --privileged"
...

Tested on Fedora 26/rawhide.

  1. https://github.com/moby/moby/issues/27886

I'll check this out.

Note: the "my_docker_extra_args" variable is intended only for use internally within the role, and as (optional) additional arguments to pass along to the docker "run" command. In retrospect, that variable should have been named something like "my_run_cmd_extra_args" to avoid confusion.

This is a great suggestion. However, the new variable also needs to be given a default value in the role's defaults/main.yml file. Otherwise, every use of the role from a playbook that does not provide a value for the variable will result in a fatal ansible error due to referencing an undefined variable.

I would ask that you please make the following additional changes for this PR:

  1. Rename your new variable to docker_extra_args to eliminate the "my_" prefix that suggests it is an internal use only variable and more accurately reflect it's purpose.
  2. Append the line docker_extra_args: null to roles/standard-test-docker/defaults/main.yml.
  3. Rename each of the references of the variable my_docker_extra_args to my_run_cmd_extra_args within roles/standard-test-docker/tasks/main.yml to more accurately reflect it's purpose and correct my poor choice for the variable name when I originally authored the role. Thank you!

rebased

Pull-Request has been closed by bxue

Metadata