Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building custom RHEL Based images will fail if make is not used #197

Closed
GR360RY opened this issue Jan 29, 2024 · 2 comments
Closed

Building custom RHEL Based images will fail if make is not used #197

GR360RY opened this issue Jan 29, 2024 · 2 comments
Labels
enhancement New feature or request triaged Triaged to be addressed in a given cycle

Comments

@GR360RY
Copy link
Contributor

GR360RY commented Jan 29, 2024

Issue Description

As stated in the centos7/README.md file, the image can be build just with packer and without using make:

Alternatively you can manually run packer. Your current working directory must
be in packer-maas/centos7, where this file is located. Once in
packer-maas/centos7 you can generate an image with:

packer init
PACKER_LOG=1 packer build .

This will result in a failed build as anaconda cannot fetch the kickstart file:

[    8.612448] dracut-initqueue[710]: % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
[    8.616439] dracut-initqueue[710]: Dload  Upload   Total   Spent    Left  Speed
[    8.620850] dracut-initqueue[710]: 0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
[    8.626626] dracut-initqueue[710]: curl: (22) The requested URL returned error: 404 Not Found
[    8.630240] dracut-initqueue[710]: Warning: anaconda: failed to fetch kickstart from http://10.0.2.2:8536/centos7.ks

When starting a build process with make, the http/centos7.ks is generated by make, hence the build finishes successfully.
Below is the code snippet from the Makefile:

http/centos7.ks: http/centos7.ks.in
	envsubst '$${KS_PROXY} $${KS_OS_REPOS} $${KS_UPDATES_REPOS} $${KS_EXTRA_REPOS}' < $< | tee $@

This happens with the rest of the RHEL based distros as far as I checked.

Proposal

Instead of using make to substitute strings in a http/centos7.ks.in and generate a new http/centos7.ks, use templatefile hcl function together with http_content

See more details in this blog post: Using Template Files with HashiCorp Packer

Pros

  • Eliminate dependence on Make
  • Move default mirror definitions from the Makefile to packer hcl template for better visibility.
  • Provide a groundwork for integrating with custom provisioners
  • Use better templating engine than make (Hashicorp templates) for kickstart files.

Please see example changes for centos7 in the fork: https://github.com/canonical/packer-maas/compare/main...GR360RY:packer-maas:packer_refactor_ks_generation?expand=1

I will be happy to provide a PR for all distributions if this is something you are willing to consider.

@alexsander-souza
Copy link
Contributor

Hi, I think this solution is much cleaner than the existing one. We would certainly consider this move if you are willing to provide PRs.

If you do, please create a PR for each distro, let's avoid one massive PR as this is hard to review.

@alexsander-souza alexsander-souza added enhancement New feature or request triaged Triaged to be addressed in a given cycle labels Jan 29, 2024
@GR360RY
Copy link
Contributor Author

GR360RY commented Jan 29, 2024

@alexsander-souza and @jurekh , the PR for CentOS 7 is ready. Please review and consider. I will continue with the reset of the distributions when this one is reviewed/commented on and merged.

alexsander-souza pushed a commit that referenced this issue Jan 29, 2024
Refactor CentOS 7 Packer templates.

Relates to #197.
alexsander-souza pushed a commit that referenced this issue Feb 1, 2024
Relates to #197 

Remove reliance on make when building the Rocky 8 image.
alexsander-souza added a commit that referenced this issue Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triaged Triaged to be addressed in a given cycle
Projects
None yet
Development

No branches or pull requests

2 participants