diff --git a/.gitignore b/.gitignore index e6e1323..6059209 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ tests/.vagrant +tests/test_variables !.gitignore +*.retry diff --git a/README.md b/README.md index 6fe3ebc..e086131 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/tasks/main.yml b/tasks/main.yml index 3bc7d28..ba38227 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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 @@ -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 ... diff --git a/tests/inventory b/tests/inventory new file mode 100644 index 0000000..2302eda --- /dev/null +++ b/tests/inventory @@ -0,0 +1 @@ +localhost ansible_connection=local diff --git a/tests/main.yml b/tests/main.yml new file mode 100644 index 0000000..b7410b9 --- /dev/null +++ b/tests/main.yml @@ -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 +... diff --git a/tests/requirements.yml b/tests/requirements.yml new file mode 100644 index 0000000..4c2de2a --- /dev/null +++ b/tests/requirements.yml @@ -0,0 +1,3 @@ +- src: chrismeyersfsu.provision_docker + name: provision_docker + diff --git a/tests/roles/ansible-jumpcloud b/tests/roles/ansible-jumpcloud new file mode 120000 index 0000000..55ff54d --- /dev/null +++ b/tests/roles/ansible-jumpcloud @@ -0,0 +1 @@ +../../../ansible-jumpcloud \ No newline at end of file diff --git a/tests/tasks/test_tasks.yml b/tests/tasks/test_tasks.yml new file mode 100644 index 0000000..95f27b2 --- /dev/null +++ b/tests/tasks/test_tasks.yml @@ -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 +... diff --git a/tests/test_variables.yml b/tests/test_variables.yml new file mode 100644 index 0000000..9d3c1ef --- /dev/null +++ b/tests/test_variables.yml @@ -0,0 +1,3 @@ +--- +enc_jumpcloud_x_connect_key: "be79ace74cdeb427679e76b747d7d9f1b295bf56" +...