basante basante - 3 months ago 37
Python Question

ansible "the directory /usr/lib/ is not empty, refusing to convert it"

I'm trying to create symlinks with ansible:

file: src=/usr/lib/x86_64-linux-gnu/{{ item.src }} dest=/usr/lib/ state=link force=yes
with_items:
- { src: 'libz.so'}
- { src: 'libfreetype.so'}
- { src: 'libjpeg.so'}


and I'm getting this:

failed: [192.168.2.2] (item={u'dest': u'/usr/lib/', u'src': u'libz.so'}) => {"failed": true, "gid": 0, "group": "root", "item": {"dest": "/usr/lib/", "src": "libz.so"}, "mode": "0755", "msg": "the directory /usr/lib/ is not empty, refusing to convert it", "owner": "root", "path": "/usr/lib/", "size": 4096, "state": "directory", "uid": 0}

Answer

You are trying to link the whole /usr/lib directory to the file.

Append {{ item.src }} to your dest

file: src=/usr/lib/x86_64-linux-gnu/{{ item.src }} dest=/usr/lib/{{ item.src }} state=link force=yes
with_items:
   - { src: 'libz.so'}
   - { src: 'libfreetype.so'}
   - { src: 'libjpeg.so'}