Skip to content

Instantly share code, notes, and snippets.

View martineg's full-sized avatar

Martin Eggen martineg

View GitHub Profile
@martineg
martineg / gist:4135519
Created November 23, 2012 13:01
lumberjack input (receiving java/tomcat logs)
# logstash indexer.conf
input {
lumberjack {
ssl_certificate => "/u01/logstash/ssl/logstash.crt"
ssl_key => "/u01/logstash/ssl/logstash.key"
type => "lumberjack"
port => 5959
}
}
@martineg
martineg / gist:7156398
Last active December 26, 2015 13:09
minimal ansible report
# first:
# $ ansible --tree facts all -m setup
import glob
import json
from collections import Counter
reports = { node['ansible_fqdn'] : node for node in [ r['ansible_facts'] for r in [ json.load(open(f)) for f in glob.glob("reports/*") ] if r.has_key('ansible_facts') ]}
@martineg
martineg / mongod.conf
Last active December 27, 2015 18:19
default mongodb config
# /etc/mongod.conf
#
dbpath = /var/lib/mongo
logpath = /var/log/mongo/mongod.log
pidfilepath = /var/run/mongodb/mongod.pid
logappend = true
fork = true
{% if replset_name is defined %}
replSet = {{ replset_name }}
@martineg
martineg / pgsql-snippets.sql
Last active January 4, 2016 16:29
PostgreSQL snippets
SELECT d.datname AS Name,
pg_catalog.pg_get_userbyid(d.datdba) AS Owner,
pg_catalog.pg_size_pretty(pg_catalog.pg_database_size(d.datname)) as size
FROM pg_catalog.pg_database d
ORDER BY pg_catalog.pg_database_size(d.datname);
- name: tomcat | Deploy configuration
template: src={{ item }}.j2 dest={{ tomcat_root }}/conf/{{ item }}
owner={{ tomcat_user }} group={{ tomcat_user }}
with_items:
- server.xml
- tomcat-users.xml
- log4j.xml
notify: restart tomcat
@martineg
martineg / gist:9049447
Last active August 29, 2015 13:56
mysql snippets
-- connections per database
select db, count(db) as connections
from information_schema.processlist group by(db) order by connections desc;
---
- hosts: xxx
user: root
vars:
ssl_cert_pkg: http://spacewalk-server/pub/rhn-org-trusted-ssl-cert-1.0-1.noarch.rpm
ssl_cert_file: /usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERT
tasks:
- name: check for Spacewalk server SSL certificate
@martineg
martineg / heartbleed.yml
Last active August 29, 2015 13:58
Check for listening on :443 on all RHEL 6.5 hosts
---
- hosts: all
tasks:
- name: Check if we listen on 443 on RHEL 6.5
command: nc -z {{ ansible_default_ipv4.address }} 443
when: ansible_distribution_version == '6.5'
register: rc
ignore_errors: true
changed_when: rc|success
@martineg
martineg / gist:10604955
Last active August 29, 2015 13:59
Ansible - wait for webapp to be available
- name: wait for app server to start up
wait_for: host=127.0.0.1 port=8080 state=started
- name: wait for webapp to be available
uri: url=http://localhost:8080/{{ monitor_uri }} method=GET
return_content=yes
timeout=30
register: result
until: "{{ status_string_ok }}" in result.content
retries: 15
@martineg
martineg / gist:1f5d3bf3f0af095eebdf
Created August 25, 2014 12:19
Pharo Teapot REST example
"From http://smalltalkhub.com/#!/~zeroflag/Teapot"
| books teapot |
books := Dictionary new.
teapot := Teapot configure: {
#defaultOutput -> #json. #port -> 8000. #debugMode -> true }.
teapot
GET: '/books' -> books;