plus3it / spel

STIG-Partitioned Enterprise Linux (spel)
Other
95 stars 61 forks source link

provided azure sample doesn't work #553

Closed bunchrt closed 2 years ago

bunchrt commented 2 years ago

Expected behavior

provided sample azure build successfully runs and creates an image (VHD or managed image)

Actual behavior

az login (success)

packer build \ -var 'spel_identifier=unique-project-id' \ -var 'spel_version=0.0.1' \ -var 'spel_disablefips=true' \ -var 'amigen_extra_rpms=["WALinuxAgent"]' \ -var 'amigen_fips_disable=true' \ -var 'amigen7_repo_names=["rhui-microsoft-azure-rhel7"]' \ -var 'azure_image_offer=rhel-raw' \ -var 'azure_image_publisher=RedHat' \ -var 'azure_image_sku=7-raw' \ -var 'azure_managed_image_resource_group_name=.........' \ -only 'azure-arm.minimal-rhel-7-image' \ spel/minimal-linux.json

==> Wait completed after 2 microseconds

==> Builds finished but no artifacts were created. spel % echo $? 0 spel % which packer --version 1.8.0 spel % ls spel/minimal-linux.json spel/minimal-linux.json

there are no relevant packer files under /tmp (macos or Azure VM) or /private/var/folders (macos)

Steps to reproduce behavior

az login (success)

packer build \ -var 'spel_identifier=unique-project-id' \ -var 'spel_version=0.0.1' \ -var 'spel_disablefips=true' \ -var 'amigen_extra_rpms=["WALinuxAgent"]' \ -var 'amigen_fips_disable=true' \ -var 'amigen7_repo_names=["rhui-microsoft-azure-rhel7"]' \ -var 'azure_image_offer=rhel-raw' \ -var 'azure_image_publisher=RedHat' \ -var 'azure_image_sku=7-raw' \ -var 'azure_managed_image_resource_group_name=.........' \ -only 'azure-arm.minimal-rhel-7-image' \ spel/minimal-linux.json

Context/Specifications

...results land in the storage account, under system/Microsoft.Compute/Images/images.

Suggestions for fix

Relevant references

lorengordon commented 2 years ago

@bunchrt Sorry about that. Lots of recent changes to update from the old json template to the new hcl template. Should be fixed in https://github.com/plus3it/spel/pull/554.

bunchrt commented 2 years ago

no problem, appreciate the upcoming patch. have ya'll considered making your spel image (well, the approach) available in Azure comm/gov as well?

lorengordon commented 2 years ago

We do use spel to create private images in Azure, but we haven't gotten around to figuring out how public images work in Azure, and setting up a subscription to host it, and a pipeline to publish it. 😄

bunchrt commented 2 years ago

soooo close.

1) I had to tweak a couple variables/settings:

-var 'azure_location=eastus' \
-var 'azure_vm_size=Standard_A2_v2' \ # I don't know if this impacts what I'm seeing below
-var 'spel_root_volume_size=50' \ # tried 32, 40, 50...

...but I can't seem to get past the following step:

==> azure-arm.minimal-rhel-7-image: Provisioning with shell script: spel/scripts/pivot-root.sh : : azure-arm.minimal-rhel-7-image: + echo 'Creating /tmproot...' azure-arm.minimal-rhel-7-image: Creating /tmproot... azure-arm.minimal-rhel-7-image: + install -Ddm 000755 /tmp/tmproot azure-arm.minimal-rhel-7-image: + echo 'Mounting tmpfs to /tmp/tmproot...' azure-arm.minimal-rhel-7-image: Mounting tmpfs to /tmp/tmproot... azure-arm.minimal-rhel-7-image: + mount none /tmp/tmproot -t tmpfs azure-arm.minimal-rhel-7-image: + echo 'Copying / to /tmp/tmproot...' azure-arm.minimal-rhel-7-image: Copying / to /tmp/tmproot... azure-arm.minimal-rhel-7-image: + cp -ax / /tmp/tmproot azure-arm.minimal-rhel-7-image: cp: error writing ‘/tmp/tmproot/var/cache/yum/x86_64/7Server/rhui-rhel-7-server-rhui-rpms/gen/filelists.xml.sqlite’: No space left on device azure-arm.minimal-rhel-7-image: cp: failed to extend ‘/tmp/tmproot/var/cache/yum/x86_64/7Server/rhui-rhel-7-server-rhui-rpms/gen/filelists.xml.sqlite’: No space left on device : : :

bunchrt commented 2 years ago

changed the instance type (you had it set to something that wanted more cores than I had allowed (basically still a new account),

-var 'azure_vm_size=Standard_D2s_v3' \
-var 'spel_root_volume_size=50' \

...and that got me past the /tmproot problem. But into another:

azure-arm.minimal-rhel-7-image: + echo 'Enabling repos in the builder box'
azure-arm.minimal-rhel-7-image: Enabling repos in the builder box
azure-arm.minimal-rhel-7-image: + yum-config-manager --disable '*'
azure-arm.minimal-rhel-7-image: + yum-config-manager --enable rhui-REGION-client-config-server-7,rhui-REGION-rhel-server-releases,rhui-REGION-rhel-server-rh-common,rhui-REGION-rhel-server-optional,rhui-REGION-rhel-server-extras,rhui-client-config-server-7,rhel-7-server-rhui-rpms,rhel-7-server-rhui-rh-common-rpms,rhel-7-server-rhui-optional-rpms,rhel-7-server-rhui-extras-rpms,rhui-rhel-7-server-rhui-rpms,rhui-rhel-7-server-rhui-rh-common-rpms,rhui-rhel-7-server-rhui-optional-rpms,rhui-rhel-7-server-rhui-extras-rpms,epel,rhui-microsoft-azure-rhel7
azure-arm.minimal-rhel-7-image: + [[ -n '' ]]
azure-arm.minimal-rhel-7-image: + [[ -n '' ]]
azure-arm.minimal-rhel-7-image: + echo 'Installing specified extra packages in the builder box'
azure-arm.minimal-rhel-7-image: Installing specified extra packages in the builder box
azure-arm.minimal-rhel-7-image: + IFS=,
azure-arm.minimal-rhel-7-image: + read -r -a BUILDER_EXTRARPMS
azure-arm.minimal-rhel-7-image: + for RPM in '"${BUILDER_EXTRARPMS[@]}"'
azure-arm.minimal-rhel-7-image: ++ yum -y install WALinuxAgent
azure-arm.minimal-rhel-7-image: Loaded plugins: langpacks, product-id, search-disabled-repos
azure-arm.minimal-rhel-7-image: epel/x86_64/metalink                                     | 6.1 kB     00:00
azure-arm.minimal-rhel-7-image: rhui-microsoft-azure-rhel7                               | 2.1 kB     00:00
azure-arm.minimal-rhel-7-image: rhui-rhel-7-server-rhui-extras-rpms                      | 2.0 kB     00:00
azure-arm.minimal-rhel-7-image: rhui-rhel-7-server-rhui-optional-rpms                    | 1.8 kB     00:00
azure-arm.minimal-rhel-7-image: rhui-rhel-7-server-rhui-rh-common-rpms                   | 2.1 kB     00:00
azure-arm.minimal-rhel-7-image: rhui-rhel-7-server-rhui-rpms                             | 2.0 kB     00:00
azure-arm.minimal-rhel-7-image: (1/3): rhui-rhel-7-server-rhui-optional-rpms/7Server/x86_6 |  26 kB   00:00
azure-arm.minimal-rhel-7-image: (2/3): rhui-rhel-7-server-rhui-optional-rpms/7Server/x86_6 | 3.0 MB   00:00
azure-arm.minimal-rhel-7-image: (3/3): rhui-rhel-7-server-rhui-optional-rpms/7Server/x86_6 | 6.6 MB   00:00
azure-arm.minimal-rhel-7-image: rhui-rhel-7-server-rhui-optional-rpms                               23328/23328
azure-arm.minimal-rhel-7-image: + STDERR='Traceback (most recent call last):
azure-arm.minimal-rhel-7-image:   File "/bin/yum", line 29, in <module>
azure-arm.minimal-rhel-7-image:     yummain.user_main(sys.argv[1:], exit_code=True)
azure-arm.minimal-rhel-7-image:   File "/usr/share/yum-cli/yummain.py", line 375, in user_main
azure-arm.minimal-rhel-7-image:     errcode = main(args)
azure-arm.minimal-rhel-7-image:   File "/usr/share/yum-cli/yummain.py", line 184, in main
azure-arm.minimal-rhel-7-image:     result, resultmsgs = base.doCommands()
azure-arm.minimal-rhel-7-image:   File "/usr/share/yum-cli/cli.py", line 585, in doCommands
azure-arm.minimal-rhel-7-image:     return self.yum_cli_commands[self.basecmd].doCommand(self, self.basecmd, self.extcmds)
azure-arm.minimal-rhel-7-image:   File "/usr/share/yum-cli/yumcommands.py", line 446, in doCommand
azure-arm.minimal-rhel-7-image:     return base.installPkgs(extcmds, basecmd=basecmd)
azure-arm.minimal-rhel-7-image:   File "/usr/share/yum-cli/cli.py", line 1017, in installPkgs
azure-arm.minimal-rhel-7-image:     txmbrs = self.install(pattern=arg)
azure-arm.minimal-rhel-7-image:   File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 4848, in install
azure-arm.minimal-rhel-7-image:     mypkgs = self.pkgSack.returnPackages(patterns=pats,
azure-arm.minimal-rhel-7-image:   File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 1075, in <lambda>
azure-arm.minimal-rhel-7-image:     pkgSack = property(fget=lambda self: self._getSacks(),
azure-arm.minimal-rhel-7-image:   File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 778, in _getSacks
azure-arm.minimal-rhel-7-image:     self.repos.populateSack(which=repos)
azure-arm.minimal-rhel-7-image:   File "/usr/lib/python2.7/site-packages/yum/repos.py", line 386, in populateSack
azure-arm.minimal-rhel-7-image:     sack.populate(repo, mdtype, callback, cacheonly)
azure-arm.minimal-rhel-7-image:   File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 263, in populate
azure-arm.minimal-rhel-7-image:     dobj = repo_cache_function(xml, csum)
azure-arm.minimal-rhel-7-image:   File "/usr/lib64/python2.7/site-packages/sqlitecachec.py", line 46, in getPrimary
azure-arm.minimal-rhel-7-image:     self.repoid))
azure-arm.minimal-rhel-7-image: TypeError: Can not create packagename index: database or disk is full'
azure-arm.minimal-rhel-7-image: + echo 'Traceback (most recent call last):
azure-arm.minimal-rhel-7-image:   File "/bin/yum", line 29, in <module>
azure-arm.minimal-rhel-7-image:     yummain.user_main(sys.argv[1:], exit_code=True)
azure-arm.minimal-rhel-7-image:   File "/usr/share/yum-cli/yummain.py", line 375, in user_main
azure-arm.minimal-rhel-7-image:     errcode = main(args)
azure-arm.minimal-rhel-7-image:   File "/usr/share/yum-cli/yummain.py", line 184, in main
azure-arm.minimal-rhel-7-image:     result, resultmsgs = base.doCommands()
azure-arm.minimal-rhel-7-image:   File "/usr/share/yum-cli/cli.py", line 585, in doCommands
azure-arm.minimal-rhel-7-image:     return self.yum_cli_commands[self.basecmd].doCommand(self, self.basecmd, self.extcmds)
azure-arm.minimal-rhel-7-image:   File "/usr/share/yum-cli/yumcommands.py", line 446, in doCommand
azure-arm.minimal-rhel-7-image:     return base.installPkgs(extcmds, basecmd=basecmd)
azure-arm.minimal-rhel-7-image:   File "/usr/share/yum-cli/cli.py", line 1017, in installPkgs
azure-arm.minimal-rhel-7-image:     txmbrs = self.install(pattern=arg)
azure-arm.minimal-rhel-7-image:   File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 4848, in install
azure-arm.minimal-rhel-7-image:     mypkgs = self.pkgSack.returnPackages(patterns=pats,
azure-arm.minimal-rhel-7-image:   File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 1075, in <lambda>
azure-arm.minimal-rhel-7-image:     pkgSack = property(fget=lambda self: self._getSacks(),
azure-arm.minimal-rhel-7-image:   File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 778, in _getSacks
azure-arm.minimal-rhel-7-image:     self.repos.populateSack(which=repos)
azure-arm.minimal-rhel-7-image:   File "/usr/lib/python2.7/site-packages/yum/repos.py", line 386, in populateSack
azure-arm.minimal-rhel-7-image:     sack.populate(repo, mdtype, callback, cacheonly)
azure-arm.minimal-rhel-7-image:   File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 263, in populate
azure-arm.minimal-rhel-7-image:     dobj = repo_cache_function(xml, csum)
azure-arm.minimal-rhel-7-image:   File "/usr/lib64/python2.7/site-packages/sqlitecachec.py", line 46, in getPrimary
azure-arm.minimal-rhel-7-image:     self.repoid))
azure-arm.minimal-rhel-7-image: TypeError: Can not create packagename index: database or disk is full'
azure-arm.minimal-rhel-7-image: + grep 'Error: Nothing to do'

==> azure-arm.minimal-rhel-7-image: Provisioning step had errors: Running the cleanup provisioner, if present...

bunchrt commented 2 years ago

I've gone up to 160gb. no dice. used --debug so I could see what's going on inside, and it's clear the partitioning is way too small. // update: I went back to the default instance size (after requesting quota bump from defaults) and it worked fine. Duh, tmpfs is using RAM, not storage. will try again w/ just 32gb.

# failed run w/ 160gb

[root@pkrvmnec3adxp1e ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0  160G  0 disk
├─sda1   8:1    0  500M  0 part
├─sda2   8:2    0  500M  0 part
├─sda3   8:3    0   31G  0 part
└─sda4   8:4    0    2M  0 part
sdb      8:16   0   16G  0 disk
└─sdb1   8:17   0   16G  0 part
sr0     11:0    1  634K  0 rom

[root@pkrvmnec3adxp1e ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        3.9G     0  3.9G   0% /dev
tmpfs           3.9G     0  3.9G   0% /dev/shm
tmpfs           3.9G   18M  3.9G   1% /run
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
none            3.9G  3.9G     0 100% /
tmpfs           783M     0  783M   0% /run/user/1000
lorengordon commented 2 years ago

@bunchrt So this is happening as a result of one of the key "features" of spel that results in extremely clean images, where it first switches the running OS into RAM, and installs updates into that ramfs partition. It then reformats the root volume and performs a clean chroot install to the actual disk.

But that means the builder VM needs a fair amount of memory, because the entire OS will be running there! I believe for our private images we've been using Standard_DS5_v2. The size of the disk is your choice, whatever you want the resulting image to have. I think anything between 20-50GB is pretty reasonable.

bunchrt commented 2 years ago

yup. made a new image w/ measly 32gb. :). figure that's safe, same as the RAM available. thanks!