roots / trellis

WordPress LEMP stack with PHP 8.2, Composer, WP-CLI and more
https://roots.io/trellis/
MIT License
2.51k stars 607 forks source link

wp-cli install (signature check) stuck in case of incorrect download #1295

Closed strarsis closed 3 years ago

strarsis commented 3 years ago

Description

When a wp cli phar file was downloaded (to /tmp) that doesn't match the signature file, e.g. a failed/corrupted download or using a development phar, the ansible task for installing wp-cli fails at the signature verification step. It can only be manually fixed by renaming/removing the non-matching wp-cli phar file.

Steps to reproduce

1.. Simulate an incorrect wp cli phar in /tmp (e.g. download the nightly build phar).

  1. Apply the trellis playbook. Notice that the playbook run fails now as the wp cli phar doesn't match the signature file.
  2. After manually renaming/removing the /tmp/wp-cli-*.phar and/or cleaning up the signature file /tmp/wp-cli-*.phar.asc, the playbook is applied and the specific WP CLI release is installed successfully.

Expected behavior: ansible-playbook applies correctly, installing the specified WP CLI release.

Actual behavior: ansible-playbook fails to apply in specific instances where the wp cli phar file is corrupted/changed/nightly.

Reproduces how often: When this issue happened, the issue reproduces until the wp cli phar file is renamed/cleaned up.

Versions

Fix #1284 - Update logrotate postrotate Nginx command (#1293)

swalkinshaw commented 3 years ago

I'm tempted to just say "wont fix" because the manual solution isn't that difficult? Plus I imagine this is fairly rare. But I was curious how I'd solve this with Ansible and I learned about block rescues.

Does https://github.com/roots/trellis/pull/1296 make sense as a solution?

tangrufus commented 3 years ago

1296 looks good.

Alternatively, we can force the two get_url tasks. See: https://docs.ansible.com/ansible/latest/collections/ansible/builtin/get_url_module.html#parameter-force

strarsis commented 3 years ago

I like this approach.