Skip to content

feat: put right credentials to chef, puppet and ansible tests #2

feat: put right credentials to chef, puppet and ansible tests

feat: put right credentials to chef, puppet and ansible tests #2

name: Ansible_install_test
on:
workflow_dispatch:
# schedule:
# Scheduled to run at 6 a.m on mondays.
#- cron: "0 6 * * 1"
push:
jobs:
ansible-install:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- 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]
# runs-on: ubuntu-latest
# steps:
# - name: Notify failure via Slack
# uses: slackapi/slack-github-action@v1.22.0
# with:
# payload: |
# {
# "text": ":warning: [Ansible 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 }}