From 6cd8de9cfdbd960f5209a6ba9977622365884eaa Mon Sep 17 00:00:00 2001 From: Vladislav Korenkov Date: Mon, 12 Dec 2022 15:47:50 +1000 Subject: [PATCH] Fix: Execution with ssh key in inventory not works Closes: polemarch/ce#306+ --- doc/api_schema.yaml | 1768 +++++++++++++++++----------------- polemarch/__init__.py | 2 +- polemarch/plugins/ansible.py | 5 +- tests.py | 75 +- 4 files changed, 960 insertions(+), 890 deletions(-) diff --git a/doc/api_schema.yaml b/doc/api_schema.yaml index 3f7b4454..dc597802 100644 --- a/doc/api_schema.yaml +++ b/doc/api_schema.yaml @@ -24,9 +24,9 @@ info: url: https://gitlab.com/vstconsulting/polemarch.git Request: - name: Question - url: https://gitlab.com/vstconsulting/polemarch/issues/new?issuable_template%5D=Ask&issue%5Btitle%5D=Ask%20about%20version%202.1.2 + url: https://gitlab.com/vstconsulting/polemarch/issues/new?issuable_template%5D=Ask&issue%5Btitle%5D=Ask%20about%20version%202.2.0 - name: Bug report - url: https://gitlab.com/vstconsulting/polemarch/issues/new?issuable_template%5D=Bug&issue%5Btitle%5D=Bug%20in%20version%202.1.2 + url: https://gitlab.com/vstconsulting/polemarch/issues/new?issuable_template%5D=Bug&issue%5Btitle%5D=Bug%20in%20version%202.2.0 - name: Feature request url: https://gitlab.com/vstconsulting/polemarch/issues/new?issuable_template%5D=Feature%20request&issue%5Btitle%5D= x-menu: @@ -67,9 +67,9 @@ info: login_url: /account/login/ x-subscriptions-prefix: polemarch.update x-versions: - application: 2.1.2 - library: 2.1.2 - vstutils: 5.1.10 + application: 2.2.0 + library: 2.2.0 + vstutils: 5.1.11 django: 3.2.16 djangorestframework: 3.14.0 drf_yasg: 1.21.4 @@ -11455,14 +11455,11 @@ definitions: usePrefetch: true value_field: name view_field: path - args: - title: Args - description: host pattern - type: string - background: - title: Background - description: run asynchronously, failing after X seconds (default=N/A) + verbose: + title: Verbose + description: verbose mode (-vvv for more, -vvvv to enable connection debugging) type: integer + maximum: 4 become: title: Become description: run operations with become (does not imply password prompting) @@ -11472,57 +11469,36 @@ definitions: description: privilege escalation method to use (default=sudo), use `ansible-doc -t become -l` to list valid choices. type: string - check: - title: Check - description: don't make any changes; instead, try to predict some of the changes - that may occur - type: boolean - connection: - title: Connection - description: connection type to use (default=smart) - type: string - diff: - title: Diff - description: when changing (small) files and templates, show the differences - in those files; works great with --check - type: boolean - extra_vars: - title: Extra vars - description: set additional variables as key=value or YAML/JSON, if filename - prepend with @ - type: string - forks: - title: Forks - description: specify number of parallel processes to use (default=5) - type: integer inventory: title: Inventory description: specify inventory host path or comma separated host list. --inventory-file is deprecated type: string format: inventory - limit: - title: Limit - description: further limit selected hosts to an additional pattern - type: string list_hosts: title: List hosts description: outputs a list of matching hosts; does not execute anything else type: boolean - one_line: - title: One line - description: condense output - type: boolean - playbook_dir: - title: Playbook dir - description: Since this tool does not use playbooks, use this as a substitute - playbook directory.This sets the relative path for many features including - roles/ group_vars/ etc. + limit: + title: Limit + description: further limit selected hosts to an additional pattern type: string poll: title: Poll description: set the poll interval if using -B (default=15) type: integer + background: + title: Background + description: run asynchronously, failing after X seconds (default=N/A) + type: integer + one_line: + title: One line + description: condense output + type: boolean + tree: + title: Tree + description: log output to this directory + type: string private_key: title: Private key description: use this file to authenticate the connection @@ -11531,37 +11507,52 @@ definitions: x-options: media_types: - '*/*' - scp_extra_args: - title: Scp extra args - description: specify extra arguments to pass to scp only (e.g. -l) + user: + title: User + description: connect as this user (default=None) type: string - sftp_extra_args: - title: Sftp extra args - description: specify extra arguments to pass to sftp only (e.g. -f, -l) + connection: + title: Connection + description: connection type to use (default=smart) type: string + timeout: + title: Timeout + description: override the connection timeout in seconds (default=10) + type: integer ssh_common_args: title: Ssh common args description: specify common arguments to pass to sftp/scp/ssh (e.g. ProxyCommand) type: string + sftp_extra_args: + title: Sftp extra args + description: specify extra arguments to pass to sftp only (e.g. -f, -l) + type: string + scp_extra_args: + title: Scp extra args + description: specify extra arguments to pass to scp only (e.g. -l) + type: string ssh_extra_args: title: Ssh extra args description: specify extra arguments to pass to ssh only (e.g. -R) type: string + check: + title: Check + description: don't make any changes; instead, try to predict some of the changes + that may occur + type: boolean syntax_check: title: Syntax check description: perform a syntax check on the playbook, but do not execute it type: boolean - timeout: - title: Timeout - description: override the connection timeout in seconds (default=10) - type: integer - tree: - title: Tree - description: log output to this directory - type: string - user: - title: User - description: connect as this user (default=None) + diff: + title: Diff + description: when changing (small) files and templates, show the differences + in those files; works great with --check + type: boolean + extra_vars: + title: Extra vars + description: set additional variables as key=value or YAML/JSON, if filename + prepend with @ type: string vault_password_file: title: Vault password file @@ -11571,11 +11562,20 @@ definitions: x-options: media_types: - '*/*' - verbose: - title: Verbose - description: verbose mode (-vvv for more, -vvvv to enable connection debugging) + forks: + title: Forks + description: specify number of parallel processes to use (default=5) type: integer - maximum: 4 + playbook_dir: + title: Playbook dir + description: Since this tool does not use playbooks, use this as a substitute + playbook directory.This sets the relative path for many features including + roles/ group_vars/ etc. + type: string + args: + title: Args + description: host pattern + type: string group: title: Group type: string @@ -11583,34 +11583,34 @@ definitions: x-properties-groups: '': - module - - args - - background + - verbose - become - become_method - - check - - connection - - diff - - extra_vars - - forks - inventory - - limit - list_hosts - - one_line - - playbook_dir + - limit - poll + - background + - one_line + - tree - private_key - - scp_extra_args - - sftp_extra_args + - user + - connection + - timeout - ssh_common_args + - sftp_extra_args + - scp_extra_args - ssh_extra_args + - check - syntax_check - - timeout - - tree - - user + - diff + - extra_vars - vault_password_file - - verbose + - forks + - playbook_dir + - args - group - x-view-field-name: args + x-view-field-name: verbose ExecuteResponse: required: - detail @@ -11654,10 +11654,55 @@ definitions: usePrefetch: true value_field: playbook view_field: name - args: - title: Args - description: Playbook(s) + verbose: + title: Verbose + description: verbose mode (-vvv for more, -vvvv to enable connection debugging) + type: integer + maximum: 4 + private_key: + title: Private key + description: use this file to authenticate the connection + type: string + format: secretfile + x-options: + media_types: + - '*/*' + user: + title: User + description: connect as this user (default=None) + type: string + connection: + title: Connection + description: connection type to use (default=smart) + type: string + timeout: + title: Timeout + description: override the connection timeout in seconds (default=10) + type: integer + ssh_common_args: + title: Ssh common args + description: specify common arguments to pass to sftp/scp/ssh (e.g. ProxyCommand) + type: string + sftp_extra_args: + title: Sftp extra args + description: specify extra arguments to pass to sftp only (e.g. -f, -l) + type: string + scp_extra_args: + title: Scp extra args + description: specify extra arguments to pass to scp only (e.g. -l) + type: string + ssh_extra_args: + title: Ssh extra args + description: specify extra arguments to pass to ssh only (e.g. -R) type: string + force_handlers: + title: Force handlers + description: run handlers even if a task fails + type: boolean + flush_cache: + title: Flush cache + description: clear the fact cache for every host in inventory + type: boolean become: title: Become description: run operations with become (does not imply password prompting) @@ -11667,110 +11712,46 @@ definitions: description: privilege escalation method to use (default=sudo), use `ansible-doc -t become -l` to list valid choices. type: string + tags: + title: Tags + description: only run plays and tasks tagged with these values + type: string + skip_tags: + title: Skip tags + description: only run plays and tasks whose tags do not match these values + type: string check: title: Check description: don't make any changes; instead, try to predict some of the changes that may occur type: boolean - connection: - title: Connection - description: connection type to use (default=smart) - type: string + syntax_check: + title: Syntax check + description: perform a syntax check on the playbook, but do not execute it + type: boolean diff: title: Diff description: when changing (small) files and templates, show the differences in those files; works great with --check type: boolean - extra_vars: - title: Extra vars - description: set additional variables as key=value or YAML/JSON, if filename - prepend with @ - type: string - flush_cache: - title: Flush cache - description: clear the fact cache for every host in inventory - type: boolean - force_handlers: - title: Force handlers - description: run handlers even if a task fails - type: boolean - forks: - title: Forks - description: specify number of parallel processes to use (default=5) - type: integer inventory: title: Inventory description: specify inventory host path or comma separated host list. --inventory-file is deprecated type: string format: inventory - limit: - title: Limit - description: further limit selected hosts to an additional pattern - type: string list_hosts: title: List hosts description: outputs a list of matching hosts; does not execute anything else type: boolean - list_tags: - title: List tags - description: list all available tags - type: boolean - list_tasks: - title: List tasks - description: list all tasks that would be executed - type: boolean - private_key: - title: Private key - description: use this file to authenticate the connection - type: string - format: secretfile - x-options: - media_types: - - '*/*' - scp_extra_args: - title: Scp extra args - description: specify extra arguments to pass to scp only (e.g. -l) - type: string - sftp_extra_args: - title: Sftp extra args - description: specify extra arguments to pass to sftp only (e.g. -f, -l) - type: string - skip_tags: - title: Skip tags - description: only run plays and tasks whose tags do not match these values - type: string - ssh_common_args: - title: Ssh common args - description: specify common arguments to pass to sftp/scp/ssh (e.g. ProxyCommand) - type: string - ssh_extra_args: - title: Ssh extra args - description: specify extra arguments to pass to ssh only (e.g. -R) - type: string - start_at_task: - title: Start at task - description: start the playbook at the task matching this name - type: string - step: - title: Step - description: 'one-step-at-a-time: confirm each task before running' - type: boolean - syntax_check: - title: Syntax check - description: perform a syntax check on the playbook, but do not execute it - type: boolean - tags: - title: Tags - description: only run plays and tasks tagged with these values + limit: + title: Limit + description: further limit selected hosts to an additional pattern type: string - timeout: - title: Timeout - description: override the connection timeout in seconds (default=10) - type: integer - user: - title: User - description: connect as this user (default=None) + extra_vars: + title: Extra vars + description: set additional variables as key=value or YAML/JSON, if filename + prepend with @ type: string vault_password_file: title: Vault password file @@ -11780,44 +11761,63 @@ definitions: x-options: media_types: - '*/*' - verbose: - title: Verbose - description: verbose mode (-vvv for more, -vvvv to enable connection debugging) + forks: + title: Forks + description: specify number of parallel processes to use (default=5) type: integer - maximum: 4 + list_tasks: + title: List tasks + description: list all tasks that would be executed + type: boolean + list_tags: + title: List tags + description: list all available tags + type: boolean + step: + title: Step + description: 'one-step-at-a-time: confirm each task before running' + type: boolean + start_at_task: + title: Start at task + description: start the playbook at the task matching this name + type: string + args: + title: Args + description: Playbook(s) + type: string x-properties-groups: '': - playbook - - args + - verbose + - private_key + - user + - connection + - timeout + - ssh_common_args + - sftp_extra_args + - scp_extra_args + - ssh_extra_args + - force_handlers + - flush_cache - become - become_method + - tags + - skip_tags - check - - connection + - syntax_check - diff - - extra_vars - - flush_cache - - force_handlers - - forks - inventory - - limit - list_hosts - - list_tags + - limit + - extra_vars + - vault_password_file + - forks - list_tasks - - private_key - - scp_extra_args - - sftp_extra_args - - skip_tags - - ssh_common_args - - ssh_extra_args - - start_at_task + - list_tags - step - - syntax_check - - tags - - timeout - - user - - vault_password_file - - verbose - x-view-field-name: args + - start_at_task + - args + x-view-field-name: verbose ExecutionTemplate: required: - name @@ -11920,10 +11920,12 @@ definitions: vars: type: object properties: - background: - title: Background - description: run asynchronously, failing after X seconds (default=N/A) + verbose: + title: Verbose + description: verbose mode (-vvv for more, -vvvv to enable connection + debugging) type: integer + maximum: 4 become: title: Become description: run operations with become (does not imply password @@ -11934,52 +11936,31 @@ definitions: description: privilege escalation method to use (default=sudo), use `ansible-doc -t become -l` to list valid choices. type: string - check: - title: Check - description: don't make any changes; instead, try to predict - some of the changes that may occur - type: boolean - connection: - title: Connection - description: connection type to use (default=smart) - type: string - diff: - title: Diff - description: when changing (small) files and templates, show - the differences in those files; works great with --check - type: boolean - extra_vars: - title: Extra vars - description: set additional variables as key=value or YAML/JSON, - if filename prepend with @ - type: string - forks: - title: Forks - description: specify number of parallel processes to use (default=5) - type: integer - limit: - title: Limit - description: further limit selected hosts to an additional pattern - type: string list_hosts: title: List hosts description: outputs a list of matching hosts; does not execute anything else type: boolean - one_line: - title: One line - description: condense output - type: boolean - playbook_dir: - title: Playbook dir - description: Since this tool does not use playbooks, use this - as a substitute playbook directory.This sets the relative - path for many features including roles/ group_vars/ etc. + limit: + title: Limit + description: further limit selected hosts to an additional pattern type: string poll: title: Poll description: set the poll interval if using -B (default=15) type: integer + background: + title: Background + description: run asynchronously, failing after X seconds (default=N/A) + type: integer + one_line: + title: One line + description: condense output + type: boolean + tree: + title: Tree + description: log output to this directory + type: string private_key: title: Private key description: use this file to authenticate the connection @@ -11988,42 +11969,57 @@ definitions: x-options: media_types: - '*/*' - scp_extra_args: - title: Scp extra args - description: specify extra arguments to pass to scp only (e.g. - -l) + user: + title: User + description: connect as this user (default=None) type: string - sftp_extra_args: - title: Sftp extra args - description: specify extra arguments to pass to sftp only (e.g. - -f, -l) + connection: + title: Connection + description: connection type to use (default=smart) type: string + timeout: + title: Timeout + description: override the connection timeout in seconds (default=10) + type: integer ssh_common_args: title: Ssh common args description: specify common arguments to pass to sftp/scp/ssh (e.g. ProxyCommand) type: string + sftp_extra_args: + title: Sftp extra args + description: specify extra arguments to pass to sftp only (e.g. + -f, -l) + type: string + scp_extra_args: + title: Scp extra args + description: specify extra arguments to pass to scp only (e.g. + -l) + type: string ssh_extra_args: title: Ssh extra args description: specify extra arguments to pass to ssh only (e.g. -R) type: string + check: + title: Check + description: don't make any changes; instead, try to predict + some of the changes that may occur + type: boolean syntax_check: title: Syntax check description: perform a syntax check on the playbook, but do not execute it type: boolean - timeout: - title: Timeout - description: override the connection timeout in seconds (default=10) - type: integer - tree: - title: Tree - description: log output to this directory - type: string - user: - title: User - description: connect as this user (default=None) + diff: + title: Diff + description: when changing (small) files and templates, show + the differences in those files; works great with --check + type: boolean + extra_vars: + title: Extra vars + description: set additional variables as key=value or YAML/JSON, + if filename prepend with @ type: string vault_password_file: title: Vault password file @@ -12033,12 +12029,16 @@ definitions: x-options: media_types: - '*/*' - verbose: - title: Verbose - description: verbose mode (-vvv for more, -vvvv to enable connection - debugging) + forks: + title: Forks + description: specify number of parallel processes to use (default=5) type: integer - maximum: 4 + playbook_dir: + title: Playbook dir + description: Since this tool does not use playbooks, use this + as a substitute playbook directory.This sets the relative + path for many features including roles/ group_vars/ etc. + type: string Task: required: - playbook @@ -12057,10 +12057,60 @@ definitions: vars: type: object properties: - args: - title: Args - description: Playbook(s) - type: string + verbose: + title: Verbose + description: verbose mode (-vvv for more, -vvvv to enable connection + debugging) + type: integer + maximum: 4 + private_key: + title: Private key + description: use this file to authenticate the connection + type: string + format: secretfile + x-options: + media_types: + - '*/*' + user: + title: User + description: connect as this user (default=None) + type: string + connection: + title: Connection + description: connection type to use (default=smart) + type: string + timeout: + title: Timeout + description: override the connection timeout in seconds (default=10) + type: integer + ssh_common_args: + title: Ssh common args + description: specify common arguments to pass to sftp/scp/ssh + (e.g. ProxyCommand) + type: string + sftp_extra_args: + title: Sftp extra args + description: specify extra arguments to pass to sftp only (e.g. + -f, -l) + type: string + scp_extra_args: + title: Scp extra args + description: specify extra arguments to pass to scp only (e.g. + -l) + type: string + ssh_extra_args: + title: Ssh extra args + description: specify extra arguments to pass to ssh only (e.g. + -R) + type: string + force_handlers: + title: Force handlers + description: run handlers even if a task fails + type: boolean + flush_cache: + title: Flush cache + description: clear the fact cache for every host in inventory + type: boolean become: title: Become description: run operations with become (does not imply password @@ -12071,126 +12121,76 @@ definitions: description: privilege escalation method to use (default=sudo), use `ansible-doc -t become -l` to list valid choices. type: string + tags: + title: Tags + description: only run plays and tasks tagged with these values + type: string + skip_tags: + title: Skip tags + description: only run plays and tasks whose tags do not match + these values + type: string check: title: Check description: don't make any changes; instead, try to predict some of the changes that may occur type: boolean - connection: - title: Connection - description: connection type to use (default=smart) - type: string + syntax_check: + title: Syntax check + description: perform a syntax check on the playbook, but do + not execute it + type: boolean diff: title: Diff description: when changing (small) files and templates, show the differences in those files; works great with --check type: boolean + list_hosts: + title: List hosts + description: outputs a list of matching hosts; does not execute + anything else + type: boolean + limit: + title: Limit + description: further limit selected hosts to an additional pattern + type: string extra_vars: title: Extra vars description: set additional variables as key=value or YAML/JSON, if filename prepend with @ type: string - flush_cache: - title: Flush cache - description: clear the fact cache for every host in inventory - type: boolean - force_handlers: - title: Force handlers - description: run handlers even if a task fails - type: boolean + vault_password_file: + title: Vault password file + description: vault password file + type: string + format: secretfile + x-options: + media_types: + - '*/*' forks: title: Forks description: specify number of parallel processes to use (default=5) type: integer - limit: - title: Limit - description: further limit selected hosts to an additional pattern - type: string - list_hosts: - title: List hosts - description: outputs a list of matching hosts; does not execute - anything else + list_tasks: + title: List tasks + description: list all tasks that would be executed type: boolean list_tags: title: List tags description: list all available tags type: boolean - list_tasks: - title: List tasks - description: list all tasks that would be executed - type: boolean - private_key: - title: Private key - description: use this file to authenticate the connection - type: string - format: secretfile - x-options: - media_types: - - '*/*' - scp_extra_args: - title: Scp extra args - description: specify extra arguments to pass to scp only (e.g. - -l) - type: string - sftp_extra_args: - title: Sftp extra args - description: specify extra arguments to pass to sftp only (e.g. - -f, -l) - type: string - skip_tags: - title: Skip tags - description: only run plays and tasks whose tags do not match - these values - type: string - ssh_common_args: - title: Ssh common args - description: specify common arguments to pass to sftp/scp/ssh - (e.g. ProxyCommand) - type: string - ssh_extra_args: - title: Ssh extra args - description: specify extra arguments to pass to ssh only (e.g. - -R) - type: string - start_at_task: - title: Start at task - description: start the playbook at the task matching this name - type: string step: title: Step description: 'one-step-at-a-time: confirm each task before running' type: boolean - syntax_check: - title: Syntax check - description: perform a syntax check on the playbook, but do - not execute it - type: boolean - tags: - title: Tags - description: only run plays and tasks tagged with these values - type: string - timeout: - title: Timeout - description: override the connection timeout in seconds (default=10) - type: integer - user: - title: User - description: connect as this user (default=None) + start_at_task: + title: Start at task + description: start the playbook at the task matching this name type: string - vault_password_file: - title: Vault password file - description: vault password file + args: + title: Args + description: Playbook(s) type: string - format: secretfile - x-options: - media_types: - - '*/*' - verbose: - title: Verbose - description: verbose mode (-vvv for more, -vvvv to enable connection - debugging) - type: integer - maximum: 4 x-properties-groups: '': - id @@ -12275,10 +12275,12 @@ definitions: vars: type: object properties: - background: - title: Background - description: run asynchronously, failing after X seconds (default=N/A) + verbose: + title: Verbose + description: verbose mode (-vvv for more, -vvvv to enable connection + debugging) type: integer + maximum: 4 become: title: Become description: run operations with become (does not imply password @@ -12289,52 +12291,31 @@ definitions: description: privilege escalation method to use (default=sudo), use `ansible-doc -t become -l` to list valid choices. type: string - check: - title: Check - description: don't make any changes; instead, try to predict - some of the changes that may occur - type: boolean - connection: - title: Connection - description: connection type to use (default=smart) - type: string - diff: - title: Diff - description: when changing (small) files and templates, show - the differences in those files; works great with --check - type: boolean - extra_vars: - title: Extra vars - description: set additional variables as key=value or YAML/JSON, - if filename prepend with @ - type: string - forks: - title: Forks - description: specify number of parallel processes to use (default=5) - type: integer - limit: - title: Limit - description: further limit selected hosts to an additional pattern - type: string list_hosts: title: List hosts description: outputs a list of matching hosts; does not execute anything else type: boolean - one_line: - title: One line - description: condense output - type: boolean - playbook_dir: - title: Playbook dir - description: Since this tool does not use playbooks, use this - as a substitute playbook directory.This sets the relative - path for many features including roles/ group_vars/ etc. + limit: + title: Limit + description: further limit selected hosts to an additional pattern type: string poll: title: Poll description: set the poll interval if using -B (default=15) type: integer + background: + title: Background + description: run asynchronously, failing after X seconds (default=N/A) + type: integer + one_line: + title: One line + description: condense output + type: boolean + tree: + title: Tree + description: log output to this directory + type: string private_key: title: Private key description: use this file to authenticate the connection @@ -12343,42 +12324,57 @@ definitions: x-options: media_types: - '*/*' - scp_extra_args: - title: Scp extra args - description: specify extra arguments to pass to scp only (e.g. - -l) - type: string - sftp_extra_args: - title: Sftp extra args - description: specify extra arguments to pass to sftp only (e.g. - -f, -l) + user: + title: User + description: connect as this user (default=None) type: string - ssh_common_args: + connection: + title: Connection + description: connection type to use (default=smart) + type: string + timeout: + title: Timeout + description: override the connection timeout in seconds (default=10) + type: integer + ssh_common_args: title: Ssh common args description: specify common arguments to pass to sftp/scp/ssh (e.g. ProxyCommand) type: string + sftp_extra_args: + title: Sftp extra args + description: specify extra arguments to pass to sftp only (e.g. + -f, -l) + type: string + scp_extra_args: + title: Scp extra args + description: specify extra arguments to pass to scp only (e.g. + -l) + type: string ssh_extra_args: title: Ssh extra args description: specify extra arguments to pass to ssh only (e.g. -R) type: string + check: + title: Check + description: don't make any changes; instead, try to predict + some of the changes that may occur + type: boolean syntax_check: title: Syntax check description: perform a syntax check on the playbook, but do not execute it type: boolean - timeout: - title: Timeout - description: override the connection timeout in seconds (default=10) - type: integer - tree: - title: Tree - description: log output to this directory - type: string - user: - title: User - description: connect as this user (default=None) + diff: + title: Diff + description: when changing (small) files and templates, show + the differences in those files; works great with --check + type: boolean + extra_vars: + title: Extra vars + description: set additional variables as key=value or YAML/JSON, + if filename prepend with @ type: string vault_password_file: title: Vault password file @@ -12388,12 +12384,16 @@ definitions: x-options: media_types: - '*/*' - verbose: - title: Verbose - description: verbose mode (-vvv for more, -vvvv to enable connection - debugging) + forks: + title: Forks + description: specify number of parallel processes to use (default=5) type: integer - maximum: 4 + playbook_dir: + title: Playbook dir + description: Since this tool does not use playbooks, use this + as a substitute playbook directory.This sets the relative + path for many features including roles/ group_vars/ etc. + type: string Task: required: - playbook @@ -12412,10 +12412,60 @@ definitions: vars: type: object properties: - args: - title: Args - description: Playbook(s) + verbose: + title: Verbose + description: verbose mode (-vvv for more, -vvvv to enable connection + debugging) + type: integer + maximum: 4 + private_key: + title: Private key + description: use this file to authenticate the connection + type: string + format: secretfile + x-options: + media_types: + - '*/*' + user: + title: User + description: connect as this user (default=None) + type: string + connection: + title: Connection + description: connection type to use (default=smart) + type: string + timeout: + title: Timeout + description: override the connection timeout in seconds (default=10) + type: integer + ssh_common_args: + title: Ssh common args + description: specify common arguments to pass to sftp/scp/ssh + (e.g. ProxyCommand) + type: string + sftp_extra_args: + title: Sftp extra args + description: specify extra arguments to pass to sftp only (e.g. + -f, -l) type: string + scp_extra_args: + title: Scp extra args + description: specify extra arguments to pass to scp only (e.g. + -l) + type: string + ssh_extra_args: + title: Ssh extra args + description: specify extra arguments to pass to ssh only (e.g. + -R) + type: string + force_handlers: + title: Force handlers + description: run handlers even if a task fails + type: boolean + flush_cache: + title: Flush cache + description: clear the fact cache for every host in inventory + type: boolean become: title: Become description: run operations with become (does not imply password @@ -12426,126 +12476,76 @@ definitions: description: privilege escalation method to use (default=sudo), use `ansible-doc -t become -l` to list valid choices. type: string + tags: + title: Tags + description: only run plays and tasks tagged with these values + type: string + skip_tags: + title: Skip tags + description: only run plays and tasks whose tags do not match + these values + type: string check: title: Check description: don't make any changes; instead, try to predict some of the changes that may occur type: boolean - connection: - title: Connection - description: connection type to use (default=smart) - type: string + syntax_check: + title: Syntax check + description: perform a syntax check on the playbook, but do + not execute it + type: boolean diff: title: Diff description: when changing (small) files and templates, show the differences in those files; works great with --check type: boolean + list_hosts: + title: List hosts + description: outputs a list of matching hosts; does not execute + anything else + type: boolean + limit: + title: Limit + description: further limit selected hosts to an additional pattern + type: string extra_vars: title: Extra vars description: set additional variables as key=value or YAML/JSON, if filename prepend with @ type: string - flush_cache: - title: Flush cache - description: clear the fact cache for every host in inventory - type: boolean - force_handlers: - title: Force handlers - description: run handlers even if a task fails - type: boolean + vault_password_file: + title: Vault password file + description: vault password file + type: string + format: secretfile + x-options: + media_types: + - '*/*' forks: title: Forks description: specify number of parallel processes to use (default=5) type: integer - limit: - title: Limit - description: further limit selected hosts to an additional pattern - type: string - list_hosts: - title: List hosts - description: outputs a list of matching hosts; does not execute - anything else + list_tasks: + title: List tasks + description: list all tasks that would be executed type: boolean list_tags: title: List tags description: list all available tags type: boolean - list_tasks: - title: List tasks - description: list all tasks that would be executed - type: boolean - private_key: - title: Private key - description: use this file to authenticate the connection - type: string - format: secretfile - x-options: - media_types: - - '*/*' - scp_extra_args: - title: Scp extra args - description: specify extra arguments to pass to scp only (e.g. - -l) - type: string - sftp_extra_args: - title: Sftp extra args - description: specify extra arguments to pass to sftp only (e.g. - -f, -l) - type: string - skip_tags: - title: Skip tags - description: only run plays and tasks whose tags do not match - these values - type: string - ssh_common_args: - title: Ssh common args - description: specify common arguments to pass to sftp/scp/ssh - (e.g. ProxyCommand) - type: string - ssh_extra_args: - title: Ssh extra args - description: specify extra arguments to pass to ssh only (e.g. - -R) - type: string - start_at_task: - title: Start at task - description: start the playbook at the task matching this name - type: string step: title: Step description: 'one-step-at-a-time: confirm each task before running' type: boolean - syntax_check: - title: Syntax check - description: perform a syntax check on the playbook, but do - not execute it - type: boolean - tags: - title: Tags - description: only run plays and tasks tagged with these values - type: string - timeout: - title: Timeout - description: override the connection timeout in seconds (default=10) - type: integer - user: - title: User - description: connect as this user (default=None) + start_at_task: + title: Start at task + description: start the playbook at the task matching this name type: string - vault_password_file: - title: Vault password file - description: vault password file + args: + title: Args + description: Playbook(s) type: string - format: secretfile - x-options: - media_types: - - '*/*' - verbose: - title: Verbose - description: verbose mode (-vvv for more, -vvvv to enable connection - debugging) - type: integer - maximum: 4 x-properties-groups: '': - id @@ -12654,10 +12654,12 @@ definitions: vars: type: object properties: - background: - title: Background - description: run asynchronously, failing after X seconds (default=N/A) + verbose: + title: Verbose + description: verbose mode (-vvv for more, -vvvv to enable connection + debugging) type: integer + maximum: 4 become: title: Become description: run operations with become (does not imply password @@ -12668,52 +12670,31 @@ definitions: description: privilege escalation method to use (default=sudo), use `ansible-doc -t become -l` to list valid choices. type: string - check: - title: Check - description: don't make any changes; instead, try to predict - some of the changes that may occur - type: boolean - connection: - title: Connection - description: connection type to use (default=smart) - type: string - diff: - title: Diff - description: when changing (small) files and templates, show - the differences in those files; works great with --check - type: boolean - extra_vars: - title: Extra vars - description: set additional variables as key=value or YAML/JSON, - if filename prepend with @ - type: string - forks: - title: Forks - description: specify number of parallel processes to use (default=5) - type: integer - limit: - title: Limit - description: further limit selected hosts to an additional pattern - type: string list_hosts: title: List hosts description: outputs a list of matching hosts; does not execute anything else type: boolean - one_line: - title: One line - description: condense output - type: boolean - playbook_dir: - title: Playbook dir - description: Since this tool does not use playbooks, use this - as a substitute playbook directory.This sets the relative - path for many features including roles/ group_vars/ etc. + limit: + title: Limit + description: further limit selected hosts to an additional pattern type: string poll: title: Poll description: set the poll interval if using -B (default=15) type: integer + background: + title: Background + description: run asynchronously, failing after X seconds (default=N/A) + type: integer + one_line: + title: One line + description: condense output + type: boolean + tree: + title: Tree + description: log output to this directory + type: string private_key: title: Private key description: use this file to authenticate the connection @@ -12722,42 +12703,57 @@ definitions: x-options: media_types: - '*/*' - scp_extra_args: - title: Scp extra args - description: specify extra arguments to pass to scp only (e.g. - -l) + user: + title: User + description: connect as this user (default=None) type: string - sftp_extra_args: - title: Sftp extra args - description: specify extra arguments to pass to sftp only (e.g. - -f, -l) + connection: + title: Connection + description: connection type to use (default=smart) type: string + timeout: + title: Timeout + description: override the connection timeout in seconds (default=10) + type: integer ssh_common_args: title: Ssh common args description: specify common arguments to pass to sftp/scp/ssh (e.g. ProxyCommand) type: string + sftp_extra_args: + title: Sftp extra args + description: specify extra arguments to pass to sftp only (e.g. + -f, -l) + type: string + scp_extra_args: + title: Scp extra args + description: specify extra arguments to pass to scp only (e.g. + -l) + type: string ssh_extra_args: title: Ssh extra args description: specify extra arguments to pass to ssh only (e.g. -R) type: string + check: + title: Check + description: don't make any changes; instead, try to predict + some of the changes that may occur + type: boolean syntax_check: title: Syntax check description: perform a syntax check on the playbook, but do not execute it type: boolean - timeout: - title: Timeout - description: override the connection timeout in seconds (default=10) - type: integer - tree: - title: Tree - description: log output to this directory - type: string - user: - title: User - description: connect as this user (default=None) + diff: + title: Diff + description: when changing (small) files and templates, show + the differences in those files; works great with --check + type: boolean + extra_vars: + title: Extra vars + description: set additional variables as key=value or YAML/JSON, + if filename prepend with @ type: string vault_password_file: title: Vault password file @@ -12767,12 +12763,16 @@ definitions: x-options: media_types: - '*/*' - verbose: - title: Verbose - description: verbose mode (-vvv for more, -vvvv to enable connection - debugging) + forks: + title: Forks + description: specify number of parallel processes to use (default=5) type: integer - maximum: 4 + playbook_dir: + title: Playbook dir + description: Since this tool does not use playbooks, use this + as a substitute playbook directory.This sets the relative + path for many features including roles/ group_vars/ etc. + type: string Task: required: - playbook @@ -12791,10 +12791,60 @@ definitions: vars: type: object properties: - args: - title: Args - description: Playbook(s) + verbose: + title: Verbose + description: verbose mode (-vvv for more, -vvvv to enable connection + debugging) + type: integer + maximum: 4 + private_key: + title: Private key + description: use this file to authenticate the connection + type: string + format: secretfile + x-options: + media_types: + - '*/*' + user: + title: User + description: connect as this user (default=None) type: string + connection: + title: Connection + description: connection type to use (default=smart) + type: string + timeout: + title: Timeout + description: override the connection timeout in seconds (default=10) + type: integer + ssh_common_args: + title: Ssh common args + description: specify common arguments to pass to sftp/scp/ssh + (e.g. ProxyCommand) + type: string + sftp_extra_args: + title: Sftp extra args + description: specify extra arguments to pass to sftp only (e.g. + -f, -l) + type: string + scp_extra_args: + title: Scp extra args + description: specify extra arguments to pass to scp only (e.g. + -l) + type: string + ssh_extra_args: + title: Ssh extra args + description: specify extra arguments to pass to ssh only (e.g. + -R) + type: string + force_handlers: + title: Force handlers + description: run handlers even if a task fails + type: boolean + flush_cache: + title: Flush cache + description: clear the fact cache for every host in inventory + type: boolean become: title: Become description: run operations with become (does not imply password @@ -12805,126 +12855,76 @@ definitions: description: privilege escalation method to use (default=sudo), use `ansible-doc -t become -l` to list valid choices. type: string + tags: + title: Tags + description: only run plays and tasks tagged with these values + type: string + skip_tags: + title: Skip tags + description: only run plays and tasks whose tags do not match + these values + type: string check: title: Check description: don't make any changes; instead, try to predict some of the changes that may occur type: boolean - connection: - title: Connection - description: connection type to use (default=smart) - type: string + syntax_check: + title: Syntax check + description: perform a syntax check on the playbook, but do + not execute it + type: boolean diff: title: Diff description: when changing (small) files and templates, show the differences in those files; works great with --check type: boolean + list_hosts: + title: List hosts + description: outputs a list of matching hosts; does not execute + anything else + type: boolean + limit: + title: Limit + description: further limit selected hosts to an additional pattern + type: string extra_vars: title: Extra vars description: set additional variables as key=value or YAML/JSON, if filename prepend with @ type: string - flush_cache: - title: Flush cache - description: clear the fact cache for every host in inventory - type: boolean - force_handlers: - title: Force handlers - description: run handlers even if a task fails - type: boolean + vault_password_file: + title: Vault password file + description: vault password file + type: string + format: secretfile + x-options: + media_types: + - '*/*' forks: title: Forks description: specify number of parallel processes to use (default=5) type: integer - limit: - title: Limit - description: further limit selected hosts to an additional pattern - type: string - list_hosts: - title: List hosts - description: outputs a list of matching hosts; does not execute - anything else + list_tasks: + title: List tasks + description: list all tasks that would be executed type: boolean list_tags: title: List tags description: list all available tags type: boolean - list_tasks: - title: List tasks - description: list all tasks that would be executed - type: boolean - private_key: - title: Private key - description: use this file to authenticate the connection - type: string - format: secretfile - x-options: - media_types: - - '*/*' - scp_extra_args: - title: Scp extra args - description: specify extra arguments to pass to scp only (e.g. - -l) - type: string - sftp_extra_args: - title: Sftp extra args - description: specify extra arguments to pass to sftp only (e.g. - -f, -l) - type: string - skip_tags: - title: Skip tags - description: only run plays and tasks whose tags do not match - these values - type: string - ssh_common_args: - title: Ssh common args - description: specify common arguments to pass to sftp/scp/ssh - (e.g. ProxyCommand) - type: string - ssh_extra_args: - title: Ssh extra args - description: specify extra arguments to pass to ssh only (e.g. - -R) - type: string - start_at_task: - title: Start at task - description: start the playbook at the task matching this name - type: string step: title: Step description: 'one-step-at-a-time: confirm each task before running' type: boolean - syntax_check: - title: Syntax check - description: perform a syntax check on the playbook, but do - not execute it - type: boolean - tags: - title: Tags - description: only run plays and tasks tagged with these values - type: string - timeout: - title: Timeout - description: override the connection timeout in seconds (default=10) - type: integer - user: - title: User - description: connect as this user (default=None) + start_at_task: + title: Start at task + description: start the playbook at the task matching this name type: string - vault_password_file: - title: Vault password file - description: vault password file + args: + title: Args + description: Playbook(s) type: string - format: secretfile - x-options: - media_types: - - '*/*' - verbose: - title: Verbose - description: verbose mode (-vvv for more, -vvvv to enable connection - debugging) - type: integer - maximum: 4 x-properties-groups: '': - id @@ -12987,10 +12987,12 @@ definitions: vars: type: object properties: - background: - title: Background - description: run asynchronously, failing after X seconds (default=N/A) + verbose: + title: Verbose + description: verbose mode (-vvv for more, -vvvv to enable connection + debugging) type: integer + maximum: 4 become: title: Become description: run operations with become (does not imply password @@ -13001,52 +13003,31 @@ definitions: description: privilege escalation method to use (default=sudo), use `ansible-doc -t become -l` to list valid choices. type: string - check: - title: Check - description: don't make any changes; instead, try to predict - some of the changes that may occur - type: boolean - connection: - title: Connection - description: connection type to use (default=smart) - type: string - diff: - title: Diff - description: when changing (small) files and templates, show - the differences in those files; works great with --check - type: boolean - extra_vars: - title: Extra vars - description: set additional variables as key=value or YAML/JSON, - if filename prepend with @ - type: string - forks: - title: Forks - description: specify number of parallel processes to use (default=5) - type: integer - limit: - title: Limit - description: further limit selected hosts to an additional pattern - type: string list_hosts: title: List hosts description: outputs a list of matching hosts; does not execute anything else type: boolean - one_line: - title: One line - description: condense output - type: boolean - playbook_dir: - title: Playbook dir - description: Since this tool does not use playbooks, use this - as a substitute playbook directory.This sets the relative - path for many features including roles/ group_vars/ etc. + limit: + title: Limit + description: further limit selected hosts to an additional pattern type: string poll: title: Poll description: set the poll interval if using -B (default=15) type: integer + background: + title: Background + description: run asynchronously, failing after X seconds (default=N/A) + type: integer + one_line: + title: One line + description: condense output + type: boolean + tree: + title: Tree + description: log output to this directory + type: string private_key: title: Private key description: use this file to authenticate the connection @@ -13055,137 +13036,100 @@ definitions: x-options: media_types: - '*/*' - scp_extra_args: - title: Scp extra args - description: specify extra arguments to pass to scp only (e.g. - -l) + user: + title: User + description: connect as this user (default=None) type: string - sftp_extra_args: - title: Sftp extra args - description: specify extra arguments to pass to sftp only (e.g. - -f, -l) + connection: + title: Connection + description: connection type to use (default=smart) type: string + timeout: + title: Timeout + description: override the connection timeout in seconds (default=10) + type: integer ssh_common_args: title: Ssh common args description: specify common arguments to pass to sftp/scp/ssh (e.g. ProxyCommand) type: string + sftp_extra_args: + title: Sftp extra args + description: specify extra arguments to pass to sftp only (e.g. + -f, -l) + type: string + scp_extra_args: + title: Scp extra args + description: specify extra arguments to pass to scp only (e.g. + -l) + type: string ssh_extra_args: title: Ssh extra args description: specify extra arguments to pass to ssh only (e.g. -R) type: string - syntax_check: - title: Syntax check - description: perform a syntax check on the playbook, but do - not execute it - type: boolean - timeout: - title: Timeout - description: override the connection timeout in seconds (default=10) - type: integer - tree: - title: Tree - description: log output to this directory - type: string - user: - title: User - description: connect as this user (default=None) - type: string - vault_password_file: - title: Vault password file - description: vault password file - type: string - format: secretfile - x-options: - media_types: - - '*/*' - verbose: - title: Verbose - description: verbose mode (-vvv for more, -vvvv to enable connection - debugging) - type: integer - maximum: 4 - Task: - required: - - playbook - type: object - properties: - playbook: - title: Playbook - type: string - format: fk_autocomplete - x-options: - model: - $ref: '#/definitions/Playbook' - usePrefetch: true - value_field: playbook - view_field: playbook - vars: - type: object - properties: - args: - title: Args - description: Playbook(s) - type: string - become: - title: Become - description: run operations with become (does not imply password - prompting) - type: boolean - become_method: - title: Become method - description: privilege escalation method to use (default=sudo), - use `ansible-doc -t become -l` to list valid choices. - type: string check: title: Check description: don't make any changes; instead, try to predict some of the changes that may occur type: boolean - connection: - title: Connection - description: connection type to use (default=smart) - type: string + syntax_check: + title: Syntax check + description: perform a syntax check on the playbook, but do + not execute it + type: boolean diff: title: Diff - description: when changing (small) files and templates, show - the differences in those files; works great with --check - type: boolean - extra_vars: - title: Extra vars - description: set additional variables as key=value or YAML/JSON, - if filename prepend with @ - type: string - flush_cache: - title: Flush cache - description: clear the fact cache for every host in inventory - type: boolean - force_handlers: - title: Force handlers - description: run handlers even if a task fails + description: when changing (small) files and templates, show + the differences in those files; works great with --check type: boolean + extra_vars: + title: Extra vars + description: set additional variables as key=value or YAML/JSON, + if filename prepend with @ + type: string + vault_password_file: + title: Vault password file + description: vault password file + type: string + format: secretfile + x-options: + media_types: + - '*/*' forks: title: Forks description: specify number of parallel processes to use (default=5) type: integer - limit: - title: Limit - description: further limit selected hosts to an additional pattern + playbook_dir: + title: Playbook dir + description: Since this tool does not use playbooks, use this + as a substitute playbook directory.This sets the relative + path for many features including roles/ group_vars/ etc. type: string - list_hosts: - title: List hosts - description: outputs a list of matching hosts; does not execute - anything else - type: boolean - list_tags: - title: List tags - description: list all available tags - type: boolean - list_tasks: - title: List tasks - description: list all tasks that would be executed - type: boolean + Task: + required: + - playbook + type: object + properties: + playbook: + title: Playbook + type: string + format: fk_autocomplete + x-options: + model: + $ref: '#/definitions/Playbook' + usePrefetch: true + value_field: playbook + view_field: playbook + vars: + type: object + properties: + verbose: + title: Verbose + description: verbose mode (-vvv for more, -vvvv to enable connection + debugging) + type: integer + maximum: 4 private_key: title: Private key description: use this file to authenticate the connection @@ -13194,55 +13138,93 @@ definitions: x-options: media_types: - '*/*' - scp_extra_args: - title: Scp extra args - description: specify extra arguments to pass to scp only (e.g. - -l) - type: string - sftp_extra_args: - title: Sftp extra args - description: specify extra arguments to pass to sftp only (e.g. - -f, -l) + user: + title: User + description: connect as this user (default=None) type: string - skip_tags: - title: Skip tags - description: only run plays and tasks whose tags do not match - these values + connection: + title: Connection + description: connection type to use (default=smart) type: string + timeout: + title: Timeout + description: override the connection timeout in seconds (default=10) + type: integer ssh_common_args: title: Ssh common args description: specify common arguments to pass to sftp/scp/ssh (e.g. ProxyCommand) type: string + sftp_extra_args: + title: Sftp extra args + description: specify extra arguments to pass to sftp only (e.g. + -f, -l) + type: string + scp_extra_args: + title: Scp extra args + description: specify extra arguments to pass to scp only (e.g. + -l) + type: string ssh_extra_args: title: Ssh extra args description: specify extra arguments to pass to ssh only (e.g. -R) type: string - start_at_task: - title: Start at task - description: start the playbook at the task matching this name + force_handlers: + title: Force handlers + description: run handlers even if a task fails + type: boolean + flush_cache: + title: Flush cache + description: clear the fact cache for every host in inventory + type: boolean + become: + title: Become + description: run operations with become (does not imply password + prompting) + type: boolean + become_method: + title: Become method + description: privilege escalation method to use (default=sudo), + use `ansible-doc -t become -l` to list valid choices. type: string - step: - title: Step - description: 'one-step-at-a-time: confirm each task before running' + tags: + title: Tags + description: only run plays and tasks tagged with these values + type: string + skip_tags: + title: Skip tags + description: only run plays and tasks whose tags do not match + these values + type: string + check: + title: Check + description: don't make any changes; instead, try to predict + some of the changes that may occur type: boolean syntax_check: title: Syntax check description: perform a syntax check on the playbook, but do not execute it type: boolean - tags: - title: Tags - description: only run plays and tasks tagged with these values + diff: + title: Diff + description: when changing (small) files and templates, show + the differences in those files; works great with --check + type: boolean + list_hosts: + title: List hosts + description: outputs a list of matching hosts; does not execute + anything else + type: boolean + limit: + title: Limit + description: further limit selected hosts to an additional pattern type: string - timeout: - title: Timeout - description: override the connection timeout in seconds (default=10) - type: integer - user: - title: User - description: connect as this user (default=None) + extra_vars: + title: Extra vars + description: set additional variables as key=value or YAML/JSON, + if filename prepend with @ type: string vault_password_file: title: Vault password file @@ -13252,12 +13234,30 @@ definitions: x-options: media_types: - '*/*' - verbose: - title: Verbose - description: verbose mode (-vvv for more, -vvvv to enable connection - debugging) + forks: + title: Forks + description: specify number of parallel processes to use (default=5) type: integer - maximum: 4 + list_tasks: + title: List tasks + description: list all tasks that would be executed + type: boolean + list_tags: + title: List tags + description: list all available tags + type: boolean + step: + title: Step + description: 'one-step-at-a-time: confirm each task before running' + type: boolean + start_at_task: + title: Start at task + description: start the playbook at the task matching this name + type: string + args: + title: Args + description: Playbook(s) + type: string x-properties-groups: '': - id @@ -13746,63 +13746,63 @@ definitions: types: MODULE: enum: - - args - - background + - verbose - become - become_method - - check - - connection - - diff - - extra_vars - - forks - - limit - list_hosts - - one_line - - playbook_dir + - limit - poll + - background + - one_line + - tree - private_key - - scp_extra_args - - sftp_extra_args + - user + - connection + - timeout - ssh_common_args + - sftp_extra_args + - scp_extra_args - ssh_extra_args + - check - syntax_check - - timeout - - tree - - user + - diff + - extra_vars - vault_password_file - - verbose + - forks + - playbook_dir + - args - group type: string PLAYBOOK: enum: - - args + - verbose + - private_key + - user + - connection + - timeout + - ssh_common_args + - sftp_extra_args + - scp_extra_args + - ssh_extra_args + - force_handlers + - flush_cache - become - become_method + - tags + - skip_tags - check - - connection + - syntax_check - diff + - list_hosts + - limit - extra_vars - - flush_cache - - force_handlers + - vault_password_file - forks - - limit - - list_hosts - - list_tags - list_tasks - - private_key - - scp_extra_args - - sftp_extra_args - - skip_tags - - ssh_common_args - - ssh_extra_args - - start_at_task + - list_tags - step - - syntax_check - - tags - - timeout - - user - - vault_password_file - - verbose + - start_at_task + - args type: string value: format: dynamic diff --git a/polemarch/__init__.py b/polemarch/__init__.py index 62ff2623..2063d981 100644 --- a/polemarch/__init__.py +++ b/polemarch/__init__.py @@ -31,6 +31,6 @@ "VST_ROOT_URLCONF": os.getenv("VST_ROOT_URLCONF", 'vstutils.urls'), } -__version__ = "2.2.0" +__version__ = "2.2.1" prepare_environment(**default_settings) diff --git a/polemarch/plugins/ansible.py b/polemarch/plugins/ansible.py index 4b45b73c..084fa036 100644 --- a/polemarch/plugins/ansible.py +++ b/polemarch/plugins/ansible.py @@ -14,7 +14,7 @@ class BaseAnsiblePlugin(BasePlugin): - __slots__ = () + __slots__ = ('files',) reference = {} base_command = settings.EXECUTOR @@ -67,7 +67,7 @@ def get_inventory(self, inventory: Optional[Union[Inventory, str, int]]) -> Tupl inventory = Inventory.objects.get(id=int(inventory)) if isinstance(inventory, Inventory): - text = inventory.get_inventory()[0] + text, self.files = inventory.get_inventory(tmp_dir=self.execution_dir) inventory_file = self.execution_dir / self.inventory_filename inventory_file.write_text(text) return str(inventory_file), self._get_raw_inventory(text) @@ -103,6 +103,7 @@ def _process_arg(self, key: str, value) -> Optional[str]: def _put_into_tmpfile(self, value) -> str: tmpfile = self.execution_dir / f'inner_arg_{uuid1()}' tmpfile.write_text(value) + tmpfile.chmod(0o600) return str(tmpfile) @classmethod diff --git a/tests.py b/tests.py index 318ad032..d8287aa8 100644 --- a/tests.py +++ b/tests.py @@ -28,9 +28,11 @@ from polemarch.main.tasks import ScheduledTask from polemarch.main.openapi import PROJECT_MENU from polemarch.main.constants import CYPHER + from polemarch.main.models.utils import ProjectProxy from polemarch.plugins.ansible import BaseAnsiblePlugin, BasePlugin, Module except ImportError: from pmlib.main.tasks import ScheduledTask + from pmlib.main.models.utils import ProjectProxy from pmlib.main.constants import CYPHER from pmlib.plugins.ansible import BaseAnsiblePlugin, BasePlugin, Module @@ -47,9 +49,11 @@ User = get_user_model() example_key = """ ------BEGIN RSA PRIVATE KEY----- -our_private_key_string ------END RSA PRIVATE KEY----- +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEIH1LLUytCpUG6FMH06Wnuk+p4ZewjyDPJKcQwsaGZ5y3oAoGCCqGSM49 +AwEHoUQDQgAET5LtltdvCIaMd4ZzXBP3JkZp/F2EMxPUiNVSe/HMdNIEnzy7WdH9 +HD1a8+068eoT+KV/ESsjDxwo2NUPZAo0pQ== +-----END EC PRIVATE KEY----- """.strip() @@ -111,6 +115,11 @@ def __init__(self, msg='Test exception.', *args, **kwargs): super().__init__(msg, *args, **kwargs) +class DummyProject: + def __getattr__(self, name): + return name + + class TestAnsibleDoc(BaseAnsiblePlugin): reference = { 'module-path': {'type': 'string'}, @@ -2204,6 +2213,33 @@ def test_echo_plugin(self): @own_projects_dir class PlaybookAndModuleTestCase(BaseProjectTestCase): + def test_execute_with_key_in_inventory(self): + self.get_model_filter('main.Variable').delete() + inventory_type = ContentType.objects.get(model='inventory', app_label='main') + self.get_model_filter('main.Variable').create( + key='ansible_ssh_private_key_file', + value=example_key, + content_type=inventory_type, + object_id=self.inventory.id + ) + self.get_model_filter('main.Variable').create( + key='ansible_user', + value='user1', + content_type=inventory_type, + object_id=self.inventory.id + ) + results = self.bulk_transactional([ + self.execute_module_bulk_data(inventory=self.inventory.id), + self.get_history_bulk_data('<<0[data][history_id]>>'), + self.get_raw_history_bulk_data('<<0[data][history_id]>>'), + ]) + self.assertEqual(results[1]['data']['status'], 'OFFLINE') + self.assertIn('"unreachable": true', results[2]['data']['detail']) + self.assertIn('"msg": "Failed to connect to the host via ssh:', results[2]['data']['detail']) + self.assertNotIn('No such file or directory', results[2]['data']['detail']) + self.assertNotIn('invalid format', results[2]['data']['detail']) + self.assertNotIn('bad permissions', results[2]['data']['detail']) + def test_v2_executions(self): self.client.force_login(self.user) result = self.client.post( @@ -4235,3 +4271,36 @@ def test_menu(self): system_tab_user = self.system_tab system_tab_user['sublinks'] = [self.users_sublink] self.assertEqual(reg_schema['info']['x-menu'], PROJECT_MENU + [system_tab_user]) + + +class BaseExecutionPluginUnitTestCase(VSTBaseTestCase): + plugin_class = None + + def setUp(self): + self.dummy_output = '' + self.dummy_execution_dir = Path(mkdtemp()) + + def tearDown(self): + shutil.rmtree(self.dummy_execution_dir, ignore_errors=True) + + def dummy_output_handler(self, message, level): + self.dummy_output += f'message:{message},level:{level}' + + def get_plugin_instance(self, options=None, execution_dir=None): + instance = self.plugin_class( + options or {}, + ProjectProxy(DummyProject()), + self.dummy_output_handler + ) + instance.execution_dir = execution_dir or self.dummy_execution_dir + return instance + + +class AnsibleExecutionPluginUnitTestCase(BaseExecutionPluginUnitTestCase): + plugin_class = BaseAnsiblePlugin + + def test_put_into_tmpfile(self): + instance = self.get_plugin_instance() + test_value = 'test_value' + filepath = instance._put_into_tmpfile(test_value) + self.assertEqual(Path(filepath).read_text(), test_value)