azubi 0.1.0.0 → 0.1.0.1
raw patch · 4 files changed
+224/−151 lines, 4 filesdep −hspecPVP ok
version bump matches the API change (PVP)
Dependencies removed: hspec
API changes (from Hackage documentation)
Files
- README.md +219/−0
- azubi.cabal +5/−41
- config.hs +0/−88
- test/Test.hs +0/−22
+ README.md view
@@ -0,0 +1,219 @@+# Azubi++[](https://travis-ci.org/mrVanDalo/azubi)++Is a very simple DevOps tool, which will never "reach" enterprise level.++## Goals++* Readable -> Haskell+* Check your rule set before changing your system -> Strong Type-system of Haskell+* Adaptive, -> can run on all kinds of Linux and it is also planed to run on osx and Windows+* Lightweight -> No installation (except some basic shell tools) needed on the target host.++## Features++### Different types of Execution++You can ++* enforce everything by command line (not yet)+* create a bash script which you can run for system setup+* use ssh to setup a target host (not yet)+* create different configurations for different situations (not yet)+* export to a Dockerfile (not yet)+* export to a Bat file (not yet)++### How to start++Install `azubi` via cabal.++ cabal install azubi++create a file (e.g. `config.hs`) somewhere you like with the content++ #!/usr/bin/env runghc+ + import Azubi+ + main :: IO ()+ main = azubiMain $ azubiConfig Gentoo $ []+ & installed "vim"+++call the script to get a help++ ./config.hs --help+++call the script to get a bashscript++ ./config.hs --output "my-first-azubi-script.sh"+++# Syntax++## Commands++Every Command should be revertable.++### installed++#### Package ++install vim if not already done:++ & installed "vim"++uninstall vim if vim is installed:++ ! installed "vim"++### exists++#### Files++create files, directories and symlinks : ++ & exists (File "~/.vimrc")+ & exists (Directory "~/.vim")+ & exists (Symlink ".bashrc" "~/.bashrc.d/bashrc")+ +delete files files, directories and symlinks : ++ & exists (File "~/.vimrc")+ & exists (Directory "~/.vim")+ & exists (Symlink ".bashrc" "~/.bashrc.d/bashrc")++#### Git projects++pull git repository if not pressent:++ & exists (Git "git@github.com:mrVanDalo/azubi.git" "~/develop/azubi" [Branch "develop"])++you can give it options++* *Branch "branchname"*+* *Recursive*+* more to follow ... +++## Logic Components+++### Combiner++#### &, !++Almost every command should be revertable. So you have 2 states++* do it -> `&`+* undo it -> `!`++this ensures the file `/tmp/foo` exist++ & exists (File "/tmp/foo")++and this ensures the file does not exist++ ! exists (File "/tmp/foo")++In most cases it happens what you expect, but sometimes it's not so obvious so we it is written right next to the command.+(e.g.:) `! exists (File "/tmp/foo")` will delete a file `/tmp/foo` but won't delete a directory `/tmp/foo`++#### !?&,!?!, &?&, &?!++They are special cases of `!` and `&` and should be read like `X if in context Y` -> `X?Y` and start only to make +sense in combination of submodules (see later).++* `&?&` is `&` if you are in a `do it` context.+* `!?&` is `!` if you are in a `do it` context.+* `&?!` is `&` if you are in a `undo it` context.+* `!?!` is `!` if you are in a `undo it` context.++for example ++ & (submodule $ []+ &?& contains (File "/dev/shm/test") ["text"]+ & exists (Symlink "~/.vimrc" "/dev/shm/test")+ )++would be reverted like this++ ! (submodule $ []+ &?& contains (File "/dev/shm/test") ["text"]+ & exists (Symlink "~/.vimrc" "/dev/shm/test")+ )++which is similar to ++ ! exists (Symlink "~/.vimrc" "/dev/shm/test")+ ++### `submodule`++to group a bunch of command together to on command you can negate all at once if you want.+But you can create a much more sophisticated combination of commands using+`!?&`,`!?!`,`&?&` and `&?!`.++for example ++ & (submodule $ []+ & contains (File "/dev/shm/test") ["text"]+ & exists (Symlink "~/.vimrc" "/dev/shm/test")+ )++is equivalent to++ & contains (File "/dev/shm/test") ["text"]+ & exists (Symlink "~/.vimrc" "/dev/shm/test")++but could be reverted like this++ ! (submodule $ []+ & contains (File "/dev/shm/test") ["text"]+ & exists (Symlink "~/.vimrc" "/dev/shm/test")+ )++which is equivalent to++ ! contains (File "/dev/shm/test") ["text"]+ ! exists (Symlink "~/.vimrc" "/dev/shm/test")++### `requires`++is used to create dependencies like "first do *this*, and when everything is fine do *this*".+They make most sense with submodules++ & ((submodule $ []+ & exists (Symlink "~/.vim" "~/.dot_vim")+ & exists (Symlink "~/.vimrc" "~/.vim/vimrc")+ ) + `requires` + (submodule $ []+ & exists (Git "git@github.com/myrepo/dot_vim.git" "~/.dot_vim" [Recursive])+ ))+ +If `requires` is called in a reverting context (e.g. using `!`) it will also create a dependency +but twisted and the body will be reverted as well.++ ! ((submodule $ []+ & exists (Symlink "~/.vim" "~/.dot_vim")+ & exists (Symlink "~/.vimrc" "~/.vim/vimrc")+ ) + `requires` + (submodule $ []+ & exists (Git "git@github.com/myrepo/dot_vim.git" "~/.dot_vim" [Recursive])+ ))+ +is equivalent to++ & ((submodule $ []+ ! exists (Git "git@github.com/myrepo/dot_vim.git" "~/.dot_vim" [Recursive])+ )+ `requires` + (submodule $ []+ ! exists (Symlink "~/.vim" "~/.dot_vim")+ ! exists (Symlink "~/.vimrc" "~/.vim/vimrc")+ ))+
azubi.cabal view
@@ -10,20 +10,19 @@ -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change-version: 0.1.0.0+version: 0.1.0.1 -- A short (one-line) description of the package.-synopsis: -synopsis: A simple DevOps tool which will "reach" the enterprice level.+synopsis: A simple DevOps tool which will never "reach" enterprice level. -- A longer description of the package.-description: A simple DevOps tool which will "reach" the enterprice level.+description: A simple DevOps tool which will never "reach" enterprice level. It is basically a Haskell lib which you can use to create nice scripts that setup you computer, via ssh bashscrip, Dockerfile, etc -- URL for the project homepage or repository.-homepage: http://azubi.github.com+homepage: http://palovandalo.com/azubi -- The license under which the package is released. license: GPL-3@@ -47,7 +46,7 @@ -- Extra files to be distributed with the package, such as examples or a -- README.--- extra-source-files: +extra-source-files: README.md -- Constraint on the version of Cabal needed to build this package. cabal-version: >=1.10@@ -82,38 +81,3 @@ type: git location: git@github.com:mrVanDalo/azubi.git --executable config- -- .hs or .lhs file containing the Main module.- main-is: config.hs-- -- ghc-options: -Wall- -- Modules included in this executable, other than Main.- -- other-modules:-- -- LANGUAGE extensions used by modules in this package.- -- other-extensions:-- -- Other library packages from which modules are imported.- build-depends: base >=4.7 && < 5- , filepath >=1 && < 2- , options >= 1.2 && < 2-- -- Directories containing source files.- hs-source-dirs: .- , src- - -- Base language which the package is written in.- default-language: Haskell2010---test-suite test- build-depends: base >= 4.7 && < 5- , filepath >=1 && < 2- , hspec >= 2.3-- type: exitcode-stdio-1.0- main-is: Test.hs- hs-source-dirs: src test- default-language: Haskell2010- buildable: True
− config.hs
@@ -1,88 +0,0 @@---import Azubi--main :: IO ()-main = azubiMain azubiSetup---azubiSetup :: AzubiConfig-azubiSetup = azubiConfig Gentoo $ []- & contains (File "~/azubi-config/azubi-config.cabal") [ "name: azubi-config"- , "version: 0.1.0.0"- , "build-type: Simple"- , "cabal-version: >=1.10"- , ""- , "executable config"- , " main-is: config.hs"- , " build-depends: base >=4.8 && < 4.9"- , " , azubi"- , " hs-source-dirs: ."- , " default-language: Haskell2010"- ]- & contains (File "~/azubi-config/config-example.hs") ( map (\c -> "-- | " ++ c ) azubiLogo- ++ [ ""- , "import Azubi"- , ""- , "main :: IO ()"- , "main = azubiMain $ azubi Gentoo $ []"- , " & installed \"vim\""- , " ! installed \"salt\""- ])- & contains (File "~/azubi-config/README.md") [ "# Azubi Example"- , ""- , "## How to start"- , ""- , "copy or link the config-example.hs file to config.hs"- , "and run cabal configure."- , "now you can start editing config.hs and run cabal run."- , "this will create a azubi.sh file you can run."- , ""- , " cabal run && bash azubi.sh"]----- | example------ myConfig :: AzubiConfig--- myConfig = azubiConfig Gentoo $ []--- & installed "vim"--- ! installed "salt"--- & (submodule $ []--- ! exists (Directory "/dev/shm/azubi-test")--- & contains (File "/dev/shm/azubi/contains") [ "this is a azubi test-line : " ++ (show i) | i <- [1,2..10]]--- & exists (Symlink "/dev/shm/azubi-link" "/dev/shm/azubi/contains")--- )--- ! (submodule $ []--- & installed "sub-emacs"--- & installed "sub-vim"--- )--- ! exists (Directory "/dev/shm/Downloads")--- ! exists (Directory "/dev/shm/Documents")--- & ((submodule $ []--- & contains (File "/etc/vim/config") ["# config"]--- ) `requires` (submodule $ []--- & installed "vim"--- ))--- & installed "vim"--- ! exists (File "/dev/shm")---- next :--- --------- commands--- git---- | todo : make logfile configurable----- sketch on the syntax------ main = do--- azubi Gentoo $ []--- & User.exists "palo" [ Uid 1000, Gid 1000 ]--- & User.exists "renoise" [ Uid 1001, Home "/home/music" ]--- & running "service"--- & uptodate (Git "/home/palo/.dot_i3/" "git@github.com/mrVanDalo/dot_i3" "master") -- | does pulls--- & uptodate (GitWithSubmodules "/home/palo/.dot_jack" "git@github.com/mrVanDalo/dot_jack" "master") -- | same but also takes car of submodules--- & backup (File "/etc/ssh/") (Directory "/backups/etc/ssh") -- | will "cp -a /etc/ssh /backups/etc/ssh/`date`"--- & published (Git "/home/palo/.dot_shell" "git@github.com/mrVanDalo/dot_shell" "master" "azubi wip message") -- | creates commits and pushes on the master branch using default message---
− test/Test.hs
@@ -1,22 +0,0 @@---import Test.Hspec--import Core.TestSyntax--import Commands.TestInstall-import Commands.TestFile-import Commands.TestGit--import Render.TestBashScript---- | tests--main :: IO ()-main = hspec $ do- testInstall- testFile- testSyntax- testGit- testBashScript-