Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy symlink to another location with ansible?

I have my symlink and want to create new symlink, that points to the same location that first symlink points. I know I can use cp -d /path/to/symlink /new/path/to/symlink. But how do it with ansible module?

I was trying copy: src=/path/to/symlink dest=/new/path/to/symlink follow=yes but it makes a copy of symlink instead create new symlink. Any ideas?

like image 579
Bartłomiej Jakub Kwiatek Avatar asked Sep 26 '14 22:09

Bartłomiej Jakub Kwiatek


1 Answers

You have two option here.

1) Create New Symlink using file module.

- name: Create symlink
  file: src=/path/to/symlink  dest=/new/path/to/symlink state=link

2) Run your working command to copy symlink using shell it will do the same.

- name: Create symlink
  shell: cp -d /path/to/symlink /new/path/to/symlink    
like image 184
Roopendra Avatar answered Oct 05 '22 13:10

Roopendra