Ansible Test - Playbook-call-slack

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"

좋은 웹페이지 즐겨찾기