Skip to content

Instantly share code, notes, and snippets.

@geerlingguy
Last active January 15, 2021 13:52
Show Gist options
  • Save geerlingguy/19aace82f94b2d07a0dfb23db7345a57 to your computer and use it in GitHub Desktop.
Save geerlingguy/19aace82f94b2d07a0dfb23db7345a57 to your computer and use it in GitHub Desktop.

Revisions

  1. geerlingguy revised this gist Feb 24, 2020. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions molecule-3-up.sh
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,7 @@
    exit 1

    export LINT_STRING="lint: |
    set -e
    yamllint .
    ansible-lint"

  2. geerlingguy created this gist Feb 21, 2020.
    47 changes: 47 additions & 0 deletions molecule-3-up.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    #!/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: |
    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