CEP's Blog -by Kage Park: Computer 카테고리 글 목록
http://kaget.cep.kr/blog/
2022-08-24T06:00:13+09:00
Textcube 1.10.7 : Tempo primo
make a deployment custom CentOS8-Stream image in Ubuntu and setup custom OS in MAAS 3.0
Kage Park
http://kaget.cep.kr/blog/319
2022-08-04T09:00:38+09:00
2022-08-04T07:27:53+09:00
<div data-pm-slice="1 1 []" data-en-clipboard="true"><span style="font-size: 14pt;"><strong>* In Ubuntu 20.04</strong></span><br /><strong>Install packer</strong></div>
<div>~$ wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg</div>
<div>~$ 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</div>
<div>~$ sudo apt update && sudo apt install packer</div>
<div>~$ packer --version</div>
<div>1.8.3</div>
<div></div>
<div><strong>Install RHEL8 template dependencies</strong></div>
<div>~$ sudo apt install qemu-utils</div>
<div>~$ sudo apt install qemu-system</div>
<div></div>
<div><strong>Get packer templates</strong></div>
<div>~$ git clone <a href="https://github.com/canonical/packer-maas.git" rev="en_rl_none">https://github.com/canonical/packer-maas.git</a></div>
<div></div>
<div><strong>Change to centos8-stream template</strong></div>
<div>~$ cd packer-maas/centos8-stream</div>
<div><em><strong>if you want change KS filethen modify http/centos8-stream.ks file.</strong></em></div>
<div><em>packer-maas/centos8-stream$ ls http/</em></div>
<div><em>centos8-stream.ks</em></div>
<div></div>
<div><strong>Build the CentOS 8 stream image from ISO file.</strong></div>
<div>packer-maas/centos8-stream$ make ISO=/global/iso/CentOS-Stream-8-x86_64-20220728-dvd1.iso</div>
<div></div>
<div><em>created centos8-stream.tar.gz file.</em></div>
<div>packer-maas/centos8-stream$ ls</div>
<div>centos8-stream.json centos8-stream.tar.gz http Makefile output-qemu README.md</div>
<div></div>
<div><strong>Copy the image file to MAAS server.</strong></div>
<div>packer-maas/ centos8-stream$ scp centos8-stream.tar.gz user@maas-server:</div>
<div></div>
<div><span style="font-size: 14pt;"><strong>* In maas-server</strong></span></div>
<div>(https://ubuntu.com/blog/cli-only-maas-operation)</div>
<div><strong>Need MAAS API-KEY-FILE</strong></div>
<div>~$ cat api-key-file</div>
<div>xlfU9XtKzmaJMAa3w7:Gq6fZxzZ6g9HsQAeKW:NGJ5qAtJrF929TU8cKCdUUqtqzwGjBbw3</div>
<div></div>
<div><strong>Login to admin in MAAS</strong></div>
<div>~$ maas login admin <a href="http://172.16.221.88:5240/MAAS" rev="en_rl_none">http://maas-server:5240/MAAS</a></div>
<div>API key (leave empty for anonymous access):</div>
<div>You are now logged in to the MAAS server at</div>
<div>http://maas-server:5240/MAAS/api/2.0/ with the profile name 'admin'.</div>
<div></div>
<div>For help with the available commands, try:</div>
<div></div>
<div> maas admin --help</div>
<div></div>
<div><strong>check boot resource </strong></div>
<div>~$ maas admin boot-resources read</div>
<div></div>
<div><strong>Import the image to MAAS in maas-server</strong></div>
<div><em>*Not support Rocky OS, CentOS 8.3</em></div>
<div>~$ maas admin boot-resources create name=centos/8-stream title='CentOS8-stream' architecture='amd64/generic' filetype='tgz' content@= centos8-stream.tar.gz</div>
<div></div>
<div><strong>Verify custom image</strong></div>
<div>~$ maas admin boot-resources read</div>
<div>....</div>
<div>{</div>
<div>"id": 13,</div>
<div>"type": "Uploaded",</div>
<div>"name": "centos/8-stream",</div>
<div>"architecture": "amd64/generic",</div>
<div>"resource_uri": "/MAAS/api/2.0/boot-resources/13/",</div>
<div>"subarches": "generic",</div>
<div>"title": "CentOS8-stream"</div>
<div>}</div>
<div>]</div>
<div></div>
<div><strong>Deploy the CentOS Image</strong></div>
<div>goto "Setting" and select "Deploy" under "Configuration".</div>
<div>Select Deployment OS to "CentOS" and release to "CentOS8-stream"</div>
<br />
<div><div class="imageblock center" style="text-align: center; clear: both;"><img src="http://kaget.cep.kr/blog/attach/1/1892429210.png" alt="User image" height="123" width="650" /></div><br /><span style="font-size: 15.008px;">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).<br /></span></div>
<div><strong>Login to compute node:</strong></div>
<div>maas-server$ ssh <a href="mailto:centos@192.168.155.54">centos@192.168.150.5</a>0</div>
<div>[centos@cent-test-host ~]$ cat /etc/redhat-release</div>
<div>CentOS Stream release 8</div>
<div></div>
<div><em>Default user without password: </em></div>
<div>CentOS -> centos</div>
<div>Ubuntu -> ubuntu</div>
<div></div>
<div><strong>Setting Password-less SSH-key in MAAS</strong></div>
<div>goto "admin" -> SSH keys -> "import SSH key"</div>
<div>then the default user will defined with this SSH key. So you can login to server with default username with imported SSH key.<br /><br />Good works OS:<br />centos 7<br />centos 8-stream</div><p><strong><a href="http://kaget.cep.kr/blog/319?commentInput=true#entry319WriteComment">댓글 쓰기</a></strong></p>
snap/snapcraft test
Kage Park
http://kaget.cep.kr/blog/318
2022-08-02T07:12:25+09:00
2022-08-02T06:32:08+09:00
Universial Package Manager snap testing<br /><br />1. Install snap package<br /><strong>2. Install snapcraft (package builder)</strong><br />$ sudo snap install snapcraft --classic<br /><br /><strong>3. Simple Python script packaging</strong><br />$ mkdir ~/work<br /><span style="font-size: 15.008px;">- make a package(test-app) directory<br /></span>$ mkdir ~/work/test-app<br /><br /><strong>4. make a python script package</strong><br />$ mkdir ~/work/test-app/myapp<br />$ mkdir ~/work/test-app/myapp/lib<br />$ vi ~/work/test-app/myapp/lib/TM.py<br />------------------------------------------------------------<br />
<div>from datetime import datetime</div>
<div>def now():</div>
<div> return datetime.now().strftime('%s')</div>
<div>
<div style="font-size: 15.008px;">------------------------------------------------------------<br /><span style="font-size: 15.008px;">$ touch ~/work/test-app/myapp/lib/__init__.py<br /></span>$ vi ~/work/test-app/myapp/test_run<br /><span style="font-size: 15.008px;">------------------------------------------------------------</span><br />
<div>#!/usr/bin/env python3</div>
<div></div>
<div>from lib import TM</div>
<div></div>
<div></div>
<div>def main():</div>
<div></div>
<div> print('Hello, I am main()')</div>
<div> aa=TM.now()</div>
<div> input("now second is:{}".format(aa))</div>
<div></div>
<div>if __name__ == '__main__':</div>
<div> main()</div>
<span style="font-size: 15.008px;">------------------------------------------------------------<br /><br /></span><strong>5. make a snap configuration</strong><br />$ mkdir ~/work/test-app/snap<br />$ vi ~/work/test-app/snap/snapcraft.yaml<br /><span style="font-size: 15.008px;">------------------------------------------------------------</span><br />
<div>name: test-app # package name</div>
<div>version: '1.1' # package version</div>
<div>summary: Example python snap app</div>
<div>description: |</div>
<div> Example python snap app description</div>
<div>base: core20 # Common Base OS ( 18: ubuntu 18.04, 20: ubuntu 20.04, 22: ubuntu 22.04 )</div>
<div>grade: stable</div>
<div>confinement: devmode</div>
<div></div>
<div>apps:</div>
<div> test-app: #Package name</div>
<div> command: myapp/test_run #running command path and filename (/snap/bin/<package name> will running the command line path file)</div>
<div> ## If need special path for shell script</div>
<div> #command: sh $SNAP/opt/foo/bin/foo.sh</div>
<div></div>
<div>parts:</div>
<div> test-app:</div>
<div> source: . #my local directory is source</div>
<div> ## When copy a file(shell/python/built binary file) to somewhere</div>
<div> plugin: dump </div>
<div> organize:</div>
<div> src/myapp: . # start with "src/" and my files are in the src directory. (copy the myapp directory)</div>
<div> ## When use python setup.py to install application then use python plugin</div>
<div> #plugin: python</div>
<div> #python-version: python3</div>
</div>
<span style="font-size: 15.008px;">------------------------------------------------------------<br /><br /></span><strong>6. build </strong><br />$ cd ~/work/test-app<br />$ snapcraft<br /><br /><strong>7. Install</strong><br />$ snap install test-app_1.1_amd64.snap --devmode<br /><br /><strong>8. check </strong><br />
<div>
<div>
<div>
<div>
<div>
<div>$ snap list |grep test-app</div>
<div>test-app 1.1 x1 - - devmode</div>
</div>
</div>
</div>
</div>
</div>
<div></div>
<div>
<div>
<div>
<div>
<div>
<div>$ df -h</div>
<div>~~~<br />/dev/loop3 128K 128K 0 100% /snap/test-app/x1</div>
<div></div>
<div>$ ls -l /snap/bin/test-app </div>
<div>lrwxrwxrwx 1 root root 13 Aug 1 14:18 /snap/bin/test-app -> /usr/bin/snap</div>
</div>
</div>
</div>
</div>
</div>
<div>
<div></div>
</div>
<div>$ /snap/bin/test-app </div>
<div>Hello, I am main()</div>
<div>now second is:1659388777<br /><br /><strong>ETC & Tools)</strong><br />
<div>$ cat cleanup_multipath_snapcraft_built_garbage.sh <br />-------------------------------------------------------------------------------------------------------------</div>
<div>#!/bin/bash -x</div>
<div>## snapcraft-created multipass VMs</div>
<div>for vm in $(multipass list | awk '{print $1}' | grep "^snapcraft-"); do</div>
<div> multipass delete $vm --purge</div>
<div>done</div>
<div></div>
<div>## snapcraft-created LXD containers</div>
<div>#for c in $(lxc list | awk '{print $2}' | grep "^snapcraft-" | grep -v "snapcraft-dev"); do</div>
<div># lxc delete $c --force</div>
<div>#done</div>
<div><span style="font-size: 15.008px;">-------------------------------------------------------------------------------------------------------------<br /></span><br />
<div>$ cat remove_disabled_snap.sh </div>
<span style="font-size: 15.008px;">-------------------------------------------------------------------------------------------------------------</span><br />
<div>#!/bin/bash</div>
<div>set -eu</div>
<div></div>
<div>LANG=en_US.UTF-8 snap list --all | awk '/disabled/{print $1, $3}' |</div>
<div> while read snapname revision; do</div>
<div> snap remove "$snapname" --revision="$revision"</div>
<div> done</div>
<div style="font-size: 15.008px;"><span style="font-size: 15.008px;">-------------------------------------------------------------------------------------------------------------</span></div>
<br />Remove Package<br />$ snap remove <package name><br />other commands: https://www.cyberithub.com/36-popular-snap-command-examples-in-linux/<br /><br /><br />Few other snap configuration files example:<br /><strong>a) automatically use bin directory in local directory (Some updated code)</strong><br /> original : https://github.com/gocarlos/python-ubuntu-snap-app-example<br />
<div>
<div>$ ls </div>
<div>bin LICENSE myapp_module mygreatapp_1.0_amd64.snap README.md requirements.txt snap</div>
<div>
<div>$ cat requirements.txt </div>
<div>numpy</div>
</div>
<div>
<div>$ cat bin/my_great_app </div>
<div>#!/usr/bin/env python3</div>
<div></div>
<div>from myapp_module import my_great_app</div>
<div></div>
<div>"""</div>
<div> my application.</div>
<div>"""</div>
<div></div>
<div>def main():</div>
<div> """run the application"""</div>
<div></div>
<div> print('I\'m inside main')</div>
<div> my_great_app.tata()</div>
<div> input("Press enter to exit ;)")</div>
<div> input()</div>
<div></div>
<div></div>
<div>if __name__ == '__main__':</div>
<div> main()</div>
</div>
<div>
<div>$ ls myapp_module/</div>
<div>__init__.py my_great_app.py</div>
</div>
<div>
<div>$ cat myapp_module/my_great_app.py </div>
<div>#!/usr/bin/env python3</div>
<div></div>
<div>def tata():</div>
<div> print ('you could do great stuff inside this function.')</div>
<div> </div>
<div>def fun(x):</div>
<div> return x + 1</div>
</div>
<div>
<div>$ cat snap/snapcraft.yaml </div>
<div>name: mygreatapp</div>
<div>version: '1.0'</div>
<div>summary: Example python snap app</div>
<div>description: |</div>
<div> Example python snap app</div>
<div>base: core18</div>
<div>grade: stable</div>
<div>confinement: devmode</div>
<div></div>
<div>apps:</div>
<div> mygreatapp:</div>
<div> <em>command: my_great_app</em></div>
<div></div>
<div>parts:</div>
<div> mygreatapp:</div>
<div><em> plugin: python</em></div>
<div><em> python-version: python3</em></div>
<div> source: .</div>
</div>
<div><br /><strong>b) Automatically build and package from remote source file.</strong><br />
<div>$ cat snap/snapcraft.yaml </div>
<div>name: hello</div>
<div>base: core18</div>
<div>version: '2.10'</div>
<div>summary: GNU Hello, the "hello world" snap</div>
<div>description: |</div>
<div> GNU hello prints a friendly greeting.</div>
<div>grade: devel</div>
<div>confinement: devmode</div>
<div>parts:</div>
<div> gnu-hello:</div>
<div> source: http://ftp.gnu.org/gnu/hello/hello-2.10.tar.gz</div>
<div> plugin: autotools</div>
<div></div>
<div>
<div>
<div></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div><p><strong><a href="http://kaget.cep.kr/blog/318?commentInput=true#entry318WriteComment">댓글 쓰기</a></strong></p>
Openstack Baremetal Compute node Basic procedure with Redfish
Kage Park
http://kaget.cep.kr/blog/317
2022-07-06T02:09:43+09:00
2022-07-02T07:02:37+09:00
<div>1. Create Node:</div>
<div>openstack baremetal node create \</div>
<div> --name <HOST NAME> \</div>
<div> --driver redfish \</div>
<div> --driver-info redfish_address=<BMC IP> \</div>
<div> --driver-info redfish_system_id=/redfish/v1/Systems/1 \</div>
<div> --driver-info redfish_username=<USER NAME> \</div>
<div> --driver-info redfish_password=<PASSWORD><br /><br />2. Setup Properties<br />
<div> 2.1 Set Redfish Verify CA to False</div>
<div> openstack baremetal set <NODE_UUID> \</div>
<div> --driver-info redfish_verify_ca="False"<br /><br />
<div> 2.2 Set boot mode to UEFI:</div>
<div> penstack baremetal node set <NODE_UUID> \</div>
<div> --property capabilities='boot_mode:uefi'<br /><br />
<div> 2.3 Set Ramdisk and Kernel :</div>
<div> openstack baremetal node set <NODE_UUID> \</div>
<div> --driver-info deploy_ramdisk=<RAMDISK IMAGE UUID> \</div>
<div> --driver-info deploy_kernel=<KERNEL IMAGE UUID><br /><br />
<div> 2.4 Set OS Image:</div>
<div> openstack baremetal node set <NODE_UUID> \</div>
<div> --instance-info image_source=<Deploy OS Image UUID> \</div>
<div> --instance-info root_gb=SIZE (optional)<br /><br /> 2.5 Set other Optional properties<br /><br />3. Setup Network Port<br />
<div> 3.1 Create PXE Port(IRONIC PORT):</div>
<div> openstack baremetal port create \</div>
<div> --node <NODE_UUID> \</div>
<div> <MAC of CHASSIS/Baremetal NODE NIC></div>
<div></div>
<div> 3.2 Create Network port (NEUTRON PORT)</div>
<div> openstack port create \</div>
<div> --mac-address <MAC of CHASSIS/Baremetal NODE NIC> \</div>
<div> --network <NETWORK UUID></div>
<div> <PORT NAME:<HOST NAME>vif></div>
<div></div>
<div> 3.3 Associate the neutron port(VIFport) to the ironic port:</div>
<div> openstack baremetal port set <IRONIC_PORT_UUID> \</div>
<div> --extra vif_port_id=<NEUTRON_PORT_UUID(above command)></div>
<div></div>
<div> 3.4 Attache VIF to the baremetal node</div>
<div> openstack baremetal node vif attach \</div>
<div> --port-uuid <IRONIC_PORT> \</div>
<div> <NODE_UUID> \</div>
<div> <NEUTRON_PORT_UUID><br /><br /><br />
<div>4. Change to manageable from enrolling</div>
<div>openstack baremetal node manage <NODE_UUID></div>
<div><br /><br /></div>
<div>5. Provide</div>
<div>openstack baremetal node provide <NODE_UUID></div>
<div> - PXE BOOT</div>
<div> - check network</div>
<div> - Run AGENT in <Deploy RAMDISK></div>
<div> - Agent heartbeat</div>
<div> - Agent check disk (not support SATADOM)</div>
<div> - Agent format disk (required format command)</div>
<div> - turn off system</div>
<div><br /><br /></div>
<div>6. Deploy</div>
<div>openstack baremetal node deploy <NODE_UUID></div>
<div> - check VIF </div>
<div> - PXE BOOT with <Deploy RAMDISK></div>
<div> - Deploy <Deploy_OS_Image> to Local Root Disk</div>
<div> - Turn off</div>
<div> - statue to active</div>
<div> - BOOT LOCAL DISK</div>
<div> - Using Same <Deploy_OS_Image> in Local Root DISK</div>
</div>
</div>
</div>
</div>
</div>
</div><p><strong><a href="http://kaget.cep.kr/blog/317?commentInput=true#entry317WriteComment">댓글 쓰기</a></strong></p>
Upgrade from CentOS 8.3 to Rocky 8.6
Kage Park
http://kaget.cep.kr/blog/316
2022-07-06T02:09:59+09:00
2022-06-16T02:14:44+09:00
Backup your important data<br /><br />Clone rocky-tools<br /># git clone https://github.com/rocky-linux/rocky-tools.git<br /><br /># cd rocky-tools/migrate2rocky<br />Run rocky-tool<br /># chmod +x migrate2rocky.sh<br /># ./migrate2rocky.sh -r<br />...<br /><br />Reboot the system<br /># reboot <br /><br />Select Rocky Linux kernel.<br />(Boot prompt show all existing kernel and rocky kernel)<p><strong><a href="http://kaget.cep.kr/blog/316?commentInput=true#entry316WriteComment">댓글 쓰기</a></strong></p>
Problem: package centos-stream-release-8.6-1.el8.noarch requires centos-stream-repos, but none of the providers can be installed
Kage Park
http://kaget.cep.kr/blog/315
2022-06-15T11:11:14+09:00
2022-06-15T11:11:07+09:00
<div># yum update</div>
<div>Last metadata expiration check: 0:06:06 ago on Tue 14 Jun 2022 06:27:04 PM PDT.</div>
<div>Module yaml error: Unexpected key in data: static_context [line 9 col 3]</div>
<div>Module yaml error: Unexpected key in data: static_context [line 9 col 3]</div>
<div>Error: </div>
<div> Problem: package centos-stream-release-8.6-1.el8.noarch requires centos-stream-repos, but none of the providers can be installed</div>
<div> - package centos-linux-repos-8-2.el8.noarch conflicts with centos-repos(8) provided by centos-stream-repos-8-2.el8.noarch</div>
<div> - package centos-stream-repos-8-2.el8.noarch conflicts with centos-repos(8) provided by centos-linux-repos-8-2.el8.noarch</div>
<div> - package centos-linux-repos-8-2.el8.noarch conflicts with centos-repos(8) provided by centos-stream-repos-8-3.el8.noarch</div>
<div> - package centos-stream-repos-8-3.el8.noarch conflicts with centos-repos(8) provided by centos-linux-repos-8-2.el8.noarch</div>
<div> - package centos-linux-repos-8-2.el8.noarch conflicts with centos-repos(8) provided by centos-stream-repos-8-4.el8.noarch</div>
<div> - package centos-stream-repos-8-4.el8.noarch conflicts with centos-repos(8) provided by centos-linux-repos-8-2.el8.noarch</div>
<div> - package centos-linux-repos-8-2.el8.noarch conflicts with centos-repos(8) provided by centos-stream-repos-8-6.el8.noarch</div>
<div> - package centos-stream-repos-8-6.el8.noarch conflicts with centos-repos(8) provided by centos-linux-repos-8-2.el8.noarch</div>
<div> - cannot install the best update candidate for package centos-linux-release-8.3-1.2011.el8.noarch</div>
<div> - problem with installed package centos-linux-repos-8-2.el8.noarch</div>
<div>(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)</div>
<div><br /><br /><br />But can not remove centos-linux-repos-8-2.el8.noarch .<br />
<div># yum erase --skip-broken --nobest centos-linux-repos-8-2.el8.noarch </div>
<div>Error: </div>
<div> Problem: The operation would result in removing the following protected packages: setup</div>
<div><br />This time you can upgrade repo then automatically remove that repo.<br /># dnf swap centos-{linux,stream}-repos<br />
<div>Dependencies resolved.</div>
<div>======================================================================================================================================================================================================================================</div>
<div> Package Architecture Version Repository Size</div>
<div>======================================================================================================================================================================================================================================</div>
<div>Installing:</div>
<div> centos-stream-release noarch 8.6-1.el8 Stream-BaseOS 22 k</div>
<div> replacing centos-linux-release.noarch 8.3-1.2011.el8</div>
<div> replacing centos-release-stream.x86_64 8.1-1.1911.0.7.el8</div>
<div> centos-stream-repos noarch 8-6.el8 Stream-BaseOS 20 k</div>
<div>Upgrading:</div>
<div> centos-gpg-keys noarch 1:8-6.el8 Stream-BaseOS 14 k</div>
<div>Removing:</div>
<div> centos-linux-repos noarch 8-2.el8 @BaseOS 26 k</div>
<div></div>
<div>Transaction Summary</div>
<div>======================================================================================================================================================================================================================================</div>
<div>Install 2 Packages</div>
<div>Upgrade 1 Package</div>
<div>Remove 1 Package</div>
<div></div>
<div>Total download size: 57 k</div>
<div>Is this ok [y/N]: y</div>
<div>Downloading Packages:</div>
<div>(1/3): centos-stream-release-8.6-1.el8.noarch.rpm 118 kB/s | 22 kB 00:00 </div>
<div>(2/3): centos-stream-repos-8-6.el8.noarch.rpm 105 kB/s | 20 kB 00:00 </div>
<div>(3/3): centos-gpg-keys-8-6.el8.noarch.rpm 75 kB/s | 14 kB 00:00 </div>
<div>--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------</div>
<div>Total 96 kB/s | 57 kB 00:00 <br /><br />and everything OK.</div>
</div>
</div>
<div></div><p><strong><a href="http://kaget.cep.kr/blog/315?commentInput=true#entry315WriteComment">댓글 쓰기</a></strong></p>