Skip to content

Commit

Permalink
Merge pull request #1 from route1337/cleanerTesting
Browse files Browse the repository at this point in the history
Moving test data to it's own role
  • Loading branch information
ahrenstein authored Mar 11, 2020
2 parents 586c721 + ba178ff commit ad0f6f7
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ suites:
playbook: tests/playbooks/repo-role.yml
hosts: kitchen
roles_path: .
additional_copy_role_path: tests/roles
ansible_inventory: tests/inventory
host_vars_path: tests/host_vars/standard
verifier:
Expand All @@ -45,6 +46,7 @@ suites:
playbook: tests/playbooks/repo-role.yml
hosts: kitchen
roles_path: .
additional_copy_role_path: tests/roles
ansible_inventory: tests/inventory
host_vars_path: tests/host_vars/no-user-management
verifier:
Expand Down
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@ Ansible Role - Linux Users: Changelog
=====================================
A list of all the changes made to this repo and the role it contains

Version 1.0.1
-------------

1. Moved test user creation to a role located at `test/roles/generate-test-data` in order to avoid production use of
the role always showing it skip test users with suspicious names
2. Documentation updates around what the `is_kitchen` variable does

Version 1.0.0
------------
-------------

1. Initial Release of repository

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ The following variables are optional:
The following variables should only be used in testing:
1. `is_kitchen` - If this variable is defined test users are created and logic changes to exclude the vagrant user from
management
1. `is_kitchen` - If this variable is defined the role(s) in `tests/roles` create sample users for testing unapproved user
deletion against. Additionally the `user_cleanup.yml` play will exempt the `vagrant` user from deletion
Testing
-------
Expand Down
2 changes: 0 additions & 2 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,5 @@
when: ansible_distribution == 'Ubuntu'
- import_tasks: users.yml
when: ansible_distribution == 'Ubuntu' and linux_users.users is defined
- import_tasks: kitchen_testing.yml
when: ansible_distribution == 'Ubuntu' and is_kitchen is defined
- import_tasks: user_cleanup.yml
when: ansible_distribution == 'Ubuntu' and linux_users.users is defined
1 change: 1 addition & 0 deletions tests/playbooks/repo-role.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
# Run the single role in this repo on all linux systems
- hosts: kitchen
roles:
- '/tmp/kitchen/roles/roles/generate-test-data'
- '/tmp/kitchen/roles'
16 changes: 16 additions & 0 deletions tests/roles/generate-test-data/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
#
# Project:: Ansible Role - Linux Users
#
# Copyright 2020, Route 1337, LLC, All Rights Reserved.
#
# Maintainers:
# - Matthew Ahrenstein: [email protected]
#
# See LICENSE
#

# Manage setting variables and users for the Test Kitchen environment

- import_tasks: sample-users.yml
when: ansible_distribution == 'Ubuntu'
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
# See LICENSE
#

# Create a test user for verifying user cleanup works
# This only runs if is_kitchen is defined
# Generate some test users to assist in testing the role

- name: Create a test user called "baduser" outside of inventory to verify the user cleanup works
user:
Expand Down

0 comments on commit ad0f6f7

Please sign in to comment.