From 5126dbc5e8fe7364e7b3a2c30e66c132e3966108 Mon Sep 17 00:00:00 2001 From: Michael Russell Date: Wed, 2 Jan 2019 10:06:47 +0100 Subject: [PATCH] Actually remove the unused RedHat repository --- tasks/elasticsearch-RedHat.yml | 6 ++--- .../helpers/serverspec/shared_spec.rb | 25 +++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/tasks/elasticsearch-RedHat.yml b/tasks/elasticsearch-RedHat.yml index 190adc3..c872fc3 100644 --- a/tasks/elasticsearch-RedHat.yml +++ b/tasks/elasticsearch-RedHat.yml @@ -20,9 +20,9 @@ - name: RedHat - remove unused Elasticsearch repo become: yes - template: - src: 'elasticsearch.repo' - dest: '/etc/yum.repos.d/elasticsearch-{{ es_other_repo_name }}.repo' + file: + path: '/etc/yum.repos.d/elasticsearch-{{ es_other_repo_name }}.repo' + state: absent when: es_use_repository - name: RedHat - include versionlock diff --git a/test/integration/helpers/serverspec/shared_spec.rb b/test/integration/helpers/serverspec/shared_spec.rb index d707cde..eca6682 100644 --- a/test/integration/helpers/serverspec/shared_spec.rb +++ b/test/integration/helpers/serverspec/shared_spec.rb @@ -167,4 +167,29 @@ shared_examples 'shared::init' do |vars| its(:content) { should match "path.data: #{vars['data_dirs'].join(',')}" } its(:content) { should match "path.logs: /var/log/elasticsearch/localhost-#{vars['es_instance_name']}" } end + + if vars['es_use_repository'] + if vars['ansible_os_family'] == 'RedHat' + describe file("/etc/yum.repos.d/elasticsearch-#{vars['es_repo_name']}.repo") do + it { should exist } + end + describe yumrepo("elasticsearch-#{vars['es_repo_name']}") do + it { should exist } + it { should be_enabled } + end + describe file("/etc/yum.repos.d/elasticsearch-#{vars['es_other_repo_name']}.repo") do + it { should_not exist } + end + describe yumrepo("elasticsearch-#{vars['es_other_repo_name']}") do + it { should_not exist } + it { should_not be_enabled } + end + end + if vars['ansible_os_family'] == 'Debian' + describe command('apt-cache policy') do + its(:stdout) { should match /elastic.co.*\/#{Regexp.quote(vars['es_repo_name'])}\//} + its(:stdout) { should_not match /elastic.co.*\/#{Regexp.quote(vars['es_other_repo_name'])}\//} + end + end + end end