Mastodon Mastodon - Snippets
 logo
  • Home 
  • Tags 
  • Blog posts 
  1. Home
  2. Categories
  3. Snippets

Snippets

November 26, 2015 •2 min read • Docker

Docker registry, S3 and permissions

There are a couple of bazillion blog posts saying “yah just did my docker registry on S3”. It’s not so easy, though. Cause what if you want to limit access to a certain IAM user? Yup, you need to go deep (well, a bit) into the policy thing of Amazon. Which sounds simple, but isn’t. I got “HTTP 500” errors from the docker registry when I first deployed. My configuration, which was wrong, looked like this: ...

November 19, 2015 •1 min read

InsufficientCapabilities on AWS

New project. I can play around as much as I want, as long as on day X I am done. Really frightening, and really cool. Anyway, first operation: Create a bunch of S3 buckets and IAM roles to interface with them. Which is kinda not-so-easy. Beacause when you create IAM capabilities with cloudformation, you get this error: { "CapabilitiesReason": "The following resource(s) require capabilities: [AWS::IAM::AccessKey, AWS::IAM::User]", "Capabilities": [ "CAPABILITY_IAM" ], "Parameters": [] }… which is a fancy way of saying “do this”: ...

July 28, 2015 •1 min read • Git

Git rebase interactive with very first commit visible

Ever wanted to squash the first two commits with a “git rebase -i”? No? Me neither. Until today. Stackoverflow to the rescue: git rebase -i rootDone.

July 28, 2015 •1 min read • Puppet

Puppet spec fixtures

That’s how you specify branches in puppetlabs’ spec_helper fixtures.yml: fixtures: forge_modules: stdlib: repo: "puppetlabs/stdlib" ref: "4.6.0" symlinks: mapr_helpers: "#{source_dir}" repositories: mapr: repo: "http://myurl/puppet-mapr.git" # this is a branch. stolen from: don't remember. ref: 'remotes/origin/ab/devel'

July 15, 2015 •1 min read • Docker

Docker, http and TLS

Today seems to be “annoyme-day”. This error message with docker: $ docker push myrepo.com:5000/name/image Post http:///var/run/docker.sock/v1.19/images/myrepo.com:5000 \ /name/image/push?tag=: read unix /var/run/docker.sock: \ connection reset by peer. Are you trying to connect to \ a TLS-enabled daemon without TLS?… does not necessarily mean that we use http:// instead of https://. It can also mean that the docker service is not running: $ systemctl status docker.service ● docker.service - Docker Application Container Engine Loaded: loaded (/etc/systemd/system/docker.service; disabled; vendor preset: disabled) Active: failed (Result: start-limit) since Wed 2015-07-15 17:16:48 CEST; 15s ago Docs: https://docs.docker.com Process: 48587 ExecStart=/usr/bin/docker td -H fd:// $DOCKER_OPTS (code=exited, status=1/FAILURE) Main PID: 48587 (code=exited, status=1/FAILURE)Took me 15 minutes. ...

July 15, 2015 •1 min read • Ssl

Get SSL certificate from endpoint quickly

If you want to download and save it so stops f*cking bugging you, you need to have it. Here’s a quick way. Shamelessly stolen from here: http://is.gd/A11rNR openssl s_client -host google.com -port 443 -prexit -showcerts

July 15, 2015 •1 min read • Docker

Docker and proxies

… so I don’t forget. “docker pull” will not use the HTTP_PROXY variable. Why? Because “docker” is just the cli program which tells the daemon what to do. And the daemon probably does not know about the variable if just set in the terminal. So, what to do to make docker use it described pretty well here: https://docs.docker.com/articles/systemd/#http-proxy Next thing: Don’t forget to go “systemctl daemon-reload”, because otherwise this will not be effective, even with “systemctl restart docker”. ...

July 2, 2015 •1 min read • Puppet

Puppet Quiz: What’s wrong here?

The error is: Dependency cycle. The code is: class my::own::docker { include ::docker file { '/var/lib/docker': ensure => directory, before => Class['docker'], } }Why? 🙂 It’s rather simple here, in the real class it really took me a while to find it.

June 23, 2015 •1 min read • Openstack

OpenStack IPs, part II

Just a short one. Now that I can list IPs (see last post), it might be nice to associate them on the command line, too. First I wanted to extend the little script, but then I remembered there must already be a CLI way for this. And there is. $ openstack server list $ nova floating-ip-associate (Note: The floating-ip is the actual IP, not the UUID of the OpenStack floating IP) ...

June 22, 2015 •1 min read • Bugs

LibreOffice tables

Filed my first LibreOffice bugs. And I must say: A free and open source word processor with an open doucment format is desperately needed, but one that actually works. LibreOffice is really … well, bad looking and playing catch-up with “the other”, and crashing really way too often for my taste. And while working with a lot of tables (which is a pain in the ass with LO) I found three bugs. And on one bug even the LO team agrees that it’s a major one 🙂 . ...

June 22, 2015 •2 min read • Solved

OpenStack floating IP convenience

Problem: I am working in a tenant which has a couple of hosts with floating IPs assigned. I always have to look them up either manually using the command line clients (and dealing with all those UUIDs), or manually in the web GUI. Didn’t like. Solution: Python script, which outputs FLOATING_IP -> HOST_NAME. Here it is. #!/usr/bin/env python from novaclient import client import novaclient.v2.floating_ips as os_fips import novaclient.v2.servers as os_servers import novaclient.v2.networks as os_networks #from pprint import pprint as pp import os from sys import exit def error(printme): print("ERROR: {}".format(printme)) exit1) def check_env(): for a in ("OS_TENANT_ID", "OS_TENANT_NAME", "OS_AUTH_URL", "OS_USERNAME", "OS_PASSWORD"): if not os.environ.get(a): error("Please set ${}".format(a)) def get_client(): check_env() return client.Client(2, os.environ["OS_USERNAME"], os.environ["OS_PASSWORD"], os.environ["OS_TENANT_NAME"], os.environ["OS_AUTH_URL"]) if __name__=="__main__": nova = get_client() fipman = os_fips.FloatingIPManager(nova) servman = os_servers.ServerManager(nova) netman = os_networks.NetworkManager(nova) ips = fipman.list() srs = servman.list() id2server = {} for a in srs: id2server[a.id] = a ips = [(ip.ip, ip.instance_id) for ip in ips] # filter out unused floating ips (which have as instance id) ips = filter(lambda x: x[1], ips) # create (IP, SERVER_NAME pairs) ips = map(lambda x: (x[0], id2server[x[1]].name), ips) # sort for convenience by host instance name ips = sorted(ips, key=lambda x: x[1].lower()) for a in ips: print("{:18s} {}".format(a[0], a[1]))Sample output: ...

June 19, 2015 •2 min read • Dev

Microsoft Code and Typescript

So being on the enterJS conference I wanted to get started with JavaScript. And TypeScript seems really promising. And once again I stumbled over the DIW pattern - Download, Install, Weird error messages. So, here’s my take on how to get started. I wanted … to try node-hid to see my USB HID devices, using TypeScript, Microsoft Visual Studio Code, and Node.js. So here’s how to get it to work: ...

June 15, 2015 •1 min read • Linux: Arch

Shared clipboard for Arch Linux as VMWare guest

… aaaand I wanted to have a shared clipboard. It’s again all in the wiki, but again a bit distributed. So here we go. First: Install open-vm-tools and gtkmm, then add some modules to system bootup “sudo pacman -S open-vm-tools gtkmm” “sudo vim /etc/mkinitcpio.conf” Under “MODULES=…” add the following: “vmxnet3 vmw_vmci vmw_pvscsi vmw_balloon” (You probably don’t need most of them, but this is the config which worked for me. I didn’t try to remove them one-by-one to see which ones are actually needed) “sudo mkinitcpio -p linux” reboot Second, make sure “vmware-user-suid-wrapper” is stared on login: ...

June 15, 2015 •1 min read

Install infinality fonts bundle in arch

Installing custom repos in Arch is kind of annoying. But here’s how it goes (especially if you’re behding a firewall which permits only ports 80, 443 and 22): First. Switch the keyserver to a HTTP based one. To do this: edit /etc/pacman.d/gnupg/gnupg.conf replace “keyserver hkp://…” with “keyserver hkp://keyserver.kjsl.com:80” Second. Get the key ID for the repo (in my case from the wiki): KEY ID is “962DDE58” Third. Download key from keyserver and sign it locally: ...

April 15, 2015 •1 min read • Docker

Fedora, docker and self-signed SSL certs

I am behind a company firewall with a man-in-the-middle SSL certificate for secure connections. Can’t have viruses over SSL, can we? But apps which actually verify SSL connections (which is all of the apps using standard SSL/TLS/whatnot libs) do not like this. And rightfully so. But then we’re left with the following problem: $ docker search test FATA[0000] Error response from daemon: GEt https://index.docker.io/v1/search?q=test: x509: certificate signed by unknown authority $Now, to solve this on Fedora we do the following (all as root): ...

August 27, 2014 •1 min read • *Nix

zsh and dot-directory completions

I blog so I don’t forget. At least that’s what I’m telling me right now 🙂 . So. To make zsh complete - for example - “cd ..” (it should append a “/” on TAB, right?) set the following in the .zshrc: setopt autocd zstyle ':completion:*' special-dirs true # please complete "cd .._/_" ...Great. Of course from Stackoverflow.

August 27, 2014 •1 min read • Git

Synology and Git, II

Don’t use the synology git package. But then Git’s not installed. I found a compromise: Install the package disable it switch back the shells in /etc/passwd from to /bin/sh Be happy.

August 20, 2014 •1 min read • Tools

Sublime Text: Keyboard Shortcut for setting Tab Width

Schwer zu finden … Wer schnell über das Keyboard die Tab Width verändern will, der tue das so: { "keys": ["super+k", "super+2"], "command": "set_setting", "args": { "setting": "tab_size", "value": 2 } }(gefunden hier: http://is.gd/Pz9zE0)

August 14, 2014 •1 min read • Solved

NAS Performance & Mac

Ich bin stolzer Besitzer eines Synology NAS. Das hängt mit meinem Mac an einem Gigabit-Ethernet, und funktioniert ziemlich gut. Große Dateien bekomme ich mit Transferraten von 100 MB/sec rüber. Aber. Möchte ich von meinem Mac aus eine Netzwerkfreigabe im Finder browsen - dann dauert das listen von Verzeichnissen SEKUNDEN. Anzeigen von JPGs (kleinen!) in der Vorschau auch gerne mal 10-20 davon. Abhilfe schafften nach langem googlen folgende Erste-Hilfe-Maßnahmen im Terminal: ...

May 9, 2014 •2 min read • Etcd

The limits of puppetDB a.k.a. etcd with puppet

Okay. Maybe this is the completely wrong way to do this, but I found no other. Comments appreciated. Situation: A DNS server cluster, meaning pacemaker managing an IP failover if one of them fails. The cluster IP (the one switching over) should be the IP used for DNS lookups. Idea: Hosts should automatically find ’their’ DNS server using something. The DNS server should register itself somewhere so it is automatically set up during the first puppet run. So far, so good. Unfortunately there are a few problems with it. My first approach was something like this: ...

January 14, 2014 •2 min read • Solved

Synology Git Server

Ich besitze ab neulich eine wundervolle Synology DS414. Schönes Teil. Und da ich aktuell ein wenig programmiere zu Hause wollte ich mir hier ein Git repository server einrichten. Das ist nicht ganz trivial, und wer sich github- oder gitlab-ähnlichen Komfort erhofft … ah, nö. Es ist commandline only, und davon viel. Aber zum Punkt - der schnellstmöglichen Einrichtung eines Git-Repo-Servers auf einer Diskstation. Der SSH-Zugriff unter Systemsteuerung > Terminal muss aktiviert sein. Es müssen Benutzer angelegt sein, und diese müssen ein Home-Verzeichnis haben (für die ssh-Schlüssel, ohne die es keinen Spaß macht). Das home-Verzeichnis aktiviert man in der Systemsteuerung > Benutzer, dann oben ein Knopf Benutzerbasis (der 2. von rechts bei mir) Wenn die Benutzer vorhanden sind legt man eine Freigabe an, das macht die Sache einfacher. Ich nutze /volume1/gitrepos. Den eigenen ssh-Schlüssel ins home-Verzeichnis kopieren. Das sollte unter /volume1/homes/ erreichbar sein, das Volume hat man vorhin in Schritt (1) ausgewählt. (natürlich muss .ssh/ 0600 und . sein, und .ssh/authorized_keys 0700 und ., aber das muss ich ja nicht extra erwähnen, oder?) Jetzt den Git-Service aktivieren, dem gewünschten Benutzer den Zugriff erlauben. Ein repository anlegen ist leider Handarbeit: Anmelden als root, dann nach /volume1/gitrepos wechseln, ein Verzeichnis anlegen … … git init bare ausführen, … und und jetzt entweder alles word-writable machen (bäh), oder dem entsprechenden Benutzer mittels chown zuweisen (yup). Beispiel: /volume1/gitrepos/my_repo Schließlich auf dem Arbeitsrechner noch git das neue Repo übergeben: git remote add origin @:/volume1/gitrepos/my_repo … und das wars. Ganz einfach, oder? Naja. ...

January 13, 2014 •1 min read • Oracle

Oracle virtualization

Ich hatte das zweifelhafte Vergnügen, mich mit OracleVM beschäftigen zu dürfen. Der Xen-basierten Virtualisierungslösung von Oracle. Zu dieser gehört der sog. “Oracle Manager”, eine WebLogic-basierte Anwendung zur Verwaltung aller VM hosts, cluster, VMs, und sonst noch allem. Die Aufgabe, die wir zu erledigen hatten, war prinzipiell einfach: Benutze den vorhandenen Manager, um auf 3 neuen Blades jeweils OracleVM (das Host-System) zu installieren, um dort ein paar virtuelle Maschinen laufen zu lassen. Der Trick: Die Blades waren über Trunk-Ports ans Netzwerk angeschlossen, da die VMs in verschiedenen Netzen operieren sollten. ...

August 1, 2013 •1 min read • Augeas

Augeas und Reihenfolge

Problem: mit HIlfe von Augeas einen Eintrag zur /etc/hosts Datei hinzufügen. Erste Lösung: augeas { "${title}" : context => '/files/etc/hosts', changes => [ "rm *[canonical = '${host}']", "set 02/canonical ${host}", "set 02/ipaddr ${ip}", ] }Funktioniert nicht. Warum? Trotz Aufruf von “save” am Ende einer jeden Sitzung im augtool ist die Reihenfolge der Anweisungen durchaus entscheidend - die Daten werden offenbar nicht erst am Ende zusammengesetzt. Hier z.B. gilt: In der gleichen Reihenfolge vorgehen, wie es auch in die Datei geschrieben werden würde. Und da steht nun mal am Anfang die IP Adresse. Daher also eine einfache kleine Änderung machen und schon gehts: ...

July 26, 2013 •1 min read • Puppet

Nervige Puppet Fehler

Was geht hier nicht? class { 'whatever' : do => 'something', before => Class[ 'something_else' ], } -> class { 'yeah_yeah' : do => 'even_more', }Na? Niemand? Gut. Lösung: “before =>” und >” mischen sich nicht. Das wäre nicht so schlimm, wäre die Fehlermeldung nicht absolut … unzureichend: err: Could not retrieve catalog from remote server: Error 400 on SERVER: undefined method `<<' for {}:Hash on node bstrap_foreman_v2. ...Noch sowas dass man nicht mehr vergisst. Glücklicherweise gibts grafische git logs … ...

July 19, 2013 •1 min read • Augeas

Puppet & Augeas & Pulp

Ach Augeas ist schon genial. Wenn nur nicht … (jaja, immer was zu meckern). Anlass diesmal: /etc/pulp/admin/admin.conf. Das ist eine in Augeas nicht vorgesehene Datei, und die Augeas-Doku ist … nun ja. Analyse: Die Datei besteht aus Sektionen ("[blablubb]"), und Einträgen (“hallo = welt”). Da sollte sich doch was finden lassen. Tut es auch: Die IniFile-Lens. Preisfrage: Wie testet man das? Beim Ausprobieren stieß ich auch auf die Information, dass die IniFile-Lens nicht für direkte Nutzung gedacht ist, sondern nur für die Nutzung in … abgeleiteten Lenses. Wie z.B. der Puppet-Lens. Die angeblich gut passt. Dann testet man das auf der Konsole folgendermaßen: ...

July 18, 2013 •1 min read • Puppet

Puppet, Arrays & Iteratoren

Endlich, endlich, endlich kommt in Puppet 3.2 die Möglichkeit, Schleifen zu bauen. Dann könnte ich eventuell folgende Aufgabenstellung ein klein wenig einfacher realisieren (aktuell arbeite ich bis zur endgültigen Umstellung unserer Systeme mit Puppet 2.7): Fasse alle im Rechner befindlichen Blockdevices der Form “/dev/sd*” - aber außer /dev/sda - in einer LVM volume group zusammen. Das Herausfinden der Blockdevices erledigt ein Fact aus Facter … naja, nicht ganz - ein in Facter 2.0 verfügbarer Fact, den ma aber dankenswerterweise zurückportieren kann. Dieser liefert uns $blockdevices - eine Komma-getrennte Liste der gefundenen devices, allerdings ohne “/dev/”, also nur “sda,sdb,sdc”. ...

July 4, 2013 •1 min read • Puppet

Puppet Stages & Notify

Die notify Funktion von Puppet hat eine seltsame Eigenschaft, die ich persönlich wenig nachvollziehbar finde. Sie impliziert einen “beforeZusammenhang zwischen der Resource, die benachrichtigt, und der benachrichtigten. Das führt zu unpraktischen Komplikationen. Der Versuch einer Herleitung: service { "tomcat" : ensure => running } file { "/etc/tomcat.conf" : notify => Service["tomcat"] }Das funktioniert bestens, und bedeutet, dass zuerst die file-Direktive abgearbeitet wird, und dann der Service. Darauf aufbauend kann ich mir sehr gut folgende Erweiterung vorstellen: class { "deployment::basic_app_server" : } file { "/etc/tomcat.conf" : notify => Service["tomcat"] }Nehmen wir an in “deployment::basic_app_server” werden einige zentrale Dinge geregelt, darunter auch der tomcat-Service. Die Absicht: Ich möchte mich darauf verlassen können, dass spezifische Module auf einem bestimmten Konfigurationsstand aufsetzen. Dafür wurden stages eigentlich erfunden (meines Erachtens nach), also erweitern wir zu: ...

July 3, 2013 •1 min read • Fun

Sicherheitsmodus

Eben in der Mailbox: From: […] Betreff: Drucker prntr3131 läuft im Sicherheitsmodus Hallo, der Etagendrucker im 3. OG “prntr3131” druckt zur Zeit weiße Schrift auf weißem Papier. Die Hotline ist informiert und wird wohl einen Techniker bestellen. Gruß, […] 🙂

  • 1
  • 2
  • 3
In case you want to follow me

Here are some links. The further to the right, the less active.

           
(c) Axel Bock | Powered by Hinode.
Code copied to clipboard