Skip to content

Commit b34e592

Browse files
authored
Merge pull request #18 from Zuehlke/feature/add-workshop-walkthrough
Add notes / walkthrough for the workshop
2 parents 9cae5ac + 79952d5 commit b34e592

1 file changed

Lines changed: 125 additions & 0 deletions

File tree

Workshop.md

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
2+
3+
# Workshop
4+
5+
6+
## Prerequisites
7+
8+
Make sure prerequisites are installed:
9+
10+
* Git - https://git-scm.com/downloads
11+
* VirtualBox - https://www.virtualbox.org/wiki/Downloads
12+
* Vagrant - https://www.vagrantup.com/downloads
13+
14+
In order to share code and fork the repository a Github account is needed. In case you don't have that yet, it's a good opportunity to create one ;)
15+
16+
In order to save time during the workshop (requires download of ~1.5GB image file) or have a chance to troubleshoot any installation issues before the workshop, please run the following commands upfront:
17+
18+
```
19+
$ git clone https://github.com/Zuehlke/linux-developer-vm-with-ansible
20+
$ cd linux-developer-vm-with-ansible
21+
$ vagrant up --no-provision
22+
$ vagrant destroy -f
23+
```
24+
25+
In case there are any issues with the above commands, please let me know!
26+
27+
## Exercises
28+
29+
### Lab 1: Up and running!
30+
31+
**Goal**: Getting the Developer VM up and running
32+
33+
* just run `vagrant up` :)
34+
35+
While this is running in the background (might take a few minutes), please continue with lab 2.
36+
37+
38+
### Lab 2: Getting to know the Developer VM Template Project
39+
40+
**Goal**: Get familiarized with the structure of the template project
41+
42+
* review the existing Ansible in the `roles/` directory
43+
* review the corresponding Testinfra tests in the `spec/` directory
44+
* review the output from running `vagrant up` in lab 1
45+
* check the README file on the VM Desktop (and configure your keyboard layout)
46+
47+
48+
### Lab 3: Make it yours!
49+
50+
**Goal**: Adapt the Dev-VM name in the README + Vagrantfile and switch to your Git repository
51+
52+
* adapt the `README.md` to describe your VM
53+
* adapt the VM name in `Vagrantfile`
54+
* create a new repo under your Github account (or alternatively fork the template repo)
55+
* switch the origin to point to your repo, then commit your changes and push
56+
* run `vagrant reload` to have the VM name changed in VirtualBox as well
57+
58+
Example:
59+
```
60+
$ git remote set-url origin https://github.com/tknerr/zdecamp21-developer-vm.git
61+
$ git commit -am "Adapt for ZCamp21 Developer VM"
62+
$ git push origin master
63+
```
64+
65+
### Lab 4: Let's take a snapshot now!
66+
67+
**Goal**: Learn how to take VM snapshots as a rescue point
68+
69+
* run `vagrant snapshot save start` to create a snapshot of the current VM state
70+
* do some changes in the VM, e.g. `sudo apt install sl` (yes... I know you want to try `sl` now... ;))
71+
* revert to previous state `vagrant snapshot restore start` (you can do that any time you borked your system and want to start back over)
72+
73+
74+
### Lab 5: Hands-On! Let's add Cowsay to our toolchain
75+
76+
**Goal**: Write your first Ansible task and Testinfra spec
77+
78+
Let's start TDD-style by writing a failing test first:
79+
80+
* create a new test spec `spec/test_cowsay.py`
81+
* use the Testinfra [package module](https://testinfra.readthedocs.io/en/latest/modules.html#testinfra.modules.package.Package) to check that the "cowsay" package is installed
82+
* run `vagrant provision` to verify that we have a failing test now
83+
84+
Then create a new Ansible role to install the "cowsay" package:
85+
86+
* create a new Ansible role named "cowsay" under the `roles/` directory
87+
* use the Ansible (apt module)[https://docs.ansible.com/ansible/2.9/modules/apt_module.html] to install the cowsay package
88+
* make sure the newly added cowsay role is referenced in `site.yml`, so that Ansible will pick it up
89+
* run `vagrant provision` to trigger the provisioning and review the Ansible output
90+
* in the VM, run `cowsay hello` (alternatively, run `vagrant ssh -c "cowsay hello"` on your host)
91+
92+
Additional hints:
93+
94+
* take a look at the other test specs (e.g. `test_git.py`) for inspiration on further checks you coud add to ensure a proper installation of cowsay
95+
* you can run `UPDATE_VM_FLAGS=--verify-only vagrant provision` to skip the Ansible provisioning and run only the tests
96+
* you can run `ROLE_TAGS=cowsay vagrant provision` to run Ansible provisioning only for the "cowsay" role (but ignore all others)
97+
* you can disable the cows in the Ansible output by setting the `ANSIBLE_NOCOWS=1` env var via the `~/.bashrc.d` mechanism [provided by the bashrc_d role](https://github.com/Zuehlke/linux-developer-vm-with-ansible/pull/11)
98+
99+
100+
### Lab 6: Export your Developer VM for others as an .ova file
101+
102+
**Goal**: Understand how to export the VM as an .ova image so that it can be distributed to the team
103+
104+
* follow the instructions in the ["Packaging" section](https://github.com/Zuehlke/linux-developer-vm-with-ansible/blob/master/README.md#packaging) to export the .ova image
105+
106+
### Lab 7: Import the Developer VM .ova file and work from there
107+
108+
**Goal**: Run through the VM import process so that you can work from within the imported VM now
109+
110+
* follow the instructions in the ["Usage" section](https://github.com/Zuehlke/linux-developer-vm-with-ansible#usage)
111+
* import the .ova image
112+
* verify that everything works by running the `update-vm` commands
113+
* review the `~/vm-setup` directory and it's connection to `update-vm`
114+
115+
Notes:
116+
* this is the point where you should consider sharing the VM .ova image with your team!
117+
* at this point you do not need Vagrant anymore and can extend the toolchain from within the VM!
118+
* you need to switch back to Vagrant everytime you want to create a fresh .ova image (and consider having a CI process that regularly builds these .ova images via vagrant)
119+
120+
### Lab 8: Work from within the imported .ova image and grow your toolchain!
121+
122+
Workshop ends here, this is left for you... :)
123+
124+
125+

0 commit comments

Comments
 (0)