Molecule: Docker issue modifying /etc/hosts inside container

Created on 19 Sep 2017  路  4Comments  路  Source: ansible-community/molecule

Issue Type

Question

Molecule and Ansible details

ansible --version
2.3.2.0
molecule --version
2.0.4
Molecule installation method: pip
Ansible installation method: One of source, pip, OS package


  • Molecule installation method: One of source, pip
  • Ansible installation method: One of source, pip, OS package

Desired Behaviour

copy the template to /etc/hosts

  • name: Copy the Customize smb.conf file
    template:
    src: etc_samba_smb.conf.j2
    dest: /etc/hosts

Actual Behaviour (Bug report only)

"msg": "Unable to rename file: /root/.ansible/tmp/ansible-tmp-1505841555.17-211086331282294/source to /etc/hosts: [Errno 16] Device or resource busy"

after doing some search i got to know that this is limitation with dockers. can you please advise if you have any work around for this ?

Please give some details of what is actually happening.
Include a minimum complete verifiable example with
output of running molecule --debug.

Most helpful comment

This answered it for me in case google brings anyone else here - docker doesn't let you modify /etc/hosts in a container: https://github.com/William-Yeh/docker-ansible/issues/4#issuecomment-149084120

All 4 comments

I set a specific property to run_not_in_container: False in the group_vars (molecule.yml configuration) and add a when: run_not_in_container for the tasks that can not be run in a Docker container.

I don't know if there is a better way, but works for me.

Also, since we are using Ansible's docker_container module, looks like there is a etc_hosts option, which you can add to create.yml.

Hi.

I'm running into some kind of similar trouble. I can't use etc_hosts in create.yml, cause at this point, I don't know the hosts IP yet. The IP is one of the hosts being created by create.yml. So I need to use hostvars['this.other.host'], but this is obviously only available after the container has been started.

Any ideas are highly appreciated :)

This answered it for me in case google brings anyone else here - docker doesn't let you modify /etc/hosts in a container: https://github.com/William-Yeh/docker-ansible/issues/4#issuecomment-149084120

Was this page helpful?
0 / 5 - 0 ratings