mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Ensure EC2 configuration check is correct
This commit is contained in:
parent
5a32664efd
commit
421f1fde1e
1 changed files with 7 additions and 5 deletions
|
@ -188,26 +188,28 @@ def __virtual__():
|
|||
return False
|
||||
|
||||
for provider, details in six.iteritems(__opts__['providers']):
|
||||
if 'provider' not in details or details['provider'] != 'ec2':
|
||||
if 'ec2' not in details:
|
||||
continue
|
||||
|
||||
if not os.path.exists(details['private_key']):
|
||||
parameters = details['ec2']
|
||||
|
||||
if not os.path.exists(parameters['private_key']):
|
||||
raise SaltCloudException(
|
||||
'The EC2 key file {0!r} used in the {1!r} provider '
|
||||
'configuration does not exist\n'.format(
|
||||
details['private_key'],
|
||||
parameters['private_key'],
|
||||
provider
|
||||
)
|
||||
)
|
||||
|
||||
keymode = str(
|
||||
oct(stat.S_IMODE(os.stat(details['private_key']).st_mode))
|
||||
oct(stat.S_IMODE(os.stat(parameters['private_key']).st_mode))
|
||||
)
|
||||
if keymode not in ('0400', '0600'):
|
||||
raise SaltCloudException(
|
||||
'The EC2 key file {0!r} used in the {1!r} provider '
|
||||
'configuration needs to be set to mode 0400 or 0600\n'.format(
|
||||
details['private_key'],
|
||||
parameters['private_key'],
|
||||
provider
|
||||
)
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue