Skip to content

Instantly share code, notes, and snippets.

@amaudy
amaudy / droplet.tf
Created September 4, 2022 04:04
Terraform code for create DigitalOcean Droplet
resource "digitalocean_droplet" "devbox" {
image = var.image
name = var.name
region = var.region
size = var.size
tags = var.tags
ssh_keys = [
data.digitalocean_ssh_key.terraform.id
]
@amaudy
amaudy / firewall.tf
Last active September 4, 2022 04:05
Firewall rule
data "http" "myip" {
url = "http://ipv4.icanhazip.com"
}
resource "digitalocean_firewall" "devbox" {
name = "demo-devbox-firewall"
droplet_ids = [digitalocean_droplet.devbox.id]
inbound_rule {
@amaudy
amaudy / terraform.tfvars
Created September 3, 2022 14:03
Configuration file for Terraform
do_token = "xxx"
do_private_key = "terraform-devbox"
image = "ubuntu-22-04-x64"
name = "demo-devbox"
region = "sgp1"
size = "s-2vcpu-4gb"
tags = ["devbox", "demo"]
@amaudy
amaudy / provider.tf
Created September 3, 2022 14:01
Terraform provider file.
terraform {
required_providers {
digitalocean = {
source = "digitalocean/digitalocean"
version = "2.12.0"
}
}
}
provider "digitalocean" {
resource "digitalocean_droplet" "web" {
image = "ubuntu-22-04-x64"
name = "devbox"
region = "sgp1"
size = "s-2vcpu-4gb"
tags = ["devbox"]
lifecycle {
prevent_destroy = false
}
@amaudy
amaudy / packer.json
Created April 10, 2021 06:19
Packer file for create AMI and provisioning server bu Ansible playbook
{
"variables": {
"aws_access_key": "ACCESSKEY",
"aws_secret_key": "SECRETKEY",
"aws_subnet_id": "SUBNETID"
},
"builders": [
{
"type": "amazon-ebs",
"access_key": "{{user `aws_access_key`}}",
root@minion:~# apt-get -q -y -o DPkg::Options::=--force-confold -o DPkg::Options::=--force-confdef install ksm-control-daemon
Reading package lists...
Building dependency tree...
Reading state information...
The following packages were automatically installed and are no longer required:
libuuid-perl linux-base
Use 'apt-get autoremove' to remove them.
The following NEW packages will be installed:
ksm-control-daemon
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
postgresql-9.4 (9.4.18-0+deb8u1) jessie; urgency=medium
Some functions were incorrectly not marked as VOLATILE. If you are using any
of these functions, consult the release notes for instructions.
query_to_xml cursor_to_xml cursor_to_xmlschema query_to_xmlschema
query_to_xml_and_xmlschema
-- Christoph Berg <myon@debian.org> Tue, 08 May 2018 20:37:04 +0200
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 localhost
127.0.0.1 localunixsocket
@amaudy
amaudy / sendemail.py
Last active April 12, 2016 02:56
simple python script send email via smtp with user/pass
from smtplib import SMTP
import datetime
debuglevel = 0
smtp = SMTP()
smtp.set_debuglevel(debuglevel)
smtp.connect('YOUR.MAIL.SERVER', 26)
smtp.login('USERNAME@DOMAIN', 'PASSWORD')