Andrew Latham

Easy start with Ansible

Example from a local ansible source tree without using any install to run adhoc commands

Setup

Download or checkout the software, unpack and change into the base directory. We will then run a script to setup the environment. This can and should be done as a user and not root. Note you may need to install packages like python3-paramiko, python-paramiko, python3-jinja2, python-jinja2, python3-yaml, python-yaml and others to use Ansible.

cat hacking/README.md
source hacking/env-setup

Assume key works

./bin/ansible all -i 192.168.15.11, -a "uname -a"
192.168.15.11 | SUCCESS | rc=0 >>
Linux nodeone 3.16.0-4-amd64 #1 SMP Debian 3.16.39-1 (2016-12-30) x86_64 GNU/Linux

Set key

 ./bin/ansible all -i 192.168.15.11, -a "uname -a" --private-key=~/.ssh/id_rsa
192.168.15.11 | SUCCESS | rc=0 >>
Linux nodeone 3.16.0-4-amd64 #1 SMP Debian 3.16.39-1 (2016-12-30) x86_64 GNU/Linux

whoami

./bin/ansible all -i 192.168.15.11, -a "whoami" --private-key=~/.ssh/id_rsa
192.168.15.11 | SUCCESS | rc=0 >>
lathama

become root via su

./bin/ansible all -i 192.168.15.11, --private-key=~/.ssh/id_rsa -b --become-method=su -K -a "whoami"
SU password: 
192.168.15.11 | SUCCESS | rc=0 >>
root
Andrew Latham

Developers on various platforms can often unknowingly introduce encoding issues on files. Here is a solution to one problem.

Simple one liner to remove all ^M line returns from files in a directory. I use this on an Open Source project I work on mainly for PHP files. Type "CTRL v" then "CTRL m" to get the system ^M char. The character will not copy and paste. The filter for SVN is optional and insert CVS or git for your SCM of choice.

grep -IUrl "^M" * | grep -v svn | xargs sed -i 's/^M$//' Easy! Search the directory recursively. Filter out the SVN files. Run SED against the files in the list.

Andrew Latham

Mediawiki hacking to make it self editable

Good documentation sometimes needs good style. Mediawiki (what powers wikipedia.org) is a great solution. Along with private SSL you can have a secure but fast documentation system anywhere in the world. By default Mediawiki will load CSS enteries from the Mediawiki: namespace. You can add overrides to these files to change the look or even add your own classes.


Common.css for screens http://wiki.domain.tld/index.php/MediaWiki:Common.css for installs without rewrite rules http://wiki.domain.tld/MediaWiki:Common.css

Print.css for printing http://wiki.domain.tld/index.php/MediaWiki:Print.css for installs without rewrite rules http://wiki.domain.tld/MediaWiki:Print.css