Fixes for this patchset: - split out elk-openstack-client.yml to match what's done elsewhere Fixes for patchset #11: - split out filebeat into separate role for openstack clients - update README.md to use elk-openstack-client.yml for this purpose - cleanup filebeat.yml.j2 to use correct syntax (no need for " anymore) Fixes for patchset #10: - add SELinux boolean "httpd_can_network_connect" - add libsemanage-python package dependency for booleans Fixes for patchset #9: - fix for RHEL7 clients, we need to specify remote EPEL rpm - RHEL7 clients need rpm_key module to import EPEL GPG key - switch to using uri module instead of curl for checking elasticsearch indices - add python-httplib2 dependency (needed for uri module) - use curl -XPOST instead of PUT for filebeat index template in elasticsearch Fixes from patchset #7 - remove unneeded rpm usage, switch to yum module - add logic to heapsize tuning so systems > 64G of memory will never exceed the 32G recommended heapsize - logic fix for prepopulating local logs into logstash - remove elasticsearch.yml, rpm provides this and we're not customizing it yet Fixes from patchset #6: - use yum repo Ansible module where we can - remove unecessary EPEL installation (only nginx needs it) - disable EPEL repo after installation to avoid OpenStack breakage This adds: (ELK Server) - Automated ELK stack deployment - SSL client generation - Heap size tuning (1/2 of available memory) - Firewall port additions (depending on active or not) - Supports either firewalld or iptables-services - Additional upstream Filebeat Kibana dashboards (ELK Client) - Sets up filebeat with appropriate SSL certificates - utilizes both hostnames and SubjectAltName support (for environments without DNS services). (Usage) ansible-playbook -i hosts install/elk.yml ansible-playbook -i hosts install/elk-client.yml --extra-vars 'elk_server=X.X.X.X' Change-Id: Iee29f985e0bbcdf706ad869f132d4c0f1593a6b6
165 lines
5.1 KiB
YAML
165 lines
5.1 KiB
YAML
---
|
|
#
|
|
# Install/run nginx for browbeat
|
|
#
|
|
|
|
- name: Import EPEL GPG Key
|
|
rpm_key: key=https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7
|
|
state=present
|
|
|
|
- name: Check for EPEL repo
|
|
yum: name=https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
|
|
state=present
|
|
|
|
- name: Install nginx, httpd-tools, httplib2, libsemanage-python
|
|
yum: name={{ item }} state=present
|
|
become: true
|
|
with_items:
|
|
- nginx
|
|
- httpd-tools
|
|
- python-httplib2
|
|
- libsemanage-python
|
|
|
|
# SELinux boolean for nginx
|
|
- name: Apply SELinux boolean httpd_can_network_connect
|
|
seboolean: name=httpd_can_network_connect state=yes persistent=yes
|
|
|
|
# deploy kibana.conf with FQDN
|
|
- name: Setup nginx reverse proxy for kibana
|
|
template:
|
|
src=kibana.conf.j2
|
|
dest=/etc/nginx/conf.d/kibana.conf
|
|
owner=root
|
|
group=root
|
|
mode=0644
|
|
become: true
|
|
register: nginx_needs_restart
|
|
|
|
# deploy basic nginx.conf 8080 vhost
|
|
- name: Setup nginx TCP/8080 vhost for SSL certificate
|
|
copy:
|
|
src=nginx.conf
|
|
dest=/etc/nginx/nginx.conf
|
|
owner=root
|
|
group=root
|
|
mode=0644
|
|
ignore_errors: true
|
|
become: true
|
|
|
|
# start nginx service
|
|
- name: Start nginx service
|
|
command: systemctl start nginx.service
|
|
ignore_errors: true
|
|
when: nginx_needs_restart != 0
|
|
|
|
- name: Set nginx to start on boot
|
|
command: systemctl enable nginx.service
|
|
ignore_errors: true
|
|
|
|
# we need TCP/80 and TCP/8080 open
|
|
# determine firewall status and take action
|
|
# 1) use firewall-cmd if firewalld is utilized
|
|
# 2) insert iptables rule if iptables is used
|
|
|
|
# Firewalld
|
|
- name: Determine if firewalld is in use
|
|
shell: systemctl is-enabled firewalld.service | egrep -qv 'masked|disabled'
|
|
ignore_errors: true
|
|
register: firewalld_in_use
|
|
|
|
- name: Determine if firewalld is active
|
|
shell: systemctl is-active firewalld.service | grep -vq inactive
|
|
ignore_errors: true
|
|
register: firewalld_is_active
|
|
|
|
- name: Determine if TCP/80 is already active
|
|
shell: firewall-cmd --list-ports | egrep -q "^80/tcp"
|
|
ignore_errors: true
|
|
register: firewalld_tcp80_exists
|
|
|
|
# add firewall rule via firewall-cmd
|
|
- name: Add firewall rule for TCP/80 (firewalld)
|
|
command: "{{ item }}"
|
|
with_items:
|
|
- firewall-cmd --zone=public --add-port=80/tcp --permanent
|
|
- firewall-cmd --reload
|
|
ignore_errors: true
|
|
become: true
|
|
when: firewalld_in_use.rc == 0 and firewalld_is_active.rc == 0 and firewalld_tcp80_exists.rc != 0
|
|
|
|
# iptables-services
|
|
- name: check firewall rules for TCP/80 (iptables-services)
|
|
shell: grep "dport 80 \-j ACCEPT" /etc/sysconfig/iptables | wc -l
|
|
ignore_errors: true
|
|
register: iptables_tcp80_exists
|
|
failed_when: iptables_tcp80_exists == 127
|
|
|
|
- name: Add firewall rule for TCP/80 (iptables-services)
|
|
lineinfile:
|
|
dest: /etc/sysconfig/iptables
|
|
line: '-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT'
|
|
regexp: '^INPUT -i lo -j ACCEPT'
|
|
insertbefore: '-A INPUT -i lo -j ACCEPT'
|
|
backup: yes
|
|
when: firewalld_in_use.rc != 0 and firewalld_is_active.rc != 0 and iptables_tcp80_exists.stdout|int == 0
|
|
register: iptables_needs_restart
|
|
|
|
- name: Restart iptables-services for TCP/80 (iptables-services)
|
|
shell: systemctl restart iptables.service
|
|
ignore_errors: true
|
|
when: iptables_needs_restart != 0 and firewalld_in_use.rc != 0 and firewalld_is_active.rc != 0
|
|
|
|
# Firewalld
|
|
- name: Determine if firewalld is in use
|
|
shell: systemctl is-enabled firewalld.service | egrep -qv 'masked|disabled'
|
|
ignore_errors: true
|
|
register: firewalld_in_use
|
|
|
|
- name: Determine if firewalld is active
|
|
shell: systemctl is-active firewalld.service | grep -vq inactive
|
|
ignore_errors: true
|
|
register: firewalld_is_active
|
|
|
|
- name: Determine if TCP/8080 is already active
|
|
shell: firewall-cmd --list-ports | egrep -q "^8080/tcp"
|
|
ignore_errors: true
|
|
register: firewalld_tcp8080_exists
|
|
|
|
# add firewall rule via firewall-cmd
|
|
- name: Add firewall rule for TCP/8080 (firewalld)
|
|
command: "{{ item }}"
|
|
with_items:
|
|
- firewall-cmd --zone=public --add-port=8080/tcp --permanent
|
|
- firewall-cmd --reload
|
|
ignore_errors: true
|
|
become: true
|
|
when: firewalld_in_use.rc == 0 and firewalld_is_active.rc == 0 and firewalld_tcp8080_exists.rc != 0
|
|
|
|
# iptables-services
|
|
- name: check firewall rules for TCP/8080 (iptables-services)
|
|
shell: grep "dport 8080 \-j ACCEPT" /etc/sysconfig/iptables | wc -l
|
|
ignore_errors: true
|
|
register: iptables_tcp8080_exists
|
|
failed_when: iptables_tcp8080_exists == 127
|
|
|
|
- name: Add firewall rule for TCP/8080 (iptables-services)
|
|
lineinfile:
|
|
dest: /etc/sysconfig/iptables
|
|
line: '-A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT'
|
|
regexp: '^INPUT -i lo -j ACCEPT'
|
|
insertbefore: '-A INPUT -i lo -j ACCEPT'
|
|
backup: yes
|
|
when: firewalld_in_use.rc != 0 and firewalld_is_active.rc != 0 and iptables_tcp8080_exists.stdout|int == 0
|
|
register: iptables_needs_restart
|
|
|
|
- name: Restart iptables-services for TCP/8080 (iptables-services)
|
|
shell: systemctl restart iptables.service
|
|
ignore_errors: true
|
|
when: iptables_needs_restart != 0 and firewalld_in_use.rc != 0 and firewalld_is_active.rc != 0
|
|
|
|
- name: Disable EPEL Repo
|
|
ini_file: dest=/etc/yum.repos.d/epel.repo
|
|
section=epel
|
|
option=enabled
|
|
value=0
|