Ansible Test - Playbook-call-slack

CodingDaddy·2022년 3월 22일
0

Ansible

목록 보기
11/11
post-thumbnail

Ansible Plabybook에서 Slack을 호출하기

기본 msg 호출하기

[call-slack-playbook.yml]

- name: Call Slack test
  hosts: api-servers
  tasks:
    - name: Initial Threaded Slack message
      community.general.slack:
        channel: '#sre-alarm'
        token: xoxb-1231231231-abcde
        msg: 'call message from ansible-playbook'
      register: slack_response

[Execution]

ansible-playbook call-slack-playbook.yml -i inventory


msg 메시지에 파라미터 삽입

- hosts: api-servers
  gather_facts: no
  tasks:
  - name: Initial Threaded Slack message
    community.general.slack:
      channel: '#sre-alarm'
      token: xoxb-1231231231-abcde
      msg: "executed: run.sh on {{ nodes }}"
    register: slack_response

[Execution]

ansible-playbook call-slack-playbook.yml -i inventory --extra-vars "nodes=api-server-1"

profile
Creative - DevOps in Korea

0개의 댓글