Copy symlink to another location with ansible?
Asked Answered
E

1

6

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?

Eblis answered 26/9, 2014 at 22:28 Comment(0)
F
6

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    
Flashboard answered 29/9, 2014 at 10:54 Comment(1)
First answer is not correct for me, because new symlink points to old symlink, while I want that new symlink will point to old symlink location. Eg: /my/project/location is my project directory, /path/to/symlink points to /my/project/location and /new/path/to/symlink points also to /my/project/location. Sectond anwer is correct.Redbug

© 2022 - 2024 — McMap. All rights reserved.