Skip to content

Instantly share code, notes, and snippets.

@garlandkr
garlandkr / gh-add-repos-to-team.sh
Created October 26, 2022 18:30 — forked from narze/gh-add-repos-to-team.sh
Add repos to team with gh
#!/bin/bash
PERMISSION="push" # Can be one of: pull, push, admin, maintain, triage
ORG="orgname"
TEAM_SLUG="your-team-slug"
# Get names with `gh repo list orgname`
REPOS=(
"orgname/reponame"
)
@garlandkr
garlandkr / 1-orgs-archetype.md
Created October 26, 2022 18:06 — forked from whatupfoo/1-orgs-archetype.md
Orgs and Teams Best Practices

Organization archetypes

The intention of this document is to provide some guidance and suggestions to customers who are wondering how they should structure organizations and teams in their GitHub Enterprise environment. The idea isn't to give hard and fast rules on which approach is better than the other, but to give examples of when one approach might be preferable to another depending on the use case.

1. A single organization with direct organization membership for repository access (not teams)

          ________________
          |     Org      |
          |    ______    |
          |   |      |\  |

| | Repo | \ |

root@dhcp104:~# cat /etc/update-motd.d/91-release-upgrade
#!/bin/sh
# if the current release is under development there won't be a new one
if [ "$(lsb_release -sd | cut -d' ' -f4)" = "(development" ]; then
exit 0
fi
if [ -x /usr/lib/ubuntu-release-upgrader/release-upgrade-motd ]; then
exec /usr/lib/ubuntu-release-upgrader/release-upgrade-motd
@garlandkr
garlandkr / Purge_CloudWatchAlarms.py
Last active April 12, 2016 17:12 — forked from jonathanwcrane/Purge_CloudWatchAlarms.py
Purge CloudWatch alarms for instances that no longer exist
import boto
cw = boto.connect_cloudwatch()
#Step 1: Get a list of all alarms in INSUFFICIENT_DATA status
#Step 2: Get a list of all instances (stopped and started)
#Step 3: Find all alarms on instances that don't exist, and delete them
###################################################
#Step 1: Get alarms in INSUFFICENT_DATA state
###################################################
#The max that we can get per loop is 100; all alarms for nonexistent instances will be in

Create Amazon EC2 Instance

  • Ensure that inbound MySQL port 3306 is opened
  • chmod 700 "keypair-name.pem"

Install MySQL

To install MySQL, run the following command from a terminal prompt:

  • sudo apt-get install mysql-server
def filter_repeated
if @event['check']['name'] == 'keepalive'
# Keepalives are a special case because they don't emit an interval.
# They emit a heartbeat every 20 seconds per
# http://sensuapp.org/docs/0.12/keepalives
interval = 20
else
interval = @event['check']['interval'].to_i || 0
end
alert_after = @event['check']['alert_after'].to_i || 0

(Note: I wrote this up quickly and without a lot of research, so there are probably inaccuracies. However, I wanted to put this out there in case it helps someone else hitting this issue. Github gists like this unfortunately don't have comment notifications, so if you want me to send me a comment, use my email matt@nanobeep.com and not the comments.)

Problem: Can't use sudo command-limiting in Ansible

The ability to limit sudo users to only be able to execute certain commands doesn't work with Ansible (without a workaround).

This isn't a problem if you're running Ansible as a super-user like root, but if you are allowing others to run Ansible on your systems in order to do things like application deploys, then you need a way to limit their access to the system for basic security.

For example, a line in /etc/sudoers like this:

- name: Register multi-line shell output
shell: blah -f -u -b -a -r
register: license_check
- name: Look for error in output
debug: "This is just used as our needed action"
failed_when: '"Specific error" in item'
with_items: license_check.stdout_lines
@garlandkr
garlandkr / hipchat-test.rb
Created March 31, 2015 15:52
Ruby HipChat Example
require 'hipchat'
hipchat_room = 123456
hipchat_name = 'Bot Name'
msg = 'This is a test'
api_token = '1234567890-=!@#$%^&*()_+'
client = HipChat::Client.new(api_token, :api_version => 'v2')
client[hipchat_room].send(hipchat_name, msg, :color => 'purple')
#/usr/bin/env ruby
# Sends events to hipchat for wonderful chatty notifications
#
# This extension requires the hipchat gem
#
# The reason I wrote this instead of using the normal hipchat handler, is that with Flapjack
# all events are handled unless you do crazy filtering stuff. Also with a large number of events
# and checks the sensu server can get overloaded with forking stuff. So anyway, hipchat extension :)
#