Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird behavior with command tests #48

Open
asciifaceman opened this issue May 24, 2019 · 1 comment
Open

Weird behavior with command tests #48

asciifaceman opened this issue May 24, 2019 · 1 comment

Comments

@asciifaceman
Copy link
Contributor

Ref: goss-org/goss#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
Copy link
Owner

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:

  • Try changing your command to bash -c "ulimit -Sn".
  • The environment variables might not be the same as in your shell session during the Goss execution.
  • degoss could be executing as a user you don't expect.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants