saltstack / saltstack/salt

Cloud profile settings don't override provider settings

Open
#51,106 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug severity-low
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description of Issue/Question

When using the "location" attribute within AWS, if I specify the "location" attribute in the profile settings and nothing within the provider settings, it defaults to something I don't want. For instance, if I default my profile settings to "location" us-east-2, and nothing in the provider file, I've noticed in the debug output it uses "us-east-1". But only for the password check, for the most part, the creation of a new instance works fine, but when it comes to validating the "auto" generated password from AWS, I notice in the debug output that the URL is being changed. This is reproducible very easily. Basically I have to update the provider file each time I work in different AWS locations because the provider file is taken precedence and/or being ignored from my profiler settings where I declare the "location" value.

Setup

Launching a new instance with no "location" provider value set:
provider file:
aws-cloud:
driver: ec2
id: XXXXXXXXXXXXXXXXXXXXXXXXXXX
key: XXXXXXXXXXXXXXXXXXXXXXXXXX
keyname: brian_keypair
private_key: /opt/salt/brian_keypair.pem
ssh_interface: public_ips

minion:
master: servername.domain.com
win_installer: /srv/salt/win/files/Salt-Minion-2018.3.3-Py3-AMD64-Setup.exe
win_username: Administrator
win_password: auto
use_winrm: True
winrm_use_ssl: True
winrm_verify_ssl: False
userdata_file: /srv/salt/win/scripts/windows-firewall.ps1
userdata_template: jinja
win_deploy_auth_retries: 10
win_deploy_auth_retry_delay: 1

Launch server with this command:
salt-cloud -p ec2-east-test salt-test01

profile file:
ec2-east-test:
provider: aws-cloud
location: us-east-2
image: ami-0170ffc1abff2ebdc
size: t2.medium
network_interfaces:
- DeviceIndex: 0
AssociatePublicIpAddress: True
SubnetId: subnet-08d67c1cadc7f948e
SecurityGroupId:
- sg-0641ea4055e5de2f2
del_root_vol_on_destroy: True
del_all_vol_on_destroy: True
rename_on_destroy: True

debug log output:
[DEBUG ] Waiting for auto-generated Windows EC2 password
[DEBUG ] Using AWS endpoint: ec2.us-east-1.amazonaws.com
[DEBUG ] AWS Request: https://ec2.us-east-1.amazonaws.com/?Action=DescribeInstances&Filter.1.Name=tag%3AName&Filter.1.Value.1=salt-test01&Version=2014-10-01
[DEBUG ] Starting new HTTPS connection (1): ec2.us-east-1.amazonaws.com:443
[DEBUG ] https://ec2.us-east-1.amazonaws.com:443 "GET /?Action=DescribeInstances&Filter.1.Name=tag%3AName&Filter.1.Value.1=salt-test01&Version=2014-10-01 HTTP/1.1" 200 230
[DEBUG ] AWS Response Status Code: 200
[ERROR ] There was a profile error:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/salt/cloud/cli.py", line 281, in run
self.config.get('names')
File "/usr/lib/python2.7/site-packages/salt/cloud/init.py", line 1454, in run_profile
ret[name] = self.create(vm_)
File "/usr/lib/python2.7/site-packages/salt/cloud/init.py", line 1284, in create
output = self.cloudsfunc
File "/usr/lib/python2.7/site-packages/salt/cloud/clouds/ec2.py", line 2705, in create
vm_, data, ip_address, display_ssh_output
File "/usr/lib/python2.7/site-packages/salt/cloud/clouds/ec2.py", line 2333, in wait_for_instance
call='action',
File "/usr/lib/python2.7/site-packages/salt/cloud/clouds/ec2.py", line 4727, in get_password_data
instance_id = _get_node(name)['instanceId']
File "/usr/lib/python2.7/site-packages/salt/cloud/clouds/ec2.py", line 3393, in _get_node
return next(iter(instance_info))
StopIteration

Everything goes through fine until it gets to the password validation, and you can see that the URL changes to something that is not "us-east-2" as I've defined it in my profile settings.

Steps to Reproduce Issue

See above.

Versions Report

(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
Salt Version:
Salt: 2018.3.3

Dependency Versions:
cffi: 1.11.5
cherrypy: Not Installed
dateutil: Not Installed
docker-py: Not Installed
gitdb: 0.6.4
gitpython: 2.1.11
ioflo: Not Installed
Jinja2: 2.7.2
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.19
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: Not Installed
Python: 2.7.5 (default, Oct 30 2018, 23:45:53)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 15.3.0
RAET: Not Installed
smmap: 0.9.0
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.1.4

System Versions:
dist: centos 7.6.1810 Core
locale: UTF-8
machine: x86_64
release: 3.10.0-862.3.2.el7.x86_64
system: Linux
version: CentOS Linux 7.6.1810 Core

Salt Minion is a Windows box, attempting to install latest Python 3 client: Salt-Minion-2018.3.3-Py3-AMD64-Setup.exe

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the Salt 2018.3.3 salt-cloud run using the shown AWS provider and profile configuration, then inspect salt/cloud/clouds/ec2.py, especially wait_for_instance, get_password_data, and _get_node. Compare the endpoint used during instance creation with the endpoint used for password validation. Done means the profile location us-east-2 is respected during password validation and the instance completes successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, python
Domain
cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.