{% from 'common/map.jinja' import root %}
{% from tpldir ~ '/map.jinja' import admin %}

admin-packages:
  pkg.installed:
    - pkgs:
      - tmux
      {% if grains['os'] != 'MacOS' %}
      - mosh
      - screen # Installed by default on OS X
      {% else %}
      - mobile-shell
      {% endif %}

{% if grains['os'] != 'MacOS' and grains.get('virtual_subtype', '') != 'Docker' %}
UTC:
    timezone.system
{% endif %}

/etc/hosts:
  file.managed:
    - user: {{ root.user }}
    - group: {{ root.group }}
    - mode: 644
    - source: salt://{{ tpldir }}/files/hosts

sshkeys-dir:
  file.directory:
    - name: {{ root.home }}/.ssh
    - user: {{ root.user }}
    - group: {{ root.group }}
    - mode: 700

sshkeys:
  file.managed:
    - name: {{ root.home }}/.ssh/authorized_keys
    - user: {{ root.user }}
    - group: {{ root.group }}
    - mode: 600
    - contents:
      {% for ssh_user in admin.ssh_users %}
      - {% include tpldir ~ '/files/ssh/' ~ ssh_user ~ '.pub' %}
      {% endfor %}
    - require:
      - file: sshkeys-dir

{% from 'common/map.jinja' import root %}
{% from tpldir ~ '/map.jinja' import admin %}

admin-packages:
  pkg.installed:
    - pkgs:
      - tmux
      - mosh
      {% if grains['os'] != 'MacOS' %}
      - screen # Installed by default on OS X
      {% endif %}

{% if grains['os'] != 'MacOS' and grains.get('virtual_subtype', '') != 'Docker' %}
UTC:
    timezone.system
{% endif %}

/etc/hosts:
  file.managed:
    - user: {{ root.user }}
    - group: {{ root.group }}
    - mode: 644
    - source: salt://{{ tpldir }}/files/hosts

sshkeys-dir:
  file.directory:
    - name: {{ root.home }}/.ssh
    - user: {{ root.user }}
    - group: {{ root.group }}
    - mode: 700

sshkeys:
  file.managed:
    - name: {{ root.home }}/.ssh/authorized_keys
    - user: {{ root.user }}
    - group: {{ root.group }}
    - mode: 600
    - contents:
      {% for ssh_user in admin.ssh_users %}
      - {% include tpldir ~ '/files/ssh/' ~ ssh_user ~ '.pub' %}
      {% endfor %}
    - require:
      - file: sshkeys-dir

Handle Homebrew renaming `mobile-shell` to `mosh`
Handle Homebrew renaming `mobile-shell` to `mosh`

Homebrew left in an alias for `mobile-shell` so the `mosh` package
actually installs correctly, but Salt's pkg.installed state then tries
to verify the installation by checking the installed packages.
That list only shows `mosh` and not the `mobile-shell` alias,
causing the state the fail.

Update to the new name, which is also consistent with everyone else.

servo/saltfs,servo/saltfs