ansible elastic repo elk install kibana dashboard

- hosts: all
  user: root
  become: yes
# the way to use privilege
  become_method: sudo
  tasks:
   - name: install elasticsearch rpm key
     rpm_key:
       key: https://artifacts.elastic.co/GPG-KEY-elasticsearch
       state: present
     become: true

   - name: install elasticsearch 6.x rpm repository
     yum_repository:
       name: elasticsearch-6.x
       description: Elasticsearch repository for 6.x packages
       baseurl: https://artifacts.elastic.co/packages/6.x/yum
       gpgcheck: true
       gpgkey: https://artifacts.elastic.co/GPG-KEY-elasticsearch
     become: true
   - name: install java & elasticsearch 6.x
     yum:
       name: "{{ item }}"
       state: present
       update_cache: true
     loop:
       - java-1.7.0-openjdk
       - elasticsearch
     become: true
   - name: elasticsearch is installed
     yum: name=elasticsearch state=installed
   - name: elasticsearch is running and enabled
     service: name=elasticsearch state=started enabled=yes
   - name: kibana is installed
     yum: name=kibana state=installed
   - name: kibana is running and enabled
     service: name=kibana state=started enabled=yes
   - name: logstash is installed
     yum: name=logstash state=installed
   - name: logstash is running and enabled
     service: name=logstash state=started enabled=yes

[root@localhost ~]# ansible-playbook elk.yml 


PLAY [all] ****************************************************************************

TASK [Gathering Facts] ****************************************************************
ok: [192.168.1.7]

TASK [install elasticsearch rpm key] **************************************************
changed: [192.168.1.7]

TASK [install elasticsearch 6.x rpm repository] ***************************************
changed: [192.168.1.7]

TASK [install java & elasticsearch 6.x] ***********************************************
changed: [192.168.1.7] => (item=java-1.7.0-openjdk)
changed: [192.168.1.7] => (item=elasticsearch)
changed: [192.168.1.7] => (item=kibana)
changed: [192.168.1.7] => (item=logstash)

TASK [elasticsearch is installed] *****************************************************
ok: [192.168.1.7]

TASK [elasticsearch is running and enabled] *******************************************
changed: [192.168.1.7]

TASK [kibana is installed] ************************************************************
ok: [192.168.1.7]

TASK [kibana is running and enabled] **************************************************
changed: [192.168.1.7]

TASK [logstash is installed] **********************************************************
ok: [192.168.1.7]

TASK [logstash is running and enabled] ************************************************
changed: [192.168.1.7]

PLAY RECAP ****************************************************************************
192.168.1.7                : ok=10   changed=9    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0 

[root@localhost ~]# 

[root@localhost ~]# service elasticsearch status
● elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2019-09-12 00:26:55 IST; 1min 56s ago
     Docs: http://www.elastic.co
 Main PID: 56507 (java)
    Tasks: 18
   CGroup: /system.slice/elasticsearch.service
           ├─56507 /bin/java -Xms1g -Xmx1g -XX:+UseConcMarkSweepGC -XX:CMSInitiating...
           └─56648 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/...

Sep 12 00:26:55 localhost.localdomain systemd[1]: Started Elasticsearch.
Sep 12 00:26:57 localhost.localdomain elasticsearch[56507]: OpenJDK 64-Bit Server VM...
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost ~]# service kibana start
kibana started
[root@localhost ~]# service kibana status
kibana is running

vim /etc/kibana/kibana.yml

server.port: 5601
server.host: "localhost"
elasticsearch.hosts: "http://localhost:9200"
[root@localhost ~]# service kibana restart
kibana started

root@localhost ~]# service logstash status
Redirecting to /bin/systemctl status logstash.service
● logstash.service - logstash
   Loaded: loaded (/etc/systemd/system/logstash.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2019-09-12 01:15:43 IST; 14s ago
 Main PID: 63218 (java)
    Tasks: 13
   CGroup: /system.slice/logstash.service
           └─63218 /bin/java -Xms1g -Xmx1g -XX:+UseConcMarkSweepGC -XX:CMSInitiating...

Sep 12 01:15:43 localhost.localdomain systemd[1]: Started logstash.
Sep 12 01:15:43 localhost.localdomain logstash[63218]: OpenJDK 64-Bit Server VM war...N
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost ~]#

[root@localhost ~]# curl -X GET http://localhost:9200
{
  "name" : "QQAYUhG",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "AxeI5l0rTqmk6qjInzFPyg",
  "version" : {
    "number" : "6.8.3",
    "build_flavor" : "default",
    "build_type" : "rpm",
    "build_hash" : "0c48c0e",
    "build_date" : "2019-08-29T19:05:24.312154Z",
    "build_snapshot" : false,
    "lucene_version" : "7.7.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}
open kibana ports
[root@localhost ~]# firewall-cmd --permanent --add-port 5601/tcp
success
[root@localhost ~]#  firewall-cmd --reload
success


Comments

Popular posts from this blog

ansible redhat cluster qorum qdevice

PE 3.9.0 on centos 6

gfs2 cluster