Command `bench setup production` is giving error on Ubuntu 22.04

I am setting Frappe and ERPNext on a new server using the command sudo -H bench setup production <user> but am getting following error.

Setting Up prerequisites...
$ bench setup role fail2ban
ansible-playbook [core 2.17.1]
  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, Mar 22 2024, 16:50: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', 'fail2ban']' returned non-zero exit status 1.
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 8, in <module>
    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', 'fail2ban']' returned non-zero exit status 1.
ERROR: bench setup role fail2ban
subprocess.CalledProcessError: Command 'bench setup role fail2ban' 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 <module>
    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 28, in setup_production_prerequisites
    exec_cmd("bench setup role fail2ban")
  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 fail2ban

I guess it’s a fresh installation, Remove the files including ubuntu , re-install ubuntu , and without creating any user, use this script to install Erpnext.

1 Like

Else try these–>

 update ansible to the last a version >= 2.4.0.0. or later

Type this command with superuser like

 1. Sudo su -
When you run sudo su - then you see as root user and then type fail2ban command.

Other references- Error while setting up bench to production mode

Hope it helps !!

Hi,

It may help to say the Frappe ERPNext versions, where the code was obtained from, and which installation instructions were followed on the new server.

The offending line appears to be:

---
- include: centos.yml

Manually install fail2ban, nginx and supervisor.

sudo apt install fail2ban nginx supervisor

sudo bench setup production $USER

1 Like

I also had this problem on Ubuntu. The reason was that for the latest version of ansible include gives an error. Changing all references from include to include_tasks in /usr/.local/lib/python3.12/site-packages/bench/playbooks/roles/mariadb/tasks/main.yml fixed things

This is a bug in frappe framework now that ansible are not honoring ‘include’ I believe

Thanks @HUMENTH

Your suggestions worked!

My problem is solved.

1 Like

The link you have shared specifically states on the page that it is important to create a Frappe User.


Are you sure we can run this script without creating any user?

Yes i installed in 2 systems without creating the users, and never faced any issue, rest it’s up to you

1 Like