./0000755000175100017510000000000015162672436010657 5ustar ubuntuubuntu./run-qemu-box/0000755000175100017510000000000015162672436013216 5ustar ubuntuubuntu./run-qemu-box/hook.bash0000644000175100017510000000001415162672436015010 0ustar ubuntuubuntuignore_error./run-qemu-box/task.bash0000644000175100017510000000236415162672436015024 0ustar ubuntuubuntuset -e iso=$(config iso) seed=$(config seed) qemu_binary=$(config qemu_binary) machine=$(config machine) ssh_port=$(config ssh_port) prefix=$(config prefix) echo "qemu_binary: $qemu_binary" echo "machine: $machine" echo "ssh_port: $ssh_port" echo "prefix: $prefix" pid=$$ echo -n $pid > ~/rocky-linux-distro/$prefix/pid test -f $iso && echo "qcow2 image exists" test -f $seed && echo "seed image exists" opts="-vnc none --nographic" if ! test "$machine" == ""; then opts="$opts -machine $machine" fi if test $os = "darwin"; then $qemu_binary \ -net nic \ -net user,hostfwd=tcp::$ssh_port-:22 \ -m 6024M \ -cpu max \ -smp 8 \ -drive "file=$iso,index=0,format=qcow2,media=disk" \ -drive file=$seed,index=1,media=cdrom \ $opts #| iconv -f UTF-8 -t UTF-8 -c else $qemu_binary \ -net nic \ -net user,hostfwd=tcp::$ssh_port-:22 \ -m 6024M \ -cpu max \ -smp 8 \ -drive "file=$iso,index=0,format=qcow2,media=disk" \ -drive file=$seed,index=1,media=cdrom \ $opts | raku -e ' ($*OUT,$*ERR).map: {.out-buffer = 0}; loop { my $buf = $*IN.read(512); last unless $buf.elems; print $buf.decode("utf8-c8", :!strict) } ' #| cat | iconv -f UTF-8 -t UTF-8 -c fi ./run-qemu-box/config.yaml0000644000175100017510000000007215162672436015346 0ustar ubuntuubuntumachine: pc-q35-rhel9.4.0 ssh_port: 10022 prefix: default ./run-qemu-box/task.check0000644000175100017510000000010615162672436015154 0ustar ubuntuubuntunote: qemu should reach login prompt regexp: ^^ \S+ \s+ "login:" \s* ./kickstart-bootstrap/0000755000175100017510000000000015162672436014671 5ustar ubuntuubuntu./kickstart-bootstrap/task.bash0000644000175100017510000000467515162672436016506 0ustar ubuntuubuntuset -e qemu_binary=$(config qemu_binary) machine=$(config machine) version=$(config version) distro_url=$(config distro_url) ks_url=$(config ks_url) prefix=$(config prefix) ssh_port=$(config ssh_port) export ssh_key_path=$(config ssh_key_path) echo "ssh_key_path: $ssh_key_path" echo "qemu_binary: $qemu_binary" echo "machine: $machine" echo "ssh_port: $ssh_port" echo "version: $version" echo "distro_url: $distro_url" echo "prefix: $prefix" echo "ks_url: $ks_url" pid=$$ echo -n $pid > ~/rocky-linux-distro/$prefix/pid cd ~/rocky-linux-distro/$prefix/ echo "downloading $distro_url ..." wget -q $distro_url -c -O ks.$version.iso 2>&1 echo "downloading done" rm -rf distro.qcow2 qemu-img create -f qcow2 distro.qcow2 40G mkdir -p .mnt sudo umount .mnt || : iso=ks.$version.iso sudo mount -o loop $iso .mnt rm -rf initrd.img rm -rf vmlinuz cp .mnt/images/pxeboot/initrd.img . cp .mnt/images/pxeboot/vmlinuz . sudo umount .mnt opts="-no-reboot -vnc none --nographic" if ! test "$machine" == ""; then opts="$opts -machine $machine" fi echo "start kickstart bootstrap ..." echo "===" echo "pwd " $(pwd) cmd="$qemu_binary -net nic -net user,hostfwd=tcp::$ssh_port-:22 -m 6024M -cpu max -smp 8 -cdrom $iso -boot d -vnc none -kernel vmlinuz -initrd initrd.img -append \"inst.ks=$ks_url console=ttyS0\" --drive file=distro.qcow2 $opts" echo "cmd: $cmd" echo "===" set +e $qemu_binary \ -net nic \ -net user,hostfwd=tcp::$ssh_port-:22 \ -m 6024M \ -cpu max \ -smp 8 \ -cdrom $iso \ -boot d \ -vnc none \ -kernel vmlinuz \ -initrd initrd.img \ -append "inst.ks=$ks_url console=ttyS0" \ --drive file=distro.qcow2 \ $opts | raku -e ' loop { ($*OUT,$*ERR).map: {.out-buffer = 0}; my $buf = $*IN.read(512); last unless $buf.elems; print $buf.decode("utf8-c8", :!strict) } say "DONE!!!"; ' #| iconv -f UTF-8 -t UTF-8 -c set -e echo "kickstart bootstrap finished" touch meta-data cat << DATA > user-data #cloud-config users: - default - name: admin shell: /bin/bash sudo: ['ALL=(ALL) NOPASSWD:ALL'] lock_passwd: false plain_text_passwd: qwerty ssh_authorized_keys: - %key% DATA raku -e ' my $c = "user-data".IO.slurp(); $c.=subst("%key%",%*ENV.IO.slurp()); "user-data".IO.spurt($c); '; cat user-data if test $os = "darwin"; then mkisofs -output /tmp/init.iso -volid cidata -joliet -rock user-data meta-data else genisoimage -output /tmp/init.iso -V cidata -r -J user-data meta-data fi ls -l /tmp/init.iso ./kickstart-bootstrap/config.yaml0000644000175100017510000000005215162672436017017 0ustar ubuntuubuntumachine: pc-q35-rhel9.4.0 prefix: default ./setup-qemu-image/0000755000175100017510000000000015162672436014044 5ustar ubuntuubuntu./setup-qemu-image/task.bash0000644000175100017510000000302415162672436015644 0ustar ubuntuubuntuset -e prefix=$(config prefix) cd ~/rocky-linux-distro echo "create prefix dir: $prefix"; mkdir -p $prefix cd $prefix distro_url=$(config distro_url) version=$(config version) export ssh_key_path=$(config ssh_key_path) echo "ssh_key_path: $ssh_key_path" echo "version: $version" echo "distro_url: $distro_url" echo "prefix: $prefix" if test -f "distro.$version.qcow2"; then echo "distro.$version.qcow2 exists, skip download" else echo "download distro from $distro_url" echo "save result to cache file - distro.$version.qcow2.cache" echo "downloading $distro_url ..." wget -q $distro_url -c -O "distro.$version.qcow2.cache" 2>&1 echo "downloading done" echo "moving distro.$version.qcow2.cache to distro.$version.qcow2" mv distro.$version.qcow2.cache distro.$version.qcow2 fi echo "removing current qemu vm - distro.qcow2" rm -rf distro.qcow2 echo "copy distro.$version.qcow2 to distro.qcow2" cp distro.$version.qcow2 distro.qcow2 touch meta-data cat << DATA > user-data #cloud-config users: - default - name: admin shell: /bin/bash sudo: ['ALL=(ALL) NOPASSWD:ALL'] lock_passwd: false plain_text_passwd: qwerty ssh_authorized_keys: - %key% DATA raku -e ' my $c = "user-data".IO.slurp(); $c.=subst("%key%",%*ENV.IO.slurp()); "user-data".IO.spurt($c); '; cat user-data if test $os = "darwin"; then mkisofs -output /tmp/init.iso -volid cidata -joliet -rock user-data meta-data else genisoimage -output /tmp/init.iso -V cidata -r -J user-data meta-data fi ls -l /tmp/init.iso ./setup-qemu-image/config.yaml0000644000175100017510000000012415162672436016172 0ustar ubuntuubuntuqemu-binary: qemu-kvm ssh_key_path: ~/.ssh/id_rsa.pub version: "10" prefix: default ./stop-qemu-box/0000755000175100017510000000000015162672436013377 5ustar ubuntuubuntu./stop-qemu-box/task.bash0000644000175100017510000000056715162672436015210 0ustar ubuntuubuntuprefix=$(config prefix) echo "prefix: $prefix" pid=$(cat ~/rocky-linux-distro/$prefix/pid || :) list_descendants () { local children=$(pgrep -P "$1"); for pid in $children; do list_descendants "$pid"; done; echo "$children"; }; if ! test "$pid" = ""; then echo "killing proccess childs by pid [$pid]"; kill $(list_descendants $pid); fi echo "done" ./stop-qemu-box/config.yaml0000644000175100017510000000002015162672436015520 0ustar ubuntuubuntuprefix: default ./check-ssh/0000755000175100017510000000000015162672436012527 5ustar ubuntuubuntu./check-ssh/task.bash0000644000175100017510000000061115162672436014326 0ustar ubuntuubuntuhost=$(config host) user=$(config ssh_user) port=$(config ssh_port) ssh_private_key=$(config ssh_private_key) echo "ssh_private_key: $ssh_private_key" if ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no -p $port -l $user -i $ssh_private_key $host uptime; then echo '{ "state" : "alive" }' > $cache_root_dir/state.json else echo '{ "state" : "" }' > $cache_root_dir/state.json fi