Skip to content

Instantly share code, notes, and snippets.

@thiagoalmeidasa
Forked from geerlingguy/molecule-3-up.sh
Created July 20, 2020 06:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thiagoalmeidasa/e4dea1fb8a436eaf8b85379eb73fe03a to your computer and use it in GitHub Desktop.
Save thiagoalmeidasa/e4dea1fb8a436eaf8b85379eb73fe03a to your computer and use it in GitHub Desktop.
Molecule 3.0 update script with all the little changes I had to make.
#!/bin/bash
#
# Update things to be compatible with Molecule 3.0.
#
# This script is NOT idempotent, and should never be run again.
exit 1
export LINT_STRING="lint: |
set -e
yamllint .
ansible-lint"
# Loop through all directories starting with "geerlingguy".
for dir in ./geerlingguy*/
do
# cd into role directory.
cd "$dir"
# Change string `pip install molecule` to `pip install molecule yamllint ansible-lint` in .travis.yml
sed -i '' 's/pip install molecule docker/pip install molecule yamllint ansible-lint docker/g' .travis.yml
# Change and remove strings in molecule.yml
sed -i '' '/[ ][ ]name: yamllint/d' molecule/default/molecule.yml
sed -i '' '/[ ][ ]options:/d' molecule/default/molecule.yml
sed -i '' '/[ ][ ][ ][ ]config-file:.*/d' molecule/default/molecule.yml
sed -i '' 's/-playbook.yml/-converge.yml/g' molecule/default/molecule.yml
sed -i '' '/[ ][ ]lint:/d' molecule/default/molecule.yml
sed -i '' '/[ ][ ][ ][ ]name: ansible-lint/d' molecule/default/molecule.yml
sed -i '' '/verifier:/d' molecule/default/molecule.yml
sed -i '' '/[ ][ ]name: testinfra/d' molecule/default/molecule.yml
sed -i '' '/[ ][ ][ ][ ]name: flake8/d' molecule/default/molecule.yml
# Update lint block in molecule.yml file.
perl -i -pe 's/lint:/$ENV{"LINT_STRING"}/g' molecule/default/molecule.yml
# Move file `molecule/default/yaml-lint.yml` to `.yamllint` (if exists).
if [ -f molecule/default/yaml-lint.yml ]; then
mv molecule/default/yaml-lint.yml .yamllint
fi
# Move file `molecule/default/playbook.yml` to `molecule/default/converge.yml` (if exists).
if [ -f molecule/default/playbook.yml ]; then
mv molecule/default/playbook.yml molecule/default/converge.yml
fi
# cd back to parent directory.
cd ..
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment