#SPDX-License-Identifier: MIT-0
---
# tasks to setup arch hosts

# Setup Crontab
- name: Install cronie
  community.general.pacman:
    name: cronie
    state: present

- name: Run cronie
  ansible.builtin.systemd_service:
    state: started
    name: cronie

- name: Enable service cronie and ensure it is not masked
  ansible.builtin.systemd_service:
    name: cronie 
    enabled: true
    masked: no

# Pacman
- name: Run full system upgrade
  community.general.pacman:
    update_cache: true
    upgrade: true

- name: Add cronjob for daily updates 
  ansible.builtin.cron:
    name: "daily full upgrade"
    user: root
    special_time: daily
    job: "pacman -Syu --noconfirm"

- name: Enable Color in pacman.conf
  ansible.builtin.lineinfile:
    path: /etc/pacman.conf
    regexp: '^#?Color'
    line: Color
    insertafter: '^\[options\]'

- name: Enable ILoveCandy in pacman.conf
  ansible.builtin.lineinfile:
    path: /etc/pacman.conf
    regexp: '^#?ILoveCandy'
    line: ILoveCandy
    insertafter: '^\[options\]'

# Fastfetch prompt
- name: Install fastfetch
  community.general.pacman:
    name: fastfetch
    state: present

- name: Create .config directory
  ansible.builtin.file:
    path: /home/alarm/.config
    state: directory
    owner: alarm
    group: alarm
    mode: '0755'

- name: Copy fastfetch config
  ansible.builtin.copy:
    src: 27.jsonc
    dest: /home/alarm/.config/27.jsonc
    owner: alarm
    group: alarm
    mode: '0744'

- name: Add welcomeprompt to .bashrc
  ansible.builtin.lineinfile:
    path: /home/alarm/.bashrc
    line: fastfetch -c /home/alarm/.config/27.jsonc

# Setup checkmk agent
- name: Copy checkmk agent
  ansible.builtin.copy:
    src: check_mk_agent 
    dest: /usr/local/bin/check_mk_agent
    owner: root
    group: root
    mode: '0755'

- name: Copy checkmk push script
  ansible.builtin.copy:
    src: checkmk_push.sh
    dest: /usr/local/bin/checkmk_push.sh
    owner: root
    group: root
    mode: '0755'

- name: Add checkmk cronjob
  ansible.builtin.cron:
    name: "checkmk push"
    user: root
    minute: "*/5"
    job: "/usr/local/bin/checkmk_push.sh"

# general tasks
- name: Install rsync
  community.general.pacman:
    name: rsync
    state: present






