Learning Circle : cdist #6 - update 1

This commit is contained in:
youngjin.han 2020-05-17 23:43:35 +09:00
parent a21705179c
commit e28b8cbcbd
5 changed files with 116 additions and 172 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
/youngjin.han/cdist.org~
/youngjin.han/dot-cdist/type/__colourful_file/file/colourful~
/youngjin.han/dot-cdist/type/__colourful_file/manifest~
/youngjin.han/dot-cdist/type/__all_in_one/manifest~

View File

@ -8,7 +8,7 @@ case "$__target_host" in
# __colourful_file --colour yellow --colour blue --colour red --colour green
# __my_dotfiles
# __my_nginx_site $__target_host
# __all_in_one $__target_host --with-x --extra-packages tree --extra-packages htop
# __all_in_one --with-x --extra-packages tree --extra-packages htop
__my_firewall --file /etc/my-nftables
;;
jafo.laptop)

View File

@ -1,12 +1,10 @@
#!/bin/sh -e
os="$(cat "$__global/explorer/os")"
default_package_name="socat sipalc sudo"
default_package_name="socat sipcalc sudo"
if [ -f "$__object/parameter/with-x" ]; then
with_x="$(cat "$__object/parameter/with-x")"
else
with_x="$__object_id"
fi
case "$os" in
@ -14,7 +12,7 @@ case "$os" in
name_netcat="netcat-openbsd"
name_wireshark="tshark"
;;
debian)
debian|devuan)
name_netcat="netcat"
name_wireshark="tshark"
;;
@ -33,12 +31,12 @@ all_package_name="$default_package_name $name_netcat $name_wireshark"
__package_update_index
for package in $all_package_name;
do require="__apt_update_index" __package $package --state=present
for package in $all_package_name; do
require="__package_update_index" __package $package --state=present
done
if [ -f "$__object/parameter/extra-packages" ]; then
for package in $(cat "$__object/parameter/extra-packages"); do
require="__apt_update_index" __package $package --state=present
require="__package_update_index" __package $package --state=present
done
fi

View File

@ -20,7 +20,7 @@
Alpine/Debian/Fedora, output an error message and abort the
manifest with exit code 1
- Additionally install all packages specified by the *--extra-packages* parameter
***** Steps 2: *__firewall* (1.25h)
***** TODO Steps 2: *__firewall* (1.25h)
- Create a new type *__my_firewall*
- Add a *type explorer* to find out whether nft is present on
the target system
@ -33,7 +33,7 @@
ruleset by generating code in *gencode-remote*
- If the filename specified by the *file* parameter is *-* (the
minus sign), then the type should read from *stdin*
***** Step 3: manifest (0.5h)
***** TODO Step 3: manifest (0.5h)
- Create a new manifest in the folder that contains the initial manifest
- Name the new manifest *firewall*
- Source the *firewall* manifest in the *initial* manifest
@ -127,201 +127,146 @@
***** DONE As usual commit all changes to your ungleich-learning-circle repo
CLOSED: [2020-05-15 금 21:07]
* 2020-05-06
** cdist #2: Your first cdist type
*** cdist #2: Your first cdist type
**** Lecture content
***** Objective
****** Begin to understand how cdist types function
***** Steps
****** DONE Create a new type named `__my_computer`
CLOSED: [2020-05-06 수 22:53]
******* DONE Mark the type as a singleton type
CLOSED: [2020-05-06 수 22:53]
******* DONE Create a `manifest` file in it
CLOSED: [2020-05-06 수 22:53]
******* DONE Use this type to install the following packages: zsh, mosh, emacs, nmap, sipcalc
CLOSED: [2020-05-06 수 22:53]
******* DONE Edit the *initial manifest* and use **__my_computer** for **localhost**
CLOSED: [2020-05-06 수 22:53]
******* DONE Match using the $__target_host variable
CLOSED: [2020-05-06 수 22:53]
****** DONE Modify your type to use a *for loop* to install the packages
CLOSED: [2020-05-06 수 22:53]
****** DONE Deploy / manage your ~/.emacs file in this type
CLOSED: [2020-05-06 수 22:53]
******* DONE Ensure that permissions and ownership are correct
CLOSED: [2020-05-06 수 22:53]
****** DONE Use different *verbosity* levels when configuring
CLOSED: [2020-05-06 수 22:54]
****** DONE Ensure that all your changes are committed and pushed in your ungleich-learning-circle repository
CLOSED: [2020-05-06 수 22:54]
******* DONE Use magit inside emacs for that
CLOSED: [2020-05-06 수 22:54]
***** DONE Documentation steps to be done in cdist.org
CLOSED: [2020-05-06 수 23:02]
****** DONE Create a new org document named `cdist.org` in the same folder as the learning.org file
CLOSED: [2020-05-06 수 23:02]
****** DONE Explain the difference between a singleton and non-singleton type
CLOSED: [2020-05-06 수 23:02]
****** DONE Explain the difference between the different verbosity levels
CLOSED: [2020-05-06 수 23:02]
****** Document (copy&paste) some of the cdist runs in a "log" section```
****** Create a new type named `__my_computer`
- Mark the type as a singleton type
- 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** for **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 same 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```
* 2020-05-04
*** cdist #1: Introduction
**** Lecture content
***** Objective
****** Begin to use cdist
- Begin to use cdist
***** Steps
****** DONE Checkout cdist quickstart https://www.cdi.st/manual/latest/cdist-quickstart.html
CLOSED: [2020-05-04 월 22:32]
****** DONE Install cdist locally
CLOSED: [2020-05-04 월 22:32]
****** DONE Create a new cdist configuration directory in ~/ungleich-learning-circle/USERNAME/dot-cdist
CLOSED: [2020-05-04 월 22:32]
****** DONE Create an empty initial manifest ("use touch")
CLOSED: [2020-05-04 월 22:32]
****** DONE Commit that status
CLOSED: [2020-05-04 월 22:37]
****** DONE Ensure that you can login as root to localhost via ssh without a password
CLOSED: [2020-05-04 월 22:37]
****** DONE Configure cdist to configures the motd of your localhost
CLOSED: [2020-05-05 화 00:42]
******* DONE Ensure you have a case block matching on $__target_host
CLOSED: [2020-05-05 화 00:21]
******* DONE Use the -c parameter to cdist to specify the configuration directory
CLOSED: [2020-05-04 월 23:58]
******* DONE Use the -vv parameter to get more verbose output
CLOSED: [2020-05-04 월 23:57]
******* DONE Search for / understand what MOTD stands for
CLOSED: [2020-05-05 화 00:41]
****** DONE Configure cdist to create the file /etc/cdist-configured
CLOSED: [2020-05-04 월 23:33]
****** DONE Configure cdist to setup the timezone on your local computer
CLOSED: [2020-05-04 월 23:33]
****** DONE Configure cdist to ensure emacs is installed
CLOSED: [2020-05-04 월 23:47]
****** DONE Ensure that in the end all changes are committed in your repository
CLOSED: [2020-05-05 화 00:42]
- 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
* 2020-05-01
*** Organisation #5: Emacs refresher
**** Lecture content
***** Objective: get confident with emacs commands
***** Find out and document how to do the following steps
****** DONE Search for something forward C-s
CLOSED: [2020-05-01 금 21:40]
****** DONE How to continue searching C-s C-s
CLOSED: [2020-05-01 금 21:43]
****** DONE Search for something backward C-r
CLOSED: [2020-05-01 금 21:55]
****** DONE Search for regular expressions instead of string (forward, backward) C-M-s C-M-r
CLOSED: [2020-05-01 금 22:25]
****** DONE Go to the beginning of the line C-a
CLOSED: [2020-05-01 금 22:16]
****** DONE Go to the end of the line C-e
CLOSED: [2020-05-01 금 22:16]
****** DONE Delete a word in front (to the right of the cursor) M-d
CLOSED: [2020-05-01 금 22:17]
****** DONE Delete a word in back (to the left of the cursor) M-BackSpace
CLOSED: [2020-05-01 금 22:18]
****** DONE List all "occurences" of a word in a file M-s o
CLOSED: [2020-05-01 금 22:53]
******* You can copy above instructions into an emacs buffer
******* And test it by showing all occurences of the word "Search"
****** DONE Search (GREP) for a word in all files in a directory RECURSIVELY M-x rgrep
CLOSED: [2020-05-01 금 22:46]
****** DONE Save the CURRENT buffer C-x C-s
CLOSED: [2020-05-01 금 21:55]
****** DONE Save ALL open files C-x-s
CLOSED: [2020-05-01 금 22:22]
****** DONE Split the window/buffer vertically C-x 2
CLOSED: [2020-05-01 금 21:48]
****** DONE Split the window/buffer horizontally C-x 3
CLOSED: [2020-05-01 금 21:48]
****** DONE Switch between the different windows C-x o
CLOSED: [2020-05-01 금 21:48]
****** DONE Close all buffers besides the active one C-x 1
CLOSED: [2020-05-01 금 21:47]
******* Don't kill it!
****** DONE Close only the active buffer C-x 0
CLOSED: [2020-05-01 금 21:54]
******* Don't kill it!
****** DONE Kill the active buffer C-x k
CLOSED: [2020-05-01 금 21:44]
****** DONE Describe/Explain the difference between closing and killing
CLOSED: [2020-05-01 금 22:09]
******* closing is that emac do not display the buffer. and the contents on the buffer are kept on behined screen.
******* killing is that emac delete the buffer. and if contents are not stored, it is losted
****** DONE Switch between buffers that are not shown C-x b
CLOSED: [2020-05-01 금 21:51]
******* DONE Document two very similar, but slightly different ways
CLOSED: [2020-05-01 금 23:28]
******** C-x b is that the selected buffer is displayed on the focused window
******** C-x C-b is that all buffers is dispalayed on the new window
******** C-x 4 b is that the selected buffer is displayed on the new window
- Search for something forward C-s
- How to continue searching C-s C-s
- Search for something backward C-r
- Search for regular expressions instead of string (forward, backward) C-M-s C-M-r
- 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) M-d
- Delete a word in back (to the left of the cursor) M-BackSpace
- List all "occurences" of a word in a file M-s o
- 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 rgrep
- 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 C-x 1
- Don't kill it!
- Close only the active buffer C-x 0
-* Don't kill it!
- Kill the active buffer C-x k
- Describe/Explain the difference between closing and killing
- closing is that emac do not display the buffer. and the contents on the buffer are kept on behined screen.
- killing is that emac delete the buffer. and if contents are not stored, it is losted
- Switch between buffers that are not shown C-x b
- Document two very similar, but slightly different ways
- C-x b is that the selected buffer is displayed on the focused window
- C-x C-b is that all buffers is dispalayed on the new window
- C-x 4 b is that the selected buffer is displayed on the new window
***** Outcome
****** DONE Document all above commands in your learning org sheet
CLOSED: [2020-05-01 금 23:28]
****** DONE Share your documentation at the end of the session (not before)
CLOSED: [2020-05-01 금 23:28]
- Document all above commands in your learning org sheet
- Share your documentation at the end of the session (not before)
* 2020-04-29
*** Organisation #4: Organising yourself
**** Lecture content
***** Objective: have a todo list based on org mode
***** Steps
****** Configure the "org-directory" to be ~/ungleich-learning-circle/USERNAME/
******* This is important as it will be used by the todo function later
****** Extend your function from the organisation #1 session
******* Instead of opening a fixed file, we include two variable parts:
******** The hostname of the machine
******** The year
******* Pressing F3 should open ~/ungleich-learning-circle/USERNAME/learning-$(hostname)-$(year).org
******** we call this "your personal agenda"
****** Configure mu4e to create a org-mode tasks from an email
******* Store these tasks in ~/ungleich-learning-circle/USERNAME/todo.org
****** Configure emacs to open the "org-agenda" with "C-c a"
****** List all TODO entries
****** List the agenda of the day
****** List the agenda of the week
****** Bind F8 to open the "org-todo-list"
****** Create some sample tasks in it
- Configure the "org-directory" to be ~/ungleich-learning-circle/USERNAME/
- This is important as it will be used by the todo function later
- Extend your function from the organisation #1 session
- Instead of opening a fixed file, we include two variable parts:
- The hostname of the machine
- The year
- Pressing F3 should open ~/ungleich-learning-circle/USERNAME/learning-$(hostname)-$(year).org
- we call this "your personal agenda"
- Configure mu4e to create a org-mode tasks from an email
- Store these tasks in ~/ungleich-learning-circle/USERNAME/todo.org
- Configure emacs to open the "org-agenda" with "C-c a"
- List all TODO entries
- List the agenda of the day
- List the agenda of the week
- Bind F8 to open the "org-todo-list"
- Create some sample tasks in it
***** From now on, maintaining tasks should be
****** Pressing F3 to open your personal "logfile"
****** Adding a TODO item
****** Pressing F8 to see the tasks with priorities
- Pressing F3 to open your personal "logfile"
- Adding a TODO item
- Pressing F8 to see the tasks with priorities
***** Bonus tasks
****** Configure mu4e to store org-mode tasks in .../todo-$(hostname)-$(year).org
- Configure mu4e to store org-mode tasks in .../todo-$(hostname)-$(year).org
* 2020-04-27
*** Organisation #3: Managing your emails
**** Lecture content
***** Objective
****** Be able to manage all your mails in mu4e
- Be able to manage all your mails in mu4e
***** Description
****** All email is synchronised using isync/mbsync
****** Email is indexed with mu (xapian backend)
****** Email is viewed in mu4e
****** All new emails arrive in the inbox
- All email is synchronised using isync/mbsync
- Email is indexed with mu (xapian backend)
- Email is viewed in mu4e
- All new emails arrive in the inbox
***** Steps
****** Install mu4e
****** Start mu4e in emacs
****** Configure mbsync for your ungleich mail account
******* Synchronise all mails into ~/Maildir/ungleich
******* This structure leaves room for other mail accounts, like ~/Maildir/gmail
****** Verify that mbsync synchronises the mail
****** Index mails using `mu` on the command line (only first time)
****** Configure mu4e to get email with mbsync -a
****** Configure mu4e to "archive" emails into ~/Maildir/ungleich/YEAR/
******* This gives you a good performance / organisation for the next decades
****** Configure mu4e/emacs for sending emails
****** Send other participants an email via mu4e
****** Verify that it arrives
****** "Archive" it afterwards
- Install mu4e
- Start mu4e in emacs
- Configure mbsync for your ungleich mail account
- Synchronise all mails into ~/Maildir/ungleich
- This structure leaves room for other mail accounts, like ~/Maildir/gmail
- Verify that mbsync synchronises the mail
- Index mails using `mu` on the command line (only first time)
- Configure mu4e to get email with mbsync -a
- Configure mu4e to "archive" emails into ~/Maildir/ungleich/YEAR/
- This gives you a good performance / organisation for the next decades
- Configure mu4e/emacs for sending emails
- Send other participants an email via mu4e
- Verify that it arrives
- "Archive" it afterwards
* 2020-04-24
*** Organisation #2: Creating, managing and sharing with "magit"
**** Lecture content
***** Install "magit" for emacs
***** Bind C-x g to open magit-status in ~/.emacs
***** Create a new directory ~/ungleich-learning-circle/ (with emacs)
****** Use C-h b in dired mode to find out how to
- Use C-h b in dired mode to find out how to
***** Create a sub directory ~/ungleich-learning-circle/YOURNAME/ (with emacs)
***** Move your previously created learning.org file into ~/ungleich-learning-circle/YOURNAME/ (with emacs)
***** Initialise it with git (with magit)
@ -342,4 +287,4 @@
***** Create a function that opens ~/learning.org in your ~/.emacs
***** Bind that function to "f3" (configure it in .emacs)
***** Create a new item named "2020-04-10"
****** Create a sub item "ungleich learning circle"
- Create a sub item "ungleich learning circle"