Select Page

Intended for Ubuntu and Debian

- name: start prometheus node-exporter in docker
  hosts: newinstance
  become: yes
  become_method: sudo
  gather_facts: no
  vars:
    home_dir: "/here/your/home"

  tasks:
  - name: show hosts
    debug: msg="play_hosts={{play_hosts}}"

  - name: remove possible old pip
    apt:
      name: python-pip
      state: absent
      purge: yes

  - name: download python program for installing latest pip 
    get_url:
      url: "https://bootstrap.pypa.io/get-pip.py"
      dest: "{{home_dir}}"
      mode: 0550

  - name: install latest pip
    command: "bash -c 'sudo python {{home_dir}}/get-pip.py'"
    
  - name: install docker-py
    pip:
      name: docker-py
      state: present
      version: 1.7.0
    become: yes
    
  - name: install docker-compose
    pip:
      name: docker-compose
      state: present
      version: 1.7.0
    become: yes

  - name: start node exporter
    docker_container:
      name: node-exporter
      image: prom/node-exporter
      state: started
      restart_policy: unless-stopped
      pull: true
      ports:
      - 9100:9100
      network_mode: host