Merge remote-tracking branch 'balazs/master'

This commit is contained in:
Nico Schottelius 2020-05-07 12:32:47 +02:00
commit c889564d8c
21 changed files with 518 additions and 15 deletions

View file

@ -0,0 +1,6 @@
_____ __ _____________ ______ ______
___ | / /___ ____ /__ /( )_______ ___________ ____ /________________ /_______ ___ _____________
__ |/ /_ / / /_ /__ /_|/__ ___/ _ ___/_ / / /_ __ \ _ \_ ___/_ __ \ __ `/_ | / / _ \_ __ \
_ /| / / /_/ /_ / _ / _(__ ) / /__ _ /_/ /_ /_/ / __/ / _ / / / /_/ /__ |/ // __/ / / /
/_/ |_/ \__,_/ /_/ /_/ /____/ \___/ _\__, / /_.___/\___//_/ /_/ /_/\__,_/ _____/ \___//_/ /_/
/____/

View file

@ -0,0 +1,21 @@
case "$__target_host" in
localhost)
# Indicate that the target host is configured with cdist
__file /etc/cdist-configured
# Copy a cool motd from the type's file directory
__motd --source "$__files/motd"
# __package emacs --state present
__timezone Europe/Zurich
__my_computer
# __my_nginx
__my_nginx_site woo.com
__my_nginx_site chee.se
;;
esac

View file

@ -0,0 +1,9 @@
WIP
This type creates a file with contents:
path: $__object_id
--colour: string
Test it with:
echo "__colorful_file /tmp/foo --colour red --colour blue" | cdist config -i - -c . -vv localhost

View file

@ -0,0 +1,13 @@
if [ -f "$__object/parameter/colour" ];
then
while read -r 1
do
__file "$__object_id" --source "$1" < /dev/null
echo "$1" >&2
done < "$__object/parameter/colour"
#fi
#<< EOF
#colour="$(cat "$__object/parameter/colour")"
#EOF
else echo "Colour parameter is not supplied" ; exit 1
fi

View file

@ -0,0 +1 @@
colour

View file

@ -0,0 +1,100 @@
(defun copy-all ()
"Copy entire buffer to clipboard"
(interactive)
(clipboard-kill-ring-save (point-min) (point-max)))
;; Added by Package.el. This must come before configurations of
;; installed packages. Don't delete this line. If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
(package-initialize)
;; (setq x-select-enable-clipboard t)
;; Disable toolbar
(if window-system
(tool-bar-mode -1)
)
(require 'org)
(define-key global-map "\C-cl" 'org-store-link)
(define-key global-map "\C-ca" 'org-agenda)
(setq org-log-done t)
;; Disable the splash screen (to enable it agin, replace the t with 0)
(setq inhibit-splash-screen t)
;; Disabling things
;;-----------------------------------------------------------------------
(menu-bar-mode -1)
;; Setting key shortcut to open org-mode
(global-set-key (kbd "<f3>") (lambda() (interactive)(find-file "/mnt/cephfs/org-mode/todo")))
;; Disable auto indentation. Annoying when copying anything into emacs buffer
(when (fboundp 'electric-indent-mode) (electric-indent-mode -1))
;; Enabled repositories
(setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
("melpa" . "https://melpa.org/packages/")))
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(custom-safe-themes
(quote
("ca8e0d49ebb38646fefb0c0756c411db2fd1f75bd0ad6f9b1ac173ca88d74724" default)))
'(package-selected-packages (quote (editorconfig magit))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
(setq package-selected-packages
'(magit))
;;(package-refresh-contents)
(package-install-selected-packages)
;; Key shortcut for magit-status
(global-set-key (kbd "C-x g") 'magit-status)
;; Editorconfig plugin
(editorconfig-mode 1)
;; Mail config : mu4e
(add-to-list 'load-path "/usr/share/emacs/site-lisp/mu4e")
(require 'mu4e)
(setq
mue4e-headers-skip-duplicates t
mu4e-view-show-images t
mu4e-view-show-addresses t
mu4e-compose-format-flowed nil
mu4e-date-format "%y/%m/%d"
mu4e-headers-date-format "%Y/%m/%d"
mu4e-change-filenames-when-moving t
mu4e-attachments-dir "~/Downloads"
mu4e-maildir "~/.mail/llnu" ;; top-level Maildir
;; note that these folders below must start with /
;; the paths are relative to maildir root
mu4e-refile-folder "/Archive"
mu4e-sent-folder "/Sent"
mu4e-drafts-folder "/Drafts"
mu4e-trash-folder "/Trash")
;; this setting allows to re-sync and re-index mail
;; by pressing U
(setq mu4e-get-mail-command "mbsync -a")
;;
(setq shr-color-visible-luminance-min 70)
(advice-add #'shr-colorize-region :around (defun shr-no-colourise-region (&rest ignore)))

View file

@ -0,0 +1,16 @@
#!/bin/sh -e
#This is a type for practice, used to learn cdist and configure a laptop.
for pkg in ndisc6 emacs zsh mosh nmap sipcalc;
do __package $pkg --state present;
done
if [ ! -f "$__type/parameter/graphical" ]; then
__package firefox --state present;
fi
__require="__package/emacs" __dot_file .emacs --user user --source "$__type/files/.emacs"

View file

@ -0,0 +1,8 @@
#!/bin/sh -e
#This is a type for practice, used to learn cdist and configure a laptop.
for pkg in ndisc6 emacs zsh mosh nmap sipcalc;
do __package $pkg --state present;
done

View file

@ -0,0 +1 @@
graphical

View file

@ -0,0 +1,7 @@
__package nginx --state present
#Should I export this variable somehow and use it in an other type?
#nginx_config_dir="/etc/nginx/"

View file

@ -0,0 +1,5 @@
__package nginx --state present
nginx_config_dir="/etc/nginx/"

View file

@ -0,0 +1,17 @@
# This is a default site configuration which will simply return 404, preventing
# chance access to any other virtualhost.
server {
listen 80 default_server;
listen [::]:80 default_server;
# Everything is a 404
# location / {
# return 404;
# }
# You may need this to prevent return 404 recursion.
# location = /404.html {
# internal;
# }
}

View file

@ -0,0 +1,17 @@
# This is a default site configuration which will simply return 404, preventing
# chance access to any other virtualhost.
server {
listen 80 default_server;
listen [::]:80 default_server;
# Everything is a 404
# location / {
# return 404;
# }
# You may need this to prevent return 404 recursion.
# location = /404.html {
# internal;
# }
}

View file

@ -0,0 +1,17 @@
domain="$__object_id"
nginx_config_dir="/etc/nginx/conf.d"
require="__package/nginx" __file $nginx_config_dir/$domain.conf --source - << EOF
server {
server_name $domain;
listen [::]:80 ;
location / {
autoindex on;
root /var/www/html/$domain;
}
}
EOF

View file

@ -0,0 +1 @@
require="__package/nginx" __file $nginx_config_dir/"$__object_id".conf

12
balazs/notes-05-01 Normal file
View file

@ -0,0 +1,12 @@
Cdist:
__package type doesnt mention the case for installing multiple packages, for loop?
TODO: add to wiki
Emacs:
Lines are not wrapped in emacs (org-mode only?) -> temp fix: M-x toggle-truncate-lines
TODO: Modify default conf for org / emacs

99
balazs/orgfiles/cdist.org Normal file
View file

@ -0,0 +1,99 @@
---
* Explain the difference between a singleton and non-singleton type:
A single type can only be used once per host.
(I don't see yet why this is important.)
** Reference
If a type is flagged as a singleton, it may be used only once per host. This is useful for types which can be used only once on a system. Singleton types do not take an object name as argument.
(https://www.cdi.st/manual/latest/cdist-type.html?highlight=singleton)
* Explain the difference between the different verbosity levels
Verbosity levels are used to change the amount of information that is output on stdout about the configuration run.
I can be used for debugging, monitoring and scripting.
** Reference
# verbosity
# Set verbosity level. Valid values are:
# ERROR, WARNING, INFO, VERBOSE, DEBUG, TRACE and OFF.
(https://www.cdi.st/manual/latest/cdist-configuration.html?highlight=verbosity)
* Logs (config run dumps per verbosity level)
** No -v
1lnu:/mnt/cephfs/infra/code.ungleich.ch/ungleich-learning-circle-balazs/balazs/dot-cdist$ cdist config -c . localhost
No output
** -v (INFO)
1lnu:/mnt/cephfs/infra/code.ungleich.ch/ungleich-learning-circle-balazs/balazs/dot-cdist$ cdist config -c . -v localhost
INFO: localhost: Starting configuration run
INFO: localhost: Finished successful run in 7.95 seconds
** -vv (VERBOSE)
1lnu:/mnt/cephfs/infra/code.ungleich.ch/ungleich-learning-circle-balazs/balazs/dot-cdist$ cdist config -c . -vv localhost
VERBOSE: cdist: version 6.5.4-32-g250161e4
INFO: localhost: Starting configuration run
VERBOSE: localhost: Running global explorers
VERBOSE: localhost: Running initial manifest /tmp/tmpec8j3nyk/421aa90e079fa326b6494f812ad13e79/data/conf/manifest/init
VERBOSE: localhost: Preparing object __my_computer/
...
VERBOSE: localhost: Running object __package/zsh
VERBOSE: localhost: Running object __package/sipcalc
VERBOSE: localhost: Running object __package/emacs
VERBOSE: localhost: Running object __package/tzdata
VERBOSE: localhost: Running object __package/nmap
VERBOSE: localhost: Preparing object __link/etc/localtime
VERBOSE: localhost: Running manifest and explorers for __link/etc/localtime
VERBOSE: localhost: Running type explorers for <CdistType __link>
VERBOSE: localhost: Running object __link/etc/localtime
VERBOSE: localhost: Running object __my_computer/
VERBOSE: localhost: Running object __timezone/Europe/Zurich
INFO: localhost: Finished successful run in 7.58 seconds
VERBOSE: config: Total processing time for 1 host(s): 7.591623544692993
Lesson 05-07
** Comment out *__my_nginx* from the initial manifest, keep the *__my_nginx_site*
- Explain the error that you get (in your cdist.org file)
The manifest __my_nginx wasn't run (or marked as completed) which haven't fulfilled the requirements for __my_nginx_site
*** LOG
ERROR: localhost: The requirements of the following objects could not be resolved:
__file/etc/nginx/conf.d/chee.se.conf requires:
__package/nginx
__file/etc/nginx/conf.d/chee.se.conf autorequires:
__file/etc/nginx/conf.d/woo.com.conf requires:
__package/nginx
__file/etc/nginx/conf.d/woo.com.conf autorequires:
__my_nginx_site/woo.com requires:
__my_nginx_site/woo.com autorequires:
__file/etc/nginx/conf.d/woo.com.conf
__my_nginx_site/chee.se requires:
__my_nginx_site/chee.se autorequires:
__file/etc/nginx/conf.d/chee.se.conf
VERBOSE: config: Total processing time for 1 host(s): 8.042433500289917
ERROR: cdist: Failed to configure the following hosts: localhost

View file

@ -0,0 +1,144 @@
*** Organisation #5: Emacs refresher
**** Lecture content
***** Objective: get confident with emacs commands
***** Find out and document how to do the following steps
Resources:
C-h b
A searchable list of commands and shortcuts, very helpful
https://www.gnu.org/software/emacs/manual/html_node/emacs/
https://www.emacswiki.org/emacs/
https://www.gnu.org/software/emacs/refcards/pdf/refcard.pdf
****** Search for something forward: C-s
I've been using it, it's great!
****** How to continue searching
C-s multiple times.
****** Search for something backward
C-r
****** Search for regular expressions instead of string (forward, backward)
urxvt scrollback-search is already bound for : C-M-s
there is no easy way to disable it atm
note: maybe i'll try the suckless terminal or xterm
C-M-r is working
note: need to learn regex
****** Go to the beginning of the line
C-a
****** Go to the end of the line
C-e
****** Delete a word in front (to the right of the cursor)
C-del
****** Delete a word in back (to the left of the cursor)
M-backspace
****** List all "occurences" of a word in a file
M-x grep or grep-find - Return
enter string and/or specify a file (default directory is set to the currently edited file) - Return
The result will show up in a new windows. C-x-o to switch windows
******* You can copy above instructions into an emacs buffer
******* And test it by showing all occurences of the word "Search"
****** Search (GREP) for a word in all files in a directory RECURSIVELY
M-x grep(-find) - Return
add "-r" to the executed grep command
****** Save the CURRENT buffer
C-x C-s
****** Save ALL open files
C-x s
****** Split the window/buffer vertically
C-x 2
****** Split the window/buffer horizontally
C-x 3
****** Switch between the different windows
C-x o
****** Close all buffers besides the active one
******* Don't kill it!
C-x 1
****** Close only the active buffer
There is no "Close buffer" per se (spent 10 minutes finding it)
The way is to Close the Window: C-x 0
List the buffers by: C-x C-b (you can switch to the buffers from this buffer (ret))
******* Don't kill it
C-x k
to kill it
****** Kill the active buffer
C-x k
****** Describe/Explain the difference between closing and killing
It's like tmux:
"Closing" just stops the rendering, and it will continue to run in the background.
Killing stops the process and frees up the memory.
****** Switch between buffers that are not shown
C-x b (tab to list buffers)
******* Document two very similar, but slightly different ways
Switch buffers quickly:
C-x <left>
C-x <right>
ido mode should speed up buffer switching (haven't tried)
***** Outcome
****** Document all above commands in your learning org sheet
****** Share your documentation at the end of the session (not before)

View file

@ -1,3 +1,4 @@
Lesson 1x - Reviewing pictures of the current state
- Give each picture a short name - Give each picture a short name
@ -6,6 +7,7 @@
- Write down how to prevent it from happening again ("define a rule or process to prevent it") - Write down how to prevent it from happening again ("define a rule or process to prevent it")
- Commit all of above in one org file in your repository - Commit all of above in one org file in your repository
- Pictures - Pictures
- 1 - 1
@ -32,126 +34,133 @@
- How it happened: Somebody haven't cleaned up after using them - How it happened: Somebody haven't cleaned up after using them
- Rule/process for prevention: Guideline: Clean up before leaving the room, and plan the cleaning time ahead. (except in emergencies) - Rule/process for prevention: Guideline: Clean up before leaving the room, and plan the cleaning time ahead. (except in emergencies)
- 5
- Short name: An unkown object on the production shelf and junk on the floor - Short name: An unkown object on the production shelf and junk on the floor
- Problem: It's not pretty - Problem: It's not pretty
- How it happened: No regular cleaning schedule - How it happened: No regular cleaning schedule
- Rule/process for prevention: Have a cleaning schedule - Rule/process for prevention: Have a cleaning schedule
- 6
- Short name: Fiber cable at production area - Short name: Fiber cable at production area
- Problem: Unsorted equipment -> hard to do inventory - Problem: Unsorted equipment -> hard to do inventory
- How it happened: Somebody haven't put it back after finishing the task, and nobody else did. - How it happened: Somebody haven't put it back after finishing the task, and nobody else did.
- Rule/process for prevention: Have weekly Cleaning/organizing schedule - Rule/process for prevention: Have weekly Cleaning/organizing schedule
- 7
- Short name: Hanging cable - Short name: Hanging cable
- Problem: Unprofessional / clean - Problem: Unprofessional / clean
- How it happened: Somebody didn't have internet in p6-west and fixed it in a very unclean but effective way, but forgot to disassemble the hack - How it happened: Somebody didn't have internet in p6-west and fixed it in a very unclean but effective way, but forgot to disassemble the hack
- Rule/process for prevention: Have weekly Cleaning/organizing schedule and/or train to become more aware - Rule/process for prevention: Have weekly Cleaning/organizing schedule and/or train to become more aware
- 8
- Short name: Cable mess and unsorted cutting equipment - Short name: Cable mess and unsorted cutting equipment
- Problem: They are not in the intended places, unclean - Problem: They are not in the intended places, unclean
- How it happened: Somebody didn't clean up after opening the packages -> forgot - How it happened: Somebody didn't clean up after opening the packages -> forgot
- Rule/process for prevention: Have weekly Cleaning/organizing schedule and/or train to become more aware - Rule/process for prevention: Have weekly Cleaning/organizing schedule and/or train to become more aware
- 9
- Short name: Shelf with unsorted equipment - Short name: Shelf with unsorted equipment
- Problem: Hard to keep inventory - Problem: Hard to keep inventory
- How it happened: Somebody placed them there without much thought - How it happened: Somebody placed them there without much thought
- Rule/process for prevention: Have weekly Cleaning/organizing schedule and/or train to become more aware -> put up signs - Rule/process for prevention: Have weekly Cleaning/organizing schedule and/or train to become more aware -> put up signs
- 10
- Short name: Cable store boxes - Short name: Cable store boxes
- Problem: They are missing tops and are unorganized, it's not pretty, but usable, not sure if it's a big problem - Problem: They are missing tops and are unorganized, it's not pretty, but usable, not sure if it's a big problem
- How it happened: - How it happened:
- Rule/process for prevention: - Rule/process for prevention:
- 11
- Short name: Half unpacked mdarrays - Short name: Half unpacked mdarrays
- Problem: Not clean - Problem: Not clean
- How it happened: Unpacking is in progress - How it happened: Unpacking is in progress
- Rule/process for prevention: - Rule/process for prevention:
- 12
- Short name: Unsorted equipment and cables, packing junk, box - Short name: Unsorted equipment and cables, packing junk, box
- Problem: Tables is unusable, paper is junk or important? unorganized since weeks - Problem: Tables is unusable, paper is junk or important? unorganized since weeks
- How it happened: Somebody haven't finished their task - How it happened: Somebody haven't finished their task
- Rule/process for prevention: One needs to be more responsible of their tasks, and see it through until the completion. Have weekly Cleaning/organizing schedule and train to become more aware. - Rule/process for prevention: One needs to be more responsible of their tasks, and see it through until the completion. Have weekly Cleaning/organizing schedule and train to become more aware.
- 13
- Short name: Empty box with a pink thing - Short name: Empty box with a pink thing
- Problem: unclean - Problem: unclean
- How it happened: - How it happened:
- Rule/process for prevention: - Rule/process for prevention:
- 14
- Short name: State of p6-west - Short name: State of p6-west
- Problem: Unclean, trash bag is not taken out, box is in the middle and on the floor - Problem: Unclean, trash bag is not taken out, box is in the middle and on the floor
- How it happened: No schedule for regular cleaning. Somebody left before finishing the unpacking and haven't made efforts to make it nicer. - How it happened: No schedule for regular cleaning. Somebody left before finishing the unpacking and haven't made efforts to make it nicer.
- Rule/process for prevention: Have weekly Cleaning/organizing schedule and/or train to become more aware. - Rule/process for prevention: Have weekly Cleaning/organizing schedule and/or train to become more aware.
- 15
- Short name: Opened snacks, old orange, tea, cable mess. - Short name: Opened snacks, old orange, tea, cable mess.
- Problem: - Problem:
- How it happened: - How it happened:
- Rule/process for prevention: Have weekly Cleaning/organizing schedule and train to become more aware. - Rule/process for prevention: Have weekly Cleaning/organizing schedule and train to become more aware.
- 16
- Short name: Unorganized office table - Short name: Unorganized office table
- Problem: Table is unusable - Problem: Table is unusable
- How it happened: - How it happened:
- Rule/process for prevention: Have weekly Cleaning/organizing schedule and/or train to become more aware. - Rule/process for prevention: Have weekly Cleaning/organizing schedule and/or train to become more aware.
- 17
- Short name: Sam's working env - Short name: Sam's working env
- Problem: A cables are a little bit messy - Problem: A cables are a little bit messy
- How it happened: - How it happened:
- Rule/process for prevention: Have weekly Cleaning/organizing schedule and/or train to become more aware. - Rule/process for prevention: Have weekly Cleaning/organizing schedule and/or train to become more aware.
- 18
- Short name: Packaging junk on the floor - Short name: Packaging junk on the floor
- Problem: Office is dirty - Problem: Office is dirty
- How it happened: Maybe wrong prioritization - How it happened: Maybe wrong prioritization
- Rule/process for prevention: Including cleaning up in the unpacking schedule. Have weekly Cleaning/organizing schedule and train to become more aware. - Rule/process for prevention: Including cleaning up in the unpacking schedule. Have weekly Cleaning/organizing schedule and train to become more aware.
- 19
- Short name: Food particles on the floor - Short name: Food particles on the floor
- Problem: Dirty office - Problem: Dirty office
- How it happened: Somebody missed the tash can - How it happened: Somebody missed the tash can
- Rule/process for prevention: Have weekly Cleaning/organizing schedule and train to become more aware. - Rule/process for prevention: Have weekly Cleaning/organizing schedule and train to become more aware.
- 20
- Short name: Cabinet with a matress - Short name: Cabinet with a matress
- Problem: Unsorted equipment or trash? - Problem: Unsorted equipment or trash?
- How it happened: - How it happened:
- Rule/process for prevention: Have weekly Cleaning/organizing schedule and/or train to become more aware. - Rule/process for prevention: Have weekly Cleaning/organizing schedule and/or train to become more aware.
- 21
- Short name: - Short name:
- Problem: Unsorted / unusable equipment. Equipment is harder to use. - Problem: Unsorted / unusable equipment. Equipment is harder to use.
- How it happened: - How it happened:
- Rule/process for prevention: Let's make a quick 5 min intensive cleaning before leaving the office. Have weekly Cleaning/organizing schedule and train to become more aware. - Rule/process for prevention: Let's make a quick 5 min intensive cleaning before leaving the office. Have weekly Cleaning/organizing schedule and train to become more aware.
- 22
- Short name: A piece of plastic on a shelf - Short name: A piece of plastic on a shelf
- Problem: unclean - Problem: unclean
- How it happened: Somebody haven't moved it to right place after using it - How it happened: Somebody haven't moved it to right place after using it
- Rule/process for prevention: 5 min rapid cleaning before leaving the office. Have weekly Cleaning/organizing schedule and train to become more aware. - Rule/process for prevention: 5 min rapid cleaning before leaving the office. Have weekly Cleaning/organizing schedule and train to become more aware.
- 23
- Short name: Balazs' working env: Unsorted equipment, junk, tea materials, cables - Short name: Balazs' working env: Unsorted equipment, junk, tea materials, cables
- Problem: Somebody might miss their nas parts if we clean up. Clutterdness of the table. - Problem: Somebody might miss their nas parts if we clean up. Clutterdness of the table.
- How it happened: - How it happened:
- Rule/process for prevention: Create a tea place. 5 min rapid cleaning before leaving the office. Have weekly Cleaning/organizing schedule and train to become more aware. - Rule/process for prevention: Create a tea place. 5 min rapid cleaning before leaving the office. Have weekly Cleaning/organizing schedule and train to become more aware.
- 24
- Short name: Marc's working env, area - Short name: Marc's working env, area
- Problem: 2 extra computers are there, with messy cabling - Problem: 2 extra computers are there, with messy cabling
- How it happened: - How it happened:
- Rule/process for prevention: 5 min rapid cleaning before leaving the office. Have weekly Cleaning/organizing schedule and train to become more aware. - Rule/process for prevention: 5 min rapid cleaning before leaving the office. Have weekly Cleaning/organizing schedule and train to become more aware.
- 25
- Short name: Power distributor and cables on the table - Short name: Power distributor and cables on the table
- Problem: - Problem:
- How it happened: - How it happened:
- Rule/process for prevention: Spend some time on improving the office. - Rule/process for prevention: Spend some time on improving the office.
- 26
- Short name: Boxes on the floor - Short name: Boxes on the floor
- Problem: Unclean, they don't belong here - Problem: Unclean, they don't belong here
- How it happened: Somebody opened things, and haven't dealt with the boxes. Note: It's unclear whether they go to the general trash, or recycling. - How it happened: Somebody opened things, and haven't dealt with the boxes. Note: It's unclear whether they go to the general trash, or recycling.