Skip to content

Chef_install_test

Chef_install_test #34

name: Chef_install_test
permissions:
contents: read
on:
workflow_dispatch:
schedule:
# Scheduled to run at 6 a.m on mondays.
- cron: "0 6 * * 1"
jobs:
chef-install:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
- 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: Create system identity file
run: |
DEST_DIR="/tmp/newrelic-agent-control"
DEST_FILE="$DEST_DIR/priv.key"
if [ ! -d "$DEST_DIR" ]; then
mkdir -p "$DEST_DIR"
fi
echo "${{ secrets.AC_PROD_E2E_NR_SYSTEM_IDENTITY_PRIVATE_KEY }}" > "$DEST_FILE"
- name: Edit and install Chef recipe
run: |
# Edit Chef newrelic-install default attributes file with required fields
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
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_PROVISIONED_CLIENT_ID']='${{ secrets.AC_PROD_E2E_NR_SYSTEM_IDENTITY_CLIENT_ID }}'
default['newrelic_install']['env']['NEW_RELIC_AUTH_PRIVATE_KEY_PATH']='/tmp/newrelic-agent-control/priv.key'
default['newrelic_install']['env']['NR_CLI_FLEET_ID']='NjQyNTg2NXxOR0VQfEZMRUVUfDAxOTkyOGQyLTg3OTAtNzJlNC05ODgwLTJhYzE0NTRlZDUyZg'
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]'
sudo chef-client --local-mode --runlist 'recipe[newrelic-install::default]' > output.log 2>&1
- 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: [chef-install]
uses: ./.github/workflows/component_send_warning_via_slack.yml
with:
message: "Chef installation workflow failed"
secrets: inherit