cloud roster: Work with custom conf dir

A path to salt-cloud config file is hardcoded into the cloud roster, so
it won't work with custom conf dir. Remove the hardcoded path and
construct it using __opts__['conf_file'].
This commit is contained in:
Sergei Zviagintsev 2017-03-02 14:21:53 +01:00
parent b0501515cb
commit dd1d3aac74

View file

@ -89,7 +89,9 @@ def targets(tgt, tgt_type='glob', **kwargs): # pylint: disable=W0613
'host': preferred_ip,
}
cloud_opts = salt.config.cloud_config('/etc/salt/cloud')
cloud_opts = salt.config.cloud_config(
os.path.join(os.path.dirname(__opts__['conf_file']), 'cloud')
)
ssh_username = salt.utils.cloud.ssh_usernames({}, cloud_opts)
if isinstance(ssh_username, string_types):
ret['tgt']['user'] = ssh_username