This cookbook provides a custom resource to configure and manage Amazon Web Services Storage Gateway virtual machines on RHEL9/KVM.
None.
The aws_sgw
custom resource manages an AWS Storage Gateway Virtual Machine.
:install
: installs kvm and caches the vm templates (required for :create):create
: creates a new AWS Storage Gateway VM:delete
: removes a pre-existing AWS Storage Gateway VM
aws_partition
: required - (String) AWS Partition. Default:commercial
cpu_allocation
: required - (Integer) The number of virtual CPUs to be allocated by the virtual machine. Default:2
mem_allocation
: required - (Integer) The amount of memory (in kilobytes) to be allocated for the virtual machine. Default16384
primary_disk
: required - (Integer) The amount of storage (in gigabytes) to be initially allocated for the virtual machine. Default:80
cache_disk
: required - (Integer) The amount of storage (in gigabytes) to be initially allocated for the virtual machine. Default:160
In metadata.rb
you should declare a dependency on this cookbook. For example:
depends 'aws-storage-gateway-kvm'
A recipe using this custom resource may look like this:
aws_sgw 'devcomm-sgw' do
aws_partition 'commercial'
cpu_allocation 2
mem_allocation 8192
primary_disk 2
cache_disk 1
action %i(install create delete)
end
Chef Infra Client, version 18.6.2
Patents: https://www.chef.io/patents
Infra Phase starting
[2025-02-16T17:39:59+00:00] ERROR: shard_seed: Failed to get dmi property serial_number: is dmidecode installed?
Creating a new client identity for default-bento-rockylinux-9 using the validator key.
Using Policyfile 'aws-storage-gateway-kvm' at revision '200a70a5a2cc680cae4b1524f9fad17ef00229f2914ef377360eda74a472a420'
Resolving cookbooks for run list: ["aws-storage-gateway-kvm::default@2025.2.0 (d4b5382)"]
Synchronizing cookbooks:
- aws-storage-gateway-kvm (2025.2.0)
Installing cookbook gem dependencies:
Compiling cookbooks...
Loading Chef InSpec profile files:
Loading Chef InSpec input files:
Loading Chef InSpec waiver files:
Converging 1 resources
Recipe: aws-storage-gateway-kvm::default
* aws_sgw[devcomm-sgw] action install
* selinux_state[name] action permissive
* template[permissive selinux config] action create
- update content in file /etc/selinux/config from e97f43 to aaf306
--- /etc/selinux/config 2024-07-23 17:30:25.075244553 +0000
+++ /etc/selinux/.chef-config20250216-3404-ljg114 2025-02-16 17:40:00.239876030 +0000
@@ -1,30 +1,16 @@
+# Generated by Chef for default-bento-rockylinux-9.vagrantup.com
+# Do NOT modify this file by hand.
+#
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
-# See also:
-# https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/using_selinux/changing-selinux-states-and-modes_using-selinux#changing-selinux-modes-at-boot-time_changing-selinux-states-and-modes
-#
-# NOTE: Up to RHEL 8 release included, SELINUX=disabled would also
-# fully disable SELinux during boot. If you need a system with SELinux
-# fully disabled instead of SELinux running with no policy loaded, you
-# need to pass selinux=0 to the kernel command line. You can use grubby
-# to persistently set the bootloader to boot with selinux=0:
-#
-# grubby --update-kernel ALL --args selinux=0
-#
-# To revert back to SELinux enabled:
-#
-# grubby --update-kernel ALL --remove-args selinux
-#
SELINUX=permissive
# SELINUXTYPE= can take one of these three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
-
-
- restore selinux security context
* dnf_package[qemu-kvm-core] action install
- install version 17:9.0.0-10.el9_5.2.x86_64 of package qemu-kvm-core
* dnf_package[qemu-kvm-tools] action install
- install version 17:9.0.0-10.el9_5.2.x86_64 of package qemu-kvm-tools
* dnf_package[libvirt] action install
- install version 0:10.5.0-7.4.el9_5.x86_64 of package libvirt
* dnf_package[virt-manager] action install
- install version 0:4.1.0-5.el9.noarch of package virt-manager
* dnf_package[virt-install] action install
- install version 0:4.1.0-5.el9.noarch of package virt-install
* dnf_package[virt-viewer] action install
- install version 0:11.0-1.el9.x86_64 of package virt-viewer
* dnf_package[virt-top] action install
- install version 0:1.1.1-9.el9.x86_64 of package virt-top
* dnf_package[libguestfs-tools] action install
- install version 0:1.51.6-5.el9.noarch of package libguestfs-tools
* dnf_package[libvirt-daemon-config-network] action install (up to date)
* dnf_package[unzip] action install
- install version 0:6.0-57.el9.x86_64 of package unzip
* service[libvirtd] action enable
- enable service service[libvirtd]
* service[libvirtd] action start
- start service service[libvirtd]
* directory[/opt/aws-sgw] action create
- create new directory /opt/aws-sgw
- change mode from '' to '0770'
- change owner from '' to 'qemu'
- change group from '' to 'qemu'
- restore selinux security context
* directory[/opt/aws-sgw/golden-images] action create
- create new directory /opt/aws-sgw/golden-images
- change mode from '' to '0660'
- change owner from '' to 'root'
- change group from '' to 'root'
- restore selinux security context
* directory[/opt/aws-sgw/sgw-disks] action create
- create new directory /opt/aws-sgw/sgw-disks
- change mode from '' to '0770'
- change owner from '' to 'qemu'
- change group from '' to 'qemu'
- restore selinux security context
* remote_file[/opt/aws-sgw/commercial-aws-storage-gateway-file-s3.kvm.zip] action create
- Progress: 0%
- Progress: 10%
- Progress: 20%
- Progress: 30%
- Progress: 40%
- Progress: 50%
- Progress: 60%
- Progress: 70%
- Progress: 80%
- Progress: 90%
- Progress: 100%
- create new file /opt/aws-sgw/commercial-aws-storage-gateway-file-s3.kvm.zip
- update content in file /opt/aws-sgw/commercial-aws-storage-gateway-file-s3.kvm.zip from none to fa1258
(file sizes exceed 10000000 bytes, diff output suppressed)
- change mode from '' to '0770'
- change owner from '' to 'root'
- change group from '' to 'root'
- restore selinux security context
* execute[Extract AWS Commercial Template] action run
- execute unzip -o commercial-aws-storage-gateway-file-s3.kvm.zip -d golden-images/
* aws_sgw[devcomm-sgw] action create
* file[/opt/aws-sgw/sgw-disks/devcomm-sgw-primary-disk.qcow2] action create
- create new file /opt/aws-sgw/sgw-disks/devcomm-sgw-primary-disk.qcow2
- update content in file /opt/aws-sgw/sgw-disks/devcomm-sgw-primary-disk.qcow2 from none to e8b9ad
(file sizes exceed 10000000 bytes, diff output suppressed)
- change mode from '' to '0770'
- change owner from '' to 'qemu'
- change group from '' to 'qemu'
- restore selinux security context
* execute[Gather VM Data] action run
- execute virsh list --all | awk '{ print $2 }' | tail -n +3 > /tmp/virsh-list-output.txt
* execute[Creating Storage Gateway - devcomm-sgw] action run
- execute virt-install --name "devcomm-sgw" --description "devcomm-sgw Storage Gateway VM" --os-variant=rhel9-unknown --ram=4000 --vcpus=2 --disk path=/opt/aws-sgw/sgw-disks/devcomm-sgw-primary-disk.qcow2,bus=virtio,size=2 --disk path=/opt/aws-sgw/sgw-disks/devcomm-sgw}-cache-disk.qcow2,bus=virtio,size=1 --network default,model=virtio --serial pty,target_type=isa-serial --console pty,target_type=serial --graphics vnc,listen="127.0.0.1",keymap=local --autoconsole none --import
* aws_sgw[devcomm-sgw] action delete
* execute[Gather VM Data] action run
- execute virsh list --all | awk '{ print $2 }' | tail -n +3 > /tmp/virsh-list-output.txt
* execute[Power Down VM - devcomm-sgw] action run
- execute virsh destroy devcomm-sgw
* execute[Destroy VM - devcomm-sgw] action run
- execute virsh undefine devcomm-sgw --remove-all-storage
Running handlers:
Running handlers complete
Infra Phase complete, 27/28 resources updated in 04 minutes 37 seconds
Downloading files from <default-bento-rockylinux-9>
Finished converging <default-bento-rockylinux-9> (4m55.94s).
-----> Kitchen is finished. (5m44.15s)
- Fork the project on github
- Commit your changes to your fork
- Send a pull request
- Author:: Erin L. Kolp (erinlkolpfoss@gmail.com)
Copyright (c) 2025 Erin L. Kolp
Licensed under the MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.