Unable to form a link of a file which is in sites-available to a directory sites-enabled in remote server using ansible?

3

1

Unable to form a link of a file which is in sites-available to a directory sites-enabled in remote server using ansible?

This is command I want to execute using file module of ansible: ln -s /etc/apache2/sites-available/wsgi-keystone.conf /etc/apache2/sites-enabled

This is the code of the task i am using:

- name: Enable the Identity service virtual hosts
  file: src=/etc/apache2/sites-available/wsgi-keystone.conf dest=/etc/apache2/sites-enabled state=link owner=root group=root mode=0644

By the way I am running the playbook as root user:

Getting the following error:

fatal: [10.0.1.32]: FAILED! => {"changed": false, "failed": true, "gid": 0, "group": "root", "mode": "0755", "msg": "refusing to convert between directory and link for /etc/apache2/sites-enabled", "owner": "root", "path": "/etc/apache2/sites-enabled", "size": 4096, "state": "directory", "uid": 0}

Karthik Vee

Posted 2016-04-11T09:28:26.147

Reputation: 53

I'm not so familiar with links, but I did find this short answer on Google Forums. Hopefully it might have a bit of insight.

– DrZoo – 2016-04-11T15:44:21.207

Answers

7

Set force=true to create the symlink.

force the creation of the symlinks in two cases:

  1. the source file does not exist (but will appear later);

  2. the destination exists and is a file (so, we need to unlink the "path" file and create symlink to the "src" file in place in it).

jasonz

Posted 2016-04-11T09:28:26.147

Reputation: 208