- name: Install git
  homebrew:
    name: git
    state: present

- name: Set name in global git configuration
  git_config:
    name: user.name
    scope: global
    value: "Andrew Bell"

- name: Set email in global git configuration
  git_config:
    name: user.email
    scope: global
    value: "{{ github.user_email }}"
  no_log: True

- name: Check for github entry in keychain
  command: >
    /usr/bin/security find-internet-password
    -a "{{ github.keychain.account }}"
    -s "{{ github.keychain.server }}"
  ignore_errors: yes
  register: result
  no_log: True

- name: Add github entry to keychain
  command: >
    /usr/bin/security add-internet-password
    -a "{{ github.keychain.account }}"
    -s "{{ github.keychain.server }}"
    -w "{{ github.keychain.password }}"
    -r "{{ github.keychain.protocol }}"
    -T "{{ github.keychain.application }}"
  when: result|failed
  no_log: True

- name: Install git
  homebrew:
    name: git
    state: present

- name: We're not using a Github API token for Homebrew
  lineinfile:
    path: "{{ ansible_user_dir }}/.bash_profile"
    regexp: '^export HOMEBREW_NO_GITHUB_API'
    line: 'export HOMEBREW_NO_GITHUB_API=1'

- name: Set name in global git configuration
  git_config:
    name: user.name
    scope: global
    value: "Andrew Bell"

- name: Set email in global git configuration
  git_config:
    name: user.email
    scope: global
    value: "{{ github.user_email }}"
  no_log: True

- name: Check for github entry in keychain
  command: >
    /usr/bin/security find-internet-password
    -a "{{ github.keychain.account }}"
    -s "{{ github.keychain.server }}"
  ignore_errors: yes
  register: result
  changed_when: false
  no_log: True

- name: Add github entry to keychain
  command: >
    /usr/bin/security add-internet-password
    -a "{{ github.keychain.account }}"
    -s "{{ github.keychain.server }}"
    -w "{{ github.keychain.password }}"
    -r "{{ github.keychain.protocol }}"
    -T "{{ github.keychain.application }}"
  when: result|failed
  no_log: True

Add envvar to turn off github api
Add envvar to turn off github api
