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

Bug: Incompatibility with Ansible 6 #1393

Closed codepuncher closed 2 years ago

codepuncher commented 2 years ago

Terms

Description

What's wrong?

Ansible 6 was released yesterday alongside ansible-core 2.13.1 This causes deployments to fail.

What have you tried?

Adding a version constraint to requirements.txt

- ansible>=2.10.0
+ ansible>=2.10.0,<6
passlib

This works

What insights have you gained?

I needed a quick way to apply the above patch to all projects, so a helpful bash script was made as a result of this.

Possible solutions

Either use the above version constraint or update Trellis to support Ansible 6

Temporary workarounds

As mentioned above.

Steps To Reproduce

  1. rm -rf trellis/.trellis/virtualenv
  2. trellis init
  3. trellis exec ansible --version # Verify ansible-core 2.13.1 is in use
  4. trellis deploy staging

Expected Behavior

To deploy without fail

Actual Behavior

The deployment fails

Relevant Log Output

TASK [connection : Check whether Ansible can connect as chiuni] ****************
System info:
  Ansible 2.13.1; Darwin
  Trellis version (per changelog): "Add built-in fail2ban filters"
---------------------------------------------------
The field 'environment' has an invalid value, which includes an undefined
variable. The error was: 'ssh_args_default' is undefined

The error appears to be in '/Users/lee-
work/Code/wordpress/chi/trellis/roles/connection/tasks/main.yml': line 18,
column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

- name: Check whether Ansible can connect as {{ dynamic_user | default(true)
| ternary('root', web_user) }}
  ^ here
We could be wrong, but this one looks like it might be an issue with
missing quotes. Always quote template expression brackets when they
start a value. For instance:

    with_items:
      - {{ foo }}

Should be written as:

    with_items:
      - "{{ foo }}"
fatal: [kinsta_staging -> localhost]: FAILED! => {}

PLAY RECAP *********************************************************************
kinsta_staging             : ok=1    changed=0    unreachable=0    failed=1    skipped=1    rescued=0    ignored=0
localhost                  : ok=0    changed=0    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0

exit status 2

Versions

6338bd21425906a62f90480b1b0bd8b80655bc56

Related discussions

https://discourse.roots.io/t/the-field-environment-has-an-invalid-value-which-includes-an-undefined-variable-the-error-was-ssh-args-default-is-undefined/23413

codepuncher commented 2 years ago

Current workaround

  1. rm -rf trellis/.trellis/virtualenv
  2. Update the version constraint for ansible in requirements.txt file to exclude version 6 upwards
    # requirements.txt
    - ansible>=2.10.0
    + ansible>=2.10.0,<6
    passlib
  3. trellis init
  4. trellis deploy [ENVIRONMENT]
  5. Commit and push changes
swalkinshaw commented 2 years ago

https://github.com/roots/trellis/pull/1396 is a workaround for now. I'll leave this issue open to investigate the root cause.