Skip to content

Instantly share code, notes, and snippets.

View stefanozanella's full-sized avatar

Stefano Zanella stefanozanella

View GitHub Profile
@stefanozanella
stefanozanella / description.md
Created December 1, 2012 02:01
Puppet implementation patterns: Safe Default

Safe Default

When

You have a defined type and want to use a default value for a parameter from a params class.

How

Set the default value of the variable as undef, then put a conditional after including the params class in the class body in which you set another internal variable with the value of the params class variable or the user-defined value.

@stefanozanella
stefanozanella / description.md
Created December 2, 2012 20:30
Puppet implementation patterns: Test with External Function

Test with External Function

When

You want to test a resource definition (class, defined type) that uses a function provided by a third-party module your module depends upon. It's supposed that you're implementing your tests with rspec-puppet.

How

@stefanozanella
stefanozanella / enable_serial_console.sh
Created January 16, 2013 18:26
Enable serial console output in CentOS (useful for OpenStack + KVM)
echo "ttyS0" > /etc/securetty
vi /etc/grub.conf
# Add console=ttyS0 to the end of kernel line(s)
vi /etc/sysconfig/init
# Edit ACTIVE_CONSOLES to look like:
ACTIVE_CONSOLES="/dev/tty[1-6] /dev/ttyS0"
# If on a live system, do the following
@stefanozanella
stefanozanella / description.sh
Created January 22, 2013 23:05
Debug Git HTTPS issues
export GIT_CURL_VERBOSE=1
git clone https://review.derecom.it/example.git
* Couldn't find host review.derecom.it in the .netrc file; using defaults
* About to connect() to review.derecom.it port 443 (#0)
* Trying 172.16.32.248... * Connected to review.derecom.it (172.16.32.248) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
* CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
* Peer's certificate issuer is not recognized: 'CN=Derecom Authentication CA,OU=PKI,O=Derecom srl,L=Padova,ST=Veneto,C=IT'
* NSS error -8179
@stefanozanella
stefanozanella / tip.md
Created November 27, 2013 12:57
How to improve UX during kickstart installations with long `%post` sections

From here

%post
# change to new vt and set stout/stdin
exec < /dev/tty6 > /dev/tty6
chvt 6
# run post-install

# write/call scripts here
@stefanozanella
stefanozanella / procedure.md
Last active October 31, 2019 11:54
Create Ubuntu server image for OpenStack

The procedure below is done on a CentOS 6.3 x86_64 hypervisor

  1. Create qcow image:
qemu-img create -f qcow2 ubuntu-12.10-server-amd64.img 5G
  1. Download Ubuntu server ISO:
wget "http://www.ubuntu.com/start-download?distro=server&bits=64&release=latest"
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.springframework.boot") version "2.4.1"
id("io.spring.dependency-management") version "1.0.10.RELEASE"
kotlin("jvm") version "1.4.21"
kotlin("plugin.spring") version "1.4.21"
kotlin("plugin.serialization") version "1.4.21" // <-- (1)
idea
}
package me.stefanozanella.sampleapp
import java.time.LocalDate
data class StockPurchase(
val ticker: String = "",
val purchaseDate: LocalDate = LocalDate.now(),
)
package me.stefanozanella.sampleapp
import com.sksamuel.avro4k.serializer.LocalDateSerializer
import kotlinx.serialization.Serializable
import java.time.LocalDate
@Serializable
data class StockPurchase(
val ticker: String = "",
@Serializable(with = LocalDateSerializer::class) val purchaseDate: LocalDate = LocalDate.now(),
package me.stefanozanella.sampleapp
import org.springframework.stereotype.Controller
import org.springframework.ui.Model
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.ModelAttribute
import org.springframework.web.bind.annotation.PostMapping
@Controller
class StockPurchaseController {