ERROR! couldn't resolve module/action 'amazon.aws.ec2'. This often indicates a misspelling, missing collection, or incorrect module path.
DougMelvin opened this issue · comments
I did this last week for a different client and everything worked as expected (eventually).
I've even nuked the VM I am working from and started completely from scratch five times so far.
I am doing this on the most recent version of Ubuntu Desktop from within a Virtualbox VM.
Please help me. I am at my wits' end.
Here are the steps I performed:
(I have been at this for hours so may have forgotten to document one or more step below)
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository --yes --update ppa:ansible/ansible
sudo apt install ansible
sudo apt install python3-pip
sudo apt install podman
sudo apt install pwgen
podman pull quay.io/coreos/butane:release
sudo apt install git
git clone https://github.com/forem/selfhost.git
cd selfhost
./setup
-- added the vault keys including the silly indents with exactly the correct number of spaces.
-- added the domain, subdomain and default email.
ansible-galaxy collection install -r requirements.yml
ssh-keygen -t rsa
pip3 install boto boto3 botocore
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
aws configure --profile forem-selfhost
ansible-playbook -i inventory/forem/setup.yml playbooks/providers/aws.yml
Then I get an error:
_ERROR! couldn't resolve module/action 'amazon.aws.ec2'. This often indicates a misspelling, missing collection, or incorrect module path.
The error appears to be in '/home/doug/selfhost/playbooks/providers/aws.yml': line 170, column 5, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
-
name: "Launch Forem instance for {{ app_domain }}"
^ here
We could be wrong, but this one looks like it might be an issue with
missing quotes. Always quote template expression brackets when they
start a value. For instance:with_items:
- {{ foo }}
Should be written as:
with_items:
- "{{ foo }}"_
Thanks.
Doug Melvin
Either the AWS API changed or the latest version of the CLI or some other module but the result is that the module "amazon.aws.ec2" is not longer supported.
In /playbooks/providers/aws.yml starting at line 171 I needed to change amazon.aws.ec2 to amazon.aws.ec2_instance and update the parameters to match the expectations of the new module.
https://docs.ansible.com/ansible/latest/collections/amazon/aws/ec2_instance_module.html
There was also an error in the last two steps - deleting the content from the bucket and displaying the public IP address.
I did not fix those as I was happy enough to get the instance deployed.
I am pretty sure that {{ forem_ec2_instance.tagged_instances | map(attribute='public_ip') | list | first }}
needs to be replaced with {{ forem_ec2_instance.instances[0].public_ip_addres }}
Thanks,
Doug Melvin
Checkout my Pull Request That will Work!