Restarting HTTPD service is not idempotence in nature and also consume more resources suggest a way to rectify this challenge in Ansible playbook?

Well,

We can use any service in Ansible playbook. Using Ansible playbook is the easiest way to get the HTTPD

Code:- use the below playbook to run and check using httpd through ansible….

hosts: HOST_NAME
vars:
- port: "8080"
tasks:
- name: Add EPEl repo
yum_repository:
name: epel
description: EPEL YUM repo
baseurl: https://download.fedoraproject.org/pub/epel/$releasever/$basearch/
- name: Install httpd
package:
name: "httpd"
state: present
- name: Copying conf file
template:
dest: "/etc/httpd/conf.d/myhttpd.conf"
src: "myhttpd.conf"
notify:
- changed
- name: Adding rule for http
firewalld:
port: "{{ port }}/tcp"
state: enabled
permanent: yes
immediate: yes
- name: Staring httpd service
service:
name: httpd
state: started
handlers:
- name: changed
service:
name: "httpd"
state: restarted
enabled: yes

Create a Hadoop Cluster Using Ansible

Cluster Using Name Node-


- hosts: 192.168.0.187
tasks:
- name:
copy:
src: hadoop-1.2.1–1.x86_64.rpm
dest: /root/hadoop-1.2.1–1.x86_64.rpm
- name:
copy:
src: jdk-8u171-linux-x64.rpm
dest: /root/jdk-8u171-linux-x64.rpm
- name: Install package
command: rpm -i hadoop-1.2.1–1.x86_64.rpm — force
args:
warn: false
register: package_installed
failed_when: false
changed_when: package_installed.rc != 0
- name: install package
command: rpm -i jdk-8u171-linux-x64.rpm
args:
warn: false
register: package_installed
failed_when: false
changed_when: package_installed.rc != 0
- copy:
dest: “/etc/hadoop/hdfs-site.xml”
src: “hdfs-site.xml”
- copy:
dest: “/etc/hadoop/core-site.xml”
src: “core-site.xml”
- file:
state: directory
path: “/nn”
- name: Formating namenode dir
command: echo Y | hadoop namenode -format
- name: starting services
command: hadoop-daemon.sh start namenode

cluster for datanode


- hosts: 192.168.0.187
tasks:
- name:
copy:
src: hadoop-1.2.1–1.x86_64.rpm
dest: /root/hadoop-1.2.1–1.x86_64.rpm
- name:
copy:
src: jdk-8u171-linux-x64.rpm
dest: /root/jdk-8u171-linux-x64.rpm
- name: Install package
command: rpm -i hadoop-1.2.1–1.x86_64.rpm — force
args:
warn: false
register: package_installed
failed_when: false
changed_when: package_installed.rc != 0
- name: install package
command: rpm -i jdk-8u171-linux-x64.rpm
args:
warn: false
register: package_installed
failed_when: false
changed_when: package_installed.rc != 0
- copy:
dest: “/etc/hadoop/hdfs-site.xml”
src: “hdfs-site.xml”
- copy:
dest: “/etc/hadoop/core-site.xml”
src: “core-site.xml”
- file:
state: directory
path: “/dn”
- name: starting services
command: hadoop-daemon.sh start datanode

This commands will help to configure Hadoop and start cluster services using ansible playbook…….

Why ansible?

Ansible lets you quickly and easily deploy multitier apps. You won’t need to write custom code to automate your systems; you list the tasks required to be done by writing a playbook, and Ansible will figure out how to get your systems to the state you want them to be in.

where the ansible used in?

  • We have data on 8,805 companies that use Ansible. The companies using Ansible are most often found in United States and in the Computer Software industry. Ansible is most often used by companies with 50–200 employees and 10M-50M dollars in revenue. Our data for Ansible usage goes back as far as 3 years and 5 months.
  • Ansible seamlessly unites workflow orchestration with configuration management, provisioning, and application deployment in one easy-to-use and deploy platform.

Uses of Ansible

The use cases of Ansible are listed below

  • Infrastructure Provisioning
  • Configuration Management
  • IT automation
  • Continuous deployment
  • Application Development
  • Network Automation
  • Security Automation
  • Infrastructure Orchestration

Top 10 benefits of using Ansible

  1. Agentless –There are no agents or software deployed on the clients/servers to work with Ansible. The connection can be done through the SSH or using the Python.
  2. English Like Language — To use the Ansible, configure, and deploy the infrastructure is very simple and it is English like the language used called YAML.
  3. Modular — The Ansible uses modules to automate, configure, deploy, and orchestrate the IT Infrastructure. There are around 750 + modules built-in Ansible.
  4. Efficient — There are no servers, daemons, or databases required for Ansible to work.
  5. Features — Ansible comes with a whole lot of features and can be used to manage the Operating systems, IT Infrastructure, the networks, the servers, and services in very less time.
  6. Secure and consistent — Since the Ansible uses SSH and Python it is very secure and the operations are flawless.
  7. Reliable — The Ansible Playbook can be used to write programs or the modules and can be used to manage the IT without any downside.
  8. Performance- The Ansible’s performance is excellent and has very little latency.
  9. Low Overhead — As it is agentless and does not require any servers, daemons, or databases it can provide a lot of space in the systems and has low overhead in terms of deployment.
  10. Simple — It is very simple to use and is supported by YAML

What Ansible Can Do?

  • Configuration Management — The enterprise hardware and software information is recorded and updated in detail, thus maintaining the consistency of the product performance.
  • Application Deployment — The applications can be managed in Ansible from Development to Production when you define and manage the applications using Ansible.
  • Orchestration — To manage as a whole and how the configurations interact.
  • Security and Compliance — Wide security policy can be deployed across the infrastructure when the policy is defined in Ansible
  • Provisioning — Helps to automate and manage the process

--

--

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