Vagrant triggers backup databases

Introduction

When you running command Vagrant resume, Vagrant halt and vagrant destroy. Then Vagrant triggers backup databases. For example backup Mysql databases for WordPress. Vagrant the essential for DevOps Roles.

Vagrant triggers backup databases

Installing vagrant triggers

$ vagrant plugin install vagrant-triggers

To configure the vagrant triggers database dump

$ vim Vagrantfile

The content as below:

VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
#config.vm.box = "digitalquery/wpvagrant"
 config.vm.box = "ubuntu/xenial64"
 config.vm.hostname = "wp"
 config.ssh.insert_key = false
 # Vagrant triggers
 #config.trigger.before :destroy, :stdout => true do
 #config.trigger.before :destroy do
 [:resume, :suspend, :halt, :destroy, :reload].each do |cmd|
 config.trigger.before cmd, stdout: true do
 info "Dumping the database before destroying the VM..."
 run_remote "bash /vagrant/mysql/db_dump.sh"
 #run "vagrant ssh -c 'sh /vagrant/wp-vagrant/mysql/db_dump.sh'"
 end
 end
 end

The databases dump script

$ vim /home/huupv/project/mysql/db_dump.sh

The content db_dump script as below:

#!/bin/bash
 echo "db name is wordpress"
 if [ ! -z "wordpress" ]; then
 now=`date +"%Y_%m_%d-%H-%M-%S"`
 db_dump_file=wordpress"_"$now".sql"
 echo "dumping database before destroy"
 echo "dump file: /vagrant/mysql/db_dumps/$db_dump_file"
 if [ ! -d /vagrant/mysql/db_dumps ]; then
 sudo mkdir /vagrant/mysql/db_dumps
 fi
 mysqldump -u root --password=root wordpress > /vagrant/mysql/db_dumps/$db_dump_file
 if [ ! "$?" -eq 0 ]; then
 echo "DATABASE DUMP FAILED - YOU MAY WISH TO ABORT VAGRANT DESTROY."
 echo "Check /vagrant/VAGRANT_ENV/db_dumps/error.log for more info"
 fi
 fi

Conclusion

How to preserve your MySQL Databases Between Destroy and halt. Vagrant triggers are the plugin. Thank you for reading the DevopsRoles page!

Vagrant SSH key pair Setup: Essential Guide for DevOps Professionals

Introduction

In this tutorial, I will guide you through setting up an Vagrant ssh key pair. We’ll generate the SSH keys, where vagrant_rsa will the private key and vagrant_rsa.pub will serve as the public key. This allows you to log into the Virtual Machine without needing a password. Setting up Vagrant is crucial for those in DevOps roles.

Understanding SSH Key Management in Vagrant

When working with Vagrant, a tool that streamlines the creation and management of virtual development environments, it’s crucial to understand how SSH keys are handled. SSH keys play a vital role in securing access to your Vagrant virtual machines (VMs).

Vagrant SSH Key Location

By default, when you initiate a new Vagrant environment, Vagrant automatically generates an SSH key pair if none exists. This is done to ensure secure, password-less access to the created VM. The location of these SSH keys is typically within the Vagrant project directory .vagrant/machines/<machine-name>/virtualbox/private_key for VirtualBox users. This path might vary slightly depending on the provider you are using, such as VMware or Hyper-V.

Managing Vagrant SSH Keys

It’s important to know that Vagrant configures its VMs to use these automatically generated keys. However, for enhanced security or personal preference, you can configure Vagrant to use a custom SSH key pair. This involves specifying your private key in the Vagrantfile and ensuring the corresponding public key is authorized in the VM. Managing these keys properly ensures that access to your VM is both secure and restricted to authorized users only.

Below is the folder structure for the Vagrant project:

/home/huupv/project
/home/huupv/project/keys/.ssh

Vagrant SSH key pair

The first is to create a vagrant SSH key

Using the ssh-keygen command to create the private key and public key for a vagrant.

ssh-keygen

The output private key and public key files in “/home/huupv/project/keys/.ssh” folder as below:

vagrant_rsa vagrant_rsa.pub

To configure vagrant ssh key in Vagrantfile

To add the lines in the Vagrantfile file as below:

Vagrant.configure("2") do |config|
config.vm.box = "centos/6"
config.ssh.insert_key = false
config.vm.boot_timeout = 800
config.ssh.private_key_path = ["keys/.ssh/vagrant_rsa", "~/.vagrant.d/insecure_private_key"]
config.vm.provision "file", source: "keys/.ssh/vagrant_rsa.pub", destination: "~/.ssh/authorized_keys"
end
  • ~/.vagrant.d/insecure_private_key: You should append this default key. The use config.ssh.insert_key = false to Vagrant not generate a random key.
  • config.ssh.private_key_path: Changing Insecure Key To My Own Key On Vagrant box.

Conclusion

Finishing, We are customizing the vagrant SSH key with a Private/Public key. What you need to Private key saves in the host and the Public key copies authorized_keys into a vagrant box for Virtual Machine. Reference to configure vagrant SSH of the vagrant main site. Thank you for reading the DevopsRoles page!

How to set up a wordpress vagrant: A Comprehensive Guide

Introduction

Setting up WordPress with Vagrant has become a go-to solution for developers seeking a reliable, consistent, and portable environment for web development. Vagrant simplifies the process of creating and configuring virtual environments, ensuring that your WordPress projects are not only portable but also identical across various systems. This guide walks you through the step-by-step process of setting up WordPress Vagrant, from basic installation to advanced configurations.

In this tutorial, I’m set up a WordPress Vagrant, using vagrant box ubuntu with Nginx + MariaDB + WordPress. Vagrant the essential for DevOps Roles.

Benefits of Using Vagrant for WordPress Development

1. Consistent Environments

  • Ensures uniformity between development, staging, and production environments.
  • Avoids the common “works on my machine” problem.

2. Portable and Reproducible

  • Easily share development environments across teams.
  • Rapidly recreate environments in case of errors or new projects.

3. Integration with Popular Tools

  • Works seamlessly with VirtualBox, Docker, and other virtualization tools.
  • Supports provisioning tools like Ansible, Chef, and Puppet.

Prerequisites

Before diving into the setup, ensure you have the following:

Required Tools

System Requirements

  • At least 8GB of RAM.
  • 20GB of free disk space.
  • A stable internet connection.

Step-by-Step Guide to Setting Up WordPress with Vagrant

The structures files and folders wordpress vagrant as below:

[huupv@localhost project]$ pwd
/home/huupv/project
[huupv@localhost project]$ ls -F
keys/ nginx/ Vagrantfile var/
mysql/ php/ VAGRANT_ENV/ wp/

To configure Vagrantfile

vim Vagrantfile

The content as below:

VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.hostname = "wp"
config.ssh.insert_key = false
#config.vm.boot_timeout = 800
#config.ssh.username = vagrant
#config.ssh.password = vagrant
#config.ssh.private_key_path = ["keys/.ssh/vagrant_rsa", "~/.vagrant.d/insecure_private_key"]
#config.vm.provision "file", source: "keys/.ssh/vagrant_rsa.pub", destination: "~/.ssh/authorized_keys"
config.vm.provision :shell, path: "VAGRANT_ENV/bootstrap.sh"
config.vm.network "forwarded_port", guest: 80, host: 8888
config.vm.network :public_network, :bridge => "eth1", :auto_config => false
config.vm.provider :virtualbox do |vb|
# Set VM memory size
vb.customize ["modifyvm", :id, "--memory", "512"]
# these 2 commands massively speed up DNS resolution, which means outbound
# connections don't take forever (eg the WP admin dashboard and update page)
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
end
end

To configure file vagrant bootstrap.sh

vim VAGRANT_ENV/bootstrap.sh

The content as below:

#!/bin/bash
echo "Vagrant box (Ubuntu 16.04 + nginx + php7.0 + MariaDB + WordPress."
 echo "Updating apt-get"
 sudo apt-get -y update
# Nginx
 echo "Installing Nginx"
 sudo apt-get install -y nginx
# MySQL
 echo "Preparing for MySQL Installation"
 sudo apt-get install -y debconf-utils
 sudo debconf-set-selections << "mysql-server mysql-server/root_password password root"
 sudo debconf-set-selections << "mysql-server mysql-server/root_password_again password root" echo "Installing MySQL" #sudo apt-get install -y mysql-server-5.7
 sudo apt-get install -y mariadb-server mariadb-client php7.0-mysql
 sudo rm -f /etc/mysql/my.cnf
 sudo rm -f /etc/alternatives/my.cnf
 sudo cp /vagrant/mysql/my.cnf /etc/alternatives/my.cnf
 sudo ln -s /etc/alternatives/my.cnf /etc/mysql/my.cnf
 ls -ll /etc/mysql/my.cnf
 echo "Installing PHP and MySQL module"
 sudo apt-get install -y php-fpm php-mysql
# Nginx Config
 echo "Overwriting default Nginx config to work with PHP"
 sudo rm -rf /etc/nginx/sites-available/default
 cp /vagrant/nginx/default.conf /etc/nginx/sites-available/default
# php cli
 sudo sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php/7.0/fpm/php.ini
 sudo sed -i "s/display_errors = .*/display_errors = On/" /etc/php/7.0/cli/php.ini
 sudo sed -i "s/memory_limit = .*/memory_limit = 30M/" /etc/php/7.0/cli/php.ini
 sudo sed -i "s/;date.timezone.*/date.timezone = UTC/" /etc/php/7.0/cli/php.ini
# php fpm
 sudo sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php/7.0/fpm/php.ini
 sudo sed -i "s/display_errors = .*/display_errors = On/" /etc/php/7.0/fpm/php.ini
 sudo sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/7.0/fpm/php.ini
 sudo sed -i "s/memory_limit = .*/memory_limit = 30M/" /etc/php/7.0/fpm/php.ini
 sudo sed -i "s/upload_max_filesize = .*/upload_max_filesize = 100M/" /etc/php/7.0/fpm/php.ini
 sudo sed -i "s/post_max_size = .*/post_max_size = 100M/" /etc/php/7.0/fpm/php.ini
 sudo sed -i "s/;date.timezone.*/date.timezone = UTC/" /etc/php/7.0/fpm/php.ini
# Restarting Nginx for config to take effect
 echo "Restarting Nginx for changes to take effect"
 sudo service nginx restart

echo "Setting Ubuntu (user) password to \"vagrant\""
echo "ubuntu:vagrant" | chpasswd
# Services restart
 sudo systemctl restart mysql.service
 sudo systemctl restart nginx.service
 sudo systemctl restart php7.0-fpm.service
sudo mysql -u root -p -e 'show databases'
 #Create wordpress databases
 bash /vagrant/mysql/create_database.sh
 #To install and configure wordpress
 cd /tmp
 curl -O https://wordpress.org/latest.tar.gz
 tar xzvf latest.tar.gz
 sudo cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php
 mkdir /tmp/wordpress/wp-content/upgrade
 sudo cp -a /tmp/wordpress/* /var/www/html
 sudo find /var/www/html -type d -exec chmod g+s {} \;
 sudo chmod g+w /var/www/html/wp-content
 sudo chmod -R g+w /var/www/html/wp-content/themes
 sudo chmod -R g+w /var/www/html/wp-content/plugins
 sudo rm -f /var/www/html/wp-config.php
 sudo cp /vagrant/wp/wp-config.php /var/www/html/wp-config.php
 sudo usermod -a -G www-data ubuntu
 sudo chown -R ubuntu:www-data /var/www/html
 sudo systemctl restart nginx.service
 echo "Cleaning up additional setup files and logs"
 #sudo rm -r /var/www/html
 #sudo rm /var/www/ubuntu-xenial-16.04-cloudimg-console.log

To configure MySQL my.cf file

vim mysql/my.cnf

The content as below:


[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0

[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
bind-address = 0.0.0.0
key_buffer_size = 16M
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size = 8
myisam-recover = BACKUP
query_cache_limit = 1M
query_cache_size = 16M
log_error = /var/log/mysql/error.log
expire_logs_days = 10
max_binlog_size = 100M
[mysqldump]
quick
quote-names
max_allowed_packet = 16M

[mysql]
[isamchk]
key_buffer_size = 16M
!includedir /etc/mysql/conf.d/

To create a database for WordPress

vim mysql/create_database.sh

The content as below:

#!/usr/bin/env bash
if [ ! -z "wordpress" ] ; then
echo "creating database"
 sudo mysql -u root -p'root' -e "CREATE DATABASE IF NOT EXISTS wordpress;"
if [ ! -z "wp_db_user" ]; then
 echo " adding custom user"
 sudo mysql -u root -p'root' -e "GRANT ALL ON wordpress.* TO 'wp_db_user'@'localhost' IDENTIFIED BY '123456789'"
 sudo mysql -u root -p'root' -e "FLUSH PRIVILEGES;"
 sudo mysql -u root -p'root' -e 'show databases;'
 fi
else
 echo "No database name specified - skipping db creation"
fi

To configure file wp-config.php for WordPress vagrant

vim wp/wp-config.php

The content as below:

<?php
define('DB_NAME', 'wordpress');
/** MySQL database username */
 define('DB_USER', 'wp_db_user');
/** MySQL database password */
 define('DB_PASSWORD', '123456789');
/** MySQL hostname */
 define('DB_HOST', 'localhost');
/** Database Charset to use in creating database tables. */
 define('DB_CHARSET', 'utf8');
/** The Database Collate type. Don't change this if in doubt. */
 define('DB_COLLATE', '');
 define('AUTH_KEY', 'put your unique phrase here');
 define('SECURE_AUTH_KEY', 'put your unique phrase here');
 define('LOGGED_IN_KEY', 'put your unique phrase here');
 define('NONCE_KEY', 'put your unique phrase here');
 define('AUTH_SALT', 'put your unique phrase here');
 define('SECURE_AUTH_SALT', 'put your unique phrase here');
 define('LOGGED_IN_SALT', 'put your unique phrase here');
 define('NONCE_SALT', 'put your unique phrase here');
 $table_prefix = 'wp_';
 define('WP_DEBUG', false);
 /** Absolute path to the WordPress directory. */
 if ( !defined('ABSPATH') )
 define('ABSPATH', dirname(__FILE__) . '/');
/** Sets up WordPress vars and included files. */
 require_once(ABSPATH . 'wp-settings.php');
 define('FS_METHOD', 'direct');

To configure file nginx.conf

vim nginx/default.conf

The content as below:

server {
 listen 80 default_server;
 listen [::]:80 default_server ipv6only=on;
 root /var/www/html/;
 index index.php index.html index.htm;
 client_max_body_size 20M;
 server_name devopsroles.com;
 location / {
 try_files $uri $uri/ /index.php?$args;
 }
 error_page 404 /404.html;
 error_page 500 502 503 504 /50x.html;
 location = /50x.html {
 root /usr/share/nginx/html;
 }
 location ~ \.php$ {
 try_files $uri =404;
 fastcgi_split_path_info ^(.+\.php)(/.+)$;
 fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
 fastcgi_index index.php;
 include fastcgi_params;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 }
 }

Vagrant up running for WordPress

[huupv@localhost ~]$ cd /home/huupv/project/
[huupv@localhost project]$ vagrant up

FAQs

Q1: Why use Vagrant over Docker for WordPress?

While Docker is lightweight, Vagrant provides a full virtualized environment, making it suitable for developers needing an environment closer to production.

Q2: Can I use a different Linux distribution?

Yes, replace ubuntu/bionic64 in the Vagrantfile with the desired box name from Vagrant Cloud.

Q3: How do I update the Vagrant environment?

Use the following commands:

  • To apply updates: vagrant provision
  • To rebuild the environment: vagrant destroy -f && vagrant up

Q4: How do I troubleshoot Vagrant errors?

  • Check the Vagrant logs in the project directory.
  • Refer to the Vagrant Documentation.

External Resources

Conclusion

You have to set up a Vagrant WordPress Nginx + MariaDB. Setting up WordPress with Vagrant is a powerful way to ensure consistency and efficiency in web development. By following this guide, you can create a robust development environment tailored to your needs. Whether you’re a solo developer or part of a team, Vagrant offers the flexibility and reliability to elevate your WordPress projects. I hope will this your helpful. Thank you for reading the DevopsRoles page!

Your Complete Guide to Useful vagrant commands line

Introduction

Master the essentials of Useful vagrant commands line. Whether you’re starting, stopping, or managing virtual machines, this article provides the necessary commands to efficiently control your Vagrant environments. Ideal for developers and IT professionals looking to streamline their workflow in virtual machine management.

In this tutorial, I guide using the useful Vagrant commands line for Virtual Machines such as: Starting and Stopping a VM so forth. Vagrant the essential for DevOps Roles.

Useful vagrant commands line

Vagrant commands for Virtual Machine

Initialize Vagrant with a Vagrantfile

# vagrant init

Initialize the vagrant with a specific box. To find a box, https://app.vagrantup.com/boxes/search
Vagrant commands for starting a Virtual Machine
To run the first vagrant up a Virtual Machine, to start vagrant environment

# vagrant up

To resume a Virtual Machine

# vagrant resume

Restarting a Virtual Machine

# vagrant reload

Vagrant commands for stopping a Virtual Machine
To stop a Virtual Machine

# vagrant halt

To suspend a Virtual Machine

# vagrant suspend

Vagrant commands cleaning up a Virtual Machine
To stop and delete all traces of the Virtual Machine

# vagrant destroy

Vagrant commands for Boxes
To list all installed boxes on your computer

# vagrant box list

To download a box image to your computer

# vagrant box add

Checking for updates vagrant box update

# vagrant box outdated

To delete a box from the machine

# vagrant boxes remove

The packages a running Virtualbox environment in a reusable box

# vagrant package

To snapshot a Virtual Machine
The VM-name often defaults. To roll back at a later time.

# vagrant snapshot save [options] [vm-name]

The useful vagrant commands
To get the vagrant version

# vagrant -v

The output status of the vagrant machine

# vagrant status

The output status of all vagrant machines

# vagrant global-status

The same as above, but prunes invalid entries

# vagrant global-status --prune

To use the debug flag to increase the verbosity of the output

# vagrant provision --debug

Vagrant can be configured to deploy code!

# vagrant push

To Runs vagrant up, forces provisioning and logs all output to a file

# vagrant up --provision | tee provision_2017.log

Conclusion

This compilation of useful Vagrant commands will empower you to manage your virtual machines more effectively. By familiarizing yourself with these commands, you can optimize your development environment and enhance your productivity. For a detailed exploration of each command, refer to the full guide. I hope will this your helpful. Thank you for reading the DevopsRoles page!

How to install Vagrant on Ubuntu: A Comprehensive Guide

Introduction

Vagrant is an open-source tool that simplifies the management of virtualized development environments. Whether you are a developer, system administrator, or DevOps engineer, Vagrant helps you create and manage virtual machines with ease, ensuring that your environments are consistent and repeatable. This guide will walk you through the process of install Vagrant on Ubuntu, covering everything from setting up prerequisites to completing the installation.

Vagrant is a crucial tool for anyone involved in development or DevOps roles, enabling you to streamline your workflows and focus on coding rather than environment setup. Let’s dive into the installation process and get Vagrant running on your Ubuntu system.

Requirements install vagrant on ubuntu

Before starting the installation, make sure you meet the following requirements:

  1. VirtualBox: Vagrant uses VirtualBox to create and manage virtual machines.
  2. sudo access: You’ll need administrative privileges to install software on your system.
  3. Ubuntu System: This guide is tailored for Ubuntu, but the steps are similar for other Linux distributions.

Step 1: Update Your System

Before installing any new software, it’s essential to update your system’s package list. This ensures that you have access to the latest versions of all packages.

sudo apt-get update

This command updates the package list, fetching the latest information on available software from the repositories.

Step 2: Install VirtualBox

Installing VirtualBox on Ubuntu 14.04

For Ubuntu 14.04 users, VirtualBox needs to be installed by adding the appropriate repository to your system. Open the /etc/apt/sources.list file:

sudo vim /etc/apt/sources.list

Add the following lines to the file:

deb http://download.virtualbox.org/virtualbox/debian saucy contrib
deb http://download.virtualbox.org/virtualbox/debian raring contrib
deb http://download.virtualbox.org/virtualbox/debian quantal contrib
deb http://download.virtualbox.org/virtualbox/debian precise contrib
deb http://download.virtualbox.org/virtualbox/debian lucid contrib non-free
deb http://download.virtualbox.org/virtualbox/debian wheezy contrib
deb http://download.virtualbox.org/virtualbox/debian squeeze contrib non-free

Once the repository is added, install VirtualBox 4.3 using the following commands:

wget http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc
sudo apt-key add oracle_vbox.asc
sudo apt-get install virtualbox-4.3

Installing VirtualBox on Ubuntu 16.04

For Ubuntu 16.04, the process is slightly different. Open the /etc/apt/sources.list file:

sudo vim /etc/apt/sources.list

Add the following line to the file:

deb http://download.virtualbox.org/virtualbox/debian xenial contrib

Now, install VirtualBox 5.1 using these commands:

wget https://www.virtualbox.org/download/oracle_vbox_2016.asc
sudo apt-key add oracle_vbox_2016.asc
sudo apt-get install virtualbox-5.1

Finally, add your user to the vboxusers group to ensure you have the necessary permissions:

sudo usermod -a -G vboxusers <your-username>

Step 3: Install Vagrant

With VirtualBox installed, you’re ready to install Vagrant. The process is straightforward and can be completed with a single command:

sudo apt-get install vagrant

This command installs the latest version of Vagrant, which is available in the Ubuntu repositories.

Frequently Asked Questions (FAQs)

What is Vagrant used for?

Vagrant is used to create and manage virtualized development environments. It allows developers to work on projects in a consistent environment across multiple machines, ensuring that the code behaves the same in development, testing, and production.

Can I use Vagrant with other virtualization platforms besides VirtualBox?

Yes, Vagrant supports several other virtualization platforms, including VMware, Hyper-V, and Docker. However, VirtualBox is the most commonly used and fully supported platform with Vagrant.

Do I need an internet connection to use Vagrant?

An internet connection is required to download Vagrant boxes (pre-configured virtual machines). However, once the boxes are downloaded, you can use Vagrant offline.

How do I update Vagrant to the latest version?

You can update Vagrant by running sudo apt-get update followed by sudo apt-get install vagrant. This will install the latest version available in the Ubuntu repositories.

Conclusion

Installing Vagrant on Ubuntu is a straightforward process that can significantly improve your development workflow. By following the steps outlined in this guide, you can set up a consistent and reproducible development environment in no time. Whether you’re new to Vagrant or a seasoned user, having it installed on your Ubuntu system will undoubtedly streamline your work.

Thank you for reading this guide on how to install Vagrant on Ubuntu. We hope you found it helpful and informative. If you have any questions or need further assistance, feel free to reach out. Thank you for reading the DevopsRoles page!

How to install vagrant on centos 6

Vagrant is Configuration Management (CM). Development environment made easy use vagrant. To knowledge, vagrant to help for building and deployment. It’s open-source. let’s go! “How to install vagrant on centos 6”. Vagrant the essential for DevOps Roles.

Requirements

  • Install VirtualBox
  • Install Vagrant
  • A sudo user

To update and install the dependency packages

 # yum update
 # yum install wget binutils qt gcc make patch libgomp glibc-headers glibc-devel kernel-headers kernel-devel dkms

Step 1: To install VirtualBox on centos 6

Downloading and installing Virtualbox on centos 6

 # cd /etc/yum.repos.d/
 # wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo
 # yum install VirtualBox-5.1

To add sudo user huupv to vboxusers

 # usermod -a -G vboxusers huupv

Step 2: To install vagrant on centos 6

Link download for the latest version of vagrant: https://www.vagrantup.com/downloads.html
For my lab, To download vagrant_2.0.0 for centos 64 bit

 # wget -qO- https://releases.hashicorp.com/vagrant/2.0.0/vagrant_2.0.0_x86_64.rpm?_ga=2.14788275.482799349.1505026202-1074579003.1504020307 -O vagrant_2.0.0_x86_64.rpm

To install vagrant

 # rpm -ivh vagrant_2.0.0_x86_64.rpm

Conclusion

Through the article, you can use How to install vagrant on centos 6 as above. I hope will this your helpful. Thank you for reading the DevopsRoles page!

How to install GitLab on Linux

In this tutorial, How to install Gitlab on Linux such as centos server and ubuntu server. To use Gitlab CE or Community Edition is open source. It’s a Git repository, a Gitlab server like a GitHub server. The commands as below running root account.

The steps for installing the Gitlab server are as below:

  • SSH client connects to Gitlab server
  • To install the package dependencies and install Gitlab CE
  • The firewall has to open a port for the GitLab server

The hardware requirements for the Gitlab server:

  • 2 cores4GB
  • of RAM

Gitlab on Centos server

Update System Packages and Install Dependencies for the Centos server.

Open a terminal

Install them by running the following command:

# yum update -y
# yum install curl openssh-server postfix -y

Note: During Postfix installation, select Internet Site when prompted.

To install GitLab CE on the Centos server

# cd /opt/
# curl -O https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh
# sh script.rpm.sh
# yum -y install gitlab-ce
# gitlab-ctl reconfigure

Gitlab on the Ubuntu server

Update and install package dependencies for the Ubuntu server

# apt-get update -y
# apt-get install curl openssh-server postfix -y

Note: During Postfix installation, select Internet Site when prompted.

To install GitLab CE server on the Ubuntu server

# cd /opt/
# curl -O https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh
# bash script.deb.sh
# apt-get install gitlab-ce
# gitlab-ctl reconfigure

How to change password root default for Gitlab server. The problem is when you first login “Invalid login or password” on the Gitlab server. This problem is solved!

# gitlab-rake gitlab:setup RAILS_ENV=production GITLAB_ROOT_PASSWORD=123456789

The finish, To install GitLab CE Server, the first login
From the browser you access to links:  “http://gitlab_domain_or_IP” and then login with a “root” user and with the initial password “5iveL!fe. (in this tutorial, the changed password for root is 123456789)

To restart the service for the Gitlab server

# gitlab-ctl restart

The output below:

 ok: run: gitaly: (pid 18182) 1s
 ok: run: gitlab-monitor: (pid 18190) 0s
 ok: run: gitlab-workhorse: (pid 18193) 1s
 ok: run: logrotate: (pid 18201) 0s
 ok: run: nginx: (pid 18210) 0s
 ok: run: node-exporter: (pid 18212) 0s
 ok: run: postgres-exporter: (pid 18232) 0s
 ok: run: postgresql: (pid 18241) 0s
 ok: run: prometheus: (pid 18251) 0s
 ok: run: redis: (pid 18256) 1s
 ok: run: redis-exporter: (pid 18261) 0s
 ok: run: sidekiq: (pid 18273) 0s
 ok: run: unicorn: (pid 18278) 1s

To check the status of Nginx

# gitlab-ctl status nginx

The output below:

 run: nginx: (pid 18210) 55s; run: log: (pid 12818) 2487s

Conclusion

Through this article, you have installed GitLab server on Linux with distros centos or ubuntu server.

You have successfully installed GitLab on Linux. You can now create users, and repositories, and start using GitLab for your version control needs.

I hope this will be helpful for you! Thank you for reading the DevopsRoles page!

Install docker and learn containers on Centos

Introduction

How to install and configure Docker on centos. Learning to download a Docker image, running a Docker container, and so forth.

Introduce the concept of Docker and containers. Explain their benefits, such as portability, scalability, and isolation. Briefly mention that the blog post will guide readers through the process of installing Docker on CentOS and getting acquainted with containers.

To install Docker and learn about containers on CentOS, Step by step install Docker on Centos 6 and Centos 7. You can follow the steps below

Install docker

Docker is incorporated into Centos 7 extras repositories, due to installation being simple. For Centos 6, you install epel-release” repositories

To install docker on Centos 7

# yum update -y && yum install epel-release -y && yum install docker -y

To install docker on Centos 6

# yum update -y && yum install epel-release -y && yum install docker-io -y

The finish installed docker, To check the status, start, and enable services docker the below commands:

For Centos 7

# systemctl start docker
# systemctl status docker
# systemctl enable docker

For Centos 6

# service docker start
# service docker status
# chkconfig docker on

To Learn basic containers, Docker

To search for a Docker image, for example, a Centos image

# docker search centos

You choose the image and download it locally, Use the docker pull command

# docker pull centos

List all the available Docker images on your host

# docker images

To delete images

# docker rmi centos

Creating and rune a container

# docker run --name My_OS centos cat /etc/hosts

Starting, stats, and stopping a container

# docker start My_OS
# docker stats My_OS
# docker stop My_OS

To Run an Interactive Session in a container

# docker run --name My_OS -it centos bash

To reconnect to the running container you need the container ID or name

# docker attach My_OS

Stopping a running container from the host

# docker kill My_OS

Conclusion

You’ve successfully installed Docker and started learning about containers on CentOS. Additionally, you may find it helpful to explore container orchestration tools like Docker Compose and Kubernetes to manage and deploy multi-container applications. I hope this helps you. Thank you for reading the DevopsRoles page!

Devops Tutorial

Exit mobile version