Compare commits
10 Commits
f0a6605f82
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| d38e3ba4e0 | |||
| 752a9de6df | |||
| 5e2ad66dfb | |||
| 0a321f2acb | |||
| 6ad0af7134 | |||
| 5b84cafa3d | |||
| a491074c4f | |||
| 06b094e769 | |||
| 62dd3230fb | |||
| a3f45c0901 |
17
hosts
Normal file
17
hosts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
[forensics]
|
||||||
|
10.8.2.12 ansible_user=administrator
|
||||||
|
|
||||||
|
[database]
|
||||||
|
10.8.2.3 ansible_user=administrator
|
||||||
|
|
||||||
|
[workstations]
|
||||||
|
10.8.1.10 ansible_user=administrator
|
||||||
|
10.8.1.40 ansible_user=administrator
|
||||||
|
|
||||||
|
[workstations:children]
|
||||||
|
web
|
||||||
|
|
||||||
|
[web]
|
||||||
|
10.8.1.90 ansible_user=administrator
|
||||||
|
|
||||||
|
|
||||||
3
roles/immortal/handlers/main.yml
Normal file
3
roles/immortal/handlers/main.yml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
- name: restart ufw
|
||||||
|
service: name=ufw state=restarted
|
||||||
|
become: yes
|
||||||
@@ -20,13 +20,58 @@
|
|||||||
src: /etc/passwd
|
src: /etc/passwd
|
||||||
dest: "{{ inventory_hostname }}"
|
dest: "{{ inventory_hostname }}"
|
||||||
|
|
||||||
|
- name: Collect disk space data
|
||||||
|
block:
|
||||||
|
- name: lsblk
|
||||||
|
shell: lsblk
|
||||||
|
register: lsblk_output
|
||||||
|
become: yes
|
||||||
|
- name: Store results
|
||||||
|
copy:
|
||||||
|
content: "{{lsblk_output.stdout}}"
|
||||||
|
dest: "{{ inventory_hostname }}/lsblk.out"
|
||||||
|
delegate_to: localhost
|
||||||
|
become: no
|
||||||
|
|
||||||
|
- name: Collect netstat
|
||||||
|
block:
|
||||||
|
- name: Run command
|
||||||
|
shell: netstat -peanut
|
||||||
|
register: netstat_output
|
||||||
|
become: yes
|
||||||
|
- name: Store results
|
||||||
|
copy:
|
||||||
|
content: "{{netstat_output.stdout}}"
|
||||||
|
dest: "{{ inventory_hostname }}/netstat.out"
|
||||||
|
delegate_to: localhost
|
||||||
|
become: no
|
||||||
|
- name: Collect process data
|
||||||
|
block:
|
||||||
|
- name: Run command
|
||||||
|
shell: ps aux
|
||||||
|
register: ps_output
|
||||||
|
become: yes
|
||||||
|
- name: Store results
|
||||||
|
copy:
|
||||||
|
content: "{{ps_output.stdout}}"
|
||||||
|
dest: "{{ inventory_hostname }}/ps.out"
|
||||||
|
delegate_to: localhost
|
||||||
|
become: no
|
||||||
- name: Get users
|
- name: Get users
|
||||||
get_users:
|
get_users:
|
||||||
#min_uid: "{{ (ansible_os_family == 'RedHat') | ternary(500,1000) }}"
|
#min_uid: "{{ (ansible_os_family == 'RedHat') | ternary(500,1000) }}"
|
||||||
min_uid: 1000
|
min_uid: 1000
|
||||||
max_uid: 65000
|
max_uid: 65000
|
||||||
|
become: yes
|
||||||
register: users_list
|
register: users_list
|
||||||
|
|
||||||
|
- name: Backup all users authorized keys
|
||||||
|
fetch:
|
||||||
|
src: "{{item['dir']}}/.ssh/authorized_keys"
|
||||||
|
dest: "{{ inventory_hostname }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
loop: "{{ users_list.users }}"
|
||||||
|
|
||||||
- name: Give root exclusively the current controller user's SSH key
|
- name: Give root exclusively the current controller user's SSH key
|
||||||
ansible.posix.authorized_key:
|
ansible.posix.authorized_key:
|
||||||
user: root
|
user: root
|
||||||
@@ -54,7 +99,6 @@
|
|||||||
|
|
||||||
- name: Disable firewalld if RHEL based
|
- name: Disable firewalld if RHEL based
|
||||||
shell: "systemctl disable firewalld; systemctl stop firewalld"
|
shell: "systemctl disable firewalld; systemctl stop firewalld"
|
||||||
|
|
||||||
when: ansible_os_family == "RedHat"
|
when: ansible_os_family == "RedHat"
|
||||||
|
|
||||||
- name: Ensure UFW is installed
|
- name: Ensure UFW is installed
|
||||||
@@ -62,6 +106,12 @@
|
|||||||
name: ufw
|
name: ufw
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
|
- name: Ensure UFW is disabled
|
||||||
|
ufw: state=disabled
|
||||||
|
|
||||||
|
- name: Reset UFW
|
||||||
|
ufw: state=reset
|
||||||
|
|
||||||
- name: Configure ufw defaults
|
- name: Configure ufw defaults
|
||||||
ufw: direction={{ item.direction }} policy={{ item.policy }}
|
ufw: direction={{ item.direction }} policy={{ item.policy }}
|
||||||
with_items:
|
with_items:
|
||||||
|
|||||||
15
setup.yml
15
setup.yml
@@ -1,20 +1,35 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- hosts: all
|
- hosts: all
|
||||||
|
handlers:
|
||||||
|
- import_tasks: handlers.yml
|
||||||
vars_prompt:
|
vars_prompt:
|
||||||
- name: password
|
- name: password
|
||||||
prompt: "Enter new root and admin password"
|
prompt: "Enter new root and admin password"
|
||||||
roles:
|
roles:
|
||||||
- immortal
|
- immortal
|
||||||
|
become: yes
|
||||||
|
|
||||||
- hosts: web
|
- hosts: web
|
||||||
|
handlers:
|
||||||
|
- import_tasks: handlers.yml
|
||||||
roles:
|
roles:
|
||||||
- web
|
- web
|
||||||
|
become: yes
|
||||||
|
|
||||||
- hosts: database
|
- hosts: database
|
||||||
|
handlers:
|
||||||
|
- import_tasks: handlers.yml
|
||||||
roles:
|
roles:
|
||||||
- database
|
- database
|
||||||
|
become: yes
|
||||||
|
|
||||||
- hosts: all
|
- hosts: all
|
||||||
|
vars:
|
||||||
|
pip_install_packages:
|
||||||
|
- name: docker
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
|
- geerlingguy.pip
|
||||||
- geerlingguy.docker
|
- geerlingguy.docker
|
||||||
|
become: yes
|
||||||
Reference in New Issue
Block a user