emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Using source blocks instead of Ansible
@ 2016-04-27 18:10 William Denton
  2016-05-05  4:12 ` William Denton
  2016-05-05 21:02 ` Karl Voit
  0 siblings, 2 replies; 3+ messages in thread
From: William Denton @ 2016-04-27 18:10 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1370 bytes --]

Is anyone using Org for remote configuration management instead of a tool like 
Ansible?

For example:  I like to install R from source to /usr/local/src/R/ so that I 
always have the latest version.  I do this (changing the version numbers as 
needed, though looking at it now I see I should set the version number as a 
variable):

#+BEGIN_SRC shell
cd /usr/local/src/R
curl -O http://cran.utstat.utoronto.ca/src/base/R-3/R-3.2.4.tar.gz
tar xzvf R-3.2.4.tar.gz
cd R-3.2.4
./configure
make
make check
cd ..
rm -f R Rscript
ln -s R-3.2.4/bin/R R
ln -s R-3.2.4/bin/Rscript Rscript
#+END_SRC

I do that on a few machines and copy and paste as needed.  Now, I could use

:dir /me@remote:

to run that on another machine.  And if I want to run that on multiple machines 
I could change the target as needed.

Has anyone taken this to the next level so it's easier to manage tasks like 
this, more reproducible, tidier, and closer to Ansible or Chef?  If so I'd love 
to see an example.  Or if anyone's tried and found it's just easier to use a 
proper purpose-built system, that's good to know too.

Looking in the archives I see there was mention a couple of years ago of 
org-converge, but it's idle:

https://github.com/wallyqs/org-converge

Cheers,

Bill
-- 
William Denton ↔  Toronto, Canada ↔  https://www.miskatonic.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Using source blocks instead of Ansible
  2016-04-27 18:10 Using source blocks instead of Ansible William Denton
@ 2016-05-05  4:12 ` William Denton
  2016-05-05 21:02 ` Karl Voit
  1 sibling, 0 replies; 3+ messages in thread
From: William Denton @ 2016-05-05  4:12 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: TEXT/PLAIN, Size: 416 bytes --]

On 27 April 2016, William Denton wrote:

> Is anyone using Org for remote configuration management instead of a tool 
> like Ansible?

I decided to try to get this working for what I needed, and I was able to do it:

https://www.miskatonic.org/2016/05/05/conforguration/

It just does one thing, but I like the way it works.

Bill
-- 
William Denton ↔  Toronto, Canada ↔  https://www.miskatonic.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Using source blocks instead of Ansible
  2016-04-27 18:10 Using source blocks instead of Ansible William Denton
  2016-05-05  4:12 ` William Denton
@ 2016-05-05 21:02 ` Karl Voit
  1 sibling, 0 replies; 3+ messages in thread
From: Karl Voit @ 2016-05-05 21:02 UTC (permalink / raw)
  To: emacs-orgmode

* William Denton <wtd@pobox.com> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-05-05 21:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-27 18:10 Using source blocks instead of Ansible William Denton
2016-05-05  4:12 ` William Denton
2016-05-05 21:02 ` Karl Voit

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).