From 556996c435ffd2f5bc914bc206c1d925cf45ccf1 Mon Sep 17 00:00:00 2001 From: Julien Mailleret Date: Tue, 30 Apr 2019 15:47:41 +0200 Subject: [PATCH 1/5] [7.x] add support for beats 7.x --- defaults/main.yml | 2 +- test/integration/standard.yml | 2 +- vars/Debian.yml | 3 ++- vars/RedHat.yml | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 9a87435..1e871b6 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,7 +1,7 @@ --- # defaults file for beats -beats_version: 6.2.4 +beats_version: 7.0.0 version_lock: false use_repository: true start_service: true diff --git a/test/integration/standard.yml b/test/integration/standard.yml index dca29a8..9ac2cdb 100644 --- a/test/integration/standard.yml +++ b/test/integration/standard.yml @@ -2,6 +2,6 @@ - name: wrapper playbook for kitchen testing "beats" hosts: localhost roles: - - { role: "ansible-beats", beat: "filebeat", beat_conf: {"filebeat": {"prospectors":[{"paths":["/var/log/*.log"],"input_type":"log"}],"registry_file": "/var/lib/filebeat/registry"} } } + - { role: "ansible-beats", beat: "filebeat", beat_conf: {"filebeat": {"inputs":[{"paths":["/var/log/*.log"],"type":"log"}]} } } vars: use_repository: "true" \ No newline at end of file diff --git a/vars/Debian.yml b/vars/Debian.yml index 9405f24..5fd0293 100644 --- a/vars/Debian.yml +++ b/vars/Debian.yml @@ -5,4 +5,5 @@ init_script: "/etc/init.d" repo_urls: "1.x": "http://packages.elastic.co/beats/apt" "5.x": "https://artifacts.elastic.co/packages/5.x/apt" - "6.x": "https://artifacts.elastic.co/packages/6.x/apt" \ No newline at end of file + "6.x": "https://artifacts.elastic.co/packages/6.x/apt" + "7.x": "https://artifacts.elastic.co/packages/7.x/apt" \ No newline at end of file diff --git a/vars/RedHat.yml b/vars/RedHat.yml index 63d4abb..da97925 100644 --- a/vars/RedHat.yml +++ b/vars/RedHat.yml @@ -5,4 +5,5 @@ init_script: "/etc/init.d" repo_urls: "1.x": "https://packages.elastic.co/beats/yum/el/$basearch" "5.x": "https://artifacts.elastic.co/packages/5.x/yum" - "6.x": "https://artifacts.elastic.co/packages/6.x/yum" \ No newline at end of file + "6.x": "https://artifacts.elastic.co/packages/6.x/yum" + "7.x": "https://artifacts.elastic.co/packages/7.x/yum" \ No newline at end of file From d3f36186fc090f1357590e651841f7f71402f7f1 Mon Sep 17 00:00:00 2001 From: Julien Mailleret Date: Thu, 2 May 2019 15:08:30 +0200 Subject: [PATCH 2/5] Update README and fix broken test --- README.md | 2 +- test/integration/multi.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 21278f6..93f5a6a 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Supported variables are as follows: - **beat** (*MANDATORY*): Beat product. Supported values are: "filebeat", "metricbeat" & "packetbeat". - **beat_conf** (*MANDATORY*): Beat Configuration. Should be defined as a map (see [Example Playbook](#example-playbook)) -- **beats_version** (*Defaults to `6.2.4`*): Beats version. **Beats 7.x is not yet supported**. +- **beats_version** (*Defaults to `7.0.0`*): Beats version. - **version_lock** (*Defaults to `false`*): Locks the installed version if set to true, thus preventing other processes from updating. This will not impact the roles ability to update the beat on subsequent runs (it unlocks and re-locks if required). - **use_repository** (*Defaults to `true`*): Use elastic repo for yum or apt if true. If false, a custom custom_package_url must be provided. - **start_service** (*Defaults to `true`*): service will be started if true, false otherwise. diff --git a/test/integration/multi.yml b/test/integration/multi.yml index b9ced96..11a3146 100644 --- a/test/integration/multi.yml +++ b/test/integration/multi.yml @@ -2,7 +2,7 @@ - name: wrapper playbook for kitchen testing "beats" hosts: localhost roles: - - { role: "ansible-beats", beat: "filebeat", beat_conf: { "filebeat": {"prospectors":[{"paths":["/var/log/*.log"],"input_type":"log"}], "registry_file": "/var/lib/filebeat/registry"} } } + - { role: "ansible-beats", beat: "filebeat", beat_conf: {"filebeat": {"inputs":[{"paths":["/var/log/*.log"],"type":"log"}]} } } - { role: "ansible-beats", beat: "metricbeat", beat_conf: { "metricbeat.modules": [{"module": "system", "metricsets": ["cpu", "filesystem", "network", "process"], "enabled": true, "period": "10s", "processes":[".*"], "cpu_ticks": false } ] } } vars: use_repository: "true" \ No newline at end of file From 90ce73b6df794f56d08eff837fdb235ecf43b96b Mon Sep 17 00:00:00 2001 From: Julien Mailleret Date: Thu, 2 May 2019 18:15:53 +0200 Subject: [PATCH 3/5] [test] add specific test for beats 6.x --- .kitchen.yml | 7 ++++ test/integration/standard-6x.yml | 8 ++++ .../standard-6x/serverspec/default_spec.rb | 39 +++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 test/integration/standard-6x.yml create mode 100644 test/integration/standard-6x/serverspec/default_spec.rb diff --git a/.kitchen.yml b/.kitchen.yml index 325b2d6..cd35ebf 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -79,6 +79,13 @@ suites: - "." run_list: attributes: + - name: standard-6x + provisioner: + playbook: test/integration/standard-6x.yml + additional_copy_path: + - "." + run_list: + attributes: - name: multi provisioner: playbook: test/integration/multi.yml diff --git a/test/integration/standard-6x.yml b/test/integration/standard-6x.yml new file mode 100644 index 0000000..30d9c33 --- /dev/null +++ b/test/integration/standard-6x.yml @@ -0,0 +1,8 @@ +--- +- name: wrapper playbook for kitchen testing "beats" + hosts: localhost + roles: + - { role: "ansible-beats", beat: "filebeat", beat_conf: {"filebeat": {"prospectors":[{"paths":["/var/log/*.log"],"input_type":"log"}], "registry_file": "/var/lib/filebeat/registry"} } } + vars: + beats_version: 6.7.1 + use_repository: "true" \ No newline at end of file diff --git a/test/integration/standard-6x/serverspec/default_spec.rb b/test/integration/standard-6x/serverspec/default_spec.rb new file mode 100644 index 0000000..2aa1692 --- /dev/null +++ b/test/integration/standard-6x/serverspec/default_spec.rb @@ -0,0 +1,39 @@ +require 'spec_helper' + +describe 'Standard Tests' do + + describe service('filebeat') do + it { should be_running } + end + + describe package('filebeat') do + it { should be_installed } + end + + describe file('/etc/filebeat/filebeat.yml') do + it { should be_file } + it { should be_owned_by 'root' } + end + + describe file('/etc/filebeat/filebeat.yml') do + it { should contain 'filebeat:' } + it { should contain 'logging:' } + it { should contain 'output:' } + end + + describe file('/etc/init.d/filebeat') do + it { should exist } + end + + if os[:family] == 'redhat' + describe command('yum versionlock list | grep filebeat') do + its(:stdout) { should_not match /filebeat/ } + end + elsif ['debian', 'ubuntu'].include?(os[:family]) + describe command('sudo apt-mark showhold | grep filebeat') do + its(:stdout) { should_not match /filebeat/ } + end + end + +end + From 4c8c4dee003f8f96b6b77565406d0bdc1a934690 Mon Sep 17 00:00:00 2001 From: Julien Mailleret Date: Thu, 2 May 2019 18:21:25 +0200 Subject: [PATCH 4/5] [ci] add beats-6.x test in ci job --- test/matrix.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/test/matrix.yml b/test/matrix.yml index 70c8851..2763b4a 100644 --- a/test/matrix.yml +++ b/test/matrix.yml @@ -8,5 +8,6 @@ OS: - centos-7 TEST_TYPE: - standard + - standard-6x - multi - config From 73d6673d878c5ba80fda73f78d21f8e5fad1282f Mon Sep 17 00:00:00 2001 From: Julien Mailleret Date: Fri, 3 May 2019 16:57:50 +0200 Subject: [PATCH 5/5] [beats] remove support for 5.x version --- README.md | 2 +- tasks/beats-debian.yml | 7 +------ tasks/beats-redhat.yml | 5 ----- templates/beats.repo.j2 | 2 +- vars/Debian.yml | 6 +----- vars/RedHat.yml | 6 +----- 6 files changed, 5 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 93f5a6a..b220e2b 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ Dependencies ------------ - Ansible version > 2.0 -- Beats version >= 1.x +- Beats version >= 6.x Example Playbook ---------------- diff --git a/tasks/beats-debian.yml b/tasks/beats-debian.yml index c85aa6f..82a1bef 100644 --- a/tasks/beats-debian.yml +++ b/tasks/beats-debian.yml @@ -1,10 +1,5 @@ --- -- name: "Debian - check that beats {{ beats_major_version }} version exists" - assert: - that: - "repo_urls[beats_major_version] is defined" - - name: Debian - Ensure apt-transport-https is installed apt: name=apt-transport-https state=present cache_valid_time=86400 when: use_repository @@ -16,7 +11,7 @@ when: use_repository - name: Debian - add beats repository - apt_repository: repo="deb {{ repo_urls[beats_major_version] }} stable main" state=present + apt_repository: repo="deb {{ repo_url }} stable main" state=present when: use_repository - name: Debian - unhold {{beat}} version for install diff --git a/tasks/beats-redhat.yml b/tasks/beats-redhat.yml index 825aba2..f79a254 100644 --- a/tasks/beats-redhat.yml +++ b/tasks/beats-redhat.yml @@ -1,10 +1,5 @@ --- -- name: "RedHat - check that beats {{ beats_major_version }} version exists" - assert: - that: - "repo_urls[beats_major_version] is defined" - - name: Ensure libselinux-python on CentOS 6.x yum: name=libselinux-python state=present update_cache=yes when: ( ansible_distribution == "CentOS" ) and ( ansible_distribution_major_version == "6" ) diff --git a/templates/beats.repo.j2 b/templates/beats.repo.j2 index b6f65b0..c89503b 100644 --- a/templates/beats.repo.j2 +++ b/templates/beats.repo.j2 @@ -1,6 +1,6 @@ [beats] name=Elastic Beats Repository -baseurl={{ repo_urls[beats_major_version] }} +baseurl={{ repo_url }} enabled=1 gpgkey=https://packages.elastic.co/GPG-KEY-elasticsearch gpgcheck=1 diff --git a/vars/Debian.yml b/vars/Debian.yml index 5fd0293..819955f 100644 --- a/vars/Debian.yml +++ b/vars/Debian.yml @@ -2,8 +2,4 @@ default_file: "/etc/default" init_script: "/etc/init.d" -repo_urls: - "1.x": "http://packages.elastic.co/beats/apt" - "5.x": "https://artifacts.elastic.co/packages/5.x/apt" - "6.x": "https://artifacts.elastic.co/packages/6.x/apt" - "7.x": "https://artifacts.elastic.co/packages/7.x/apt" \ No newline at end of file +repo_url: "https://artifacts.elastic.co/packages/{{ beats_major_version }}/apt" diff --git a/vars/RedHat.yml b/vars/RedHat.yml index da97925..34a6787 100644 --- a/vars/RedHat.yml +++ b/vars/RedHat.yml @@ -2,8 +2,4 @@ default_file: "/etc/sysconfig" init_script: "/etc/init.d" -repo_urls: - "1.x": "https://packages.elastic.co/beats/yum/el/$basearch" - "5.x": "https://artifacts.elastic.co/packages/5.x/yum" - "6.x": "https://artifacts.elastic.co/packages/6.x/yum" - "7.x": "https://artifacts.elastic.co/packages/7.x/yum" \ No newline at end of file +repo_url: "https://artifacts.elastic.co/packages/{{ beats_major_version }}/yum" \ No newline at end of file