Tuesday, June 11, 2024

Get remote openssl Certificate Information

$ openssl s_client -showcerts -servername example.com -connect example.com:443 </dev/null | openssl x509 -noout -dates -in -

...

notBefore=Feb 22 18:00:59 2024 GMT

notAfter=Feb 21 18:00:59 2026 GMT

Monday, June 10, 2024

Monday, December 04, 2023

Running `go` From a Docker Container

 I followed instructions I found here: https://hub.docker.com/_/golang

% cat Dockerfile

FROM golang:1.21
WORKDIR /usr/src/app
# pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change
COPY go.mod go.sum ./
RUN go mod download && go mod verify
COPY . .
RUN go build -v -o /usr/local/bin/app ./...
CMD ["app"]

You can use it like this ...

% cat hello.go
package main
import ("fmt")

func main() {
  fmt.Println("Hello World!")
}

% docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp golang:1.21 go build /usr/src/myapp/hello.go

% docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp golang:1.21 /usr/src/myapp/hello
Hello World!


Saturday, August 12, 2023

Ansible Unit Test Molecule Invert Failure into Success

 This is the use case where you are expecting a task to fail during the unit test.  There are cases where you would want to test for this.  Use your imagination. 


Anyways add this to the end of your molecule/*/converge.yml file:

---
- name: Converge
  hosts: all
  vars:

    ... omitted ...

    task_that_should_fail: 'Check if web server returns 200 on localhost'
  tasks:

    ... omitted ...

    - name: Role Should Fail In This Test
      block:
        - name: Include my_role
          ansible.builtin.include_role:
            name: "my_role"
          ignore_errors: true

        - name: Passed is Fail
          fail:
            msg: "Role my_role unexpectedly successed!"

      rescue:
        - name: Failed is Pass
          debug:
            msg: "Role my_role failed when it should have!"
          when:
            - ansible_failed_task.name == task_that_should_fail

        - name: Passed is Fail
          fail:
            msg: "Role my_role unexpectedly succeed!"
          when:
            - not ansible_failed_task.name == task_that_should_fail

Wednesday, August 02, 2023

How to Add the Current Time to the Results of Your MySQL Select Statements

 MariaDB [xx_config]> select *, NOW() from servers where id = 'Fakeuuid-kinda'; 
| ID              |  VERSION |  NOW()    
| Thing One | Thing Two  | 2023-08-03 02:57:44 

Tuesday, August 01, 2023

What Data Directory is MariaDB 10.6 using?

 Run this SQL query ...

root@xoubdmz1:~ # mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 587
Server version: 10.6.14-MariaDB-1:10.6.14+maria~ubu2204-log mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show variables like 'datadir';
+---------------+-----------------+
| Variable_name | Value           |
+---------------+-----------------+
| datadir       | /var/lib/mysql/ |
+---------------+-----------------+
1 row in set (0.001 sec)

MariaDB [(none)]>