Closed lud97x closed 3 years ago
Hi @lud97x -
I'm not certain I completely understand the problem. octocatalog-diff is designed to work in a git repository, and that's why it defaults to the assumption that you're in a git repository. That's probably not a default we're interested in changing right now.
However, it does seem as though it works correctly when you pass the bootstrapped-{to,from}-dir
arguments, so I suspect that octocatalog-diff just doesn't understand the structure of the repository or directory you're running it from.
I'm not entirely familiar with the control-repo
pattern from puppet, we don't use it internally at GitHub. Is the path /etc/puppetlabs/code/environments/dev
a working git checkout?
Hi @ahayworth ,
I use r10k to create each puppet environment ( dev and production folders), so maybe r10k is doing something different than git.
The path /etc/puppetlabs/code/environments/dev
includes the puppet control-repo from a git repo and the folder modules/
all the puppet modules present in a Puppetfile.
Inside the /etc/puppetlabs/code/environments/dev
:
git status
HEAD detached at e229c40
Untracked files:
(use "git add <file>..." to include in what will be committed)
.r10k-deploy.json
modules/
---
git log --oneline
e229c40 (HEAD, origin/dev, cache/dev) diff
2c5ae3a diff
---
git branch
* (HEAD detached at e229c40)
production
---
git checkout production
Previous HEAD position was e229c40 diff
Switched to branch 'production'
Your branch is up to date with 'origin/production'.
---
The folder structure looks like this:
control-repo/
├── data/
│ ├── nodes/
│ └── common.yaml
├── manifests/
│ └── site.pp
├── scripts/
│ ├── code_manager_config_version.rb
│ ├── config_version.rb
│ └── config_version.sh
|── modules/ # <-------- populate with the command 'r10k puppetfile install Puppetfile'
├── site-modules/
│ ├── profile/
│ └── role/
├── LICENSE
├── Puppetfile
├── README.md
├── environment.conf
└── hiera.yaml
What is the expected repository structure ?
What is the expected repository structure ?
I think your repo structure is okay, actually. Looking through the output, I can see that octocatalog-diff
actually does find the production
and dev
branches correctly, and copies them to the /tmp
compilation dirs as expected. Apologies for the misdirection there 😆
As your issue title mentioned, the issue really is the config_version.sh
script; it's expecting to be in a git repository but octocatalog-diff
is not actually copying the whole git repo over. It's doing a git archive
, which doesn't include the .git
subdirectory, so any git
commands fail.
I don't think, however, that we need the config_version.sh
script to actually run at all. It's not necessary at this point, and octocatalog-diff
passes a CLI flag that purports to disable it completely for older versions of puppet: https://github.com/github/octocatalog-diff/blob/5ae7f1b009ced6edccc11c803018c9fc1420ab00/lib/octocatalog-diff/catalog-util/command.rb#L111-L121 (The flag didn't work on newer versions).
I think we should just figure out how to skip the config_version.sh
entirely here. Looking at puppet's docs, it looks like the script itself is configurable: https://puppet.com/docs/puppet/7.4/config_file_environment.html
Could you try disabling that in the environment config and re-running?
Hi @ahayworth
You were right, I did a quick fix by commenting the git cmd in the config_version.sh
like below:
#elif type git >/dev/null; then
# The git command is available.
# git --git-dir $1/$2/.git rev-parse HEAD
The result below:
/etc/puppetlabs/code/environments/dev# octocatalog-diff -n mongodb01.lud.home --bootstrap-script /root/r10k.sh
I, [2021-02-22T19:36:12.578744 #9551] INFO -- : Catalogs compiled for mongodb01.lud.home
I, [2021-02-22T19:36:12.588685 #9551] INFO -- : Diffs computed for mongodb01.lud.home
diff origin/production/mongodb01.lud.home current/mongodb01.lud.home
*******************************************
Package[mongodb_client] =>
parameters =>
ensure =>
- latest
+ absent
*******************************************
Package[mongodb_server] =>
parameters =>
ensure =>
- latest
+ absent
*******************************************
Yumrepo[mongodb] =>
parameters =>
baseurl =>
- https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/latest./$basearch/
+ https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/absent./$basearch/
*******************************************
So it is working now :), thank you.
Happy to help! 😄
Hi,
What did you do? Run octocatalog-diff between dev and production branches with a r10k bootstrap script.
What happened? It fails showing a catalog compile , a git archive error on the script config_version.sh
What did you expect to happen? I expect it to work as it is working without a git integration.
How can someone reproduce the problem?
Directly from the puppetserver in
/etc/puppetlabs/code/environments/dev
I did:`octocatalog-diff -d -n mongodb01.lud.home -f origin/dev -t origin/production --bootstrap-script /tmp/r10k.sh
Content of
config_version.sh
: https://github.com/puppetlabs/control-repo/blob/production/scripts/config_version.shContent of
/tmp/r10k.sh
:Content of
/etc/octocatalog-diff.cfg.rb
The output:
Compiling manually the catalog works:
Output: The output is huge, I can put it if require:
Without the git integration it's works:
Output: