---
# file: kontor-ansible.yml
- hosts: localhost
  remote_user: root
  tasks:
    - name: create group kontor
      group:
        name: kontor
        state: present

    - name: create user kontor
      user:
        name: kontor
        home: /home/kontor
        shell: /bin/bash
        state: present
        #        generate_ssh_key: yes
        #        ssh_key_bits: 4096
        #        ssh_key_file: .ssh/id_rsa

    - name: create log directory
      file:
        path: /var/log/kontor
        state: directory
        owner: kontor
        group: kontor
        mode: 0775
        recurse: true

    - name: create run directory
      file:
        path: /var/run/kontor
        state: directory
        owner: kontor
        group: kontor
        mode: 0775
        recurse: true

    - name: create directory
      file:
        path: /home/kontor/production
        state: directory
        owner: kontor
        group: kontor
        mode: 0775
        recurse: false

    - name: copy binary
      copy:
        src: bin/kontor
        dest: /home/kontor/production/kontor
        mode: 0775

    - name: copy templates
      copy:
        src: templates
        dest: /home/kontor/production/kontor/templates
        mode: 0775
