From b27e8dda285adce25299f3a3102ea0a87f8bde65 Mon Sep 17 00:00:00 2001 From: James Tombleson Date: Fri, 26 Apr 2019 16:01:55 -0700 Subject: [PATCH] Moved Kibana to a role Untested but should be moved over. --- playbook/linux/elastic/config-kibana.yml | 3 +- playbook/linux/elastic/role-test.yml | 10 ++++++ roles/kibana/defaults/main.yml | 24 ++++++++++++++ roles/kibana/tasks/ubuntu.yml | 42 ++++++++++++++++++++++++ roles/kibana/templates/kibana.j2 | 8 ++--- 5 files changed, 81 insertions(+), 6 deletions(-) create mode 100644 roles/kibana/tasks/ubuntu.yml diff --git a/playbook/linux/elastic/config-kibana.yml b/playbook/linux/elastic/config-kibana.yml index e507c78..49c8c58 100644 --- a/playbook/linux/elastic/config-kibana.yml +++ b/playbook/linux/elastic/config-kibana.yml @@ -19,5 +19,4 @@ - name: systemd - restart Kibana become: true systemd: - name: kibana - state: restarted + name: kiband diff --git a/playbook/linux/elastic/role-test.yml b/playbook/linux/elastic/role-test.yml index 68fb5bc..aff8c2d 100644 --- a/playbook/linux/elastic/role-test.yml +++ b/playbook/linux/elastic/role-test.yml @@ -13,3 +13,13 @@ systemd_enabled: true systemd_restart: true + - name: install kibana + import_role: + name: kibana + vars: + server_port: 5601 + server_host: ansible_default_ipv4.address + server_name: ansible_hostname + elasticsearch_hosts: + - http://192.168.0.173:9200 + diff --git a/roles/kibana/defaults/main.yml b/roles/kibana/defaults/main.yml index a3854d0..15e4a89 100644 --- a/roles/kibana/defaults/main.yml +++ b/roles/kibana/defaults/main.yml @@ -8,8 +8,32 @@ # Role variables # +# Allow 5601 though UFW +ufw_server_port: false +# systemd - enable Kibana on startup +systemd_enabled: false + +# systemd - restart Kibana +systemd_restart: false # # Configuration file variables # + +# Defines that port that Kibana will listen on +# Default: 5601 +server_port: 5601 + +# Specifies the address to which the Kibana server will bind. IP addresses and host names are both valid values. +# The default is 'localhost', which usually means remote machines will not be able to connect. +# To allow connections from remote users, set this parameter to a non-loopback address. +server_host: localhost + +# The Kibana server's name. This is used for display purposes. +server_name: {{ ansible_hostname }} + +# The URLs of the Elasticsearch instances to use for all your queries. +elasticsearch_hosts: + - localhost + - server02 diff --git a/roles/kibana/tasks/ubuntu.yml b/roles/kibana/tasks/ubuntu.yml new file mode 100644 index 0000000..6086ed5 --- /dev/null +++ b/roles/kibana/tasks/ubuntu.yml @@ -0,0 +1,42 @@ + +# This handles the install and configuration for ubuntu based computers. + +- name: Install Elastic Repo + include: install-repo.yml + +- name: Intall Kibana from APT + become: true + apt: + name: kibana + +- name: Update Kibana config from template + become: true + template: + src: kibana.j2 + dest: /etc/kibana/kibana.yml + backup: true + +- name: Allow 5601 though UFW + when: ufw_server_port == true_ + become: true + ufw: + rule: allow + port: server_port + +- name: systemd - daemon reload + become: true + systemd: + daemon_reload: yes + +- name: systemd - enable Kibana on startup + when: systemd_enabled == true + become: true + systemd: + name: kibana + enabled: yes + +- name: systemd - restart Kibana + when: systemd_restart == true + become: true + systemd: + name: kiband diff --git a/roles/kibana/templates/kibana.j2 b/roles/kibana/templates/kibana.j2 index 234a051..ee09b97 100644 --- a/roles/kibana/templates/kibana.j2 +++ b/roles/kibana/templates/kibana.j2 @@ -1,14 +1,14 @@ # Kibana is served by a back end server. This setting specifies the port to use. #server.port: 5601 -server.port: {{ k_server_port }} +server.port: {{ server_port }} # Specifies the address to which the Kibana server will bind. IP addresses and host names are both valid values. # The default is 'localhost', which usually means remote machines will not be able to connect. # To allow connections from remote users, set this parameter to a non-loopback address. #server.host: "192.168.0.173" -server.host: {{ ansible_default_ipv4.address }} +server.host: {{ server_host }} # Enables you to specify a path to mount Kibana at if you are running behind a proxy. # Use the `server.rewriteBasePath` setting to tell Kibana if it should remove the basePath @@ -26,12 +26,12 @@ server.host: {{ ansible_default_ipv4.address }} #server.maxPayloadBytes: 1048576 # The Kibana server's name. This is used for display purposes. -server.name: {{ ansible_hostname }} +server.name: {{ server_name }} # The URLs of the Elasticsearch instances to use for all your queries. #elasticsearch.hosts: ["http://localhost:9200"] elasticsearch.hosts: [ - {{ k_elasticsearch_hosts }} + {{ elasticsearch_hosts }} ] # When this setting's value is true Kibana uses the hostname specified in the server.host