forem / selfhost

Selfhost your Forem Community on your own infrastructure 🎉
https://www.forem.com/get-started/
GNU Affero General Public License v3.0
1.45k stars 174 forks source link

ERROR! couldn't resolve module/action 'amazon.aws.ec2'. This often indicates a misspelling, missing collection, or incorrect module path. #77

Open DougMelvin opened 1 year ago

DougMelvin commented 1 year ago

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:

Should be written as:

with_items:
  - "{{ foo }}"_

Thanks. Doug Melvin

DougMelvin commented 1 year ago

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.ec2instance 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='publicip') | list | first }} needs to be replaced with _{{ forem_ec2_instance.instances[0].public_ipaddres }}

Thanks, Doug Melvin

ikarus-sagar commented 1 year ago

Checkout my Pull Request That will Work!