salt-cloud provision process creates two keys for minion, one denied
The process of provisioning a minion to EC2 is creating two minion keys. One in denied and the other active. As a result, the minion fails to start which is obviously a show stopper issue.
error output:
running install_egg_info
Removing /usr/lib/python2.7/site-packages/salt-2015.8.1-py2.7.egg-info
Writing /usr/lib/python2.7/site-packages/salt-2015.8.1-py2.7.egg-info
* INFO: Running install_centos_git_post()
* INFO: Running install_centos_check_services()
* INFO: Running install_centos_restart_daemons()
* INFO: Running daemons_running()
* ERROR: salt-minion was not found running
* ERROR: Failed to run daemons_running()!!!
* ERROR: salt-minion was not found running. Pass '-D' to bootstrap-salt.sh when bootstrapping for additional debugging information...
[DEBUG ] n/man1
copying doc/man/salt-ssh.1 -> /usr/share/man/man1
copying doc/man/salt-syndic.1 -> /usr/share/man/man1
copying doc/man/salt-unity.1 -> /usr/share/man/man1
copying doc/man/salt.7 -> /usr/share/man/man7
running install_egg_info
Removing /usr/lib/python2.7/site-packages/salt-2015.8.1-py2.7.egg-info
Writing /usr/lib/python2.7/site-packages/salt-2015.8.1-py2.7.egg-info
* INFO: Running install_centos_git_post()
* INFO: Running install_centos_check_services()
* INFO: Running install_centos_restart_daemons()
* INFO: Running daemons_running()
* ERROR: salt-minion was not found running
* ERROR: Failed to run daemons_running()!!!
* ERROR: salt-minion was not found running. Pass '-D' to bootstrap-salt.sh when bootstrapping for additional debugging information...
Error: There was a profile error: Command 'ssh -t -t -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null -oControlPath=none -oPasswordAuthentication=no -oChallengeResponseAuthentication=no -oPubkeyAuthentication=yes -oKbdInteractiveAuthentication=no -i /srv/etc/.ssh/mykey.pem -p 22 [email protected] \'sudo /tmp/.saltcloud-afd9dbac-8335-400e-9b31-e2a80d3978c6/deploy.sh -c \'"\'"\'/tmp/.saltcloud-afd9dbac-8335-400e-9b31-e2a80d3978c6\'"\'"\' git v2015.8.1\'' failed. Exit code: 1
profile:
base-linux-ec2:
provider: aws-uswest2
availability_zone: us-west-2a
del_root_vol_on_destroy: True
rename_on_destroy: True
image: ami-xxx
ssh_username: centos
script_args: git v2015.8.1
userdata_file: /srv/salt/files/user-data/linux-bootstrap.sh
size: t2.micro
private_key: /srv/etc/.ssh/mykey.pem
keyname:mykey.pem.pub
iam_profile: APIServerRole
network_interfaces:
- DeviceIndex: 0
PublicIpAddresses:
- Primary: True
AssociatePublicIpAddress: False
allocate_new_eip: False
SubnetId: subnet-xxx
SecurityGroupId: sg-xxx
SourceDestCheck: True
tag: {'Monitored': 'Yes', 'Role': 'nat'}
salt master versions:
[root@manage etc]# salt --versions
Salt Version:
Salt: 2015.8.1
Dependency Versions:
Jinja2: 2.7.2
M2Crypto: 0.21.1
Mako: Not Installed
PyYAML: 3.10
PyZMQ: 14.3.1
Python: 2.7.5 (default, Jun 24 2015, 00:41:19)
RAET: Not Installed
Tornado: 4.1
ZMQ: 3.2.5
cffi: 0.8.6
cherrypy: Not Installed
dateutil: Not Installed
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
libnacl: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.6
mysql-python: Not Installed
pycparser: 2.10
pycrypto: 2.6.1
pygit2: 0.21.4
python-gnupg: Not Installed
smmap: Not Installed
timelib: Not Installed
System Versions:
dist: centos 7.1.1503 Core
machine: x86_64
release: 3.10.0-229.14.1.el7.centos.plus.x86_64
system: CentOS Linux 7.1.1503 Core
salt minion versions:
[root@api centos]# salt-call --versions
Salt Version:
Salt: 2015.8.1
Dependency Versions:
Jinja2: 2.7.2
M2Crypto: 0.21.1
Mako: Not Installed
PyYAML: 3.10
PyZMQ: 14.3.1
Python: 2.7.5 (default, Jun 24 2015, 00:41:19)
RAET: Not Installed
Tornado: 4.1
ZMQ: 3.2.5
cffi: Not Installed
cherrypy: Not Installed
dateutil: Not Installed
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
libnacl: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.6
mysql-python: Not Installed
pycparser: Not Installed
pycrypto: 2.6.1
pygit2: Not Installed
python-gnupg: Not Installed
smmap: Not Installed
timelib: Not Installed
System Versions:
dist: centos 7.1.1503 Core
machine: x86_64
release: 3.10.0-229.14.1.el7.x86_64
system: CentOS Linux 7.1.1503 Core
EDIT: added output from salt-key
[root@manage ~]# salt-key
Accepted Keys:
api.0.uswest2a.production
master-minion.uswest2.production
nat.0.uswest2a.production
Denied Keys:
api.0.uswest2a.production
Unaccepted Keys:
Rejected Keys:
EDIT2: adding additional findings regarding installation of pip
I'm finding that this seems to be caused by installation of pip on the minion image.
- base CentOS 7.1 image deployed without error
- installed pip 7.1 and ran 'pip install cli53' and the resulting image fails to deploy, leaving both active and denied keys on master.
EDIT3: some additional info about the minion keys
- Cleared all keys for this target minion before starting another deploy.
- After starting the deploy, did a checksum of the key that is created for the target.
- Deployment process runs and fails
- Ran checksum after the deploy fails and note that the original accepted key has not changed, but there is another key in the denied folder for the same minion target.
[root@manage etc]# cksum pki/minions/api.0.uswest2a.production
1691884919 450 pki/minions/api.0.uswest2a.production
[root@manage etc]# cksum pki/minions/api.0.uswest2a.production
1691884919 450 pki/minions/api.0.uswest2a.production
[root@manage etc]# cksum pki/minions_denied/api.0.uswest2a.production
1596210643 450 pki/minions_denied/api.0.uswest2a.production
[root@manage etc]# salt-key
Accepted Keys:
api.0.uswest2a.production
master-minion.uswest2.production
nat.0.uswest2a.production
Denied Keys:
api.0.uswest2a.production
Unaccepted Keys:
Rejected Keys:
I believe I have found the problem here, which makes no sense whatsoever...
It seems that an upgrade of pip from 7.1 to 7.1.2 allows this to install and run without intervention.
WTF? I agree, that makes no sense. But I guess I'm glad that it works? I don't like problems that seem to disappear for no good reason; they tend to like to come back.
Keep us posted if you see it again.
If you run 'runner.cloud.create' multiple times on the same minion/node, this bug appears. In my case, I have created a reactor that fires when salt-cloud has a cache miss. While debugging I will often times delete the minion keys from the master and remove the salt-cloud cache file. The reactor then fires, and regardless of whether or not I use a deployment script, I get a mixture of accepted, denied, and unaccepted keys.
reactor:
- 'salt/cloud/*/cache_node_new':
- '/srv/reactor/ec2-autoscale.sls'
[root@aws-salt1 ~]# salt-key
Accepted Keys:
syncthegrainsagain
Denied Keys:
syncthegrainsagain
Unaccepted Keys:
syncthegrainsagain
Rejected Keys:
[~]# cksum /etc/salt/pki/master/minions_pre/syncthegrainsagain
3359059719 450 /etc/salt/pki/master/minions_pre/syncthegrainsagain
[~]# cksum /etc/salt/pki/master/minions/syncthegrainsagain
1021715550 450 /etc/salt/pki/master/minions/syncthegrainsagain
[~]# cksum /etc/salt/pki/master/minions_denied/syncthegrainsagain
3359059719 450 /etc/salt/pki/master/minions_denied/syncthegrainsagain
I noticed this behavior. When I did, it turned out to be happening because I wrote a custom deploy script that installed salt-minion before creating the minion keys. This caused salt-cloud to create an approved key followed by salt-master storing a rejected (conflicting) key.
My solution was to make sure I created the minion keys before installing salt-minion.
I don't predict the salt-cloud docs improving in the future, so I'm just gonna leave this here and hope it's helpful for someone someday.
Hello, I'm facing the same issue when deploying CentOS 6.9 VM to vmware (vcenter)... when I deploy a VM with salt-cloud and deploy: True bootstrap-salt.sh run on the deployed VM and fails at end when checking salt-minion on the salt master server I see 2 key entries for the deployed VM but one is on denied Key section.
When I deploy a VM with salt-cloud but with deploy: False, I do not have the minion key on master because salt-minion is not installed on deployed VM. (obviously)
I transfer bootstrap-salt.sh on created VM and then run it : it ends correctly after installing salt-minion with only one accepted key on master
The bootstrap-salt script is the one in /etc/salt/cloud.deploy.d and is the same for the both tests and will manage the key creation and the installation...
And the minion is not already installed (with deploy: False, there is no salt-minion installed)
my pip version is above 7.1 (related above as possible cause)
Salt Cloud version : salt-cloud -V Salt Version: Salt: 2018.3.2
Dependency Versions: Apache Libcloud: 2.0.0 cffi: 1.11.5 cherrypy: 5.6.0 dateutil: Not Installed docker-py: Not Installed gitdb: Not Installed gitpython: Not Installed ioflo: Not Installed Jinja2: 2.8.1 libgit2: Not Installed libnacl: Not Installed M2Crypto: Not Installed Mako: Not Installed msgpack-pure: Not Installed msgpack-python: 0.4.6 mysql-python: Not Installed pycparser: 2.18 pycrypto: 2.6.1 pycryptodome: Not Installed pygit2: Not Installed Python: 2.7.13 (default, Jul 12 2017, 17:32:34) python-gnupg: Not Installed PyYAML: 3.11 PyZMQ: 14.5.0 RAET: Not Installed smmap: Not Installed timelib: Not Installed Tornado: 4.2.1 ZMQ: 4.0.5
System Versions: dist: redhat 6.5 Santiago locale: UTF-8 machine: x86_64 release: 2.6.32-431.el6.x86_64 system: Linux version: Red Hat Enterprise Linux Server 6.5 Santiago
pip version : pip -V pip 10.0.1 from /usr/lib/python2.7/site-packages/pip (python 2.7)