Skip to content

Commit 11cd8af

Browse files
author
P4T12ICK
committed
Idempotence
1 parent a94835a commit 11cd8af

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed

tasks/install_art.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
---
22

3+
- name: Check if Atomic Red Team is already installed
4+
become: true
5+
stat:
6+
path: /opt/AtomicRedTeam
7+
register: art_installed
8+
39
- name: Install Atomic Red Team
410
become: true
511
shell: |
@@ -8,6 +14,7 @@
814
IEX (IWR https://raw.githubusercontent.com/redcanaryco/invoke-atomicredteam/master/install-atomicredteam.ps1);
915
Install-AtomicRedTeam -Force'
1016
register: output_art
17+
when: not art_installed.stat.exists | default(false)
1118

1219
- name: create directory for default powershell profile
1320
file:

tasks/install_osquery_linux.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
stat: path=/etc/init.d/osqueryd
2222
register: service_status
2323

24+
- name: Check if osquery is already installed
25+
become: true
26+
stat:
27+
path: /usr/bin/osqueryd
28+
register: osquery_installed
29+
2430
- name: is osquery service exist? if yes stop it!
2531
become: true
2632
service:
@@ -31,10 +37,13 @@
3137
- name: run osquery_install.sh
3238
become: true
3339
command: sh /tmp/osquery_install.sh
40+
when: not osquery_installed.stat.exists | default(false)
3441

3542
- name: clean the script
3643
become: true
37-
command: rm /tmp/osquery_install.sh
44+
file:
45+
path: /tmp/osquery_install.sh
46+
state: absent
3847

3948
- name: copy template.osquery.conf
4049
become: true
@@ -74,7 +83,11 @@
7483

7584
- name: make /var/log/osquery dir accessible to everyone (rwx)
7685
become: true
77-
command: chmod a+rwx /var/log/osquery -R
86+
file:
87+
path: /var/log/osquery
88+
state: directory
89+
mode: '0777'
90+
recurse: yes
7891

7992
- name: Create folder directory for inputs configuration
8093
become: true

tasks/install_sysmon_linux.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
become: true
66
ansible.builtin.shell: lsb_release -rs
77
register: result
8+
changed_when: false
89

910
- name: add the microsoft repo
1011
become: true
@@ -37,9 +38,16 @@
3738
src: "SysMonLinux-CatchAll.xml"
3839
dest: "/tmp/SysMonLinux-CatchAll.xml"
3940

41+
- name: Check if sysmon is already configured
42+
become: true
43+
stat:
44+
path: /etc/sysmon/sysmon.xml
45+
register: sysmon_configured
46+
4047
- name: launch with config
4148
become: true
4249
ansible.builtin.shell: sysmon -accepteula -i /tmp/SysMonLinux-CatchAll.xml
50+
when: not sysmon_configured.stat.exists | default(false)
4351

4452
- name: install powershell
4553
become: true

tasks/install_universal_forwarder.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,17 @@
2828
mode: '0644'
2929
force: yes
3030

31+
- name: Check if splunk is already configured
32+
become: true
33+
stat:
34+
path: /opt/splunkforwarder/etc/.ui_login
35+
register: splunk_configured
36+
3137
- name: splunk license acceptance
3238
become: true
3339
shell: sudo -u splunkfwd /opt/splunkforwarder/bin/splunk start --accept-license --answer-yes --no-prompt --seed-passwd {{ ludus_ar_linux_splunk_password }}
40+
when: not splunk_configured.stat.exists | default(false)
41+
changed_when: false
3442

3543
- name: Stop splunk uf
3644
become: true

0 commit comments

Comments
 (0)