3 minutes
Setting up Renovate for Github repositories
A few months ago I created an ansible-role that installed and setup a basic “monitoring server”. The role will install Grafana
, Prometheus
, Node_exporter
& Promtail
on a node and make sure all the services are running. In my task files, I utilize a variable that defines every version for the respective service. These versions are pinned as defaults and need to be manually updated everytime there is a new version available. This is because I’m downloading the specific binary files from the Github projects.
I wanted to find a way to automate this process and make something scan for changes and notify me when a new version is available. That’s where I stumbled up renovate, a dependency tracking tool that can aid you in keeping you repositories up-to-date!
Installing
The installation was pretty straight forward and easy using the Renovate Github App. I could login with my Github account and give permissions to the bot for any repositories that I wanted. For now I just selected my ansible-monitoring
repo. After that the bot created a pull-request which will add a basic renovate.json
config file.
Configuration
With a basic renovate.json
file ready in the repository, I could try and tinker with it to create the solution I needed. I decided to make use of regex to find the versions of the services in my defaults/main.yml
file and compare the values to the latest versions of the projects. This is done using github-tags
as a datasource and depName
as the name of the upstream repository to check.
First of I created the renovate comments inside of my defaults/main.yml
file which will help identify the version:
# Prometheus
prometheus_install: true
prometheus_user: prometheus
# Renovate: datasource=github-tags depName=prometheus/prometheus
prometheus_version: v2.48.1
# Node_exporter
exporter_install: true
exporter_user: node_exporter
# Renovate: datasource=github-tags depName=prometheus/node_exporter
exporter_version: v1.7.0
# Loki
loki_install: true
loki_user: loki
# Renovate: datasource=github-tags depName=grafana/loki
loki_version: v2.9.3
# Promtail
promtail_install: true
promtail_user: promtail
# Renovate: datasource=github-tags depName=grafana/loki
promtail_version: v2.9.3
After that, the renovate.json
file could be created to collect the versions and compare them:
{
"regexManagers": [
{
"fileMatch": ["\\.yml$"],
"matchStrings": [
"# Renovate: datasource=(?<datasource>.*?) depName=(?<depName>.*?)( versioning=(?<versioning>.*?))?\\sprometheus_version: (?<currentValue>.*)\\s",
"# Renovate: datasource=(?<datasource>.*?) depName=(?<depName>.*?)( versioning=(?<versioning>.*?))?\\sexporter_version: (?<currentValue>.*)\\s",
"# Renovate: datasource=(?<datasource>.*?) depName=(?<depName>.*?)( versioning=(?<versioning>.*?))?\\sloki_version: (?<currentValue>.*)\\s",
"# Renovate: datasource=(?<datasource>.*?) depName=(?<depName>.*?)( versioning=(?<versioning>.*?))?\\spromtail_version: (?<currentValue>.*)\\s"
]
}
]
}
Once these changes were pushed, I could already see a pull-request coming in after a few minutes. The renovate bot found a new version of prometheus and changed it in my defaults/main.yml
file and created a pull-request for the update. This notified me and needed my approval before merging.
Voila, this is a great way to “automate” the version bumps in my repository.