File tree Expand file tree Collapse file tree 2 files changed +21
-9
lines changed
infrastructure/ansible/playbooks/api/roles/api/tasks Expand file tree Collapse file tree 2 files changed +21
-9
lines changed Original file line number Diff line number Diff line change 9090 aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }} --profile ddays-app
9191 aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} --profile ddays-app
9292
93+ - name : Get Prometheus server IP
94+ id : get-ip
95+ run : |
96+ IP=$(aws ec2 describe-instances \
97+ --region eu-central-1 \
98+ --profile ddays-app \
99+ --filters "Name=tag:Project,Values=dump-monitoring" "Name=tag:Environment,Values=production" \
100+ --query 'Reservations[0].Instances[0].PublicIpAddress' \
101+ --output text)
102+ echo "prometheus_ip=$IP" >> $GITHUB_OUTPUT
103+
93104 - name : Run Ansible playbook
94105 run : |
95106 eval $(ssh-agent)
96107 ./infrastructure/scripts/ansible-playbook.sh ${{ github.ref_name == 'main' && 'production' || github.ref_name }} api
108+ env :
109+ prometheus_ip : ${{ steps.get-ip.outputs.prometheus_ip }}
Original file line number Diff line number Diff line change 1111 group : ' {{ ansible_user }}'
1212 mode : 0600
1313
14- - name : Get the ip address of the prometheus production server
15- command : aws ec2 describe-instances \
16- --region eu-central-1 \
17- --profile ddays-app \
18- --filters "Name=tag:Project,Values=dump-monitoring" "Name=tag:Environment,Values=production" \
19- --query 'Reservations[0].Instances[0].PublicIpAddress' \
20- --output text
21- register : production_ip
14+ - name : Set Prometheus IP from environment
15+ set_fact :
16+ prometheus_ip : " {{ lookup('env', 'prometheus_ip') }}"
17+
18+ - name : print Prometheus IP
19+ debug :
20+ msg : ' Prometheus IP is {{ prometheus_ip }}'
2221
2322- name : Create new api docker container
2423 docker_container :
4140 traefik.http.routers.api.middlewares : ' api-retry, api-cors'
4241 traefik.http.services.api.loadbalancer.server.scheme : ' http'
4342 # Router specifically for /api/metrics with IP restriction
44- traefik.http.middlewares.metrics-whitelist.ipwhitelist.sourcerange : ' {{ production_ip.stdout }}'
43+ traefik.http.middlewares.metrics-whitelist.ipwhitelist.sourcerange : ' {{ prometheus_ip }}'
4544 traefik.http.routers.api-metrics.rule : ' Host(`{{ api_domain }}`) && PathPrefix(`/api/metrics`)'
4645 traefik.http.routers.api-metrics.middlewares : metrics-whitelist
4746
You can’t perform that action at this time.
0 commit comments