diff --git a/changelogs/fragments/2735-onepassword-add_domain_option.yml b/changelogs/fragments/2735-onepassword-add_domain_option.yml new file mode 100644 index 0000000000..eef74439ce --- /dev/null +++ b/changelogs/fragments/2735-onepassword-add_domain_option.yml @@ -0,0 +1,3 @@ +--- +minor_changes: + - onepassword lookup plugin - add ``domain`` option (https://github.com/ansible-collections/community.general/issues/2734). diff --git a/plugins/lookup/onepassword.py b/plugins/lookup/onepassword.py index a2346ed072..715c337ffd 100644 --- a/plugins/lookup/onepassword.py +++ b/plugins/lookup/onepassword.py @@ -30,6 +30,11 @@ DOCUMENTATION = ''' aliases: ['vault_password'] section: description: Item section containing the field to retrieve (case-insensitive). If absent will return first match from any section. + domain: + description: Domain of 1Password. Default is U(1password.com). + version_added: 3.2.0 + default: '1password.com' + type: str subdomain: description: The 1Password subdomain to authenticate against. username: @@ -109,6 +114,7 @@ class OnePass(object): self.logged_in = False self.token = None self.subdomain = None + self.domain = None self.username = None self.secret_key = None self.master_password = None @@ -168,7 +174,7 @@ class OnePass(object): args = [ 'signin', - '{0}.1password.com'.format(self.subdomain), + '{0}.{1}'.format(self.subdomain, self.domain), to_bytes(self.username), to_bytes(self.secret_key), '--output=raw', @@ -265,6 +271,7 @@ class LookupModule(LookupBase): section = kwargs.get('section') vault = kwargs.get('vault') op.subdomain = kwargs.get('subdomain') + op.domain = kwargs.get('domain', '1password.com') op.username = kwargs.get('username') op.secret_key = kwargs.get('secret_key') op.master_password = kwargs.get('master_password', kwargs.get('vault_password'))