mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-06 20:17:15 +00:00
* Get first found configuration file
There are three valid places to get the configuration.
https://developer.1password.com/docs/cli/about-biometric-unlock#remove-old-account-information
* Use common config class
* Add changelog fragment
* Explicitly use new style classes for Python 2.7 compatibility
This shouldn’t matter for lookups, but does matter for module_utils
and modules since Python 2.7 is still supported on the managed node.
* Update changelogs/fragments/4065-onepassword-config.yml
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 9e1af2d1bc)
Co-authored-by: Sam Doran <github@samdoran.com>
This commit is contained in:
parent
5759688b0f
commit
4ed3fa9a73
4 changed files with 44 additions and 7 deletions
|
|
@ -166,6 +166,8 @@ from subprocess import Popen, PIPE
|
|||
from ansible.module_utils.common.text.converters import to_bytes, to_native
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
from ansible_collections.community.general.plugins.module_utils.onepassword import OnePasswordConfig
|
||||
|
||||
|
||||
class AnsibleModuleError(Exception):
|
||||
def __init__(self, results):
|
||||
|
|
@ -179,7 +181,6 @@ class OnePasswordInfo(object):
|
|||
|
||||
def __init__(self):
|
||||
self.cli_path = module.params.get('cli_path')
|
||||
self.config_file_path = '~/.op/config'
|
||||
self.auto_login = module.params.get('auto_login')
|
||||
self.logged_in = False
|
||||
self.token = None
|
||||
|
|
@ -187,6 +188,8 @@ class OnePasswordInfo(object):
|
|||
terms = module.params.get('search_terms')
|
||||
self.terms = self.parse_search_terms(terms)
|
||||
|
||||
self._config = OnePasswordConfig()
|
||||
|
||||
def _run(self, args, expected_rc=0, command_input=None, ignore_errors=False):
|
||||
if self.token:
|
||||
# Adds the session token to all commands if we're logged in.
|
||||
|
|
@ -299,7 +302,7 @@ class OnePasswordInfo(object):
|
|||
|
||||
def get_token(self):
|
||||
# If the config file exists, assume an initial signin has taken place and try basic sign in
|
||||
if os.path.isfile(self.config_file_path):
|
||||
if os.path.isfile(self._config.config_file_path):
|
||||
|
||||
if self.auto_login is not None:
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue