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

[FEATURE REQUEST] Run local SLS file automatically on reboot, without going masterless! #58928

Open
evenyougreg opened this issue Nov 11, 2020 · 9 comments
Labels
Feature new functionality including changes to functionality and code refactors, etc. Windows
Projects
Milestone

Comments

@evenyougreg
Copy link

Is your feature request related to a problem? Please describe.

My organization has a backup site failover issue that could be solved with Salt.

When our Windows minions failover to our backup site B, they are first powered down at site A, they then lose their original IP address and get a new one when they are powered back up at site B. In order to get back on the network and reconnect with the master and everything else they need "ipconfig /registerdns" ran.

Describe the solution you'd like

I am aware of masterless mode, but it turns off its ability and duty to talk to the master for instructions entirely, and goes totally headless.

What I need: When the server is powered back on and subsequently the salt agent is started, I need to run a local SLS file that runs "ipconfig /registerdns" with cmd.run, which will restore DNS and finally get everything it needs from the master. So I guess it's kind of a hybrid of local and remote working together?

Describe alternatives you've considered

I've tried different combinations of minion config file changes in hopes that the functionality is hidden in plain site, but I have struck out.

This is just one scenario, but I have many more situations that would benefit from this feature. Or, does it already exist and I'm just not seeing it?

Thanks in advance,

Greg

@evenyougreg evenyougreg added the Feature new functionality including changes to functionality and code refactors, etc. label Nov 11, 2020
@Timbus
Copy link
Contributor

Timbus commented Nov 12, 2020

You can run salt with an alternative config location, -c, in combination with the usual salt-call --local. This would allow you to specify an alternative config for your bootstrap state, as well as your standard config for master mode. Is that what you're looking for?

@evenyougreg
Copy link
Author

evenyougreg commented Nov 12, 2020

It might be, can you give me an example? I've never heard of -c alternate configs.

I just need 1 sls file to run when the server powers back on, regardless of whether or not the minion can talk to the master. So I can't be doing any manual salt-call commands, not sure if that's a part of what you're getting at. It all has to happen automatically.

Thanks again,

Greg

@morsik
Copy link
Contributor

morsik commented Nov 12, 2020

If you need to run such command on startup, then maybe it would be better not to force Salt to run it, but force Salt to configure actual startup script on your system?

@evenyougreg
Copy link
Author

Yes, that is what I'll be doing if I can't find a smooth way for Salt to handle it entirely on its own. Thanks for your input, it reinforces what I am planning as a last resort.

@morsik
Copy link
Contributor

morsik commented Nov 12, 2020

@evenyougreg to be honest, I've never thought of such usecase as yours, since SaltStack is mostly management configuration ;) (apart from other nice stuff of couse) When I wanted to configure something at start of system, I always used Salt to configure startup instead of making Salt of doing things like that. Mainly, because you can't rely on it always because - as you said - master may be unavailable.

But managing startup script seems more Salty than actually executing ipconfig /registerdns alone without any reason (as it looks from the description).

@Timbus
Copy link
Contributor

Timbus commented Nov 13, 2020

I just need 1 sls file to run when the server powers back on, regardless of whether or not the minion can talk to the master. So I can't be doing any manual salt-call commands, not sure if that's a part of what you're getting at. It all has to happen automatically.

Oh okay that's even easier then. You just need to run have the state.sls on your machine, then use state.template:
salt-call --local state.template /path/to/local/state.sls.
The reason I suggested a second config was because I assumed you wanted a more complicated masterless setup, but the above would be good enough for a single state file.

Of course you'll need some way to run this command automatically at startup (perhaps every 'x' minutes is better). I suggest systemd on most linux machines, or the windows scheduled task manager.

@brianthelion
Copy link

@evenyougreg We have a little utility package that we've been working on to support use-cases like this. We're using it pretty aggressively. See https://github.com/f0cal/saltbox

@cmcmarrow
Copy link
Contributor

cmcmarrow commented Dec 7, 2020

@evenyougreg could use the salt module win_task. win_task works with Windows Task Scheduler so you can tell windows to run a ‘salt-call’ every time windows boots back up.

https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.win_task.html

@cmcmarrow cmcmarrow added Question The issue is more of a question rather than a bug or a feature request Windows and removed Feature new functionality including changes to functionality and code refactors, etc. needs-triage labels Dec 7, 2020
@evenyougreg
Copy link
Author

Thanks @cmcmarrow, I appreciate the input. I'm trying to avoid intervention/help outside of Salt software, which is why I was posting as a feature request. Seems like an obvious thing that could be built into Salt.

@xeacott xeacott added this to To do in Windows Jan 11, 2021
@sagetherage sagetherage added this to the Approved milestone Feb 9, 2021
@sagetherage sagetherage added Feature new functionality including changes to functionality and code refactors, etc. and removed Question The issue is more of a question rather than a bug or a feature request labels May 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature new functionality including changes to functionality and code refactors, etc. Windows
Projects
Windows
  
To do
Development

No branches or pull requests

6 participants