#! /usr/bin/env ansible-playbook --ask-vault-pass

## ---------------------------------------------
## Ansible playbook for setting up a new machine
## ---------------------------------------------
---
- name: Configure a new machine
  hosts: localhost

  # include all variables first to allow overriding
  vars_files:
    - vars/atom.yml
    - vars/dotfiles.yml

  handlers:
    - name: restart dock
      command: killall Dock
      when: ansible_distribution == 'MacOSX'

  tasks:
    ## ------------------------
    ## Run macOS specific tasks
    ## ------------------------
    - include: tasks/macbook.yml
      tags: osx
      when: ansible_distribution == 'MacOSX'

    ## -------------------------
    ## Run Ubuntu specific tasks
    ## -------------------------
    - include: tasks/ubuntu.yml
      tags: ubuntu
      when: ansible_distribution == 'Ubuntu'

    ## -----------------------------------------------
    ## Include vars_file for overriding default values
    ## -----------------------------------------------
    - name: include override vars (if it exists)
      tags: always
      include_vars: "{{ item }}"
      with_first_found:
        - files:
            - ../vars/override.yml
          skip: true # don't error if not found

    ## --------------------------
    ## Include common task files
    ## --------------------------
    - include: tasks/atom.yml
      tags: common

    - include: tasks/dotfiles.yml
      tags: common

    - include: tasks/ssh.yml
      tags: common

    - include: tasks/vim.yml
      tags: common

#! /usr/bin/env ansible-playbook --ask-vault-pass

## ---------------------------------------------
## Ansible playbook for setting up a new machine
## ---------------------------------------------
---
- name: Configure a new machine
  hosts: localhost

  # include all variables first to allow overriding
  vars_files:
    - vars/atom.yml
    - vars/dotfiles.yml

  handlers:
    - name: restart dock
      command: killall Dock
      when: ansible_distribution == 'MacOSX'

  tasks:
    ## ------------------------
    ## Run macOS specific tasks
    ## ------------------------
    - include: tasks/macbook.yml
      tags: osx
      when: ansible_distribution == 'MacOSX'

    ## -------------------------
    ## Run Ubuntu specific tasks
    ## -------------------------
    - include: tasks/ubuntu.yml
      tags: ubuntu
      become: true
      when: ansible_distribution == 'Ubuntu'

    ## -----------------------------------------------
    ## Include vars_file for overriding default values
    ## -----------------------------------------------
    - name: include override vars (if it exists)
      tags: always
      include_vars: "{{ item }}"
      with_first_found:
        - files:
            - ../vars/override.yml
          skip: true # don't error if not found

    ## --------------------------
    ## Include common task files
    ## --------------------------
    - include: tasks/atom.yml
      tags: common

    - include: tasks/dotfiles.yml
      tags: common

    - include: tasks/ssh.yml
      tags: common

    - include: tasks/vim.yml
      tags: common

Add `become` for Ubuntu tasks
Add `become` for Ubuntu tasks
