From mboxrd@z Thu Jan 1 00:00:00 1970 From: Karl Voit Subject: Re: Using source blocks instead of Ansible Date: Thu, 5 May 2016 23:02:28 +0200 Message-ID: <2016-05-05T22-49-08@devnull.Karl-Voit.at> References: Reply-To: Karl Voit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:44525) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ayQQN-0002sd-TI for emacs-orgmode@gnu.org; Thu, 05 May 2016 17:03:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ayQQB-0002Vd-R1 for emacs-orgmode@gnu.org; Thu, 05 May 2016 17:03:02 -0400 Received: from plane.gmane.org ([80.91.229.3]:50684) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ayQQB-0002PY-KY for emacs-orgmode@gnu.org; Thu, 05 May 2016 17:02:55 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1ayQQ1-0001NI-Hy for emacs-orgmode@gnu.org; Thu, 05 May 2016 23:02:45 +0200 Received: from friends.grml.info ([136.243.234.19]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 05 May 2016 23:02:45 +0200 Received: from news1142 by friends.grml.info with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 05 May 2016 23:02:45 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org * William Denton wrote: > > Is anyone using Org for remote configuration management instead of a tool= > like=20 > Ansible? Yes. I do. A month ago, I had to set up three Xubuntu machines from scratch with a very similar setup. Not everything worked perfectly. Some steps required manual changing to the running ssh/shell-session and entering passwords and so on directly before I could continue with C-c C-c of the next block. Overall, I was happy with my approach. It did not require as much of a learning (and setup) effort as Ansible which I don't know yet. IMHO the effort-value-ratio was quite good. My approach: * SYSTEM SETUP :PROPERTIES: :VAR: system="myhostname" host="192.168.1.2" user="user" gitname="git name" gitemail="user@gmx.at" server="192.168.1.1" :SESSION: 2016-03-22-remote-Linux-setup :results: output :tangle: ~/2016-03-22-remote-Linux-setup.sh :shebang: #!/bin/sh :comments: org :END: Setting defining myexit() and set_variable_equalsign() #+BEGIN_SRC sh myexit() { [ "x$2" == "x" ] || echo "ERROR: $2" [ "$1" -lt 1 ] && echo "$FILENAME done." [ "$1" -gt 0 ] && echo "$FILENAME aborted with errorcode $1." exit $1 } set_variable_root_equalsign() { FILE="${1}" KEY="${2}" VALUE="${3}" [ "x${VALUE}" == "x" ] && myexit 42 "set_variable_equalsign did not receive three arguments" sudo sed -i "s/^\(${KEY}\s*=\s*\).*\$/\1$VALUE/" "${FILE}" return_value=$? [ ${return_value} -eq 0 ] || echo "Could not set \"$KEY\" to \"$VALUE\" in \"$FILE\": error code ${return_value}" } #+END_SRC #+BEGIN_SRC sh echo "ssh-copy-id $user@$host" #+END_SRC Create ssh connection: #+BEGIN_SRC sh ssh $user@$host #+END_SRC Testing user, host, and sudo: *enter sudo Password in session* buffer! #+BEGIN_SRC sh date echo "my new host: $HOSTNAME" echo "my username: $USER" sudo head -n 1 /etc/shadow && echo "success" #+END_SRC #+BEGIN_SRC sh echo "$0: install ssh and related ..." DEBPACKAGES="openssh-server ssh-askpass ssh autossh" sudo apt-get install --yes ${DEBPACKAGES} #+END_SRC #+BEGIN_SRC sh echo "$0: setup git for root ..." sudo git config --global user.name "$gitname" sudo git config --global user.email "$gitemail" #+END_SRC #+BEGIN_SRC sh FILE="/etc/etckeeper/etckeeper.conf" KEY="VCS" VALUE="git" set_variable_root_equalsign "${FILE}" "${KEY}" "${VALUE}" cd /etc sudo etckeeper init sudo etckeeper commit "Initial commit of Org-mode setup script" #+END_SRC #+BEGIN_SRC sh echo "$0: get my emacs config ..." DOTEMACSSRC="$server:.emacs.d" cd $HOME scp -qr ${DOTEMACSSRC} . echo "$0: create host-specific init.el ..." cd .emacs.d cp init-gary.el init-${hostname}.el rm init.el ln -s init-${hostname}.el init.el #+END_SRC Scale fonts in Xfce: #+BEGIN_SRC sh export DISPLAY=:0.0 ## query current value: xfconf-query -c xsettings -p /Xft/DPI ## set new value: xfconf-query -c xsettings -p /Xft/DPI -n -t int -s 140 ## query new value: xfconf-query -c xsettings -p /Xft/DPI #+END_SRC switch CAPSLOCK to Ctrl: Make permanent: /usr/bin/setxkbmap -option '' -option 'ctrl:nocaps' ... add to Session & Startup > Application Autostart > Add ... For current session only: #+BEGIN_SRC sh export DISPLAY=:0.0 setxkbmap -option '' -option 'ctrl:nocaps'W #+END_SRC ... and so forth ... -- mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML to Org-mode: > get Memacs from https://github.com/novoid/Memacs < https://github.com/novoid/extract_pdf_annotations_to_orgmode + more on github