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

Drush 9 output values return as string rather than array when executed on Ansible with remote alias #3298

Closed
ericpugh opened this issue Jan 10, 2018 · 4 comments

Comments

@ericpugh
Copy link

Using Drush 9.0.0-rc2 and Ansible 2.4
I'm having an issue executing drush commands from a simple Ansible playbook, and I'm thinking that there is something about Drush 9 return codes that are causing a problem.

For example, below is a simple playbook to test executing on a remote alias from a local DrupalVM inventory. All drush commands when executed directly on the local box with the remote alias work as expected. Also, non-drush tasks when executed from the Ansible playbook work as expected. However, drush commands always fails (stopping the playbook execution) even though the command successfully executes on the remote box.

Example playbook:

- hosts: all
  become: no

  tasks:
    - name: Execute a drush command on the remote.
      command: "/var/www/drupal/vendor/bin/drush @drupalvm.remote cr"
      args:
        chdir: "/var/www/drupal/web"

This fails, returning the following to the Ansible recap, but the cache is sucessfully rebuilt on the remote :

fatal: [192.168.88.88]: FAILED! => {
	"changed": true, 
	"cmd": ["/var/www/drupal/vendor/bin/drush", "@drupalvm.remote", "cr"], 
	"delta": "0:00:23.032100", 
	"end": "2018-01-10 13:04:33.274621", 
	"msg": "non-zero return code", 
	"rc": 1, 
	"start": "2018-01-10 13:04:10.242521", 
	"stderr": " [error]  The command could not be executed successfully (returned:  [success] Cache rebuild complete.\n, code: 0) ",
	"stderr_lines": [" [error]  The command could not be executed successfully (returned:  [success] Cache rebuild complete.", ", code: 0) "], 
	"stdout": " [success] Cache rebuild complete.", "stdout_lines": [" [success] Cache rebuild complete."]
}

It seems like something has changed with the exit status of drush commands in backend.inc??

@weitzman
Copy link
Member

Nothing has deliberately changed. Perhaps run same commands manually with --verbose and verify exit codes - https://www.cyberciti.biz/faq/shell-how-to-determine-the-exit-status-of-linux-and-unix-command/

@ericpugh
Copy link
Author

ericpugh commented Jan 10, 2018

Thanks for the reply. That's what was confusing me, because executed manually (and in the output of the Ansible recap) was always "code: 0"
This PR fixes the issue for me. Since this description is about Aegir, I'm not sure exactly what the similarities are, but it seems that when executed via Anisble there is something different about the output string that is not properly parsed in drush_backend_parse_output and gets returned as a string rather than an Array
#3260

@ericpugh ericpugh changed the title Drush 9 non-zero return code when executed on Ansible with remote alias Drush 9 output values return as string rather than arraywhen executed on Ansible with remote alias Jan 10, 2018
@ericpugh ericpugh changed the title Drush 9 output values return as string rather than arraywhen executed on Ansible with remote alias Drush 9 output values return as string rather than array when executed on Ansible with remote alias Jan 10, 2018
@weitzman
Copy link
Member

I wonder if this is another instance of #3127

@greg-1-anderson
Copy link
Member

Yes, duplicate of #3127. Let's track there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants