refactor provisioner::base and autogenerate /etc/profile.d/crowbar-vars.sh
Split up the enormous base.rb into manageable chunks, and add a new provisioner::shell_vars recipe which auto-generates /etc/profile.d/crowbar-vars.sh. For each machine alias, it defines shell variables mapping to that machine's node and role. For example, if you have a machine with alias controller1, it means that you can type stuff like:
knife node show $controller1
knife role show $controller1r
less +F /var/log/crowbar/chef-client/$controller1.log
rather than having to endure the pain of tedious messing around with MAC addresses.
This idea originates from https://github.com/SUSE-Cloud/suse-cloud-vagrant/blob/master/vagrant/provisioning/admin/node-sh-vars and @dirkmueller suggested that some of the tweaks in the appliances / Vagrant boxes should be ported into the product. So this is the second step towards that, the first being: https://github.com/crowbar/crowbar-openstack/pull/20
You know that it is bad behavior to use dashes instead of underscores for filenames in ruby?
@tboerger Excellent point - I forgot about that since I was thinking of the files as recipes not Ruby files. Will fix!
@tboerger BTW I found another reason to prefer underscores:
WARNING Cookbooks with dashes (hyphens) are difficult to test with ChefSpec because of how Chef classifies objects. We recommend naming cookbooks with underscores (_) instead of dashes (-).
Oh, that's talking about cookbooks not recipes. Never mind :-)
For the record, I found a way to automatically change all .rb files affected by this PR to have underscores instead of hyphens:
base_commit=`git upstream` # commit on which this PR is based
# Find and store all files affected by this PR
git diff --name-only $base_commit..HEAD > ~/touched-files.txt
git filter-branch --index-filter '
# get the current index
git ls-files -s > index.txt
# Replace any hyphens in the affected files with underscores
grep "\.rb$" ~/touched-files.txt | while read file; do
perl -pi -e "m%\t\Q$file\E\$% && s/-/_/g" index.txt
done
# Convert index.txt to a new (binary) index and then replace the old one.
# We cannot use git-update-index directly on .git/index because then the
# files pre-rename would persist.
cat index.txt | \
GIT_INDEX_FILE=$GIT_INDEX_FILE.new git update-index --index-info && \
mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"
' $base_commit..HEAD
This was based off this blog post.
+1
Rebased because it looks like the gate failed due to the PR being based on master from before the change regarding digest authentication.
And now the gate fails for some weird reason which looks unrelated :-(
@aspiers not sure since when, but this needs a rebase :/
@aspiers ping for the rebase
@vuntz Rebased. I also locally backported to 3.0 and tested on my c19 which is currently running SOC6 - seemed to work fine, but I didn't test on SOC7 yet.
@tboerger I ran rubocop -c .hound.ruby.yaml against the files changed by this PR, and it didn't generate any of the Style/DotPosition violations Hound is complaining about - any ideas why?
That was with rubocop 0.33. I upgraded to 0.38 and now it complains:
Error: obsolete parameter RunRailsCops (for AllCops) found in /home/adam/SUSE/cloud/crowbar/git/crowbar/barclamps/crowbar-core/.hound.ruby.yml
Use the following configuration instead:
Rails:
Enabled: true
but if I fix that, I still can't reproduce the errors Hound is generating.
Hound is not complaining anymore :)
@tboerger That's because of the last commit, but the Style/DotPosition question still needs to be answered.
Rebased.
Rebased again.
+1
+1