Coder Social home page Coder Social logo

Comments (8)

marcelbrueckner avatar marcelbrueckner commented on May 14, 2024 1

I quickly hacked something together to make this work. I say hacked as I'm not too deep into your role and I'm unsure if this is the way to go for adding that feature. However, it's looking quite ok for a midnight development session :)

  1. Added my services configuration as docker_services to gitlab_runner_runners

    gitlab_runner_runners:
      - name: "{{ inventory_hostname }}-docker"
        executor: docker
        # ... some other config omitted for readability ...
        docker_services:
          - name: docker:20.10.12-dind
            command: ["--insecure-registry=10.0.0.0/24"]
  2. Created a template file templates/config.runners.docker.services.j2

    {% for service in gitlab_runner.docker_services %}
        [[runners.docker.services]]
    {% for attr in service %}
          {{ attr }} = {{ service[attr] | to_json }}
    {% endfor %}
    {% endfor %}
  3. Added the following to tasks/update-config-runner.yml

    # Task named "{{ runn_name_prefix }} Set runner docker network option" comes before
    
    #### [[runners.docker.services]] section ####
    - name:  "{{ runn_name_prefix }} Set additional services"
      blockinfile:
        dest: "{{ temp_runner_config.path }}"
        content: "{{ lookup('template', 'config.runners.docker.services.j2') if gitlab_runner.docker_services is defined }}"
        state: "{{ 'present' if gitlab_runner.docker_services is defined else 'absent' }}"
        marker: "# {mark} runners.docker.services"
        insertafter: EOF
      check_mode: no
      notify:
      - restart_gitlab_runner
      - restart_gitlab_runner_macos
    
    #### [runners.custom_build_dir] section ##### comes next

That's it. This looks like so in my GitLab runner configuration and works quite well for my needs.

[[runners]]
  name = "runner-docker"
  executor = "docker"
  # ... some other config omitted for readability ...
  [runners.cache]
  [runners.docker]
    volumes = ["/root/.docker/config.json:/root/.docker/config.json:ro", "/certs/client", "/cache"]
    image = "docker:20.10.12"
    privileged = true
    disable_entrypoint_overwrite = false
    oom_kill_disable = false

# BEGIN runners.docker.services
    [[runners.docker.services]]
      name = "docker:20.10.12-dind"
      command = ["--insecure-registry=10.0.0.1/8"]
# END runners.docker.services

from ansible-gitlab-runner.

riemers avatar riemers commented on May 14, 2024 1

If your happy with the code and tested it, no reason not to make a PR for it. I have reverted PR's in the past because of issues but that is the point of the test and its a community effort :)

from ansible-gitlab-runner.

solidnerd avatar solidnerd commented on May 14, 2024

ping @riemers

from ansible-gitlab-runner.

riemers avatar riemers commented on May 14, 2024

This does sound a lot like one of the open issues, where multiple instances are created where it doesn't work with. I believe it is this one #85 which has no fix for it yet. Would take some time to fix too, which i sadly don't have at this time. (new job/kids etc)

from ansible-gitlab-runner.

solidnerd avatar solidnerd commented on May 14, 2024

@riemers thanks for clarifying this to me 👍 . So I don't need a direct solution for my problem 😏 because I wanted only to clarify that my assumption is correct and I can try to make a pr for this case that others could use this as well.

Thanks for your work on this project it did give me a nice easy smooth start.

from ansible-gitlab-runner.

weakcamel avatar weakcamel commented on May 14, 2024

I've hit the same problem.

A bit of background:

The way I've been setting up the runners so far was to avoid using gitlab-runner register command entirely, instead doing the process purely in Ansible:

  • in case the runner is already registered in coordinator, retrieve its token (here be dragons!) with Runners API
  • templating out the config.toml

This worked perfectly... until token value was removed from the API entirely. And this is how I stumbled across this excellent role :-)


Back to the problem at hand: I also need to use [[runners.docker.services]]. Not sure I'd manage the time to add support for this as I need to put something together fast - but in case I do, would it make more sense to add services as a separate option or under extra_configs?

Services do need to appear as sub-section of runners.docker, however the existing logic seems harder to change this way. Not sure how to approach this - as the service entry is >1 line... :)

from ansible-gitlab-runner.

riemers avatar riemers commented on May 14, 2024

This is a longer problem indeed, hence why help is requested. I don't see myself solving this soon though.

from ansible-gitlab-runner.

github-actions avatar github-actions commented on May 14, 2024

Seems this message did not get a lot of love. This does not mean it was not seen but time wise might not have made it to proper attention. This is just the clean up action ;)

from ansible-gitlab-runner.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.