Skip to content

Commit

Permalink
add Testing for the role
Browse files Browse the repository at this point in the history
  • Loading branch information
marcomc committed Dec 12, 2017
1 parent 4fc64fc commit 8fb8b65
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
tests/.vagrant
tests/test_variables
!.gitignore
*.retry
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,27 @@ To be retrieved from JumpCloud portal by a JC Admin account

To be stored in an Ansible Vault. It's very high-sensitivity Information.

## Testing
### Requirements
create the file tests/test_variables.yml that must include your private jumpcloud_x_connect_key as follow:
```
---
enc_jumpcloud_x_connect_key: "xxxxxxxxxxxxxyyyyyyyyyyyyyyzzzzzzzzzz"
...
```

Make sure that on you JumpCloud account you have the following System Groups:
```
ansible_test_1
ansible_test_2
```

Run
```
cd tests/
ansible-playbook main.yml
```

#### [`jumpcloud_x_connect_key`][jumpcloud-x-connect-key]
Default: none

Expand Down
4 changes: 2 additions & 2 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
jumpcloud_not_installed: "{{ not (jumpcloud_agent_config_status.stat.isreg is defined and jumpcloud_agent_config_status.stat.isreg) }}"

- name: Install JumpCloud if required
include: install.yml
import_tasks: install.yml
when: jumpcloud_not_installed or jumpcloud_force_install

- name: check JumpCloud agent config again
Expand All @@ -22,6 +22,6 @@
jumpcloud_is_installed: "{{ jumpcloud_agent_config_status.stat.isreg is defined and jumpcloud_agent_config_status.stat.isreg}}"

- name: Update System Attributes if JumpCloud is insalled
include: update_system.yml
import_tasks: update_system.yml
when: jumpcloud_is_installed
...
1 change: 1 addition & 0 deletions tests/inventory
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
localhost ansible_connection=local
43 changes: 43 additions & 0 deletions tests/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
- name: Bring up Docker containers
hosts: localhost
gather_facts: false
vars:
inventory:
- name: ansible_jumpcloud_test_host_1
image: "chrismeyers/centos6"
roles:
- role: provision_docker
provision_docker_company: 'ansible'
provision_docker_inventory: "{{ inventory }}"

- name: Update the hostname
hosts: docker_containers
tasks:
- hostname:
name: "{{ inventory_hostname}}"

- name: Run JumpCloud role
hosts: docker_containers
roles:
- { role: ansible-jumpcloud }
vars_files:
- ./test_variables.yml
vars:
jumpcloud_tags:
- 'test_tag1'
- 'test_tag2'
jumpcloud_displayName: "{{ inventory.name }}"
jumpcloud_allowPublicKeyAuthentication: 'false'
jumpcloud_allowSshPasswordAuthentication: 'false'
jumpcloud_allowSshRootLogin: 'true'
jumpcloud_allowMultiFactorAuthentication: 'false'

- name: Run Tests
hosts: docker_containers
tasks:
- { include: tasks/test_tasks.yml }


- name: Destroy Docker Containers
...
3 changes: 3 additions & 0 deletions tests/requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- src: chrismeyersfsu.provision_docker
name: provision_docker

1 change: 1 addition & 0 deletions tests/roles/ansible-jumpcloud
4 changes: 4 additions & 0 deletions tests/tasks/test_tasks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
- name: Check that the host has been added to JumpCloud
- name: Check that the host has been associated to all the specified Groups
...
3 changes: 3 additions & 0 deletions tests/test_variables.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
enc_jumpcloud_x_connect_key: "be79ace74cdeb427679e76b747d7d9f1b295bf56"
...

0 comments on commit 8fb8b65

Please sign in to comment.