Updates from June, 2016 Toggle Comment Threads | Keyboard Shortcuts

  • penguin 16:22 on 2016-06-28 Permalink | Reply
    Tags: , , ,   

    Testing logstash configs with Docker 

    Now this is really not rocket science, but since I might do this more often, I don’t want to google every time.

    Prepare your directories

    ./tmp                   # THIS IS YOUR WORKING DIRECTORY
      |- patterns/          # optional
      |   |- patternfile1   # optional
      |   |- patternfile2   # optional
      |- logs.log
      |- logstash.conf

    Prepare your logstash config

    # logstash.conf
    input {
      file {
        path => '/stash/logs.log'
      }
    }
    
    filter {
      # whatever config you want to test
      grok {
        match        => [ "message", "%{WHATEVER}" ]
        patterns_dir => '/stash/patterns'              # optional :)
      }
    }
    
    output {
      stdout { codec => rubydebug }
    }

    Run logstash

    docker run --rm -ti -v $(pwd):/stash logstash logstash -f /stash/logstash.conf

    Done.

    Done. 🙂

     
  • penguin 08:07 on 2016-06-28 Permalink | Reply
    Tags: , rspec, rspec-puppet, ,   

    Loathing RSpec and Puppet 

    There are words for how much I hate RSpec (especially RSpec-Puppet), but they would be too harsh to write down.

    So now that I don’t have to google the same shit over and over again, here’s what you have to do to get basic puppet module testing up and running (replace $MODULE with your module name, of course):

    $MODULE/Rakefile

    require 'rubygems'
    require 'puppetlabs_spec_helper/rake_tasks'

    $MODULE/.fixtures.yml

    fixtures:
      repositories:
        concat: git://github.com/puppetlabs/puppetlabs-concat.git
        # alternate method, for specifying refs
        stdlib: 
          repo: git://github.com/puppetlabs/puppetlabs-stdlib.git
          ref:  1.0.0
      symlinks:
        # do _not_ forget this
        $MODULE: "#{source_dir}"

    $MODULE/spec/spec_helper.rb

    require 'rubygems'
    require 'puppetlabs_spec_helper/module_spec_helper'

    $MODULE/spec/classes/$MODULE_spec.rb

    # see also http://rspec-puppet.com/
    require 'spec_helper'
    
    describe '$MODULE' do
      context 'default' do
        it {
          should contain_file('/etc/haproxy/haproxy.conf')
        }
    
        # or ...
        it do
          is_expected.to contain_file('/this/syntax/is/even/more/retarded')
        end
      end
    end

    Final note

    It’s “rake spec”, not “rake test”. Of course.

     
  • penguin 11:53 on 2016-06-22 Permalink | Reply
    Tags: jumpcloud, ldap, teamcity   

    TeamCity LDAP authentication with JumpCloud 

    JumpCloud looks like a great service to use LDAP without using LDAP. And I have just managed to find an error in the documentation, precisely the file “ldap-config.properties.dist”.

    The working configuration is:

    # basic jumpcloud url
    java.naming.provider.url=ldap://ldap.jumpcloud.com:389/
    
    # search user for jumpcloud
    java.naming.security.principal=uid=BIND_USER_NAME,ou=Users,o=ORG_ID,dc=jumpcloud,dc=com
    java.naming.security.credentials=BIND_USER_PASSWORD
    
    # unix ldap seems to use uid as username - see https://is.gd/dBPegr
    teamcity.users.login.filter=(uid=$capturedLogin$)
    teamcity.users.username=uid
    teamcity.users.base=ou=Users,o=ORG_ID,dc=jumpcloud,dc=com

    Seems to work nicely, now comes the finetuning.

     
c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
shift + esc
cancel