---

- name: Check if calibration repo exists
  stat:
    path: /etc/zoox/calibration
  register: calibration_directory

- name: Stash any local calibration edits
  command: git stash --all
  args:
    chdir: /etc/zoox/calibration
  when: calibration_directory.stat.exists
  register: git_stash
  changed_when: "'No local changes to save' not in git_stash.stdout"
  failed_when: false

# Updates to the latest on origin/master
- name: Sync calibration repo
  git:
    repo: git@git.zooxlabs.com:zooxco/calibration.git
    dest: "/etc/zoox/calibration"
    update: yes
    version: "{{ calibration_repo_version }}"
    accept_hostkey: yes
    # ug=rwx,o=rx. this permits multiple zoox-group users to run the setup
    # script on a shared machine.
    umask: "002"
