8

I have an Ansible setup for "Gitlab Runners". These use toml as configuration format

[[runners]]
  name = "gitlab-runner-1"
  url = "https://example.com"
  token = "x"
  executor = "docker"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
  [runners.docker]
    tls_verify = false
    image = "ubuntu:bionic"
    privileged = true
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/cache"]
    shm_size = 0

Currently we use "ini_file" for adding custom configurations to it. For example

- name: set listen_address to activate debug for container
  ini_file:
    section: session_server
    path: /srv/gitlab-runner/config/config.toml
    option: listen_address
    value: '"0.0.0.0:8093"'

I understand how this simple use case works.

Now I want to insert/replace somethng more complex:

[[runners]]
  [runners.cache]
    Type = "s3"
    [runners.cache.s3]
    ServerAddress = "s3.example.com"
      AccessKey = "access-key"
      SecretKey = "secret-key"
      BucketName = "runner"
      Insecure = false

Is this possible with the ini_file module ?

I tried with the https://docs.ansible.com/ansible/latest/collections/ansible/builtin/blockinfile_module.html module and failed. This make it very hard to understand and probably flaky. Or is there a proven way to accomplish this with the "blockinfile" module?

madflow
  • 310
  • 2
  • 9

0 Answers0