---
# Common tasks for all OCI instances

- name: Update system packages
  yum:
    name: "*"
    state: latest
    update_cache: yes

- name: Install essential packages
  yum:
    name:
      - git
      - vim
      - htop
      - tmux
      - curl
      - wget
      - unzip
      - jq
      - nc
      - telnet
      - python3-pip
    state: present

- name: Set timezone
  timezone:
    name: UTC

- name: Configure firewall for internal traffic
  firewalld:
    zone: trusted
    source: 10.0.0.0/16
    permanent: yes
    state: enabled
  notify: reload firewall

- name: Open PostgreSQL port
  firewalld:
    port: 5432/tcp
    permanent: yes
    state: enabled
  notify: reload firewall

- name: Open Redis port
  firewalld:
    port: 6379/tcp
    permanent: yes
    state: enabled
  notify: reload firewall

handlers:
  - name: reload firewall
    service:
      name: firewalld
      state: reloaded
