0

My Puppet class looks like this:

class aoa_agent_installation::splunk_install {
    $sourcefile = $osfamily ? {
        'Solaris' => 'puppet:///modules/aoa_agent_installation/splunkforwarder-6.5.2-67571ef4b87d-SunOS-sparc.tar.Z',
        'RedHat' => 'puppet:///modules/aoa_agent_installation/splunkforwarder-6.5.2-67571ef4b87d-Linux-x86_64.tgz',
        'AIX' => 'puppet:///modules/aoa_agent_installation/splunkforwarder-6.5.2-67571ef4b87d-AIX-powerpc.tgz',
    }

    $dirname = 'splunkforwarder'
    $filename = "${dirname}.tar.gz"
    $install_path = "/opt/${dirname}"

    file { $install_path:
        ensure => directory,
        owner  => 'findev',
        group  => 'finacle',
        mode   => '0777',
    }

    archive { $filename:
        path         => "/tmp/${filename}",
        source       => $sourcefile,
        extract      => true,
        extract_path => '/opt',
        creates      => "${install_path}",
        cleanup      => true,
        user         => 'findev',
        group        => 'finacle',
        require      => File[$install_path],
    }

    exec {'start_splunk_service':
        path        => '/usr/bin:/bin:/usr/sbin:/sbin',
        user        => 'findev',
        command     => '/opt/splunkforwarder/bin/splunk start --accept-license && echo "1" > /tmp/splunk_status.txt',
        onlyif      => [ 
            "test -f /opt/splunkforwarder/bin/splunk",
            "test `ps -ef | grep -v grep | grep splunk | wc -l` -eq 0",
            ],
        environment => ["HOME=/app/finacle"],
        require     => Archive[$filename],
    }

    file { '/opt/splunkforwarder/etc/system/local/deploymentclient.conf': 
        ensure  => present,
        owner   => 'findev',
        group   => 'finacle',
        mode    => "0777",
        source  => 'puppet:///modules/aoa_agent_installation/deploymentclient.conf',
        require => Archive[$filename],
    }

    exec {'restart_start_splunk_service':
        path        => '/usr/bin:/bin:/usr/sbin:/sbin',
        user        => 'findev',
        command     => '/opt/splunkforwarder/bin/splunk restart && echo "0" > /tmp/splunk_status.txt',
        onlyif      => [ 
            "test -f /opt/splunkforwarder/bin/splunk",
            "test `cat /tmp/splunk_status.txt | tr -s ' '` -eq 1",
            ],
        environment => ["HOME=/app/finacle"],
        require     => File['/opt/splunkforwarder/etc/system/local/deploymentclient.conf'],
    }
}

I am getting the below error:

Error : Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Invalid relationship: Exec[start_splunk_service] { require => Archive[/tmp/${filename}] }, because Archive[/tmp/${filename}] doesn't seem to be in the catalog

Matthew Schuchard
  • 25,172
  • 3
  • 47
  • 67
Rohith
  • 1,077
  • 5
  • 16
  • 36
  • It is not possible for that error to occur given the manifest you have shown above. However, you can possibly bypass this anyway by removing the use of hardcoded variables from your manifest, since that is not good code style and seems to be related to your issue. – Matthew Schuchard Jun 29 '17 at 17:29
  • I concur that the error message you present does not correspond to the code you present, but myself, I don't see a problem with using hardcoded variables to DRY out your code a bit. Nevertheless, you should consider pulling these out as class parameters. In any case, it's hard to help when we have to speculate about what the problem is. – John Bollinger Jun 29 '17 at 22:00
  • I just compiled the above code and it causes no such error, as noted already. – Alex Harvey Jun 30 '17 at 13:53

0 Answers0