Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We tried doing that before, but this method has a problem in the following situation:
Then, after this run, you have:
Because of this, the
(Custom)
task will be skipped, so the custom repository won't be added, but it won't be removed either, and you'll end up with:and in this situation, the role may have an unexpected behavior as you can't know in advance from which source the installed package will come from.
Another problematic situation is the following:
datadog_apt_repo: "deb https://my.custom.repo stable main"
datadog_apt_repo: "deb https://my.custom.repo2 stable main"
Then you end up with:
In this case, you don't know from which custom repository will the package come from.
I think the following fix would work for both scenarios while keeping the role idempotency:
That way, we make sure the previous custom repository is removed when:
datadog_apt_repo
is not set (that way, we don't keep a previous custom repo activated when we want the official repos)datadog_apt_repo
has been modified (that way, we only use the custom repository currently specified in the role config).WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@KSerrania thanks looking at my PR and for the thoughtful review! I hadn't considered the case that you outlined and agree that your proposed solution seems like the most straightforward way to address things 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jharley I'll cherry-pick the changes you made here and add my own then, if you don't mind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@KSerrania Not at all! Thank you 🙏