Error 'ssh_args_default' is undefined in AWX

I’m getting an error when running Trellis via AWX:

The field 'environment' has an invalid value, which includes an undefined variable. The error was: 'ssh_args_default' is undefined

The playbook runs properly from the cli. I tried defining ssh_args_default to ‘’, as well as real SSH args. All ways I tested, local CLI deployment still worked and failed in AWX.

I did see this post that covers a similar error message, and verified that the directory is not world-writable.

The full error text (below) also suggests that a string might need quotes, but is incorrect.

Suggestions?

“msg”: “The field ‘environment’ has an invalid value, which includes an undefined variable. The error was: ‘ssh_args_default’ is undefined\n\nThe error appears to be in ‘/tmp/awx_116_0yibk53w/project/trellis/roles/connection/tasks/main.yml’: line 18, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Check whether Ansible can connect as {{ dynamic_user | default(true) | ternary(‘root’, web_user) }}\n ^ here\nWe could be wrong, but this one looks like it might be an issue with\nmissing quotes. Always quote template expression brackets when they\nstart a value. For instance:\n\n with_items:\n - {{ foo }}\n\nShould be written as:\n\n with_items:\n - “{{ foo }}”\n”,

This is the line where the variable is read.

Removing {{ ssh_args_default }} prevents the error and the playbook continues beyond that task.

Yeah it most cases removing that won’t matter. I’m guessing it’s a bug to do with this line: https://github.com/roots/trellis/blob/ab70d8ed84ef54054de2024e5c2639e047c0b905/lib/trellis/plugins/callback/vars.py#L110

Maybe you could help to debug a bit and add two lines before or after it:

print(PlayContext(play=play)._ssh_args.default)
print(PlayContext(play=play)._ssh_args)

this is the output via ansible-playbook:
-o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s
<ansible.playbook.attribute.FieldAttribute object at 0x109717190>

is that a fatal error? I have no background in python.

Testing in AWX, I don’t get any python output. Any idea how to enable that?

I added some -debug lines before the -name block where the error occurs:

- debug:
    msg: "ssh_args_default:: {{ ssh_args_default }}"

- debug:
    msg: "ansible_ssh_extra_args:: {{ ansible_ssh_extra_args | default('') }}"

this shows the following

TASK [connection : Specify preferred HostKeyAlgorithms for unknown hosts] ************************************************************************************
skipping: [domain.co]

TASK [connection : debug] ***************************************************************************************
ssh_args_default:: -o ForwardAgent=yes -o ControlMaster=auto -o
ControlPersist=60s
ok: [domain.co]

TASK [connection : debug] ***************************************************************************************
ansible_ssh_extra_args::
ok: [domain.co]

Interesting… thanks for debugging.

It’s odd because the error message was 'ssh_args_default' is undefined but in both your debugging attempts it did exist :thinking:

Maybe I’m confused but I don’t see why it would have failed in the first place based on this:

TASK [connection : debug] ***************************************************************************************
ssh_args_default:: -o ForwardAgent=yes -o ControlMaster=auto -o
ControlPersist=60s
ok: [domain.co]

I learned a few things on SO: https://stackoverflow.com/questions/59848192/

Primarily, I needed to set the path in AWX settings to callback plugins. That got the ball rolling for me. That lead to a lightbulb moment about directory structure in AWX and I rebuilt the repo with trellis as the base and site (bedrock) inside.

I also had to rename galaxy.yml to roles/requirements.yml for AWX to find it.

Probably a couple of other things as well. I’ll post more detailed findings and maybe a PR when I’ve gotten this cleaned up a bit more. So glad this part is behind me now. Hoped to get AWX working in an afternoon and it’s been a week. :rofl:

1 Like

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