Thank you this worked for me very well until I started hit a snag when now try to ran bench setup production (username) : I am getting an error associated with python3-apt, let me paste the error below
TASK [fail2ban : Install fail2ban] *****************************************************************************************************************************
task path: /usr/local/lib/python3.10/dist-packages/bench/playbooks/roles/fail2ban/tasks/main.yml:6
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<127.0.0.1> EXEC /bin/sh -c ‘echo ~root && sleep 0’
<127.0.0.1> EXEC /bin/sh -c ‘( umask 77 && mkdir -p “echo /root/.ansible/tmp
”&& mkdir “echo /root/.ansible/tmp/ansible-tmp-1658325828.2886786-1834-7555114602888
” && echo ansible-tmp-1658325828.2886786-1834-7555114602888=“echo /root/.ansible/tmp/ansible-tmp-1658325828.2886786-1834-7555114602888
” ) && sleep 0’
Using module file /usr/local/lib/python3.10/dist-packages/ansible/modules/apt.py
<127.0.0.1> PUT /root/.ansible/tmp/ansible-local-1773cnt95zto/tmpf8oz70cl TO /root/.ansible/tmp/ansible-tmp-1658325828.2886786-1834-7555114602888/AnsiballZ_apt.py
<127.0.0.1> EXEC /bin/sh -c ‘chmod u+x /root/.ansible/tmp/ansible-tmp-1658325828.2886786-1834-7555114602888/ /root/.ansible/tmp/ansible-tmp-1658325828.2886786-1834-7555114602888/AnsiballZ_apt.py && sleep 0’
<127.0.0.1> EXEC /bin/sh -c ‘/usr/bin/python3.10 /root/.ansible/tmp/ansible-tmp-1658325828.2886786-1834-7555114602888/AnsiballZ_apt.py && sleep 0’
<127.0.0.1> EXEC /bin/sh -c ‘rm -f -r /root/.ansible/tmp/ansible-tmp-1658325828.2886786-1834-7555114602888/ > /dev/null 2>&1 && sleep 0’
[WARNING]: Updating cache and auto-installing missing dependency: python3-apt
fatal: [localhost]: FAILED! => {
“changed”: false,
“invocation”: {
“module_args”: {
“allow_change_held_packages”: false,
“allow_downgrade”: false,
“allow_unauthenticated”: false,
“autoclean”: false,
“autoremove”: false,
“cache_valid_time”: 0,
“clean”: false,
“deb”: null,
“default_release”: null,
“dpkg_options”: “force-confdef,force-confold”,
“fail_on_autoremove”: false,
“force”: false,
“force_apt_get”: false,
“install_recommends”: null,
“lock_timeout”: 60,
“name”: “fail2ban”,
“only_upgrade”: false,
“package”: [
“fail2ban”
],
“policy_rc_d”: null,
“purge”: false,
“state”: “present”,
“update_cache”: null,
“update_cache_retries”: 5,
“update_cache_retry_max_delay”: 12,
“upgrade”: “no”
}
},
“msg”: “python3-apt must be installed and visible from /usr/bin/python3.10.”
}
PLAY RECAP *****************************************************************************************************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=1 skipped=1 rescued=0 ignored=0
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 2.
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 121, in cli
raise e
File “/usr/local/lib/python3.10/dist-packages/bench/cli.py”, line 111, in cli
bench_command()
File “/usr/local/lib/python3.10/dist-packages/click/core.py”, line 1130, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python3.10/dist-packages/click/core.py”, line 1055, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python3.10/dist-packages/click/core.py”, line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python3.10/dist-packages/click/core.py”, line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python3.10/dist-packages/click/core.py”, line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python3.10/dist-packages/click/core.py”, line 760, in invoke
return __callback(*args, **kwargs)
File “/usr/local/lib/python3.10/dist-packages/bench/commands/setup.py”, line 273, 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 322, 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 2.
ERROR:
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 121, in cli
raise e
File “/usr/local/lib/python3.10/dist-packages/bench/cli.py”, line 111, in cli
bench_command()
File “/usr/local/lib/python3.10/dist-packages/click/core.py”, line 1130, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python3.10/dist-packages/click/core.py”, line 1055, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python3.10/dist-packages/click/core.py”, line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python3.10/dist-packages/click/core.py”, line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python3.10/dist-packages/click/core.py”, line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python3.10/dist-packages/click/core.py”, line 760, in invoke
return __callback(*args, **kwargs)
File “/usr/local/lib/python3.10/dist-packages/bench/commands/setup.py”, line 72, in setup_production
setup_production(user=user, yes=yes)
File “/usr/local/lib/python3.10/dist-packages/bench/config/production_setup.py”, line 33, in setup_production
setup_production_prerequisites()
File “/usr/local/lib/python3.10/dist-packages/bench/config/production_setup.py”, line 24, in setup_production_prerequisites
exec_cmd(“bench setup role fail2ban”)
File “/usr/local/lib/python3.10/dist-packages/bench/utils/init.py”, line 153, in exec_cmd
raise CommandFailedError
bench.exceptions.CommandFailedError
I have tried to follow other solutions on the net like
cd /usr/lib/python3/dist-packages
and pasting these two;
sudo ln -s apt_inst.cpython-38m-x86_64-linux-gnu.so apt_inst.so
sudo ln -s apt_pkg.cpython-38m-x86_64-linux-gnu.so apt_pkg.so
since am not sure what version 3.10 uses for these files i left them as for version 3.8
I also did the same on this route
/usr/local/lib/python3.10/dist-packages
Am still getting the same error not sure if you had success. Am using ubuntu 20.04LTS , am considering reinstalling the OS and try again