Search code examples
pythonrspecansibletest-kitchen

Ansible kitchen test fails executing source command on debian


I wrote a ansible playbook role for python and trying to test it using kitchen test with Serverspec/RSpec. The following test is making sure if I am able source activate the virtualenv. This runs fine on CentOS but test fails on Debian-Ubuntu with an error (check below the code block)

  describe command("source #{jenkins_home}/virtualenv/#{version}/bin/activate") do
    its(:exit_status) { should eq 0 }
  end

Error:

 6) Command "source /home/jenkins/virtualenv/pypy3/bin/activate" exit_status should eq 0
    Failure/Error: its(:exit_status) { should eq 0 }

      expected: 0
           got: 127

      (compared using ==)
      /bin/sh -c source\ /home/jenkins/virtualenv/pypy3/bin/activate

    # /tmp/verifier/suites/serverspec/python_spec.rb:22:in `block (3 levels) in <top (required)>'

MY ASSUMPTION

Its trying to run from /bin/sh which basically cant run source command. How can I mitigate this problem?


Solution

  • Can you change the call from source to .? That should work in both bash and sh.