我有一个用于“Gitlab Runners”的 Ansible 设置。这些用作toml
配置格式
[[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
目前我们使用“ini_file”来添加自定义配置。例如
- 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"'
我了解这个简单的用例是如何工作的。
现在我想插入/替换一些更复杂的东西:
[[runners]]
[runners.cache]
Type = "s3"
[runners.cache.s3]
ServerAddress = "s3.example.com"
AccessKey = "access-key"
SecretKey = "secret-key"
BucketName = "runner"
Insecure = false
使用 ini_file 模块可以实现这一点吗?
我尝试过https://docs.ansible.com/ansible/latest/collections/ansible/builtin/blockinfile_module.html模块并失败。这使得它很难理解,而且可能不稳定。或者有没有一种行之有效的方法可以用“blockinfile”模块来实现这一点?