Open separate PR for each occurance of dependency with renovate - terraform

I have a repo in which I manage Terraformcode for multiple environments.
For example I would have these files:
/terraform/dev/superapp/main.tf
/terraform/prod/superapp/main.tf
In those files, I define the used providers, modules, etc. The versions of those components are identical on dev and prod.
I enabled renovate on that repo and it works almost perfectly.
But renovate will open a PR that updates the versions for e.g. the aws provider or the eks-module in dev and prod in just one PR.
But I would like to have separate PRs for each module, provider, etc and then again separate PRs for dev and prod.
So I would end up with four PRs regarding the aws-provider and the eks-module.
One for each dependency in each environment.
I checked the docs of Renovate, but I could not really find out which parameter would trigger such a behaviour, but I am sure this has to be possible.
Any help is much appreciated.

You can specify the configuration option additionalBranchPrefix to add a prefix to the branch name created by Renovate. By using parentDir or baseDir in the prefix, Renovate will split PRs based on where the package definition is located.
In your case, since the immediate parent directory has the same name (superapp), you would have to use baseDir to take into account the whole path of the file to update.
Adding this configuration in renovate.json should do the trick:
{
"packageRules": [
{
"managers": ["terraform"],
"additionalBranchPrefix": "{{baseDir}}-",
"packagePatterns": [".*"]
}
]
}

As far as I know that is not possible at the moment with renovate.
You could try and include the files/paths one by one, but I do not think that will work.

Related

.gitattributes for linguist doesn't work correctly with gitlab

I have a (private) project on Gitlab which uses GameMaker, and the .yy files were being detected as Yacc. I looked up how to change this, so I came across .gitattributes files, as described here and here. I created a .gitattributes file in the project directory with the following content:
*.yy linguist-language=GameMaker JSON
*.yy linguist-detectable=true
*.yyp linguist-language=GameMaker JSON
*.yyp linguist-detectable=true
The files are no longer being detected as Yacc, but they are also not detected as "GameMaker JSON", Gitlab now shows the repository as 100% GameMaker Language. I have tried both *.yy linguist-detectable syntax without the =true and with it, I have tried writing GameMaker-JSON with hyphens instead of spaces, and I have confirmed that the .gitattributes file was pushed onto the main branch (which is the only branch). How can I resolve this so that the .yy and .yyp files get recognized correctly, am I missing something?
It seems I mistakenly assumed that linguist allows you to specify custom language names in .gitattributes, but to my current knowledge, that is unfortunately not possible. I will henceforth specify to mark .yy and .yyp files as JSON in my project (refer to this comment I made), which I have already confirmed to work correctly.
My intention was to mark files that are specifically used as GameMaker project files or asset files (which are created and used by the GameMaker editor and not intended to be edited manually) differently from other files with JSON syntax (GameMaker also allows you to parse data from JSON files within your game code, these files would usually use the .json extension and not .yy or .yyp).
For now, it seems advisable for GameMaker projects to either specify .yy and .yyp as JSON or specify them to not be counted by linguist at all, since they aren't code that is manually written by the user.

Which include syntax is recommended?

We have a copy of to-be-continuous at Orange, which is currently used like this:
include:
# Python template
- project: "to-be-continuous/python"
ref: "1.2.2"
file: "/templates/gitlab-ci-python.yml"
However I have no idea how the sync works with the Orange repo, and I'm thinking it's better to make all projects directly include the gitlab.com link for faster access to new functionnalities, what do you think, do you expect any issues, security or operational wise?
include:
# Python template
- remote: 'https://gitlab.com/to-be-continuous/python/-/raw/1.2.2/templates/gitlab-ci-python.yml'
To-be-continuous at Orange are syncronised every night with gitlab.com. So you don't miss any newer functionalities. My suggestion is to use 1st include, because our internal repo have more customisation for our needs like devops-store variant, ODE..
Prefer use first include for all current cases.
You have to use second include for example to validate a new functionality not yet merged.
The include/remote may work but requires that your GitLab server has a direct access to the referenced link (gitlab.com in your case).
/!\ the include/remote syntax doesn't not support double include: when you're trying to include a template that itself includes a (local) template.

Ecto mutliple repos-- how to ignore one for migrations

I have an app configured
config :my_app,
ecto_repos: [MyApp.Repo, MyApp.LegacyRepo]
MyApp.Repo's migrations are managed by Ecto.
MyApp.LegacyRepo migrations are handled by Rails and error out on mix ecto.migrate
Is there a way to specify "I have two repos, but please ignore the second for migrations"?
Another option is to change your config.exs. Change it to...
config :my_app, ecto_repos: [MyApp.Repo]
According to the ecto.migrate documentation...
The repositories to migrate are the ones specified under the
:ecto_repos option in the current app configuration. However, if the
-r option is given, it replaces the :ecto_repos config.
Not having a MyApp.LegacyRepo in ecto_repos doesn't prevent reads or writes or anything else you'd expect. It just configures the migration task.
You can pass a repo into mix ecto.migrate like this
mix ecto.migrate -r MyApp.Repo
You can update test/test_helper.ex in a phoenix app to only run one repo migrations like this
Mix.Task.run "ecto.migrate", ["-r", "MyApp.Repo", "--quiet"]

Layering projects on top of each other with git

Let there be:
There are different repositories repoA, repoB and repoC each respecting the same directory layout principles, which are to be merged onto a third repoM's working directory (the "master" project).
repoM has an atypical setup (--work-dir and --git-dir are sepparate). repo[A-C] are cloned as bare, and they are set as core.bare = false and core.worktree=<--work-dir-of-repoM>.
The requirements:
I need to always have an overview over the history of all files in repoM's work-dir, which could have stemmed from repo[A-C]. With this approach, I lose all that information.
Alternative:
I've been thinking about using git-subtree instead (git version 1.7.11.2, so it's already built-in), leaving repo[A-C] bare, and then
git pull -s subtree, or
git subtree ...
With the subtree pull strategy, I lose the history on a merge conflict (git blame says so).
I've never used subtree before, but from my understanding it's not possible to merge files from repo[A-C] into repoM's work-dir, those files must be put into a subdirectory of repo[A-C]. This is definitely not what I need. Why? Because of the following ...
Problem statement:
You have different git repositories each containing different sets of files, usually configuration files and some shell scripts. You want to put everything in the $HOME (which is <--work-dir-of-repoM>) directory from all those repositories. You should be able to see at all time where each file comes from, edit, commit and push changes to each one's origin. You've guessed it, it something like vundle, but generalized for any kind of configuration of any program, not just vim bundles. If a conflict occures, one should be able to track down which two authors of the same file need to get in touch with each other and make up a deal (if one needs to be made).
This is for an open-source project I'm trying to get a prototype working, so any help is highly appreciated. Also ideas about already existing projects which do this in a similar manner are highly appreciated.
Note: the "master directory" does not necessarily have to be $HOME, I've used it as a possible hint on the kind of problem this could solve.
Why not simply use Git Submodules in your "master project"?

Puppet how to run all manifests in directory

So I have a directory of puppet manifests that I want to run.
Is it possible to do something like:
include /etc/puppet/users/server522/*.pp
and have puppet run them?
I've tried
include users::server522::*
and several other variations
I always get an error about puppet being unable to find it.
Is there anyway to do this?
So my final solution to this was write a script that would take the directory listing and for each .pp file add an include into the server522.pp file. Quite annoying that puppet won't include an entire directory.
What are you trying to do here, and are you sure you're doing it the correct way? To wit, if you have multiple manifests corresponding to multiple servers, you need to define the nodes for each server. If OTOH you're trying to apply multiple manifests to a single node it's not clear why you would be doing that, instead of just using your defined classes. A little more information would be helpful here.
I do not see the point of each user having its own manifest. I would rather create script that would automatically build one manifest file, basing on data from some source, for instance from HEAD of git repository containing CSV file with current list of users.
If you realy want to use separate manifest file for every user you may consider having seprate module for every user:
manifests
default.pp <-- here comes default manifest
module_for_user_foo/
manifests/
init.pp <-- here comes your 'foo' user
module_for_user_bar/
manifests/
init.pp <-- here comes your 'bar' user
Now you may copy modules containing manifests.

Resources