generated from linux-system-roles/template
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add larger test which uses more attributes
Signed-off-by: Radovan Sroka <[email protected]>
- Loading branch information
Showing
8 changed files
with
272 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,7 +75,7 @@ | |
cmnd_alias: | ||
- name: PING | ||
commands: | ||
- /bin/ping | ||
- /usr/bin/ping | ||
user_alias: | ||
- name: PINGERS | ||
users: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# | ||
# Ansible managed | ||
# | ||
# system_role:sudo | ||
|
||
|
||
# Default override specifications | ||
Defaults: PINGERS !requiretty | ||
Defaults> root !set_logname | ||
Defaults@ host1, host2 !requiretty, !requiretty | ||
Defaults! /usr/bin/ls !requiretty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# | ||
# Ansible managed | ||
# | ||
# system_role:sudo | ||
|
||
# Default specifications | ||
Defaults syslog=auth | ||
|
||
# Default override specifications | ||
Defaults> root !set_logname |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,230 @@ | ||
--- | ||
- name: Basic test for Sudo | ||
hosts: all | ||
tasks: | ||
- name: Run tests | ||
block: | ||
- name: Run the role | ||
include_role: | ||
name: linux-system-roles.sudo | ||
vars: | ||
sudo_rewrite_default_sudoers_file: true | ||
sudo_remove_unauthorized_included_files: true | ||
sudo_sudoers_files: | ||
- path: /etc/sudoers | ||
defaults: | ||
- "!visiblepw" | ||
- always_set_home | ||
- match_group_by_gid | ||
- always_query_group_plugin | ||
- env_reset | ||
- secure_path: | ||
- /sbin | ||
- /bin | ||
- /usr/sbin | ||
- /usr/bin | ||
- env_keep: | ||
- COLORS | ||
- DISPLAY | ||
- HOSTNAME | ||
- HISTSIZE | ||
- KDEDIR | ||
- LS_COLORS | ||
- PS1 | ||
- PS2 | ||
- QTDIR | ||
- USERNAME | ||
- LANG | ||
- LC_ADDRESS | ||
- LC_CTYPE | ||
- LC_COLLATE | ||
- LC_IDENTIFICATION | ||
- LC_MEASUREMENT | ||
- LC_MESSAGES | ||
- LC_MONETARY | ||
- LC_NAME | ||
- LC_NUMERIC | ||
- LC_PAPER | ||
- LC_TELEPHONE | ||
- LC_TIME | ||
- LC_ALL | ||
- LANGUAGE | ||
- LINGUAS | ||
- _XKB_CHARSET | ||
- XAUTHORITY | ||
user_specifications: | ||
- users: | ||
- root | ||
hosts: | ||
- ALL | ||
operators: | ||
- ALL | ||
commands: | ||
- ALL | ||
- users: | ||
- "%wheel" | ||
hosts: | ||
- ALL | ||
operators: | ||
- ALL | ||
commands: | ||
- ALL | ||
- type: user | ||
defaults: | ||
- "!requiretty" | ||
users: | ||
- PINGERS | ||
- type: runas | ||
defaults: | ||
- "!set_logname" | ||
operators: | ||
- root | ||
- type: host | ||
defaults: | ||
- "!requiretty" | ||
- "!set_logname" | ||
hosts: | ||
- host1 | ||
- host2 | ||
- type: command | ||
defaults: | ||
- "!requiretty" | ||
commands: | ||
- /usr/bin/cd | ||
include_directories: | ||
- /etc/sudoers.d | ||
aliases: | ||
cmnd_alias: | ||
- name: PING | ||
commands: | ||
- /usr/bin/ping | ||
host_alias: | ||
- name: HOST | ||
hosts: | ||
- myhost | ||
user_alias: | ||
- name: PINGERS | ||
users: | ||
- username | ||
runas_alias: | ||
- name: RUNAS | ||
users: | ||
- username | ||
- path: /etc/sudoers.d/pingers | ||
user_specifications: | ||
- type: user | ||
defaults: | ||
- "!requiretty" | ||
users: | ||
- PINGERS | ||
- type: runas | ||
defaults: | ||
- "!set_logname" | ||
operators: | ||
- root | ||
- type: host | ||
defaults: | ||
- "!requiretty" | ||
- "!requiretty" | ||
hosts: | ||
- host1 | ||
- host2 | ||
- type: command | ||
defaults: | ||
- "!requiretty" | ||
commands: | ||
- /usr/bin/ls | ||
- path: /etc/sudoers.d/root | ||
defaults: | ||
- syslog=auth | ||
user_specifications: | ||
- type: runas | ||
defaults: | ||
- "!set_logname" | ||
operators: | ||
- root | ||
|
||
- name: Create temp test directory | ||
tempfile: | ||
path: /var/tmp | ||
prefix: sudo_ | ||
state: directory | ||
register: __sudo_tmpdir | ||
|
||
- name: Backup sudoers | ||
copy: | ||
src: /etc/sudoers | ||
dest: "{{ __sudo_tmpdir.path }}/sudoers" | ||
owner: root | ||
group: root | ||
mode: 0644 | ||
remote_src: true | ||
|
||
- name: Backup sudoers.d | ||
copy: | ||
src: /etc/sudoers.d | ||
dest: "{{ __sudo_tmpdir.path }}/sudoers.d" | ||
owner: root | ||
group: root | ||
mode: 0644 | ||
remote_src: true | ||
|
||
- name: Get stat of tests/files/test_large_configuration_sudoers.ok | ||
delegate_to: localhost | ||
stat: | ||
path: files/test_large_configuration_sudoers.ok | ||
checksum_algorithm: sha256 | ||
register: sudoers_ok | ||
|
||
# sha256sum ./files/test_large_configuration_sudoers.ok | ||
- name: Check sudoers | ||
command: >- | ||
echo "{{ sudoers.ok.stat.checksum }} /etc/sudoers" | sha256sum --check | ||
- name: Get stat of tests/files/test_large_configuration_pingers.ok | ||
delegate_to: localhost | ||
stat: | ||
path: files/test_large_configuration_pingers.ok | ||
checksum_algorithm: sha256 | ||
register: pingers_ok | ||
|
||
# sha256sum ./files/test_large_configuration_pingers.ok | ||
- name: Check pingers | ||
command: >- | ||
echo "{{ pingers.ok.stat.checksum }} /etc/sudoers.d/pingers" | sha256sum --check | ||
- name: Get stat of tests/files/test_large_configuration_root.ok | ||
delegate_to: localhost | ||
stat: | ||
path: files/test_large_configuration_root.ok | ||
checksum_algorithm: sha256 | ||
register: root_ok | ||
|
||
# sha256sum ./files/test_large_configuration_root.ok | ||
- name: Check root | ||
command: >- | ||
echo "{{ sudoers.ok.stat.checksum }} /etc/sudoers.d/root" | sha256sum --check | ||
- name: Restore sudoers | ||
copy: | ||
src: "{{ __sudo_tmpdir.path }}/sudoers" | ||
dest: /etc/sudoers | ||
owner: root | ||
group: root | ||
mode: 0644 | ||
remote_src: true | ||
|
||
- name: Restore sudoers.d | ||
copy: | ||
src: "{{ __sudo_tmpdir.path }}/sudoers.d" | ||
dest: /etc/sudoers.d | ||
owner: root | ||
group: root | ||
mode: 0644 | ||
remote_src: true | ||
|
||
- name: Clean up temp directory | ||
file: | ||
path: "{{ __sudo_tmpdir.path }}" | ||
state: absent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,7 +76,7 @@ | |
cmnd_alias: | ||
- name: PING | ||
commands: | ||
- /bin/ping | ||
- /usr/bin/ping | ||
user_alias: | ||
- name: PINGERS | ||
users: | ||
|