Ansible https://tech.feedyourhead.at/tags/ansible en HackADay: Let's make a Nukestation https://tech.feedyourhead.at/content/hackaday-lets-make-a-nukestation <span class="field field--name-title field--type-string field--label-hidden">HackADay: Let&#039;s make a Nukestation</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>Every time I replace an old hard disk by a newer or bigger one I think that I'll wipe it later. Now I have a big amount of hard disks to wipe. Since wiping takes ages, I don't want to use my personal computer for that. I would prefer a small device with low energy consumption just for wiping. That's why I am going to build a "Nukestation". Basically it's just a Raspberry Pi with nwipe on it and a udev-rule for automatically wipe attached hard disks. But some extras would be nice...</p> <h3>Hardware</h3> <p>My setup is quite basic: a Raspberry Pi 3b+, a Disk-Docking-Station(USB), and a LED for signalling that the drive can safely removed/attached. I know, It would be much better to use a red LED for signalling when the Nukestation is wiping disks, but I had just green LED's at home. That's why I am gonna do that the way around.</p> <p> <video controls="" height="360" width="480"><source src="/sites/default/files/DateiUploads/nukestation.mp4" type="video/mp4" /></video> </p> <p>This video shows my setup. As soon as I plugg in the harddisk, the green led turns dark for signalling that it is not safe to remove the disk now, and on the screen we can see that nwipe starts it's job.</p> <h3>Little Extras</h3> <p>I wrote a bash-script called "nukestation.sh". This script is a wrapper for nwipe and allows us to:</p> <ul> <li>Create Pre-run-hooks(like turn off the LED)</li> <li>Run nwipe with configurable settings</li> <li>Create Post-run-hoocks(like turn on the LED)</li> <li>Send a notification including the nwipe-log via email</li> </ul> <h3>Installation</h3> <p>I won't use this Raspberry Pi only for wiping disks. That's why I need a very easy to use installation routine for the nukestation. I used the configuration management sytem <a href="https://www.ansible.com/">ansible</a> for that. The sources of my nukestation ansible-role can be downloaded on <a href="https://github.com/whotwagner/ansible-role-nukestation">Github</a>&nbsp; and the role is available on ansible-galaxy too. On a freshly installed <a href="https://www.raspberrypi.org/downloads/raspbian/">Raspbian</a>&nbsp; the Nukestation can be installed using the follwing commands:</p> <pre> <code> $ sudo apt-get install ansible $ sudo ansible-galaxy install whotwagner.nukestation $ cat > playbook.yml << EOF --- - hosts: localhost roles: - whotwagner.nukestation EOF $ sudo ansible-playbook playbook.yml </code></pre> <p>The playbook above will just install Nukestation without mailsupport. If we want to install a mailsystem with a smarthost using authentication to automatically send notifications we can use another playbook:</p> <pre> <code> $ sudo apt-get install ansible $ sudo ansible-galaxy install whotwagner.nukestation $ cat > playbook.yml << EOF - hosts: localhost roles: - whotwagner.nukestation vars: nukestation_mailconf: server: mail.example.conf:587 user: username@example.conf pass: super-secret-password from: from@example.com to: to@example.com EOF $ sudo ansible-playbook playbook.yml </code></pre> <p>A detailed documentation about the playbook and the nukestation.sh-script can be found at <a href="https://github.com/whotwagner/ansible-role-nukestation">Github</a>.</p> <h3>Conclusio</h3> <p>Nukestation allows me to wipe disks easily and I'll recieve notifications as soon as the wipejob is finished. <em>"I love it when a plan comes together"</em></p> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/users/hoti" typeof="schema:Person" property="schema:name" datatype="">Hoti</span></span> <span class="field field--name-created field--type-created field--label-hidden">Apr 15 2018</span> <div class="field field--name-field-tagies field--type-entity-reference field--label-above"> <div class="field__label">Tags</div> <div class='field__items'> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/hackaday" hreflang="en">HackADay</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/hardware" hreflang="en">Hardware</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/raspberry" hreflang="en">Raspberry</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/Linux" hreflang="en">Linux</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/tricks" hreflang="en">Tricks</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/ansible" hreflang="en">Ansible</a></div> </div> </div> <section class="field field--name-comment-node-blog field--type-comment field--label-hidden comment-wrapper"> </section> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class='title comment-form__title'> <i class="fa fa-comments-o"></i> Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=262&amp;2=comment&amp;3=comment" token="mXNkYhJywlpehAmSRx0Jlb3KcW68vS026m820TmEpE8"></drupal-render-placeholder> </section> Sun, 15 Apr 2018 16:45:24 +0000 Hoti 262 at https://tech.feedyourhead.at Managing MaraDNS with Ansible https://tech.feedyourhead.at/content/managing-maradns-with-ansible <span class="field field--name-title field--type-string field--label-hidden">Managing MaraDNS with Ansible</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>I wrote a <a href="https://github.com/whotwagner/ansible-role-maradns">role for managing MaraDNS with Ansible</a>.</p> <h3>Requirements</h3> <ul> <li>Ansible 2.1+ (might ork with prior versions too)</li> <li>Debian-based Linux-distribution</li> </ul> <h3>Installation</h3> <p><code>ansible-galaxy install whotwagner.maradns</code></p> <h3>Configuration Example</h3> <pre><code> maradns_zones: - name: example.com email: support@example.com spf: - { val: 'v=spf1 ip4:212.41.224.0/24 -all' } txt: - { val: 'v=spf1 ip4:212.41.224.0/24 -all' } - { name: 'xmas', val: 'Merry Christmas' } ns: - { val: ns1.example.com. } - { val: ns2.example.com. } - { name: 'subdom.%', val: 'ns1.%' } mx: - { prio: 5, rec: mx.example.com. } - { prio: 10, rec: mx2.% } srv: - { name: "_sip._udp", val: "0 0 5060 sip.%" } fqdn4: - { domain: "mx", ip: "7.7.7.7" } ptr: - { domain: "www", ip: "8.8.8.8" } a: - { ip: 8.8.8.8 } - { domain: 'www', ip: 8.8.8.8 } - { domain: 'sip', ip: 6.6.6.6 } # the following zone is disabled: - name: alice.com enabled: False </pre><code></div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/users/hoti" typeof="schema:Person" property="schema:name" datatype="">Hoti</span></span> <span class="field field--name-created field--type-created field--label-hidden">Aug 28 2017</span> <div class="field field--name-field-tagies field--type-entity-reference field--label-above"> <div class="field__label">Tags</div> <div class='field__items'> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/ansible" hreflang="en">Ansible</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/Programming" hreflang="en">Programming</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/sysadmin" hreflang="en">Sysadmin</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/Linux" hreflang="en">Linux</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/downloads" hreflang="en">Downloads</a></div> </div> </div> <section class="field field--name-comment-node-blog field--type-comment field--label-hidden comment-wrapper"> </section> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class='title comment-form__title'> <i class="fa fa-comments-o"></i> Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=243&amp;2=comment&amp;3=comment" token="zU_W2MAJyqckkwjlDcj7hoIYMTQfaajbt8qlMirMjXA"></drupal-render-placeholder> </section> Mon, 28 Aug 2017 18:28:00 +0000 Hoti 243 at https://tech.feedyourhead.at Testing ansible-roles automatically on every git-push https://tech.feedyourhead.at/content/testing-ansible-roles-automatically-on-every-git-push <span class="field field--name-title field--type-string field--label-hidden">Testing ansible-roles automatically on every git-push</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p><img alt="ansible" data-entity-type="file" data-entity-uuid="42485588-89f9-4e0e-bf7b-0cae9a7b373c" src="/sites/default/files/inline-images/ansible.png" /></p> <p><a href="https://www.ansible.com/">Ansible</a> is a powerful configuration management tool. For developing and distributing ansible-roles we use <a href="https://about.gitlab.com/">Gitlab</a> at <a href="http://www.toscom.at">Toscom</a>. In this article I'll describe how to automatically test ansible-roles for different Linux-Distributions in <a href="https://www.docker.com/">Docker-Container</a> using Gitlab-Runner whenever someone pushes changes into our Gitlab-Repository.</p> <h3>Creating a Ansible-Debian-Docker-Image</h3> <p>First I created the following Dockerfile:</p> <pre> <code> # This Dockerfile was tested with debian jessie # # Build with: docker build -t ansible/debian_jessie . # FROM debian MAINTAINER hoti ENV DEBIAN_FRONTEND noninteractive RUN echo "deb http://ftp.debian.org/debian jessie-backports main" &gt; /etc/apt/sources.list.d/backports.list RUN apt-get update &amp;&amp; apt-get upgrade -y RUN apt-get install -y build-essential git python python-dev libffi-dev libssl-dev python-pip libyaml-dev libgmp-dev libgmp10 libyaml-0-2 apt-utils RUN apt-get install -y -t jessie-backports python-pyasn1 python-setuptools RUN git clone https://github.com/ansible/ansible.git /usr/local/src/ansible RUN cd /usr/local/src/ansible &amp;&amp; git checkout v2.1.2.0-1 &amp;&amp; git submodule update --init --recursive &amp;&amp; make &amp;&amp; make install USER root WORKDIR /var/tmp </code></pre> <p>This Dockerfile is easily built by calling the follwing command</p> <pre> <code> docker build -tansible/debian_jessie . </code></pre> <h3>Configuring the Gitlab-Repository</h3> <p>It's very important to install the Gitlab-Runner and Docker on the same host. The Gitlab-Runner can easily installed using <a href="https://docs.gitlab.com/runner/install/linux-repository.html">this instructions</a>.</p> <p>Now we can create the gitlab-runer-control-file(.gitlab-ci.yml) in our Gitlab-Repository of our ansible-role(let's call it "fancy-ansible-role"):</p> <pre> <code> debian:jessie: image: ansible/debian_jessie before_script: - mkdir -p roles/fancy-ansible-role - rsync -ar --exclude=.git --exclude=roles . roles/fancy-ansible-role script: - ansible-playbook .playbook.yml </code></pre> <p>And for our tests we create in our fancy-ansible-role-repository a file called .playbook.yml:</p> <pre> <code> - hosts: localhost roles: - fancy-ansible-role </code></pre> <p>To complete our ansible-role I'll create a simple task and add it to the fancy-ansible-role. This simple code I'll place at tasks/main.yml:</p> <pre> <code> --- - name: Fancy Ansible Role Debug debug: msg="HELLO WORLD" </code></pre> <p>This role simply prints out "HELLO WORLD".</p> <h3>Our Result</h3> <p>Finally we can push any changes in our repository and we can monitor the output of our tests in Gitlab:</p> <p><img alt="Ansible-Build" data-entity-type="file" data-entity-uuid="42c2718c-43fe-497b-9509-e31cf2a399de" height="545" src="/sites/default/files/inline-images/2016-12-07-19%3A09%3A17.jpg" width="1169" /></p> <h3>Conclusio</h3> <p>In this article I just created a playbook for one Linux-Distribution but it could be easily extended to perform those tests on multiple Distributions. This clearly shows that <a href="https://en.wikipedia.org/wiki/Continuous_integration">Continous Integration</a>-Tools can be very handy for Systemadministrators too.</p> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/users/hoti" typeof="schema:Person" property="schema:name" datatype="">Hoti</span></span> <span class="field field--name-created field--type-created field--label-hidden">Dec 07 2016</span> <div class="field field--name-field-tagies field--type-entity-reference field--label-above"> <div class="field__label">Tags</div> <div class='field__items'> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/ansible" hreflang="en">Ansible</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/tricks" hreflang="en">Tricks</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/git" hreflang="en">git</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/Linux" hreflang="en">Linux</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/sysadmin" hreflang="en">Sysadmin</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/Programming" hreflang="en">Programming</a></div> </div> </div> <section class="field field--name-comment-node-blog field--type-comment field--label-hidden comment-wrapper"> </section> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class='title comment-form__title'> <i class="fa fa-comments-o"></i> Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=217&amp;2=comment&amp;3=comment" token="a6k5_ZBG2Xoz36bsGQAsCBwAp8QVdd8-9G5xejvhl4c"></drupal-render-placeholder> </section> Wed, 07 Dec 2016 17:41:04 +0000 Hoti 217 at https://tech.feedyourhead.at facts2dw https://tech.feedyourhead.at/content/facts2dw <span class="field field--name-title field--type-string field--label-hidden">facts2dw</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>facts2dw.rb&nbsp; is a simple script which converts ansible(tested with&nbsp;1.9.2)&nbsp; facts into dokuwiki-format and uploads it via xmlrpc-interface into dokuwiki This script uses http-basic-authentication and ssl to login into dokuwiki. Ansible caches all the facts in &lt;ANSIBLE-DIR&gt;/facts so it is quite easy to import all facts into dokuwiki using the following line:</p> <pre> <code> for i in `ls *`; do facts2dw.rb $i; done </code></pre> <p>To upload all the changes whenever they occur I would suggest to use inotify. It is very easy to change this script to use puppet-facts instead of ansible-facts. If puppetdb is installed all the facts can fetched via the rest interface. It's just a matter of few lines. Of course the jason-structur will look different, but it will be easy to modify this very simple script. I would recommend to use the debug-code which executes 'pp', to dump the jason-hash.</p> <p>BTW: <a href="https://www.dokuwiki.org/devel:xmlrpc">don't forget to configure the xmlrpc-access in dokuwiki proberly!</a></p> <p>&nbsp;</p> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/users/hoti" typeof="schema:Person" property="schema:name" datatype="">Hoti</span></span> <span class="field field--name-created field--type-created field--label-hidden">Sep 24 2015</span> <div class="clearfix text-formatted field field--name-field-md5sum field--type-text field--label-above"> <div class="field__label">md5sum</div> <div class="field__item"><p>9f419544609f2539f79390e8f121a678</p> </div> </div> <div class="clearfix text-formatted field field--name-field-sha256sum field--type-text field--label-above"> <div class="field__label">sha256sum</div> <div class="field__item"><p>d25806bd0d8edf36caf6405e450c9dcd5e40ae5fa7d7ee16c6aabc5ecc1f090b</p> </div> </div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field__label">Tags</div> <div class="field__items"> <div class="field__item"><a href="/tags/downloads" hreflang="en">Downloads</a></div> <div class="field__item"><a href="/tags/ruby" hreflang="en">Ruby</a></div> <div class="field__item"><a href="/tags/ansible" hreflang="en">Ansible</a></div> <div class="field__item"><a href="/tags/puppet" hreflang="en">Puppet</a></div> <div class="field__item"><a href="/Programming" hreflang="en">Programming</a></div> <div class="field__item"><a href="/tags/sysadmin" hreflang="en">Sysadmin</a></div> </div> </div> <section class="field field--name-comment-node-download field--type-comment field--label-hidden comment-wrapper"> </section> Thu, 24 Sep 2015 13:18:36 +0000 Hoti 111 at https://tech.feedyourhead.at