June 17, 2022

RHEL 9.0 How to Disable BAD PASSWORD: The password fails the dictionary check - it is based on a dictionary word

NEVER USE THIS IN A NOT TEST/DEVELOPMENT ENVIRONMENT

$ sudo passwd student
Changing password for user student.
New password: 
BAD PASSWORD: The password fails the dictionary check - it is based on a dictionary word

You need to change 2 lines.

$ sudo vim /etc/pam.d/system-auth
...
# password    requisite     pam_pwquality.so try_first_pass local_users_only retry=3 authtok_type=
password    sufficient    pam_unix.so try_first_pass nullok sha512 shadow

Here is the diff

$ sudo diff /etc/pam.d/system-auth /etc/pam.d/system-auth.ORIG 
10,11c10,11
< # password    requisite     pam_pwquality.so try_first_pass local_users_only retry=3 authtok_type=
< password    sufficient    pam_unix.so try_first_pass nullok sha512 shadow
---
> password    requisite     pam_pwquality.so try_first_pass local_users_only retry=3 authtok_type=
> password    sufficient    pam_unix.so try_first_pass use_authtok nullok sha512 shadow

Now you can set weak password for users.

RHEL 9.0 How to Change the Tab Size in VIM

$ sudo dnf install vim-enhanced bash-completion -y
$ sudo vim /etc/vimrc
...
set tabstop=2
set shiftwidth=2
set expandtab

Set default editor to vim.

$ sudo vim /etc/profile
...
EDITOR=vim

After installing bash completion you need to login out and then login before completion takes affect.

https://stackoverflow.com/questions/2054627/how-do-i-change-tab-size-in-vim

May 26, 2022

Getting Started with Red Hat OpenShift Local (formerly Red Hat CodeReady Containers, CRC)

2.3. Installing CRC- https://crc.dev/crc/#installing_gsg

After download have 2 files:

  • /home/magnuskkarlsson/Downloads/crc-linux-amd64.tar.xz
  • /home/magnuskkarlsson/Downloads/pull-secret
$ cd ~/Downloads
$ tar xvf crc-linux-amd64.tar.xz
$ mkdir -p ~/bin
$ cp ~/Downloads/crc-linux-*-amd64/crc ~/bin
$ crc version
CRC version: 2.3.0+dab5e0d
OpenShift version: 4.10.12
Podman version: 3.4.4

2.6. Upgrading CRC - https://crc.dev/crc/#upgrading_gsg

3.2. Setting up CRC

$ crc setup
$ crc start --pull-secret-file ~/Downloads/pull-secret
...
Started the OpenShift cluster.

The server is accessible via web console at:
  https://console-openshift-console.apps-crc.testing

Log in as administrator:
  Username: kubeadmin
  Password: ggNNE-tdBvf-Se8j5-yT8nF

Log in as user:
  Username: developer
  Password: developer

Use the 'oc' command line interface:
  $ eval $(crc oc-env)
  $ oc login -u developer https://api.crc.testing:6443

Testing

$ eval $(crc oc-env)

$ oc login -u developer https://api.crc.testing:6443

$ oc completion -h
...
  # Installing bash completion on Linux
  ## If bash-completion is not installed on Linux, install the 'bash-completion' package
  ## via your distribution's package manager.
  ## Load the oc completion code for bash into the current shell
  source <(oc completion bash)
...
$ source <(oc completion bash)

$ crc console --credentials
To login as a regular user, run 'oc login -u developer -p developer https://api.crc.testing:6443'.
To login as an admin, run 'oc login -u kubeadmin -p ggNNE-tdBvf-Se8j5-yT8nF https://api.crc.testing:6443'

$ oc get clusterversions
NAME      VERSION   AVAILABLE   PROGRESSING   SINCE   STATUS
version   4.10.12   True        False         18d     Cluster version is 4.10.12

$ oc get nodes
NAME                 STATUS   ROLES           AGE   VERSION
crc-xhphl-master-0   Ready    master,worker   19d   v1.23.5+70fb84c

$ crc console --url
https://console-openshift-console.apps-crc.testing

Other resources:

https://github.com/code-ready/crc

June 1, 2021

MicroProfile OpenAPI on Wildfly 23 and JBoss EAP 7.3.x

Introduction

In my last blog I showed a simple example app annotated with Eclipse MicroProfile OpenAPI Annotation. See https://magnus-k-karlsson.blogspot.com/2021/05/auto-generate-openapiswagger.html

Here will deploy it on Wildfly and call OpenAPI.

Wildfly 23.0.2.Final

On Wildfly is Eclipse MicroProfile already installed and all you need is to start it with the correct configuration.

$ ./standalone.sh -c standalone-microprofile.xml

And then call it

$ curl http://localhost:8080/openapi
---
openapi: 3.0.3
info:
  title: example-openapi-swagger.war
  version: "1.0"
servers:
- url: /example-openapi-swagger
paths:
  /api/persons:
    get:
      summary: Get all persons.
      description: Get all persons in DB.
      parameters:
      - name: name
        in: query
        description: The name to search for.
        required: false
        schema:
          type: string
        example: '*he*'
      responses:
        "500":
          description: Internal Error
          content:
            application/json: {}
        "200":
          description: All persons in DB.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Person'
components:
  schemas:
    Person:
      type: object
      properties:
        age:
          format: int32
          type: integer
        name:
          type: string

And to get JSON instead.

$ curl http://localhost:8080/openapi?format=JSON  
{
  "openapi" : "3.0.3",
  "info" : {
    "title" : "example-openapi-swagger.war",
    "version" : "1.0"
  },
  "servers" : [ {
    "url" : "/example-openapi-swagger"
  } ],
  "paths" : {
    "/api/persons" : {
      "get" : {
        "summary" : "Get all persons.",
        "description" : "Get all persons in DB.",
        "parameters" : [ {
          "name" : "name",
          "in" : "query",
          "description" : "The name to search for.",
          "required" : false,
          "schema" : {
            "type" : "string"
          },
          "example" : "*he*"
        } ],
        "responses" : {
          "500" : {
            "description" : "Internal Error",
            "content" : {
              "application/json" : { }
            }
          },
          "200" : {
            "description" : "All persons in DB.",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/Person"
                }
              }
            }
          }
        }
      }
    }
  },
  "components" : {
    "schemas" : {
      "Person" : {
        "type" : "object",
        "properties" : {
          "age" : {
            "format" : "int32",
            "type" : "integer"
          },
          "name" : {
            "type" : "string"
          }
        }
      }
    }
  }
}

JBoss EAP 7.3

The JBoss EAP does not come bundled with OpenAPI and you need to install JBOSS EAP XP 2.0.0. See https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.3/pdf/using_eclipse_microprofile_with_jboss_eap_xp_2.0.0/Red_Hat_JBoss_Enterprise_Application_Platform-7.3-Using_Eclipse_MicroProfile_with_JBoss_EAP_XP_2.0.0-en-US.pdf