Ive now resolved this issue as ive found that the ansible.builtin.apt command did not deploy the any of the packages I listed in the ansible.yaml file.
I found this out by accessing the temp EC2 instance that was creating the AMI and listing installed packages. In the end I installed libyaml-dev from the command line and after a while ruby 3.3.5 was installed.