ansible roles are not copying template configuration into container hosts
See original GitHub issueIssue Type
- Bug report
Molecule and Ansible details
ansible --version && molecule --version
ansible 2.7.10
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.5 (default, Apr 9 2019, 14:30:50) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]
molecule, version 2.20.1
Molecule installation method (one of):
- pip
Ansible installation method (one of):
- OS package
Detail any linters or test runners used:
dependency: name: galaxy driver: name: docker lint: name: yamllint platforms:
- name: inpup01p1
hostname: inpup01p1
image: puppetmaster:2.0
pre_build_image: True
privileged: True
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro command: “/usr/sbin/init” capabilities:
- SYS_ADMIN networks:
- name: example
- name: nocon01p1
hostname: nocon01p1
image: centos:7.6
pre_build_image: True
privileged: True
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro command: “/usr/sbin/init” capabilities:
- SYS_ADMIN exposed_ports:
- 8500/tcp
- 8500/udp
- 8301/tcp
- 8301/udp published_ports:
- 0.0.0.0:8500:8500/tcp
- 0.0.0.0:8500:8500/udp networks:
- name: example
- name: nocon02p1
hostname: nocon02p1
image: centos:7.6
pre_build_image: True
privileged: True
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro command: “/usr/sbin/init” capabilities:
- SYS_ADMIN exposed_ports:
- 8500/tcp
- 8500/udp
- 8301/tcp
- 8301/udp networks:
- name: example
- name: nocon03p1
hostname: nocon03p1
image: centos:7.6
pre_build_image: True
privileged: True
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro command: “/usr/sbin/init” capabilities:
- SYS_ADMIN exposed_ports:
- 8500/tcp
- 8500/udp
- 8301/tcp
- 8301/udp networks:
- name: example
- name: nocon04p1
hostname: nocon04p1
image: centos:7.6
pre_build_image: True
privileged: True
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro command: “/usr/sbin/init” capabilities:
- SYS_ADMIN exposed_ports:
- 8500/tcp
- 8500/udp
- 8301/tcp
- 8301/udp networks:
- name: example provisioner: name: ansible options: vvv: true lint: name: ansible-lint playbooks: prepare: prepare.yaml env: ANSIBLE_ROLES_PATH: …/resources/roles/ verifier: name: testinfra lint: name: flake8
prepare.yaml
- hosts: nocon01p1, nocon02p1, nocon03p1
gather_facts: true
vars:
hosts_add_basic_ipv6: false
hosts_add_ansible_managed_hosts: true
hosts_network_interface: eth1
hosts_entries:
- name: pulp
ip: 10.173.96.177
aliases:
- pulp
roles:
- hosts
i am using this roles
https://github.com/bertvv/ansible-role-hosts.git
Desired Behavior
it should modify hosts file of every container.
Actual Behaviour
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_copy_payload_lofnwe/ansible_copy_payload.zip/ansible/module_utils/basic.py", line 2592, in atomic_move
os.rename(b_tmp_dest_name, b_dest)
OSError: [Errno 16] Device or resource busy
fatal: [nocon01p1]: FAILED! => {
"changed": false,
"checksum": "4b3f405fab4e3570f9bae91a12c2475c1d8feef1",
"diff": [],
"invocation": {
"module_args": {
"_original_basename": "etc_hosts.j2",
"attributes": null,
"backup": false,
"checksum": "4b3f405fab4e3570f9bae91a12c2475c1d8feef1",
"content": null,
"delimiter": null,
"dest": "/etc/hosts",
"directory_mode": null,
"follow": false,
"force": true,
"group": "root",
"local_follow": null,
"mode": 420,
"owner": "root",
"regexp": null,
"remote_src": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"src": "/root/.ansible/tmp/ansible-tmp-1558616775.13-94474003016736/source",
"unsafe_writes": null,
"validate": null
}
},
"msg": "Unable to make /root/.ansible/tmp/ansible-tmp-1558616775.13-94474003016736/source into to /etc/hosts, failed final rename from /etc/.ansible_tmpV1vvPLhosts: [Errno 16] Device or resource busy"
}
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_copy_payload_Ptxd2h/ansible_copy_payload.zip/ansible/module_utils/basic.py", line 2592, in atomic_move
os.rename(b_tmp_dest_name, b_dest)
OSError: [Errno 16] Device or resource busy
fatal: [nocon02p1]: FAILED! => {
"changed": false,
"checksum": "a7779bc0e68106719907e1a97bf50d1cdae8b2e7",
"diff": [],
"invocation": {
"module_args": {
"_original_basename": "etc_hosts.j2",
"attributes": null,
"backup": false,
"checksum": "a7779bc0e68106719907e1a97bf50d1cdae8b2e7",
"content": null,
"delimiter": null,
"dest": "/etc/hosts",
"directory_mode": null,
"follow": false,
"force": true,
"group": "root",
"local_follow": null,
"mode": 420,
"owner": "root",
"regexp": null,
"remote_src": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"src": "/root/.ansible/tmp/ansible-tmp-1558616775.31-186801450187651/source",
"unsafe_writes": null,
"validate": null
}
},
"msg": "Unable to make /root/.ansible/tmp/ansible-tmp-1558616775.31-186801450187651/source into to /etc/hosts, failed final rename from /etc/.ansible_tmpQrJsbPhosts: [Errno 16] Device or resource busy"
}
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_copy_payload_Iy2DSa/ansible_copy_payload.zip/ansible/module_utils/basic.py", line 2592, in atomic_move
os.rename(b_tmp_dest_name, b_dest)
OSError: [Errno 16] Device or resource busy
fatal: [nocon03p1]: FAILED! => {
"changed": false,
"checksum": "9c7e1cc5ddc28c69784f653c4a1e5ea229880706",
"diff": [],
"invocation": {
"module_args": {
"_original_basename": "etc_hosts.j2",
"attributes": null,
"backup": false,
"checksum": "9c7e1cc5ddc28c69784f653c4a1e5ea229880706",
"content": null,
"delimiter": null,
"dest": "/etc/hosts",
"directory_mode": null,
"follow": false,
"force": true,
"group": "root",
"local_follow": null,
"mode": 420,
"owner": "root",
"regexp": null,
"remote_src": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"src": "/root/.ansible/tmp/ansible-tmp-1558616775.32-192566833611638/source",
"unsafe_writes": null,
"validate": null
}
},
"msg": "Unable to make /root/.ansible/tmp/ansible-tmp-1558616775.32-192566833611638/source into to /etc/hosts, failed final rename from /etc/.ansible_tmpspRaPhhosts: [Errno 16] Device or resource busy"
}
output of running molecule --debug
.
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Template a file out to a target host - Ansible Documentation
The jinja2_native setting has no effect. Native types are never used in the template module which is by design used for generating text...
Read more >Choosing between Ansible's copy and template modules
When it comes to transferring files to a remote system with Ansible, the copy and template modules are great tools for the job....
Read more >How to Create Ansible Templates to Save Configuration Time
Most Ansible admins use the copy module to transfer files to remote hosts but, as mentioned above, this isn't feasible with templates. Below...
Read more >How I can transfer Jinja2 template on diffrent container using ...
I configured nginx using localhost. But now how can I use template Jinja2 and transfer it on container using ansible. --- - hosts:...
Read more >How To Test & Build Quickly Ansible Roles ... - Getbetterdevops
The files directory contains files targeted to be copied to target hosts ... not in ansible_skip_tags" - name: Wordpress | Configure php.ini template:...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I found answer on this comment , may be it help.
This has nothing to do with Molecule, is pure Ansible user issue.