---
#
# all actions
#
- hosts: all
  become: true
  tasks:
    - name: set eth1 interface
      blockinfile:
        path: /etc/network/interfaces
        block: |
          auto eth1
          iface eth1 inet static
              address 172.16.1.7
              netmask 255.255.255.0
      register: eth1_added
    - name: restart network service
      service:
        name: networking
        state: restarted
      when: eth1_added.changed
    - name: install deps
      apk:
        name: python-dev,python3-dev,py-virtualenv,nginx,supervisor,build-base,musl-dev,gcc,linux-headers,libffi,libffi-dev, shadow, git, postgresql-dev, postgresql-client, libmemcached-dev, zlib-dev
        update_cache: yes
    - name: create etc supervisor.d folder
      file:
        path: /etc/supervisor.d
        state: directory
    - name: starts supervisord
      service:
        name: supervisord
        state: started
    - name: Set authorized key for user vagrant copying it from current user
      authorized_key:
        user: vagrant
        state: present
        key: "{{ lookup('file', lookup('env','HOME') + '/.ssh/id_rsa.pub') }}"
