Running "wp ai1wm" CLI from build-after.yml

Good evening,

Hoping someone else has come across this issue/knows of a simple solution. I’ve attempted all variants of echo “Y/y”, using yes | wp ai1wm, etc… Nothing seems to work.

I’ve tested that running the command as-is does run successfully if run manually within vagrant (in the same directory the build step runs from):

  • name: Restore from latest backup with All-in-One WP Migration
    command: echo ‘y’ | wp ai1wm restore development-btraill-test-wp-20240324-130438-zee8xf.wpress
    args:
    chdir: “{{ deploy_helper.new_release_path }}/web/app/ai1wm-backups/”

Any ideas how to get the Ansible build-after.yml to run the following command?

wp ai1wm restore development-btraill-test-wp-20240324-130438-zee8xf.wpress

Command output:

wp ai1wm restore development-btraill-test-wp-20240324-130438-zee8xf.wpress
Restore in progress…
The import process will overwrite your website including the database, media, plugins, and themes. Are you sure to proceed? [y/n]

I hit y and the command processes for about 30-45seconds:

Success: Restore complete.

When I run it via the build-after.yml:

TASK [deploy : Restore from latest backup with All-in-One WP Migration] ********
changed: [redacted]

Running the command via build-after.yml takes maybe half of the time – which indicates it’s not completing. (I see no changes)

One additional note: If I use yes | wp ai1wm restore – it seems to just hang and never return.

Am I missing something easy? I have verified the file exists on the server in the directory path that {{ deploy_helper.new_release_path }}/web/app/ai1wm-backups/ resolves to.

Does not the command support the --yes flag for confirming non-interactively?

Also there appears to be a filter that is used for getting an user confirmation (add_filter( 'ai1wm_import', 'Ai1wm_Import_Confirm::execute', 100 );), so you could try removing that filter (in PHP, with the CLI code (maybe a plugin?))?

Thank you – I don’t know why I didn’t think of the --yes flag. That worked!