|
| 1 | +name: Chef_install_test |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + # schedule: |
| 6 | + # Scheduled to run at 6 a.m on mondays. |
| 7 | + #- cron: "0 6 * * 1" |
| 8 | + push: |
| 9 | + |
| 10 | +jobs: |
| 11 | + chef-install: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + steps: |
| 15 | + - name: Checkout repository |
| 16 | + uses: actions/checkout@v2 |
| 17 | + |
| 18 | + - name: Set up and execute Chef installation |
| 19 | + run: | |
| 20 | + set -e # Exit immediately if a command exits with a non-zero status |
| 21 | +
|
| 22 | + # Download and install Cinc (Chef) |
| 23 | + curl -L https://omnitruck.cinc.sh/install.sh | sudo bash |
| 24 | + |
| 25 | + # Download and unpack newrelic-install cookbook |
| 26 | + wget https://supermarket.chef.io/cookbooks/newrelic-install/download -O newrelic-install.tar.gz |
| 27 | + mkdir cookbooks |
| 28 | + tar -xzf newrelic-install.tar.gz -C cookbooks/. |
| 29 | +
|
| 30 | + - name: Create system identity file |
| 31 | + run: | |
| 32 | + DEST_DIR="/tmp/newrelic-agent-control" |
| 33 | + DEST_FILE="$DEST_DIR/priv.key" |
| 34 | + |
| 35 | + if [ ! -d "$DEST_DIR" ]; then |
| 36 | + mkdir -p "$DEST_DIR" |
| 37 | + fi |
| 38 | + |
| 39 | + echo "${{ secrets.AC_PROD_E2E_NR_SYSTEM_IDENTITY_PRIVATE_KEY }}" > "$DEST_FILE" |
| 40 | +
|
| 41 | + - name: Edit and install Chef recipe |
| 42 | + run: | |
| 43 | + # Edit Chef newrelic-install default attributes file with required fields |
| 44 | + sed -i '/curl -Ls https:\/\/download.newrelic.com\/install\/newrelic-cli\/scripts\/install.sh/{s/newrelic install/newrelic install --debug/}' cookbooks/newrelic-install/resources/newrelic_install.rb |
| 45 | + cat <<EOF > cookbooks/newrelic-install/attributes/default.rb |
| 46 | + default['newrelic_install']['NEW_RELIC_API_KEY'] = '${{ secrets.AC_PROD_E2E_API_KEY }}' |
| 47 | + default['newrelic_install']['NEW_RELIC_ACCOUNT_ID'] = '${{ secrets.AC_PROD_E2E_ACCOUNT_ID }}' |
| 48 | + default['newrelic_install']['NEW_RELIC_REGION'] = 'US' |
| 49 | + default['newrelic_install']['targets'] = [ |
| 50 | + 'logs-integration-agent-control', |
| 51 | + 'agent-control' |
| 52 | + ] |
| 53 | + default['newrelic_install']['env']['NEW_RELIC_CLI_SKIP_CORE'] = '1' |
| 54 | + default['newrelic_install']['env']['NEW_RELIC_AUTH_PROVISIONED_CLIENT_ID']='${{ secrets.AC_PROD_E2E_NR_SYSTEM_IDENTITY_CLIENT_ID }}' |
| 55 | + default['newrelic_install']['env']['NEW_RELIC_AUTH_PRIVATE_KEY_PATH']='/tmp/newrelic-agent-control/priv.key' |
| 56 | + default['newrelic_install']['env']['NR_CLI_FLEET_ID']='NjQyNTg2NXxOR0VQfEZMRUVUfDAxOTkyOGQyLTg3OTAtNzJlNC05ODgwLTJhYzE0NTRlZDUyZg' |
| 57 | + default['newrelic_install']['env']['NEW_RELIC_AGENT_CONTROL_HOST_MONITORING_SOURCE']='infra-agent' |
| 58 | + default['newrelic_install']['env']['NEW_RELIC_AGENT_CONTROL_PROXY_URL']='' |
| 59 | + default['newrelic_install']['env']['NEW_RELIC_AGENT_CONTROL_PROXY_CA_BUNDLE_DIR']='' |
| 60 | + default['newrelic_install']['env']['NEW_RELIC_AGENT_CONTROL_PROXY_CA_BUNDLE_FILE']='' |
| 61 | + default['newrelic_install']['env']['NEW_RELIC_AGENT_CONTROL_PROXY_IGNORE_SYSTEM']='false' |
| 62 | + EOF |
| 63 | + |
| 64 | + # Execute newrelic install |
| 65 | + sudo chef-client --local-mode --runlist 'recipe[newrelic-install::default]' |
| 66 | +
|
| 67 | + - name: Check for successful installation |
| 68 | + run: | |
| 69 | + if grep -qE "Agent Control\s*\(installed\)" output.log; then |
| 70 | + echo "Installation successful: Agent Control is installed." |
| 71 | + else |
| 72 | + echo "Installation failed: Agent Control is not installed." |
| 73 | + exit 1 |
| 74 | + fi |
| 75 | +
|
| 76 | +# notify-failure: |
| 77 | +# if: ${{ always() && failure() }} |
| 78 | +# needs: [puppet-install] |
| 79 | +# runs-on: ubuntu-latest |
| 80 | +# steps: |
| 81 | +# - name: Notify failure via Slack |
| 82 | +# uses: slackapi/slack-github-action@v1.22.0 |
| 83 | +# with: |
| 84 | +# payload: | |
| 85 | +# { |
| 86 | +# "text": ":warning: [Puppet installation workflow failed] @hero check <${{ env.GITHUB_JOB_URL }}>" |
| 87 | +# } |
| 88 | +# env: |
| 89 | +# SLACK_WEBHOOK_URL: ${{ secrets.AC_SLACK_WEBHOOK }} |
| 90 | +# GITHUB_JOB_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |
0 commit comments