Question: How to correctly update hosts in saltstack?

**cmd.run "apt update && apt upgrade -y"**

sometimes asks confirmation to overwrite config files with new version, how automatically preserve the current config file? "**Y/N**"

or

there are better way to update entire system via salt-stack?

Answer: 
There is the [pkg module](https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.pkg.html). Use it like that:

```
salt '*' pkg.upgrade --refresh=True

```
You can use the pkg.upgrade module, or you could schedule a pkg.uptodate state.

<https://docs.saltstack.com/en/latest/ref/states/all/salt.states.pkg.html#salt.states.pkg.uptodate>

And use the salt scheduler to run it periodically.

<https://docs.saltstack.com/en/latest/topics/jobs/#scheduling-jobs>