network_interface
network_interface copied to clipboard
Create the network configuration file for ethernet devices fails to create interface file
--
# file: vagrant.yml
- hosts: testing
remote_user: ansible
vars:
network_ether_interfaces:
- device: eth0
bootproto: static
address: 10.x.x.192
netmask: 255.255.255.0
gateway: 10.x.x.254
roles:
- { role: network_interface, sudo: yes }
- name: Create the network configuration file for ethernet devices
template: src=ethernet_{{ ansible_os_family }}.j2 dest={{ net_path }}/{{ item.device }}.cfg
with_items: network_ether_interfaces
when: network_ether_interfaces is defined
register: ether_result
Execution of the play just hangs. Verbose run:
/bin/sh -c 'sudo -k && sudo -H -S -p "[sudo via ansible, key=rkikxypuytvtphsbalvwtvwxdzygmekv] password: " -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-rkikxypuytvtphsbalvwtvwxdzygmekv; rc=flag; [ -r /etc/network/interfaces.d/eth0.cfg ] || rc=2; [ -f /etc/network/interfaces.d/eth0.cfg ] || rc=1; [ -d /etc/network/interfaces.d/eth0.cfg ] && rc=3; python -V 2>/dev/null || rc=4; [ x"$rc" != "xflag" ] && echo "${rc} "/etc/network/interfaces.d/eth0.cfg && exit 0; (python -c '"'"'"'"'"'"'"'"'import hashlib; BLOCKSIZE = 65536; hasher = hashlib.sha1();
afile = open("'"'"'"'"'"'"'"'"'/etc/network/interfaces.d/eth0.cfg'"'"'"'"'"'"'"'"'", "rb")
buf = afile.read(BLOCKSIZE)
while len(buf) > 0:
hasher.update(buf)
buf = afile.read(BLOCKSIZE)
afile.close()
print(hasher.hexdigest())'"'"'"'"'"'"'"'"' 2>/dev/null) || (python -c '"'"'"'"'"'"'"'"'import sha; BLOCKSIZE = 65536; hasher = sha.sha();
afile = open("'"'"'"'"'"'"'"'"'/etc/network/interfaces.d/eth0.cfg'"'"'"'"'"'"'"'"'", "rb")
buf = afile.read(BLOCKSIZE)
while len(buf) > 0:
hasher.update(buf)
buf = afile.read(BLOCKSIZE)
afile.close()
print(hasher.hexdigest())'"'"'"'"'"'"'"'"' 2>/dev/null) || (echo '"'"'"'"'"'"'"'"'0 '"'"'"'"'"'"'"'"'/etc/network/interfaces.d/eth0.cfg)'"'"''
Running the script by hand I get the follow error.
$ sudo -s
# python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import hashlib
>>> BLOCKSIZE = 65536
>>> hasher = hashlib.sha1()
>>> afile = open('/etc/network/interfaces.d/eth0.cfg','rb')
IOError: [Errno 2] No such file or directory: '/etc/network/interfaces.d/eth0.cfg'