Skip to content

Instantly share code, notes, and snippets.

@thejohnny
thejohnny / vault_logrotate
Created June 17, 2021 16:55 — forked from abuxton/vault_logrotate
logrotate setting file for HashiCorp's Vault audit file
# Change the path below to your own audit log path.
/var/log/vault/audit.log {
rotate 30
daily
# Do not execute rotate if the log file is empty.
notifempty
missingok
compress
# Set compress on next rotate cycl to prevent entry loss when performing compression.
delaycompress
@thejohnny
thejohnny / cloud_init_debugging.md
Created April 15, 2021 12:38 — forked from RagedUnicorn/cloud_init_debugging.md
Debugging tipps when working with cloud-init

Cloud-Init Debugging

Cloud-init combined with terraform can be a powerful tool to provision instances on startup. Debugging scripts that are run by cloud-init however are not the easiest to debug.

Logs

Usually on an Ubuntu machine a lot of what is happening can be found in the syslog

cat /var/log/syslog

Keybase proof

I hereby claim:

  • I am thejohnny on github.
  • I am thejohnny (https://keybase.io/thejohnny) on keybase.
  • I have a public key ASDcNAVyyNn-Oy3EnNs75PynuhYFnZfu0-x9BTzLG0ICXAo

To claim this, I am signing this object:

@thejohnny
thejohnny / delete-ami
Created December 20, 2018 20:17 — forked from elasticdog/delete-ami
Deregister an Amazon Machine Image (AMI) and delete its corresponding root device snapshot
#!/usr/bin/env bash
#
# delete-ami
#
# A script to deregister an Amazon Machine Image (AMI) and
# delete its corresponding root device snapshot.
#
##### Functions
data "template_file" "sts_assume_role" {
template = "${file("${path.module}/templates/policies/sts-assume-role.json")}"
vars {
sts_external_id = "${var.sts_external_id}"
}
}
resource "aws_iam_role" "main" {
name = "DatadogAWSIntegrationRole"
# List public hostnames of instances in an Elastic Load Balancer (ELB)
instances=`elb-describe-instance-health name-of-elb --show-long | cut -d"," -f2`
for instance in $instances
do
echo $instance -\> `ec2-describe-instances $instance | egrep "^INSTANCE" | cut -f4`
done
# same as one-liner
#for instance in `elb-describe-instance-health name-of-elb --show-long | cut -d"," -f2`; do echo $instance -\> `ec2-describe-instances $instance | egrep "^INSTANCE" | cut -f4`; done
task :add_github_to_known_hosts do
run "ssh [email protected] -o StrictHostKeyChecking=no -o'HostKeyAlgorithms=ssh-rsa' 2&1> /dev/null"
run "ssh [email protected] -o StrictHostKeyChecking=no -o'HostKeyAlgorithms=ssh-dss' 2&1> /dev/null"
end
1)
RuntimeError in 'CampaignPolicy Simple Policy Matching should be able to find promo policies by criteria'
[#<DataMapper::Validate::ValidationErrors:0x106bd9460 @resource=#<Criterion::Request @id=nil @campaign_policy_id=1 @host="http://www.videojuicer.com" @path="/" @http_query=nil @exclude=nil @created_at=nil @updated_at=nil>, @errors={}>, #<DataMapper::Validate::ValidationErrors:0x106bd93c0 @resource=#<Criterion::Affiliate @id=nil @campaign_policy_id=1 @user_id=1 @created_at=nil @updated_at=nil>, @errors={}>, #<DataMapper::Validate::ValidationErrors:0x106bd8740 @resource=#<Criterion::DateRange @id=nil @campaign_policy_id=1 @from=#<DateTime: 4889977/2,0,2299161> @until=#<DateTime: 4890459/2,0,2299161> @created_at=nil @updated_at=nil>, @errors={}>, #<DataMapper::Validate::ValidationErrors:0x106bd7840 @resource=#<Criterion::WeekDay @id=nil @campaign_policy_id=1 @monday=true @tuesday=nil @wednesday=nil @thursday=nil @friday=nil @saturday=nil @sunday=nil @exclude=nil @created_at=nil @updated_at=nil>, @errors={
/Users/john/Projects/Spreedly.git/vendor/rails/activerecord/lib/active_record/observer.rb:35: warning: instance variable @observers not initialized
Exception `NameError' at /Users/john/Projects/Spreedly.git/vendor/rails/activesupport/lib/active_support/dependencies.rb:443 - uninitialized constant ApiVersion4Controller
/Users/john/Projects/Spreedly.git/vendor/rails/actionpack/lib/action_controller/response.rb:50: warning: instance variable @session not initialized
/Users/john/Projects/Spreedly.git/vendor/rails/actionpack/lib/action_controller/templates/rescues/_request_and_response.erb:20: warning: instance variable @data not initialized
SQL (0.1ms) SET NAMES 'utf8'
SQL (0.1ms) SET SQL_AUTO_IS_NULL=0
Processing ApplicationController#show_subscriber to xml (for 127.0.0.1 at 2009-03-18 16:20:29) [GET]
Parameters: {"site_id"=>"thejohnny-test", "id"=>"1", "api_version"=>"v4"}
3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912983367336244065664308602139494639522473719070217986094370277053921717629317675238467481846766940513200056812714526356082778577134275778960917363717872146844090122495343014654958537105079227968925892354201995611212902196086403441815981362977477130996051870721134999999837297804995105973173281609631859502445945534690830264252230825334468503526193118817101000313783875288658753320838142061717766914730359825349042875546873115956286388235378759375195778185778053217122680661300192787661119590921642019893809525720106548586327