NeevAI SuperCloud
LoginSIGN UP
  • NeevCloud Account
    • Getting Started with Neev account
      • Create & activate NeevCloud account
        • NeevCloud Account Signup
          • Email Verification
          • KYC Validation
          • Enter Billing Profile
          • Payment Validation
        • Customer Validation Process for Indian Customers
          • If you are the primary contact of the Organization
          • If you are not a Primary Contact in NeevCloud Account
      • Customer Validation Process FAQs
  • NeevCloud Products
    • Dashboard
    • Computes
      • Compute Flavors
      • Getting Started Launch VMs
        • Launch Alma Linux
        • Launch Window Server
        • Launch Instance using the Password
      • Launch instance by 1-click Marketplace platform
        • Create a Tally instance from the Neevcloud Marketplace
        • Create a PostgreSQL instance from Neevcloud Marketplace
        • Create a Nginx instance from Neevcloud Marketplace
        • Create a MariaDB instance from Neevcloud Marketplace
        • Create a Docker instance from Neevcloud Marketplace
        • Create a Nodejs Instance from Neevcloud Marketplace
        • Create a MongoDB Instance from the Neevcloud Marketplace
        • Create a CloudPanel Instance from the Neevcloud Marketplace
        • Create a GitLab Instance from the Neevcloud Marketplace
        • Create a Ubuntu RDP Instance from the Neevcloud Marketplace
        • Create a Clickhouse Instance from the Neevcloud Marketplace
        • Create an OpenLiteSpeed WordPress Instance from the NeevCloud Marketplace
        • Create a FortiGate instance from the Neevcloud Marketplace
      • Manage Cloud Instance
        • Overview
        • Volumes
        • Snapshots
        • Networking
        • Security Group
          • Add Rules to the Security group
        • Rescale
        • Pricing
      • Default username of operating systems
      • Volume-based instances and image-based instances.
      • How to Delete the Instance
    • GPU
      • Deploy GPU Instance with Tesla T4
    • Networking
      • Network
        • Create a Network
        • Create Network With Private IP
      • LoadBalancer
        • Configure Load Balancing
      • Floating IPs
        • Create Floating IPs
        • Assign Floating IPs
      • Routers
        • Create Router
      • Security Groups
        • Add Security Group
        • Allow SSH Port to Specific IP Address
        • Allow ICMP for ping
        • Allow RDP Port to Specific IP Address
      • Subnets
        • Create Subnets
    • Volumes
      • Create a volume
      • Delete a volume
      • Attach Volume to Instance
      • Extend Instance Volume Size
      • To create a server using volume
    • Backups
      • Here's a guide on how to create a backup.
    • Snapshots
      • Create snapshosts
      • Create an Instance using Snapshot
    • Storage
      • Object storage
        • Create Bucket
        • Service URLs for NeevCloud S3
      • Neevcloud S3 integration
        • Connect Acronis Backup Gateway With Neevcloud Storage
        • Connect Veeam Backup Gateway With Neevcloud Storage
        • Connect MSP360 Backup With Neevcloud Storage
        • Connect Vembu Backup with Neevcloud storage
        • Connect Ahsay cloud backup suite(ACBS) with NeevCloud Storage
        • Connect ARQ Backup Solution with NeevCloud Storage
        • Backup your WordPress Site to Neevcloud s3 storage with using Updraft plugin
        • Connect Bucket with S3 Client
        • Connect Bucket with Cyberduck
        • Connect S3 storage to CPanel
        • Connect S3 Drive to NeevCloud S3 Bucket
        • Mount S3 Bucket to Linux operating system
        • How To Mount NeevCloud S3 Bucket as a Window Drive
      • S3 data migrations
        • Migrate from AWS s3 storage to NeevCloud s3 storage
        • Migrate from Wasabi s3 storage to NeevCloud s3 storage
    • Kubernetes
      • Launch Kubernetes Cluster
    • Financial Information
      • Add Fund
      • Bill History
      • Billing Address
      • How Does NeevCloud Billing Works
    • Access Details
      • SSH KEY
        • Generate SSH_KEY
      • Application Credentials
      • S3/EC2 Credentials
        • Create S3/EC2 Credentials
    • Abuse Complaints
      • What is Phishing?
    • Support
    • Security
  • NeevCloud Guide
    • NeevCloud KnowledgeBase
      • Set up LEMP (Linux, Nginx, MySQL, PHP) in Ubuntu Linux
      • Set up LAMP (Linux, Apache, MySQL, PHP) in Ubuntu Linux
      • Set up WordPress in Linux instance
      • Set up Plesk in Ubuntu
      • Set up Cpanel in Linux Instance
      • Set up Grafana
        • Install Grafana and Prometheus on Ubuntu 22.04
      • Set up a MongoDB Cluster using 3 Linux Instances
        • MongoDB Cluster with 3 Linux Instances
      • Setup Ansible Linux Instance and Application deployment on Instances
        • Deployment Application on Instances
      • Install Node.js & NPM on Linux
        • Installation of Node.js and NPM in Alma Linux
      • How to use SFTP for Uploading & Downloading files
      • Two-factor Authentication
      • How to use PuTTY for SSH key-based authentication
      • How To Create VPC on NeevCloud
      • How to Install Nginx on Ubuntu 22.04
      • How To Install Apache on Ubuntu 22.04
      • How To Install MySQL on Ubuntu 22.04
        • Mysql database backup and restore by mysqldump
      • How To Install MariaDB on Ubuntu 22.04
      • How To Install PostgreSQL on Ubuntu 22.04
      • How To Install MongoDB on Ubuntu 22.04
      • How To Install phpMyAdmin on Ubuntu 22.04
      • How To Open Port on Linux
      • How to Install Metabase on Ubuntu 22.04
      • How to transfer data from a Windows server to a NeevCloud bucket using Rclone
      • How to Integrate QNAP NAS storage and Backup to Neevcloud
      • How to Install Remote Desktop (xrdp) on Ubuntu.
      • Setup MLflow in Neevcloud Instance
      • Docker
        • Docker Installation in Ubuntu/Debian
        • Some Best practices for using Docker in application development include:
          • Create a Docker File and using Docker file Build Images
          • Docker Container
          • Docker-Compose
      • Acronis Backup Gateway With Neevcloud
    • Kubernetes
      • Deploy Nginx Service in Kubernetes
      • Deploy Lamp in Kubernetes with using Helm.
      • Deploy WordPress in Kubernetes.
      • Deploy Argocd in Kubernetes
      • Deploy Jenkins in the Kubernetes cluster
    • Troubleshoot
      • How to Access Instances
        • Access Linux instance
        • Access with Password Authentication
        • Access Windows Instance
        • Change the RDP Port and access the windows server
      • How to change the SSH Port
      • Troubleshooting Steps If your Instance is not accessible
      • How to Monitor Server Load on a Windows Cloud Instance
      • Why cloud instance is Out Of disk space
      • High Processor Load on your cloud instance
      • Steps If your Website URL is down
      • Best Practices After Reboot.
      • Reset the root password.
    • Use case
      • High-Level Architecture with Load Balancer and Jump Server in a VPC Setup
    • FAQ
      • Setup Zabbix app
      • How to change the instance Password
      • How to Access a Server Using a Static IP Address
      • What is the billing process for NeevCloud?
      • What payment methods are accepted by NeevCloud?
      • What happens if I miss a payment?
      • What is YAML
      • How can I get support for billing-related issues?
      • Can I contact NeevCloud's technical support team?
      • How to raise the ticket in the NeevCloud
      • Where can I find additional information on pricing and billing?
      • What are the terms and conditions for using Neevcloud services
Powered by GitBook
On this page
  • Deployment application on an instance
  • Prerequisites:-
  • Update && upgrade the all Node
  • Installation of Ansible
  • Creating an Ansible Inventory File
  • Create the Inventory File
  • Validate Your Inventory File
  • To check connection between nodes
  • To check storage and spaces
  • Preparing Playbook
  • Running Your Playbook
  • Deploy Docker on Your host nodes Through Ansible
  1. NeevCloud Guide
  2. NeevCloud KnowledgeBase
  3. Setup Ansible Linux Instance and Application deployment on Instances

Deployment Application on Instances

Ansible provides open-source automation that reduces complexity and runs everywhere. Using Ansible lets you automate virtually any task.

PreviousSetup Ansible Linux Instance and Application deployment on InstancesNextInstall Node.js & NPM on Linux

Last updated 7 months ago

Deployment application on an instance

Prerequisites:-

One Ansible Master Node

One or more Ansible Hosts Node

Make sure all the Nodes create the Same SSH_KEY

Check Ansible Master node is the machine we’ll use to connect to and control the Ansible hosts over SSH.

Ubuntu 22.04

Update && upgrade the all Node

Run these commands on all the nodes

sudo apt-get update -y && apt-get upgrade -y

Connect all the host nodes with the Master node by using SSH_KEY

Navigate to the .ssh directory to the master node

cd .ssh/

Create a file like ansible_key

vi ansible_key

In ansible_key, insert the key you downloaded when creating the server.

Open the downloaded key in Notepad and copy/paste it into the ansible_key file.

Grant access to the key.

chmod 700 ~/.ssh/
chmod 600 ~/.ssh/ansible_key

Access the host node from the master node.

Installation of Ansible

Ansible as a means of managing your server infrastructure, you need to install the Ansible software on the machine that will serve as the Ansible master node.

To add the official project's PPA (Personal Package Archive) to your system's list of sources in the control node, execute the following command:

sudo apt-add-repository ppa:ansible/ansible

Next, refresh your master node

sudo apt-get update -y 

Following the update you can install the Ansible -

sudo apt-get install ansible -y

Creating an Ansible Inventory File

To manage your nodes with Ansible, you need to create an inventory file. The inventory file contains information about the hosts you want to manage with Ansible. Here's a quick guide on how to create one.

Choose Your Inventory Format

Ansible supports two formats for inventory files: INI and YAML. The INI format is simpler and more commonly used for small projects or examples. The YAML format provides more flexibility and is preferred for more complex configurations.

INI Format Example:

[webservers]
webserver1.example.com
webserver2.example.com

[dbservers]
dbserver.example.com

YAML Format Example:

all:
  children:
    webservers:
      hosts:
        webserver1.example.com:
        webserver2.example.com:
    dbservers:
      hosts:
        dbserver.example.com:

Create the Inventory File

  • For INI Format: Simply create a new file with a .ini extension (e.g., inventory.ini) and insert your host information following the INI example format.

  • For YAML Format: Create a file with a .yml or .yaml extension (e.g., inventory.yml) and structure your host information as shown in the YAML example.

You can choose the format accordingly.

For creating an Inventory file run these commands:-

vi /etc/ansible/hosts 
[servers]
server1 ansible_host=Host-1_IP_address
server2 ansible_host=Host-2_IP_address

[all:vars]
ansible_python_interpreter=/usr/bin/python3

Validate Your Inventory File

After creating your inventory file, you can validate it by running the following Ansible command:

ansible-inventory --list -y -i path/to/your/inventory/file 
ansible-inventory --list -y -i /etc/ansible/hosts 

To check connection between nodes

Once you have added your servers to the inventory file, verify that Ansible can connect to them and execute commands via SSH.

From your local machine or Ansible master node, run:

When executing any command with Ansible, it's crucial to always specify the path to the host file. You can observe the effect of this practice in the examples below.

ansible all -m ping -i /etc/ansible/hosts --private-key=~/.ssh/ansible_key

To check storage and spaces

Run the following command to check the available spaces and storage.

ansible all -a "free -h" -i /etc/ansible/hosts --private-key=~/.ssh/ansible_key

To check the Uptime of all servers ->

ansible servers -a "uptime" -i /etc/ansible/hosts --private-key=~/.ssh/ansible_key

Preparing Playbook

The playbook.yml file is where all your tasks are defined. A task is the smallest unit of action you can automate using an Ansible playbook. But first, create your playbook file using your preferred text editor:

sudo mkdir -p /etc/ansible/playbook/
cd /etc/ansible/playbook/
vi create_file.yml

Adding a creating a file task to your playbook.

---
- name: This playbook will create a file
  hosts: all
  become: true
  tasks:
    - name: Create a file
      file:
        path: /home/ubuntu/server_file.txt
        state: touch

Running Your Playbook

You’re now ready to run this playbook on one or more servers. Most playbooks are configured to be executed on every server in your inventory by default, but you’ll specify your server this time.

Before running the playbook command, navigate to the playbook directory.

cd /etc/ansible/playbook

ansible-playbook create_file.yml -i /etc/ansible/hosts --private-key=~/.ssh/ansible_key

Now we are performing another task to add users to all servers.

Adding creating a user task to your playbook.

cd /etc/ansible/playbook
vi playbook_user.yml
---
- name: This playbook creates a user
  hosts: all
  become: true
  tasks:
    - name: to create a user name testing_user
      user: name=server_testing_user
ansible-playbook playbook_user.yml -i /etc/ansible/hosts --private-key=~/.ssh/ansible_key

Deploy Docker on Your host nodes Through Ansible

Deploying Docker on your worker nodes can be efficiently accomplished using Ansible, a powerful automation tool that simplifies complex configuration tasks and repetitive deployment processes. Below are the steps to achieve a seamless Docker installation across your nodes:

1. Preparation of Inventory File

2. Install Docker Role

3. Create Your Playbook

4. Execute Playbook

Make sure we install the docker by following these steps because docker does not install directly we are adding apt-key-gpg and repository. We are adding apt-key-gpg and a repository inside the playbook.

We have already created the Inventory host file, and now we the creating a playbook for installing docker.

cd /etc/ansible/playbook/
vi docker_install.yml
ansible-playbook docker-install.yml -i /etc/ansible/hosts --private-key=~/.ssh/ansible_key

Now check the installed docker and go through individual nodes.

docker -v

By following these steps, you'll successfully deploy Docker on your worker nodes using Ansible, streamlining your deployment process and ensuring a consistent environment across all nodes.