Skip to content

Commit 0475a79

Browse files
author
Michael Chmielewski
committed
Removed Threat Stack agent 1.x support
Also switched over the kitchen tests to use docker, not vagrant. It now supports running tests on every supported platform. * Currently using a fork of the `install.sh` file because the `kitchen-salt` gem does not properly identify Amazon Linux 2 (`bootstrap_url`). The PR to fix it is saltstack/kitchen-salt#319, once this is accepted and released, the `bootstrap_url` setting can be removed from `.kitchen.yml`. * Fixed a bug where the formula was having a hard time formatting the Threat Stack Amazon Linux package repository URLs.
1 parent 0e8cf97 commit 0475a79

File tree

5 files changed

+153
-75
lines changed

5 files changed

+153
-75
lines changed

.kitchen.yml

Lines changed: 132 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
---
22
driver:
3-
name: vagrant
3+
name: docker
44

55
provisioner:
66
name: salt_solo
7+
bootstrap_url: 'https://raw.githubusercontent.com/olhado/kitchen-salt/master/assets/install.sh'
78
is_file_root: true
89
# Use this section (and comment out the `threatstack.sls` definition in the `pillars` section)
910
# to grab pillar data from the `pillar.example` file
@@ -34,13 +35,138 @@ provisioner:
3435
- threatstack
3536

3637
platforms:
37-
- name: centos-6
38-
- name: centos-7.6
39-
- name: debian-8.11
40-
- name: debian-9.6
41-
- name: ubuntu-14.04
38+
- name: amazonlinux-1
39+
image: amazonlinux:1
40+
driver_config:
41+
run_command: /sbin/init
42+
privileged: true
43+
run_options:
44+
env: container=docker
45+
volume:
46+
- /sys/fs/cgroup:/sys/fs/cgroup
47+
provision_command:
48+
- yum install -y audit initscripts
49+
- sed -i 's/local_events = yes/local_events = no/g' /etc/audit/auditd.conf
50+
- chkconfig auditd on
51+
- name: amazonlinux-2
52+
image: amazonlinux:2
53+
driver_config:
54+
run_command: /sbin/init
55+
privileged: true
56+
run_options:
57+
env: container=docker
58+
volume:
59+
- /sys/fs/cgroup:/sys/fs/cgroup
60+
provision_command:
61+
- yum install -y audit initscripts
62+
- sed -i 's/local_events = yes/local_events = no/g' /etc/audit/auditd.conf
63+
- systemctl enable auditd.service
64+
image: centos:7
65+
- name: centos-7
66+
image: centos:7
67+
driver_config:
68+
run_command: /sbin/init
69+
privileged: true
70+
run_options:
71+
env: container=docker
72+
volume:
73+
- /sys/fs/cgroup:/sys/fs/cgroup
74+
provision_command:
75+
- yum install -y audit initscripts
76+
- sed -i 's/local_events = yes/local_events = no/g' /etc/audit/auditd.conf
77+
- systemctl enable auditd.service
78+
- name: centos-8
79+
image: centos:8
80+
driver_config:
81+
run_command: /sbin/init
82+
privileged: true
83+
run_options:
84+
env: container=docker
85+
volume:
86+
- /sys/fs/cgroup:/sys/fs/cgroup
87+
provision_command:
88+
- yum install -y audit initscripts
89+
- sed -i 's/local_events = yes/local_events = no/g' /etc/audit/auditd.conf
90+
- systemctl enable auditd.service
91+
- name: debian-8
92+
image: debian:8
93+
driver_config:
94+
run_command: /sbin/init
95+
cap_add:
96+
- SYS_ADMIN
97+
run_options:
98+
env: container=docker
99+
volume:
100+
- /sys/fs/cgroup:/sys/fs/cgroup
101+
provision_command:
102+
- sed -i 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config
103+
- systemctl enable ssh.service
104+
- name: debian-9
105+
image: debian:9
106+
driver_config:
107+
run_command: /bin/systemd
108+
cap_add:
109+
- SYS_ADMIN
110+
run_options:
111+
env: container=docker
112+
volume:
113+
- /sys/fs/cgroup:/sys/fs/cgroup
114+
provision_command:
115+
- sed -i 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config
116+
- systemctl enable ssh.service
117+
- name: debian-10
118+
image: debian:10
119+
driver_config:
120+
run_command: /sbin/init
121+
cap_add:
122+
- SYS_ADMIN
123+
run_options:
124+
env: container=docker
125+
volume:
126+
- /sys/fs/cgroup:/sys/fs/cgroup
127+
provision_command:
128+
- sed -i 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config
129+
- systemctl enable ssh.service
42130
- name: ubuntu-16.04
131+
image: ubuntu:16.04
132+
driver_config:
133+
run_command: /sbin/init
134+
cap_add:
135+
- SYS_ADMIN
136+
run_options:
137+
env: container=docker
138+
volume:
139+
- /sys/fs/cgroup:/sys/fs/cgroup
140+
provision_command:
141+
- sed -i 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config
142+
- systemctl enable ssh.service
43143
- name: ubuntu-18.04
144+
image: ubuntu:18.04
145+
driver_config:
146+
run_command: /sbin/init
147+
cap_add:
148+
- SYS_ADMIN
149+
run_options:
150+
env: container=docker
151+
volume:
152+
- /sys/fs/cgroup:/sys/fs/cgroup
153+
provision_command:
154+
- sed -i 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config
155+
- systemctl enable ssh.service
156+
- name: ubuntu-20.04
157+
image: ubuntu:20.04
158+
driver_config:
159+
run_command: /sbin/init
160+
cap_add:
161+
- SYS_ADMIN
162+
run_options:
163+
env: container=docker
164+
volume:
165+
- /sys/fs/cgroup:/sys/fs/cgroup
166+
provision_command:
167+
- sed -i 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config
168+
- systemctl enable ssh.service
169+
# - name: amazonlinux-2
44170

45171
suites:
46172
- name: default

Gemfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
source 'https://rubygems.org'
2-
31
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
42

53
group :development, :unit_tests do
6-
gem 'rake', :require => false
4+
gem 'rake', :require => false
75
end
86
group :system_tests do
97
gem 'serverspec', :require => false
108
gem 'test-kitchen', :require => false
119
gem 'kitchen-salt', :require => false
12-
gem 'kitchen-vagrant', :require => false
10+
gem 'kitchen-docker', :require => false
1311
end
1412

1513
# vim:ft=ruby

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22

33
A formula for installing Threat Stack agent
44

5-
This formula supports installing agent 1.x and agent 2.x
5+
This formula supports installing agent 2.x
6+
7+
>>>
8+
**No longer supports Threat Stack agent 1.x**
9+
10+
For 1.x support, look at the 2.x versions of this formula.
11+
>>>
612
713
## Available states
814
The following states are available:
@@ -16,13 +22,10 @@ The following states are available:
1622
* `ts_configure_agent:` [optional] If the agent should be configured during run. Set to False if installing agent into an AMI.
1723
* ex. True
1824
* `ts_agent_version:` [optional] Version of agent to install. By default if this setting is omitted, the latest version will be installed. Set a version to maintain consistency in an environment.
19-
* ex. "1.4.5.0ubuntu14.0"
20-
* `ts_agent_config_args:` [optional] Optional arguments to be passed to `cloudsight config` or `tsagent config` (depends on version of agent). Use this to enable optional features.
21-
* agent 1.x ex. "--enable_foo=1"
25+
* ex. "2.0.0.0ubuntu20.0"
2226
* agent 2.x ex. "--set enable_foo 1"
23-
* `ts_agent_extra_args:` [optional] Optional arguments to be passed to `cloudsight setup` or `tsagent setup` (depends on version of agent).
24-
* Please refer to the agent documentation or check the appropriate help output for `cloudsight setup`/`tsagent setup`.
25-
* `ts_agent_1x_platforms:` [required] This list defines the linux distributions (and versions) that should use the 1.x agent. This should only be changed if you have reviewed this salt formula, and understand the ramifications.
27+
* `ts_agent_extra_args:` [optional] Optional arguments to be passed to `tsagent setup`.
28+
* Please refer to the agent documentation or check the appropriate help output for `tsagent setup`.
2629

2730
## Testing
2831
There is currently no spec testing as a saltstack rspec module does not exist.

pillar.example

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
deploy_key: "xxxx-xxxx-your-secret-key-xxxx"
22
ts_configure_agent: True
3-
ts_agent_version: 1.4.5.0ubuntu14.0
4-
ts_agent_config_args: '--enable_foo=1'
3+
ts_agent_version: 2.3.0*
4+
ts_agent_config_args: '--set log.level info'
55
ts_agent_extra_args: ''
6-
ts_agent_1x_platforms: ['CentOS-6', 'RHEL-6', 'Ubuntu-trusty', 'Debian-wheezy']

threatstack/init.sls

Lines changed: 7 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
{% set os_family = grains['os_family'] %}
44
{% set os_name = grains['os'] %}
55
{% set agent2_pkg_url_base = 'https://pkg.threatstack.com/v2' %}
6-
{% set agent1_pkg_url_base = 'https://pkg.threatstack.com' %}
76
{% set pkg_location = { 'pkg_url': '' } %}
87

98
# For Debian-based distributions
@@ -18,20 +17,17 @@
1817

1918
# Check if OS is not supported in 2.X, and assign the repository URL appropriately
2019
{% if pkg_url is not defined %}
21-
{% if ([os_name, os_maj_ver.ver]|join('-')) in pillar['ts_agent_1x_platforms'] %}
22-
{% set _ = pkg_location.update({ 'pkg_url': agent1_pkg_url_base}) %}
23-
{% else %}
24-
{% set _ = pkg_location.update({ 'pkg_url': agent2_pkg_url_base}) %}
25-
{% endif %}
20+
{% set _ = pkg_location.update({ 'pkg_url': agent2_pkg_url_base}) %}
2621

2722
# Set the rest of the URL path
2823
#
2924
# CentOS and EL are fundamentally the same package, so pull from the same place
3025
{% if os_family=="Debian" %}
3126
{% set _ = pkg_location.update({ 'pkg_url': ([pkg_location.pkg_url, 'Ubuntu']|join('/')) }) %}
3227
{% elif os_name=="Amazon" %}
33-
{% if pkg_location.pkg_url==agent1_pkg_url_base %}
34-
{% set _ = pkg_location.update({ 'pkg_url': ([pkg_location.pkg_url, 'Amazon']|join('/')) }) %}
28+
# First version of Amazon Linux 1 was '2011.09'
29+
{% if os_maj_ver.ver > 2010 %}
30+
{% set _ = pkg_location.update({ 'pkg_url': ([pkg_location.pkg_url, 'Amazon', '1']|join('/')) }) %}
3531
{% else %}
3632
{% set _ = pkg_location.update({ 'pkg_url': ([pkg_location.pkg_url, 'Amazon', os_maj_ver.ver]|join('/')) }) %}
3733
{% endif %}
@@ -79,7 +75,7 @@ threatstack-repo:
7975
- file: '/etc/apt/sources.list.d/threatstack.list'
8076
{% elif os_family=="RedHat" %}
8177
cmd.run:
82-
- name: 'curl {{ gpgkey }} -O {{ gpgkey_file }}'
78+
- name: 'curl {{ gpgkey }} -o {{ gpgkey_file }}'
8379
- creates: {{ gpgkey_file }}
8480
pkgrepo.managed:
8581
- name: threatstack
@@ -113,10 +109,7 @@ threatstack-agent:
113109
{% endif %}
114110

115111
# Configure identity file by running script, needs to be done only once
116-
# Agent 2.x uses `tsagent` to setup and configure the agent process
117-
# Agent 1.x uses `cloudsight` to setup and configure the agent process
118112
{% if pillar['ts_configure_agent'] is not defined or pillar['ts_configure_agent'] == True %}
119-
{% if pkg_location.pkg_url.startswith(agent2_pkg_url_base) %}
120113
tsagent-setup:
121114
cmd.run:
122115
- cwd: /
@@ -125,7 +118,7 @@ tsagent-setup:
125118
- require:
126119
- pkg: threatstack-agent
127120

128-
{% if pillar['ts_agent_config_args'] is defined %}
121+
{% if pillar['ts_agent_config_args'] is defined %}
129122
/opt/threatstack/etc/.config_args:
130123
file.managed:
131124
- user: root
@@ -140,58 +133,17 @@ tsagent-config:
140133
- name: tsagent config {{ pillar['ts_agent_config_args'] }}
141134
- watch:
142135
- file: /opt/threatstack/etc/.config_args
143-
{% endif %}
144-
145-
{% else %}
146-
cloudsight-setup:
147-
cmd.run:
148-
- cwd: /
149-
- name: cloudsight setup --deploy-key={{ pillar['deploy_key'] }} {{ agent_extra_args }}
150-
- unless: test -f /opt/threatstack/cloudsight/config/.audit
151-
- require:
152-
- pkg: threatstack-agent
153-
154-
{% if pillar['ts_agent_config_args'] is defined %}
155-
/opt/threatstack/cloudsight/config/.config_args:
156-
file.managed:
157-
- user: root
158-
- group: root
159-
- mode: '0644'
160-
- contents:
161-
- {{ pillar['ts_agent_config_args'] }}
162-
163-
cloudsight-config:
164-
cmd.wait:
165-
- cwd: /
166-
- name: cloudsight config {{ pillar['ts_agent_config_args'] }}
167-
- watch:
168-
- file: /opt/threatstack/cloudsight/config/.config_args
169-
{% endif %}
170-
171136
{% endif %}
172137
{% endif %}
173138

174139
# NOTE: We do not signal the cloudsight service to restart via the package
175140
# resource because the workflow differs between fresh installation and
176141
# upgrades. The package scripts will handle this.
177-
# Agent 1.x is defined as the `cloudsight` service
178-
# Agent 2.x is defined as the `threatstack` service
179-
{% if pkg_location.pkg_url.startswith(agent2_pkg_url_base) %}
180142
threatstack:
181143
service.running:
182144
- enable: True
183145
- restart: True
184-
{% if pillar['ts_agent_config_args'] is defined %}
146+
{% if pillar['ts_agent_config_args'] is defined %}
185147
- watch:
186148
- cmd: tsagent-config
187-
{% endif %}
188-
{% else %}
189-
cloudsight:
190-
service.running:
191-
- enable: True
192-
- restart: True
193-
{% if pillar['ts_agent_config_args'] is defined %}
194-
- watch:
195-
- cmd: cloudsight-config
196-
{% endif %}
197149
{% endif %}

0 commit comments

Comments
 (0)