This file is indexed.

/usr/share/puppet/modules.available/nanliu-staging/spec/defines/staging_file_spec.rb is in puppet-module-nanliu-staging 1.0.4-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
require 'spec_helper'
describe 'staging::file', :type => :define do

  # forcing a more sane caller_module_name to match real usage.
  let(:facts) { {
    :caller_module_name => 'spec',
    :osfamily           => 'RedHat',
    :staging_http_get   => 'curl',
    :puppetversion      => Puppet.version,
  } }

  describe 'when deploying via puppet' do
    let(:title) { 'sample.tar.gz' }
    let(:params) { { :source => 'puppet:///modules/staging/sample.tar.gz' } }

    it {
      should contain_file('/opt/staging')
      should contain_file('/opt/staging/spec/sample.tar.gz')
      should_not contain_exec('/opt/staging/spec/sample.tar.gz')
    }
  end

  describe 'when deploying via local' do
    let(:title) { 'sample.tar.gz' }
    let(:params) { { :source => '/nfs/sample.tar.gz',
      :target => '/usr/local/sample.tar.gz',
    } }

    it {
      should contain_file('/opt/staging')
      should contain_file('/usr/local/sample.tar.gz')
      should_not contain_exec('/opt/staging/spec/sample.tar.gz')
    }
  end

  describe 'when deploying via Windows local' do
    let(:title) { 'sample.tar.gz' }
    let(:params) { {
      :source => 'S:/nfs/sample.tar.gz',
      :target => '/usr/local/sample.tar.gz',
    } }

    it {
      should contain_file('/opt/staging')
      should contain_file('/usr/local/sample.tar.gz')
      should_not contain_exec('/opt/staging/spec/sample.tar.gz')
    }
  end

  describe 'when deploying via http' do
    let(:title) { 'sample.tar.gz' }
    let(:params) { { :source => 'http://webserver/sample.tar.gz' } }

    it {
      should contain_file('/opt/staging')
      should contain_exec('/opt/staging/spec/sample.tar.gz').with( {
        :command => 'curl  -f -L -o /opt/staging/spec/sample.tar.gz http://webserver/sample.tar.gz',
        :path        => '/usr/local/bin:/usr/bin:/bin',
        :environment => nil,
        :cwd         => '/opt/staging/spec',
        :creates     => '/opt/staging/spec/sample.tar.gz',
        :logoutput   => 'on_failure',
      })
    }
  end

  describe 'when deploying via http with custom curl options' do
    let(:title) { 'sample.tar.gz' }
    let(:params) { {
      :source => 'http://webserver/sample.tar.gz',
      :curl_option => '-b',
    } }

    it {
      should contain_file('/opt/staging')
      should contain_exec('/opt/staging/spec/sample.tar.gz').with( {
        :command => 'curl -b -f -L -o /opt/staging/spec/sample.tar.gz http://webserver/sample.tar.gz',
        :path        => '/usr/local/bin:/usr/bin:/bin',
        :environment => nil,
        :cwd         => '/opt/staging/spec',
        :creates     => '/opt/staging/spec/sample.tar.gz',
        :logoutput   => 'on_failure',
      })
    }
  end

  describe 'when deploying via http with parameters' do
    let(:title) { 'sample.tar.gz' }
    let(:params) { { :source => 'http://webserver/sample.tar.gz',
      :target    => '/usr/local/sample.tar.gz',
      :tries     => '10',
      :try_sleep => '6',
    } }

    it { should contain_file('/opt/staging')
      should contain_exec('/usr/local/sample.tar.gz').with( {
        :command => 'curl  -f -L -o /usr/local/sample.tar.gz http://webserver/sample.tar.gz',
        :path        => '/usr/local/bin:/usr/bin:/bin',
        :environment => nil,
        :cwd         => '/usr/local',
        :creates     => '/usr/local/sample.tar.gz',
        :tries       => '10',
        :try_sleep   => '6',
      })
    }
  end

  describe 'when deploying via https' do
     let(:title) { 'sample.tar.gz' }
     let(:params) { { :source => 'https://webserver/sample.tar.gz' } }

     it { should contain_file('/opt/staging') }
     it { should contain_exec('/opt/staging/spec/sample.tar.gz').with( {
       :command => 'curl  -f -L -o /opt/staging/spec/sample.tar.gz https://webserver/sample.tar.gz',
       :path        => '/usr/local/bin:/usr/bin:/bin',
       :environment => nil,
       :cwd         => '/opt/staging/spec',
       :creates     => '/opt/staging/spec/sample.tar.gz',
       :logoutput   => 'on_failure',
     }) }
  end

  describe 'when deploying via https with parameters' do
    let(:title) { 'sample.tar.gz' }
    let(:params) { { :source => 'https://webserver/sample.tar.gz',
      :username => 'puppet',
      :password => 'puppet',
    } }

    it {
      should contain_file('/opt/staging')
      should contain_exec('/opt/staging/spec/sample.tar.gz').with( {
        :command => 'curl  -f -L -o /opt/staging/spec/sample.tar.gz -u puppet:puppet https://webserver/sample.tar.gz',
        :path        => '/usr/local/bin:/usr/bin:/bin',
        :environment => nil,
        :cwd         => '/opt/staging/spec',
        :creates     => '/opt/staging/spec/sample.tar.gz',
        :logoutput   => 'on_failure',
      })
    }
  end

  describe 'when deploying via ftp' do
    let(:title) { 'sample.tar.gz' }
    let(:params) { { :source => 'ftp://webserver/sample.tar.gz' } }

    it {
      should contain_file('/opt/staging')
      should contain_exec('/opt/staging/spec/sample.tar.gz').with( {
        :command => 'curl  -o /opt/staging/spec/sample.tar.gz ftp://webserver/sample.tar.gz',
        :path        => '/usr/local/bin:/usr/bin:/bin',
        :environment => nil,
        :cwd         => '/opt/staging/spec',
        :creates     => '/opt/staging/spec/sample.tar.gz',
        :logoutput   => 'on_failure',
      })
    }
  end

  describe 'when deploying via ftp with parameters' do
    let(:title) { 'sample.tar.gz' }
    let(:params) { { :source => 'ftp://webserver/sample.tar.gz',
      :username => 'puppet',
      :password => 'puppet',
    } }

    it {
      should contain_file('/opt/staging')
      should contain_exec('/opt/staging/spec/sample.tar.gz').with( {
        :command => 'curl  -o /opt/staging/spec/sample.tar.gz -u puppet:puppet ftp://webserver/sample.tar.gz',
        :path        => '/usr/local/bin:/usr/bin:/bin',
        :environment => nil,
        :cwd         => '/opt/staging/spec',
        :creates     => '/opt/staging/spec/sample.tar.gz',
        :logoutput   => 'on_failure',
      })
    }
  end

end