-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
) * OPS-4371 Implemented minimal document module to upload files to 1PW * OPS-4371 Added quotes to 1PW item category * OPS-4371 Added OpenSSL to awx-ee * OPS-4371 Downgraded Terraform to 1.1.4 * OPS-4371 set session shorthand for item plugin * OPS-4371 1Password action plugins now get sessions shorthand from args * OPS-4371 Added session_shorthand to plugin documentation * OPS-4371 Increased Helm and 1PW CLI versions, added dnf upgrade
- Loading branch information
1 parent
95f8ef5
commit 9cd03f1
Showing
15 changed files
with
177 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from __future__ import (absolute_import, division, print_function) | ||
|
||
__metaclass__ = type | ||
|
||
import os | ||
import onepwd | ||
from ansible.plugins.action import ActionBase | ||
from ansible.errors import AnsibleActionFail | ||
|
||
class ActionModule(ActionBase): | ||
def run(self, tmp=None, task_vars=None, **kwargs): | ||
login_secret=onepwd.get_op_login() | ||
session_shorthand=self._task.args.get('session_shorthand', os.getenv('USER')) | ||
session_timeout=kwargs.get('session_timeout', 30) | ||
op = onepwd.OnePwd(secret=login_secret, shorthand=session_shorthand, session_timeout=session_timeout) | ||
|
||
# Input validation | ||
for arg in ['vault', 'name', 'path']: | ||
if arg not in self._task.args: | ||
raise AnsibleActionFail(f"Parameter '{arg}' is required.") | ||
vault = self._task.args.get('vault') | ||
name = self._task.args.get('name') | ||
path = self._task.args.get('path') | ||
check = self._task.check_mode | ||
|
||
if not check: | ||
try: | ||
op.edit_document_from_file(path, name, vault) | ||
except onepwd.UnknownResourceItem: | ||
op.create_document_from_file(path, name, vault) | ||
return {'changed': True} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Dummy module needed by ansible-doc | ||
DOCUMENTATION = r''' | ||
--- | ||
module: item | ||
short_description: Minimal plugin to create 1Password documents | ||
description: | ||
- Create 1Password documents | ||
- Updates the item without checking if it's different | ||
- Will be replaced by the item module when it can be used to upload files | ||
version_added: 2.12.3 | ||
author: DBC SRE Team | ||
options: | ||
vault: | ||
description: | ||
- Vault of the document to create. | ||
type: str | ||
required: yes | ||
name: | ||
description: | ||
- Name of the document to create. | ||
type: str | ||
required: yes | ||
path: | ||
description: | ||
- Path to the file to upload. | ||
type: str | ||
required: yes | ||
session_shorthand: | ||
description: | ||
- Session shorthand used by the 1Password CLI. | ||
- Must be set when running in AWX. | ||
type: str | ||
default: the USER environment variable | ||
''' | ||
|
||
EXAMPLES = r''' | ||
- name: Create Document | ||
dbildungscloud.onepwd.document: | ||
vault: "vault" | ||
name: "name" | ||
path: /path/to/file | ||
''' | ||
|
||
RETURN = r''' | ||
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters