ansible 2.4.2.0
molecule, version 2.7.0
I need configure a custom nameserver into a docker container. (/etc/resolv.conf)
When I run a container manually, I insert the nameserver like this:
How can I add the nameserver with molecule.yml file?
What you can do is, first updating the create.yml file by adding the following line:
dns_servers: "{{ dns_servers.links | default(omit) }}"
to the Create molecule instance(s) task.
In molecule.yml, you can use something like this:
- name: my_host
groups:
- my_fancy_group
image: milcom/centos7-systemd
networks:
- name: container
dns_servers:
- 192.168.1.100
When you execute a molecule test, the container(s) will be created with the dns option.
Thanks @dj-wasabi
Or if you don't feel like setting through molecule.yml you can simply hard code it in create.yml. The whole point of create.yml was to provide flexibility to people to do things the way they felt best.
In the case for docker, we seem to be adding most settings to molecule.yml. However, the more complex drivers (ec2, gce, openstack) most of the create.yml woud be customized by the user.
Also, feel free to submit a PR to add this functionality, so others may benefit.
Thanks @dj-wasabi
It's works with a modification:
dns_servers: "{{ item.dns_servers | default(omit) }}"
I created a PR with the modification
I closed the issue wrongly
Most helpful comment
Thanks @dj-wasabi
It's works with a modification:
dns_servers: "{{ item.dns_servers | default(omit) }}"
I created a PR with the modification
I closed the issue wrongly