You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

124 lines
3.5 KiB

{{ "{% set privkey_path = '" ~ "{}".format(salt.pillar.get("saltbox:master:pillar:git_pillar_privkey")) ~ " %}" }}
{% raw %}
---
{% set telegram = salt.pillar.get("telegram") %}
{% set remote_addr = salt.pillar.get("remote_addr") %}
{% set update_git_pillar = salt.pillar.get("update_git_pillar") %}
{% set project_trigger = salt.pillar.get("triggered_by:project") %}
{% set last_commit_sha = salt.pillar.get("triggered_by:last_commit_sha") %}
{% set committer = salt.pillar.get("triggered_by:committer") %}
{% set commit_message = salt.pillar.get("triggered_by:commit_message") %}
{% set build_pipeline_name = salt.pillar.get("build:pipeline_name") %}
{% set build_job_name = salt.pillar.get("build:job_name") %}
{% set build_name = salt.pillar.get("build:name") %}
{% set build_id = salt.pillar.get("build:id") %}
fire update event:
salt.runner:
- name: event.send
- tag: "hook/fileserver/update/begin"
- data:
src_ip: "{{ remote_addr }}"
triggered_by:
project: "{{ project_trigger }}"
commit_ref: "{{ last_commit_sha }}"
commit_message: "{{ commit_message }}"
committer: "{{ committer }}"
build:
pipeline_name: "{{ build_pipeline_name }}"
job_name: "{{ build_job_name }}"
name: "{{ build_name }}"
id: "{{ build_id }}"
reset pillar checkout:
salt.function:
- name: git.reset
- tgt: "roles:salt_master"
- tgt_type: "grain"
- kwarg:
cwd: /srv/salt/pillars
identity: "{{ privkey_path }}"
opts: "--hard origin/master"
update pillar checkout:
salt.function:
- name: git.pull
- tgt: "roles:salt_master"
- tgt_type: "grain"
- kwarg:
cwd: /srv/salt/pillars
identity: "{{ privkey_path }}"
clear git locks:
salt.runner:
- name: cache.clear_git_lock
- role: gitfs
- type: update
update fileserver:
salt.runner:
- name: fileserver.update
sync grains:
salt.runner:
- name: saltutil.sync_grains
refresh grains:
salt.function:
- name: saltutil.refresh_grains
- tgt: "*"
sync modules:
salt.runner:
- name: saltutil.sync_modules
refresh modules:
salt.function:
- name: saltutil.refresh_modules
- tgt: "*"
{% if update_git_pillar %}
fire pillar update event:
salt.runner:
- name: event.send
- tag: "hook/git_pillar/update/begin"
- data:
src_ip: "{{ remote_addr }}"
triggered_by:
project: "{{ project_trigger }}"
commit_ref: "{{ last_commit_sha }}"
commit_message: "{{ commit_message }}"
committer: "{{ committer }}"
build:
pipeline_name: "{{ build_pipeline_name }}"
job_name: "{{ build_job_name }}"
name: "{{ build_name }}"
id: "{{ build_id }}"
update git pillar:
salt.runner:
- name: git_pillar.update
sync pillar:
salt.runner:
- name: saltutil.sync_pillar
refresh pillar:
salt.function:
- name: saltutil.refresh_pillar
- tgt: "*"
{% endif %}
telegram notification:
salt.runner:
- name: event.send
- tag: "notify/telegram"
- data:
message: |
Fileserver update completed! Triggered by commit `{{ last_commit_sha }}` by `{{ committer }}` on `{{ project_trigger }}`.
Built via pipeline `{{ build_pipeline_name }}`, job `{{ build_job_name }}`.
https://concourse.dev.maio.me/teams/main/pipelines/{{ build_pipeline_name }}/jobs/{{ build_job_name }}/
---
Commit {{ last_commit_sha }} by {{ committer }}:
{{ commit_message }}
{% endraw %}