From 5a114cf6ae50ddc9fa66d5cd140e5ad7ef6f71d5 Mon Sep 17 00:00:00 2001
From: Daniel Heule <hda@sfs.biz>
Date: Tue, 14 Jan 2014 10:11:33 +0100
Subject: [PATCH] __cron should replace entrys with his id, try 2

---
 cdist/conf/type/__cron/explorer/entry | 2 +-
 cdist/conf/type/__cron/gencode-remote | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/cdist/conf/type/__cron/explorer/entry b/cdist/conf/type/__cron/explorer/entry
index 15d9bdba..c3bf02d2 100644
--- a/cdist/conf/type/__cron/explorer/entry
+++ b/cdist/conf/type/__cron/explorer/entry
@@ -22,4 +22,4 @@
 name="$__object_name"
 user="$(cat "$__object/parameter/user")"
 
-crontab -u $user -l 2>/dev/null | grep "# $name\$" | head -n 1 || true
+crontab -u $user -l 2>/dev/null | grep "# $name\$" || true
diff --git a/cdist/conf/type/__cron/gencode-remote b/cdist/conf/type/__cron/gencode-remote
index 712eb1a1..77a63b9b 100755
--- a/cdist/conf/type/__cron/gencode-remote
+++ b/cdist/conf/type/__cron/gencode-remote
@@ -78,8 +78,9 @@ DONE
 
 case "$state_should" in
     present)
+        # if we insert new entry, filter also all entrys out with the same id 
         echo "("
-        echo "crontab -u $user -l 2>/dev/null | grep -v -E \"$filter\" 2>/dev/null || true"
+        echo "crontab -u $user -l 2>/dev/null | grep -v -E \"$filter\" | grep -v \"# $name\\$\" 2>/dev/null || true"
         echo "echo '$entry'"
         echo ") | crontab -u $user -"
     ;;