Skip to content

Commit

Permalink
first test of retriving duplicate inactive systems from JC
Browse files Browse the repository at this point in the history
  • Loading branch information
marcomc committed Jun 28, 2018
1 parent 2d2ae47 commit d0519b4
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Default: `no`

Whether or not to use sudo during installation.

#### [`jumpcloud_tags`][jumpcloud-tagsh]
#### [`jumpcloud_tags`][jumpcloud-tags]

The list of JC tags you want a host or a group of hosts to be part of
- 'tag_one'
Expand Down
6 changes: 0 additions & 6 deletions tasks/check_system_registration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@
"Content-Type": "application/json"
"Accept": "application/json"
"x-api-key": "{{ jumpcloud_api_key }}"
body_format: json
body: '{ "displayName" : "{{ jumpcloud_displayName }}",
"allowPublicKeyAuthentication" : "{{ jumpcloud_allowPublicKeyAuthentication }}",
"allowSshPasswordAuthentication" : "{{ jumpcloud_allowSshPasswordAuthentication }}",
"allowSshRootLogin" : "{{ jumpcloud_allowSshRootLogin }}",
"allowMultiFactorAuthentication" : "{{ jumpcloud_allowMultiFactorAuthentication }}" }'
follow_redirects: all
return_content: yes
status_code: 200
Expand Down
29 changes: 29 additions & 0 deletions tasks/find_registered_systems.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
- name: Retrive the list of registeed systems with the same name
uri:
url: "{{ jumpcloud_api_v1_url }}/search/systems"
method: POST
headers:
"Content-Type": "application/json"
"Accept": "application/json"
"x-api-key": "{{ jumpcloud_api_key }}"
body_format: json
body: '{ "filter" :
{"and" :
[{ "displayName" : "{{ jumpcloud_displayName }}" },
{"active" : "false" }]
},
"fields": "displayName _id" }'
follow_redirects: all
return_content: yes
status_code: 200
delegate_to: localhost
register: jc_registered_systems_json_response
when: jumpcloud_displayName is defined
ignore_errors: yes

- debug:
var: jc_registered_systems_json_response

- pause:
...
6 changes: 6 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@
jumpcloud_system_key: "{{ jumpcloud_system_key_result.stdout }}"
when: jumpcloud_is_installed

- debug:
var: jumpcloud_system_key

- name: Check System Registration
import_tasks: check_system_registration.yml
when: jumpcloud_system_key is defined

- name: Find Registered Systems with the same name
import_tasks: find_registered_systems.yml

- name: Update System Attributes if the System is registered in JumpCloud
import_tasks: update_system.yml
when: jc_system_is_registered
Expand Down

0 comments on commit d0519b4

Please sign in to comment.