AllInfo
Main: Info Blog Temp Mail


wrk 2024-10-07 18-16-47

  name: Install Blackbox Exporter
   hosts: all
  become: yes
  tasks:
    - name: Copy Blackbox Exporter from local file
      copy:
        src: /path/to/local/blackbox_exporter-{{ version }}-linux-amd64.tar.gz
        dest: /tmp/blackbox_exporter.tar.gz

    - name: Extract Blackbox Exporter
      unarchive:
        src: /tmp/blackbox_exporter.tar.gz
        dest: /usr/local/bin/
        remote_src: yes

    - name: Move binary to /usr/local/bin
      command: mv /usr/local/bin/blackbox_exporter-{{ version }}-linux-amd64/blackbox_exporter /usr/local/bin/
      args:
        removes: /usr/local/bin/blackbox_exporter

    - name: Create Blackbox Exporter configuration file
      copy:
        dest: /etc/prometheus/blackbox.yml
        content: |
          modules:
            tcp_connect:
              prober: tcp
              timeout: 1s

            ping4:
              prober: icmp
              timeout: 3s
              icmp:
                preferred_ip_protocol: ip4
                ip_protocol_fallback: false
        owner: root
        group: root
        mode: '0644'

    - name: Create systemd service for Blackbox Exporter
      copy:
        dest: /etc/systemd/system/blackbox_exporter.service
        content: |
          [Unit]
          Description=Blackbox Exporter

          [Service]
          ExecStart=/usr/local/bin/blackbox_exporter --config.file=/etc/prometheus/blackbox.yml --web.listen-address=:9988
          Restart=always

          [Install]
          WantedBy=multi-user.target
        owner: root
        group: root
        mode: '0644'

    - name: Start and enable Blackbox Exporter service
      systemd:
        name: blackbox_exporter.service
        state: started
        enabled: yes

    - name: Open port 9988 for Blackbox Exporter in the firewall (if applicable)
      firewalld:
        port: 9988/tcp
        permanent: yes
        state: enabled

    - name: Reload firewalld to apply changes (if applicable)
      command: firewall-cmd --reload


3.145.108.87 / 2024-12-22_20-59-33 UTC.