Skip to content

Instantly share code, notes, and snippets.

View mrcrilly's full-sized avatar

Michael Crilly mrcrilly

View GitHub Profile
@mrcrilly
mrcrilly / gist:8416194
Created January 14, 2014 10:17
Foreman SSL cert change failure.
root@xyz:/etc/apache2/conf.d# ls -l /etc/foreman/tls
total 16
-rw-r--r-- 1 root root 2090 Jan 13 10:27 xyz.crt
-rw-r--r-- 1 root root 1675 Jan 13 10:27 xyz.key
-rw-r--r-- 1 root root 4474 Jan 13 10:27 ca_bundle.cer
root@xyz:/etc/apache2/conf.d# openssl verify -verbose -CAfile /etc/foreman/tls/ca_bundle.cer /etc/foreman/tls/xyz.crt
/etc/foreman/tls/xyz.crt: OK
root@xyz:/etc/apache2/conf.d# tail foreman.conf -n15
@mrcrilly
mrcrilly / gist:8417156
Created January 14, 2014 11:54
Foreman installer log
[ INFO 2014-01-14 11:36:49 main] Parsing default values from puppet modules...
[DEBUG 2014-01-14 11:36:49 main] echo '$kafo_config_file="/usr/share/foreman-installer/config/foreman-installer.yaml" $kafo_add_progress=true include foreman_proxy::params include puppet::params include foreman::params dump_values(foreman_proxy::params::port,foreman_proxy::params::dhcp_range,foreman_proxy::params::dns_server,foreman_proxy::params::ssl_ca,foreman_proxy::params::ssldir,foreman_proxy::params::tftp_root,foreman_proxy::params::dhcp,foreman_proxy::params::dhcp_vendor,foreman_proxy::params::dhcp_key_secret,foreman_proxy::params::bmc,foreman_proxy::params::use_sudoersd,foreman_proxy::params::tftp,foreman_proxy::params::dns_managed,foreman_proxy::params::custom_repo,foreman_proxy::params::user,foreman_proxy::params::ssl,foreman_proxy::params::ssl_key,foreman_proxy::params::tftp_dirs,foreman_proxy::params::dhcp_managed,foreman_proxy::params::trusted_hosts,foreman_proxy::params::puppetca,foreman_proxy::params::puppetca_cmd,f
@mrcrilly
mrcrilly / gist:8440712
Created January 15, 2014 17:38
Puppet apt-mark issues
# puppet agent -t
Info: Retrieving plugin
Info: Loading facts in /var/lib/puppet/lib/facter/vmwaretools_version.rb
Info: Loading facts in /var/lib/puppet/lib/facter/esx_version.rb
Info: Loading facts in /var/lib/puppet/lib/facter/facter_dot_d.rb
Info: Loading facts in /var/lib/puppet/lib/facter/rabbitmq_erlang_cookie.rb
Info: Loading facts in /var/lib/puppet/lib/facter/root_home.rb
Info: Loading facts in /var/lib/puppet/lib/facter/puppet_vardir.rb
Info: Loading facts in /var/lib/puppet/lib/facter/pe_version.rb
Info: Loading facts in /var/lib/puppet/lib/facter/concat_basedir.rb
@mrcrilly
mrcrilly / mcollective.rb
Created January 17, 2014 16:32
MCollective bug or lack of understanding
require 'mcollective'
mc = MCollective::Client.new('/etc/mcollective/server.cfg')
mc.discover('/.*/', 60)
mc.disconnect
# $ ruby helloworld.rb
# /usr/lib/ruby/1.8/mcollective/discovery.rb:24:in `discovery_method': undefined method `[]' for nil:NilClass (NoMethodError)
# from /usr/lib/ruby/1.8/mcollective/discovery.rb:84:in `force_discovery_method_by_filter'
$ python rita.py
debug: contentpath: /Users/someuser/.rita/content/
debug: raw content: [('/Users/someuser/.rita/content/', ['pages'], ['helloworld.md', 'index.md']), ('/Users/someuser/.rita/content/pages', [], ['aboutme.md'])]
debug: process_content()
debug: content: []
@mrcrilly
mrcrilly / mcollective-to-foreman.py
Created January 19, 2014 16:00
Script for using MCollective's mco client and Foreman's API to check server visibility between the two systems. I obviously want all hosts in Foreman/Puppet to be visible via MCollective too. This simple Python script does a check for me, printing a list of servers that aren't visible between both systems (missing from one or the other). The onl…
import requests, shlex, json
from subprocess import Popen, PIPE
class MCollective:
def list_hosts(self):
process = Popen(shlex.split("mco rpc rpcutil ping -j"), stdout=PIPE)
j = process.communicate()[0]
process.wait()
@mrcrilly
mrcrilly / vlan-db-flask.txt
Created January 24, 2014 11:41
Flask output for VLAN DB
ImmutableMultiDict([('active', u'on'), ('site', u'1'), ('enhanced', u'on'), ('vlanid', u'13')])
Subnets: False
Sites: [<Site A9 (True)>]
Active: True
Enhanced: True
127.0.0.1 - - [24/Jan/2014 10:52:28] "POST /vlans/add HTTP/1.1" 302 -
ImmutableMultiDict([('active', u'on'), ('vlanid', u'13'), ('enhanced', u'on')])
@mrcrilly
mrcrilly / trace.txt
Created January 24, 2014 16:28
Trace
Traceback (most recent call last):
File "/home/mcrilly/Documents/Git/vs-vlan-db/venv/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/home/mcrilly/Documents/Git/vs-vlan-db/venv/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/home/mcrilly/Documents/Git/vs-vlan-db/venv/lib/python2.7/site-packages/flask_restful/__init__.py", line 258, in error_router
return original_handler(e)
File "/home/mcrilly/Documents/Git/vs-vlan-db/venv/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/mcrilly/Documents/Git/vs-vlan-db/venv/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
@mrcrilly
mrcrilly / banned.py
Last active January 4, 2016 13:49
Banned IPs
import sys
from ipaddress import IPv4Network, IPv4Address
def error_banned(ip_addr):
print "That's a banned IP: {}".format(str(ip_addr))
def error_private(ip_addr):
print "That IP is in a private range: {}".format(str(ip_addr))
@mrcrilly
mrcrilly / subnet_add.py
Created January 26, 2014 14:44
subnet add
# Works...
@app.route('/subnets/add', methods=['GET', 'POST'])
def subnets_add():
form = subnet.SubnetFormv2()
data = helpers.top_ten()
if form.validate_on_submit():
form.populate_obj(Subnet)
dbo.session.commit()