Skip to content

Instantly share code, notes, and snippets.

View scross01's full-sized avatar

Stephen Cross scross01

  • Oracle
  • Ottawa, Canada
View GitHub Profile
@scross01
scross01 / opc-set-shared-network-resolver.sh
Last active May 28, 2017 12:49
Oracle Compute Cloud. Add the nameserver to /etc/resolv.conf for an interface with a private ip on the shared network
# get the IP address for eth0
private_ip=$(/sbin/ifconfig eth0 | grep 'inet ' | awk '{ print $2 }')
# shared network private IPs are in a /30 subnet, nameserver is IP address -1
nameserver=$(echo ${private_ip} | awk -F. '{ sub("."$4,"."$4-1) } 1')
# append to /etc/resolv.conf
sudo sed -i -e "\$anameserver ${nameserver}" /etc/resolv.conf
@scross01
scross01 / config
Created June 20, 2017 17:07
SSH keep-alive options (~/.ssh/config)
Host *
ServerAliveInterval 300
ServerAliveCountMax 2
@scross01
scross01 / config
Created June 20, 2017 20:59
SSH proxy connection through a bastion host (~/.ssh/config)
Host my-private-host
Hostname <PRIVATE_IP>
User opc
IdentityFile ~/.ssh/id_rsa
ProxyCommand ssh -i ~/.ssh/id_rsa opc@<BASTION_IP> -W %h:%p %r
@scross01
scross01 / opc-sec-rule-ssh.tf
Last active August 28, 2017 19:18
Terraform OPC Provider Security Rule to enable ingress SSH from the Public Internet to an Instance with a Public IP on a Shared Network interface
resource "opc_compute_security_list" "enable-ssh" {
name = "Enable-SSH-access"
policy = "DENY"
outbound_cidr_policy = "PERMIT"
}
resource "opc_compute_sec_rule" "allow-ssh" {
name = "Allow-ssh-access"
source_list = "seciplist:/oracle/public/public-internet"
destination_list = "seclist:${opc_compute_security_list.enable-ssh.name}"
@scross01
scross01 / oci-classic-storage.cyberduckprofile
Last active October 30, 2017 19:54
Oracle Cloud Infrastructure Storage Classic Cyberduck Profile
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Protocol</key>
<string>swift</string>
<key>Vendor</key>
<string>oracle</string>
<key>Description</key>
<string>Oracle Cloud Infrastructure - Storage Classic</string>
@scross01
scross01 / oci-linux-instance-remote-exec.tf
Last active September 27, 2022 20:52
Oracle Cloud Infrastructure Instance with Terraform remote-exec Provisioner
resource "oci_core_instance" "example" {
compartment_id = "${var.compartment_ocid}"
availability_domain = "${var.availability_domain}"
subnet_id = "${var.subnet_ocid}"
display_name = "example"
image = "${lookup(data.oci_core_images.image-list.images[0], "id")}"
shape = "VM.Standard1.1"
metadata = {
ssh_authorized_keys = "${file(var.ssh_public_key_file)}"
@scross01
scross01 / oci-linux-instance-cloud-init.tf
Last active April 23, 2023 19:55
Oracle Cloud Infrastructure instance with Terraform cloud-init user_data
data "template_file" "cloud-config" {
template = <<YAML
#cloud-config
runcmd:
- echo 'This instance was provisioned by Terraform.' >> /etc/motd
YAML
}
resource "oci_core_instance" "example" {
count = 1
@scross01
scross01 / example-instance-orchestraion-plan.json
Last active January 5, 2018 15:21
Terraform and Oracle Cloud Infrastructure Classic Orchestrations
{
"name": "/Compute-mydomain/user@example/example-instance-orchestraion",
"description": "Example Instance Orchesrtation",
"desired_state": "active",
"objects":
[
{
"label": "MyInstance",
"type": "Instance",
"description": "My instance",
@scross01
scross01 / example-instance.tf
Last active January 5, 2018 15:23
Terraform and Oracle Cloud Infrastructure Classic Orchestrations - Example 2
resource "opc_compute_instance" "MyInstance" {
name = "vm-1"
shape = "oc3"
boot_order = [ 1 ]
label = "vm-1"
networking_info {
index = 0
shared_network = true
seclists = [ "${opc_compute_security_list.wlsadmin_seclist.name}" ]
resource "opc_compute_ip_network" "ipnet1" {
name = "ipnet1"
ip_address_prefix = "192.168.4.0/24"
}
resource "opc_compute_storage_volume" "boot" {
size = "12"
name = "boot"
bootable = true
image_list = "/oracle/public/OL_7.2_UEKR4_x86_64"