Coder Social home page Coder Social logo

ansible-demo's Introduction

โš™๏ธ Ansible Example ๐Ÿ› ๏ธ

1. Install Ansible

If you are using Ubuntu / Debian

sudo apt update
sudo apt install ansible

If you are using CentOS / Redhat

sudo yum install epel-release
sudo yum install ansible

2. Generate a new SSH KEY

ssh-keygen -t rsa -f $HOME/.ssh/id_rsa  -q -P ""  <<< y

3. Copy SSH Key to remote servers

ssh-copy-id remote_user@remote_machine

4. Copy SSH Key to remote servers

ssh-copy-id remote_user@remote_machine

Build your inventory file:

edit inventory.yml file:

web:
  hosts:
    web1:
      ansible_connection: ssh # can be local in case host is localhost
      ansible_host: 1.1.1.1
    web2:
      ansible_connection: ssh # can be local in case host is localhost
      ansible_host: 2.2.2.2
    # You can add as many machines as you want

  vars:
    domain: www.helloworld.com # a fully qualifed domain name, or use nip.io to transfer your IP into a DN

db:
  hosts:
    db1:
      ansible_connection: ssh # can be local in case host is localhost
      ansible_host: 3.3.3.3
  
  vars:
    mysql_root_password: password

all:
  vars:
    ansible_python_interpreter: /usr/bin/python3
    ansible_ssh_private_key_file: ~/.ssh/id_rsa
    ansible_user: firas
    ansible_sudo_pass: pass

you can check ansible.cfg for variables that you can change/ update:

[defaults]
remote_tmp= /tmp/.ansible-${USER}/tmp

5. Deploy ๐Ÿš€ your app:

5.1. Nginx App

# To install Nginx
ansible-playbook -i inventory.yml  nginx/nginx_install.yml
# To enable the new domain name
ansible-playbook -i inventory.yml  nginx/nginx_sync_domain.yml
# To secure the new domain name with SSL 
ansible-playbook -i inventory.yml  nginx/nginx_secure_domain_https.yml

5.2. MySQL Database

# To install MySQL
ansible-playbook -i inventory.yml  mysql/mysql_install.yml

5.2. Docker

# To install Docker
ansible-playbook -i inventory.yml docker/docker_install.yml
# To Create a Docker container
ansible-playbook -i inventory.yml docker/docker_install.yml
# To delete the Docker container
ansible-playbook -i inventory.yml docker/docker_install.yml

ansible-demo's People

Watchers

James Cloos avatar Firas Chbiki 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.