How to prevent salt-cloud from upgrading salt-minion to the latest version?
Description of Issue/Question
We run 2016.3 in our production environment b/c we are not ready to upgrade to 2016.11, and we use salt-cloud to provision new Debian Jessie/8 vm's in VMWare. We clone from a template the has 2016.3.4 installed, and we've held the salt-minion & salt-common pkgs in an unsuccessful attempt to prevent them from being upgraded on both our salt-master & template. When we provision new vm's using salt-cloud, it upgrades to version 2016.11. We want to prevent this from happening.
It was recommended that we try using script_args: 'git v2016.3.4' in our salt-cloud configuration. The problem is we dont want to install via git. We want to stick with the debian package, so that is not a good solution for us.
What is the recommended way to accomplish this?
Setup
Our salt-cloud profile config:
feed_servers:
provider: vmware_provider
clonefrom: jessie_template
num_cpus: 2
memory: 1GB
resourcepool: Prod
cluster: Live
datastore: Tier1
folder: Linux_Servers
domain: fqdn.com
template: False
power_on: True
deploy: True
ssh_username: root
password: insecurepassword
devices:
disk:
Hard disk 2:
#name: extra_space
size: 20
thin_provision: True
minion:
master: salt-master.fqdn
startup_states: sls
sls_list:
- cloud.provision
Steps to Reproduce Issue
We provision a new vm using salt-cloud, like so: salt-cloud -p feed_servers new-feed-server.. eventually we see this in the output indicating that it's upgraded salt-minion:
* INFO: Running config_salt()
* INFO: Running install_debian_8_stable()
Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
salt-common
Suggested packages:
python-augeas
The following packages will be upgraded:
salt-common salt-minion
2 upgraded, 0 newly installed, 0 to remove and 17 not upgraded.
Need to get 4,135 kB of archives.
After this operation, 35.8 kB of additional disk space will be used.
Get:1 https://repo.saltstack.com/apt/debian/8/amd64/latest/ jessie/main salt-minion all 2016.11.1+ds-1 [26.5 kB]
Get:2 https://repo.saltstack.com/apt/debian/8/amd64/latest/ jessie/main salt-common all 2016.11.1+ds-1 [4,109 kB]
Reading changelogs...
Fetched 4,135 kB in 1s (3,683 kB/s)
(Reading database ... 34913 files and directories currently installed.)
Preparing to unpack .../salt-minion_2016.11.1+ds-1_all.deb ...
Unpacking salt-minion (2016.11.1+ds-1) over (2016.11.0+ds-1) ...
Preparing to unpack .../salt-common_2016.11.1+ds-1_all.deb ...
Unpacking salt-common (2016.11.1+ds-1) over (2016.11.0+ds-1) ...
Processing triggers for systemd (215-17+deb8u5) ...
Processing triggers for man-db (2.7.0.2-5) ...
Setting up salt-common (2016.11.1+ds-1) ...
Setting up salt-minion (2016.11.1+ds-1) ...
Configuration file '/etc/salt/minion'
==> Modified (by you or by a script) since installation.
==> Package distributor has shipped an updated version.
==> Using current old file as you requested.
* INFO: Running install_debian_check_services()
* INFO: Running install_debian_restart_daemons()
* INFO: Running daemons_running()
Connection to [IP ADDR] closed.
* INFO: Salt installed!
Versions Report
salt-cloud --versions-report
Salt Version:
Salt: 2016.3.4
Dependency Versions:
Apache Libcloud: 0.20.0
cffi: 1.8.3
cherrypy: Not Installed
dateutil: 2.2
gitdb: 0.5.4
gitpython: 0.3.2 RC1
ioflo: Not Installed
Jinja2: 2.7.3
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: Not Installed
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.2
mysql-python: 1.2.3
pycparser: 2.17
pycrypto: 2.6.1
pygit2: Not Installed
Python: 2.7.9 (default, Jun 29 2016, 13:08:31)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 14.4.0
RAET: Not Installed
smmap: 0.8.2
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.0.5
System Versions:
dist: debian 8.6
machine: x86_64
release: 3.16.0-4-amd64
system: Linux
version: debian 8.6
salt-master --versions-report
Salt Version:
Salt: 2016.3.4
Dependency Versions:
cffi: 1.8.3
cherrypy: Not Installed
dateutil: 2.2
gitdb: 0.5.4
gitpython: 0.3.2 RC1
ioflo: Not Installed
Jinja2: 2.7.3
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: Not Installed
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.2
mysql-python: 1.2.3
pycparser: 2.17
pycrypto: 2.6.1
pygit2: Not Installed
Python: 2.7.9 (default, Jun 29 2016, 13:08:31)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 14.4.0
RAET: Not Installed
smmap: 0.8.2
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.0.5
System Versions:
dist: debian 8.6
machine: x86_64
release: 3.16.0-4-amd64
system: Linux
version: debian 8.6
One thing that seems to have worked is making our repo configuration immutable. eg
chattr +i /etc/apt/sources.list.d/saltstack.list
cat /etc/apt/sources.list.d/saltstack.list
deb http://repo.saltstack.com/apt/debian/8/amd64/2016.3 jessie main
Since doing that, salt-cloud appears to have skipped the upgrade...eg
* INFO: Running config_salt()
* INFO: Running install_debian_8_stable()
Reading package lists...
Building dependency tree...
Reading state information...
salt-minion is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
* INFO: Running install_debian_check_services()
* INFO: Running install_debian_restart_daemons()
* INFO: Running daemons_running()
Connection to [IP ADDR] closed.
* INFO: Salt installed!
While this appears to have worked for us, we've had to do quite a bit of forcing it outside of salt. Is there a better way to accomplish this in salt itself?
If salt is already on your images, you should be able to set deploy: True in the provider or profile, and the deploy script will not be run. Unfortunately it will also not deploy any keys, so you would have to accept the minion key with salt-key or the wheel client.
You might be able to just symlink /bin/true to /etc/salt/cloud.deploy.d/bootstrap-salt.sh and it will use that as the bootstrap script, but still generate and copy over minion keys for you.
I've run into this issue as well. Salt version 2017.7.0 has major changes that causes syntax errors with my salt state, so I'm sticking with 2016.11.x for now. I'm provisioning with salt-cloud 2016.11.6, and the 2017 version gets installed on the provisioned server. Is there any way to tell the server to use the correct salt version in the map file?
specify which version to install using script_args
https://docs.saltstack.com/en/latest/topics/cloud/misc.html#deploy-script-arguments https://docs.saltstack.com/en/latest/topics/tutorials/salt_bootstrap.html
script_args: stable 2016.11.6
Otherwise, the newest is installed by default by salt bootstrap.
Thanks, I just added script_args: 'git v2016.11.6' to my provider conf and it's looking good.
I'll try stable instead - looks like that will use the ubuntu package instead of git which would be nice.
@schlagify I just found out that there is a -C option on salt-bootstrap.
-C Only run the configuration function. This option automatically
bypasses any installation.
This will not upgrade the minion if you have them installed already on a golden image, and will only copy the configuration files over from the /tmp file that is specified by -c which salt-cloud does for you.
I am going to close this issue.
Thanks, Daniel