Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create replace action plugin; remove replace module. #62150

Draft
wants to merge 1 commit into
base: devel
Choose a base branch
from

Conversation

crossan007
Copy link
Contributor

SUMMARY

Converts the replace (linux-only) module to an Action Plugin to provide cross-platform compatibility.

It adopts a similar approach as the template module, where the actual logic is executed on the Ansible Control server.

First, the referenced file is copied from the remote host to the ACS, then the replace operation is executed, and then the new file is copied back if there was a change

This Action Plugin works "as is"; however, I'm aware that I'm missing the .py moudle files, and probably other requisite docs / changes, so I'm opening this as a draft pull request so as to welcome changes / corrections.

ISSUE TYPE
  • Feature Pull Request
  • New Module Pull Request
COMPONENT NAME

replace

@ansibot
Copy link
Contributor

ansibot commented Sep 11, 2019

cc @EvanK
click here for bot help

@ansibot ansibot added affects_2.10 This issue/PR affects Ansible v2.10 community_review In order to be merged, this PR must follow the community review workflow. feature This issue/PR relates to a feature request. files Files category module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. new_plugin This PR includes a new plugin. support:community This issue/PR relates to code supported by the Ansible community. labels Sep 11, 2019
@ansibot
Copy link
Contributor

ansibot commented Sep 11, 2019

The test ansible-test sanity --test pylint [explain] failed with 23 errors:

lib/ansible/plugins/action/replace.py:24:38: bad-whitespace: Exactly one space required after comma     def copy_local_file_to_remote(self,local_path,remote_path,task_vars):
                                       ^
lib/ansible/plugins/action/replace.py:24:49: bad-whitespace: Exactly one space required after comma     def copy_local_file_to_remote(self,local_path,remote_path,task_vars):
                                                  ^
lib/ansible/plugins/action/replace.py:24:61: bad-whitespace: Exactly one space required after comma     def copy_local_file_to_remote(self,local_path,remote_path,task_vars):
                                                              ^
lib/ansible/plugins/action/replace.py:36:13: trailing-whitespace: Trailing whitespace
lib/ansible/plugins/action/replace.py:46:12: undefined-variable: Undefined variable 'action_plugin_result'
lib/ansible/plugins/action/replace.py:50:38: bad-whitespace: Exactly one space required after comma     def copy_remote_file_to_local(self,remote_path,local_path,task_vars):
                                       ^
lib/ansible/plugins/action/replace.py:50:50: bad-whitespace: Exactly one space required after comma     def copy_remote_file_to_local(self,remote_path,local_path,task_vars):
                                                   ^
lib/ansible/plugins/action/replace.py:50:61: bad-whitespace: Exactly one space required after comma     def copy_remote_file_to_local(self,remote_path,local_path,task_vars):
                                                              ^
lib/ansible/plugins/action/replace.py:63:13: trailing-whitespace: Trailing whitespace
lib/ansible/plugins/action/replace.py:73:12: undefined-variable: Undefined variable 'action_plugin_result'
lib/ansible/plugins/action/replace.py:76:0: trailing-whitespace: Trailing whitespace
lib/ansible/plugins/action/replace.py:104:0: trailing-whitespace: Trailing whitespace
lib/ansible/plugins/action/replace.py:123:0: trailing-whitespace: Trailing whitespace
lib/ansible/plugins/action/replace.py:124:71: bad-whitespace: Exactly one space required after comma         copy_remote_to_acs_result = self.copy_remote_file_to_local(path,local_copy_of_original_file,task_vars)
                                                                        ^
lib/ansible/plugins/action/replace.py:124:99: bad-whitespace: Exactly one space required after comma         copy_remote_to_acs_result = self.copy_remote_file_to_local(path,local_copy_of_original_file,task_vars)
                                                                                                    ^
lib/ansible/plugins/action/replace.py:127:0: trailing-whitespace: Trailing whitespace
lib/ansible/plugins/action/replace.py:128:14: bad-whitespace: No space allowed before bracket         print (copy_remote_to_acs_result)
               ^
lib/ansible/plugins/action/replace.py:156:16: undefined-variable: Undefined variable 'module'
lib/ansible/plugins/action/replace.py:159:0: trailing-whitespace: Trailing whitespace
lib/ansible/plugins/action/replace.py:186:98: bad-whitespace: Exactly one space required after comma             copy_acs_to_remote_result = self.copy_local_file_to_remote(local_copy_of_original_file,path,task_vars)
                                                                                                   ^
lib/ansible/plugins/action/replace.py:186:103: bad-whitespace: Exactly one space required after comma             copy_acs_to_remote_result = self.copy_local_file_to_remote(local_copy_of_original_file,path,task_vars)
                                                                                                        ^
lib/ansible/plugins/action/replace.py:190:0: trailing-whitespace: Trailing whitespace
lib/ansible/plugins/action/replace.py:191:0: missing-final-newline: Final newline missing

The test ansible-test sanity --test docs-build [explain] failed with 2 errors:

docs/docsite/rst/porting_guides/porting_guide_2.5.rst:223:0: undefined-label: undefined label: replace_module (if the link has no caption the label must precede a section header)
docs/docsite/rst/reference_appendices/faq.rst:450:0: undefined-label: undefined label: replace_module (if the link has no caption the label must precede a section header)

The test ansible-test sanity --test action-plugin-docs [explain] failed with 1 error:

lib/ansible/plugins/action/replace.py:0:0: action plugin has no matching module to provide documentation

The test ansible-test sanity --test compile --python 2.6 [explain] failed with 1 error:

lib/ansible/plugins/action/replace.py:3:1: SyntaxError:

The test ansible-test sanity --test ignores [explain] failed with 1 error:

test/sanity/ignore.txt:2258:1: File 'lib/ansible/modules/files/replace.py' does not exist

The test ansible-test sanity --test line-endings [explain] failed with 1 error:

lib/ansible/plugins/action/replace.py:0:0: use "\n" for line endings instead of "\r\n"

The test ansible-test sanity --test pep8 [explain] failed with 43 errors:

lib/ansible/plugins/action/replace.py:24:39: E231: missing whitespace after ','
lib/ansible/plugins/action/replace.py:24:50: E231: missing whitespace after ','
lib/ansible/plugins/action/replace.py:24:62: E231: missing whitespace after ','
lib/ansible/plugins/action/replace.py:25:10: E114: indentation is not a multiple of four (comment)
lib/ansible/plugins/action/replace.py:25:10: E117: over-indented (comment)
lib/ansible/plugins/action/replace.py:36:14: W291: trailing whitespace
lib/ansible/plugins/action/replace.py:38:69: E128: continuation line under-indented for visual indent
lib/ansible/plugins/action/replace.py:39:69: E128: continuation line under-indented for visual indent
lib/ansible/plugins/action/replace.py:40:69: E128: continuation line under-indented for visual indent
lib/ansible/plugins/action/replace.py:41:69: E128: continuation line under-indented for visual indent
lib/ansible/plugins/action/replace.py:42:69: E128: continuation line under-indented for visual indent
lib/ansible/plugins/action/replace.py:43:69: E128: continuation line under-indented for visual indent
lib/ansible/plugins/action/replace.py:50:39: E231: missing whitespace after ','
lib/ansible/plugins/action/replace.py:50:51: E231: missing whitespace after ','
lib/ansible/plugins/action/replace.py:50:62: E231: missing whitespace after ','
lib/ansible/plugins/action/replace.py:51:10: E114: indentation is not a multiple of four (comment)
lib/ansible/plugins/action/replace.py:51:10: E117: over-indented (comment)
lib/ansible/plugins/action/replace.py:63:14: W291: trailing whitespace
lib/ansible/plugins/action/replace.py:65:69: E128: continuation line under-indented for visual indent
lib/ansible/plugins/action/replace.py:66:69: E128: continuation line under-indented for visual indent
lib/ansible/plugins/action/replace.py:67:69: E128: continuation line under-indented for visual indent
lib/ansible/plugins/action/replace.py:68:69: E128: continuation line under-indented for visual indent
lib/ansible/plugins/action/replace.py:69:69: E128: continuation line under-indented for visual indent
lib/ansible/plugins/action/replace.py:70:69: E128: continuation line under-indented for visual indent
lib/ansible/plugins/action/replace.py:76:1: W293: blank line contains whitespace
lib/ansible/plugins/action/replace.py:78:5: E303: too many blank lines (2)
lib/ansible/plugins/action/replace.py:104:1: W293: blank line contains whitespace
lib/ansible/plugins/action/replace.py:115:9: E303: too many blank lines (2)
lib/ansible/plugins/action/replace.py:115:161: E501: line too long (167 > 160 characters)
lib/ansible/plugins/action/replace.py:117:13: E116: unexpected indentation (comment)
lib/ansible/plugins/action/replace.py:117:13: E265: block comment should start with '# '
lib/ansible/plugins/action/replace.py:118:13: E116: unexpected indentation (comment)
lib/ansible/plugins/action/replace.py:123:1: W293: blank line contains whitespace
lib/ansible/plugins/action/replace.py:124:72: E231: missing whitespace after ','
lib/ansible/plugins/action/replace.py:124:100: E231: missing whitespace after ','
lib/ansible/plugins/action/replace.py:127:1: W293: blank line contains whitespace
lib/ansible/plugins/action/replace.py:128:9: E303: too many blank lines (2)
lib/ansible/plugins/action/replace.py:128:14: E211: whitespace before '('
lib/ansible/plugins/action/replace.py:159:1: W293: blank line contains whitespace
lib/ansible/plugins/action/replace.py:186:99: E231: missing whitespace after ','
lib/ansible/plugins/action/replace.py:186:104: E231: missing whitespace after ','
lib/ansible/plugins/action/replace.py:190:1: W293: blank line contains whitespace
lib/ansible/plugins/action/replace.py:191:36: W292: no newline at end of file

click here for bot help

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed community_review In order to be merged, this PR must follow the community review workflow. labels Sep 11, 2019
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Sep 19, 2019
@goneri goneri added the ci_verified Changes made in this PR are causing tests to fail. label Oct 2, 2019
@ansibot ansibot removed the needs_triage Needs a first human triage before being processed. label Oct 2, 2019
@ansibot ansibot added the support:core This issue/PR relates to code supported by the Ansible Engineering Team. label Mar 26, 2020
@ansibot ansibot added pre_azp This PR was last tested before migration to Azure Pipelines. and removed ci_verified Changes made in this PR are causing tests to fail. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. labels Dec 5, 2020
@ansibot ansibot added the WIP This issue/PR is a work in progress. Nevertheless it was shared for getting input from peers. label Feb 16, 2021
@ansibot ansibot removed the support:community This issue/PR relates to code supported by the Ansible community. label Mar 5, 2021
@webknjaz
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ansibot ansibot removed the pre_azp This PR was last tested before migration to Azure Pipelines. label Oct 20, 2022
@bcoca
Copy link
Member

bcoca commented Oct 20, 2022

instead of replacing replace, maybe a new name? (alter, displace, substitute, supplant, translate?)

@ansibot
Copy link
Contributor

ansibot commented Oct 20, 2022

The test ansible-test sanity --test pep8 [explain] failed with 43 errors:

lib/ansible/plugins/action/replace.py:24:39: E231: missing whitespace after ','
lib/ansible/plugins/action/replace.py:24:50: E231: missing whitespace after ','
lib/ansible/plugins/action/replace.py:24:62: E231: missing whitespace after ','
lib/ansible/plugins/action/replace.py:25:10: E114: indentation is not a multiple of 4 (comment)
lib/ansible/plugins/action/replace.py:25:10: E117: over-indented (comment)
lib/ansible/plugins/action/replace.py:36:14: W291: trailing whitespace
lib/ansible/plugins/action/replace.py:38:69: E128: continuation line under-indented for visual indent
lib/ansible/plugins/action/replace.py:39:69: E128: continuation line under-indented for visual indent
lib/ansible/plugins/action/replace.py:40:69: E128: continuation line under-indented for visual indent
lib/ansible/plugins/action/replace.py:41:69: E128: continuation line under-indented for visual indent
lib/ansible/plugins/action/replace.py:42:69: E128: continuation line under-indented for visual indent
lib/ansible/plugins/action/replace.py:43:69: E128: continuation line under-indented for visual indent
lib/ansible/plugins/action/replace.py:50:39: E231: missing whitespace after ','
lib/ansible/plugins/action/replace.py:50:51: E231: missing whitespace after ','
lib/ansible/plugins/action/replace.py:50:62: E231: missing whitespace after ','
lib/ansible/plugins/action/replace.py:51:10: E114: indentation is not a multiple of 4 (comment)
lib/ansible/plugins/action/replace.py:51:10: E117: over-indented (comment)
lib/ansible/plugins/action/replace.py:63:14: W291: trailing whitespace
lib/ansible/plugins/action/replace.py:65:69: E128: continuation line under-indented for visual indent
lib/ansible/plugins/action/replace.py:66:69: E128: continuation line under-indented for visual indent
lib/ansible/plugins/action/replace.py:67:69: E128: continuation line under-indented for visual indent
lib/ansible/plugins/action/replace.py:68:69: E128: continuation line under-indented for visual indent
lib/ansible/plugins/action/replace.py:69:69: E128: continuation line under-indented for visual indent
lib/ansible/plugins/action/replace.py:70:69: E128: continuation line under-indented for visual indent
lib/ansible/plugins/action/replace.py:76:1: W293: blank line contains whitespace
lib/ansible/plugins/action/replace.py:78:5: E303: too many blank lines (2)
lib/ansible/plugins/action/replace.py:104:1: W293: blank line contains whitespace
lib/ansible/plugins/action/replace.py:115:9: E303: too many blank lines (2)
lib/ansible/plugins/action/replace.py:115:161: E501: line too long (167 > 160 characters)
lib/ansible/plugins/action/replace.py:117:13: E116: unexpected indentation (comment)
lib/ansible/plugins/action/replace.py:117:13: E265: block comment should start with '# '
lib/ansible/plugins/action/replace.py:118:13: E116: unexpected indentation (comment)
lib/ansible/plugins/action/replace.py:123:1: W293: blank line contains whitespace
lib/ansible/plugins/action/replace.py:124:72: E231: missing whitespace after ','
lib/ansible/plugins/action/replace.py:124:100: E231: missing whitespace after ','
lib/ansible/plugins/action/replace.py:127:1: W293: blank line contains whitespace
lib/ansible/plugins/action/replace.py:128:9: E303: too many blank lines (2)
lib/ansible/plugins/action/replace.py:128:14: E211: whitespace before '('
lib/ansible/plugins/action/replace.py:159:1: W293: blank line contains whitespace
lib/ansible/plugins/action/replace.py:186:99: E231: missing whitespace after ','
lib/ansible/plugins/action/replace.py:186:104: E231: missing whitespace after ','
lib/ansible/plugins/action/replace.py:190:1: W293: blank line contains whitespace
lib/ansible/plugins/action/replace.py:191:36: W292: no newline at end of file

The test ansible-test sanity --test line-endings [explain] failed with 1 error:

lib/ansible/plugins/action/replace.py:0:0: use "\n" for line endings instead of "\r\n"

The test ansible-test sanity --test pylint [explain] failed with 12 errors:

lib/ansible/plugins/action/replace.py:36:13: trailing-whitespace: Trailing whitespace
lib/ansible/plugins/action/replace.py:46:12: undefined-variable: Undefined variable 'action_plugin_result'
lib/ansible/plugins/action/replace.py:63:13: trailing-whitespace: Trailing whitespace
lib/ansible/plugins/action/replace.py:73:12: undefined-variable: Undefined variable 'action_plugin_result'
lib/ansible/plugins/action/replace.py:76:0: trailing-whitespace: Trailing whitespace
lib/ansible/plugins/action/replace.py:104:0: trailing-whitespace: Trailing whitespace
lib/ansible/plugins/action/replace.py:123:0: trailing-whitespace: Trailing whitespace
lib/ansible/plugins/action/replace.py:127:0: trailing-whitespace: Trailing whitespace
lib/ansible/plugins/action/replace.py:156:16: undefined-variable: Undefined variable 'module'
lib/ansible/plugins/action/replace.py:159:0: trailing-whitespace: Trailing whitespace
lib/ansible/plugins/action/replace.py:190:0: trailing-whitespace: Trailing whitespace
lib/ansible/plugins/action/replace.py:191:0: missing-final-newline: Final newline missing

click here for bot help

@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Oct 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects_2.10 This issue/PR affects Ansible v2.10 feature This issue/PR relates to a feature request. files Files category module This issue/PR relates to a module. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. new_plugin This PR includes a new plugin. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. support:core This issue/PR relates to code supported by the Ansible Engineering Team. WIP This issue/PR is a work in progress. Nevertheless it was shared for getting input from peers.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants