2023-06-22 18:30:18 +00:00
|
|
|
---
|
2023-06-24 12:05:13 +00:00
|
|
|
################################
|
|
|
|
# T-Pot - Abort if run as root #
|
|
|
|
################################
|
|
|
|
|
2023-07-02 12:52:06 +00:00
|
|
|
- name: T-Pot - Abort if run as root
|
2023-06-24 12:05:13 +00:00
|
|
|
hosts: all
|
|
|
|
gather_facts: true
|
2023-06-30 11:15:30 +00:00
|
|
|
become: false
|
2023-07-02 12:52:06 +00:00
|
|
|
tags:
|
|
|
|
- "Debian"
|
|
|
|
- "Fedora"
|
|
|
|
- "openSUSE Tumbleweed"
|
|
|
|
- "Ubuntu"
|
2023-06-30 11:15:30 +00:00
|
|
|
|
2023-06-24 12:05:13 +00:00
|
|
|
pre_tasks:
|
2023-07-02 12:52:06 +00:00
|
|
|
- name: Check if running as root (All)
|
2023-06-24 12:05:13 +00:00
|
|
|
assert:
|
|
|
|
that: ansible_user_id != 'root'
|
|
|
|
fail_msg: "T-Pot playbook should not be run as root."
|
|
|
|
success_msg: "Running as user: {{ ansible_user_id }}."
|
2023-07-02 12:52:06 +00:00
|
|
|
- name: Check if supported distribution (All)
|
2023-06-25 11:17:33 +00:00
|
|
|
assert:
|
|
|
|
that: ansible_distribution in ["Debian", "Fedora", "openSUSE Tumbleweed", "Ubuntu"]
|
|
|
|
fail_msg: "T-Pot is not supported on this plattform: {{ ansible_distribution }}."
|
|
|
|
success_msg: "T-Pot will now install on {{ ansible_distribution }}."
|
2023-06-24 12:05:13 +00:00
|
|
|
|
2023-06-25 11:17:33 +00:00
|
|
|
############################################################
|
|
|
|
# T-Pot - Install recommended, remove conflicting packages #
|
|
|
|
############################################################
|
2023-06-22 18:30:18 +00:00
|
|
|
|
2023-06-25 11:17:33 +00:00
|
|
|
- name: T-Pot - Install recommended, remove conflicting packages
|
2023-06-22 18:30:18 +00:00
|
|
|
hosts: all
|
|
|
|
gather_facts: true
|
|
|
|
become: true
|
|
|
|
|
|
|
|
tasks:
|
2023-06-24 12:05:13 +00:00
|
|
|
- name: Syncing clocks (All)
|
2023-06-22 18:30:18 +00:00
|
|
|
shell: "hwclock --hctosys"
|
2023-06-25 11:17:33 +00:00
|
|
|
when: ansible_distribution in ["Debian", "Fedora", "openSUSE Tumbleweed", "Ubuntu"]
|
2023-07-02 12:52:06 +00:00
|
|
|
tags:
|
|
|
|
- "Debian"
|
|
|
|
- "Fedora"
|
|
|
|
- "openSUSE Tumbleweed"
|
|
|
|
- "Ubuntu"
|
2023-06-22 18:30:18 +00:00
|
|
|
|
2023-06-24 12:05:13 +00:00
|
|
|
- name: Install recommended packages (Debian, Ubuntu)
|
2023-06-22 18:30:18 +00:00
|
|
|
package:
|
|
|
|
name:
|
|
|
|
- bash-completion
|
|
|
|
- ca-certificates
|
|
|
|
- curl
|
|
|
|
- git
|
|
|
|
- gnupg
|
|
|
|
- grc
|
|
|
|
- neovim
|
|
|
|
- net-tools
|
2023-06-24 12:05:13 +00:00
|
|
|
state: latest
|
|
|
|
update_cache: yes
|
2023-06-22 18:30:18 +00:00
|
|
|
when: ansible_distribution in ["Debian", "Ubuntu"]
|
2023-07-02 12:52:06 +00:00
|
|
|
tags:
|
|
|
|
- "Debian"
|
|
|
|
- "Ubuntu"
|
2023-06-22 18:30:18 +00:00
|
|
|
|
2023-06-24 12:05:13 +00:00
|
|
|
- name: Install recommended packages (Fedora)
|
|
|
|
package:
|
|
|
|
name:
|
|
|
|
- bash-completion
|
|
|
|
- ca-certificates
|
|
|
|
- curl
|
|
|
|
- dnf-plugins-core
|
|
|
|
- git
|
|
|
|
- grc
|
|
|
|
- neovim
|
|
|
|
- net-tools
|
|
|
|
state: latest
|
|
|
|
update_cache: yes
|
|
|
|
when: ansible_distribution in ["Fedora"]
|
2023-07-02 12:52:06 +00:00
|
|
|
tags:
|
|
|
|
- "Fedora"
|
2023-06-24 12:05:13 +00:00
|
|
|
|
2023-06-25 14:56:18 +00:00
|
|
|
- name: Remove conflicting packages (openSUSE Tumbleweed)
|
|
|
|
package:
|
|
|
|
name:
|
|
|
|
- cups
|
|
|
|
- net-tools
|
|
|
|
- postfix
|
|
|
|
- yast2-auth-client
|
|
|
|
- yast2-auth-user
|
|
|
|
state: absent
|
|
|
|
update_cache: yes
|
|
|
|
when: ansible_distribution in ["openSUSE Tumbleweed"]
|
2023-07-02 12:52:06 +00:00
|
|
|
tags:
|
|
|
|
- "openSUSE Tumbleweed"
|
2023-06-25 14:56:18 +00:00
|
|
|
|
2023-06-25 11:17:33 +00:00
|
|
|
- name: Install recommended packages (openSUSE Tumbleweed)
|
|
|
|
package:
|
|
|
|
name:
|
|
|
|
- bash-completion
|
|
|
|
- busybox-net-tools
|
|
|
|
- ca-certificates
|
|
|
|
- curl
|
|
|
|
- git
|
|
|
|
- grc
|
|
|
|
- neovim
|
|
|
|
state: latest
|
|
|
|
update_cache: yes
|
|
|
|
when: ansible_distribution in ["openSUSE Tumbleweed"]
|
2023-07-02 12:52:06 +00:00
|
|
|
tags:
|
|
|
|
- "openSUSE Tumbleweed"
|
2023-06-25 11:17:33 +00:00
|
|
|
|
2023-07-02 12:52:06 +00:00
|
|
|
#####################################
|
|
|
|
# T-Pot - Prepare for Docker Engine #
|
|
|
|
#####################################
|
2023-06-22 18:30:18 +00:00
|
|
|
|
|
|
|
- name: T-Pot - Prepare for and install Docker Engine
|
|
|
|
hosts: all
|
|
|
|
gather_facts: true
|
|
|
|
become: true
|
|
|
|
|
|
|
|
tasks:
|
2023-06-24 12:05:13 +00:00
|
|
|
- name: Remove distribution based Docker packages (Debian, Fedora, Ubuntu)
|
2023-06-22 18:30:18 +00:00
|
|
|
package:
|
|
|
|
name:
|
|
|
|
- docker
|
|
|
|
- docker-engine
|
|
|
|
- docker.io
|
|
|
|
- containerd
|
|
|
|
- runc
|
|
|
|
state: absent
|
2023-06-24 12:05:13 +00:00
|
|
|
update_cache: yes
|
|
|
|
when: ansible_distribution in ["Debian", "Fedora", "Ubuntu"]
|
2023-07-02 12:52:06 +00:00
|
|
|
tags:
|
|
|
|
- "Debian"
|
|
|
|
- "Fedora"
|
|
|
|
- "Ubuntu"
|
2023-06-22 18:30:18 +00:00
|
|
|
|
2023-06-24 12:05:13 +00:00
|
|
|
- name: Add folder for Docker Engine GPG key (Debian, Ubuntu)
|
2023-06-22 18:30:18 +00:00
|
|
|
file:
|
|
|
|
path: /etc/apt/keyrings
|
|
|
|
state: directory
|
|
|
|
mode: 0755
|
|
|
|
when: ansible_distribution in ["Debian", "Ubuntu"]
|
2023-07-02 12:52:06 +00:00
|
|
|
tags:
|
|
|
|
- "Debian"
|
|
|
|
- "Ubuntu"
|
2023-06-22 18:30:18 +00:00
|
|
|
|
2023-06-24 12:05:13 +00:00
|
|
|
- name: Download Docker Engine GPG key (Debian, Ubuntu)
|
2023-06-22 18:30:18 +00:00
|
|
|
get_url:
|
|
|
|
url: https://download.docker.com/linux/{{ ansible_distribution | lower }}/gpg
|
|
|
|
dest: /etc/apt/keyrings/docker
|
|
|
|
mode: 0755
|
|
|
|
when: ansible_distribution in ["Debian", "Ubuntu"]
|
2023-07-02 12:52:06 +00:00
|
|
|
tags:
|
|
|
|
- "Debian"
|
|
|
|
- "Ubuntu"
|
2023-06-22 18:30:18 +00:00
|
|
|
|
2023-06-24 12:05:13 +00:00
|
|
|
- name: Decrypt Docker Engine GPG key (Debian, Ubuntu)
|
2023-06-22 18:30:18 +00:00
|
|
|
shell: gpg --dearmor /etc/apt/keyrings/docker
|
|
|
|
args:
|
|
|
|
creates: /etc/apt/keyrings/docker.gpg
|
|
|
|
when: ansible_distribution in ["Debian", "Ubuntu"]
|
2023-07-02 12:52:06 +00:00
|
|
|
tags:
|
|
|
|
- "Debian"
|
|
|
|
- "Ubuntu"
|
2023-06-22 18:30:18 +00:00
|
|
|
|
2023-06-24 12:05:13 +00:00
|
|
|
- name: Add Docker Engine repository (Debian, Ubuntu)
|
2023-06-22 18:30:18 +00:00
|
|
|
apt_repository:
|
|
|
|
filename: docker
|
|
|
|
repo: "deb [arch={{ ansible_architecture | replace('aarch64', 'arm64') }} signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable"
|
|
|
|
state: present
|
2023-06-24 12:05:13 +00:00
|
|
|
update_cache: yes
|
2023-06-22 18:30:18 +00:00
|
|
|
when: ansible_distribution in ["Debian", "Ubuntu"]
|
2023-07-02 12:52:06 +00:00
|
|
|
tags:
|
|
|
|
- "Debian"
|
|
|
|
- "Ubuntu"
|
2023-06-22 18:30:18 +00:00
|
|
|
|
2023-06-25 11:17:33 +00:00
|
|
|
- name: Add Docker repository (Fedora)
|
|
|
|
shell: |
|
|
|
|
if [ "$(dnf repolist docker-ce-stable)" == "" ];
|
|
|
|
then
|
|
|
|
dnf -y config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
|
|
|
|
fi
|
2023-06-24 12:05:13 +00:00
|
|
|
when: ansible_distribution in ["Fedora"]
|
2023-07-02 12:52:06 +00:00
|
|
|
tags:
|
|
|
|
- "Fedora"
|
2023-06-24 12:05:13 +00:00
|
|
|
|
2023-07-02 12:52:06 +00:00
|
|
|
#################################
|
|
|
|
# T-Pot - Install Docker Engine #
|
|
|
|
#################################
|
|
|
|
|
|
|
|
- name: T-Pot - Install Docker Engine
|
|
|
|
hosts: all
|
|
|
|
gather_facts: true
|
|
|
|
become: true
|
|
|
|
|
|
|
|
tasks:
|
2023-06-25 11:17:33 +00:00
|
|
|
- name: Install Docker Engine packages (openSUSE Tumbleweed)
|
|
|
|
package:
|
|
|
|
name:
|
|
|
|
- docker
|
2023-07-01 01:26:26 +00:00
|
|
|
- docker-bash-completion
|
|
|
|
- docker-buildx
|
|
|
|
- docker-compose
|
|
|
|
- docker-compose-switch
|
|
|
|
- liblvm2cmd2_03
|
|
|
|
- lvm2
|
2023-06-25 11:17:33 +00:00
|
|
|
state: latest
|
|
|
|
update_cache: yes
|
|
|
|
when: ansible_distribution in ["openSUSE Tumbleweed"]
|
2023-07-02 12:52:06 +00:00
|
|
|
tags:
|
|
|
|
- "openSUSE Tumbleweed"
|
2023-06-24 12:05:13 +00:00
|
|
|
|
|
|
|
- name: Install Docker Engine packages (Debian, Fedora, Ubuntu)
|
2023-06-22 18:30:18 +00:00
|
|
|
package:
|
|
|
|
name:
|
|
|
|
- docker-ce
|
|
|
|
- docker-ce-cli
|
|
|
|
- containerd.io
|
|
|
|
- docker-buildx-plugin
|
|
|
|
- docker-compose-plugin
|
2023-06-24 12:05:13 +00:00
|
|
|
state: latest
|
|
|
|
update_cache: yes
|
2023-06-22 18:30:18 +00:00
|
|
|
when: ansible_distribution in ["Debian", "Fedora", "Ubuntu"]
|
2023-07-02 12:52:06 +00:00
|
|
|
tags:
|
|
|
|
- "Debian"
|
|
|
|
- "Fedora"
|
|
|
|
- "Ubuntu"
|
2023-06-22 18:30:18 +00:00
|
|
|
|
2023-07-02 12:52:06 +00:00
|
|
|
- name: Stop Docker (All)
|
2023-06-24 12:05:13 +00:00
|
|
|
service:
|
2023-06-22 18:30:18 +00:00
|
|
|
name: docker
|
2023-07-02 12:52:06 +00:00
|
|
|
state: stopped
|
|
|
|
enabled: false
|
2023-07-01 01:26:26 +00:00
|
|
|
when: ansible_distribution in ["Debian", "Fedora", "openSUSE Tumbleweed", "Ubuntu"]
|
2023-07-02 12:52:06 +00:00
|
|
|
tags:
|
|
|
|
- "Debian"
|
|
|
|
- "Fedora"
|
|
|
|
- "openSUSE Tumbleweed"
|
|
|
|
- "Ubuntu"
|
2023-06-22 18:30:18 +00:00
|
|
|
|
|
|
|
######################################################
|
|
|
|
# T-Pot - Adjust configs, add users and groups, etc. #
|
|
|
|
######################################################
|
|
|
|
|
|
|
|
- name: T-Pot - Adjust configs, add users and groups, etc.
|
|
|
|
hosts: all
|
|
|
|
gather_facts: true
|
|
|
|
become: true
|
|
|
|
|
|
|
|
tasks:
|
2023-06-24 12:05:13 +00:00
|
|
|
- name: Create T-Pot group (All)
|
2023-06-22 18:30:18 +00:00
|
|
|
group:
|
|
|
|
name: tpot
|
|
|
|
gid: 2000
|
|
|
|
state: present
|
2023-06-25 11:17:33 +00:00
|
|
|
when: ansible_distribution in ["Debian", "Fedora", "openSUSE Tumbleweed", "Ubuntu"]
|
2023-07-02 12:52:06 +00:00
|
|
|
tags:
|
|
|
|
- "Debian"
|
|
|
|
- "Fedora"
|
|
|
|
- "openSUSE Tumbleweed"
|
|
|
|
- "Ubuntu"
|
2023-06-22 18:30:18 +00:00
|
|
|
|
2023-06-24 12:05:13 +00:00
|
|
|
- name: Create T-Pot user (All)
|
2023-06-22 18:30:18 +00:00
|
|
|
user:
|
|
|
|
name: tpot
|
|
|
|
uid: 2000
|
|
|
|
system: yes
|
|
|
|
shell: /bin/false
|
|
|
|
home: /nonexistent
|
|
|
|
group: tpot
|
2023-06-25 11:17:33 +00:00
|
|
|
when: ansible_distribution in ["Debian", "Fedora", "openSUSE Tumbleweed", "Ubuntu"]
|
2023-07-02 12:52:06 +00:00
|
|
|
tags:
|
|
|
|
- "Debian"
|
|
|
|
- "Fedora"
|
|
|
|
- "openSUSE Tumbleweed"
|
|
|
|
- "Ubuntu"
|
2023-06-22 18:30:18 +00:00
|
|
|
|
2023-06-24 12:05:13 +00:00
|
|
|
- name: Disable ssh.socket unit (Ubuntu)
|
2023-06-22 18:30:18 +00:00
|
|
|
systemd:
|
|
|
|
name: ssh.socket
|
|
|
|
state: stopped
|
|
|
|
enabled: false
|
|
|
|
when: ansible_distribution in ["Ubuntu"]
|
2023-07-02 12:52:06 +00:00
|
|
|
tags:
|
|
|
|
- "Ubuntu"
|
2023-06-22 18:30:18 +00:00
|
|
|
|
2023-06-24 12:05:13 +00:00
|
|
|
- name: Remove ssh.socket.conf file (Ubuntu)
|
2023-06-22 18:30:18 +00:00
|
|
|
file:
|
|
|
|
path: /etc/systemd/system/ssh.service.d/00-socket.conf
|
|
|
|
state: absent
|
|
|
|
when: ansible_distribution in ["Ubuntu"]
|
2023-07-02 12:52:06 +00:00
|
|
|
tags:
|
|
|
|
- "Ubuntu"
|
2023-06-22 18:30:18 +00:00
|
|
|
|
2023-06-26 02:59:52 +00:00
|
|
|
- name: Change SSH Port to 64295 (Debian, Fedora, Ubuntu)
|
2023-06-22 18:30:18 +00:00
|
|
|
lineinfile:
|
|
|
|
path: /etc/ssh/sshd_config
|
|
|
|
line: "Port 64295"
|
|
|
|
insertafter: EOF
|
|
|
|
when: ansible_distribution in ["Debian", "Fedora", "Ubuntu"]
|
2023-07-02 12:52:06 +00:00
|
|
|
tags:
|
|
|
|
- "Debian"
|
|
|
|
- "Fedora"
|
|
|
|
- "Ubuntu"
|
2023-06-22 18:30:18 +00:00
|
|
|
|
2023-06-25 11:17:33 +00:00
|
|
|
- name: Change SSH Port to 64295 (openSUSE Tumbleweed)
|
|
|
|
lineinfile:
|
|
|
|
path: /etc/ssh/sshd_config.d/port.conf
|
|
|
|
line: "Port 64295"
|
|
|
|
create: yes
|
|
|
|
when: ansible_distribution in ["openSUSE Tumbleweed"]
|
2023-07-02 12:52:06 +00:00
|
|
|
tags:
|
|
|
|
- "openSUSE Tumbleweed"
|
2023-06-25 11:17:33 +00:00
|
|
|
|
|
|
|
- name: Add T-Pot SSH port to Firewall (Fedora, openSUSE Tumbleweed)
|
2023-06-22 18:30:18 +00:00
|
|
|
firewalld:
|
|
|
|
port: 64295/tcp
|
|
|
|
permanent: yes
|
|
|
|
state: enabled
|
2023-06-25 11:17:33 +00:00
|
|
|
when: ansible_distribution in ["Fedora", "openSUSE Tumbleweed"]
|
2023-07-02 12:52:06 +00:00
|
|
|
tags:
|
|
|
|
- "Fedora"
|
|
|
|
- "openSUSE Tumbleweed"
|
2023-06-22 18:30:18 +00:00
|
|
|
|
2023-06-25 11:17:33 +00:00
|
|
|
- name: Set T-Pot default target to ACCEPT (Fedora, openSUSE Tumbleweed)
|
2023-06-22 18:30:18 +00:00
|
|
|
firewalld:
|
2023-06-24 12:05:13 +00:00
|
|
|
zone: public
|
2023-06-22 18:30:18 +00:00
|
|
|
target: ACCEPT
|
|
|
|
permanent: yes
|
2023-06-24 12:05:13 +00:00
|
|
|
state: enabled
|
2023-06-25 11:17:33 +00:00
|
|
|
when: ansible_distribution in ["Fedora", "openSUSE Tumbleweed"]
|
2023-07-02 12:52:06 +00:00
|
|
|
tags:
|
|
|
|
- "Fedora"
|
|
|
|
- "openSUSE Tumbleweed"
|
2023-06-22 18:30:18 +00:00
|
|
|
|
2023-06-24 12:05:13 +00:00
|
|
|
- name: Load kernel modules (Fedora)
|
2023-06-22 18:30:18 +00:00
|
|
|
command: modprobe -v iptable_filter
|
|
|
|
when: ansible_distribution in ["Fedora"]
|
2023-07-02 12:52:06 +00:00
|
|
|
tags:
|
|
|
|
- "Fedora"
|
2023-06-22 18:30:18 +00:00
|
|
|
|
2023-06-24 12:05:13 +00:00
|
|
|
- name: Update iptables.conf (Fedora)
|
2023-06-22 18:30:18 +00:00
|
|
|
lineinfile:
|
|
|
|
path: /etc/modules-load.d/iptables.conf
|
|
|
|
line: iptable_filter
|
|
|
|
create: yes
|
|
|
|
when: ansible_distribution in ["Fedora"]
|
2023-07-02 12:52:06 +00:00
|
|
|
tags:
|
|
|
|
- "Fedora"
|
2023-06-22 18:30:18 +00:00
|
|
|
|
2023-06-24 12:05:13 +00:00
|
|
|
- name: Update SELinux config (Fedora)
|
2023-06-22 18:30:18 +00:00
|
|
|
lineinfile:
|
|
|
|
path: /etc/selinux/config
|
|
|
|
regexp: '^SELINUX='
|
|
|
|
line: 'SELINUX=permissive'
|
|
|
|
when: ansible_distribution in ["Fedora"]
|
2023-07-02 12:52:06 +00:00
|
|
|
tags:
|
|
|
|
- "Fedora"
|
2023-06-22 18:30:18 +00:00
|
|
|
|
2023-07-02 12:52:06 +00:00
|
|
|
- name: Stop Resolved (Fedora, Ubuntu)
|
2023-06-30 23:23:57 +00:00
|
|
|
service:
|
|
|
|
name: systemd-resolved
|
|
|
|
state: stopped
|
|
|
|
when: ansible_distribution in ["Fedora", "Ubuntu"]
|
2023-07-02 12:52:06 +00:00
|
|
|
tags:
|
|
|
|
- "Fedora"
|
|
|
|
- "Ubuntu"
|
2023-06-30 23:23:57 +00:00
|
|
|
|
2023-06-24 12:05:13 +00:00
|
|
|
- name: Modify DNSStubListener in resolved.conf (Fedora, Ubuntu)
|
2023-06-22 18:30:18 +00:00
|
|
|
lineinfile:
|
|
|
|
path: /etc/systemd/resolved.conf
|
|
|
|
regexp: '^.*DNSStubListener=.*'
|
|
|
|
line: 'DNSStubListener=no'
|
|
|
|
state: present
|
|
|
|
when: ansible_distribution in ["Fedora", "Ubuntu"]
|
2023-07-02 12:52:06 +00:00
|
|
|
tags:
|
|
|
|
- "Fedora"
|
|
|
|
- "Ubuntu"
|
|
|
|
|
|
|
|
############################
|
|
|
|
# T-Pot - Restart services #
|
|
|
|
############################
|
2023-06-22 18:30:18 +00:00
|
|
|
|
2023-07-02 12:52:06 +00:00
|
|
|
- name: T-Pot - Restart services
|
|
|
|
hosts: all
|
|
|
|
gather_facts: true
|
|
|
|
become: true
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- name: Start Resolved (Fedora, Ubuntu)
|
2023-06-30 22:31:50 +00:00
|
|
|
service:
|
2023-06-30 23:23:57 +00:00
|
|
|
name: systemd-resolved
|
2023-07-02 12:52:06 +00:00
|
|
|
state: restarted
|
2023-06-30 22:31:50 +00:00
|
|
|
when: ansible_distribution in ["Fedora", "Ubuntu"]
|
2023-07-02 12:52:06 +00:00
|
|
|
tags:
|
|
|
|
- "Fedora"
|
|
|
|
- "Ubuntu"
|
|
|
|
|
|
|
|
- name: Restart Firewalld (Fedora, openSUSE Tumbleweed)
|
|
|
|
service:
|
|
|
|
name: firewalld
|
|
|
|
state: restarted
|
|
|
|
when: ansible_distribution in ["Fedora", "openSUSE Tumbleweed"]
|
|
|
|
tags:
|
|
|
|
- "Fedora"
|
|
|
|
- "openSUSE Tumbleweed"
|
2023-06-30 22:31:50 +00:00
|
|
|
|
2023-07-02 13:05:55 +00:00
|
|
|
- name: Get Firewall rules (Fedora, openSUSE Tumbleweed)
|
|
|
|
command: "firewall-cmd --list-all"
|
|
|
|
register: firewall_output
|
|
|
|
when: ansible_distribution in ["Fedora", "openSUSE Tumbleweed"]
|
|
|
|
tags:
|
|
|
|
- "Fedora"
|
|
|
|
- "openSUSE Tumbleweed"
|
|
|
|
|
|
|
|
- name: Print Firewall rules (Fedora, openSUSE Tumbleweed)
|
|
|
|
debug:
|
|
|
|
var: firewall_output.stdout_lines
|
|
|
|
when: ansible_distribution in ["Fedora", "openSUSE Tumbleweed"]
|
|
|
|
tags:
|
|
|
|
- "Fedora"
|
|
|
|
- "openSUSE Tumbleweed"
|
|
|
|
|
2023-07-02 12:52:06 +00:00
|
|
|
- name: Enable Docker Engine upon boot (All)
|
2023-06-24 12:05:13 +00:00
|
|
|
service:
|
2023-06-30 23:23:57 +00:00
|
|
|
name: docker
|
2023-07-02 12:52:06 +00:00
|
|
|
state: restarted
|
|
|
|
enabled: true
|
|
|
|
when: ansible_distribution in ["Debian", "Fedora", "openSUSE Tumbleweed", "Ubuntu"]
|
|
|
|
tags:
|
|
|
|
- "Debian"
|
|
|
|
- "Fedora"
|
|
|
|
- "openSUSE Tumbleweed"
|
|
|
|
- "Ubuntu"
|
2023-06-22 18:30:18 +00:00
|
|
|
|
2023-07-02 12:52:06 +00:00
|
|
|
- name: Restart SSH (All)
|
2023-06-24 12:05:13 +00:00
|
|
|
service:
|
2023-06-30 21:42:19 +00:00
|
|
|
name: "{{ 'sshd' if ansible_distribution in ['Debian', 'openSUSE Tumbleweed'] else 'ssh' }}"
|
2023-06-22 18:30:18 +00:00
|
|
|
state: restarted
|
|
|
|
enabled: true
|
2023-07-02 12:52:06 +00:00
|
|
|
when: ansible_distribution in ["Debian", "Fedora", "openSUSE Tumbleweed", "Ubuntu"]
|
|
|
|
tags:
|
|
|
|
- "Debian"
|
|
|
|
- "Fedora"
|
|
|
|
- "openSUSE Tumbleweed"
|
|
|
|
- "Ubuntu"
|
2023-06-22 18:30:18 +00:00
|
|
|
|
|
|
|
#######################################################################
|
|
|
|
# T-Pot - Adjust group users, bashrc, clone / update T-Pot repository #
|
|
|
|
#######################################################################
|
|
|
|
|
|
|
|
- name: T-Pot - Adjust group users, bashrc, clone / update T-Pot repository
|
|
|
|
hosts: all
|
|
|
|
gather_facts: true
|
2023-06-30 11:15:30 +00:00
|
|
|
become: false
|
2023-07-02 12:52:06 +00:00
|
|
|
tags:
|
|
|
|
- "Debian"
|
|
|
|
- "Fedora"
|
|
|
|
- "openSUSE Tumbleweed"
|
|
|
|
- "Ubuntu"
|
2023-06-22 18:30:18 +00:00
|
|
|
|
|
|
|
tasks:
|
2023-06-24 12:05:13 +00:00
|
|
|
- name: Add aliases (All)
|
2023-06-22 18:30:18 +00:00
|
|
|
blockinfile:
|
|
|
|
path: ~/.bashrc
|
|
|
|
block: |
|
|
|
|
alias dps='grc --colour=on docker ps -f status=running -f status=exited --format "table {{'{{'}}.Names{{'}}'}}\t{{'{{'}}.Status{{'}}'}}\t{{'{{'}}.Ports{{'}}'}}" | sort'
|
|
|
|
alias dpsw='watch -c bash -ic dps'
|
|
|
|
marker: "# {mark} ANSIBLE MANAGED BLOCK"
|
|
|
|
insertafter: EOF
|
|
|
|
state: present
|
2023-06-25 11:17:33 +00:00
|
|
|
when: ansible_distribution in ["Debian", "Fedora", "openSUSE Tumbleweed", "Ubuntu"]
|
2023-06-22 18:30:18 +00:00
|
|
|
|
2023-06-24 12:05:13 +00:00
|
|
|
- name: Clone / Update T-Pot repository (All)
|
2023-06-22 18:30:18 +00:00
|
|
|
git:
|
|
|
|
repo: 'https://github.com/telekom-security/tpotce'
|
|
|
|
dest: '/home/{{ ansible_user_id }}/tpotce/'
|
|
|
|
version: dev
|
|
|
|
clone: yes
|
|
|
|
update: no
|
2023-06-25 11:17:33 +00:00
|
|
|
when: ansible_distribution in ["Debian", "Fedora", "openSUSE Tumbleweed", "Ubuntu"]
|
2023-06-22 18:30:18 +00:00
|
|
|
|
2023-06-24 12:05:13 +00:00
|
|
|
- name: Add current user to Docker, T-Pot group (All)
|
2023-06-22 18:30:18 +00:00
|
|
|
become: true
|
|
|
|
user:
|
|
|
|
name: "{{ ansible_user_id }}"
|
|
|
|
groups:
|
|
|
|
- docker
|
|
|
|
- tpot
|
|
|
|
append: yes
|
2023-06-25 11:17:33 +00:00
|
|
|
when: ansible_distribution in ["Debian", "Fedora", "openSUSE Tumbleweed", "Ubuntu"]
|
2023-06-22 18:30:18 +00:00
|
|
|
|
2023-06-24 12:05:13 +00:00
|
|
|
- name: Check for non-root user id (All)
|
2023-06-22 18:30:18 +00:00
|
|
|
debug:
|
|
|
|
msg: "Detected user: '{{ ansible_user_id }}'"
|
2023-06-25 11:17:33 +00:00
|
|
|
when: ansible_distribution in ["Debian", "Fedora", "openSUSE Tumbleweed", "Ubuntu"]
|
2023-06-22 18:30:18 +00:00
|
|
|
failed_when: ansible_user_id == "root"
|