naftulikay / ansible-role-degoss

An Ansible role for installing, running, and removing Goss from a system without leaving any traces.
Other
42 stars 12 forks source link

Weird behavior with command tests #48

Open asciifaceman opened 5 years ago

asciifaceman commented 5 years ago

Ref: https://github.com/aelsabbahy/goss/issues/450

vagrant@devel:~$ goss add command 'ulimit -Hn'
Adding Command to './goss.yaml':

ulimit -Hn:
  exit-status: 0
  stdout:
  - "65535"
  stderr: []
  timeout: 10000

vagrant@devel:~$ goss add command 'ulimit -Sn'
Adding Command to './goss.yaml':

ulimit -Sn:
  exit-status: 0
  stdout:
  - "65535"
  stderr: []
  timeout: 10000

./goss.yml

command:
  ulimit -Hn:
    exit-status: 0
    stdout:
    - "65535"
    stderr: []
    timeout: 10000
  ulimit -Sn:
    exit-status: 0
    stdout:
    - "65535"
    stderr: []
    timeout: 10000
vagrant@devel:~$ goss validate
......

Total Duration: 0.006s
Count: 6, Failed: 0, Skipped: 0

Encapsulated in degoss:

Command: ulimit -Sn: stdout: patterns not found: [65535]

Command: ulimit -Hn: stdout: patterns not found: [65535]
naftulikay commented 5 years ago

So I'm not sure what's actually happening here, but ulimit isn't an executable, it's a built-in to your shell:

$ which ulimit || echo "couldn't find it"
couldn't find it

A number of things:

We'd need to extend the degoss module to add env_vars to be able to set your environment the way you'd expect. I removed environment variables in a previous major release, might have to add them back in for this use case.

I'd try using a become_user on your degoss role if you want a very specific user to execute things:

- name: my play
  roles:
    - role: degoss
      # ...
      become: true
      become_user: doctorstevebrule