feat: add chef install test #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Chef_install_test | |
| on: | |
| workflow_dispatch: | |
| # schedule: | |
| # Scheduled to run at 6 a.m on mondays. | |
| #- cron: "0 6 * * 1" | |
| push: | |
| jobs: | |
| chef-install: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v2 | |
| - name: Set up and execute Chef installation | |
| run: | | |
| set -e # Exit immediately if a command exits with a non-zero status | |
| # Download and install Cinc (Chef) | |
| curl -L https://omnitruck.cinc.sh/install.sh | sudo bash | |
| # Download and unpack newrelic-install cookbook | |
| wget https://supermarket.chef.io/cookbooks/newrelic-install/download -O newrelic-install.tar.gz | |
| mkdir cookbooks | |
| tar -xzf newrelic-install.tar.gz -C cookbooks/. | |
| - name: Edit and install Chef recipe | |
| run: | | |
| # Edit Chef newrelic-install default attributes file with required fields | |
| cat <<EOF > cookbooks/newrelic-install/attributes/default.rb | |
| default['newrelic_install']['NEW_RELIC_API_KEY'] = '${{ secrets.AC_PROD_E2E_API_KEY }}' | |
| default['newrelic_install']['NEW_RELIC_ACCOUNT_ID'] = '${{ secrets.AC_PROD_E2E_ACCOUNT_ID }}' | |
| default['newrelic_install']['NEW_RELIC_REGION'] = 'US' | |
| default['newrelic_install']['targets'] = [ | |
| 'logs-integration-agent-control', | |
| 'agent-control' | |
| ] | |
| default['newrelic_install']['env']['NEW_RELIC_CLI_SKIP_CORE'] = '1' | |
| default['newrelic_install']['env']['NEW_RELIC_AUTH_CLIENT_ID']='${{ secrets.AC_PROD_E2E_NR_SYSTEM_IDENTITY_CLIENT_ID }}' | |
| default['newrelic_install']['env']['NEW_RELIC_AUTH_CLIENT_PRIVATE_KEY']='${{ secrets.AC_PROD_E2E_NR_SYSTEM_IDENTITY_PRIVATE_KEY }}' | |
| default['newrelic_install']['env']['NR_CLI_FLEET_ID']='MTIyMTMwNjh8TkdFUHxGTEVFVHwwMTk1ZDE1NC1iNTI0LTdhMTYtYWExYS0wYzQ2Y2VhOGFiMzg' | |
| default['newrelic_install']['env']['NEW_RELIC_AGENT_CONTROL_HOST_MONITORING_SOURCE']='infra-agent' | |
| default['newrelic_install']['env']['NEW_RELIC_AGENT_CONTROL_PROXY_URL']='' | |
| default['newrelic_install']['env']['NEW_RELIC_AGENT_CONTROL_PROXY_CA_BUNDLE_DIR']='' | |
| default['newrelic_install']['env']['NEW_RELIC_AGENT_CONTROL_PROXY_CA_BUNDLE_FILE']='' | |
| default['newrelic_install']['env']['NEW_RELIC_AGENT_CONTROL_PROXY_IGNORE_SYSTEM']='false' | |
| EOF | |
| # Execute newrelic install | |
| sudo chef-client --local-mode --runlist 'recipe[newrelic-install::default]' | |
| - name: Check for successful installation | |
| run: | | |
| if grep -qE "Agent Control\s*\(installed\)" output.log; then | |
| echo "Installation successful: Agent Control is installed." | |
| else | |
| echo "Installation failed: Agent Control is not installed." | |
| exit 1 | |
| fi | |
| # notify-failure: | |
| # if: ${{ always() && failure() }} | |
| # needs: [puppet-install] | |
| # runs-on: ubuntu-latest | |
| # steps: | |
| # - name: Notify failure via Slack | |
| # uses: slackapi/slack-github-action@v1.22.0 | |
| # with: | |
| # payload: | | |
| # { | |
| # "text": ":warning: [Puppet installation workflow failed] @hero check <${{ env.GITHUB_JOB_URL }}>" | |
| # } | |
| # env: | |
| # SLACK_WEBHOOK_URL: ${{ secrets.AC_SLACK_WEBHOOK }} | |
| # GITHUB_JOB_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |