1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Port vault-keyring.py to properly load the config. Fixes #31304 (#31315)

This commit is contained in:
Matt Martz 2017-10-13 12:46:24 -05:00 committed by Adrian Likins
parent ecee475a3a
commit e2f16cfaf7

View file

@ -65,20 +65,20 @@ import sys
import getpass import getpass
import keyring import keyring
import ansible.constants as C from ansible.config.manager import ConfigManager, get_ini_config_value
def main(): def main():
(parser, config_path) = C.load_config_file() config = ConfigManager()
if parser.has_option('vault', 'username'): username = get_ini_config_value(
username = parser.get('vault', 'username') config._parser,
else: dict(section='vault', key='username')
username = getpass.getuser() ) or getpass.getuser()
if parser.has_option('vault', 'keyname'): keyname = get_ini_config_value(
keyname = parser.get('vault', 'keyname') config._parser,
else: dict(section='vault', key='keyname')
keyname = 'ansible' ) or 'ansible'
if len(sys.argv) == 2 and sys.argv[1] == 'set': if len(sys.argv) == 2 and sys.argv[1] == 'set':
intro = 'Storing password in "{}" user keyring using key name: {}\n' intro = 'Storing password in "{}" user keyring using key name: {}\n'