-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update install script for agent version 2.x (#43)
* update install script for 2.x * fix RedHat-specific syntax * fix 1.x syntax * account for different repos * fix idempotence
- Loading branch information
Greg Malkov
authored
Jan 18, 2019
1 parent
ce40163
commit d423621
Showing
12 changed files
with
163 additions
and
30 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
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 |
---|---|---|
@@ -1,2 +1,5 @@ | ||
- name: restart cloudsight | ||
service: name=cloudsight state=restarted | ||
|
||
- name: restart tsagent | ||
service: name=threatstack state=restarted |
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,15 @@ | ||
--- | ||
- name: Check if agent is v1.x | ||
set_fact: | ||
threatstack_v1_string: "{{ threatstack_pkg | regex_search('agent[=-]1\\.') }}" | ||
|
||
- name: Define v1 variable | ||
set_fact: | ||
threatstack_v1: "{{ threatstack_v1_string != '' }}" | ||
|
||
- name: Ensure agent_type is defined | ||
fail: | ||
msg: "threatstack_feature_plan is mandatory for 1.x agents!" | ||
when: | ||
- threatstack_v1 | ||
- agent_type == '' |
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,10 @@ | ||
--- | ||
- name: Define v1 package URL variable | ||
set_fact: | ||
threatstack_pkg_url: "{{ threatstack_v1_pkg_url }}" | ||
when: threatstack_v1 | ||
|
||
- name: Define v2 package URL variable | ||
set_fact: | ||
threatstack_pkg_url: "{{ threatstack_v2_pkg_url }}" | ||
when: not threatstack_v1 |
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,76 @@ | ||
--- | ||
|
||
# 2.x agent setup | ||
|
||
- name: Get setup string | ||
set_fact: | ||
setup_string: tsagent setup -url {{ threatstack_url }} -deploy-key {{ threatstack_deploy_key }} -ruleset "{{ threatstack_ruleset | join(",") }}" {{ threatstack_agent_extra_args }} | ||
|
||
- name: Get checksum of setup string | ||
set_fact: | ||
setup_checksum: "{{ setup_string | checksum }}" | ||
|
||
- name: Create file to track checksum of setup string | ||
copy: | ||
content: "{{ setup_checksum }}" | ||
dest: /opt/threatstack/etc/.setup_checksum | ||
owner: root | ||
group: root | ||
mode: 0644 | ||
register: setup_file | ||
|
||
- name: Get config string | ||
set_fact: | ||
config_string: tsagent config -set {{ threatstack_agent_config_args }} | ||
|
||
- name: Get checksum of config string | ||
set_fact: | ||
config_checksum: "{{ config_string | checksum }}" | ||
|
||
- debug: | ||
msg: "{{ threatstack_agent_config_args }}" | ||
|
||
- name: Create file to track checksum of config string | ||
copy: | ||
content: "{{ config_checksum }}" | ||
dest: /opt/threatstack/etc/.config_checksum | ||
owner: root | ||
group: root | ||
mode: 0644 | ||
register: config_file | ||
when: threatstack_agent_config_args != None | ||
|
||
- name: Agent setup | ||
command: "{{ setup_string }}" | ||
register: setup_result | ||
changed_when: False | ||
|
||
- name: Wait 5 seconds | ||
pause: | ||
seconds: 5 | ||
|
||
- name: Agent config | ||
command: "{{ config_string }}" | ||
when: config_file.changed | ||
|
||
- name: Restart tsagent | ||
service: name=threatstack state=restarted | ||
when: setup_file.changed or config_file.changed | ||
|
||
- name: Wait 5 seconds | ||
pause: | ||
seconds: 5 | ||
when: setup_file.changed or config_file.changed | ||
|
||
- name: Test agent state | ||
command: tsagent status | ||
register: tsagent_status | ||
retries: 5 | ||
delay: 2 | ||
until: tsagent_status.rc == 0 | ||
when: setup_file.changed or config_file.changed | ||
tags: | ||
- checkstate | ||
|
||
- name: Ensure agent is running | ||
service: name=threatstack state=started |
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