Skip to content

Commit 750356c

Browse files
authored
Merge branch 'main' into fix/graceful-elasticsearch
2 parents 6929260 + 68a6ad6 commit 750356c

File tree

22 files changed

+180
-241
lines changed

22 files changed

+180
-241
lines changed

.github/workflows/kics.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
name: KICS Security Scan
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
logLevel:
7+
description: 'Log level'
8+
required: true
9+
default: 'warning'
10+
type: choice
11+
options:
12+
- info
13+
- warning
14+
- debug
15+
pull_request:
16+
push:
17+
branches:
18+
- 'main'
19+
merge_group:
20+
schedule:
21+
- cron: '15 6 * * 4'
22+
jobs:
23+
kics:
24+
runs-on: ubuntu-latest
25+
26+
steps:
27+
- uses: actions/checkout@v4
28+
- name: Mkdir results-dir
29+
# make sure results dir is created
30+
run: mkdir -p results-dir
31+
- name: run kics Scan
32+
uses: Checkmarx/kics-github-action@5a6152ef88416063435cebadfec9de28bcfd041d # v2.1.4
33+
with:
34+
# path: 'roles,plugins'
35+
path: '.'
36+
# fail_on: high
37+
ignore_on_exit: results
38+
output_formats: 'json,sarif'
39+
output_path: results-dir
40+
- name: Upload SARIF file
41+
uses: github/codeql-action/upload-sarif@af56b044b5d41c317aef5d19920b3183cb4fbbec # v3
42+
with:
43+
sarif_file: results-dir/results.sarif

docs/role-elasticsearch.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Role Variables
1515
* *elasticsearch_node_types*: List of types of this very node. Please refer to [official docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-node.html) for details. (default: not set. allowed value: array of types)
1616
+ *elasticsearch_nodename*': Node name of the Elasticsearch node. (default: value of `ansible_hostname`)
1717
* *elasticsearch_clustername*: Name the Elasticsearch Cluster (default: `elasticsearch`)
18-
* *elasticsearch_heap*: Heapsize for Elasticsearch. (Half of free memory on host. Maximum 30GB. (default: Half of hosts memory. Min 1GB, Max 30GB)
18+
* *elasticsearch_heap*: Heapsize for Elasticsearch. Set to `false` to follow Elastic recommendations for elasticsearch 8.x (default: Half of hosts memory. Min 1GB, Max 30GB)
1919
* *elasticsearch_tls_key_passphrase*: Passphrase for elasticsearch certificates (default: `PleaseChangeMeIndividually`)
2020
* *elasticsearch_cert_validity_period*: number of days that the generated certificates are valid (default: 1095).
2121
* *elasticsearch_cert_expiration_buffer*: Ansible will renew the elasticsearch certificate if its validity is shorter than this value, which should be number of days. (default: 30)

molecule/elasticsearch_no-security/verify.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
tasks:
1010

1111
# Remember, this is the no-security scenario. So no https
12+
# The comment below will create an exception for KICS security scan
1213
- name: Health check
1314
ansible.builtin.uri:
15+
# kics-scan ignore-line
1416
url: http://localhost:{{ elasticstack_elasticsearch_http_port }}/_cluster/health
1517
method: GET
1618
return_content: yes
@@ -24,6 +26,7 @@
2426

2527
- name: Node check
2628
ansible.builtin.uri:
29+
# kics-scan ignore-line
2730
url: http://localhost:{{ elasticstack_elasticsearch_http_port }}/_cat/nodes
2831
method: GET
2932
return_content: yes

molecule/elasticsearch_test_modules/converge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
netways.elasticstack.elasticsearch_user:
5151
name: new-user1
5252
fullname: New User
53-
password: changeMe123!
53+
password: "{{ lookup('community.general.random_string', length=12, min_lower=1, min_upper=1, min_numeric=1, min_special=1, override_special='-_=!') }}"
5454
5555
roles:
5656
- new-role1

molecule/elasticstack_default/converge.yml

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@
1818
elasticstack_full_stack: true
1919
elasticstack_no_log: false
2020
logstash_pipeline_unsafe_shutdown: true
21-
logstash_redis_password: "ThisIsMyRedisTest"
21+
logstash_redis_password: "{{ lookup('ansible.builtin.password', '/tmp/redispassword', chars=['ascii_letters'], length=15) }}"
2222
redis_requirepass: "{{ logstash_redis_password }}"
23-
beats_filebeat_syslog_udp: true
24-
beats_filebeat_syslog_tcp: true
23+
beats_filebeat_journald: true
2524
beats_filebeat_modules:
2625
- system
2726
beats_fields:
@@ -51,19 +50,3 @@
5150
- name: Include Beats
5251
ansible.builtin.include_role:
5352
name: beats
54-
- name: Install rsyslog
55-
ansible.builtin.package:
56-
name: rsyslog
57-
- name: Remove cache # noqa: risky-shell-pipe
58-
ansible.builtin.shell: >
59-
if test -n "$(ps -p $$ | grep bash)"; then set -o pipefail; fi;
60-
rm -rf /var/cache/*
61-
changed_when: false
62-
- name: Configure rsyslog
63-
ansible.builtin.lineinfile:
64-
line: "*.* @@localhost:514"
65-
path: /etc/rsyslog.conf
66-
- name: Start rsyslog
67-
ansible.builtin.service:
68-
name: rsyslog
69-
state: started

molecule/elasticstack_default/molecule.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ platforms:
3232
pre_build_image: true
3333
provisioner:
3434
name: ansible
35+
inventory:
36+
host_vars:
37+
elasticstack${ELASTIC_RELEASE}-cluster2-${MOLECULE_DISTRO}:
38+
elasticsearch_tls_key_passphrase: UniqueHostPassword
39+
3540
# Just enable temporarily. Sometimes it's useful, but most of the time it's
3641
# overwhelming
3742
#env:

molecule/elasticstack_default/prepare.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,13 @@
3535
- unzip
3636
- systemd
3737

38+
# KICS complains about packages being updated.
39+
# In this case, a mere test scenario it is OK, though.
40+
3841
- name: Update all installed packages RHEL
3942
ansible.builtin.yum:
4043
name: '*'
44+
# kics-scan ignore-line
4145
state: latest
4246
update_cache: yes
4347
update_only: yes
@@ -46,6 +50,7 @@
4650
- name: Update all installed packages Debian
4751
ansible.builtin.apt:
4852
name: '*'
53+
# kics-scan ignore-line
4954
state: latest
5055
update_cache: yes
5156
when: ansible_os_family == "Debian"

molecule/elasticstack_default/verify.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717
port: 5044
1818
when: "'logstash' in group_names"
1919

20-
- name: Wait for syslog port to open
21-
ansible.builtin.wait_for:
22-
port: 514
23-
2420
- name: Set elasticsearch_ca variable if not already done by user
2521
ansible.builtin.set_fact:
2622
elasticsearch_ca: "{{ groups[elasticstack_elasticsearch_group_name][0] }}"

molecule/logstash_full_stack-oss/converge.yml

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,14 @@
1919
logstash_security: false
2020
logstash_pipeline_unsafe_shutdown: true
2121
elasticstack_security: false
22-
beats_filebeat_syslog_udp: true
23-
beats_filebeat_syslog_tcp: true
22+
beats_filebeat_journald: true
2423
logstash_beats_tls: false
2524
elasticstack_release: 7
2625
elasticstack_no_log: false
2726
tasks:
2827
- name: "Include Elastics repos role"
2928
ansible.builtin.include_role:
3029
name: repos
31-
- name: Install rsyslog
32-
ansible.builtin.package:
33-
name: rsyslog
34-
- name: Start rsyslog
35-
ansible.builtin.service:
36-
name: rsyslog
37-
state: started
3830
- name: "Include Elasticsearch role"
3931
ansible.builtin.include_role:
4032
name: elasticsearch
@@ -47,12 +39,3 @@
4739
- name: "Include Logstash"
4840
ansible.builtin.include_role:
4941
name: logstash
50-
- name: Configure rsyslog
51-
ansible.builtin.lineinfile:
52-
line: "*.* @@localhost:514"
53-
path: /etc/rsyslog.conf
54-
- name: Restart rsyslog
55-
ansible.builtin.service:
56-
name: rsyslog
57-
state: restarted
58-
changed_when: false

molecule/logstash_full_stack-oss/verify.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
- name: Run syntax check
1414
ansible.builtin.command: "/usr/share/logstash/bin/logstash --path.settings=/etc/logstash -t"
1515
when: "'logstash' in group_names"
16-
- name: Check for open port tcp {{ elasticstack_beats_port }}
17-
ansible.builtin.wait_for:
18-
port: "{{ elasticstack_beats_port }}"
19-
when: "'logstash' in group_names"
2016
- name: Query for Logstasch indices
2117
ansible.builtin.shell: >
2218
curl -s http://localhost:{{ elasticstack_elasticsearch_http_port }}/_cat/indices |

0 commit comments

Comments
 (0)