Roots Discourse

Error while evaluating conditional (not (not ansible_ssh_extra_args)): 'ansible_ssh_extra_args' is undefined

I’m getting an error when trying to provision a remote server:
System info:
Ansible 2.11.1; Darwin
Trellis version (per changelog): “Improve handling of PHP versions and support PHP 8.0”
---------------------------------------------------
The conditional check ‘not (not ansible_ssh_extra_args)’ failed. The error
was: error while evaluating conditional (not (not ansible_ssh_extra_args)):
‘ansible_ssh_extra_args’ is undefined

The error appears to be in '/Users/james/Sites/square-
mile/trellis/roles/connection/tasks/main.yml': line 9, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


- name: Specify preferred HostKeyAlgorithms for unknown hosts
  ^ here
fatal: [138.68.144.64]: FAILED! => {}

PLAY RECAP **********************************************************************************************************************************
138.68.144.64              : ok=0    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   

Provision has always gone fine for me before, any ideas?

This reminds me of a recent PR that has been merged, it could also solve your issue:

Thanks for your help starsis, that didn’t work but I have managed to fix it it seems.

I think it was just an issue with my ansible. I tried to update it last week and it throw some errors, I thought i’d navigated them and updated, but it must not have properly updated. I’m not quite sure what the fix was in the end, but I temporarily renamed some folders in in Library > Python … > ansible and installed again and have now managed to provision a server and deploy to another one.

Same error here.

With Ansible v2.9.23 as installed via Trellis-cli, same with Ansible v2.10.11.

Also tried using

  • v2.8 for ERROR! Unexpected Exception, this is probably a bug: cannot pickle '_io.TextIOWrapper' object)
  • v2.9.0 for ERROR! Unexpected Exception, this is probably a bug: cannot pickle 'module' object.
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 '/Volumes/Ochosi/Clients/Client/example.com/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: [157.230.58.##]: FAILED! => {}

Current, latest [HEAD/Master of the roles/connect/main tasks](https://raw.githubusercontent.com/roots/trellis/master/roles/connection/tasks/main.yml, with the update to not ansible_ssh_extra_args.

I am using the virtual environment generated by Trellis-cli, Python v3.8.5 on Big Sur.

That uninitialized (undefined) variable ssh_args_default is defined in Python code by Trellis:

So that function is either not called or it isn’t able to set that variable.

More information about .ssh_args:
https://docs.ansible.com/ansible/2.9/plugins/connection/ssh.html?highlight=ansible%20doc#parameter-ssh_args

1 Like

You are so dope, @strarsis. What would I do without you.

In my case, the only difference in the plugins/callback/vars.py file was that I had this line in there:

# handle Ansible 2.7 and 2.8 cases by normalizing each into a dict
-        try:
-            from ansible import context

I think I had restored that line in initial troubleshooting, following having rebased my local Trellis codebase.

I am using Ansible v10. What I think may have solved the issue for me is that at some point in my hacking, I had added quotes around {{ dynamic_user | default(true) | ternary('root', web_user) }}.

So, sadly, I’m not sure what exactly caused the error in the first place.

In my case, it’s resolved. Thank you!

This topic was automatically closed after 42 days. New replies are no longer allowed.