fix(archive): add config file to service only if defined
This commit is contained in:
		
							parent
							
								
									a5d4d03f8d
								
							
						
					
					
						commit
						a5b44c812b
					
				@ -103,7 +103,7 @@ prometheus-archive-install-{{ name }}-managed-service:
 | 
			
		||||
        group: {{ name }}
 | 
			
		||||
        workdir: {{ p.dir.var }}/{{ name }}
 | 
			
		||||
        stop: ''
 | 
			
		||||
               {%- if name in ('node_exporter', 'consul_exporter') %}
 | 
			
		||||
               {%- if name in ('node_exporter', 'consul_exporter') or 'config_file' not in p.pkg.component[name] %}
 | 
			
		||||
        start: {{ p.pkg.component[name]['path'] }}/{{ name }}
 | 
			
		||||
               {%- else %}
 | 
			
		||||
        start: {{ p.pkg.component[name]['path'] }}/{{ name }} --config.file {{ p.pkg.component[name]['config_file'] }}  # noqa 204
 | 
			
		||||
 | 
			
		||||
@ -7,9 +7,11 @@ control 'prometheus components' do
 | 
			
		||||
  when 'debian'
 | 
			
		||||
    service_dir = '/lib/systemd/system'
 | 
			
		||||
    alert_manager_service = 'prometheus-alertmanager'
 | 
			
		||||
    node_exporter_service = 'prometheus-node-exporter'
 | 
			
		||||
  else
 | 
			
		||||
    service_dir = '/usr/lib/systemd/system'
 | 
			
		||||
    alert_manager_service = 'alertmanager'
 | 
			
		||||
    node_exporter_service = 'node_exporter'
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # describe package('cron') do
 | 
			
		||||
@ -82,7 +84,7 @@ control 'prometheus components' do
 | 
			
		||||
    it { should exist }
 | 
			
		||||
    its('group') { should eq 'node_exporter' }
 | 
			
		||||
  end
 | 
			
		||||
  describe file("#{service_dir}/node_exporter.service") do
 | 
			
		||||
  describe file("#{service_dir}/#{node_exporter_service}.service") do
 | 
			
		||||
    it { should exist }
 | 
			
		||||
    its('group') { should eq 'root' }
 | 
			
		||||
    its('mode') { should cmp '0644' }
 | 
			
		||||
 | 
			
		||||
@ -1,39 +1,31 @@
 | 
			
		||||
# frozen_string_literal: true
 | 
			
		||||
 | 
			
		||||
control 'services with a consistent service name across distros' do
 | 
			
		||||
  title 'should be running'
 | 
			
		||||
 | 
			
		||||
  # we forced node_exporter's service name to `node_exporter` in the pillar,
 | 
			
		||||
  # so its name will be the same across distros for this test
 | 
			
		||||
  describe service('node_exporter') do
 | 
			
		||||
    it { should be_enabled }
 | 
			
		||||
    it { should be_running }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # node_exporter port
 | 
			
		||||
  describe port(9100) do
 | 
			
		||||
    it { should be_listening }
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
control 'services with a consistent service name on each distro' do
 | 
			
		||||
  title 'should be running'
 | 
			
		||||
 | 
			
		||||
  # if we don't set a service name in the pillar,
 | 
			
		||||
  # its name will be the same on each distro, no matter what the
 | 
			
		||||
  # install method we choose
 | 
			
		||||
 | 
			
		||||
  distro_service =
 | 
			
		||||
  distro_services =
 | 
			
		||||
    case platform[:family]
 | 
			
		||||
    when 'debian'
 | 
			
		||||
      'prometheus-blackbox-exporter'
 | 
			
		||||
      %w[
 | 
			
		||||
        prometheus
 | 
			
		||||
        prometheus-alertmanager
 | 
			
		||||
        prometheus-node-exporter
 | 
			
		||||
        prometheus-blackbox-exporter
 | 
			
		||||
      ]
 | 
			
		||||
    else
 | 
			
		||||
      'blackbox_exporter'
 | 
			
		||||
      %w[
 | 
			
		||||
        prometheus
 | 
			
		||||
        alertmanager
 | 
			
		||||
        node_exporter
 | 
			
		||||
        blackbox_exporter
 | 
			
		||||
      ]
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
  describe service(distro_service) do
 | 
			
		||||
    it { should be_enabled }
 | 
			
		||||
    it { should be_running }
 | 
			
		||||
  distro_services.each do |service|
 | 
			
		||||
    describe service(service) do
 | 
			
		||||
      it { should be_enabled }
 | 
			
		||||
      it { should be_running }
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # blackbox_exporter port
 | 
			
		||||
 | 
			
		||||
@ -81,15 +81,6 @@ prometheus:
 | 
			
		||||
              email_configs:
 | 
			
		||||
                - to: 'team-X+alerts@example.org'
 | 
			
		||||
 | 
			
		||||
          inhibit_rules:
 | 
			
		||||
            - name: opsGenie-receiver
 | 
			
		||||
              opsgenie_configs:
 | 
			
		||||
                - api_key: mysecret
 | 
			
		||||
            - name: slack-receiver
 | 
			
		||||
              slack_configs:
 | 
			
		||||
                - channel: '#my-channel'
 | 
			
		||||
                  image_url: 'http://some.img.com/img.png'
 | 
			
		||||
 | 
			
		||||
      node_exporter:
 | 
			
		||||
        version: v0.18.1
 | 
			
		||||
        archive:
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user