Skip to content

Commit

Permalink
adding additional documentation and flexibility with exercises
Browse files Browse the repository at this point in the history
  • Loading branch information
IPvSean committed Apr 15, 2020
1 parent 1de5913 commit 18e073d
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 23 deletions.
4 changes: 1 addition & 3 deletions docs/contribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

We treat Ansible Automation Workshops just like we treat the Ansible Project. Please help us! Check out the [Issues](https://github.com/ansible/workshops/issues) for a list of what we are working on.


## Table of Conents
## Table of Contents

* [Pull Requests ](#pull-requests)
* [Create a fork!](#create-a-fork)
Expand All @@ -16,7 +15,6 @@ We treat Ansible Automation Workshops just like we treat the Ansible Project. P
* [Contributing New Workshop Types of content](#contributing-new-workshop-types-of-content)
* [Going Further](#going-further)


# Pull Requests

We take pull requests! What is a pull request?
Expand Down
72 changes: 64 additions & 8 deletions docs/exercises.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# Contribute new Exercise Content
# Create New Exercise Content

We encourage folks to create new exercise content, fork with your own content, and customize the workshop any way you want. This will give you the flexibility to customize workshops for your own friends, customers, community or project!

## Table of Contents

# Using your own fork

When a workshop is provisioned, the control node for every workbench (where the Red Hat Ansible Automation is installed and executed from) will load solution exercises into `~/{{workshop}}-workshop`. For example if you are running the `networking` workshop the home directory for every student will have `~/home/networking-workshop`.

Expand All @@ -10,20 +16,70 @@ This can be customized! There are three variables that you can change with your

These variables are used in the `control_node` role which can found here: `provisioner/roles/control_node/tasks/main.yml`

Here is an example of provisioning the `workshop_type: rhel` with exercises from a forked repository on a different branch:

## Practical Example

Here is the `extra_vars` example of provisioning the `workshop_type: rhel` with exercises from a forked repository on a different branch:

```
---
ec2_region: us-east-2
# name prefix for all the VMs
ec2_name_prefix: sean-april8-rhel
admin_password: ansible1234
ec2_name_prefix: sean-workshop
admin_password: ansible123
student_total: 1
workshop_type: rhel
create_login_page: true
ansible_workshops_url: https://github.com/ipvsean/workshops.git
ansible_workshops_version: "test_branch"
```

This would load the exercises `/exercises/ansible_rhel` from fork `github.com/ipvsean/workshops.git` branch `test_branch` into the student home directory of `~/rhel-workshop`


# Changing solution folder on control node

It is possible to change the location of the destination folder where the exercises are loaded into with the `exercise_dest_location` variable.


## Practical Example

Here is the `extra_vars` example of provisioning the `workshop_type: rhel` with exercises from a forked repository on a different branch:

```
---
ec2_region: us-east-1
ec2_name_prefix: sean-workshop2
admin_password: ansible123
student_total: 1
workshop_type: rhel
create_login_page: true
ansible_workshops_url: https://github.com/ipvsean/workshops.git
ansible_workshops_version: "test_branch"
exercise_dest_location: "my_folder"
```

This would load the exercises `/exercises/ansible_rhel` from fork `github.com/ipvsean/workshops.git` branch `test_branch` into the student home directory of `~/my_folder`

# Changing source folder for exercise solutions

It is possible to change the location of the source folder with the `exercise_src_location` variable. This defaults to `exercises/ansible_{{workshop_type}}`. For example by default it would load `exercises/ansible_rhel` for the `workshop_type: rhel` workshop.

## Practical Example

Here is the `extra_vars` example of provisioning the `workshop_type: rhel` with different exercises from a forked repository on a different branch:

```
---
ec2_region: us-east-1
ec2_name_prefix: sean-workshop2
admin_password: ansible123
student_total: 1
workshop_type: rhel
dns_type: aws
create_login_page: true
towerinstall: true
autolicense: true
ansible_workshops_url: https://github.com/ipvsean/workshops.git
ansible_workshops_version: "test_branch"
exercise_dest_location: "my_folder"
exercise_src_location: "exercises/my_exercises"
```

This would load the exercises `/exercises/my_exercises` from fork `github.com/ipvsean/workshops.git` branch `test_branch` into the student home directory of `~/my_folder`
2 changes: 1 addition & 1 deletion docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ cd into the relevant project folder and execute the Playbook from the command li

```
TASK [manage_ec2_instances : Create EC2 instances for rtr3 node (NETWORKING MODE)] ***
fatal: [localhost]: FAILED! => changed=false
fatal: [localhost]: FAILED! => changed=false
msg: 'Instance creation failed => OptInRequired: In order to use this AWS Marketplace product you need to accept terms and subscribe. To do so please visit https://aws.amazon.com/marketplace/pp?sku=bw54e0gl17zf0vxq54dttwvow'
```
Expand Down
16 changes: 5 additions & 11 deletions provisioner/roles/control_node/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,12 @@
- "{{ansible_user}}"
- "{{username}}"

# FIXME: This should probably be refactored to use things like the following
# instead of hard coding
#
# command: cp -r /tmp/linklight/exercises/{{workshop_type}}/ /home/{{ username }}/{{workshop_type}}-workshop/
#
# That would enable a more generic role/scaffolding
- name: clean out /tmp/linklight
- name: clean out /tmp/workshops
file:
path: /tmp/linklight
path: /tmp/workshops
state: absent

- name: Clone workshops repo (NETWORKING MODE)
- name: Clone workshops repo
git:
accept_hostkey: true
clone: true
Expand All @@ -101,8 +95,8 @@

- name: Move relevant exercises to correct location
copy:
src: "/tmp/workshops/exercises/ansible_{{workshop_type}}/"
dest: "/home/{{ username }}/{{workshop_type}}-workshop"
src: '{{ "/tmp/workshops/" + exercise_src_location | default("exercises/ansible_" + workshop_type) }}'
dest: '{{ "/home/" + username + "/" + exercise_dest_location | default(workshop_type + "-workshop") }}'
remote_src: true
owner: "{{ username }}"
group: "{{ username }}"
Expand Down

0 comments on commit 18e073d

Please sign in to comment.