---
- hosts: localhost
  gather_facts: yes

  tasks:
    # With Ansible 2.0, this can hopefully become easily distro-independent
    # via the 'package' module:
    # https://docs.ansible.com/ansible/package_module.html
    - name: install pip
      when: ansible_os_family == "Archlinux"
      pacman:
        name: python2-pip
      become: yes
    - name: install pip (Arch)
      when: ansible_os_family == "Ubuntu"
      apt:
        name: python-pip
      become: yes
    - name: install python and pip (OS X)
      when: ansible_os_family == "Darwin"
      homebrew:
        name: python

    - name: install boto
      pip:
        # Boto is silently not supported in Python 3.
        # https://github.com/boto/boto/issues/3433
        executable: pip2
        name: boto
      become: yes
    - name: install six
      pip:
        executable: pip2
        name: six
      become: yes
    - name: ensure .ssh directory exists
      file:
        dest: ~/.ssh
        owner: "{{ansible_user_id}}"
        mode: u=rwx,g=,o=
        state: directory
    - name: install ssh keys (VPN Server)
      copy:
        content: "{{ lookup('hashi_vault', 'secret=secret/ssh/vpnserver').private_key }}"
        dest: ~/.ssh/VPNServer.pem
        owner: "{{ansible_user_id}}"
        mode: u=r,g=,o=
    - name: install ssh keys (aws_mturk)
      copy:
        content: "{{ lookup('hashi_vault', 'secret=secret/ssh/mturk').private_key }}"
        dest: ~/.ssh/aws_mturk.pem
        owner: "{{ansible_user_id}}"
        mode: u=r,g=,o=
    # This is just a super useful utility.
    - name: install ansible-shell
      pip:
        executable: pip2
        name: ansible-shell
      become: yes
