- name: turn off analytics
  command: brew analytics off

- name: update
  homebrew: update_homebrew=yes

- name: tap versions
  homebrew_tap:
    tap: '{{ item }}'
  with_items: '{{ dotfiles.homebrew.taps }}'

- name: install packages
  homebrew:
    name: '{{ item }}'
    state: present
  with_items: '{{ dotfiles.homebrew.packages }}'

- name: clean up space
  command: brew cleanup

- name: get analytics state
  command: brew analytics
  register: brew_analytics

- name: turn off analytics
  command: brew analytics off
  when: '"disabled" not in brew_analytics.stdout'

- name: update
  homebrew: update_homebrew=yes

- name: tap versions
  homebrew_tap:
    tap: '{{ item }}'
  with_items: '{{ dotfiles.homebrew.taps }}'

- name: install packages
  homebrew:
    name: '{{ item }}'
    state: present
  with_items: '{{ dotfiles.homebrew.packages }}'

- name: clean up space
  command: brew cleanup

Change analytics state only if it is not disabled yet
Change analytics state only if it is not disabled yet
