Files
activecm-rita/installer/install_scripts/install_pre.yml
T
Liza Tsibur 2bd5475e76 Installer and Import Logic Updates (#90)
* Disable permission flag checks on imported logs (#86)

* Disable permission flag checks on imported logs

* Display individual log errors even if there are no viable logs

---------

Co-authored-by: Naomi Kramer <naomi@activecountermeasures.com>

* Installer Import Logic Updates (#89)

* rename sshprep to sshprep.sh

* installer updates

removed mass upgrades, cleaned up installer, removed references to unsupported OS's, improved error handling and usage messages

* threat intel feed error handling

* cleaned up installer scripts and improved helper functions

* Update ansible-installer.sh

---------

Co-authored-by: Naomi Kramer <naomi@activecountermeasures.com>
2026-01-20 17:50:56 -07:00

235 lines
7.9 KiB
YAML

# ansible playbook that performs pre-installation tasks for RITA
- name: "RITA Pre: System prep and checks"
hosts: "{{ install_hosts }}"
become: true
vars:
ansible_python_interpreter: /bin/python3
# early tasks for checking system compatibility
pre_tasks:
- name: "RITA Pre: Checking Linux distribution"
ansible.builtin.fail:
msg: "Distribution {{ ansible_distribution }} is not supported, please see the documentation for supported distributions."
when:
- ansible_distribution != 'CentOS'
- ansible_distribution != 'Rocky'
- ansible_distribution != 'Ubuntu'
- ansible_distribution != 'RedHat'
- ansible_distribution != 'AlmaLinux' #NOTE: legacy support for AlmaLinux 8 only
tags:
- linux
- name: "RITA Pre: Checking Linux distribution version"
ansible.builtin.fail:
msg: "Distribution {{ ansible_distribution }} {{ ansible_distribution_major_version }} is not supported."
when:
- >
(ansible_distribution == 'Ubuntu' and ansible_distribution_major_version not in ['22', '24']) or
(ansible_distribution == 'CentOS' and ansible_distribution_major_version != '9') or
(ansible_distribution == 'RedHat' and ansible_distribution_major_version not in ['8', '9']) or
(ansible_distribution == 'AlmaLinux' and ansible_distribution_major_version != '8')
tags:
- linux
- name: "RITA Pre: Check CPU architecture"
ansible.builtin.fail:
msg: "CPU architecture {{ ansible_architecture }} is not supported."
when: ( ansible_architecture != "x86_64" ) #and ansible_architecture != "aarch64" ) # "aarch64" for pi. #pi0w is armv6l. i386. amd64?
tasks:
# Add repositories
# Note that apt-key is deprecated and that directly downloading the key to trusted.gpg.d WITH A .asc EXTENSION is the correct way now.
- name: "RITA Pre: Download Docker Ubuntu GPG apt key"
block:
- name: "RITA Pre: Download Docker Ubuntu GPG apt key with get_url module"
get_url:
url: https://download.docker.com/linux/ubuntu/gpg
dest: /etc/apt/trusted.gpg.d/docker-ubuntu.asc
mode: "0644"
force: true
rescue:
- name: "RITA Pre: Download failed with get_url module. Falling back to curl"
shell: curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/trusted.gpg.d/docker-ubuntu.asc
when: ansible_distribution == 'Ubuntu'
tags:
- packages
- linux
- linuxdeb
- name: "RITA Pre: Add Docker Repository to Ubuntu"
apt_repository:
repo: deb https://download.docker.com/linux/{{ ansible_distribution|lower }} {{ ansible_distribution_release }} stable
state: present
when: ansible_distribution == 'Ubuntu'
tags:
- packages
- linux
- linuxdeb
- name: "RITA Pre: Add Docker Repository to Centos and Rocky distributions" #Alma is included for legacy support
yum_repository:
name: docker-ce
description: Docker package repository
gpgkey: https://download.docker.com/linux/centos/gpg
baseurl: https://download.docker.com/linux/centos/$releasever/$basearch/stable/
state: present
enabled: true
when: ansible_distribution == 'CentOS' or ansible_distribution == 'Rocky' or ansible_distribution == 'AlmaLinux'
tags:
- packages
- linux
- linuxrpm
- name: "RITA Pre: Add Docker Repository to RHEL distribution"
yum_repository:
name: docker-ce
description: Docker package repository
gpgkey: https://download.docker.com/linux/rhel/gpg
baseurl: https://download.docker.com/linux/rhel/$releasever/$basearch/stable/
state: present
enabled: true
when: ansible_distribution == 'RedHat'
tags:
- packages
- linux
- linuxrpm
# Install docker
- name: "RITA Pre: Install docker on Ubuntu"
block:
- name: "RITA Pre: Uninstall unofficial docker packages on Ubuntu"
apt:
name:
- docker-client
- docker-client-latest
- docker-common
- docker-compose
- docker-compose-v2
- docker-doc
- docker-engine
- docker-latest
- docker-latest-logrotate
- docker-logrotate
- docker.io
- podman-docker
state: absent
update_cache: true
cache_valid_time: 3600
tags:
- docker
- linux
- linuxdeb
- name: "RITA Pre: Install docker-ce on Ubuntu"
apt:
name:
- docker-ce
- docker-ce-cli
- docker-compose-plugin
- containerd.io
state: latest
update_cache: true
cache_valid_time: 3600
tags:
- docker
- linux
- linuxdeb
- name: "RITA Pre: Install docker modules for Python on Ubuntu"
apt:
name:
- python3-docker
- python3-requests
tags:
- docker
- linux
- linuxdeb
when: ansible_distribution == 'Ubuntu'
- name: "RITA Pre: Install docker on rpm-based distributions"
block:
- name: "RITA Pre: Uninstall unofficial docker packages on rpm-based distributions"
yum:
name:
- docker-client
- docker-client-latest
- docker-common
- docker-compose
- docker-compose-v2
- docker-doc
- docker-engine
- docker-latest
- docker-latest-logrotate
- docker-logrotate
- docker.io
- docker
- podman-docker
- podman
- runc
state: absent
update_cache: true
tags:
- docker
- linux
- linuxrpm
- name: "RITA Pre: Install docker-ce on rpm-based distributions"
yum:
name:
- docker-ce
- docker-ce-cli
- docker-buildx-plugin
- docker-compose-plugin
- containerd.io
state: latest
update_cache: true
tags:
- docker
- linux
- linuxrpm
when: ansible_distribution == 'CentOS' or ansible_distribution == 'RedHat' or ansible_distribution == 'Rocky' or ansible_distribution == 'AlmaLinux'
- name: "RITA Pre: Start and enable docker in systemd"
systemd:
name: docker
state: started
enabled: yes
tags:
- docker
- linux
- linuxdeb
- linuxrpm
- name: "RITA Pre: Transfer docker-compose script to target system for backwards compatibility"
copy:
src: docker-compose
dest: /usr/local/bin/docker-compose
owner: root
group: root
mode: 0755
tags:
- docker
- linux
- linuxdeb
- linuxrpm
# TODO: Fix and add this back in after RITA#65 is done
# #This keypair will be used for all transfers between all zeek sensors and all achunter systems.
# #Note that if there's an existing key it will not be overwritten. Keypair will be placed in the playbook directory.
# #Note: formerly used {{ playbook_dir }}
# - name: "RITA Pre: Generate ssh keypair for log transfers"
# local_action:
# module: "user"
# name: "{{ lookup('env','USER') }}"
# generate_ssh_key: true
# ssh_key_type: "rsa"
# ssh_key_bits: 4096
# ssh_key_file: "{{ lookup('env', 'PWD') }}/id_rsa_dataimport"
# # when: ansible_connection != "local"
# tags:
# - docker
# - linux
# - linuxdeb
# - linuxrpm