Andrew Latham

Easy start with Ansible

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


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/
source hacking/env-setup

Assume key works

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


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

become root via su

./bin/ansible all -i, --private-key=~/.ssh/id_rsa -b --become-method=su -K -a "whoami"
SU password: | SUCCESS | rc=0 >>
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 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