From fecf438ec6084f99426dbdb8ce917a94bf62c482 Mon Sep 17 00:00:00 2001
From: nd <git@notandy.de>
Date: Fri, 23 Apr 2021 21:17:05 +0200
Subject: [PATCH] add support to create symlinks

---
 README.md      | 5 ++++-
 tasks/file.yml | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index b7ce5d0..6f68b75 100644
--- a/README.md
+++ b/README.md
@@ -15,9 +15,12 @@ group: root
 # permission bits, can be octal number or the string representation
 mode: 0700
 
-# can be 'present', 'absent', 'directory', or 'touch' (ensure file is created and set modification time to now, but do not change the content)
+# can be 'present', 'absent', 'directory', or 'touch' (ensure file is created and set modification time to now, but do not change the content), 'link'
 state:  present
 
+# target if state is 'link'
+src: ''
+
 # set the file content, mutaly exclusive with "template". Only handeled if the state if 'file'
 content: ''
 
diff --git a/tasks/file.yml b/tasks/file.yml
index 6d71f46..8080a24 100644
--- a/tasks/file.yml
+++ b/tasks/file.yml
@@ -4,6 +4,7 @@
       owner: root
       mode: "0700"
       state: touch
+      src: ~
       content: ~
       template: ~
       template_vars: {}
@@ -20,11 +21,13 @@
     group: "{{ file.group }}"
     owner: "{{ file.owner }}"
     mode: "{{ file.mode }}"
+    src: "{{ file.src }}"
     state: "{{ file.state }}"
 
-- name: create file/folder
+- name: create file/folder and set content
   when:
     - file.content
+    - not file.src
   copy:
     dest: "{{ file.path }}"
     group: "{{ file.group }}"
-- 
GitLab