Coder Social home page Coder Social logo

dsti-devops-2020-fall-iac's Introduction

Infrastructure as Code

The goal of this lab are to:

Usefull links

Prerequisites

Before you can start the lab, you have to:

  1. Install Virtualbox: https://www.virtualbox.org/wiki/Downloads

  2. Install Vagrant on your computer: https://www.vagrantup.com/downloads.html

  3. (Optional) On Windows, ensure that Hyper-V is disabled:

    1. Open a new Powershell
    2. Run the following command:
      Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-All
  4. Download the centos/7 Vagrant box for the Virtualbox provider:

    $ vagrant box add centos/7
    ==> box: Loading metadata for box 'centos/7'
        box: URL: https://vagrantcloud.com/centos/7
    This box can work with multiple providers! The providers that it
    can work with are listed below. Please review the list and choose
    the provider you will be working with.
    
    1) hyperv
    2) libvirt
    3) virtualbox
    4) vmware_desktop
    
    Enter your choice: 3
  5. Install vagrant vbguest pluggin (enables folder mounting)

    vagrant plugin install vagrant-vbguest
    
  6. Clone the lab repository to your computer:

    git clone https://github.com/adaltas/ece-devops.git
    
  7. Go to the infra-as-code directory:

    cd ece-devops/infra-as-code
    

Lab

Useful information

In the lab, we will use the ansible_local provisioner, so Ansible will be automatically installed on the VM by Vagrant. You don't need it on your computer!

Resources

In the infra-as-code directory, you will find:

  • A Vagrantfile that defines the VMs to be managed by Vagrant (1 CentOS 7 VM named gitlab_server in our case)
  • A playbooks/ directory that contains Ansible playbooks to install GitLab and run health checks

Lab Part 1

  1. Take a look at the Vagrantfile and at the YAML files playbooks/run.yml and playbooks/gitlab/install/tasks/main.yml
  2. Create and provision the VM
    1. Run the vagrant up command
    2. You should end up with the following error (this is planned):
      TASK [gitlab/install : Install GitLab] *****************************************
      fatal: [gitlab_server]: FAILED! => {"changed": false, "msg": "No package matching 'gitlab-ee' found available, installed or updated", "rc": 126, "results": ["No package matching 'gitlab-ee' found available, installed or updated"]}
    3. Check that everything is ok by connecting to the VM through SSH:
      vagrant ssh gitlab_server
      
  3. Complete the GitLab installation
    1. Fill the blanks in gitlab/install/tasks/main.yml based on the steps 1. and 2. of the GitLab installation doc for CentOS 7
    2. Update the playbooks on the VM using vagrant upload:
      vagrant upload playbooks /vagrant/playbooks gitlab_server
      
    3. Rerun provisioning with the command vagrant provision
  4. Test your installation by connecting to http://20.20.20.2 (step 3 of the GitLab installation doc):
    1. Choose a password
    2. Login as the user root using the password

Lab Part 2

  1. Read the GitLab Health Check doc
  2. Run a healthcheck using curl:
    1. Connect to the VM using vagrant ssh
    2. Run the command:
      $ curl http://127.0.0.1/-/health
      GitLab OK
  3. Read playbooks/roles/gitlab/healthchecks/tasks/main.yml to understand how it relates
  4. Run the gitlab/healthcheck role
    1. Connect to the VM using vagrant ssh
    2. Run the playbooks using the right tag (replace TAG):
      ansible-playbook /vagrant/playbooks/run.yml --tags TAG -i /tmp/vagrant-ansible/inventory/vagrant_ansible_local_inventory
      

Note: you can also modify the Vagrantfile to change the tag you want to run your playbook with. Then, instead of running the ansible-playbook command inside the VM (after SSH), you can tell vagrant to run ansible provision again with command:

vagrant provision
  1. Run the 2 other kind of health checks in the playbook (using the uri module):
    1. Readiness check.
    2. Liveness check
  2. Print the results of the health checks in the console
  3. (Bonus) Print a custom message with only the disfunctional(s) services in the Readiness check if there are some. To test the printing, stop redis using the command sudo gitlab-ctl stop redis on the node before running the playbook again. Tip: use the json attribute of the response.

dsti-devops-2020-fall-iac's People

Contributors

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