Skip to content

v0.2.1 Deployment on Two Machines

Prasad Talasila edited this page Nov 24, 2017 · 1 revision

Prerequisite

  1. Ubuntu server 16.04 operating system.

  2. Record the Domain names, Public and Private IP Addresses and Login Credentials of both the machines. Let label the IP addresses as follows.

    Machine Public IP Private IP
    Front-End-and-LB Public_IP_1 Private_IP_1
    Execution-Nodes Public_IP_2 Private_IP_2

    Because of ease of use, domain names (DNS) are a preferred option for hostnames in all the configuration files. If you have domain names for the machines, you can use the domain names in the place of IP addresses in all the configuration files.
    Most likely, your machine may be on a corporate private network with a gateway / proxy server / firewall connection to Internet. In that case, please use your machine's private ip address.
    You can locate the configured IP address of your machine using the following command.

    ip addr show
    

    in the displayed output, look for IP address following the inet keyword.

  3. Change the listening port of SSH server to 2222 in /etc/ssh/sshd_config file and restart the SSH server using the following command.
    sudo service ssh restart
    If the SSH server is not running on your machine, please ignore the rest of this section and directly go to On Machine 1 section.

  4. For the SSH setting to be fully effective, logout of the current SSH session and relogin.

  5. From Machine 1, SSH into Machine 2 using its Private IP once to add the SSH server public key of Machine 2 to ~/.ssh/known_hosts in Machine 1.

On Machine 1

  1. Create SSH config file (~/.ssh/config) with the following contents.
    Host *
         StrictHostKeyChecking no
         UserKnownHostsFile=/dev/null

  2. Create ansible config file (~/.ansible.cfg) with the following contents
    [defaults]
    host_key_checking = False

  3. Download the code repository
    wget https://github.com/AutolabJS/AutolabJS/archive/dev.zip -O AutolabJS.zip
    unzip AutolabJS.zip
    mv AutolabJS-dev AutolabJS

  4. Change to deploy directory
    cd AutolabJS/deploy

  5. Update the certificate information in deploy/openssl.cnf and deploy/keys.conf.

  6. Execute setup script
    ./setup.sh

  7. Configure the autolab components by editing the configuration files in deploy/configs/<component>. Note that you need to use the Private IP of the machines wherever required.
    The list of configuration files to be changed are:
    deploy/configs/main_server: APIKeys.json, conf.json, courses.json, labs.json
    deploy/configs/load_balancer: nodes_data_conf.json
    deploy/configs/execution_nodes: scores.json, conf.json

  8. Edit the ansible inventory file. You can find the inventory in AutolabJS/deploy directory.

    1. Update the credentials as required. Please make sure that the changed passwords match in both the inventory file and the configuration files.
      The locations of credentials are:

      File MySQL GitLab Main Server
      deploy/inventory
      deploy/configs/main_server/APIKeys.json ✔ (for /admin route)
      deploy/configs/main_server/conf.json
      deploy/configs/load_balancer/nodes_data_conf.json
    2. In the gitlab section of inventory file, change the hostname of gitlab item from localhost to Public IP. The line should look like

    [gitlab]    
    
    <Public_IP_1> ansible_connection=local ansible_python_interpreter=/usr/bin/python2 gitlab_password=<gitlab_password>
    

    The only exception to the use of private IP is given in the above line. If your Gitlab installation runs on a computer with one public IP address and one private IP address, use the public_IP_1 address in the above line. Otherwise, use private_IP_1 address.

    1. In the loadbalancer section of inventory file, change gitlab_hostname variable in loadbalancer group to Private IP of Machine 1.
    [loadbalancer]    
    
    localhost ansible_connection=local ansible_python_interpreter=/usr/bin/python2 submissions_dir=../load_balancer/submissions gitlab_hostname=<Private_IP_1> gitlab_password=12345678
    
    1. In the executionnodes section of inventory file, change the hostname of executionnode item to Private IP of Execution Node and change gitlab_hostname variable to Private IP of Machine 1. The connection to execution nodes is changed from localhost to ssh. The line should look like
    [executionnodes]    
    
    <Private_IP_2> ansible_connection=ssh ansible_user=<machine2_user> ansible_password=<machine2_ssh_password> ansible_python_interpreter=/usr/bin/python2 gitlab_hostname=<Private_IP_1> gitlab_password=12345678 port=8082
    
  9. Run the ansible-playbook
    sudo ansible-playbook -i inventory playbook.yml -u <username2> --ask-sudo-pass
    You will be asked for two sudo passwords with the following prompts.

    [sudo] password for <username1>: 
    SUDO password: 

    The first line corresponds to sudo credentials for username1 on ; the second SUDO corresponds to sudo password on .

  10. Ansible installs all the components of Autolab. If the previous step executes successfully, the installation is complete.

  11. Add cron job to restart the autolab components automatically. You need to do this on both the machines.

    1. Login as root
      sudo su
    2. Copy restart script to root account on both the machines
      cp deploy/autolab-restart.sh /root/
      You need to use sftp to copy autolab-restart.sh script to machine2.
    3. Open crontab editor as root user
      crontab -e
    4. Enter a job in the file to run the restart script every minute.
      * * * * * bash /root/autolab-restart.sh
  12. In case of installation failure due to incorrect configuration, please see the FAQ page to see if you can resolve the error. If not, you can run the following commands to uninstall Autolab.

    1. The uninstall command is:
      sudo ansible-playbook -i inventory uninstall.yml -u <username2> --ask-sudo-pass
      The username and the password to be provided are the credentials of root user of machine2.

    2. Remove the previously generated SSH keys
      rm -f AutolabJS/deploy/keys/main_server/*
      rm -f AutolabJS/deploy/keys/load_balancer/id_rsa*

    3. Remove the data directories of MySQL and Gitlab components.
      sudo rm -rf /opt/sqldata
      sudo rm -rf /srv/gitlab

    4. Check the configuration done in steps - (6), (7) and Repeat the installation step-(8) given above.

  13. After successful installation, delete SSH and ansible configuration files.
    rm ~/.ssh/config ~/.ansible.cfg

  14. Installation creates containers for main server, load balancer, execution node, data base and Gitlab. For further information on managing these containers see container maintenance page.

Clone this wiki locally
You can’t perform that action at this time.