Skip to content

[BUGFIX 60515] - Fix bug when specifying template_source using net.load_template#67715

Merged
dwoz merged 2 commits intosaltstack:masterfrom
stiltzkin10:fix-60515-load-template
Jan 30, 2026
Merged

[BUGFIX 60515] - Fix bug when specifying template_source using net.load_template#67715
dwoz merged 2 commits intosaltstack:masterfrom
stiltzkin10:fix-60515-load-template

Conversation

@stiltzkin10
Copy link
Contributor

@stiltzkin10 stiltzkin10 commented Feb 9, 2025

What does this PR do?

Remove unsued code block that causes the script to fail. It sets the local variables salt_render and file_exists, neither of them is used later in the code.

The code block uses template_name which is not mandatory if the user specifies template_source. If template_name is not set, the code crashes.

What issues does this PR fix or reference?

Fixes #60515

Previous Behavior

$ sudo salt XXXX net.load_template template_source='ntp server 192.168.1.100' test=true
XXXX:
    The minion function caused an exception: Traceback (most recent call last):
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/metaproxy/proxy.py", line 479, in thread_return
        return_data = minion_instance.executors[fname](
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 149, in __call__
        return self.loader.run(run_func, *args, **kwargs)
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1232, in run
        return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1247, in _run_as
        return _func_or_method(*args, **kwargs)
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/executors/direct_call.py", line 10, in execute
        return func(*args, **kwargs)
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 149, in __call__
        return self.loader.run(run_func, *args, **kwargs)
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1232, in run
        return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1247, in _run_as
        return _func_or_method(*args, **kwargs)
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/napalm.py", line 502, in func_wrapper
        ret = func(*args, **kwargs)
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/napalm_network.py", line 1959, in load_template
        salt_render = False
    AttributeError: 'NoneType' object has no attribute 'startswith'

New Behavior

$ sudo salt XXXX net.load_template template_source='ntp server 192.168.1.100' test=true
XXXX:
    ----------
    already_configured:
        False
    comment:
        Configuration discarded.
    diff:
        +ntp server 192.168.1.100
    loaded_config:
    result:
        True

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with GPG?

No

Please review Salt's Contributing Guide for best practices, including the
PR Guidelines.

See GitHub's page on GPG signing for more information about signing commits with GPG.

@stiltzkin10 stiltzkin10 requested a review from a team as a code owner February 9, 2025 09:02
@stiltzkin10 stiltzkin10 changed the title [BUG 60515] - Fix bug when specifying template_source using net.load_template [BUGFIX 60515] - Fix bug when specifying template_source using net.load_template Feb 9, 2025
@stiltzkin10 stiltzkin10 force-pushed the fix-60515-load-template branch from 8c0931a to d43f2bc Compare February 9, 2025 19:05
twangboy
twangboy previously approved these changes Feb 11, 2025
@twangboy twangboy added this to the Argon v3008.0 milestone Feb 11, 2025
@twangboy twangboy added the test:full Run the full test suite label Jul 2, 2025
@welcome
Copy link

welcome bot commented Jan 30, 2026

Congratulations on your first PR being merged! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] napalm: net.load_template does not work

3 participants