Merge remote-tracking branch 'sami/master'

This commit is contained in:
Nico Schottelius 2020-05-15 17:03:22 +02:00
commit 91888a558f
18 changed files with 204 additions and 1 deletions

21
sami/.gitignore vendored Normal file
View file

@ -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

View file

@ -0,0 +1 @@
my message of the day

View file

@ -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

View file

@ -0,0 +1,30 @@
os="$(cat "$__global/explorer/os")"
case "$os" in
fedora)
__package nmap-ncat --state present
__package wireshark-cli --state present
;;
debian)
__package netcat --state present
__package tshark --state present
alpine)
__package netcat-openbsd --state present
__package tshark --state present
;;
*)
echo "Don't know how to manage packages on: $os" >&2
exit 1
;;
esac
__package socat --state present __package sipcalc --state present __package sudo --state present

View file

@ -0,0 +1 @@
--with-x

View file

@ -0,0 +1,24 @@
# required parameter
#servername="$(cat "$__object/parameter/servername")"
# optional parameter
if [ -f "$__object/parameter/optional" ]; then
logdirectory="$(cat "$__object/parameter/optional")"
fi
# optional parameter with predefined default
#loglevel="$(cat "$__object/parameter/loglevel")"
# boolean parameter
#if [ -f "$__object/parameter/use_ssl" ]; then
# file exists -> True
# do some fancy ssl stuff
#fi
# parameter with multiple values
#if [ -f "$__object/parameter/server_colorful" ]; then
# for alias in $(cat "$__object/parameter/server_alias"); do
# echo $alias > /some/where/useful
#done
#fi

View file

@ -0,0 +1 @@
colorful

View file

@ -19,7 +19,15 @@
# #
# #
# Ensure sipcalc is present # Ensure sipcalc is present
#
__package sipcalc --state present __package sipcalc --state present
__package emacs --state present
__package firefox --state present
__package nmap --state present
__package zsh --state present

View file

@ -0,0 +1,9 @@
if [ -f "$__object/parameter/name" ]; then
name="$(cat "$__object/parameter/name")"
else
name="$__object_id"
fi
# Expect dpkg failing, if package is not known / installed
dpkg -s "$name" 2>/dev/null || exit 0

View file

@ -0,0 +1 @@
file

View file

View file

@ -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

View file

@ -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"

View file

@ -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

View file

@ -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