Then I try to run ansible-playbook dev.yml -vvv and it doesn’t get past the first task, python_interpreter : Get Ubuntu version
Is there someplace in vagrant up or vagrant provision that admin_user and web_user are supposed to be created? I’m not seeing it in the vagrant output.
I wondered about that. There doesn’t seem to be a setting for $ANSIBLE_LOG_PATH in the trellis venv, so I added log_path = ./ansible.log to ansible.cfg and am running vagrant destroy -f && vagrant up again.
In vagrant up the output contains these references to “user”:
TASK [common : Generate SSH key for vagrant user] ******************************
TASK [mariadb : Set root user password] ****************************************
TASK [mariadb : Delete anonymous MySQL server users] ***************************
with a mode of 0700, this may cause issues when running as another user. To
TASK [wordpress-setup : Create/assign database user to db and grant permissions] ***
TASK [wordpress-install : Change site owner to user] ***************************
Yes. Thank you. Running over previous vagrant up and vagrant provision server, same result:
TASK [python_interpreter : Get Ubuntu version] ***************************************************************************************
task path: example.com/trellis/roles/python_interpreter/tasks/main.yml:2
<192.168.50.5> ESTABLISH LOCAL CONNECTION FOR USER: mikekilmer
<192.168.50.5> EXEC sudo -H -S -n -u root /bin/sh -c 'echo BECOME-SUCCESS-ghmrvlsmcvmeqvmkluaxlxmwcdqypahr ; lsb_release -rs'
System info:
Ansible 2.10.13; Darwin
Trellis 1.8.0: February 12th, 2021
[WARNING]: Failure using method (v2_runner_on_failed) in callback plugin (<ansible.plugins.callback.output.CallbackModule object at
0x110bc3a00>): Invalid color supplied to display: bright gray
Callback Exception:
File "example.com/trellis/.trellis/virtualenv/lib/python3.9/site-packages/ansible/executor/task_queue_manager.py", line 389, in send_callback
method(*new_args, **kwargs)
File "example.com/trellis/lib/trellis/plugins/callback/output.py", line 42, in v2_runner_on_failed
output.display_host(self, result)
File "example.com/trellis/lib/trellis/utils/output.py", line 120, in display_host
display(obj, result)
File "example.com/trellis/lib/trellis/utils/output.py", line 105, in display
display(system(obj.vagrant_version), 'bright gray')
File "example.com/trellis/.trellis/virtualenv/lib/python3.9/site-packages/ansible/utils/display.py", line 215, in display
raise AnsibleAssertionError('Invalid color supplied to display: %s' % color)
I’m going to try the vagrant destroy loop again, using that ansible-playbook commend rather than vagrant up and vagrant provision. Is this something that needs to be run following vagrant up? Now I’m getting that error when vagrant up hasn’t been run.
With or without vagrant up beforehand, this fails with same error.
Cloned the Trellis master directly, created my own venv for pip requirements, server.yml is looking for a swapfile role, which doesn’t seem to exist (either locally or on github).
I had forgotten to run ansible-galaxy install -r galaxy.yml.
Following that, same “password is required” when I run ansible-playbook server.yml -e env=development, both before and after vagrant up. Same error also after vagrant provision and no admin user created. Don’t know if there’s supposed to be one, or if vagrant is supposed to be the user on dev box.
When running the server.yml playbook directly with --ask-become-pass, it stalls indefinitely (ten minutes plus) on that command. I’m about ready to throw in the towel on Ansible… I mean Trellis… I mean web development… I mean computers at all.
This option will cause ansible to prompt for the sudo password interactively.
As this doesn’t work in playbooks, ansible will wait for it unsuccessfully until it times out.
Can you define the password directly in ansible config, e.g. as ansible_become_password variable?
- block:
- name: Get Ubuntu version
raw: lsb_release -rs
register: ubuntu_version
changed_when: false
- name: Set ansible_python_interpreter for Ubuntu >= 18.04
set_fact:
ansible_python_interpreter: python3
ansible_become_password: "mikekilmer"
when: ubuntu_version.stdout | trim is version('18.04', '>=')
when: ansible_python_interpreter is not defined
tags: always
I think what it comes down to is that Ansible is trying to connect as the user who runs the playbook in the host machine (mikekilmer), while that user hasn’t been created on the guest machine.
Is there supposed to be a user on the guest which matches the host? Or, is Ansible not supposed to be trying to connect as the host user who runs the playbook (mikekilmer)?
Just had an idea: You are using a fresh clone from Trellis, right? Have you also ensured that no .ansible folder from previous attempts is used? These hidden folders could still be there.
Tried blowing out trellis/.vagrant as well as ~/.ansible. Same result. After running vagrant up --provision, there is no admin user, no web user, no user matching the host machine user who runs the playbook.
And same result trying to run ansible-playbook server.yml -e env=development:
<192.168.50.5> ESTABLISH LOCAL CONNECTION FOR USER: mikekilmer
<192.168.50.5> EXEC sudo -H -S -n -u root /bin/sh -c 'echo BECOME-SUCCESS-qlcblryqaqnlhnqrkaarqfdwxswlthyb ; lsb_release -rs'
System info:
Ansible 2.10.13; Darwin
Trellis version (per changelog): "Fix #1277 - Disable PHP CLI memory limit"
---------------------------------------------------
non-zero return code
sudo: a password is required
fatal: [192.168.50.5]: FAILED! => {
"changed": false,
"rc": 1,
"stderr_lines": [
"sudo: a password is required"
],
"stdout": "",
"stdout_lines": []
}
May be worth mentioning as well, that xDebug doesn’t seem to be enabled, which is what got me trying to run the provisioning tasks in the first place:
Note: Ansible will attempt connections as user = admin ok: [192.168.50.5]
But there is no admin user. Do you know if there is supposed to be an admin or a web user on the dev machine? I see that vagrant, in www-data group, owns the web files:
Additionally, I’m not sure if the IP address I have set in vagrant.default.yml is the one that should be referenced in the logs, but as you can see, it’s 192.168.50.5. Previously, I’ve been using the default IP. This time, I tried updating it to 192.168.50.9.
If I understand correctly, the following settings in hosts/development makes it so that within the Vagrant box, 192.168.50.5 is used, while locally, in the host, it’s 192.168.50.9:
In the browser, example.test is served, but I want to be able to re-provision using Ansible/Trellis, not to mention, I believe xDebug is supposed to be active “out of the box.”
This was a red herring, just telling me that xDebug isn’t enabled for the command line php. If I put phpinfo() into a file at /srv/www/example.com/current/web/info.php it confirms xDebug is active.