Skip to content

Commit

Permalink
multiple updates, trying to troubleshoot key issues for gerald and er…
Browse files Browse the repository at this point in the history
…ic and kyle
  • Loading branch information
IPvSean committed Mar 20, 2018
1 parent ff2f221 commit 8aac458
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 28 deletions.
43 changes: 43 additions & 0 deletions docs/faq.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# FAQ
Frequently Asked Questions... or rather common problems that people have hit.

## Problem: boto3 missing

```
fatal: [localhost]: FAILED! => {"attempts": 1, "changed": false, "msg": "Python modules \"botocore\" or \"boto3\" are missing, please install both"}
```

OR

```
fatal: [localhost]: FAILED! => {"attempts": 1, "changed": false, "msg": "boto is required for this module"}
```

Solution:
```
pip install boto boto3
```


## Problem: Unable to locate credentials

```
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: NoCredentialsError: Unable to locate credentials
fatal: [localhost]: FAILED! => {"attempts": 1, "changed": false, "msg": "Failed to describe VPCs: Unable to locate credentials"}
```

Solution:
Set your Access Key ID and Secret Access Key under ~/.aws/credentials

```
[root@centos ~]# cat ~/.aws/credentials
[default]
aws_access_key_id = ABCDEFGHIJKLMNOP
aws_secret_access_key = ABCDEFGHIJKLMNOP/ABCDEFGHIJKLMNOP
```

## Problem: Not authorized for image

```
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ClientError: An error occurred (AuthFailure) when calling the DescribeImageAttribute operation: Not authorized for image:ami-26ebbc5c
```
18 changes: 12 additions & 6 deletions provisioner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,14 @@ To provision the workshop onto AWS use the following directions:

pip install boto boto3

4. Create an [Access Key ID and Secret Access Key](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html) (you should be using IAM and [not your AWS account directly](http://docs.aws.amazon.com/general/latest/gr/managing-aws-access-keys.html)). Save the ID and key for later.
4. Set your Access Key ID and Secret Access Key from Step 2 under ~/.aws/credentials

```
[root@centos ~]# cat ~/.aws/credentials
[default]
aws_access_key_id = ABCDEFGHIJKLMNOP
aws_secret_access_key = ABCDEFGHIJKLMNOP/ABCDEFGHIJKLMNOP
```

5. Install the `passlib` library

Expand All @@ -74,20 +81,19 @@ If you haven't done so already make sure you have the repo cloned to the machine
1. Define the following variables in a file passed in using `-e @extra_vars.yml`

```yml
ec2_key_name: username # SSH key in AWS to put in all the instances
ec2_region: us-east-1 # region where the nodes will live
ec2_az: us-east-1a # availability zone
ec2_name_prefix: TRAINING-LAB # name prefix for all the VMs
ec2_name_prefix: TRAININGLAB # name prefix for all the VMs
admin_password: ansible
## Optional Variables
localsecurity: false # skips firewalld installation and SE Linux when turned to false
localsecurity: false # skips firewalld installation and SE Linux when false
```
For an example, look at [sample-vars.yml](sample-vars.yml) for a list of all the knobs you can control. You can use pre-existing AWS VPCs you already created.
2. Run the playbook:
ansible-playbook provision_lab.yml -e @extra_vars.yml -e @users.yml
ansible-playbook provision_lab.yml -e @extra_vars.yml
What does the provisioner take care of automatically?
- AWS VPC creation (Amazon WebServices Virtual Private Cloud)
Expand All @@ -100,7 +106,7 @@ What does the provisioner take care of automatically?
4. Check on the EC2 console and you should see instances being created like:
TRAINING-LAB-<student_username>-node1|2|3|haproxy|tower|control
TRAINING-LAB-<student_username>-node1|2|3|tower|control
## Accessing student documentation and slides
Expand Down
8 changes: 7 additions & 1 deletion provisioner/aws-directions/AWSHELP.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# AWS DIRECTIONS HELP
These steps will walk you through where to create credentials (Access Key ID and Secret Access Key) on AWS to use for provisioning VMs with Ansible.
These steps will walk you through where to create credentials (Access Key ID and Secret Access Key) on AWS to use for provisioning VMs with Ansible.

## Login
Login to the AWS Console on [https://aws.amazon.com/](https://aws.amazon.com/)
Expand Down Expand Up @@ -29,4 +29,10 @@ You need to create a new access key, only then will the necessary key and key ID

You now have your Access Key ID and Secret Access Key!

## AWS References

- [Access Key ID and Secret Access Key](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html)
- [managing-aws-access-keys.html(http://docs.aws.amazon.com/general/latest/gr/managing-aws-access-keys.html).


[Return to aws_lab_setup directions](../README.md)
2 changes: 1 addition & 1 deletion provisioner/roles/connectivity_test/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- name: Wait 400 seconds, but only start checking after 30 seconds
wait_for_connection:
delay: 30
timeout: 600
timeout: 400

# This wait_for_connection task can't be part of manage_ec2_instances
# because you can't use groups with delegate_to, see:
Expand Down
4 changes: 0 additions & 4 deletions provisioner/roles/manage_ec2_instances/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,3 @@ ec2_login_names:
ubuntu14: ubuntu
ubuntu16: ubuntu
csr-byol: ec2-user

# Backwards compatability
types: "{{ ec2_lab_node_types }}"
aws_key_name: "{{ ec2_key_name }}"
26 changes: 10 additions & 16 deletions provisioner/roles/manage_ec2_instances/tasks/provision.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,14 @@
- networking
- ec2_vpc_id2 is undefined

- name: start ssh agent
raw: "eval `ssh-agent -s`"
- name: enable ssh-agent
shell: eval $(ssh-agent)

- name: Create ssh key pair for workshop {{ ec2_name_prefix }}
ec2_key:
name: "{{ ec2_name_prefix }}-key"
region: "{{ ec2_region }}"
register: create_key
when: ec2_key_name is undefined

# - name: The key for for workshop {{ ec2_name_prefix }}
# debug:
Expand All @@ -211,17 +210,12 @@
raw: ssh-add ./aws-private.pem
when: create_key.changed

- name: set keys for instance creation dynamically since key was not supplied by user
set_fact:
ec2_key_name: "{{ ec2_name_prefix }}-key"
when: ec2_key_name is undefined

- name: debugging all variables for ec2 instance creation VPC-1
debug:
msg:
- "ec2_name_prefix: {{ec2_name_prefix}}"
- "ec2_vpc_id: {{ ec2_vpc_id }}"
- "ec2_key_name: {{ ec2_key_name }}"
- "{{ ec2_name_prefix }}-key: {{ ec2_name_prefix }}-key"
- "ec2_security_group: {{ ec2_security_group }}"
- "ec2_vpc_subnet_id: {{ ec2_vpc_subnet_id }}"

Expand Down Expand Up @@ -269,7 +263,7 @@
- name: Create EC2 instances for ansible node (control node)
ec2:
assign_public_ip: yes
key_name: "{{ ec2_key_name }}"
key_name: "{{ ec2_name_prefix }}-key"
group: "{{ ec2_security_group }}"
instance_type: "{{ ec2_instance_types[ansible_node].size }}"
image: "{{ ansible_control_node_ami.image_id }}"
Expand Down Expand Up @@ -320,7 +314,7 @@
- name: Create EC2 instances for node1
ec2:
assign_public_ip: yes
key_name: "{{ ec2_key_name }}"
key_name: "{{ ec2_name_prefix }}-key"
group: "{{ ec2_security_group }}"
instance_type: "{{ ec2_instance_types[node1_node].size }}"
image: "{{ node1_ami.image_id }}"
Expand Down Expand Up @@ -374,7 +368,7 @@
- name: Create EC2 instances for node2
ec2:
assign_public_ip: yes
key_name: "{{ ec2_key_name }}"
key_name: "{{ ec2_name_prefix }}-key"
group: "{{ ec2_security_group }}"
instance_type: "{{ ec2_instance_types[node2_node].size }}"
image: "{{ node2_ami.image_id }}"
Expand Down Expand Up @@ -428,7 +422,7 @@
- name: Create EC2 instances for node3
ec2:
assign_public_ip: yes
key_name: "{{ ec2_key_name }}"
key_name: "{{ ec2_name_prefix }}-key"
group: "{{ ec2_security_group }}"
instance_type: "{{ ec2_instance_types[node3_node].size }}"
image: "{{ node3_ami.image_id }}"
Expand Down Expand Up @@ -482,7 +476,7 @@
- name: Create EC2 instances for rtr1 node (NETWORKING MODE)
ec2:
assign_public_ip: yes
key_name: "{{ ec2_key_name }}"
key_name: "{{ ec2_name_prefix }}-key"
group: "{{ ec2_security_group }}"
instance_type: "{{ ec2_instance_types[rtr1_node].size }}"
image: "{{ rtr1_ami.image_id }}"
Expand Down Expand Up @@ -531,7 +525,7 @@
- name: Create EC2 instances for rtr2 node in VPC-2 (NETWORKING MODE)
ec2:
assign_public_ip: yes
key_name: "{{ ec2_key_name }}"
key_name: "{{ ec2_name_prefix }}-key"
group: "{{ ec2_security_group2 }}"
instance_type: "{{ ec2_instance_types[rtr2_node].size }}"
image: "{{ rtr2_ami.image_id }}"
Expand Down Expand Up @@ -580,7 +574,7 @@
- name: Create EC2 instances for host1 node in VPC-2 (NETWORKING MODE)
ec2:
assign_public_ip: yes
key_name: "{{ ec2_key_name }}"
key_name: "{{ ec2_name_prefix }}-key"
group: "{{ ec2_security_group2 }}"
instance_type: "{{ ec2_instance_types[host1_node].size }}"
image: "{{ host1_ami.image_id }}"
Expand Down

0 comments on commit 8aac458

Please sign in to comment.