How To Make Ansible Role And Integrate them

roles_path= your path
ansible-galaxy role init “name of role you want to give”
 — -
# tasks file for mylb
- name: “Installing haproxy”
yum:
name: “haproxy”
— name: “editing and pasting haproxy file”
template:
src: haproxy.cfg
dest: /etc/haproxy/haproxy.cfg
— name: “starting ha proxy serice”
service:
name: “haproxy”
state: restarted
enabled: yes
— name: “disabling selinux”
ansible.posix.selinux:
policy: targeted
state: permissive
 — -
# tasks file for myweb
- name: “installing http and php”
package:
name:
— httpd
— php
state: present
— name: “putting index.php file in backend server”
copy:
src: index.php
dest: /var/www/html/index.php
— name: “starting haproxy server”
service:
name: httpd
state: started
- hosts: localhost
tasks:
- name:calling mylb role to configure haproxy
include_role:
name: mylb
- hosts: b
tasks:
- name:calling myweb role to configure webserver
include_role:
name: myweb
role running successfully

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Create Google Classrooms using Google Apps Script

On duplicates and persistence

Beginners

Microservices and it’s Architecture

UITextField Obscura

Flask is Heavy? Use Matplotlib and Seaborn in Streamlit

How adopting Agile for a transformational project is helping a large bank to increase efficiency by…

Future of Mobile App Development Technologies

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Gupta Aditya

Gupta Aditya

More from Medium

Automate your SSH logins with this .bat script for your private network.

Using Handlers with Import and Include statements

Copy Multiple Files — Ansible lookup plugin fileglob

How to connect your pc to Gitlab with ssh