Posted
Filed under Computer
* In Ubuntu 20.04
Install packer
~$ wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
~$ echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
~$ sudo apt update && sudo apt install packer
~$ packer --version
1.8.3
Install RHEL8 template dependencies
~$ sudo apt install qemu-utils
~$ sudo apt install qemu-system
Get packer templates
Change to centos8-stream template
~$ cd packer-maas/centos8-stream
if you want change KS filethen  modify http/centos8-stream.ks file.
packer-maas/centos8-stream$ ls http/
centos8-stream.ks
Build the CentOS 8 stream image from ISO file.
packer-maas/centos8-stream$ make ISO=/global/iso/CentOS-Stream-8-x86_64-20220728-dvd1.iso
created centos8-stream.tar.gz file.
packer-maas/centos8-stream$ ls
centos8-stream.json centos8-stream.tar.gz http Makefile output-qemu README.md
Copy the image file to MAAS server.
packer-maas/ centos8-stream$ scp centos8-stream.tar.gz user@maas-server:
* In maas-server
(https://ubuntu.com/blog/cli-only-maas-operation)
Need MAAS API-KEY-FILE
~$ cat api-key-file
xlfU9XtKzmaJMAa3w7:Gq6fZxzZ6g9HsQAeKW:NGJ5qAtJrF929TU8cKCdUUqtqzwGjBbw3
Login to admin in MAAS
~$  maas login admin http://maas-server:5240/MAAS
API key (leave empty for anonymous access):
You are now logged in to the MAAS server at
http://maas-server:5240/MAAS/api/2.0/ with the profile name 'admin'.
For help with the available commands, try:
  maas admin --help
check boot resource
~$ maas admin boot-resources read
Import the image to MAAS in maas-server
*Not support Rocky OS, CentOS 8.3
~$ maas admin boot-resources create name=centos/8-stream title='CentOS8-stream' architecture='amd64/generic' filetype='tgz' content@= centos8-stream.tar.gz
Verify custom image
~$ maas admin boot-resources read
....
{
"id": 13,
"type": "Uploaded",
"name": "centos/8-stream",
"architecture": "amd64/generic",
"resource_uri": "/MAAS/api/2.0/boot-resources/13/",
"subarches": "generic",
"title": "CentOS8-stream"
}
]
Deploy the CentOS Image
goto "Setting" and select "Deploy" under "Configuration".
Select Deployment OS to "CentOS" and release to "CentOS8-stream"

User image

and deploy a machine then the server will start with Ubuntu image. but at the last procedure, the deploy OS with my selected OS (CentOS8-stream).
Login to compute node:
maas-server$ ssh centos@192.168.150.50
[centos@cent-test-host ~]$ cat /etc/redhat-release
CentOS Stream release 8
Default user without password:
CentOS -> centos
Ubuntu -> ubuntu
Setting Password-less SSH-key in MAAS
goto "admin" -> SSH keys -> "import SSH key"
then the default user will defined with this SSH key. So you can login to server with default username with imported SSH key.

Good works OS:
centos 7
centos 8-stream
2022/08/04 07:27 2022/08/04 07:27
[로그인][오픈아이디란?]
Posted
Filed under Computer/package
Universial Package Manager snap testing

1. Install snap package
2. Install snapcraft (package builder)
$ sudo snap install snapcraft --classic

3. Simple Python script packaging
$ mkdir ~/work
- make a package(test-app) directory
$ mkdir ~/work/test-app

4. make a python script package
$ mkdir ~/work/test-app/myapp
$ mkdir ~/work/test-app/myapp/lib
$ vi ~/work/test-app/myapp/lib/TM.py
------------------------------------------------------------
from datetime import datetime
def now():
    return datetime.now().strftime('%s')
------------------------------------------------------------
$ touch ~/work/test-app/myapp/lib/__init__.py
$ vi ~/work/test-app/myapp/test_run
------------------------------------------------------------
#!/usr/bin/env python3
from lib import TM
def main():
    print('Hello, I am main()')
    aa=TM.now()
    input("now second is:{}".format(aa))
if __name__ == '__main__':
    main()
------------------------------------------------------------

5. make a snap configuration
$ mkdir ~/work/test-app/snap
$ vi ~/work/test-app/snap/snapcraft.yaml
------------------------------------------------------------
name:           test-app # package name
version:        '1.1'        # package version
summary:        Example python snap app
description: |
    Example python snap app description
base: core20      # Common Base OS ( 18: ubuntu 18.04, 20: ubuntu 20.04, 22: ubuntu 22.04 )
grade:          stable
confinement:    devmode
apps:
  test-app:  #Package name
    command:    myapp/test_run  #running command path and filename (/snap/bin/<package name> will running the command line path file)
    ## If need special path for shell script
    #command: sh $SNAP/opt/foo/bin/foo.sh
parts:
  test-app:
    source: . #my local directory is source
    ## When copy a file(shell/python/built binary file) to somewhere
    plugin:     dump 
    organize:
          src/myapp: .     # start with "src/" and my files are in the src directory. (copy the myapp directory)
    ## When use python setup.py to install application then use python plugin
    #plugin:     python
    #python-version: python3
------------------------------------------------------------

6. build 
$ cd ~/work/test-app
$ snapcraft

7. Install
$ snap install test-app_1.1_amd64.snap --devmode

8. check 
$ snap list |grep test-app
test-app             1.1                         x1     -                -            devmode
$ df -h
~~~
/dev/loop3                 128K  128K     0 100% /snap/test-app/x1
$ ls -l /snap/bin/test-app 
lrwxrwxrwx 1 root root 13 Aug  1 14:18 /snap/bin/test-app -> /usr/bin/snap
$ /snap/bin/test-app 
Hello, I am main()
now second is:1659388777

ETC & Tools)
$ cat cleanup_multipath_snapcraft_built_garbage.sh 
-------------------------------------------------------------------------------------------------------------
#!/bin/bash -x
## snapcraft-created multipass VMs
for vm in $(multipass list | awk '{print $1}' | grep "^snapcraft-"); do
    multipass delete $vm --purge
done
## snapcraft-created LXD containers
#for c in $(lxc list | awk '{print $2}' | grep "^snapcraft-" | grep -v "snapcraft-dev"); do
#    lxc delete $c --force
#done
-------------------------------------------------------------------------------------------------------------

$ cat remove_disabled_snap.sh 
-------------------------------------------------------------------------------------------------------------
#!/bin/bash
set -eu
LANG=en_US.UTF-8 snap list --all | awk '/disabled/{print $1, $3}' |
    while read snapname revision; do
        snap remove "$snapname" --revision="$revision"
    done
-------------------------------------------------------------------------------------------------------------

Remove Package
$ snap remove <package name>
other commands: https://www.cyberithub.com/36-popular-snap-command-examples-in-linux/


Few other snap configuration files example:
a) automatically use bin directory in local directory (Some updated code)
    original : https://github.com/gocarlos/python-ubuntu-snap-app-example
$ ls                    
bin  LICENSE  myapp_module  mygreatapp_1.0_amd64.snap  README.md  requirements.txt  snap
$ cat requirements.txt 
numpy
$ cat bin/my_great_app 
#!/usr/bin/env python3
from myapp_module import my_great_app
"""
    my application.
"""
def main():
    """run the application"""
    print('I\'m inside main')
    my_great_app.tata()
    input("Press enter to exit ;)")
    input()
if __name__ == '__main__':
    main()
$ ls myapp_module/
__init__.py  my_great_app.py
$ cat myapp_module/my_great_app.py 
#!/usr/bin/env python3
def tata():
    print ('you could do great stuff inside this function.')
    
def fun(x):
    return x + 1
$ cat snap/snapcraft.yaml 
name:           mygreatapp
version:        '1.0'
summary:        Example python snap app
description: |
    Example python snap app
base: core18
grade:          stable
confinement:    devmode
apps:
  mygreatapp:
    command:    my_great_app
parts:
  mygreatapp:
    plugin:     python
    python-version: python3
    source: .

b)  Automatically build and package from remote source file.
$ cat snap/snapcraft.yaml 
name: hello
base: core18
version: '2.10'
summary: GNU Hello, the "hello world" snap
description: |
  GNU hello prints a friendly greeting.
grade: devel
confinement: devmode
parts:
  gnu-hello:
    source: http://ftp.gnu.org/gnu/hello/hello-2.10.tar.gz
    plugin: autotools
2022/08/02 06:32 2022/08/02 06:32
[로그인][오픈아이디란?]
Posted
Filed under Computer
1. Create Node:
openstack baremetal node create  \
    --name <HOST NAME> \
    --driver redfish \
    --driver-info redfish_address=<BMC IP> \
    --driver-info redfish_system_id=/redfish/v1/Systems/1 \
    --driver-info redfish_username=<USER NAME> \
    --driver-info redfish_password=<PASSWORD>

2. Setup Properties
    2.1 Set Redfish Verify CA to False
        openstack baremetal set <NODE_UUID> \
            --driver-info redfish_verify_ca="False"

    2.2 Set boot mode to UEFI:
        penstack baremetal node set <NODE_UUID> \
             --property capabilities='boot_mode:uefi'

    2.3 Set Ramdisk and Kernel :
        openstack baremetal node set <NODE_UUID> \
            --driver-info deploy_ramdisk=<RAMDISK IMAGE UUID> \
            --driver-info deploy_kernel=<KERNEL IMAGE UUID>

    2.4 Set OS Image:
        openstack baremetal node set <NODE_UUID> \
            --instance-info image_source=<Deploy OS Image UUID> \
            --instance-info root_gb=SIZE  (optional)

    2.5 Set other Optional properties

3. Setup Network Port
    3.1 Create PXE Port(IRONIC PORT):
        openstack baremetal port create  \
            --node <NODE_UUID> \
            <MAC of CHASSIS/Baremetal NODE NIC>
    3.2 Create Network port (NEUTRON PORT)
        openstack port create  \
            --mac-address <MAC of CHASSIS/Baremetal NODE NIC> \
            --network  <NETWORK UUID>
            <PORT NAME:<HOST NAME>vif>
    3.3 Associate the neutron port(VIFport) to the ironic port:
        openstack baremetal port set <IRONIC_PORT_UUID>  \
            --extra vif_port_id=<NEUTRON_PORT_UUID(above command)>
    3.4 Attache VIF to the baremetal node
        openstack baremetal node vif attach  \
            --port-uuid <IRONIC_PORT> \
            <NODE_UUID> \
            <NEUTRON_PORT_UUID>


4. Change to manageable from enrolling
openstack baremetal node manage <NODE_UUID>


5. Provide
openstack baremetal node provide <NODE_UUID>
    - PXE BOOT
    - check network
    - Run AGENT in <Deploy RAMDISK>
        - Agent heartbeat
        - Agent check disk (not support SATADOM)
        - Agent format disk (required format command)
    - turn off system


6. Deploy
openstack baremetal node deploy <NODE_UUID>
    - check VIF 
    - PXE BOOT with <Deploy RAMDISK>
    - Deploy <Deploy_OS_Image> to Local Root Disk
    - Turn off
    - statue to active
    - BOOT LOCAL DISK
    - Using Same <Deploy_OS_Image> in Local Root DISK


( If you use "boot_mode:local" then use "adopt" command instead deploy. )
2022/07/02 07:02 2022/07/02 07:02
[로그인][오픈아이디란?]
Posted
Filed under Computer/Linux
Backup your important data

Clone rocky-tools
# git clone https://github.com/rocky-linux/rocky-tools.git

# cd rocky-tools/migrate2rocky
Run rocky-tool
# chmod +x migrate2rocky.sh
# ./migrate2rocky.sh -r
...

Reboot the system
# reboot 

Select Rocky Linux kernel.
(Boot prompt show all existing kernel and rocky kernel)
2022/06/16 02:14 2022/06/16 02:14
[로그인][오픈아이디란?]
Posted
Filed under Computer/Linux
# yum update
Last metadata expiration check: 0:06:06 ago on Tue 14 Jun 2022 06:27:04 PM PDT.
Module yaml error: Unexpected key in data: static_context [line 9 col 3]
Module yaml error: Unexpected key in data: static_context [line 9 col 3]
Error: 
 Problem: package centos-stream-release-8.6-1.el8.noarch requires centos-stream-repos, but none of the providers can be installed
  - package centos-linux-repos-8-2.el8.noarch conflicts with centos-repos(8) provided by centos-stream-repos-8-2.el8.noarch
  - package centos-stream-repos-8-2.el8.noarch conflicts with centos-repos(8) provided by centos-linux-repos-8-2.el8.noarch
  - package centos-linux-repos-8-2.el8.noarch conflicts with centos-repos(8) provided by centos-stream-repos-8-3.el8.noarch
  - package centos-stream-repos-8-3.el8.noarch conflicts with centos-repos(8) provided by centos-linux-repos-8-2.el8.noarch
  - package centos-linux-repos-8-2.el8.noarch conflicts with centos-repos(8) provided by centos-stream-repos-8-4.el8.noarch
  - package centos-stream-repos-8-4.el8.noarch conflicts with centos-repos(8) provided by centos-linux-repos-8-2.el8.noarch
  - package centos-linux-repos-8-2.el8.noarch conflicts with centos-repos(8) provided by centos-stream-repos-8-6.el8.noarch
  - package centos-stream-repos-8-6.el8.noarch conflicts with centos-repos(8) provided by centos-linux-repos-8-2.el8.noarch
  - cannot install the best update candidate for package centos-linux-release-8.3-1.2011.el8.noarch
  - problem with installed package centos-linux-repos-8-2.el8.noarch
(try to add '--allowerasing' to command line to replace conflicting packages or '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)



But can not remove centos-linux-repos-8-2.el8.noarch .
# yum erase --skip-broken --nobest centos-linux-repos-8-2.el8.noarch 
Error: 
 Problem: The operation would result in removing the following protected packages: setup

This time you can upgrade repo then automatically remove that repo.
# dnf swap centos-{linux,stream}-repos
Dependencies resolved.
======================================================================================================================================================================================================================================
 Package                                                         Architecture                                     Version                                               Repository                                               Size
======================================================================================================================================================================================================================================
Installing:
 centos-stream-release                                           noarch                                           8.6-1.el8                                             Stream-BaseOS                                            22 k
     replacing  centos-linux-release.noarch 8.3-1.2011.el8
     replacing  centos-release-stream.x86_64 8.1-1.1911.0.7.el8
 centos-stream-repos                                             noarch                                           8-6.el8                                               Stream-BaseOS                                            20 k
Upgrading:
 centos-gpg-keys                                                 noarch                                           1:8-6.el8                                             Stream-BaseOS                                            14 k
Removing:
 centos-linux-repos                                              noarch                                           8-2.el8                                               @BaseOS                                                  26 k
Transaction Summary
======================================================================================================================================================================================================================================
Install  2 Packages
Upgrade  1 Package
Remove   1 Package
Total download size: 57 k
Is this ok [y/N]: y
Downloading Packages:
(1/3): centos-stream-release-8.6-1.el8.noarch.rpm                                                                                                                                                     118 kB/s |  22 kB     00:00    
(2/3): centos-stream-repos-8-6.el8.noarch.rpm                                                                                                                                                         105 kB/s |  20 kB     00:00    
(3/3): centos-gpg-keys-8-6.el8.noarch.rpm                                                                                                                                                              75 kB/s |  14 kB     00:00    
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                  96 kB/s |  57 kB     00:00     

and everything OK.
2022/06/15 11:11 2022/06/15 11:11
[로그인][오픈아이디란?]