Git Product home page Git Product logo

check_server_log_files's Introduction

Check log files in a server through the web browser

License: MIT GitHub release Build status Ansible Role Ansible Role downloads

This solution is explained in detail in the Codeyourinfra project blog post How to check log files in a server without logging in the server. Check it out!

Problem

The developers are always requesting you the applications' log files, for troubleshooting purposes. The company's security policies determine that they can't log in the server where the files are. You're tired of sending the files by email to the developers all day long.

Solution

Make the log files available through the web browser! check_server_log_files is an example of Ansible role which makes that for you. When executed, the role installs and configures the Apache HTTP Server in a way that log files become accessible through the browser.

In our sample the Jenkins log is exposed, but you can easily do the same for any application, by setting accordingly the variables. You can either replace the default variables defined in the defaults/main.yml file or override them by setting new values in the playbook level, as shown below:

---
- hosts: apps
  roles:
    - role: check_server_log_files
      vars:
        apache_confs:
          - directory: /var/log/app1
            alias: /logs/app1
            conf: app1-logs.conf
          - directory: /var/log/app2
            alias: /logs/app2
            conf: app2-logs.conf

Test

First of all, run the command vagrant up, in order to turn on the jenkins server. After that, execute the command ansible-playbook playbook.yml. Finally, open your web browser and access the Jenkins log files through the URL http://192.168.33.10/logs/jenkins. Alternativelly, download the Jenkins log file through the command wget http://192.168.33.10/logs/jenkins/jenkins.log.

Automated tests

You can also test the solution automaticaly, by executing ./test.sh or using Molecule. With the latter, you can perform the test not only locally (the default), but in AWS as well. During the Codeyourinfra's continuous integration process in Travis CI, the solution is tested in an EC2 instance.

In order to get your environment ready for using Molecule, prepare your Python virtual environment, executing python3 -m venv env && source env/bin/activate && pip install -r requirements.txt. After that, just run the command molecule test, to test the solution locally in a VirtualBox VM managed by Vagrant.

If you prefer performing the test in AWS, bear in mind you must have your credentials appropriately in ~/.aws/credentials. You can configure it through the AWS CLI tool. The test is performed in the AWS region Europe - London (eu-west-2). Just run molecule test -s aws and check the running instance through your AWS Console.

check_server_log_files's People

Contributors

dependabot[bot] avatar gustavomcarmo avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  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.