Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions instruqt-opensource/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Instruqt Open Source

This project contains working tracks for open source projects.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
slug: building-an-image
id: erdmilpgrbpe
type: challenge
title: Building a container image
teaser: Learn how to build an image using a Dockerfile
notes:
- type: text
contents: |
# Learn about Docker

Docker is an open platform for developing, shipping, and running applications.
Docker enables you to separate your applications from your infrastructure so
you can deliver software quickly. Containers run anywhere!

In this first challenge, you'll create a container image. Please wait while we
boot a virtual machine for you.
tabs:
- title: Terminal
type: terminal
hostname: docker-vm
- title: Editor
type: code
hostname: docker-vm
path: /app
difficulty: basic
timelimit: 600
---

🧪 Build a Docker image
=======================

Use this command to build a Docker image using the Dockerfile in
this directory:

```
docker build -t my-service .
```

💡 Source editor
================

Did you notice the tab with the source code editor, next to
the terminal?

🏁 Finish
=========

To complete the
challenge, press **Check**."
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -euxo pipefail

if ! docker image ls | grep "my-service"; then
fail-message "Couldn't find an image with the name my-service"
exit 1
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -euxo pipefail

echo "Running challenge setup script on host docker-vm"

# Initialize the home directory with the Dockerfile
mkdir /app
touch /app/Dockerfile
set-workdir /app

# Create the Dockerfile
cat <<EOF >> /app/Dockerfile
FROM nginx
EOF
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -euxo pipefail

echo "Running challenge solve script on host docker-vm"

docker build -t my-service /app
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
slug: running-a-container
id: lwhlbafmwvb2
type: challenge
title: Starting a container
teaser: Start the container image you've just built
notes:
- type: text
contents: |
# Starting a container image

Container images can be started any where a container runtime is installed.
tabs:
- title: Terminal
type: terminal
hostname: docker-vm
- title: nginx
type: service
hostname: docker-vm
port: 80
difficulty: basic
timelimit: 600
---

🚀 Let's run it
===============

Now that you have built a container image, you can run it.

👨‍💻 Step 01 - Start container
============================

Run the following command to start the container:

```
docker run --name some-container -p 80:80 -d my-service
```

👀 Step 02 - NGINX tab
======================

Check the nginx tab (next the the terminal tab) to verify if the container is running.
You should see a "Welcome to nginx" message

✅ Step 03 - Verify the container
=================================

To verify if the container is running using the command line, run this command:

```
docker container ls
```

🏁 Finish
=========

## Check

To complete this track, press **Check**
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -euxo pipefail

echo "Running challenge check script on host docker-vm"

if ! docker container ls | grep -q "my-service"; then
fail-message "There is no running container 'my-service'. Did you run it?"
exit 1
fi

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -euxo pipefail

echo "Running challenge solve script on host docker-vm"

docker run --name my-service -p 80:80 -d my-service
6 changes: 6 additions & 0 deletions instruqt-opensource/learn-milvus/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: "3"
virtualmachines:
- name: docker-vm
image: instruqt/docker-2010
shell: /bin/bash
machine_type: n1-standard-1
22 changes: 22 additions & 0 deletions instruqt-opensource/learn-milvus/track.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
slug: learn-milvus
id: ww8aaffptmba
title: Learn Milvus
teaser: Use a virtual machine (VM) as a sandbox host
description: |-
This template shows you how to use a Virtual Machine (VM). VMs can be used when you need more compute and memory or for running Docker containers.

**This track demonstrates how to:**
- Provision virtual machine sandbox host using a predefined Compute Engine image
- Use the Docker daemon on the sandbox host to build and run container images
- Add check and solve scripts
- Add simple assets (a Dockerfile) to the sandbox host
icon: https://cdn.instruqt.com/assets/templates/docker.png
tags: []
owner: instruqt-demos
developers:
- todd@instruqt.com
lab_config:
overlay: false
width: 33
position: right
checksum: "1467653403314078352"
11 changes: 11 additions & 0 deletions instruqt-opensource/learn-milvus/track_scripts/setup-docker-vm
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -euxo pipefail

echo "Running track setup script on host docker-vm"

# Wait for the Instruqt host bootstrap to finish
until [ -f /opt/instruqt/bootstrap/host-bootstrap-completed ]
do
sleep 1
done

Empty file added instruqt-pocs/README.md
Empty file.
130 changes: 130 additions & 0 deletions instruqt-pocs/project-dev/01-project/assignment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
---
slug: project
id: hxl3epr8t4ss
type: challenge
title: XL release, Ansible Tower, Git Server and Jenkins
notes:
- type: text
contents: |
# **Overview of Developer Experience project**

![DeveloperExperienceproject.png](../assets/DeveloperExperienceproject.png)
tabs:
- title: git-shell
type: terminal
hostname: git-jenkins-server
- title: Shell-Local
type: terminal
hostname: local-system
- title: ansible
type: service
hostname: ansibletower
path: /
port: 443
- title: xlrelease
type: service
hostname: xlrelease
path: /
port: 5516
url: http://signin.aws.amazon.com/
- title: jenkins
type: website
url: http://git-jenkins-server.${_SANDBOX_ID}.instruqt.io:8080
new_window: true
difficulty: basic
timelimit: 600
---
We have preprovisioned 4 VM's Git Server & Jenkins, XL release, Ansible Tower and Client server.

Ansible Tower
===

- Login to Ansible Tower with credentials: **username:** `admin` , **password:** `password`
- Open credentials tab, Click on the `+` button to add new credentials and enter the follwing details:
- **NAME**: `git`
- **CREDENTIAL TYPE**: `Source Control`
- **USERNAME**: `gituser`
- **PASSWORD**: `password`,
- Click **Enter** button on keyboard after providing password
- Or else Click on **save** to save the details.
![image.png](../assets/image.png)
## Open projects tab, Click on the Demo Project and edit the follwing details:

- **SCM URL**:
```
http://gituser@[[ Instruqt-Var key="url" hostname="git-jenkins-server" ]]/project.git
```
- **SCM CREDENTIAL**: `git`
![image.png](../assets/git_credentials.png)
- Click on **Save**
## Open Templates, Click on the Demo job template and edit the follwing details:
- Clicimage.pngk on **PLAYBOOK** dropdown and select the playbook (demo_playbook.yml)
![](../assets/git_credentials.png)
- As of now we had a demo_playbook.yml pushed in repo, So Add it to Start the **JOB** using the **Template**


XL release steps
===

- Open **XL release** in **tabs** with credentials: **username:** `admin` , **password:** `admin`
- click on **folder**
- click on **Samples & Tutorials**
![image.png](../assets/image.png)
- Click on **template** with named **Applications/XL_Test** which we have created as a sample template
- Now click on **Jenkins task** which is added already.
![image.png](../assets/image.png)
- Now click on `Config`.
- **Select Server**: `Jenkins Server` from dropdown menu
- **Job**: `JenkinsTestJob`
![image.png](../assets/image.png)

Now close the window.

**Next we need to create a trigger**.

- Click on **Triggers** in left side panel.
![image.png](../assets/image.png)
- Click on Add **Trigger**.
- Update the mandatory fields like **Title**,
- Select **trigger type** as `Git: Poll`,
- **Pole interval** : `5`,
- Select your **Repository** (here we have created a Git connection with name `Git Server`).
- **Branch**: master
![image.png](../assets/image.png)
![image.png](../assets/image.png)
- Select your **template:** Applications/XL_Test and **folder:** Samples & Tutorials
- Enter mandatory field **Release Title** (as per your choice)
- **click** on Save
![image.png](../assets/image.png)


Workflow
===

Go to the **Shell_local** tab
- cd project/
- Make some changes in `demo_playbook.yml` using
```
vi demo_playbook.yml
```
After you made changes, then push to the git server
```
git add .
git commit -m "First commit"
git push origin master
```

Now check the flow on XL release, Jenkins and Ansible Tower.
Open **Jenkins** in **tabs** with credentials: **username:** `admin` , **password:** `admin`
XL release trigger jenkins when there is a commit in git repo, jenkins builds job and deploys to ansible tower.

Outputs should look like:
- In **Jenkins:**
![image.png](../assets/image.png)
- In **Ansible:**
**Jobs:**
![image.png](../assets/image.png)
**Dashboard:**
![image.png](../assets/image.png)
- In **XL Release:**
![image.png](../assets/image.png)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
agent variable set url $HOSTNAME.$_SANDBOX_ID.instruqt.io
55 changes: 55 additions & 0 deletions instruqt-pocs/project-dev/01-project/setup-local-system
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash
set -euxo pipefail

echo "Running track setup script"

# Wait for the Instruqt host bootstrap to finish.
until [ -f /opt/instruqt/bootstrap/host-bootstrap-completed ]
do
sleep 1
done

# Here we are installing the nginx package. The noninteractive setting ensures
# that the apt command won't stop and ask for user input.
apt -y update
DEBIAN_FRONTEND=noninteractive apt -y install nginx vim

cat >/root/project/demo_playbook.yml <<\EOF
# Adding a demo playbook
---
- name: demo playbook
hosts: all
tasks:
- name: Hello Message
debug:
msg: "Hello instruqt customer"
EOF
cd project/
git add .
git commit -m "Demo playbook"
git push origin master
#cat ~/.ssh/id_rsa.pub | ssh root@git "mkdir -p ~/.ssh && touch ~/.ssh/authorized_keysnew && cat >> ~/.ssh/authorized_keysnew"
#cat ~/.ssh/id_rsa.pub | ssh -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null root@git "mkdir -p ~/.ssh && touch ~/.ssh/authorized_keysnewtest && cat >> ~/.ssh/authorized_keysnewtest"



# # Remove the default nginx landing page and replace
# # it with something more useful.
# rm /var/www/html/index.nginx-debian.html
# cat >> /var/www/html/index.html <<-EOF
# <html>
# <head><title>Meow!</title></head>
# <body>
# <div style="width:800px;margin: 0 auto">
# <!-- BEGIN -->
# <center><img src="http://placekitten.com/640/480"></img></center>
# <center><h2>Meow World!</h2></center>
# <center>Welcome to the Meow World application. Meow! =^._.^=</center>
# <!-- END -->
# </div>
# </body>
# </html>
# EOF

# # Start up the nginx service.
# service nginx start
Loading