3

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}
jasonz
  • 228
  • 1
  • 6
Karthik Vee
  • 53
  • 1
  • 6
  • I'm not so familiar with links, but I did find [this](https://groups.google.com/forum/#!msg/ansible-project/Q5KdwEjugI8/e_kmGGYUX8AJ) short answer on Google Forums. Hopefully it might have a bit of insight. – DrZoo Apr 11 '16 at 15:44

1 Answers1

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

DavidPostill
  • 153,128
  • 77
  • 353
  • 394
jasonz
  • 228
  • 1
  • 6