---
- name: setup OBS worker
  hosts: obs_workers
  user: root
  vars_files:
    - "vars/{{ ansible_facts['os_family'] }}-{{ ansible_facts['distribution_major_version']}}.yml"
  tasks:
    - name: install common utilities
      zypper:
        name:
          - etckeeper
          - git
          - ltrace
          - man
          - screen
          - strace
          - tcpdump
          - tmux
          - vim

  # We need to initialize etckeeper after installing it (in Debian and other
  # distros this is done automatically)
    - name: Check if etckeeper is initialized
      stat:
        path: "/etc/.git"
      register: etckeeper_result
    - name: Initialize etckeeper
      ansible.builtin.shell: "etckeeper init; etckeeper commit initial"
      when: not etckeeper_result.stat.exists

  roles:
    - name: osmocom-obs-worker
      tags:
        - obs-worker
