From 3045a40ba77dee48aab90567a5acb06e50bca4b0 Mon Sep 17 00:00:00 2001 From: samuel Date: Tue, 12 May 2020 12:06:57 +0200 Subject: [PATCH] adding org files --- sami/.gitignore | 21 +++++++ sami/my-cdist/.cdist/files/motd | 1 + sami/my-cdist/.cdist/manifest/init | 15 +++++ .../.cdist/type/__my_computer/manifest | 10 ++- sami/my-org-files/#cdist.org# | 63 +++++++++++++++++++ sami/my-org-files/cdist.org/cdist#1-intro.org | 38 +++++++++++ sami/my-org-files/cdist.org/cdist#2-type.org | 24 +++++++ sami/my-org-files/cdist.org/cdist.org | 15 +++++ 8 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 sami/.gitignore create mode 100644 sami/my-cdist/.cdist/files/motd create mode 100644 sami/my-org-files/#cdist.org# create mode 100644 sami/my-org-files/cdist.org/cdist#1-intro.org create mode 100644 sami/my-org-files/cdist.org/cdist#2-type.org create mode 100644 sami/my-org-files/cdist.org/cdist.org diff --git a/sami/.gitignore b/sami/.gitignore new file mode 100644 index 0000000..72e7b61 --- /dev/null +++ b/sami/.gitignore @@ -0,0 +1,21 @@ + +# Created by https://www.gitignore.io/api/linux +# Edit at https://www.gitignore.io/?templates=linux + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +# End of https://www.gitignore.io/api/linux + diff --git a/sami/my-cdist/.cdist/files/motd b/sami/my-cdist/.cdist/files/motd new file mode 100644 index 0000000..7ce6bf3 --- /dev/null +++ b/sami/my-cdist/.cdist/files/motd @@ -0,0 +1 @@ +my message of the day diff --git a/sami/my-cdist/.cdist/manifest/init b/sami/my-cdist/.cdist/manifest/init index e69de29..8f12e3b 100644 --- a/sami/my-cdist/.cdist/manifest/init +++ b/sami/my-cdist/.cdist/manifest/init @@ -0,0 +1,15 @@ +case "$__target_host" in + localhost) + #target is configured with cdist + __file /etc/cdist-configured + + # motd from th file directory + __motd --source "$__files/motd" + + __timezone Europe/Zurich + + # types to be used + __my_computer +;; +esac + diff --git a/sami/my-cdist/.cdist/type/__my_computer/manifest b/sami/my-cdist/.cdist/type/__my_computer/manifest index 07320cd..662e44c 100755 --- a/sami/my-cdist/.cdist/type/__my_computer/manifest +++ b/sami/my-cdist/.cdist/type/__my_computer/manifest @@ -19,7 +19,15 @@ # # # Ensure sipcalc is present -# + __package sipcalc --state present +__package emacs --state present + +__package firefox --state present + +__package nmap --state present + +__package zsh --state present + diff --git a/sami/my-org-files/#cdist.org# b/sami/my-org-files/#cdist.org# new file mode 100644 index 0000000..cef418c --- /dev/null +++ b/sami/my-org-files/#cdist.org# @@ -0,0 +1,63 @@ + + + + + +*** cdist #1: Introduction +**** Lecture content +***** Objective +****** Begin to use cdist +***** Steps +****** Checkout cdist quickstart https://www.cdi.st/manual/latest/cdist-quickstart.html +****** Install cdist locally +****** Create a new cdist configuration directory in ~/ungleich-learning-circle/USERNAME/dot-cdist +****** Create an empty initial manifest ("use touch") +****** Commit that status +****** Ensure that you can login as root to localhost via ssh without a password +****** Configure cdist to configures the motd of your localhost +******* Ensure you have a case block matching on $__target_host +******* Use the -c parameter to cdist to specify the configuration directory +******* Use the -vv parameter to get more verbose output +******* Search for / understand what MOTD stands for +****** Configure cdist to create the file /etc/cdist-configured +****** Configure cdist to setup the timezone on your local computer +****** Configure cdist to ensure emacs is installed +****** Ensure that in the end all changes are committed in your repository + + + + + + + + + + + + + + + + + + + + + + + +* cdist #5: Generating Code & Exploring + +* Understanding how to generate code and when to use it +** define gencode-remote script: ~/.cdist/type/__nginx_site. After manifest is applied it should restart services so configuration is active. Our gencode-remote looks like echo "service nginx restart" + +* Modify the previously created type *__my_nginx_site* +** We modify the previously created type so that the gencode-remote script reacts accordingly +- echo "if_configurationfile_changes" >> "$__messages_out" + +* Read about cdist messaging +** cdist has a simple but powerful way of allowing communication between the initial manifest and types as well as types and types. +* What is the difference between gencode-local and gencode-remote? + +** gencode-remote used to generate code to be executed on the target host +** gencode-local used to generate code to be executed on the source host \ No newline at end of file diff --git a/sami/my-org-files/cdist.org/cdist#1-intro.org b/sami/my-org-files/cdist.org/cdist#1-intro.org new file mode 100644 index 0000000..89f31bc --- /dev/null +++ b/sami/my-org-files/cdist.org/cdist#1-intro.org @@ -0,0 +1,38 @@ +*** cdist #1: Introduction +**** Lecture content +***** Objective +****** Begin to use cdist +***** Steps +****** Install cdist locally https://www.cdi.st/manual/latest/cdist-quickstart.html +****** Create a new cdist configuration directory in ~/ungleich-learning-circle/USERNAME/dot-cdist +****** Create an empty initial manifest +****** Commit that status +****** Ensure that you can login as root to localhost via ssh without a password +****** Configure cdist to configures the motd of your localhost +******* Ensure you have a case block matching on $__target_host +******* Use the -c parameter to cdist to specify the configuration directory +******* Use the -vv parameter to get more verbose output +****** Configure cdist to create the file /etc/cdist-configured +****** Configure cdist to setup the timezone on your local computer +****** Configure cdist to ensure emacs is installed +****** Ensure that in the end all changes are committed in your repository + +* init.file +- sami@cdist/manifest$ cat init +case "$__target_host" in + localhost) + #target is configured with cdist + __file /etc/cdist-configured + + # motd from th file directory + __motd --source "$__files/motd" + + __timezone Europe/Zurich + + +;; +esac + + +* Types manifest for installing packages or insuring that packages are installed +- __package emacs --state present diff --git a/sami/my-org-files/cdist.org/cdist#2-type.org b/sami/my-org-files/cdist.org/cdist#2-type.org new file mode 100644 index 0000000..614d705 --- /dev/null +++ b/sami/my-org-files/cdist.org/cdist#2-type.org @@ -0,0 +1,24 @@ +*** cdist #2: Your first cdist type +**** Lecture content +***** Objective +****** Begin to understand how cdist types function +******* Types are the main component of cdist and define functionality. If you use cdist, you'll write a type for every functionality you would like to use. +***** Steps +****** Create a new type named `__my_computer` + - Mark the type as a singleton type (If a type is flagged as a singleton, it may be used only once per host.) + - Create a `manifest` file in it + - Use this type to install the following packages: zsh, mosh, emacs, nmap, sipcalc + - Edit the *initial manifest* and use **__my_computer** - Here we have to simply add __my_computer in the types file + **localhost** + - Match using the $__target_host variable +****** Modify your type to use a *for loop* to install the packages +****** Deploy / manage your ~/.emacs file in this type + - Ensure that permissions and ownership are correct +****** Use different *verbosity* levels when configuring +****** Ensure that all your changes are committed and pushed in your ungleich-learning-circle repository + - Use magit inside emacs for that +***** Documentation steps to be done in cdist.org + - Create a new org document named `cdist.org` in the safind . -name "~/.emacs"me folder as the learning.org file + - Explain the difference between a singleton and non-singleton type + - Explain the difference between the different verbosity levels + - Document (copy&paste) some of the cdist runs in a "log" section```find . -name "~/.emacs" diff --git a/sami/my-org-files/cdist.org/cdist.org b/sami/my-org-files/cdist.org/cdist.org new file mode 100644 index 0000000..a6bb386 --- /dev/null +++ b/sami/my-org-files/cdist.org/cdist.org @@ -0,0 +1,15 @@ +* cdist #5: Generating Code & Exploring + +* Understanding how to generate code and when to use it +** define gencode-remote script: ~/.cdist/type/__nginx_site. After manifest is applied it should restart services so configuration is active. Our gencode-remote looks like echo "service nginx restart" + +* Modify the previously created type *__my_nginx_site* +** We modify the previously created type so that the gencode-remote script reacts accordingly +- echo "if_configurationfile_changes" >> "$__messages_out" + +* Read about cdist messaging +** cdist has a simple but powerful way of allowing communication between the initial manifest and types as well as types and types. +* What is the difference between gencode-local and gencode-remote? + +** gencode-remote used to generate code to be executed on the target host +** gencode-local used to generate code to be executed on the source host \ No newline at end of file