I have a previously working piece of Ansible that I’ve inherited for a previous contractor, and I’m getting an error message that doesn’t lead me in the right direction. I have tried searching for a few days now, with no joy, and my colleagues can’t figure it out either.
fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute u'subnet-0facefaceface9'\n\n
The error appears to have been in '/cup/core-kubernetes-linux/ansible/roles/aws_vpc/tasks/routes.yml': line 62, column 3, but may\n
be elsewhere in the file depending on the exact syntax problem.\n\n
The offending line appears to be:\n\n\n
- name: Routes | Set up NAT-protected route table\n
^ here\n
"}
I have added some carriage returns to make it a bit more readable.
I have tried adding extra debug, for az_to_private_sub and public_subnet_to_az, and these look OK. I’ve tried reading the docs
Use debug statements so that you know what is in “existing_nat_gateways.result” and “public_subnets_to_az”.
It looks to me as if there is no element called “subnet-0facefaceface9” in the dictionary “public_subnets_to_az” (that is a very cool subnet ID by the way).
Yes, the actual subnet id was subnet-0f18a0d4a7e9c7719. I was concerned that putting the subnet ID and other IDs into here might (somehow?) be a security issue. I’ve deleted the whole VPC now, so it won’t be a problem.
Here’s the additional debug (which all looks fine to my eyes!!)
I have noticed that when I destroy the VPC and re-run the job the existing nat gateways debug shows as “pending”, even when I show the debug, put in a 20 minute delay and then show the debug again. This seems really odd to me. I even went on to the AWS console and the However, when I re-run the job it shows as “available” and it complains about one of the eu-west-1x-public-subnet (with x being a, b or c). The route table DOES seem to have those three subnets in, but when the job fails, they disappear.