From 0c88a2372d1b40363d950fab4dd960f5b694e047 Mon Sep 17 00:00:00 2001 From: Niall Byrne Date: Thu, 20 May 2021 09:54:29 -0400 Subject: [PATCH] feat(IMPORT): import role from legacy provisioner project --- .cookiecutter/cookiecutter.json | 12 ++ .github/workflows/push.yml | 174 +++++++++++------- .github/workflows/release.yml | 13 +- .travis.yml | 8 +- .yamllint | 13 +- README.md | 38 +++- defaults/main.yml | 8 +- meta/main.yml | 2 +- molecule/mock_install_no_update/converge.yml | 4 + molecule/mock_install_no_update/vars/main.yml | 2 +- molecule/mock_install_no_update/verify.yml | 3 + .../mock_install_with_update/converge.yml | 18 ++ .../mock_install_with_update/molecule.yml | 54 ++++++ .../mock_install_with_update/vars/main.yml | 5 + molecule/mock_install_with_update/verify.yml | 15 ++ tasks/main.yml | 7 + 16 files changed, 281 insertions(+), 95 deletions(-) create mode 100644 .cookiecutter/cookiecutter.json create mode 100644 molecule/mock_install_with_update/converge.yml create mode 100644 molecule/mock_install_with_update/molecule.yml create mode 100644 molecule/mock_install_with_update/vars/main.yml create mode 100644 molecule/mock_install_with_update/verify.yml diff --git a/.cookiecutter/cookiecutter.json b/.cookiecutter/cookiecutter.json new file mode 100644 index 0000000..8d168c9 --- /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 installs the JumpCloud agent on OSX machines.", + "email": "niall@niallbyrne.ca", + "galaxy_namespace_slug": "osx_provisioner", + "galaxy_role_slug": "jumpcloud", + "github_handle": "osx-provisioner", + "project_name": "role-jumpcloud", + "project_slug": "role-jumpcloud" +} diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index c0beb30..26a8ffb 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -10,7 +10,36 @@ on: jobs: - build: + documentation_test: + + runs-on: ubuntu-latest + + steps: + + - name: Documentation Test -- Checkout Repository + uses: actions/checkout@v1 + + - name: Documentation Test -- Setup Environment + run: | + source ./.github/scripts/setup.sh + env: + WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + + - name: Documentation Test -- Documentation Validation + uses: gaurav-nelson/github-action-markdown-link-check@1.0.11 + with: + use-quiet-mode: 'no' + use-verbose-mode: 'yes' + + - name: Documentation Test -- Report Success + run: | + ./.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}" ":x: documentation test has failed!" + + molecule_lint: runs-on: ubuntu-latest strategy: @@ -19,65 +48,84 @@ jobs: python-version: [3.7] steps: - - name: 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: Build -- Checkout Repository - uses: actions/checkout@v1 - - - name: Build -- Setup Environment + - name: Molecule Lint -- Setup Environment run: | source ./.github/scripts/setup.sh env: WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} - - - name: Build -- Install Requirements + - name: Molecule Lint -- Install Requirements run: | pip install poetry poetry install - - name: Build -- Run Linter + + - name: Molecule Lint -- 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) + - name: Molecule Lint -- Report Job Status (Success) run: | - ./.github/scripts/notifications.sh "${NOTIFICATION}" "build was successful!" - - name: Build -- Report Job Status (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}" "build has failed!" + ./.github/scripts/notifications.sh "${NOTIFICATION}" ":x: molecule linting has failed!" - documentation_test: + release: + needs: [molecule_lint, documentation_test, security_test] runs-on: ubuntu-latest steps: - - name: Documentation Test -- Checkout Repository + + - name: Release -- Checkout Repository + if: contains(github.ref, '/tags/v') uses: actions/checkout@v1 - - name: Documentation Test -- Setup Environment + + - 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: Documentation Test -- Documentation Validation - uses: gaurav-nelson/github-action-markdown-link-check@1.0.11 + - name: Release -- Generate Changelog + if: contains(github.ref, '/tags/v') + uses: scottbrenner/generate-changelog-action@1.0.3 + id: Changelog + env: + REPO: ${{ github.repository }} + - name: Release -- Create Github Release + if: contains(github.ref, '/tags/v') + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - use-quiet-mode: 'no' - use-verbose-mode: 'yes' + tag_name: ${{ env.NEWTAG }} + release_name: Release ${{ env.NEWTAG }} + body: | + ${{ steps.Changelog.outputs.changelog }} + draft: true + prerelease: false - - name: Documentation Test -- Report Success + - name: Release -- Report Job Status (Success) + if: contains(github.ref, '/tags/v') run: | - ./.github/scripts/notifications.sh "${NOTIFICATION}" "documentation test has passed!" - - name: Documentation Test -- Report Failure - if: failure() + ./.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}" "documentation test has failed!" + ./.github/scripts/notifications.sh "${NOTIFICATION}" ":x: automated release generation failed!" security_test: @@ -88,13 +136,14 @@ jobs: python-version: [3.7] 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 -- Checkout Repository - uses: actions/checkout@v1 - name: Security Test -- Setup Environment run: | source ./.github/scripts/setup.sh @@ -111,61 +160,48 @@ jobs: poetry install safety check - - name: Shellcheck -- Report Job Status on Success + - name: Security Test -- Report Job Status on 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: security checks were successful!" + - name: Security Test -- Report Job Status on Failure if: failure() run: | - ./.github/scripts/notifications.sh "${NOTIFICATION}" "security checks failed!" + ./.github/scripts/notifications.sh "${NOTIFICATION}" ":x: security checks failed!" - release: - needs: [build, documentation_test, security_test] + workflow_lint: runs-on: ubuntu-latest + strategy: + max-parallel: 4 + matrix: + python-version: [3.7] steps: - - name: Release -- Checkout + + - 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: Release -- Setup Environment + - 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: Release -- Prepare Content - if: contains(github.ref, '/tags/v') + - name: Workflow Lint -- Run Linter run: | - NEWTAG=${BRANCH_OR_TAG} - echo "NEWTAG=${NEWTAG}" >> $GITHUB_ENV - echo "{}" > package.json - - name: Release -- Generate Changelog - if: contains(github.ref, '/tags/v') - uses: scottbrenner/generate-changelog-action@1.0.3 - id: Changelog - env: - REPO: ${{ github.repository }} - - name: Release -- Create Github Release - if: contains(github.ref, '/tags/v') - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ env.NEWTAG }} - release_name: Release ${{ env.NEWTAG }} - body: | - ${{ steps.Changelog.outputs.changelog }} - draft: true - prerelease: false + yamllint .github/workflows - - name: Release -- Report Job Status (Success) - if: contains(github.ref, '/tags/v') + - name: Workflow Lint -- Report Job Status (Success) run: | - ./.github/scripts/notifications.sh \ - "${NOTIFICATION}" \ - "automated release has been created: https://github.com/${USERNAME}/${PROJECT_NAME}/releases" - - name: Release -- Report Job Status (Failure) - if: failure() && contains(github.ref, '/tags/v') + ./.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}" "automated release generation failed!" + ./.github/scripts/notifications.sh "${NOTIFICATION}" ":x: workflow linting has failed!" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 238228b..b90d640 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 index 5da32f1..c8f154c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,11 @@ jobs: - os: osx osx_image: xcode12.5 env: - - SCENARIO=hostmachine1 + - SCENARIO=mock_install_no_update + - os: osx + osx_image: xcode12.5 + env: + - SCENARIO=mock_install_with_update before_install: [] install: - sudo python3 -m pip install poetry @@ -16,4 +20,4 @@ script: - poetry run molecule test -s "${SCENARIO}" notifications: slack: - onOocckzUfSjYwx/o1tD1wvWvOGsLYRp8LXEUDU79ycPjm/MQy2rSYiOFxkd54bn75MQZEagUm48ehVOgRzmBKEfBqcSbY7oVYinjaE3FrTedplnwbP7/925d1fWr+zqd2XshU7IQZHRNepFKw7Uux8L+tSYrGUFpgak4zS/KBDpfEzyQbqyiYeu/BycF21Mc+hgoNPzwi3oIOWhN+W6xQmIWdkqwHDi8Ut/37nLMCOtoljIVGLjHjy64Wk5Kf88xZQNMJU34BSBK5lYgsZQ8eDJlAn/yGGkxW+qUCZ1EgP9c6+jAsjLOpCUgwR7IvkYCtYQV9svK+TwIHnoLJ1XRmuhiL8aYKfEFeIkysttkBcn4jLCUR1QL13f8wsCBszoqK4QLbhMikkOWMveFziKRZHfQv10jDOlVGWIuWqQ9M0yVwPLoTgKL1Kp+QZq0/1mJLdC0hiEXpv3ewF6AzPrP5+FJQxO/ZxR57v78xJ52T9blF/6iiSMISH7vaM0XGjw5uNW7vx6nLs/PQlelCmooCRZ1klM0bB4rkQyPEtDaMSOXPzUdkLp6Xpc13GgyjsWudzdaenO0HNADMDgDQY5dZHGSJ43F1yNVDOgqMvkKNLxbxpWgZZZpNkGGHfZEfzrX378e/4d4lGwGyPE2VhjblZZaePlLKn+BmX9z4llL1E= + secure: M1WQxUExLm0hXI5M6QTW9c91ecWvYbglXm3XE0cgOXB/G455pCtqP252VFPdcXPfijq5Zg6qKyHdaJrv0mqMKQw6Zb5s38WV4uBldOPWQ8K4vaS/84YkeqevuF+oahi+bO0QV+CB/X/8NGN5tW3yoFaiA+DliPH72jRrBUL2Dc9As0+sSe5WaG3dAqHWl1BMKZ3gV1o/WqHM3Pjj+KjWgDyE0dEpqmGSrdbt7itJVWs2PqRbEkBpur6HyE6nKu29y7TU7Gvm7oUAqPlMk4WO7d9NGqHq4Mf4Sk/S63/rccmB3X5plCcFZlcJ3UE4ZsRhw/xV94wyKEGngVuyfIiPjBjW04d8hQg1p7P4qMNmnhVcMpoYPjpZzcnMh/nql993+6x1devAbsCwXDf20GOc1MYIINU13+iGCYEJj4omc2SqSK1dg4dK+RtwrzwseiqefjjmA8ganROe6pAd0DC8Bz//pZyJuQ46pf9vrGa4Hmo4Xh2K2VUhWhlNW7ZrundBJ1337cicKMVzAI0cgOg5ivAnJ4Cnsa6+gyRWgkJHLnSZDWre/9Vqc2Ef0A7EXJcgx+/nmyTLsuD1Kp8vm9wKgYLBrI3DAwua+LHuu0lEQf0JOlenM011UcA/PizIrVnE3kc9N/6Eljdp4a40J0EDNgAakE71E2uyWXuOgCCBEeA= diff --git a/.yamllint b/.yamllint index c8f71e4..536f9c6 100644 --- a/.yamllint +++ b/.yamllint @@ -21,18 +21,23 @@ rules: indentation: spaces: consistent indent-sequences: true + level: error comments: disable comments-indentation: disable - document-start: enable + document-start: + level: error empty-lines: max: 3 level: error hyphens: level: error - key-duplicates: enable + key-duplicates: + level: error line-length: disable - new-line-at-end-of-file: enable + new-line-at-end-of-file: + level: error new-lines: type: unix - trailing-spaces: enable + trailing-spaces: + level: error truthy: disable diff --git a/README.md b/README.md index 2372d14..ab94850 100644 --- a/README.md +++ b/README.md @@ -8,18 +8,34 @@ - Travis CI: ![TravisCI](https://travis-ci.com/osx-provisioner/role-jumpcloud.svg?branch=production) - Github Actions: [![role-jumpcloud](https://github.com/osx-provisioner/role-jumpcloud/actions/workflows/push.yml/badge.svg?branch=production)](https://github.com/osx-provisioner/role-jumpcloud/actions/workflows/push.yml) -Installs the JumpCloud agent on OSX machines. +Ansible role that installs the JumpCloud agent on OSX machines. + +### Notes: +- See the [JumpCloud Website](https://jumpcloud.com/) for further details about this platform. Requirements ------------ None - Role Variables -------------- -None +- `jumpcloud_agent_url`: + - The URL to the JumpCloud Agent installation script for OSX. (Available from the JumpCloud website.) +- `jumpcloud_uninstall_url`: + - The URL to the JumpCloud Agent uninstall script for OSX. (Available from the JumpCloud website, not currently used.) +- `jumpcloud_connect_key:` + - The preferred method of setting this variable is through the `JUMPCLOUD_CONNECT_KEY` environment variable. + - The value should be set to your JumpCloud Connect Key, this secret value is accessible from the JumpCloud admin console. +- `jumpcloud_upgrade`: + - A boolean which determines if the installer will try to update existing JumpCloud installs. +- `jumpcloud_agent_location`: + - The expected installation location. +- `jumpcloud_installer_destination`: + - The ephemeral location for the downloaded installer script. + +[See The Default Values](defaults/main.yml) Dependencies ------------ @@ -29,11 +45,17 @@ None 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-jumpcloud } +```yaml +- hosts: web + roles: + - role: osx_provisioner.jumpcloud + jumpcloud_agent_url: "https://raw.githubusercontent.com/TheJumpCloud/support/master/scripts/macos/install_agent_and_serviceaccount.sh" + jumpcloud_uninstall_url: "https://github.com/TheJumpCloud/support/releases/download/mac_agent_uninstaller/remove_mac_agent.sh" + jumpcloud_connect_key: "{{ lookup('env', 'JUMPCLOUD_CONNECT_KEY') }}" + jumpcloud_upgrade: false + jumpcloud_agent_location: /opt/jc + jumpcloud_installer_destination: /tmp/jc_installer.sh +``` License ------- diff --git a/defaults/main.yml b/defaults/main.yml index 427144c..388584f 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,10 +1,10 @@ --- # defaults file for role-jumpcloud -jumpcloud_agent_url: https://raw.githubusercontent.com/TheJumpCloud/support/master/scripts/macos/install_agent_and_serviceaccount.sh -jumpcloud_uninstall_url: https://github.com/TheJumpCloud/support/releases/download/mac_agent_uninstaller/remove_mac_agent.sh -jumpcloud_connect_key: "{{ lookup('env', JUMPCLOUD_CONNECT_KEY }}" -jumpcloud_upgrade: false +jumpcloud_agent_url: "https://raw.githubusercontent.com/TheJumpCloud/support/master/scripts/macos/install_agent_and_serviceaccount.sh" +jumpcloud_uninstall_url: "https://github.com/TheJumpCloud/support/releases/download/mac_agent_uninstaller/remove_mac_agent.sh" +jumpcloud_connect_key: "{{ lookup('env', 'JUMPCLOUD_CONNECT_KEY') }}" +jumpcloud_upgrade: true jumpcloud_agent_location: /opt/jc jumpcloud_installer_destination: /tmp/jc_installer.sh diff --git a/meta/main.yml b/meta/main.yml index 75fba45..074b08d 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -3,7 +3,7 @@ galaxy_info: role_name: jumpcloud namespace: osx_provisioner author: Niall Byrne - description: Installs the JumpCloud agent on OSX machines. + description: Ansible role that installs the JumpCloud agent on OSX machines. company: Shared Vision Solutions license: MPL-2 platforms: diff --git a/molecule/mock_install_no_update/converge.yml b/molecule/mock_install_no_update/converge.yml index ade7bfa..291c752 100644 --- a/molecule/mock_install_no_update/converge.yml +++ b/molecule/mock_install_no_update/converge.yml @@ -3,6 +3,10 @@ hosts: all connection: local tasks: + - name: Load Default Variables + include_vars: ../../defaults/main.yml + - name: Load Default Variables + include_vars: ../../defaults/main.yml - name: Load Scenario Variables include_vars: vars/main.yml - name: "Include osx_provisioner.jumpcloud" diff --git a/molecule/mock_install_no_update/vars/main.yml b/molecule/mock_install_no_update/vars/main.yml index f739ac5..d1f278c 100644 --- a/molecule/mock_install_no_update/vars/main.yml +++ b/molecule/mock_install_no_update/vars/main.yml @@ -1,5 +1,5 @@ --- -jumpcloud_agent_url: "https://gist.githubusercontent.com/niall-byrne/94e995c8951bca59a826715053fb2bf8/raw/db7a6d427b5205d1276ae0cc7d60ee8ef82cd5c3/installer.sh" +jumpcloud_agent_url: "https://gist.githubusercontent.com/niall-byrne/94e995c8951bca59a826715053fb2bf8/raw/50450b3cf6e36fd483ab9dc88c63d8ac4b15a71d/installer.sh" jumpcloud_connect_key: "secret_jumpcloud_key" jumpcloud_upgrade: false jumpcloud_agent_location: /tmp/mock_installer_arguments diff --git a/molecule/mock_install_no_update/verify.yml b/molecule/mock_install_no_update/verify.yml index 2aa8a63..3306b3d 100644 --- a/molecule/mock_install_no_update/verify.yml +++ b/molecule/mock_install_no_update/verify.yml @@ -3,9 +3,12 @@ hosts: all gather_facts: false tasks: + - name: Load Default Variables + include_vars: ../../defaults/main.yml - name: Load Scenario Variables include_vars: vars/main.yml - name: Read Variables from Test Run + become: true slurp: src: /tmp/mock_installer_arguments register: results diff --git a/molecule/mock_install_with_update/converge.yml b/molecule/mock_install_with_update/converge.yml new file mode 100644 index 0000000..d583f01 --- /dev/null +++ b/molecule/mock_install_with_update/converge.yml @@ -0,0 +1,18 @@ +--- +- name: Converge + hosts: all + connection: local + tasks: + - name: Load Default Variables + include_vars: ../../defaults/main.yml + - name: Load Scenario Variables + include_vars: vars/main.yml + - name: Mock Previous Install Data + become: true + copy: + dest: "{{ jumpcloud_agent_location }}" + content: "Mock Previous Install\n" + mode: 0644 + - name: "Include osx_provisioner.jumpcloud" + ansible.builtin.include_role: + name: "osx_provisioner.jumpcloud" diff --git a/molecule/mock_install_with_update/molecule.yml b/molecule/mock_install_with_update/molecule.yml new file mode 100644 index 0000000..0fe1e6e --- /dev/null +++ b/molecule/mock_install_with_update/molecule.yml @@ -0,0 +1,54 @@ +--- +dependency: + name: galaxy +driver: + name: delegated + options: + managed: False + ansible_connection_options: + ansible_connection: local + ansible_sudo_pass: "${ANSIBLE_SUDO_PASSWORD}" + become_method: sudo +platforms: + - name: instance +provisioner: + name: ansible +verifier: + name: ansible +scenario: + create_sequence: + - dependency + - create + - prepare + check_sequence: + - dependency + - cleanup + - destroy + - create + - prepare + - converge + - check + - destroy + converge_sequence: + - dependency + - create + - prepare + - converge + destroy_sequence: + - dependency + - cleanup + - destroy + test_sequence: + - dependency + - lint + - cleanup + - destroy + - syntax + - create + - prepare + - converge + # - idempotence, disabled for update as installer will always run + - side_effect + - verify + - cleanup + - destroy diff --git a/molecule/mock_install_with_update/vars/main.yml b/molecule/mock_install_with_update/vars/main.yml new file mode 100644 index 0000000..c90d440 --- /dev/null +++ b/molecule/mock_install_with_update/vars/main.yml @@ -0,0 +1,5 @@ +--- +jumpcloud_agent_url: "https://gist.githubusercontent.com/niall-byrne/94e995c8951bca59a826715053fb2bf8/raw/50450b3cf6e36fd483ab9dc88c63d8ac4b15a71d/installer.sh" +jumpcloud_connect_key: "secret_jumpcloud_key" +jumpcloud_upgrade: true +jumpcloud_agent_location: /tmp/mock_installer_arguments diff --git a/molecule/mock_install_with_update/verify.yml b/molecule/mock_install_with_update/verify.yml new file mode 100644 index 0000000..4cf4636 --- /dev/null +++ b/molecule/mock_install_with_update/verify.yml @@ -0,0 +1,15 @@ +--- +- name: Verify + hosts: all + gather_facts: false + tasks: + - name: Load Scenario Variables + include_vars: vars/main.yml + - name: Read Variables from Test Run + slurp: + src: "{{ jumpcloud_agent_location }}" + register: results + - name: Check Mock Install Arguments (confirm it's been installed twice!) + assert: + that: + - results.content | b64decode == "Mock Previous Install\n-s -k secret_jumpcloud_key\n" diff --git a/tasks/main.yml b/tasks/main.yml index 5095110..b112407 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -5,6 +5,8 @@ stat: path: "{{ jumpcloud_agent_location }}" register: software_location + tags: + - jumpcloud - name: Download the JumpCloud Agent Installer get_url: @@ -12,10 +14,15 @@ dest: "{{ jumpcloud_installer_destination }}" mode: 0700 when: (software_location.stat.exists and jumpcloud_upgrade) or not software_location.stat.exists + tags: + - jumpcloud - name: Run the Agent Installation Script become: true command: "{{ jumpcloud_installer_destination }} -s -k {{ jumpcloud_connect_key }}" + register: installed args: chdir: /tmp/ when: (software_location.stat.exists and jumpcloud_upgrade) or not software_location.stat.exists + tags: + - jumpcloud