Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Starr-Bochicchio andrewsomething

View GitHub Profile
@andrewsomething
andrewsomething / assign-ip.py
Last active Oct 16, 2020
Assign a DigitalOcean Floating IP to a Droplet
View assign-ip.py
#!/usr/bin/python
import os
import sys
import requests
import json
api_base = 'https://api.digitalocean.com/v2'
@andrewsomething
andrewsomething / handlers.yml
Last active Sep 15, 2020
My "first five minutes" on a server
View handlers.yml
---
- name: Restart sshd
service:
name: ssh
state: restarted
become: yes
@andrewsomething
andrewsomething / hacktoberfest-label.py
Last active Sep 8, 2020
This script will add the "hacktoberfest" label to any issue that also has one of the following labels applied: 'help wanted', 'first-timers-only', 'up-for-grabs'
View hacktoberfest-label.py
#!/usr/bin/env python3
import os
import sys
import requests
import json
LABELS = ['help wanted', 'help-wanted', 'first-timers-only', 'up-for-grabs',
'good first issue']
API_BASE = 'https://api.github.com/'
@andrewsomething
andrewsomething / snapshot.rb
Created Feb 26, 2015
Power off and Snapshot a DigitalOcean Droplet
View snapshot.rb
#!/usr/bin/env ruby
require 'droplet_kit'
require 'json'
token = ENV['DO_TOKEN']
client = DropletKit::Client.new(access_token: token)
droplet_id = ARGV[0]
snapshot_name = ARGV[1] || Time.now.strftime("%b. %d, %Y - %H:%M:%S %Z")
@andrewsomething
andrewsomething / cloud_init_runcmd.py
Last active Aug 22, 2019
This script takes a cloud-config file as input and returns the 'shellified' script that would be produced by cloudinit from the runcmd stanza.
View cloud_init_runcmd.py
#!/usr/bin/python
"""
This script take a cloud-config file as input and returns the 'shellified'
script that would be produced by cloudinit from the runcmd stanza.
https://github.com/number5/cloud-init/blob/74e61ab27addbfcceac4eba254f739ef9964b0ed/cloudinit/config/cc_runcmd.py
https://github.com/number5/cloud-init/blob/74e61ab27addbfcceac4eba254f739ef9964b0ed/cloudinit/util.py#L1708
"""
@andrewsomething
andrewsomething / main.go
Last active Mar 15, 2019
Report download statistics for GitHub release assets
View main.go
package main
import (
"context"
"encoding/json"
"flag"
"fmt"
"os"
"strings"
"text/tabwriter"
@andrewsomething
andrewsomething / BACKUP.md
Last active Dec 21, 2018
Backup GitLab to DigitalOcean Spaces
View BACKUP.md

Backup GitLab to DigitalOcean Spaces

GitLab uses Fog to communicate with various object storage services when running backups. Fog works with S3 as well as S3-compatible services like Spaces. The key difference is that you need to explictly set the endpoint for non-S3 services. If you are using the "ominbus" GitLab packages, you would need to add the following to /etc/gitlab/gitlab.rb:

gitlab_rails['backup_upload_connection'] = {
@andrewsomething
andrewsomething / main.tf
Last active Dec 12, 2018
Terraform + DigitalOcean Kubernetes = <3
View main.tf
provider "digitalocean" {}
// Create a cluster on DigitalOcean
resource "digitalocean_kubernetes_cluster" "example" {
name = "example"
region = "nyc1"
version = "1.12.3-do.1"
node_pool {
name = "wokers"
View tf.diff
diff --git a/digitalocean/config.go b/digitalocean/config.go
index 96f6785..bc38c31 100644
--- a/digitalocean/config.go
+++ b/digitalocean/config.go
@@ -12,33 +12,63 @@ import (
"github.com/hashicorp/terraform/helper/logging"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
+ "github.com/minio/minio-go"
"golang.org/x/oauth2"
@andrewsomething
andrewsomething / get_snapshots.go
Created Nov 18, 2016
List DigitalOcean snapshots using godo
View get_snapshots.go
package main
import "os"
import "fmt"
import "golang.org/x/oauth2"
import "github.com/digitalocean/godo"
type TokenSource struct {
AccessToken string
}
You can’t perform that action at this time.