0% found this document useful (0 votes)
113 views8 pages

MODUL C - Infrastructure Programmable & Automation

The document provides instructions for a small programming group to containerize their services and centrally manage their infrastructure using Docker and Ansible. It includes steps to install and configure Docker, set up a local Docker registry, build and run containerized Python web and Nginx applications, and create Ansible playbooks for centralized management of containers across multiple servers.

Uploaded by

arsi jovik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
113 views8 pages

MODUL C - Infrastructure Programmable & Automation

The document provides instructions for a small programming group to containerize their services and centrally manage their infrastructure using Docker and Ansible. It includes steps to install and configure Docker, set up a local Docker registry, build and run containerized Python web and Nginx applications, and create Ansible playbooks for centralized management of containers across multiple servers.

Uploaded by

arsi jovik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

LOMBA KOMPETENSI SISWA

SEKOLAH MENENGAH KEJURUAN


TINGKAT PROVINSI JAWA BARAT
TAHUN 2022

BIDANG LOMBA
TEKNOLOGI INFORMASI SISTEM ADMINISTRASI JARINGAN
IT NETWORK SYSTEMS ADMINISTRATION
DESCRIPTION OF PROJECT

A small group of programmers is starting to adopt Docker to containerize their services.


Their network infrastructure is usually configured by calling the APIs from a
programming language. Recently their netdevops engineer has gotten a long paid leave,
you need to take over his responsibility.
SYSTEM PROGRAMMABILITY
Scripted Configuration
▪ Access Deployer server to configure python and Dockerfile for other servers
▪ Prepare all other servers to be able to be managed by the Deployer server.
○ Configure IP Address of all other servers on the network according to the
addressing table.
▪ Create a python3 or bash script to access network devices information
○ use RESTCONF/NETCONF
○ Save the script in /home/ubuntu/netdev.py or /home/ubuntu/netdev.sh
○ When the script is executed, it will return all IP addresses configured in
shared-router
○ You will not be able to access the router directly.
○ Below is an example of how to query the RESTCONF API to view the
network interfaces using bash and python3 (json and request module).

curl https://1.1.1.1/restconf/data/ietf-interfaces:interfaces -k -H "Accept:


application/yang-data+json" -u "username:password"

import json
import requests
requests.packages.urllib3.disable_warnings()

api_url = "https://1.1.1.1/restconf/data/ietf-interfaces:interfaces"

headers = { "Accept": "application/yang-data+json",


"Content-type":"application/yang-data+json"
}

basicauth = ("username", "password")

resp = requests.get(api_url, auth=basicauth, headers=headers, verify=False)

print(resp.content)

○ Expected output:
Python Web Application
▪ Programmers asked us to make sure they can run sample code below in the
python3 virtual environment on all other servers.
▪ Install python3 and other required packages to run the code main.py
▪ Enable python3 virtual environment and create a new virtual environment on
“/opt/env/myenv”
○ Install the required packages to run the code in this virtual environment
▪ Save the following code in directory “/opt/sample-web”
○ main.py
from flask import Flask
from flask import request
from flask import render_template

sample = Flask(__name__)

@sample.route("/")
def main():
return render_template("index.html")

if __name__ == "__main__":
sample.run(host="0.0.0.0", port=8080)

○ index.html
<html>
<head>
<title>Sample app</title>
</head>
<body>
<h1>You are calling me from {{request.remote_addr}}</h1>
</body>
</html>

▪ Make sure the code can be executed in the server without any trouble
CONTAINERIZED SERVICE
Docker Installation/Configuration
▪ Configure Docker in all servers, make sure user ‘patah’ can use docker command
without sudo.
▪ To reach the internet, use the 1st interface with IP Address from DHCP.

Local Registry in Deployer


▪ Run registry server container
○ Container Name : registry
○ Use image registry from Docker Hub
○ Volume Mounts : /mnt/registry to /var/lib/registry
○ Configure to Listen in port 5000
▪ Pull image python:3.8-slim from Docker Hub.
○ Push this image to the local registry container with the same name and tag.
▪ Pull image nginx:latest from Docker Hub.
○ Push this image to the local registry container with name webserver:base

Running Python Web Application in Deployer


▪ Use the code Python Web Application in /opt/sample-web to create a Dockerfile
○ Use base image python:3.8-slim
○ Expose port 80
○ Copy all code into workdir.
○ Use /opt/sample-web as workdir inside the container.
○ Save the Dockerfile in /opt/sample-web/Dockerfile
▪ Build the Dockerfile into image with name sampleweb:latest
○ Run the application from this image
○ Container Name : sampleweb
○ Configure to Listen in Port 80
▪ Push the image to the local registry container with the same name and tag.

Running Normal Services in DSRV1, DSRV2, and DSRV3


▪ Use the image nginx:latest and create a container based web server serving the file
public.html as specified in the appendix.
○ Container name : farm-1
○ Make it accessible via http://{ip_address}/public.html
○ Do not expose any port on the host.
▪ Use the image nginx:latest and create a container based web server serving the file
external.html as specified in the appendix.
○ Container name : farm-2
○ Make it accessible via http://{ip_address}/external.html
○ Do not expose any port on the host.
Centralized Management in Deployer

▪ Install ansible in Deployer and make it executable from any user.

▪ Create an ansible playbook in /opt/playbook/docker-start.yml to start all farm


containers in DSRV1, DSRV2, and DSRV3.
▪ Create an ansible playbook in /opt/playbook/docker-stop.yml to stop all farm
containers in DSRV1, DSRV2, and DSRV3.
▪ Create an inventory file for three DSRV servers in /opt/playbook/dsrv-inventory
APPENDIX

All Server Console Access


Username competitor

Password Skills39

Shared Router API Access


Username admin

Password Skills39

IP Address 10.254.254.111

NETCONF port 830

RESTCONF https://10.254.254.111/restconf

Addressing Table
Device Name IP Address CIDR Remark

DSRV1 DHCP ISP

10.200.200.1/24 Automated

DSRV2 DHCP ISP

10.200.200.3/24 Automated

DSRV3 DHCP ISP

10.200.200.3/24 Automated

Deployer DHCP ISP

10.200.200.254/24 Automated

public.html
<h1> Public Web Page </h1><br>
<br>
Welcome to ITNSA LKSN 2021

external.html
<h1> External Web Page </h1><br>
<br>
Welcome to ITNSA LKSN 2021
TOPOLOGY

You might also like