Install error (Linux, AWS)
MakaryGo opened this issue · comments
Describe the bug
When trying to set it up according to the instructions, it crashes at step
fatal: [forem]: FAILED! =>
msg: |-
The task includes an option with an undefined variable. The error was: list object has no element 0
The error appears to be in '/home/makarygo/selfhost/playbooks/providers/aws.yml': line 48, column 5, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: Set forem_vpc_id fact
^ here
To Reproduce
ansible-playbook -i inventory/forem/setup.yml playbooks/providers/aws.yml
OS (please complete the following information):
- Linux
Cloud Provider (please complete the following information):
- AWS
Task step looks for a default VPC https://github.com/forem/selfhost/blob/main/playbooks/providers/aws.yml#L41-L50. If you deleted the default one it will be blank and fail.
You can comment lines 41 to 50:
- amazon.aws.ec2_vpc_net_info:
filters:
"isDefault": "true"
region: "{{ fcos_aws_region }}"
profile: "{{ fcos_aws_profile }}"
register: forem_vpc_info
- name: Set forem_vpc_id fact
ansible.builtin.set_fact:
forem_vpc_id: "{{ forem_vpc_info['vpcs'][0]['vpc_id'] }}"
and then just pass in the VPC ID (replace vpc-1212233445566
in the example below with your AWS VPC ID) from your account in the region you are using via an extra var:
ansible-playbook -i inventory/forem/setup.yml playbooks/providers/aws.yml -e forem_vpc_id=vpc-1212233445566
or use a region that still has a default VPC present.
It seemed to help, after changing region in /playbook/providers/aws.yml
Only now it crashes at another step:
TASK [Launch Forem instance for <redacted>] **********************************************************************
fatal: [forem]: FAILED! =>
msg: |-
The task includes an option with an undefined variable. The error was: No first item, sequence was empty.
The error appears to be in '/home/makarygo/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 }}"
I think it is having issues because vpc_subnet_id: "{{ forem_subnet_info.subnets | map(attribute='id') | list | first }}"
expects a list of subnets.
- name: Gather info about VPC subnets
amazon.aws.ec2_vpc_subnet_info:
filters:
vpc-id: "{{ forem_vpc_id }}"
availability-zone: "{{ fcos_aws_region }}a"
region: "{{ fcos_aws_region }}"
profile: "{{ fcos_aws_profile }}"
register: forem_subnet_info
Should get that info but if your VPC that you are using doesn't have any subnets that most likely is a problem.
Debugging your AWS account is a bit beyond our scope here so I would see if you have a default VPC on this account in this region and if not, recreate it https://aws.amazon.com/premiumsupport/knowledge-center/deleted-default-vpc/ and just use the default one if you can't figure out what is going on with your subnets on your current AWS VPC.
Yeah, I used this AWS account log time ago for deployment of different project, I will try to deploy with other provider. Thanks for assistance and sorry for stupid questions, just never worked with Ansible before.
No worries and no problem @MakaryGo. I think if you just tried a different region in AWS and make sure you have a default VPC you will be off the to the races.
Hey @MakaryGo I am going to close this request for now. If you want, you can post on https://forem.dev any issues you are having with your VPC on your AWS account and maybe the community can offer more advice.