ERROR: bench setup role nginx (Production)

I’m trying to setup production mode for my erpnext 15 but i’m getting this error.

darklord@Rahul-PC:~/frappe-bench$ sudo bench setup production darklord
[sudo] password for darklord:
Setting Up prerequisites…
$ bench setup role nginx
ansible-playbook [core 2.16.7]
config file = None
configured module search path = [‘/root/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/local/lib/python3.10/dist-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/local/bin/ansible-playbook
python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (/usr/bin/python3)
jinja version = 3.1.4
libyaml = True
No config file found; using defaults
setting up inventory plugins
Loading collection ansible.builtin from
host_list declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
script declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
auto declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
yaml declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
ini declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
toml declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does
not match ‘all’
ERROR! [DEPRECATED]: ansible.builtin.include has been removed. Use include_tasks or import_tasks instead. This feature was removed from ansible-core in a release after 2023-05-16. Please update your playbooks.

The error appears to be in ‘/usr/local/lib/python3.10/dist-packages/bench/playbooks/roles/mariadb/tasks/main.yml’: line 2, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


  • include: centos.yml
    ^ here
    ERROR: Command ‘[‘ansible-playbook’, ‘-c’, ‘local’, ‘site.yml’, ‘-vvvv’, ‘-e’, ‘{“production”: true, “admin_emails”: “”, “mysql_root_password”: null, “container”: false}’, ‘-t’, ‘nginx’]’ returned non-zero exit status 1.
    Traceback (most recent call last):
    File “/usr/local/bin/bench”, line 8, in
    sys.exit(cli())
    File “/usr/local/lib/python3.10/dist-packages/bench/cli.py”, line 132, in cli
    bench_command()
    File “/usr/local/lib/python3.10/dist-packages/click/core.py”, line 1157, in call
    return self.main(*args, **kwargs)
    File “/usr/local/lib/python3.10/dist-packages/click/core.py”, line 1078, in main
    rv = self.invoke(ctx)
    File “/usr/local/lib/python3.10/dist-packages/click/core.py”, line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
    File “/usr/local/lib/python3.10/dist-packages/click/core.py”, line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
    File “/usr/local/lib/python3.10/dist-packages/click/core.py”, line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
    File “/usr/local/lib/python3.10/dist-packages/click/core.py”, line 783, in invoke
    return __callback(*args, **kwargs)
    File “/usr/local/lib/python3.10/dist-packages/bench/commands/setup.py”, line 370, in setup_roles
    run_playbook(“site.yml”, extra_vars=extra_vars, tag=role)
    File “/usr/local/lib/python3.10/dist-packages/bench/utils/init.py”, line 345, in run_playbook
    subprocess.check_call(args, cwd=os.path.join(bench.path[0], “playbooks”))
    File “/usr/lib/python3.10/subprocess.py”, line 369, in check_call
    raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command ‘[‘ansible-playbook’, ‘-c’, ‘local’, ‘site.yml’, ‘-vvvv’, ‘-e’, ‘{“production”: true, “admin_emails”: “”, “mysql_root_password”: null, “container”: false}’, ‘-t’, ‘nginx’]’ returned non-zero exit status 1.
    ERROR: bench setup role nginx
    subprocess.CalledProcessError: Command ‘bench setup role nginx’ returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “/usr/local/bin/bench”, line 8, in
sys.exit(cli())
File “/usr/local/lib/python3.10/dist-packages/bench/cli.py”, line 132, in cli
bench_command()
File “/usr/local/lib/python3.10/dist-packages/bench/commands/setup.py”, line 110, in setup_production
setup_production(user=user, yes=yes)
File “/usr/local/lib/python3.10/dist-packages/bench/config/production_setup.py”, line 37, in setup_production
setup_production_prerequisites()
File “/usr/local/lib/python3.10/dist-packages/bench/config/production_setup.py”, line 30, in setup_production_prerequisites
exec_cmd(“bench setup role nginx”)
File “/usr/local/lib/python3.10/dist-packages/bench/utils/init.py”, line 178, in exec_cmd
raise CommandFailedError(cmd) from subprocess.CalledProcessError(return_code, cmd)
bench.exceptions.CommandFailedError: bench setup role nginx

Help someone
Thanks

What is your ansible version?

it’s showing 2.16.7

darklord@Rahul-PC:~/frappe-bench$ ansible --version
ansible [core 2.16.7]
config file = None
configured module search path = [‘/home/darklord/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/local/lib/python3.10/dist-packages/ansible
ansible collection location = /home/darklord/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/local/bin/ansible
python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (/usr/bin/python3)
jinja version = 3.1.4
libyaml = True

image

My current version is working fine for me. Please check once

how to downgrade ansible version

Uninstall the old one and download the version as per your need.

 pip uninstall ansible

 pip install ansible==X.Y.Z

 for example - pip install ansible==2.9.10

I tried many version but none of them fix the issue. which one is right?

im also tring to start production server for my custom app any where a full guied of steps and requirement for installation

You can save yourself the hassle by using this GitHub - flexcomng/erpnext_quick_install: Unattended install script for ERPNext Versions, 13, 14 and 15

2 Likes

thanks for your reply but i m trying to install my own application in production mode , and which packages required for enable to production i saw lot off error some ansible , fail2ban , ngnix, wich steps have to create production Env

You will hardly find this exact information anywhere with regards specific packages as some of them are dependencies which are installed as part of other installations. There are a lot of manual install guides in the forum and i believe a quick search will return tons of results. You can also check here for basic information about the packages required for installing ERPNext GitHub - frappe/bench: CLI to manage Multi-tenant deployments for Frappe apps

But the script i shared earlier handles all the required packages for production installation. You can also inspect the content of the script to find the information you need if you absolutely need to manual install.

1 Like

I like to keep this thread open.
I ve same same problem and no solution.
I ve an ansbile playbook to create a erpnext under debian. Last run 3 month ago everything was working. right now i run in the same problem.

bye shb

Hi I faced the same issue and fixed by modifying the below file.

sudo nano /usr/local/lib/python3.10/dist-packages/bench/playbooks/roles/mariadb/tasks/main.yml

modify include to include_tasks:

  • include_tasks: centos.yml

when: ansible_distribution == ‘CentOS’ and ansible_distribution_major_version|int >= 6

  • include_tasks: ubuntu-trusty.yml

when: ansible_distribution == ‘Ubuntu’ and ansible_distribution_version == ‘14.04’

  • include_tasks: ubuntu-xenial_bionic.yml

when: ansible_distribution == ‘Ubuntu’ and ansible_distribution_major_version|int >= 16
iss

3 Likes

thanks @Abu_Fawzan_khalid your solution worked