Skip to content

Commit

Permalink
Adding tests for testing deduplication of values macro changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Matos committed May 7, 2021
1 parent 7a83a5e commit 43eb263
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 7 deletions.
@@ -0,0 +1,13 @@
#!/bin/bash

# variables = var_accounts_tmout=700

sed -i "/.*TMOUT.*/d" /etc/profile.d/*.sh

if grep -q "TMOUT" /etc/profile; then
sed -i "s/.*TMOUT.*/TMOUT=700/" /etc/profile
echo "TMOUT=800" >> /etc/profile.d/tmout.sh
else
echo "TMOUT=700" >> /etc/profile
echo "TMOUT=800" >> /etc/profile.d/tmout.sh
fi
@@ -0,0 +1,13 @@
#!/bin/bash

# variables = var_accounts_tmout=700

sed -i "/.*TMOUT.*/d" /etc/profile

if grep -q "TMOUT" /etc/profile.d/tmout.sh; then
sed -i "s/.*TMOUT.*/TMOUT=700/" /etc/profile.d/tmout.sh
echo "TMOUT=800" >> /etc/profile.d/tmout.sh
else
echo "TMOUT=700" >> /etc/profile.d/tmout.sh
echo "TMOUT=800" >> /etc/profile.d/tmout.sh
fi
Expand Up @@ -2,10 +2,14 @@

# variables = var_accounts_tmout=900

TEST_FILE=/etc/profile.d/tmout.sh

sed -i "/.*TMOUT.*/d" /etc/profile

if grep -q "TMOUT" /etc/profile.d/tmout.sh; then
sed -i "s/.*TMOUT.*/TMOUT=950; readonly TMOUT; export TMOUT/" /etc/profile.d/tmout.sh
test -f $TEST_FILE || touch $TEST_FILE

if grep -q "TMOUT" $TEST_FILE; then
sed -i "s/.*TMOUT.*/TMOUT=950; readonly TMOUT; export TMOUT/" $TEST_FILE
else
echo "TMOUT=950; readonly TMOUT; export TMOUT" >> /etc/profile.d/tmout.sh
echo "TMOUT=950; readonly TMOUT; export TMOUT" >> $TEST_FILE
fi
Expand Up @@ -2,10 +2,14 @@

# variables = var_accounts_tmout=900

TEST_FILE=/etc/profile.d/tmout.sh

sed -i "/.*TMOUT.*/d" /etc/profile

if grep -q "^TMOUT" /etc/profile.d/tmout.sh; then
sed -i "s/^TMOUT.*/TMOUT=950/" /etc/profile.d/tmout.sh
test -f $TEST_FILE || touch $TEST_FILE

if grep -q "^TMOUT" $TEST_FILE; then
sed -i "s/^TMOUT.*/TMOUT=950/" $TEST_FILE
else
echo "TMOUT=950" >> /etc/profile.d/tmout.sh
echo "TMOUT=950" >> $TEST_FILE
fi
2 changes: 1 addition & 1 deletion shared/macros-ansible.jinja
Expand Up @@ -361,7 +361,7 @@ The following macro remediates one audit watch rule in /etc/audit/audit.rules.
The macro requires following parameters:
- path: path to watch
- permissions: permissions changes to watch for
- key: key to use as identifier.
- key: key to use as identifier
#}}
{{% macro ansible_audit_auditctl_add_watch_rule(path='', permissions='', key='') -%}}
- name: Check if watch rule for {{{ path }}} already exists in /etc/audit/audit.rules
Expand Down

0 comments on commit 43eb263

Please sign in to comment.