Skip to content

Commit e13efe3

Browse files
authored
Merge pull request #74 from threatstack/disable-service-flag
Add flag to explicitly disable the threatstack service.
2 parents bcf42cf + 5e6f992 commit e13efe3

File tree

6 files changed

+38
-17
lines changed

6 files changed

+38
-17
lines changed

README.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,21 @@ Role Variables
2222
--------------
2323
The following variables are available for override.
2424

25-
| Variable | Type | Default | Required | Description |
26-
|-------------------------------|---------|-----------------------------|-----------|---------------------------------------------------------------------------------------------------------------------------------------------------|
27-
| threatstack_deploy_key | String | | Yes | Your TS deploy key. |
28-
| threatstack_feature_plan | String | | Yes if 1x | (Agent 1.x only) TS Feature Plan. "i" for investigate/"m" for montior. |
29-
| threatstack_ruleset | Array | ["Base Rule Set"] | | Array of rulesets to apply to hosts. |
30-
| threatstack_pkg_url | String | Depends on version | | Location of package repo. Only change if you mirror your own. |
31-
| threatstack_pkg | String | threatstack-agent | | Name of package. Specify package version using `"threatstack-agent=X.Y.Z"` (Debian/Ubuntu) or `"threatstack-agent-X.Y.Z"` (RedHat/CentOS/Amazon). |
32-
| threatstack_pkg_version | String | | | If defined, pins specific threatstack package version
25+
| Variable | Type | Default | Required | Description |
26+
|-----------------------------------|---------|-----------------------------|-----------|---------------------------------------------------------------------------------------------------------------------------------------------------|
27+
| threatstack_deploy_key | String | | Yes | Your TS deploy key. |
28+
| threatstack_feature_plan | String | | Yes if 1x | (Agent 1.x only) TS Feature Plan. "i" for investigate/"m" for montior. |
29+
| threatstack_ruleset | Array | ["Base Rule Set"] | | Array of rulesets to apply to hosts. |
30+
| threatstack_pkg_url | String | Depends on version | | Location of package repo. Only change if you mirror your own. |
31+
| threatstack_pkg | String | threatstack-agent | | Name of package. Specify package version using `"threatstack-agent=X.Y.Z"` (Debian/Ubuntu) or `"threatstack-agent-X.Y.Z"` (RedHat/CentOS/Amazon). |
32+
| threatstack_pkg_version | String | | | If defined, pins specific threatstack package version
3333
| threatstack_pkg_validate | Boolean | yes | | Should packages be validated? We default to yes, but if you repackage anything you may need to change this. |
34-
| threatstack_url | String | https://app.threatstack.com | | The URL endpoint for Threat Stack. This should not change. |
35-
| threatstack_hostname | String | | | The display hostname in the Threat Stack UI. Defaults to hostname. |
36-
| threatstack_configure_agent | Boolean | true | | Set to false to not configure the host, just install the package. |
37-
| threatstack_agent_extra_args | String | | | Pass optional arguments during agent registration. |
38-
| threatstack_agent_config_args | String | | | Pass optional configuration arguments after agent registration. |
34+
| threatstack_url | String | https://app.threatstack.com | | The URL endpoint for Threat Stack. This should not change. |
35+
| threatstack_hostname | String | | | The display hostname in the Threat Stack UI. Defaults to hostname. |
36+
| threatstack_configure_agent | Boolean | true | | Set to false to not configure the host, just install the package. |
37+
| threatstack_agent_extra_args | String | | | Pass optional arguments during agent registration. |
38+
| threatstack_agent_config_args | String | | | Pass optional configuration arguments after agent registration. |
39+
| threatstack_agent_disable_service | Boolean | false | | Make sure agent service is disabled and not running after installation |
3940

4041
Install
4142
----------------

defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ threatstack_config: "{{ threatstack_config_dir }}/tsconfig.json"
1515
threatstack_configure_agent: true
1616
threatstack_agent_extra_args:
1717
threatstack_agent_config_args:
18+
threatstack_agent_disable_service: false
1819

1920
# Set according to feature plan. https://www.threatstack.com/plans
2021
# * agent_type="i" - Investigate, Legacy (Basic, Pro, Advanced)

tasks/apt_install.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,13 @@
3737
apt:
3838
name: "{{ threatstack_pkg }}={{threatstack_pkg_version}}"
3939
state: "{{ threatstack_pkg_state }}"
40-
when: threatstack_pkg_version is defined
40+
when: threatstack_pkg_version is defined
41+
42+
- name: Stop and disable ThreatStack if not configured
43+
become: yes
44+
service:
45+
name: threatstack
46+
state: stopped
47+
enabled: no
48+
when:
49+
- threatstack_agent_disable_service | bool

tasks/facts.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
- name: Define v1 variable
77
set_fact:
8-
threatstack_v1: "{{ threatstack_v1_string != '' }}"
8+
threatstack_v1: "{{ (threatstack_v1_string != '') | bool }}"
99

1010
- name: Ensure agent_type is defined
1111
fail:

tasks/tsagent_setup.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070

7171
- name: Restart tsagent
7272
service: name=threatstack state=restarted
73-
when: setup_file.changed or config_file.changed
73+
when: (setup_file.changed or config_file.changed) and not threatstack_agent_disable_service | bool
7474

7575
- name: Wait 5 seconds
7676
pause:
@@ -93,3 +93,4 @@
9393
name: threatstack
9494
state: started
9595
enabled: yes
96+
when: not threatstack_agent_disable_service | bool

tasks/yum_install.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,13 @@
3232
name: "{{ threatstack_pkg }}-{{threatstack_pkg_version}}"
3333
state: "{{ threatstack_pkg_state }}"
3434
update_cache: yes
35-
when: threatstack_pkg_version is defined
35+
when: threatstack_pkg_version is defined
36+
37+
- name: Stop and disable ThreatStack if not configured
38+
become: yes
39+
service:
40+
name: threatstack
41+
state: stopped
42+
enabled: no
43+
when:
44+
- threatstack_agent_disable_service | bool

0 commit comments

Comments
 (0)