Cannot import name 'cli' from '__main__'

I’m trying to get a Digital Ocean droplet setup with a barebones Trellis installation.

So far I have:

  • Setup a new Ubuntu 20.04 Server
  • Created a new user adduser daniel
  • Added user to sudo sudo -aG sudo daniel
  • Switched to user su daniel
  • Updated and upgraded sudo apt-get update and sudo apt-get upgrade
  • Installed Homebrew /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  • Then followed that with their recommendation to add to path and install build essentials: echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> /home/daniel/.profile and eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" and sudo apt-get install build-essential
  • Installed Python3 as described in Trellis docs sudo apt-get install -y python3 python-is-python3 python3-pip
  • Installed python3-venv as mentioned in a Trellis error message: sudo apt-get install python3-venv
  • Created a new project in ~/projects/ trellis new example.com
  • Enter the project directory cd ~/projects/example.com
  • Added Digital Ocean access token to environment variable export DIGITALOCEAN_ACCESS_TOKEN={redacted}
  • Create a new Digital Ocean droplet trellis droplet create production

I then get the following warning, both at this stage, or if I try to use trellis provision production

[WARNING]: Skipping plugin (/home/daniel/projects/example.com/trellis/lib /trellis/plugins/callback/vars.py) as it seems to be invalid: cannot import name 'cli' from '__main__' (/home/daniel/projects/example.com/trellis/.tr ellis/virtualenv/bin/ansible-playbook)

And then the following error


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 '/home/daniel/projects/example.com/trellis/r
oles/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: [104.248.172.171 → localhost]: FAILED! => {}`


I feel like I must be missing something obvious. I’ve worked out (I think) that the error message is due to the vars.py warning. cannot import name 'cli' from '__main__'.

Am I doing something wrong in the setup process to cause this error?

Ah, I found the GitHub issue related to this.

This fixed it for me.

1 Like

Hey Daniel, glad you found that fix!

One other thing I noticed, it seems like you installed trellis-cli on the Ubuntu server?

The usual workflow is to install trellis-cli and create Trellis projects on your local computer, then provision the remote server and deploy to it. This wouldn’t have avoided the issue you ran into but just wanted to point it out.

Another note is that trellis-cli has a trellis droplet create command to automate creating and provisioning a server on Digital Ocean :smile:

Hey

Thanks - I had trouble setting up Trellis on WSL so I setup a Ubuntu Server to see if that fixed it. Now I know more about how Trellis/Vagrant etc. works I’m now setting up on WSL again.

Should have mentioned the instructions I listed above were in-place of doing it on my local machine.

Thanks for the advice
Dan