Answers: <p>GitLab is probably not the right tool for this. GitLab build pipelines are designed to produce output, not manage state on various servers.  What system did you use to install and configure gitlab-runner on each of these servers? This is the sort of tool you're looking for to manage all of these servers.</p>
  
Answers: CC BY-SA 4.0
Answers: 2023-01-28T16:12:18.003Z
Answers: you are right, i'm using docker swarm instead, just run the gitlab-runner on leader node to deploy service.
Answers: Charles Bao
Answers: CC BY-SA 4.0
Answers: 2021-11-16T19:57:34.793Z
Answers: 2021-11-16T19:57:34.793Z
Answers: Segfault
Body: <p>I have several VMs running <code>gilab-runner</code>, and I'm using <code>gitlab-ci</code> to deploy microservices into those VMs. Now I want to monitore those VMs with prometheus and grafana, but i need to setup <code>node-exporter/cadvisor</code> etc. service into those VMs.</p>
  <p>My idea is using gitlab-ci to define a common job for those VMs.</p>
  <p>I have already write the <code>docker-compose.yml</code> and <code>.gitlab-ci.yml</code>.</p>
  <pre class="lang-yaml prettyprint-override"><code>version: '3.8'
  
  services:
    node-exporter:
      image: prom/node-exporter:latest
      container_name: node-exporter
      restart: unless-stopped
      volumes:
        - /proc:/host/proc:ro
        - /sys:/host/sys:ro
        - /:/rootfs:ro
      command:
        - '--path.procfs=/host/proc'
        - '--path.rootfs=/rootfs'
        - '--path.sysfs=/host/sys'
        - '--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)'
      ports:
        - &quot;9100:9100&quot;
  
    cadvisor:
      image: google/cadvisor
      container_name: cadvisor
      restart: unless-stopped
      volumes:
        - /:/rootfs:ro
        - /var/run:/var/run:rw
        - /sys:/sys:ro
        - /var/lib/docker/:/var/lib/docker:ro
        - /dev/disk/:/dev/disk:ro
      ports:
        - &quot;8080:8080&quot;
  </code></pre>
  <pre class="lang-yaml prettyprint-override"><code>deploy-workers:
    tags:
      - worker
    stage: deploy-workers
    script:
      - docker-compose -f docker-compose.worker.yaml pull
      - docker-compose -f docker-compose.worker.yaml down
      - docker-compose -f docker-compose.worker.yaml up -d
  </code></pre>
  <p>Then I register the runner in all my VMs with <code>worker</code> tag.</p>
  <p>However, only one worker job is triggered during ci.</p>
  <p>I have about <code>20</code> VMs to go.</p>
  <p>Do anyone have suggestions?</p>
  
Tags: <gitlab-ci-runner>
Title: how to deploy same job on all my runners?
UserDisplayName: Charles Bao
ThreadText: # how to deploy same job on all my runners?
  
  (Asked by: username_0 on 2021-11-15)
  
  I have several VMs running `gilab-runner`, and I'm using `gitlab-ci` to deploy microservices into those VMs. Now I want to monitore those VMs with prometheus and grafana, but i need to setup `node-exporter/cadvisor` etc. service into those VMs.
  
  My idea is using gitlab-ci to define a common job for those VMs.
  
  I have already write the `docker-compose.yml` and `.gitlab-ci.yml`.
  
  ```yaml
  version: '3.8'
  
  services:
    node-exporter:
      image: prom/node-exporter:latest
      container_name: node-exporter
      restart: unless-stopped
      volumes:
        - /proc:/host/proc:ro
        - /sys:/host/sys:ro
        - /:/rootfs:ro
      command:
        - '--path.procfs=/host/proc'
        - '--path.rootfs=/rootfs'
        - '--path.sysfs=/host/sys'
        - '--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)'
      ports:
        - "9100:9100"
  
    cadvisor:
      image: google/cadvisor
      container_name: cadvisor
      restart: unless-stopped
      volumes:
        - /:/rootfs:ro
        - /var/run:/var/run:rw
        - /sys:/sys:ro
        - /var/lib/docker/:/var/lib/docker:ro
        - /dev/disk/:/dev/disk:ro
      ports:
        - "8080:8080"
  
  ```
  
  ```yaml
  deploy-workers:
    tags:
      - worker
    stage: deploy-workers
    script:
      - docker-compose -f docker-compose.worker.yaml pull
      - docker-compose -f docker-compose.worker.yaml down
      - docker-compose -f docker-compose.worker.yaml up -d
  
  ```
  
  Then I register the runner in all my VMs with `worker` tag.
  
  However, only one worker job is triggered during ci.
  
  I have about `20` VMs to go.
  
  Do anyone have suggestions?
  
  **Tags:** gitlab-ci-runner
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-11-16. Score: 0
  
  GitLab is probably not the right tool for this. GitLab build pipelines are designed to produce output, not manage state on various servers. What system did you use to install and configure gitlab-runner on each of these servers? This is the sort of tool you're looking for to manage all of these servers.
  
  > **Comments:**
  > **username_0**: you are right, i'm using docker swarm instead, just run the gitlab-runner on leader node to deploy service.  
  
  ---
  
  