Skip to content

Instantly share code, notes, and snippets.

@ryan-lane
Created January 22, 2015 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryan-lane/1942ca62c3e074d58fdf to your computer and use it in GitHub Desktop.
Save ryan-lane/1942ca62c3e074d58fdf to your computer and use it in GitHub Desktop.
#grep maxlogins /etc/security/limits.conf /etc/security/limits.d/*
mycommand to be run:
- cmd
- run
@ilikeitsalty
Copy link

so this is what I am doing:

# blah blah disclosure 
# Procedure:
#grep maxlogins /etc/security/limits.conf /etc/security/limits.d/*
# blah blah more stuff here

{% if not 0  == salt['cmd.retcode']('grep "'"^[^#].*maxlogins"'" /etc/security/limits.conf /etc/security/limits.d/* > /dev/null 2>&1') %}
add_security_limits:
  cmd.run:
    - names:
      - 'echo "#Configured to meet V-22298" >> /etc/security/limits.d/V-22298.conf'
      - 'echo "* hard maxlogins 10" >> /etc/security/limits.d/V-22298.conf'
{% endif %}

So it runs fine. But when I add the tombstone I see this in the output:

[ERROR ] Command 'grep "^[^#].maxlogins" /etc/security/limits.conf /etc/security/limits.d/ > /dev/null 2>&1' failed with return code: 2
[ERROR ] output:

it still runs fine, but I see the error. Otherwise I just see info stuff, which is what I would expect even with the tombstone.

thought?

@ryan-lane
Copy link
Author

add_security_limits:
  cmd.run:
    - names:
      - 'echo "#Configured to meet V-22298" >> /etc/security/limits.d/V-22298.conf'
      - 'echo "* hard maxlogins 10" >> /etc/security/limits.d/V-22298.conf'
    - unless: grep '^[^#].*maxlogins' /etc/security/limits.conf /etc/security/limits.d/*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment