Closed mohsenasm closed 6 years ago
Hi. Thank you for the feed back.
this is a odd error.
Apparently your nextcloud instance is already installed so the roles has already passed various occ commands for setup.
yet it fails on this task : https://github.com/aalaesar/install_nextcloud/blob/master/tasks/main.yml#L67
most of the "occ" tasks are build the same, with the become_user: "{{ nextcloud_websrv_user }}"
directive.
somehow ansible didn't or failed to switch to the www-data user.
can you tel me more about your environment:
what version of ansible is used ?
do the system has sudo installed ? (if yes , can you switch to www-data with sudo -su www-data
?)
what's the default shell for www-data ?
you can get more verbose output and get directly to the failing task with --tags install_aps -vvv
to see what's appening.
Regards, Aal.
Hi
Thanks for your response, But I installed nextcloud itself after that error.
what version of ansible is used?
$ ansible --version
ansible 2.5.2
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/mohsen/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.13 (default, Nov 24 2017, 17:33:09) [GCC 6.3.0 20170516]
Do the system has sudo installed? Yes
$ sudo -su www-data
www-data@server:/home/user$
what's the default shell for www-data? Bash
$ echo $0
/bin/bash
OK thank you for your answers. I'm not sure what prevented Ansible to run occ as ww-data for this task
Thanks for your response, But I installed nextcloud itself after that error.
Not sure I understand properly: you tried to install nextcloud and the role failed first but when running it again (for logs) make it looks like it is installed already. So you tried another way.
Regards.
Hello,
I'm having the same issue @aalaesar ;
TASK [nextcloud.admin.install_nextcloud : Check Nextcloud is configured] *******
ok: [molecule-local-instance-0]
TASK [nextcloud.admin.install_nextcloud : Nextcloud installation] **************
skipping: [molecule-local-instance-0]
TASK [nextcloud.admin.install_nextcloud : [NC apps] - lists the number of apps available in the instance.] ***
fatal: [molecule-local-instance-0]: FAILED! => changed=false
cmd:
- php
- occ
- app:list
- --output=json_pretty
- --no-warnings
delta: '0:00:00.308773'
end: '2023-05-22 15:21:35.909991'
msg: non-zero return code
rc: 1
start: '2023-05-22 15:21:35.601218'
stderr: ''
stderr_lines: <omitted>
stdout: |-
Console has to be executed with the user that owns the file config/config.php
Current user id: 0
Owner id of config.php: 33
Try adding 'sudo -u #33' to the beginning of the command (without the single quotes)
If running with 'docker exec' try adding the option '-u 33' to the docker command (without the single quotes)
stdout_lines: <omitted>
PLAY RECAP *********************************************************************
molecule-local-instance-0 : ok=158 changed=27 unreachable=0 failed=1 skipped=62 rescued=0 ignored=0
It's weird because the variables used are the ones by default.
» ansible --version
ansible [core 2.14.4]
config file = /home/x/Documents/Sysadmin/piops/ansible.cfg
configured module search path = ['/home/x/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.10/site-packages/ansible
ansible collection location = /home/x/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible
python version = 3.10.10 (main, Mar 5 2023, 22:26:53) [GCC 12.2.1 20230201] (/usr/bin/python)
jinja version = 3.1.2
libyaml = True
# echo $0
bash
The system does have sudo installed.
From what I understand, I'm connecting in the context of a Molecule test, with Vagrant as the user. It might make it difficult or buggy to become another user. So I've tried to run with the verbose options and see what happens.
I did set the become user as root by default in the vars for the connection, so this might break the installation of apps.
test:
hosts:
molecule-local-instance-0:
vars:
ansible_user: root
ansible_become: true
ansible_become_user: root
The issue is that I cannot remove this, as it breaks other roles, namely the ones that install PHP versions ( or any role that uses APT ).
I'm still facing this issue. It's weird because the rest of the install works fine.
From what I understand, it's a dead end in my case because Privilege escalation must be general. Thus, I become
root, after what I cannot become
the www-data
user later in the play.
I fixed it by changing the way I become
. Protip : don't become for a whole playbook.
@nono-lqdn I'm facing the same problem. First I wrote become
in my playbook which resulted in the same error mentioned above. But without writing it in to my playbook I cannot use the role at all. It complains about not being able to install some packages with app (i.e. acl
and ca-certificates
, in tasks/setup_env.yml
-->- name: setup_env | Update ca-certificate
). So I added become: true
to this specific task which also results in ansible complaining about not having the right permission to use apt.
Where exactly did you use become
?
I use this playbook.yml
then with this command
sudo ansible-playbook playbook.yml
, I have this error:My OS Version:
Full log if needed: