Skip to content

Ansible_install_test #14

Ansible_install_test

Ansible_install_test #14

name: Ansible_install_test
permissions:
contents: read
on:
workflow_dispatch:
schedule:
# Scheduled to run at 6 a.m on mondays.
- cron: "0 6 * * 1"
jobs:
ansible-install:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
- name: Set up Ansible
run: |
set -e # Exit immediately if a command exits with a non-zero status
# Update package list and install ansible
sudo apt update
sudo apt install ansible -y
- 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: Install New Relic ansible module
run: |
# Install New Relic Ansible module
ansible-galaxy install newrelic.newrelic_install
- name: Create and apply Ansible playbook
run: |
# Create ansible playbook file
cat <<EOF > playbook.yaml
- name: Install New Relic infrastructure and logs
hosts: all
roles:
- role: newrelic.newrelic_install
vars:
targets:
- logs-agent-control
- agent-control
environment:
NEW_RELIC_API_KEY: ${{ secrets.AC_PROD_E2E_API_KEY }}
NEW_RELIC_ACCOUNT_ID: "${{ secrets.AC_PROD_E2E_ACCOUNT_ID }}"
NEW_RELIC_REGION: US
NEW_RELIC_CLI_SKIP_CORE: "true"
NR_CLI_FLEET_ID : "NjQyNTg2NXxOR0VQfEZMRUVUfDAxOTkyOGQyLTg3OTAtNzJlNC05ODgwLTJhYzE0NTRlZDUyZg"
NEW_RELIC_AUTH_PROVISIONED_CLIENT_ID : "${{ secrets.AC_PROD_E2E_NR_SYSTEM_IDENTITY_CLIENT_ID }}"
NEW_RELIC_AUTH_PRIVATE_KEY_PATH : "/tmp/newrelic-agent-control/priv.key"
NEW_RELIC_AGENT_CONTROL_HOST_MONITORING_SOURCE: "infra-agent"
NEW_RELIC_AGENT_CONTROL_PROXY_URL : ""
NEW_RELIC_AGENT_CONTROL_PROXY_CA_BUNDLE_DIR : ""
NEW_RELIC_AGENT_CONTROL_PROXY_CA_BUNDLE_FILE : ""
NEW_RELIC_AGENT_CONTROL_PROXY_IGNORE_SYSTEM : "false"
EOF
ansible-playbook playbook.yaml -i "localhost," --connection=local > 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: [ansible-install]
uses: ./.github/workflows/component_send_warning_via_slack.yml
with:
message: "Ansible installation workflow failed"
secrets: inherit