Ansible tutorial

An Ansible tutorial is a practical guide that teaches you how to use Ansible, an automation tool, to manage servers and automate tasks. These tutorials usually start with the basics of installing Ansible and writing simple “playbooks,” which are scripts that define the tasks to be automated. You’ll learn to execute these playbooks to manage configurations and deploy software across your servers, making the process efficient and repeatable. The tutorials are designed to be accessible, emphasizing hands-on learning and real-world applications.

Ansible is an automation and orchestration tool. It is software that automates software provisioning, configuration management, and application deployment. The best way to increase my DevOps skills.

Getting Started with Ansible

Ansible tutorial

Start your project

$ mkdir project
$ cd project

Create an Ansible Inventory file



List of hosts you want to manage, grouped into groups.( deploy your local machine)

Create ansible-playbook


- hosts:
user: root
  - name: install nginx
    apt: pkg=nginx state=present
  - name: start nginx every bootup
    service: name=nginx state=started enabled=yes

Ansible run playbook

ansible-playbook -i hosts playbook.yml

Structure ansible role

files/ # 'copy' will refer to this
templates/ # 'template' will refer to this
meta/ # Role dependencies here

Ansible Modules

Service modules

- service:
   name: nginx
   state: started
   enabled: yes

Install Nginx modules

  - name: ensure nginx is at the latest version
    apt: name=nginx state=latest
  - name: start nginx
     name: nginx
     state: started

Ansible shell

- shell: apt-get install nginx -y

script module

- script: /home/huupv/
    creates: /path/file # skip if this exists
    removes: /path/file # skip if this is missing
    chdir: /path # cd here before running

Keep reading. I will update you later! Thank you for reading the DevopsRoles page!