# coding: utf-8
import fabric.api as fab
import cuisine


def install(filename, user="root"):
    """
    Installs crontab from a given cronfile
    """
    tmp_file = fab.run("mktemp fabixcron.XXXX")
    cuisine.file_upload(tmp_file, filename)
    fab.sudo("crontab -u{} {}".format(user, tmp_file))

@@ -88,11 +88,25 @@
 oot%22
+, append=False
 ):%0A
-
     
@@ -164,24 +164,27 @@
 %22%22%22%0A    
-tmp_file
+new_crontab
  = fab.r
@@ -239,28 +239,242 @@
 oad(
-tmp_file, filename)%0A
+new_crontab, filename)%0A    if append is True:%0A        sorted_crontab = fab.run(%22mktemp fabixcron.XXXX%22)%0A        # When user have no crontab, then crontab command returns 1 error code%0A        with fab.settings(warn_only=True):%0A        
     
@@ -497,35 +497,227 @@
 b -u
+ 
 %7B%7D 
-%7B%7D%22.format(user, tmp_file
+-l %3E%3E %7B%7D 2%3E /dev/null%22.format(user, new_crontab))%0A        fab.sudo(%22sort -u -o %7B%7D %7B%7D%22.format(sorted_crontab, new_crontab))%0A        new_crontab = sorted_crontab%0A    fab.sudo(%22crontab -u %7B%7D %7B%7D%22.format(user, new_crontab
 ))%0A

Add option to append to crontab instead of replace it