(use-modules (ice-9 filesystem) (ordo)) (define* (install-aws-cli #:key (url "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip") update? install-dir bin-dir) (let* ((conn (current-connection)) (tmp-dir (run conn "mktemp" "-d" #:return car #:check? #t))) (dynamic-wind (const #t) (lambda () (let ((zipfile (file-name-join* tmp-dir (file-basename url)))) (run conn "wget" "-O" zipfile url #:check? #t) (run conn "unzip" zipfile "-d" tmp-dir #:check? #t) (run conn (file-name-join* tmp-dir "aws" "install") (when install-dir `("-i" ,install-dir)) (when bin-dir `("-b" ,bin-dir)) (when update? "-u") #:check? #t))) (lambda () (run conn "rm" "-rf" tmp-dir))))) (playbook #:name "Test Playbook" #:plays (list (play #:name "Test play" #:host "localhost" #:tasks (list (task #:name "Install AWS CLI" #:action (lambda () (install-aws-cli #:update? #t #:install-dir (file-name-join* ($ #:fact.home-dir) ".local" "aws-cli") #:bin-dir (file-name-join* ($ #:fact.home-dir) ".local" "bin"))))))))