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

Exception "autoinstall_snippets_dir" is required to find snippets for windows #3819

Closed
sergey-ganchuk opened this issue Sep 4, 2024 · 3 comments · Fixed by #3840
Closed
Assignees
Labels
3.3.4 Release 3.3.4 3.3.6 Release 3.3.6 Bug Report Reporting a bug
Milestone

Comments

@sergey-ganchuk
Copy link

sergey-ganchuk commented Sep 4, 2024

Describe the bug

I'm trying to create system based on windows profile.
cobbler sync fails.

message in cobbler log:
"autoinstall_snippets_dir" is required to find snippets

Steps to reproduce

  1. import windows iso: cobbler import --path=/mnt --name=win11
  2. create system linked to win11 profile
  3. run cobbler sync

Expected behavior

cobbler sync should end without error

Cobbler version

Cobbler 3.3.6
  source: df356046, Tue Jul 16 11:51:24 2024 +0200
  build time: Wed Sep  4 07:51:36 2024

Operating system

Distributor ID: Ubuntu
Description: Ubuntu 22.04.3 LTS
Release: 22.04
Codename: jammy

Cobbler log

 "autoinstall_snippets_dir" is required to find snippets
#   File "/usr/local/lib/python3.10/dist-packages/cobbler/templar.py", line 213, in render_cheetah
#     data_out = str(generated_template_class)
#
#   File "/usr/local/lib/python3.10/dist-packages/Cheetah/Template.py", line 1053, in __unicode__
#     return getattr(self, mainMethName)()
#
#   File "cheetah_cobbler.template_api_1725438165_04825_46539.py", line 100, in respond
#
#   File "cheetah_cobbler.template_api_1725438165_04825_46539.py", line 71, in __errorCatcher1
#
#   File "<string>", line 1, in <module>
#
#   File "/usr/local/lib/python3.10/dist-packages/cobbler/template_api.py", line 189, in SNIPPET
#     result = self.BuiltinTemplate.SNIPPET(self, file)
#
#   File "DynamicallyCompiledCheetahTemplate.py", line 87, in SNIPPET
#
#   File "/usr/local/lib/python3.10/dist-packages/cobbler/template_api.py", line 157, in read_snippet
#     raise AttributeError("\"autoinstall_snippets_dir\" is required to find snippets")
#

Screenshots

Additional information

also on version 3.3.4

@sus-admin
Copy link

sus-admin commented Sep 17, 2024

I've come across this error myself using Cobbler 3.3.6 running on Fedora 34 Server, after successfully importing a Windows 10 distro (following the guide here). I'm getting the below error in cobbler.log upon adding a new Windows Cobbler System, or performing a Cobbler sync

# *** ERROR ***
#
# There is a templating error preventing this file from rendering correctly.
#
# This is most likely not due to a bug in Cobbler and is something you can fix.
#
# Look at the message below to see what things are causing problems.
#
# (1) Does the template file reference a $variable that is not defined?
# (2) is there a formatting error in a Cheetah directive?
# (3) Should dollar signs ($) be escaped that are not being escaped?
#
# Try fixing the problem and then investigate to see if this message goes
# away or changes.
#
#
# "autoinstall_snippets_dir" is required to find snippets
#   File "/usr/local/lib/python3.9/site-packages/cobbler/templar.py", line 213, in render_cheetah
#     data_out = str(generated_template_class)
#
#   File "/usr/lib64/python3.9/site-packages/Cheetah/Template.py", line 1053, in __unicode__
#     return getattr(self, mainMethName)()
#
#   File "cheetah_cobbler.template_api_1726589201_6438434_24689.py", line 100, in respond
#
#   File "cheetah_cobbler.template_api_1726589201_6438434_24689.py", line 71, in __errorCatcher1
#
#   File "<string>", line 1, in <module>
#
#   File "/usr/local/lib/python3.9/site-packages/cobbler/template_api.py", line 189, in SNIPPET
#     result = self.BuiltinTemplate.SNIPPET(self, file)
#
#   File "DynamicallyCompiledCheetahTemplate.py", line 87, in SNIPPET
#
#   File "/usr/local/lib/python3.9/site-packages/cobbler/template_api.py", line 157, in read_snippet
#     raise AttributeError("\"autoinstall_snippets_dir\" is required to find snippets")
#

[2024-09-17_120640_Sync_82b6555c1d344536ae32eabb0442def6] 2024-09-17T12:06:42 - INFO | Exception occurred: <class 'cobbler.cexceptions.CX'>
[2024-09-17_120640_Sync_82b6555c1d344536ae32eabb0442def6] 2024-09-17T12:06:42 - INFO | Exception value: 'Error templating file, check cobbler.log for more details'
[2024-09-17_120640_Sync_82b6555c1d344536ae32eabb0442def6] 2024-09-17T12:06:42 - INFO | Exception Info:
  File "/usr/local/lib/python3.9/site-packages/cobbler/utils.py", line 2258, in run
    rc = self._run(self)

  File "/usr/local/lib/python3.9/site-packages/cobbler/remote.py", line 165, in runner
    self.remote.api.sync(self.options.get("verbose", False), what=what)

  File "/usr/local/lib/python3.9/site-packages/cobbler/api.py", line 1596, in sync
    sync_obj.run()

  File "/usr/local/lib/python3.9/site-packages/cobbler/actions/sync.py", line 179, in run
    utils.run_triggers(self.api, None, "/var/lib/cobbler/triggers/sync/post/*")

  File "/usr/local/lib/python3.9/site-packages/cobbler/utils.py", line 1001, in run_triggers
    rc = m.run(api, arglist)

  File "/usr/local/lib/python3.9/site-packages/cobbler/modules/sync_post_wingen.py", line 361, in run
    gen_win_files(distro, autoinstall_meta)

  File "/usr/local/lib/python3.9/site-packages/cobbler/modules/sync_post_wingen.py", line 198, in gen_win_files
    data = templ.render(post_tmpl_data, meta, None)

  File "/usr/local/lib/python3.9/site-packages/cobbler/templar.py", line 117, in render
    data_out = self.render_cheetah(raw_data, search_table)

  File "/usr/local/lib/python3.9/site-packages/cobbler/templar.py", line 220, in render_cheetah
    raise CX("Error templating file, check cobbler.log for more details")

[2024-09-17_120640_Sync_82b6555c1d344536ae32eabb0442def6] 2024-09-17T12:06:42 - ERROR | ### TASK FAILED ###

I've taken a look at template_api.py and concluded that a variable is not set properly in Cobbler's environment. The Variable "autoinstall_snippets_dir" is defined in settings.yaml, but not in windows.settings. I've tried defining the variable in windows.settings file, restarting cobblerd, and running cobbler sync again, but the error persists.

I noticed that the "autoinstall_snippets_dir" defined in settings.yaml has its value UNquoted, whereas variables in windows.settings have their values inside double-qoutes, however, I've tried with and without quotes for that variable in windows.settings file, which did not seem to make any difference.

I've also tried unsetting the "autoinstall" option for the Cobbler Profile to attempt to bypass loading templates/snippets, but this brought no change either. I tried this with and without the "autoinstall_snippets_dir" variable set in windows.settings file (with and without quotes).

Is there another snippets directory that should be installed or created?

I've also taken some steps from here (which may or may not be relevant to Cobbler 3.3.6?) and even though it mentions windows.settings file, I still couldn't get passed this step. Without "cobbler sync" action working, I'm not comfortable proceeding. I also wanted to point out an inconsistency with this guide, and the official docs

For now, I will pursue Windows deployments with the "windows_enabled" option set to "false" in windows.settings, since this error does not arise with Windows disabled in Cobbler, and I'm not trying to do unattended install right now, just PXE boot with manual install.

@SchoolGuy SchoolGuy added 3.3.6 Release 3.3.6 3.3.4 Release 3.3.4 labels Nov 10, 2024
@SchoolGuy
Copy link
Member

@tpw56j Do you have any idea what could cause this?

@tpw56j
Copy link
Contributor

tpw56j commented Nov 10, 2024

@SchoolGuy This is a bug that I forgot to backport to 3.3.

@SchoolGuy SchoolGuy moved this from Todo to In Progress in Cobbler Server Nov 12, 2024
@SchoolGuy SchoolGuy added this to the V3.3.7 milestone Nov 12, 2024
@SchoolGuy SchoolGuy linked a pull request Nov 12, 2024 that will close this issue
12 tasks
@github-project-automation github-project-automation bot moved this from In Progress to Done in Cobbler Server Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.3.4 Release 3.3.4 3.3.6 Release 3.3.6 Bug Report Reporting a bug
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants