Coder Social home page Coder Social logo

hostname-monitor's Introduction

Hostname Monitor Service

This project showing how to provision, deploy and run script as service on both Linux and Windows.

File Details

  • .gitignore - Git ignore file.
  • ansible.cfg - Ansible configuration to configure the inventory details
  • host-monitor.service - Linux based service file for configuring the service
  • hosts - Inventory file for Ansible to have the server details where the service will be deployed
  • Jenkinsfile - Jenkins pipeline file to create the service on both windows and linux
  • playbook.yml - Ansible playbook to deploy copy the files and to create the service on both windows and linux
  • process.py - Simple python script to print hostname and date stamp
  • README.md - This file

CI/CD Pipeline Flow

Github -> Jenkins with Ansible (on linux) -> Target (Windows/Linux Server)

Ansible can be installed on a different server like below but for this project the above flow is used by having Jenkins and Anisble on same linux server.

Github -> Jenkins (on linux) -> Ansible (linux) -> Target (Windows/Linux Server)

Prerequisites

Github

  • Nothing required

Jenkins

  • Install Git for checkout repo during build.
  • Install python sudo yum install python3 -y as it required for Ansible.
  • Install Ansible sudo yum install python3 -y and add ansible bin directory /usr/local/bin to Environment variable PATH
  • Make sure the SSH keys used to connect linux target servers is under /var/lib/jenkins/.ssh/ with owner as jenkins for user and group with required permission.
  • Create pipeline to use Jenkinsfile file from Github repo.
  • Add credentials to Jenkins if the repo is private and configure it in pipeline.
  • Configure the pipeline to have listed parameters to be passed on each build.
  • Install WinRM which is used by Ansible for connecting to Windows. You can use sudo pip3 install pywinrm for linux host.
Parameter type: Choice, Parameter Name: host, Paramater Value: ['linux','windows']; // This is deciding which target the pipeline should be executed. It can be either windows or linux, but not both.
Parameter type: Credentials, Parameter Name: git_credential, Paramater Value: <User name and password of git repo>; // Configured it in Jenkins
Parameter type: String, Parameter Name: git_branch, Paramater Value: <Branch of git repo>; // master
Parameter type: String, Parameter Name: git_repo_url, Paramater Value: <Clone URL of git repo>;
Parameter type: Text, Parameter Name: host_details, Paramater Value: <[linux]\nlinux1.com\nlinux2.com \nOR\n [windows]\nwin1.com\nwin2.com>;

Ansible

  • No seperate configuration for Ansible as we covered it in above section.

Linux Targets

  • No seperate configs but esnure the SSH connectivity from Jenkins

Windows Targets

Implementation

  • Implementation is simple. Change the target server details on hosts file. For Linux server add hostname below [linux] and windows server below [windows]. Once done push it to repo and configure it to consumed by Jenkins pipeline to read the file Jenkinsfile. Ensure the other parameter values are also given if default value are not set for those.

Assumption/Key Details

  • User/SSH details for bot linux and windows hosts are already configured.
  • Linux user used here is ec2-user
  • Windows user used here is Test
  • Script and log will be available in /app/ for Linux targets
  • Script and log will be available in C:\Process\ for Linux targets
  • Linux service name host-monitor.service
  • Windows service name Hostname Monitor

hostname-monitor's People

Contributors

fazith27 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.