Flower7C3
Flower7C3

Reputation: 326

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?

Upvotes: 6

Views: 9007

Answers (1)

Roopendra
Roopendra

Reputation: 7762

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    

Upvotes: 6

Related Questions