Skip to content

Instantly share code, notes, and snippets.

@rgl
rgl / windows-drivers.md
Created November 25, 2019 10:59
Install windows drivers

Example of how to install a inf file:

NB You can also use the dism module cmdlets (e.g. Add-WindowsDriver).

function Install-Driver($path) {
    # trust the driver certificate.
    $catPath = $path.Replace('.inf', '.cat')
    $cerPath = $path.Replace('.inf', '.cer')
    $certificate = (Get-AuthenticodeSignature $catPath).SignerCertificate
@rgl
rgl / ansible.md
Last active January 19, 2020 21:25
Ansible Notes

Quick start:

cat >inventory.yml <<'EOF'
all:
  children:
    idrac:
      hosts:
        esxi[1:3]-idrac.example:
 # you can also override a specific host properties:
@rgl
rgl / python-embedded.md
Last active March 18, 2024 15:33
notes about python embedded in windows

The gist is:

  1. install the normal python from python.org
  2. install everything into a venv
  3. copy the venv into python embed.

A raw example

unzip python-3.8.0-embed-amd64.zip
INFO winrm: WinRM is ready!
DEBUG guest: Searching for cap: reboot
DEBUG guest: Checking in: windows
DEBUG guest: Found cap: reboot in windows
INFO guest: Execute capability: reboot [#<Vagrant::Machine: default (VagrantPlugins::ProviderLibvirt::Provider)>] (windows)
DEBUG winrmshell: [WinRM] opening remote shell on http://192.168.121.157:5985/wsman
DEBUG winrmshell: [WinRM] Endpoint doesn't support config request for MaxEnvelopsizekb
DEBUG winrmshell: [WinRM] Waiting for output...
DEBUG winrmshell: [WinRM] Processing output
DEBUG winrmshell: [WinRM] polling for pipeline state. message: #<WinRM::PSRP::Message:0x00007fa9a09197a8 @data="\xEF\xBB\xBF<Obj RefId=\"0\"><MS><Version N=\"protocolversion\">2.3</Version><Version N=\"PSVersion\">2.0</Version><Version N=\"SerializationVersion\">1.1.0.1</Version></MS></Obj>", @destination=1, @type=65538, @pipeline_id="00000000-0000-0000-0000-000000000000", @runspace_pool_id="00000000-0000-0000-0000-000000000000">
@rgl
rgl / error.md
Last active July 17, 2019 21:41
k3s-server fails to start with --disable-agent

Errors while installing k3s with --disable-agent.

I'm using my rgl/k3s-vagrant environment to try this out. I've used the following command to start the vagrant environment:

vagrant up --provider=libvirt s1 # see https://github.com/rgl/k3s-vagrant/blob/master/provision-k3s-server.sh

which will eventually install k3s and error out:

@rgl
rgl / installer-syslog.txt
Created July 9, 2019 16:52
I'm trying to use https://github.com/rgl/debian-vagrant to create a buster vagrant box, but on virtualbox it fails with https://pasteboard.co/ImUOUzF.png ... any idea why? after I click Continue it works fine. It also works fine when I use libvirt instead of virtualbox.
This file has been truncated, but you can view the full file.
Jul 7 19:26:43 syslogd started: BusyBox v1.30.1
Jul 7 19:26:43 kernel: klogd started: BusyBox v1.30.1 (Debian 1:1.30.1-4)
Jul 7 19:26:43 kernel: [ 0.000000] Linux version 4.19.0-5-amd64 (debian-kernel@lists.debian.org) (gcc version 8.3.0 (Debian 8.3.0-7)) #1 SMP Debian 4.19.37-5 (2019-06-19)
Jul 7 19:26:43 kernel: [ 0.000000] Command line: BOOT_IMAGE=/install.amd/vmlinuz initrd=/install.amd/initrd.gz auto=true url=10.0.2.2:8616/preseed.txt hostname=vagrant domain=home net.ifnames=0 BOOT_DEBUG=2 DEBCONF_DEBUG=5
Jul 7 19:26:43 kernel: [ 0.000000] x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers'
Jul 7 19:26:43 kernel: [ 0.000000] x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers'
Jul 7 19:26:43 kernel: [ 0.000000] x86/fpu: Supporting XSAVE feature 0x004: 'AVX registers'
Jul 7 19:26:43 kernel: [ 0.000000] x86/fpu: xstate_offset[2]: 576, xstate_sizes[2]: 256
Jul 7 19:26:43 kernel: [ 0.000000] x86/fpu: Enabled xstate features 0x7, context size is 832 byte
@rgl
rgl / deb-tree-graph.sh
Last active June 3, 2019 20:10
debian package tree graph
# XXX failed attempt at getting a single graph with all the package dependencies...
mkdir tmp
cd tmp
for pkg in `grep-status --not --field=Package --eq '' --show-field=Package -n`; do
debtree --show-installed "$pkg" >"$pkg.dot"
done
cat *.dot | grep -v digraph | grep -v '}'| (echo 'strict digraph "root" {';cat;echo '}') | dot | neato -n2 -Tpng -o example.png
@rgl
rgl / try-vagrant-triggers-experimental.rb
Created May 27, 2019 21:50
an example on how to see which vagrant triggers exist
# NB before running this you need to export an environment variable: export VAGRANT_EXPERIMENTAL='typed_triggers'
# see https://www.vagrantup.com/docs/triggers/configuration.html#trigger-types
# NB to see all triggers you need to edit your vagrant source code:
# sudo vim /opt/vagrant/embedded/gems/2.2.4/gems/vagrant-2.2.4/lib/vagrant/plugin/v2/trigger.rb
# and add a @ui.info to see all trigger action stages, et all:
# NB see https://github.com/hashicorp/vagrant/blob/v2.2.4/lib/vagrant/plugin/v2/trigger.rb
# # Fires all triggers, if any are defined for the action and guest. Returns early
# # and logs a warning if the community plugin `vagrant-triggers` is installed
# #
# # @param [Symbol] action Vagrant command to fire trigger on
@rgl
rgl / docker-build-log.txt
Created January 14, 2019 23:21
swtpm build failure
rgl@rgl-desktop:~/Projects/swtpm$ docker build -t build-swtpm-ubuntu-18.04 -f Dockerfile.ubuntu-18.04 .
Sending build context to Docker daemon 3.927MB
Step 1/9 : FROM ubuntu:18.04
---> 1d9c17228a9e
Step 2/9 : RUN apt-get -y update && apt-get -y install build-essential fakeroot devscripts equivs
---> Using cache
---> 3702a1c0519d
Step 3/9 : ENV DEBIAN_FRONTEND noninteractive
---> Running in 97d7d40c7e1a
Removing intermediate container 97d7d40c7e1a
@rgl
rgl / Start-WrappedProcess.ps1
Created January 6, 2018 08:20
Run a process and capture its stdout and stderr to a file
# converts/escapes a string to a command line argument.
function ConvertTo-CommandLineArgument {
# Normally, an Windows application (.NET applications too) parses
# their command line using the CommandLineToArgvW function. Which has
# some peculiar rules.
# See http://msdn.microsoft.com/en-us/library/bb776391(VS.85).aspx
#
# TODO how about backslashes? there seems to be a weird interaction
# between backslahses and double quotes...
process {