Christian Boltz c34100
{% set git_repos = salt['pillar.get']('profile:web_static:git_repos') %}
Christian Boltz c34100
Christian Boltz c34100
static_master_pgks:
Christian Boltz c34100
  pkg.installed:
Christian Boltz c34100
    - pkgs:
Christian Boltz c34100
      - git
Christian Boltz c34100
      - rsync
Christian Boltz c34100
Christian Boltz c34100
/home/web_static/.ssh/id_ed25519:
Christian Boltz c34100
  file.managed:
Christian Boltz c34100
    - contents_pillar: profile:web_static:ssh_private_key
Christian Boltz c34100
    - mode: 600
Christian Boltz c34100
    - user: web_static
Christian Boltz c34100
Christian Boltz c34100
/home/web_static/.ssh/known_hosts:
Christian Boltz c34100
  file.managed:
Christian Boltz c34100
    - contents_pillar: profile:web_static:ssh_known_hosts
Christian Boltz c34100
    - mode: 644
Christian Boltz c34100
    - user: root
Christian Boltz c34100
Christian Boltz c34100
/home/web_static/bin:
Christian Boltz c34100
  file.directory:
Christian Boltz c34100
    - user: root
Christian Boltz c34100
Christian Boltz 1edcb9
static_master_cron_mailto:
Christian Boltz 1edcb9
  cron.env_present:
Christian Boltz 1edcb9
    - name: MAILTO
Christian Boltz 1edcb9
    - value: admin-auto@opensuse.org
Christian Boltz 1edcb9
    - user: web_static
Christian Boltz 1edcb9
Christian Boltz c34100
/home/web_static/bin/fetch_and_rsync_static:
Christian Boltz c34100
  cron.present:
Christian Boltz c34100
    - user: web_static
Christian Boltz c34100
    - minute: 0
Christian Boltz c34100
  file.managed:
Christian Boltz c34100
    - context:
Christian Boltz c34100
      expected_gitmodules: {{ pillar['profile']['web_static']['expected_gitmodules'] }}
Christian Boltz c34100
      server_list: {{ pillar['profile']['web_static']['server_list'] }}
Christian Boltz c34100
      git_dirs: {{ git_repos }}
Christian Boltz c34100
    - mode: 755
Christian Boltz c34100
    - source: salt://profile/static/files/git_pull_and_update.sh
Christian Boltz c34100
    - template: jinja
Christian Boltz c34100
    - user: root
Christian Boltz c34100
Christian Boltz c34100
/home/web_static/git:
Christian Boltz c34100
  file.directory:
Christian Boltz c34100
    - user: web_static
Christian Boltz c34100
Christian Boltz c34100
# clone git repos
Christian Boltz c34100
{% for dir, data in git_repos.items() %}
Christian Boltz c34100
{{ data.repo }}:
Christian Boltz c34100
  # salt 2018.3.3 introduced git.cloned - switch once our salt is new enough
Christian Boltz c34100
  git.latest:
Christian Boltz c34100
    - branch: {{ data.get('branch', 'master') }}
Christian Boltz c34100
    - target: /home/web_static/git/{{ dir }}
Christian Boltz c34100
    # When checking out a non-default branch, salt will create a local branch based on HEAD by default.
Christian Boltz c34100
    # We need to specify "rev" to ensure we get the branch we want, and to make it tracking the branch from origin.
Christian Boltz c34100
    - rev: {{ data.get('branch', 'master') }}
Christian Boltz c34100
    - user: web_static
Christian Boltz c34100
{% endfor %}