I'm creating a custom AMI using packer and ansible. The base AMI is an Ubuntu 20.04 provided by the Canonical and it's customized using an ansible playbook.
I'm installing python3.9 and setting it as the default python:
- name: Setup Python3.9 As Default Python Interpreter
shell: |
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 2
Each EC2 instance based on this AMI is unreachable via ssh (I have installed openssh-server and placed the keys). Once the instance is rebooted I can ssh to the server.
The issue seams to be with the cloud-init
package that is not working with python3.9.
What did I try?
- Disable the
cloud-init
package - no ssh connection even after the reboot
- Manually install the latest version of
cloud-init
- no ssh on the initial boot, ssh after the reboot worked. Got this error - ubuntu@ip-XXX-XX-XX-XXX:~$ docker Traceback (most recent call last): File "/usr/lib/command-not-found", line 28, in <module> from CommandNotFound import CommandNotFound File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 19, in <module> from CommandNotFound.db.db import SqliteDatabase File "/usr/lib/python3/dist-packages/CommandNotFound/db/db.py", line 5, in <module> import apt_pkg ModuleNotFoundError: No module named 'apt_pkg'