Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker issue modifying /etc/hosts inside container #959

Closed
r0ckyte opened this issue Sep 19, 2017 · 4 comments
Closed

Docker issue modifying /etc/hosts inside container #959

r0ckyte opened this issue Sep 19, 2017 · 4 comments

Comments

@r0ckyte
Copy link

r0ckyte commented Sep 19, 2017

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.

@dj-wasabi
Copy link
Contributor

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.

@retr0h
Copy link
Contributor

retr0h commented Sep 19, 2017

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.

@loomsen
Copy link
Contributor

loomsen commented Jun 18, 2018

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 :)

@pbuckley
Copy link

This answered it for me in case google brings anyone else here - docker doesn't let you modify /etc/hosts in a container: William-Yeh/docker-ansible#4 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants