Learning Circle : cdist #2

This commit is contained in:
youngjin.han 2020-05-06 23:04:02 +09:00
parent bace4a52cb
commit d6402038c5
6 changed files with 396 additions and 1 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/youngjin.han/dot-cdist/type/__my_computer/manifest~

5
youngjin.han/cdist.org Normal file
View File

@ -0,0 +1,5 @@
* non-singleton needs poress ID.
* singletion should be carried out by itself.
* verbosity level display me cdist processing information.
** '-v' is light information.
** '-vv' and '-vvv' iform me more cidst processing information (e.g. debug, verbose and etc)

View File

@ -2,7 +2,8 @@ __file /etc/cdist-configured
case "$__target_host" in
localhost)
__motd
__timezone Asia/Seoul
__package emacs --state present
__my_computer
;;
esac

View File

@ -0,0 +1,349 @@
#!/bin/sh -e
packages_to_install="zsh mosh emacs nmap sipcals"
__apt_update_index
for package in $package_to_install;
do require="__apt_update_index" __package $package --state=present
done
__require="__package/emacs" \
__directory ~/.emacs.d
__require="__package/emacs __directory/~/.emacs.d" \
__file ~/.emacs.d/init.el \
--owner root \
--group root \
--mode 0644 \
--source - << EOF
;;; init.el --- GNU Emacs Configuration
;; Copyright (C) 2014 Terencio Agozzino
;; Author: Terencio Agozzino <terencio.agozzino@gmail.com>
;; Created: February 16, 2014
;; Homepage: https://github.com/rememberYou/.emacs.d
;; Keywords: abbrev, convenience, faces, maint, outlines, vc
;; This program is free software. You can redistribute it and/or modify it under
;; the terms of the Do What The Fuck You Want To Public License, version 2 as
;; published by Sam Hocevar.
;;
;; This program is distributed in the hope that it will be useful, but WITHOUT
;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
;; FOR A PARTICULAR PURPOSE.
;;
;; You should have received a copy of the Do What The Fuck You Want To Public
;; License along with this program. If not, see http://www.wtfpl.net/.
;;; Commentary:
;; Following lines build the configuration code out of the config.el file.
;;; Code:
;; Make startup faster by reducing the frequency of garbage
;; collection.
(setq gc-cons-threshold (* 50 1000 1000))
(require 'package)
(package-initialize)
(if (file-exists-p (expand-file-name "00_global_config.el" user-emacs-directory))
(load-file (expand-file-name "00_global_config.el" user-emacs-directory)))
(if (file-exists-p (expand-file-name "10_magit_config.el" user-emacs-directory))
(load-file (expand-file-name "10_magit_config.el" user-emacs-directory)))
(if (file-exists-p (expand-file-name "20_mu4e_config.el" user-emacs-directory))
(load-file (expand-file-name "20_mu4e_config.el" user-emacs-directory)))
(if (file-exists-p (expand-file-name "21_smtp_config.el" user-emacs-directory))
(load-file (expand-file-name "21_smtp_config.el" user-emacs-directory)))
(if (file-exists-p (expand-file-name "30_agenda_config.el" user-emacs-directory))
(load-file (expand-file-name "30_agenda_config.el" user-emacs-directory)))
(if (file-exists-p (expand-file-name "99_custom_config.el" user-emacs-directory))
(load-file (expand-file-name "99_custom_config.el" user-emacs-directory)))
(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.
'(org-agenda-files
(quote
("~/ungleich-learning-circle/youngjin.han/todo-node02-2020.org" "~/ungleich-learning-circle/youngjin.han/learning-node02-2020.org")))
'(package-selected-packages (quote (zenburn-theme magit)))
'(xterm-mouse-mode t))
(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.
)
;; Make gc pauses faster by decreasing the threshold.
(setq gc-cons-threshold (* 2 1000 1000))
;;; init.el ends here
EOF
__require="__package/emacs __directory/~/.emacs.d __file/~/.emacs.d/init.el" \
__file ~/.emacs.d/00_global_config.el \
--owner root \
--group root \
--mode 0644 \
--source - << EOF
;; 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)
;; load emacs 24's package system. Add MELPA repository.
(when (>= emacs-major-version 24)
(require 'package)
(add-to-list
'package-archives
;; '("melpa" . "http://stable.melpa.org/packages/") ; many packages won't show if using stable
'("melpa" . "http://melpa.milkbox.net/packages/")
;; '("org" . "http://orgmode.org/elpa/")
t))
(setq auth-sources '("~/.authinfo.gpg"
"~/.authinfo"))
(setq-default
;; ad-redefinition-action 'accept ; Silence warnings for redefinition
;; cursor-in-non-selected-windows t ; Hide the cursor in inactive windows
;; display-time-default-load-average nil ; Don't display load average
;; fill-column 80 ; Set width for automatic line breaks
help-window-select t ; Focus new help windows when opened
indent-tabs-mode nil ; Prefers spaces over tabs
inhibit-startup-screen t ; Disable start-up screen
;; initial-scratch-message "" ; Empty the initial *scratch* buffer
;; kill-ring-max 128 ; Maximum length of kill ring
;; load-prefer-newer t ; Prefers the newest version of a file
;; mark-ring-max 128 ; Maximum length of mark ring
;; scroll-conservatively most-positive-fixnum ; Always scroll by one line
;; select-enable-clipboard t ; Merge system's and Emacs' clipboard
tab-width 4 ; Set width for tabs
;; use-package-always-ensure t ; Avoid the :ensure keyword for each package
;; user-full-name "Terencio Agozzino" ; Set the full name of the current user
;; user-mail-address "terencio.agozzino@gmail.com" ; Set the email address of the current user
vc-follow-symlinks t ; Always follow the symlinks
;; view-read-only t ; Always open read-only buffers in view-mode
)
(cd "~/") ; Move to the user directory
(column-number-mode 1) ; Show the column number
(display-time-mode 1) ; Enable time in the mode-line
(fset 'yes-or-no-p 'y-or-n-p) ; Replace yes/no prompts with y/n
(global-hl-line-mode) ; Hightlight current line
;; (set-default-coding-systems 'utf-8) ; Default to utf-8 encoding
;; (show-paren-mode 1) ; Show the parent
;; use variable-pitch fonts for some headings and titles
(setq zenburn-use-variable-pitch t)
;; scale headings in org-mode
(setq zenburn-scale-org-headlines t)
;; scale headings in outline-mode
(setq zenburn-scale-outline-headlines t)
(setq zenburn-override-colors-alist
'(("zenburn-bg+05" . "#282828")
("zenburn-bg+1" . "#2F2F2F")
("zenburn-bg+2" . "#3F3F3F")
("zenburn-bg+3" . "#4F4F4F")))
(load-theme 'zenburn t)
(set-face-attribute 'default nil :font "Source Code Pro Medium")
(set-fontset-font t 'latin "Noto Sans")
(set-frame-font "DejaVu Sans Mono-18" nil t)
;;문법 강조를 활성화
(global-font-lock-mode t)
(transient-mark-mode 1)
(when window-system
(menu-bar-mode -1) ; Disable the menu bar
(scroll-bar-mode -1) ; Disable the scroll bar
(tool-bar-mode -1) ; Disable the tool bar
(tooltip-mode -1)) ; Disable the tooltips
;; org-mode 설정
;; org-mode 활성화
(require 'org)
;; org-mode를 .org로 끝나는 파일에서 활성화
(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
;; (global-set-key (kbd "<f3>") (lambda () (interactive) (find-file (concat "~/ungleich-learning-circle/youngjin.han/learning-"(system-name)"-"(substring (current-time-string) -4 nil)".org"))))
(global-set-key (kbd "<f3>") (lambda () (interactive) (find-file (concat "~/ungleich-learning-circle/youngjin.han/learning-"(system-name)"-"(format-time-string "%Y")".org"))))
(setq org-directory (expand-file-name "~/ungleich-learning-circle/youngjin.han"))
(use-package window
:ensure nil
:bind (("C-x 3" . hsplit-last-buffer)
("C-x 2" . vsplit-last-buffer))
:preface
(defun hsplit-last-buffer ()
"Gives the focus to the last created horizontal window."
(interactive)
(split-window-horizontally)
(other-window 1))
(defun vsplit-last-buffer ()
"Gives the focus to the last created vertical window."
(interactive)
(split-window-vertically)
(other-window 1)))
EOF
__require="__package/emacs __directory/~/.emacs.d __file/~/.emacs.d/init.el" \
__file ~/.emacs.d/10_magit_config.el \
--owner root \
--group root \
--mode 0644 \
--source - << EOF
;; 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.
(require 'magit)
(global-set-key (kbd "C-x g") 'magit-status)
EOF
__require="__package/emacs __directory/~/.emacs.d __file/~/.emacs.d/init.el" \
__file ~/.emacs.d/20_mu4e_config.el \
--owner root \
--group root \
--mode 0644 \
--source - << EOF
;; 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.
(add-to-list 'load-path "/usr/local/share/emacs/site-lisp/mu4e")
(require 'mu4e)
;; location of my maildir
(setq mu4e-maildir (expand-file-name "~/.maildir/ungleich/youngjin.han@ungleich.ch/"))
(setq mu4e-maildir-shortcuts
'( (:maildir "/Inbox" :key ?i)
(:maildir "/archive" :key ?a)
(:maildir "/drafts" :key ?d)
(:maildir "/sent" :key ?s)
(:maildir "/trash" :key ?t)))
;; these are actually the defaults
(setq
mu4e-refile-folder "/archive" ;; saved messages
mu4e-drafts-folder "/drafts" ;; unfinished messages
mu4e-sent-folder "/sent" ;; folder for sent messages
mu4e-trash-folder "/trash") ;; trashed messages
(setq
mu4e-index-cleanup nil ;; don't do a full cleanup check
mu4e-index-lazy-check t) ;; don't consider up-to-date dirs
(setq
mu4e-get-mail-command "mbsync -a" ;; or fetchmail, or ...
mu4e-update-interval 300) ;; update every 5 minutes
;; show images
(setq mu4e-show-images t)
(setq mu4e-reply-to-address "youngjin.han@ungleich.ch"
user-mail-address "youngjin.han@ungleich.ch"
user-full-name "YOUNGJIN.HAN")
;; spell check
(add-hook 'mu4e-compose-mode-hook
(defun my-do-compose-stuff ()
"My settings for message composition."
(set-fill-column 72)
(flyspell-mode)))
;;rename files when moving
;;NEEDED FOR MBSYNC
(setq mu4e-change-filenames-when-moving t)
;;store org-mode links to messages
(require 'org-mu4e)
(define-key mu4e-headers-mode-map (kbd "C-c c") 'mu4e-org-store-and-capture)
(define-key mu4e-view-mode-map (kbd "C-c c") 'mu4e-org-store-and-capture)
(setq mu4e-headers-skip-duplicates nil)
;;store link to message if in header view, not to header query
(setq org-mu4e-link-query-in-headers-mode nil)
EOF
__require="__package/emacs __directory/~/.emacs.d __file/~/.emacs.d/init.el" \
__file ~/.emacs.d/21_smtp_config.el \
--owner root \
--group root \
--mode 0644 \
--source - << EOF
;; 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.
(require 'smtpmail)
;; smtp
(setq message-send-mail-function 'smtpmail-send-it
smtpmail-starttls-credentials
'(("smtp.ungleich.ch" 587 nil nil))
smtpmail-default-smtp-server "smtp.ungleich.ch"
smtpmail-smtp-server "smtp.ungleich.ch"
smtpmail-smtp-service 587
smtpmail-auth-credentials "~/.authinfo"
smtpmail-debug-info t)
EOF
__require="__package/emacs __directory/~/.emacs.d __file/~/.emacs.d/init.el" \
__file ~/.emacs.d/30_agenda_config.el \
--owner root \
--group root \
--mode 0644 \
--source - << EOF
;; 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.
(require 'org-agenda)
(global-set-key (kbd "C-c a") 'org-agenda)
(require 'org-capture)
(setq org-capture-templates
'(("t" "todo" entry (file+headline (concat "~/ungleich-learning-circle/youngjin.han/todo-"(system-name)"-"(format-time-string "%Y")".org") "Tasks")
"* TODO [#A] %?\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n%a\n")))
(global-set-key (kbd "<f8>") 'org-todo-list)
(setq org-log-done 'time)
EOF
__require="__package/emacs __directory/~/.emacs.d __file/~/.emacs.d/init.el" \
__file ~/.emacs.d/99_custom_config.el \
--owner root \
--group root \
--mode 0644 \
--source - << EOF
;; 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.
EOF

View File

@ -1,3 +1,42 @@
* 2020-05-06
** 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```
* 2020-05-04
*** cdist #1: Introduction
**** Lecture content