Installing web servers, database services and such tools are tedious task especially when we have to repeat it over and over again, for example in a test environment.
Here are some useful playbooks that we can use to simplify the process.
These are just simple and portable playbooks. If we want to follow the industry standards, it is easy to create Ansible roles from this code.
Install Nginx
---
- name: Install Nginx
hosts: all
become: yes
tasks:
- name: Install Nginx
apt:
name: nginx
state: present
- name: Start Nginx service
service:
name: nginx
state: started
Install MySQL
---
- name: Install MySQL
hosts: all
become: yes
tasks:
- name: Install MySQL
apt:
name:
- mysql-server
- mysql-client
state: present
- name: Start MySQL service
service:
name: mysql
state: started
Install Apache
---
- name: Install Apache
hosts: all
become: yes
tasks:
- name: Install Apache
apt:
name:
- apache2
- apache2-utils
state: present
- name: Start Apache service
service:
name: apache2
state: started