Skip to content

Commit

Permalink
finds current git branch, adds it to slack notification
Browse files Browse the repository at this point in the history
  • Loading branch information
acozine committed Feb 9, 2024
1 parent e4585c4 commit d9d0139
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions playbooks/nginxplus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,27 @@
- ../group_vars/nginxplus/main.yml

pre_tasks:
- name: stop playbook if you didn't use --limit
fail:
msg: "you must use -l or --limit"
when: ansible_limit is not defined
run_once: true

- name: tell infrastructure and ansible-alerts the playbook is starting
community.general.slack:
token: "{{ vault_tower_slack_token }}"
msg: "Ansible is now running `{{ ansible_play_name }}` with the `{{ ansible_run_tags }}` tag on {{ inventory_hostname }}"
channel: "{{ item }}"
loop: "{{ slack_alerts_channel }}"
tags: always
- name: prepare to update loadbalancer config
block:
- name: find the git branch
local_action: ansible.builtin.command git rev-parse --abbrev-ref HEAD
run_once: true
register: git_branch

- name: stop playbook if you didn't use --limit
fail:
msg: "you must use -l or --limit"
when: ansible_limit is not defined
run_once: true

- name: tell infrastructure and ansible-alerts the playbook is starting
community.general.slack:
token: "{{ vault_tower_slack_token }}"
msg: "Ansible is now running `{{ ansible_play_name }}` from the `{{ git_branch.stdout }}` branch with the `{{ ansible_run_tags }}` tag on {{ inventory_hostname }}"
channel: "{{ item }}"
loop: "{{ slack_alerts_channel }}"
tags: always
become: false

# updates existing load balancer
roles:
Expand Down

0 comments on commit d9d0139

Please sign in to comment.