spurin / diveintoansible-lab

Dive Into Ansible Lab
850 stars 531 forks source link

Section 7 AWS with Ansible #71

Closed bakker-ca closed 2 years ago

bakker-ca commented 2 years ago

The ansible security group does not get uploaded to AWS in revision 01. The playbook runs with a change being notified but the ansible security group does not appear. The error code is below.

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: InvalidKeyPair.NotFoundThe key pair 'ansible' does not exista4ea55ef-eafe-4aa1-827a-26b36fd0345d fatal: [localhost]: FAILED! => {"boto3_version": "1.19.12", "botocore_version": "1.22.12", "changed": false, "msg": "Instance creation failed: The key pair 'ansible' does not exist"}

I tested disabling my access key and got "AWS was not able to validate the provided access credentials" so I am sure I am communicating with AWS. Enabling it goes back to the error above.

spurin commented 2 years ago

Thanks @bakker-ca

Appreciate you raising this. Will investigate and report back 👍

spurin commented 2 years ago

Hi @bakker-ca

This took me a little while to get too but, I am going through this now as I'm doing the V3 refresh of Dive Into Ansible.

Have just tried this as per the video and for me, it's worked without an issue. I have my security group setup as follows -

image

Here's the console log -

ansible@ubuntu-c:~/diveintoansible/Using Ansible with Cloud Services and Containers/AWS with Ansible/01$ sudo pip3 install boto boto3
[sudo] password for ansible: 
Collecting boto
  Downloading boto-2.49.0-py2.py3-none-any.whl (1.4 MB)
     |████████████████████████████████| 1.4 MB 4.8 MB/s 
Collecting boto3
  Downloading boto3-1.20.21-py3-none-any.whl (131 kB)
     |████████████████████████████████| 131 kB 38.5 MB/s 
Collecting jmespath<1.0.0,>=0.7.1
  Downloading jmespath-0.10.0-py2.py3-none-any.whl (24 kB)
Collecting s3transfer<0.6.0,>=0.5.0
  Downloading s3transfer-0.5.0-py3-none-any.whl (79 kB)
     |████████████████████████████████| 79 kB 1.1 MB/s 
Collecting botocore<1.24.0,>=1.23.21
  Downloading botocore-1.23.21-py3-none-any.whl (8.4 MB)
     |████████████████████████████████| 8.4 MB 8.3 MB/s 
Collecting python-dateutil<3.0.0,>=2.1
  Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
     |████████████████████████████████| 247 kB 7.7 MB/s 
Requirement already satisfied: urllib3<1.27,>=1.25.4 in /usr/lib/python3/dist-packages (from botocore<1.24.0,>=1.23.21->boto3) (1.25.8)
Requirement already satisfied: six>=1.5 in /usr/lib/python3/dist-packages (from python-dateutil<3.0.0,>=2.1->botocore<1.24.0,>=1.23.21->boto3) (1.14.0)
Installing collected packages: boto, jmespath, python-dateutil, botocore, s3transfer, boto3
Successfully installed boto-2.49.0 boto3-1.20.21 botocore-1.23.21 jmespath-0.10.0 python-dateutil-2.8.2 s3transfer-0.5.0
ansible@ubuntu-c:~/diveintoansible/Using Ansible with Cloud Services and Containers/AWS with Ansible/01$ ansible-playbook ec2_playbook.yaml 

PLAY [localhost] *******************************************************************************************************************************************************************************************************

TASK [Create a security group in AWS for SSH access and HTTP] **********************************************************************************************************************************************************
changed: [localhost]

PLAY RECAP *************************************************************************************************************************************************************************************************************
localhost                  : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

Would you give this another try and let me know how you get on please.

Thanks

James

bakker-ca commented 2 years ago

Hi James

I tried again and found the issue. It was the interface between the chair and the keyboard(me). I was looking at US-east-2 on AWS but the groups were created on US-east-1. When I went into the right region, the group was there. I was the able to complete the labs.

Thanks.

Brian

Sent from my iPhone

On Dec 7, 2021, at 5:26 AM, James Spurin @.***> wrote:

 Hi @bakker-ca

This took me a little while to get too but, I am going through this now as I'm doing the V3 refresh of Dive Into Ansible.

Have just tried this as per the video and for me, it's worked without an issue. I have my security group setup as follows -

Here's the console log -

@.:~/diveintoansible/Using Ansible with Cloud Services and Containers/AWS with Ansible/01$ sudo pip3 install boto boto3 [sudo] password for ansible: Collecting boto Downloading boto-2.49.0-py2.py3-none-any.whl (1.4 MB) |████████████████████████████████| 1.4 MB 4.8 MB/s Collecting boto3 Downloading boto3-1.20.21-py3-none-any.whl (131 kB) |████████████████████████████████| 131 kB 38.5 MB/s Collecting jmespath<1.0.0,>=0.7.1 Downloading jmespath-0.10.0-py2.py3-none-any.whl (24 kB) Collecting s3transfer<0.6.0,>=0.5.0 Downloading s3transfer-0.5.0-py3-none-any.whl (79 kB) |████████████████████████████████| 79 kB 1.1 MB/s Collecting botocore<1.24.0,>=1.23.21 Downloading botocore-1.23.21-py3-none-any.whl (8.4 MB) |████████████████████████████████| 8.4 MB 8.3 MB/s Collecting python-dateutil<3.0.0,>=2.1 Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB) |████████████████████████████████| 247 kB 7.7 MB/s Requirement already satisfied: urllib3<1.27,>=1.25.4 in /usr/lib/python3/dist-packages (from botocore<1.24.0,>=1.23.21->boto3) (1.25.8) Requirement already satisfied: six>=1.5 in /usr/lib/python3/dist-packages (from python-dateutil<3.0.0,>=2.1->botocore<1.24.0,>=1.23.21->boto3) (1.14.0) Installing collected packages: boto, jmespath, python-dateutil, botocore, s3transfer, boto3 Successfully installed boto-2.49.0 boto3-1.20.21 botocore-1.23.21 jmespath-0.10.0 python-dateutil-2.8.2 s3transfer-0.5.0 @.:~/diveintoansible/Using Ansible with Cloud Services and Containers/AWS with Ansible/01$ ansible-playbook ec2_playbook.yaml

PLAY [localhost] ***

TASK [Create a security group in AWS for SSH access and HTTP] ** changed: [localhost]

PLAY RECAP ***** localhost : ok=1 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Would you give this another try and let me know how you get on please.

Thanks

James

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

spurin commented 2 years ago

Perfect! Thanks @bakker-ca

Closing this :-)