From ed024df1b15c701fa8410c2422041af69723f570 Mon Sep 17 00:00:00 2001 From: Niall Byrne Date: Fri, 21 May 2021 21:09:29 -0400 Subject: [PATCH] feat(IMPORT): import role from legacy provisioner project --- .ansible-lint | 1 + .cookiecutter/cookiecutter.json | 12 + .github/scripts/build.sh | 12 + .github/scripts/setup.sh | 3 + .github/workflows/push.yml | 239 +++++++---- .github/workflows/release.yml | 13 +- .travis.yml | 15 - .yamllint | 24 +- LICENSE | 374 +----------------- README.md | 51 ++- defaults/main.yml | 14 +- handlers/main.yml | 2 +- meta/main.yml | 11 +- molecule/default/molecule.yml | 2 +- molecule/docker1/converge.yml | 10 - molecule/docker1/molecule.yml | 13 - molecule/docker1/verify.yml | 8 - molecule/hostmachine1/converge.yml | 10 - molecule/hostmachine1/verify.yml | 8 - molecule/one_of_each/converge.yml | 12 + .../molecule.yml | 0 molecule/one_of_each/vars/main.yml | 9 + molecule/one_of_each/verify.yml | 43 ++ requirements.yml | 3 +- tasks/main.yml | 49 ++- tests/test.yml | 2 +- 26 files changed, 397 insertions(+), 543 deletions(-) create mode 100644 .cookiecutter/cookiecutter.json create mode 100644 .github/scripts/build.sh delete mode 100644 .travis.yml delete mode 100644 molecule/docker1/converge.yml delete mode 100644 molecule/docker1/molecule.yml delete mode 100644 molecule/docker1/verify.yml delete mode 100644 molecule/hostmachine1/converge.yml delete mode 100644 molecule/hostmachine1/verify.yml create mode 100644 molecule/one_of_each/converge.yml rename molecule/{hostmachine1 => one_of_each}/molecule.yml (100%) create mode 100644 molecule/one_of_each/vars/main.yml create mode 100644 molecule/one_of_each/verify.yml diff --git a/.ansible-lint b/.ansible-lint index f4b9a17..475a8d3 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -1,2 +1,3 @@ +--- # .ansible-lint skip_list: [] diff --git a/.cookiecutter/cookiecutter.json b/.cookiecutter/cookiecutter.json new file mode 100644 index 0000000..8c85f0e --- /dev/null +++ b/.cookiecutter/cookiecutter.json @@ -0,0 +1,12 @@ +{ + "_template": "https://github.com/shared-vision-solutions/ansible-workbench.git", + "author": "Niall Byrne", + "company": "Shared Vision Solutions", + "description": "Ansible role that wraps geerlingguy.homebrew in a retry loop to deal with connectivity issues.", + "email": "niall@niallbyrne.ca", + "galaxy_namespace_slug": "osx_provisioner", + "galaxy_role_slug": "homebrew_retry", + "github_handle": "osx-provisioner", + "project_name": "role-homebrew-retry", + "project_slug": "role-homebrew-retry" +} diff --git a/.github/scripts/build.sh b/.github/scripts/build.sh new file mode 100644 index 0000000..5d7b84d --- /dev/null +++ b/.github/scripts/build.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -o pipefail + +main() { + + pip install poetry + poetry install + +} + +main "$@" diff --git a/.github/scripts/setup.sh b/.github/scripts/setup.sh index c595a9d..4834d8a 100644 --- a/.github/scripts/setup.sh +++ b/.github/scripts/setup.sh @@ -13,3 +13,6 @@ main() { } main + +# Create Empty Results File +touch /tmp/results.yml diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 4ac7f22..da9cee4 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -10,55 +10,21 @@ on: jobs: - build: + documentation_test: runs-on: ubuntu-latest - strategy: - max-parallel: 4 - matrix: - python-version: [3.7] steps: - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - name: Build -- Checkout Repository + - name: Documentation Test -- Checkout Repository uses: actions/checkout@v1 - - name: Build -- Setup Environment + - name: Documentation Test -- Setup Environment run: | source ./.github/scripts/setup.sh env: WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} - - name: Build -- Install Requirements - run: | - pip install poetry - poetry install - - name: Build -- Run Linter - run: | - poetry run molecule lint - - name: Build -- Run docker1 Scenario - run: | - poetry run molecule test -s docker1 - - - name: Build -- Report Job Status (Success) - run: | - ./.github/scripts/notifications.sh "${NOTIFICATION}" "build was successful!" - - name: Build -- Report Job Status (Failure) - if: failure() - run: | - ./.github/scripts/notifications.sh "${NOTIFICATION}" "build has failed!" - - documentation_test: - - runs-on: ubuntu-latest - - steps: - - name: Documentation Test -- Checkout Repository - uses: actions/checkout@v1 - name: Documentation Test -- Documentation Validation uses: gaurav-nelson/github-action-markdown-link-check@1.0.11 with: @@ -67,70 +33,124 @@ jobs: - name: Documentation Test -- Report Success run: | - ./.github/scripts/notifications.sh "${NOTIFICATION}" "documentation test has passed!" + ./.github/scripts/notifications.sh "${NOTIFICATION}" ":white_check_mark: documentation test was successful!" - name: Documentation Test -- Report Failure + if: failure() run: | - ./.github/scripts/notifications.sh "${NOTIFICATION}" "documentation test has failed!" + ./.github/scripts/notifications.sh "${NOTIFICATION}" ":x: documentation test has failed!" - security_test: + molecule_lint: runs-on: ubuntu-latest strategy: max-parallel: 4 matrix: - python-version: [3.7] + python-version: [3.8] steps: - - name: Security Test -- Set up Python ${{ matrix.python-version }} + + - name: Molecule Lint -- Checkout Repository + uses: actions/checkout@v1 + + - name: Molecule Lint -- Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v1 with: python-version: ${{ matrix.python-version }} - - name: Security Test -- Checkout Repository - uses: actions/checkout@v1 - - - name: Security Test -- Run Gitleaks - uses: zricethezav/gitleaks-action@master + - name: Molecule Lint -- Setup Environment + run: | + source ./.github/scripts/setup.sh + env: + WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} - - name: Security Test -- Check Dependencies + - name: Molecule Lint -- Install Requirements run: | - pip install safety poetry - pip install --upgrade pip + pip install poetry poetry install - safety check - - name: Shellcheck -- Report Job Status on Success + - name: Molecule Lint -- Run Linter + run: | + poetry run molecule lint + + - name: Molecule Lint -- Report Job Status (Success) run: | - ./.github/scripts/notifications.sh "${NOTIFICATION}" "security checks succeeded!" - - name: Shellcheck -- Report Job Status on Failure + ./.github/scripts/notifications.sh "${NOTIFICATION}" ":white_check_mark: molecule linting was successful!" + - name: Molecule Lint -- Report Job Status (Failure) if: failure() run: | - ./.github/scripts/notifications.sh "${NOTIFICATION}" "security checks failed!" - - release: - needs: [build, documentation_test, security_test] - - runs-on: ubuntu-latest + ./.github/scripts/notifications.sh "${NOTIFICATION}" ":x: molecule linting has failed!" + + osx_build: + + runs-on: macos-${{ matrix.os }} + strategy: + max-parallel: 4 + matrix: + os: [10.15] + platform: [x86_64] + python-version: [3.8.10] + scenario: ["one_of_each"] steps: - - name: Release -- Checkout + - name: OSX Build -- Checkout uses: actions/checkout@v1 - - - name: Release -- Setup Environment + + - name: OSX Build -- Setup python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: OSX Build -- Setup Environment run: | source ./.github/scripts/setup.sh + source ./.github/scripts/build.sh env: WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} - - - name: Release -- Prepare Content + + - name: OSX Build -- Molecule Scenario + run: | + touch /tmp/results.yml + poetry run molecule test -s "${SCENARIO}" + env: + SCENARIO: ${{ matrix.scenario}} + + - name: OSX Build -- Report Job Status (Success) + run: | + ./.github/scripts/notifications.sh "${NOTIFICATION}" ":white_check_mark: OSX ${{ matrix.os }}, molecule test scenario '${SCENARIO}' was successful" + env: + SCENARIO: ${{ matrix.scenario}} + + - name: OSX Build -- Report Job Status (Failure) + if: failure() + run: | + ./.github/scripts/notifications.sh "${NOTIFICATION}" ":x: OSX ${{ matrix.os }}, molecule test scenario '${SCENARIO}' failed!" + env: + SCENARIO: ${{ matrix.scenario}} + + release: + needs: [documentation_test, molecule_lint, osx_build, security_test] + + runs-on: ubuntu-latest + + steps: + + - name: Release -- Checkout Repository + if: contains(github.ref, '/tags/v') + uses: actions/checkout@v1 + + - name: Release -- Setup Environment if: contains(github.ref, '/tags/v') run: | + source ./.github/scripts/setup.sh NEWTAG=${BRANCH_OR_TAG} echo "NEWTAG=${NEWTAG}" >> $GITHUB_ENV echo "{}" > package.json + env: + WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + - name: Release -- Generate Changelog if: contains(github.ref, '/tags/v') - uses: scottbrenner/generate-changelog-action@1.0.3 + uses: scottbrenner/generate-changelog-action@v1.3.3 id: Changelog env: REPO: ${{ github.repository }} @@ -146,14 +166,91 @@ jobs: ${{ steps.Changelog.outputs.changelog }} draft: true prerelease: false - + - name: Release -- Report Job Status (Success) if: contains(github.ref, '/tags/v') run: | - ./.github/scripts/notifications.sh \ - "${NOTIFICATION}" \ - "automated release has been created: https://github.com/${USERNAME}/${PROJECT_NAME}/releases" + ./.github/scripts/notifications.sh "${NOTIFICATION}" ":white_check_mark: automated release has been created:\nhttps://github.com/${USERNAME}/${PROJECT_NAME}/releases" - name: Release -- Report Job Status (Failure) if: failure() && contains(github.ref, '/tags/v') run: | - ./.github/scripts/notifications.sh "${NOTIFICATION}" "automated release generation failed!" + ./.github/scripts/notifications.sh "${NOTIFICATION}" ":x: automated release generation failed!" + + security_test: + + runs-on: ubuntu-latest + strategy: + max-parallel: 4 + matrix: + python-version: [3.8] + + steps: + + - name: Security Test -- Checkout Repository + uses: actions/checkout@v1 + - name: Security Test -- Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + + - name: Security Test -- Setup Environment + run: | + source ./.github/scripts/setup.sh + env: + WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + + - name: Security Test -- Run Gitleaks + uses: zricethezav/gitleaks-action@master + + - name: Security Test -- Check Dependencies + run: | + pip install safety poetry + pip install --upgrade pip + poetry install + safety check + + - name: Security Test -- Report Job Status on Success + run: | + ./.github/scripts/notifications.sh "${NOTIFICATION}" ":white_check_mark: security checks were successful!" + - name: Security Test -- Report Job Status on Failure + if: failure() + run: | + ./.github/scripts/notifications.sh "${NOTIFICATION}" ":x: security checks failed!" + + workflow_lint: + + runs-on: ubuntu-latest + strategy: + max-parallel: 4 + matrix: + python-version: [3.8] + + steps: + + - name: Workflow Lint -- Checkout Repository + uses: actions/checkout@v1 + - name: Workflow Lint -- Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + + - name: Workflow Lint -- Setup Environment + run: | + source ./.github/scripts/setup.sh + env: + WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + - name: Workflow Lint -- Install Requirements + run: | + pip install yamllint + + - name: Workflow Lint -- Run Linter + run: | + yamllint .github/workflows -f standard + + - name: Workflow Lint -- Report Job Status (Success) + run: | + ./.github/scripts/notifications.sh "${NOTIFICATION}" ":white_check_mark: workflow linting was successful!" + - name: Workflow Lint -- Report Job Status (Failure) + if: failure() + run: | + ./.github/scripts/notifications.sh "${NOTIFICATION}" ":x: workflow linting has failed!" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c17f9d7..d13609f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,10 +25,6 @@ jobs: python-version: [3.7] steps: - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - name: Publish to Galaxy -- Code Checkout (workflow dispatch) if: github.event_name == 'workflow_dispatch' @@ -42,6 +38,11 @@ jobs: with: fetch-depth: 0 + - name: Publish to Galaxy -- Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Publish to Galaxy -- Setup Environment run: | source .github/scripts/setup.sh @@ -60,8 +61,8 @@ jobs: - name: Publish to Galaxy -- Report Job Status (Success) run: | - ./.github/scripts/notifications.sh "${NOTIFICATION}" "automated galaxy import has been completed!" + ./.github/scripts/notifications.sh "${NOTIFICATION}" ":white_check_mark: automated ansible galaxy import has been completed!" - name: Publish to Galaxy -- Report Job Status (Failure) if: failure() run: | - ./.github/scripts/notifications.sh "${NOTIFICATION}" "automated galaxy import has failed!" + ./.github/scripts/notifications.sh "${NOTIFICATION}" ":x: automated ansible galaxy import has failed!" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 1d78ced..0000000 --- a/.travis.yml +++ /dev/null @@ -1,15 +0,0 @@ -sudo: required -language: bash -jobs: - include: - - os: osx - osx_image: xcode12.5 - env: - - SCENARIO=hostmachine1 -before_install: [] -install: -- sudo python3 -m pip install poetry -- poetry install -script: -- poetry run molecule lint -- poetry run molecule test -s "${SCENARIO}" diff --git a/.yamllint b/.yamllint index 8827676..536f9c6 100644 --- a/.yamllint +++ b/.yamllint @@ -2,12 +2,15 @@ # Based on ansible-lint config extends: default +ignore: | + .cache + rules: braces: - max-spaces-inside: 1 + max-spaces-inside: 0 level: error brackets: - max-spaces-inside: 1 + max-spaces-inside: 0 level: error colons: max-spaces-after: -1 @@ -15,19 +18,26 @@ rules: commas: max-spaces-after: -1 level: error + indentation: + spaces: consistent + indent-sequences: true + level: error comments: disable comments-indentation: disable - document-start: disable + document-start: + level: error empty-lines: max: 3 level: error hyphens: level: error - indentation: disable - key-duplicates: enable + key-duplicates: + level: error line-length: disable - new-line-at-end-of-file: disable + new-line-at-end-of-file: + level: error new-lines: type: unix - trailing-spaces: disable + trailing-spaces: + level: error truthy: disable diff --git a/LICENSE b/LICENSE index a612ad9..d15a579 100644 --- a/LICENSE +++ b/LICENSE @@ -1,373 +1,7 @@ -Mozilla Public License Version 2.0 -================================== +Copyright 2021 Niall Byrne -1. Definitions --------------- +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -1.1. "Contributor" - means each individual or legal entity that creates, contributes to - the creation of, or owns Covered Software. +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -1.2. "Contributor Version" - means the combination of the Contributions of others (if any) used - by a Contributor and that particular Contributor's Contribution. - -1.3. "Contribution" - means Covered Software of a particular Contributor. - -1.4. "Covered Software" - means Source Code Form to which the initial Contributor has attached - the notice in Exhibit A, the Executable Form of such Source Code - Form, and Modifications of such Source Code Form, in each case - including portions thereof. - -1.5. "Incompatible With Secondary Licenses" - means - - (a) that the initial Contributor has attached the notice described - in Exhibit B to the Covered Software; or - - (b) that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the - terms of a Secondary License. - -1.6. "Executable Form" - means any form of the work other than Source Code Form. - -1.7. "Larger Work" - means a work that combines Covered Software with other material, in - a separate file or files, that is not Covered Software. - -1.8. "License" - means this document. - -1.9. "Licensable" - means having the right to grant, to the maximum extent possible, - whether at the time of the initial grant or subsequently, any and - all of the rights conveyed by this License. - -1.10. "Modifications" - means any of the following: - - (a) any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered - Software; or - - (b) any new file in Source Code Form that contains any Covered - Software. - -1.11. "Patent Claims" of a Contributor - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the - License, by the making, using, selling, offering for sale, having - made, import, or transfer of either its Contributions or its - Contributor Version. - -1.12. "Secondary License" - means either the GNU General Public License, Version 2.0, the GNU - Lesser General Public License, Version 2.1, the GNU Affero General - Public License, Version 3.0, or any later versions of those - licenses. - -1.13. "Source Code Form" - means the form of the work preferred for making modifications. - -1.14. "You" (or "Your") - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that - controls, is controlled by, or is under common control with You. For - purposes of this definition, "control" means (a) the power, direct - or indirect, to cause the direction or management of such entity, - whether by contract or otherwise, or (b) ownership of more than - fifty percent (50%) of the outstanding shares or beneficial - ownership of such entity. - -2. License Grants and Conditions --------------------------------- - -2.1. Grants - -Each Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: - -(a) under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and - -(b) under Patent Claims of such Contributor to make, use, sell, offer - for sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. - -2.2. Effective Date - -The licenses granted in Section 2.1 with respect to any Contribution -become effective for each Contribution on the date the Contributor first -distributes such Contribution. - -2.3. Limitations on Grant Scope - -The licenses granted in this Section 2 are the only rights granted under -this License. No additional rights or licenses will be implied from the -distribution or licensing of Covered Software under this License. -Notwithstanding Section 2.1(b) above, no patent license is granted by a -Contributor: - -(a) for any code that a Contributor has removed from Covered Software; - or - -(b) for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - -(c) under Patent Claims infringed by Covered Software in the absence of - its Contributions. - -This License does not grant any rights in the trademarks, service marks, -or logos of any Contributor (except as may be necessary to comply with -the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - -No Contributor makes additional grants as a result of Your choice to -distribute the Covered Software under a subsequent version of this -License (see Section 10.2) or under the terms of a Secondary License (if -permitted under the terms of Section 3.3). - -2.5. Representation - -Each Contributor represents that the Contributor believes its -Contributions are its original creation(s) or it has sufficient rights -to grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - -This License is not intended to limit any rights You have under -applicable copyright doctrines of fair use, fair dealing, or other -equivalents. - -2.7. Conditions - -Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted -in Section 2.1. - -3. Responsibilities -------------------- - -3.1. Distribution of Source Form - -All distribution of Covered Software in Source Code Form, including any -Modifications that You create or to which You contribute, must be under -the terms of this License. You must inform recipients that the Source -Code Form of the Covered Software is governed by the terms of this -License, and how they can obtain a copy of this License. You may not -attempt to alter or restrict the recipients' rights in the Source Code -Form. - -3.2. Distribution of Executable Form - -If You distribute Covered Software in Executable Form then: - -(a) such Covered Software must also be made available in Source Code - Form, as described in Section 3.1, and You must inform recipients of - the Executable Form how they can obtain a copy of such Source Code - Form by reasonable means in a timely manner, at a charge no more - than the cost of distribution to the recipient; and - -(b) You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter - the recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - -You may create and distribute a Larger Work under terms of Your choice, -provided that You also comply with the requirements of this License for -the Covered Software. If the Larger Work is a combination of Covered -Software with a work governed by one or more Secondary Licenses, and the -Covered Software is not Incompatible With Secondary Licenses, this -License permits You to additionally distribute such Covered Software -under the terms of such Secondary License(s), so that the recipient of -the Larger Work may, at their option, further distribute the Covered -Software under the terms of either this License or such Secondary -License(s). - -3.4. Notices - -You may not remove or alter the substance of any license notices -(including copyright notices, patent notices, disclaimers of warranty, -or limitations of liability) contained within the Source Code Form of -the Covered Software, except that You may alter any license notices to -the extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - -You may choose to offer, and to charge a fee for, warranty, support, -indemnity or liability obligations to one or more recipients of Covered -Software. However, You may do so only on Your own behalf, and not on -behalf of any Contributor. You must make it absolutely clear that any -such warranty, support, indemnity, or liability obligation is offered by -You alone, and You hereby agree to indemnify every Contributor for any -liability incurred by such Contributor as a result of warranty, support, -indemnity or liability terms You offer. You may include additional -disclaimers of warranty and limitations of liability specific to any -jurisdiction. - -4. Inability to Comply Due to Statute or Regulation ---------------------------------------------------- - -If it is impossible for You to comply with any of the terms of this -License with respect to some or all of the Covered Software due to -statute, judicial order, or regulation then You must: (a) comply with -the terms of this License to the maximum extent possible; and (b) -describe the limitations and the code they affect. Such description must -be placed in a text file included with all distributions of the Covered -Software under this License. Except to the extent prohibited by statute -or regulation, such description must be sufficiently detailed for a -recipient of ordinary skill to be able to understand it. - -5. Termination --------------- - -5.1. The rights granted under this License will terminate automatically -if You fail to comply with any of its terms. However, if You become -compliant, then the rights granted under this License from a particular -Contributor are reinstated (a) provisionally, unless and until such -Contributor explicitly and finally terminates Your grants, and (b) on an -ongoing basis, if such Contributor fails to notify You of the -non-compliance by some reasonable means prior to 60 days after You have -come back into compliance. Moreover, Your grants from a particular -Contributor are reinstated on an ongoing basis if such Contributor -notifies You of the non-compliance by some reasonable means, this is the -first time You have received notice of non-compliance with this License -from such Contributor, and You become compliant prior to 30 days after -Your receipt of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent -infringement claim (excluding declaratory judgment actions, -counter-claims, and cross-claims) alleging that a Contributor Version -directly or indirectly infringes any patent, then the rights granted to -You by any and all Contributors for the Covered Software under Section -2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all -end user license agreements (excluding distributors and resellers) which -have been validly granted by You or Your distributors under this License -prior to termination shall survive termination. - -************************************************************************ -* * -* 6. Disclaimer of Warranty * -* ------------------------- * -* * -* Covered Software is provided under this License on an "as is" * -* basis, without warranty of any kind, either expressed, implied, or * -* statutory, including, without limitation, warranties that the * -* Covered Software is free of defects, merchantable, fit for a * -* particular purpose or non-infringing. The entire risk as to the * -* quality and performance of the Covered Software is with You. * -* Should any Covered Software prove defective in any respect, You * -* (not any Contributor) assume the cost of any necessary servicing, * -* repair, or correction. This disclaimer of warranty constitutes an * -* essential part of this License. No use of any Covered Software is * -* authorized under this License except under this disclaimer. * -* * -************************************************************************ - -************************************************************************ -* * -* 7. Limitation of Liability * -* -------------------------- * -* * -* Under no circumstances and under no legal theory, whether tort * -* (including negligence), contract, or otherwise, shall any * -* Contributor, or anyone who distributes Covered Software as * -* permitted above, be liable to You for any direct, indirect, * -* special, incidental, or consequential damages of any character * -* including, without limitation, damages for lost profits, loss of * -* goodwill, work stoppage, computer failure or malfunction, or any * -* and all other commercial damages or losses, even if such party * -* shall have been informed of the possibility of such damages. This * -* limitation of liability shall not apply to liability for death or * -* personal injury resulting from such party's negligence to the * -* extent applicable law prohibits such limitation. Some * -* jurisdictions do not allow the exclusion or limitation of * -* incidental or consequential damages, so this exclusion and * -* limitation may not apply to You. * -* * -************************************************************************ - -8. Litigation -------------- - -Any litigation relating to this License may be brought only in the -courts of a jurisdiction where the defendant maintains its principal -place of business and such litigation shall be governed by laws of that -jurisdiction, without reference to its conflict-of-law provisions. -Nothing in this Section shall prevent a party's ability to bring -cross-claims or counter-claims. - -9. Miscellaneous ----------------- - -This License represents the complete agreement concerning the subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the extent -necessary to make it enforceable. Any law or regulation which provides -that the language of a contract shall be construed against the drafter -shall not be used to construe this License against a Contributor. - -10. Versions of the License ---------------------------- - -10.1. New Versions - -Mozilla Foundation is the license steward. Except as provided in Section -10.3, no one other than the license steward has the right to modify or -publish new versions of this License. Each version will be given a -distinguishing version number. - -10.2. Effect of New Versions - -You may distribute the Covered Software under the terms of the version -of the License under which You originally received the Covered Software, -or under the terms of any subsequent version published by the license -steward. - -10.3. Modified Versions - -If you create software not governed by this License, and you want to -create a new license for such software, you may create and use a -modified version of this License if you rename the license and remove -any references to the name of the license steward (except to note that -such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary -Licenses - -If You choose to distribute Source Code Form that is Incompatible With -Secondary Licenses under the terms of this version of the License, the -notice described in Exhibit B of this License must be attached. - -Exhibit A - Source Code Form License Notice -------------------------------------------- - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - -If it is not possible or desirable to put the notice in a particular -file, then You may include the notice in a location (such as a LICENSE -file in a relevant directory) where a recipient would be likely to look -for such a notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice ---------------------------------------------------------- - - This Source Code Form is "Incompatible With Secondary Licenses", as - defined by the Mozilla Public License, v. 2.0. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index da35ffd..1e86155 100644 --- a/README.md +++ b/README.md @@ -1,44 +1,67 @@ # role-homebrew-retry ### Master: -- Travis CI: ![TravisCI](https://travis-ci.com/osx-provisioner/role-homebrew-retry.svg?branch=master) -- Github Actions: [![role-homebrew-retry](https://github.com/osx-provisioner/role-homebrew-retry/actions/workflows/push.yml/badge.svg?branch=master)](https://github.com/osx-provisioner/role-homebrew-retry/actions/workflows/push.yml) +[![role-homebrew-retry](https://github.com/osx-provisioner/role-homebrew-retry/actions/workflows/push.yml/badge.svg?branch=master)](https://github.com/osx-provisioner/role-homebrew-retry/actions/workflows/push.yml) ### Production: -- Travis CI: ![TravisCI](https://travis-ci.com/osx-provisioner/role-homebrew-retry.svg?branch=production) -- Github Actions: [![role-homebrew-retry](https://github.com/osx-provisioner/role-homebrew-retry/actions/workflows/push.yml/badge.svg?branch=production)](https://github.com/osx-provisioner/role-homebrew-retry/actions/workflows/push.yml) +[![role-homebrew-retry](https://github.com/osx-provisioner/role-homebrew-retry/actions/workflows/push.yml/badge.svg?branch=production)](https://github.com/osx-provisioner/role-homebrew-retry/actions/workflows/push.yml) -Encapsulates geerlingguy.homebrew in a simple retry loop, to allow for connectivity errors during homebrew installs. +Ansible role that installs homebrew apps, casks and taps in a retry loop to deal with connectivity issues. + +### Notes: +- See the [homebrew website](https://brew.sh/) for further details about this tool. Requirements ------------ None - Role Variables -------------- -None +- `brew_user`: + - The user to run homebrew operations as. + - This role uses the dependency [geeringguy.homebrew](https://github.com/geerlingguy/ansible-role-homebrew) to setup homebrew, you may need to set the `homebrew_user` variable in the toplevel playbook. + - The default value will work fine if you're simply installing for the current user. +- `brew_retries`: + - The number of attempts that will be made to install the homebrew apps, casks and taps. +- `brew_packages`: + - A list of homebrew apps install. +- `brew_casks`: + - A list of homebrew casks to install. +- `brew_taps`: + - A list of homebrew taps to install. +- `brew_install_state`: + - Toggle between various install options. + - Set this to `latest` to install the newest version on each execution. + - Set this to `present` to simply ensure the app or cash is present. + - `latest` is temporarily disabled for casks due to [this issue](https://github.com/ansible-collections/community.general/issues/1647). +- `brew_sudo_password`: + - Some casks may require SUDO to complete their install (Zoom is an example...) This variable gives you a way to override the default value used. + +[See The Default Values](defaults/main.yml) Dependencies ------------ -None +- geerlingguy.homebrew Example Playbook ---------------- -Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: - - - hosts: all - roles: - - { role: osx-provisioner.role-homebrew-retry } +```yaml +- hosts: all + roles: + - role: osx_provisioner.homebrew_retry + brew_retries: 42 + brew_packages: + - mysql +``` License ------- -MPL-2 +MIT Author Information ------------------ diff --git a/defaults/main.yml b/defaults/main.yml index 34e073b..3c98a81 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,2 +1,14 @@ --- -# defaults file for role-homebrew-retry +# defaults file for homebrew-retry + +brew_user: "{{ lookup('env', 'USER') }}" +brew_retries: 3 +brew_taps: [] +brew_packages: [] +brew_casks: [] + +# Typical Values: latest, present +brew_install_state: latest + +# Some casks may require SUDO to complete their install +brew_sudo_password: "{{ ansible_become_password }}" diff --git a/handlers/main.yml b/handlers/main.yml index 9e95629..943d9b7 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,2 +1,2 @@ --- -# handlers file for role-homebrew-retry +# handlers file for homebrew-retry diff --git a/meta/main.yml b/meta/main.yml index 72e8845..1f8442f 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -3,9 +3,9 @@ galaxy_info: role_name: homebrew_retry namespace: osx_provisioner author: Niall Byrne - description: Encapsulates geerlingguy.homebrew in a simple retry loop, to allow for connectivity errors during homebrew installs. + description: Ansible role that installs homebrew apps, casks and taps in a retry loop to deal with connectivity issues. company: Shared Vision Solutions - license: MPL-2 + license: MIT platforms: - name: MacOSX versions: @@ -14,5 +14,10 @@ galaxy_info: min_ansible_version: 3.3.0 galaxy_tags: - osx + - mac + - homebrew + - provision + - install -dependencies: [] +dependencies: + - geerlingguy.homebrew diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index baca59e..ec0f582 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -12,4 +12,4 @@ verifier: lint: | set -e yamllint . - ansible-lint + ansible-lint --exclude ~/.cache diff --git a/molecule/docker1/converge.yml b/molecule/docker1/converge.yml deleted file mode 100644 index 4b870ff..0000000 --- a/molecule/docker1/converge.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -- name: Converge - hosts: all - connection: local - vars: - test: true - tasks: - - name: "Include osx_provisioner.homebrew_retry" - ansible.builtin.include_role: - name: "osx_provisioner.homebrew_retry" diff --git a/molecule/docker1/molecule.yml b/molecule/docker1/molecule.yml deleted file mode 100644 index b5710a8..0000000 --- a/molecule/docker1/molecule.yml +++ /dev/null @@ -1,13 +0,0 @@ ---- -dependency: - name: galaxy -driver: - name: docker -platforms: - - name: instance - image: docker.io/pycontribs/centos:8 - pre_build_image: true -provisioner: - name: ansible -verifier: - name: ansible diff --git a/molecule/docker1/verify.yml b/molecule/docker1/verify.yml deleted file mode 100644 index 67dbf23..0000000 --- a/molecule/docker1/verify.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -- name: Verify - hosts: all - gather_facts: false - tasks: - - name: PlaceHolder Task - debug: - msg: "Verification Script." diff --git a/molecule/hostmachine1/converge.yml b/molecule/hostmachine1/converge.yml deleted file mode 100644 index 4b870ff..0000000 --- a/molecule/hostmachine1/converge.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -- name: Converge - hosts: all - connection: local - vars: - test: true - tasks: - - name: "Include osx_provisioner.homebrew_retry" - ansible.builtin.include_role: - name: "osx_provisioner.homebrew_retry" diff --git a/molecule/hostmachine1/verify.yml b/molecule/hostmachine1/verify.yml deleted file mode 100644 index 67dbf23..0000000 --- a/molecule/hostmachine1/verify.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -- name: Verify - hosts: all - gather_facts: false - tasks: - - name: PlaceHolder Task - debug: - msg: "Verification Script." diff --git a/molecule/one_of_each/converge.yml b/molecule/one_of_each/converge.yml new file mode 100644 index 0000000..465ab41 --- /dev/null +++ b/molecule/one_of_each/converge.yml @@ -0,0 +1,12 @@ +--- +- name: Converge + hosts: all + connection: local + tasks: + + - name: Load Scenario Variables + include_vars: vars/main.yml + + - name: "Include homebrew-retry" + include_role: + name: "role-homebrew-retry" diff --git a/molecule/hostmachine1/molecule.yml b/molecule/one_of_each/molecule.yml similarity index 100% rename from molecule/hostmachine1/molecule.yml rename to molecule/one_of_each/molecule.yml diff --git a/molecule/one_of_each/vars/main.yml b/molecule/one_of_each/vars/main.yml new file mode 100644 index 0000000..25035d4 --- /dev/null +++ b/molecule/one_of_each/vars/main.yml @@ -0,0 +1,9 @@ +--- +brew_packages: + - telnet +brew_casks: + - google-chrome +brew_taps: + - gromgit/fuse + +ansible_become_password: "" diff --git a/molecule/one_of_each/verify.yml b/molecule/one_of_each/verify.yml new file mode 100644 index 0000000..a859423 --- /dev/null +++ b/molecule/one_of_each/verify.yml @@ -0,0 +1,43 @@ +--- +- name: Verify + hosts: all + gather_facts: false + tasks: + + - name: Load Scenario Variables + include_vars: vars/main.yml + + - name: Check telnet was installed + stat: + path: "/usr/local/bin/telnet" + register: telnet_file + + - name: Check Google Chrome was installed + stat: + path: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" + register: chrome_file + + - name: Check which taps are present + command: brew tap + changed_when: true + register: taps + + - name: Assert telnet was Installed Correctly + assert: + that: + - telnet_file.stat.exists + - telnet_file.stat.executable + msg: "The telnet binary must exist and be executable." + + - name: Assert Google Chrome was Installed Correctly + assert: + that: + - chrome_file.stat.exists + - chrome_file.stat.executable + msg: "The Google Chrome binary must exist and be executable." + + - name: Assert Homebrew Taps were Installed Correctly + assert: + that: + - brew_taps[0] in taps.stdout + msg: "The configured homebrew taps be present." diff --git a/requirements.yml b/requirements.yml index 24698c3..1b74b8c 100644 --- a/requirements.yml +++ b/requirements.yml @@ -1,2 +1,3 @@ --- -- src: osx_provisioner.homebrew_retry +- src: geerlingguy.homebrew + version: 3.1.0 diff --git a/tasks/main.yml b/tasks/main.yml index 02e9a58..04ef656 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,5 +1,48 @@ --- -# tasks file for role-homebrew-retry +# tasks file for retry -- name: Placeholder Task - debug: msg="Your dedication and hard work goes here." +- name: Install Homebrew Taps + become: True + become_user: "{{ brew_user }}" + community.general.homebrew_tap: + name: "{{ brew_taps }}" + state: present + retries: "{{ brew_retries }}" + delay: 3 + register: install_taps + until: install_taps is not failed + when: ansible_os_family == "Darwin" + tags: + - homebrew-retry + +- name: Install Homebrew Apps (With Hombrew Update) + become: True + become_user: "{{ brew_user }}" + community.general.homebrew: + name: "{{ brew_packages }}" + state: "{{ brew_install_state }}" + update_homebrew: yes + retries: "{{ brew_retries }}" + delay: 3 + register: install_apps + until: install_apps is not failed + when: ansible_os_family == "Darwin" + tags: + - homebrew-retry + +- name: Install Homebrew Casks + become: True + become_user: "{{ brew_user }}" + community.general.homebrew_cask: + name: "{{ brew_casks }}" + # Upgrades Disabled Here Due to: https://github.com/ansible-collections/community.general/issues/1647 + state: present + accept_external_apps: yes + sudo_password: "{{ brew_sudo_password }}" + retries: "{{ brew_retries }}" + delay: 3 + register: install_casks + until: install_casks is not failed + when: ansible_os_family == "Darwin" + tags: + - homebrew-retry diff --git a/tests/test.yml b/tests/test.yml index ba1792b..cf0f5a0 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -2,4 +2,4 @@ - hosts: localhost remote_user: root roles: - - role-homebrew-retry + - homebrew-retry