diff --git a/instruqt-opensource/README.md b/instruqt-opensource/README.md new file mode 100644 index 0000000..60ac0af --- /dev/null +++ b/instruqt-opensource/README.md @@ -0,0 +1,3 @@ +# Instruqt Open Source + +This project contains working tracks for open source projects. \ No newline at end of file diff --git a/instruqt-opensource/learn-milvus/01-building-an-image/assignment.md b/instruqt-opensource/learn-milvus/01-building-an-image/assignment.md new file mode 100755 index 0000000..fe9ef29 --- /dev/null +++ b/instruqt-opensource/learn-milvus/01-building-an-image/assignment.md @@ -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**." diff --git a/instruqt-opensource/learn-milvus/01-building-an-image/check-docker-vm b/instruqt-opensource/learn-milvus/01-building-an-image/check-docker-vm new file mode 100755 index 0000000..3903f21 --- /dev/null +++ b/instruqt-opensource/learn-milvus/01-building-an-image/check-docker-vm @@ -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 \ No newline at end of file diff --git a/instruqt-opensource/learn-milvus/01-building-an-image/setup-docker-vm b/instruqt-opensource/learn-milvus/01-building-an-image/setup-docker-vm new file mode 100755 index 0000000..d1395ce --- /dev/null +++ b/instruqt-opensource/learn-milvus/01-building-an-image/setup-docker-vm @@ -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 <> /app/Dockerfile +FROM nginx +EOF diff --git a/instruqt-opensource/learn-milvus/01-building-an-image/solve-docker-vm b/instruqt-opensource/learn-milvus/01-building-an-image/solve-docker-vm new file mode 100755 index 0000000..767638c --- /dev/null +++ b/instruqt-opensource/learn-milvus/01-building-an-image/solve-docker-vm @@ -0,0 +1,6 @@ +#!/bin/bash +set -euxo pipefail + +echo "Running challenge solve script on host docker-vm" + +docker build -t my-service /app \ No newline at end of file diff --git a/instruqt-opensource/learn-milvus/02-running-a-container/assignment.md b/instruqt-opensource/learn-milvus/02-running-a-container/assignment.md new file mode 100755 index 0000000..05abe36 --- /dev/null +++ b/instruqt-opensource/learn-milvus/02-running-a-container/assignment.md @@ -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** diff --git a/instruqt-opensource/learn-milvus/02-running-a-container/check-docker-vm b/instruqt-opensource/learn-milvus/02-running-a-container/check-docker-vm new file mode 100755 index 0000000..f306a11 --- /dev/null +++ b/instruqt-opensource/learn-milvus/02-running-a-container/check-docker-vm @@ -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 + diff --git a/instruqt-opensource/learn-milvus/02-running-a-container/solve-docker-vm b/instruqt-opensource/learn-milvus/02-running-a-container/solve-docker-vm new file mode 100755 index 0000000..ecfc0d6 --- /dev/null +++ b/instruqt-opensource/learn-milvus/02-running-a-container/solve-docker-vm @@ -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 diff --git a/instruqt-opensource/learn-milvus/config.yml b/instruqt-opensource/learn-milvus/config.yml new file mode 100644 index 0000000..5964641 --- /dev/null +++ b/instruqt-opensource/learn-milvus/config.yml @@ -0,0 +1,6 @@ +version: "3" +virtualmachines: +- name: docker-vm + image: instruqt/docker-2010 + shell: /bin/bash + machine_type: n1-standard-1 diff --git a/instruqt-opensource/learn-milvus/track.yml b/instruqt-opensource/learn-milvus/track.yml new file mode 100755 index 0000000..4484810 --- /dev/null +++ b/instruqt-opensource/learn-milvus/track.yml @@ -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" diff --git a/instruqt-opensource/learn-milvus/track_scripts/setup-docker-vm b/instruqt-opensource/learn-milvus/track_scripts/setup-docker-vm new file mode 100755 index 0000000..2389580 --- /dev/null +++ b/instruqt-opensource/learn-milvus/track_scripts/setup-docker-vm @@ -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 + diff --git a/instruqt-pocs/README.md b/instruqt-pocs/README.md new file mode 100644 index 0000000..e69de29 diff --git a/instruqt-pocs/project-dev/01-project/assignment.md b/instruqt-pocs/project-dev/01-project/assignment.md new file mode 100755 index 0000000..f8235ec --- /dev/null +++ b/instruqt-pocs/project-dev/01-project/assignment.md @@ -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) \ No newline at end of file diff --git a/instruqt-pocs/project-dev/01-project/setup-git-jenkins-server b/instruqt-pocs/project-dev/01-project/setup-git-jenkins-server new file mode 100755 index 0000000..9128109 --- /dev/null +++ b/instruqt-pocs/project-dev/01-project/setup-git-jenkins-server @@ -0,0 +1 @@ +agent variable set url $HOSTNAME.$_SANDBOX_ID.instruqt.io \ No newline at end of file diff --git a/instruqt-pocs/project-dev/01-project/setup-local-system b/instruqt-pocs/project-dev/01-project/setup-local-system new file mode 100755 index 0000000..f5d44aa --- /dev/null +++ b/instruqt-pocs/project-dev/01-project/setup-local-system @@ -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 +# +# Meow! +# +#
+# +#
+#

Meow World!

+#
Welcome to the Meow World application. Meow! =^._.^=
+# +#
+# +# +# EOF + +# # Start up the nginx service. +# service nginx start diff --git a/instruqt-pocs/project-dev/01-project/setup-xlrelease b/instruqt-pocs/project-dev/01-project/setup-xlrelease new file mode 100755 index 0000000..ca45cd3 --- /dev/null +++ b/instruqt-pocs/project-dev/01-project/setup-xlrelease @@ -0,0 +1,217 @@ +#!/bin/bash +# +# This is a sample setup script. Rename this file to setup-$CONTAINER +# (where $container is the name of the container as defined in your config.yml), +# and replace this content with your own script. +# +# This script will be run when you setup the challenge. +# +# Remember that the exit code is important. See the documentation +# for more information. +# +echo "waiting 180 seconds for cloud-init to update /etc/apt/sources.list" +timeout 180 /bin/bash -c \ + 'until stat /var/lib/cloud/instance/boot-finished 2>/dev/null; do echo waiting ...; sleep 1; done' +# Added sleep to make sure apt is unlocked +echo "Sleeping to make sure we are started" +sleep 30 + +# Get temporary license +# curl -o license.json --user instruqt:nk60kjLvnjIN -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '{"firstName":"Instruqt","lastName":"User","company":"Training","email":"instruqt@company.com"}' https://download.xebialabs.com/api/temporary/xl-release +# Temporarily disabled checking of SSL Cert, as it is expired +curl -k -o license.json --user instruqt:nk60kjLvnjIN -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '{"firstName":"Instruqt","lastName":"User","company":"Training","email":"instruqt@company.com"}' https://download.xebialabs.com/api/temporary/xl-release +# Alternative Server +# curl -o license.json --user instruqt:nk60kjLvnjIN -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '{"firstName":"Instruqt","lastName":"User","company":"Training","email":"instruqt@company.com"}' https://download2.xebialabs.com/api/temporary/xl-release +cat license.json | jq -r .license > /opt/xlr/server/conf/xl-release-license.lic + +# Add hotfixes for Reporting data +svn export https://github.com/xebialabs/instruqt-trainings.git/trunk/topic-xl-release-training/track-xlrelease-end-user-training/artifacts/resources/hotfix +svn export https://github.com/xebialabs/instruqt-trainings.git/trunk/topic-xl-release-training/track-xlrelease-end-user-training/artifacts/resources/hotfix-plugins + +cp hotfix/fix-release-risks-and-progress.jar /opt/xlr/server/hotfix/lib/ +cp hotfix-plugins/workaround-for-fixing-tile-legends.jar /opt/xlr/server/hotfix/plugins/ +chown -R xlrelease:xlrelease /opt/xlr/server/hotfix/* +rm -rf hotfix +rm -rf hotfix-plugins + +chown -R xlrelease:xlrelease /opt/xlr/server + +# Restart XL Release +systemctl restart xl-release +rm license.json +# Check if XL Release is up +echo "Check XL Release Status" +while ! nc -z localhost 5516; do echo "Port 5516 not open" && sleep 1; done +echo "Port is open, continuing" + +# Set Archiving to 0 Days +curl -f http://admin:admin@localhost:5516/settings/ci/Configuration/settings/ArchivingSettings -X PUT \ + -H 'Accept: application/json' \ + -H 'Content-Type: application/json' \ + -d '{"id":"Configuration/settings/ArchivingSettings", + "type":"xlrelease.ArchivingSettings", + "releaseAgeToDeleteFromJcr":0, + "preArchivingEnabled":true}' + + echo " Test" + + ############# Git and Jenkins connections to XL release +#!/bin/bash + +# Set the SANDBOX_ID environment variable +#export SANDBOX_ID="a5mq9l7jyhiy" +SANDBOX_ID=$(echo ${_SANDBOX_ID}) + +# Define the Git server cURL command +git_curl_command=$(cat < /home/git/.ssh/authorized_keys" +sudo chown -R git:git /home/git/.ssh/ +sudo mkdir /home/git/project.git +sudo chmod 0700 /home/git/project.git/ +sudo -- sh -c "cd /home/git/project.git ; git init --bare" +sudo chown -R git:git /home/git/project.git/ + +####### +sudo apt update +sudo apt install -y build-essential net-tools curl git software-properties-common nginx git fcgiwrap apache2-utils unzip +mkdir /var/www/html/myrepo ; cd /var/www/html/myrepo ; mkdir project.git +cd project.git ; git --bare init +git update-server-info +chown -R www-data:www-data /var/www/html/myrepo ; chmod -R 755 /var/www/html/myrepo + +echo "$password" | htpasswd -c -i /var/www/html/myrepo/htpasswd gituser +cat >> /etc/nginx/conf.d/git-jenkins-server.${_SANDBOX_ID}.instruqt.io.conf <<-EOF +server { + listen 80 default_server; + listen [::]:80 default_server; + root /var/www/html/myrepo; + server_name git-jenkins-server.${_SANDBOX_ID}.instruqt.io; + index index.html index.htm index.git-jenkins-server.dxuowdcjuw4e.instruqt.io.html; + + location / { + try_files \$uri \$uri/ =404; + } + + location ~ (/.*) { + client_max_body_size 0; + auth_basic "Git Login"; + auth_basic_user_file "/var/www/html/myrepo/htpasswd"; + include /etc/nginx/fastcgi_params; + fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend; + fastcgi_param GIT_HTTP_EXPORT_ALL ""; + fastcgi_param GIT_PROJECT_ROOT /var/www/html/myrepo; + fastcgi_param REMOTE_USER \$remote_user; + fastcgi_param PATH_INFO \$1; + fastcgi_pass unix:/var/run/fcgiwrap.socket; + } +} +EOF + +nginx -t +systemctl restart nginx + + + diff --git a/instruqt-pocs/project-dev/track_scripts/setup-local-system b/instruqt-pocs/project-dev/track_scripts/setup-local-system new file mode 100755 index 0000000..28de828 --- /dev/null +++ b/instruqt-pocs/project-dev/track_scripts/setup-local-system @@ -0,0 +1,4 @@ +mkdir project ; cd project ; git init +git config --global user.email "user1@yourdomain.com" +git config --global user.name "user1" +git remote add origin http://gituser:password@git-jenkins-server.${_SANDBOX_ID}.instruqt.io/project.git \ No newline at end of file diff --git a/instruqt-pocs/project-dev/track_scripts/setup-xlrelease b/instruqt-pocs/project-dev/track_scripts/setup-xlrelease new file mode 100755 index 0000000..8ace5a1 --- /dev/null +++ b/instruqt-pocs/project-dev/track_scripts/setup-xlrelease @@ -0,0 +1 @@ +apt-get install jq -y \ No newline at end of file