Skip to content

Instantly share code, notes, and snippets.

@jspaleta
Created September 28, 2022 23:18
Show Gist options
  • Save jspaleta/7f86c93f52607326a1541c6b4e9473c6 to your computer and use it in GitHub Desktop.
Save jspaleta/7f86c93f52607326a1541c6b4e9473c6 to your computer and use it in GitHub Desktop.
Ansible Tower Nginx Remediation
type: CheckConfig
api_version: core/v2
metadata:
name: nginx-http-service-healthcheck
annotations:
# Required key: io.sensu.ansible.config.actions
# Value: stringified json array of Job Template Requests
# all request attributes are optional
# Each Job Template Request may consist of:
# Either template_name and/or template_id, with template_id taking precedence
# Either inventory_name and/or inventory_id, with inventory_id taking precedence
# Matching Sensu event occurrence conditions
# Matching Sensu event severity conditions
# Provide limit string to set inventory limit, empty string is replaced with entity name
io.sensu.ansible.config.actions: |
[
{
# Apply the Tower Job Template named "Nginx Restart" to the Tower inventory named "Nginx"
# when then check is in a 1:warning or 2:critical state with an occurance count of exactly 3
"template_name": "Nginx Restart",
"inventory_name": "Nginx",
"limit": "",
"occurrences": [ 3 ],
"severities": [ 1, 2 ]
}
]
spec:
check_hooks: null
command: http-check --timeout 10 --url "http://127.0.0.1:80/"
env_vars: null
high_flap_threshold: 0
interval: 30
low_flap_threshold: 0
output_metric_format: ""
output_metric_handlers: null
pipelines:
- api_version: core/v2
name: ansible-tower
proxy_entity_name: ""
publish: true
round_robin: true
runtime_assets:
- sensu/http-checks:0.5.0
secrets: null
stdin: false
subdue: null
subscriptions:
- nginx
timeout: 0
ttl: 0
type: Handler
api_version: core/v2
metadata:
name: ansible-tower
spec:
# Command modified to include non-standard port and protocol options for local testing Tower install
command: sensu-ansible-handler --host ${ANSIBLE_HOST} --port ${ANSIBLE_PORT} --protocol http --insecure-skip-tls-verify
env_vars:
- ANSIBLE_TOKEN=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
- ANSIBLE_HOST=localhost
- ANSIBLE_PORT=9000
filters: null
handlers: null
runtime_assets:
- sensu/sensu-ansible-handler:2.1.0
secrets: null
timeout: 10
type: pipe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment