3 changed files with 66 additions and 9 deletions
@ -0,0 +1,60 @@ |
|||||
|
--- |
||||
|
|
||||
|
- name: Deploy Prometheus on OpenShift |
||||
|
hosts: itix |
||||
|
become: yes |
||||
|
vars: |
||||
|
itix_openshift_docker_images_repo_url: https://github.com/nmasse-itix/OpenShift-Docker-Images.git |
||||
|
itix_prometheus_project: openshift-metrics |
||||
|
itix_grafana_route: grafana.{{ openshift_master_default_subdomain }} |
||||
|
itix_prometheus_route: prometheus.{{ openshift_master_default_subdomain }} |
||||
|
itix_alerts_route: prometheus-alerts.{{ openshift_master_default_subdomain }} |
||||
|
tasks: |
||||
|
- name: Create a temporary directory |
||||
|
tempfile: |
||||
|
state: directory |
||||
|
register: tempfile |
||||
|
|
||||
|
- name: Clone the nmasse-itix/OpenShift-Docker-Images GIT repository |
||||
|
git: |
||||
|
repo: '{{ itix_openshift_docker_images_repo_url }}' |
||||
|
dest: '{{ tempfile.path }}' |
||||
|
version: '{{ itix_openshift_docker_images_repo_tag|default(''master'') }}' |
||||
|
|
||||
|
- name: Process the grafana-prometheus-storage template |
||||
|
command: oc process -f '{{ tempfile.path }}/grafana/grafana-prometheus-storage.yaml' -p 'NAMESPACE={{ itix_prometheus_project }}' |
||||
|
register: oc_process |
||||
|
|
||||
|
- set_fact: |
||||
|
grafana_prometheus_storage: '{{ oc_process.stdout }}' |
||||
|
|
||||
|
- name: Process the grafana-prometheus template |
||||
|
command: oc process -f '{{ tempfile.path }}/grafana/grafana-prometheus.yaml' -p 'NAMESPACE={{ itix_prometheus_project }}' -p 'PROMETHEUS_ROUTE_HOSTNAME={{ itix_prometheus_route }}' -p 'ALERTS_ROUTE_HOSTNAME={{ itix_alerts_route }}' |
||||
|
register: oc_process |
||||
|
|
||||
|
- set_fact: |
||||
|
grafana_prometheus: '{{ oc_process.stdout }}' |
||||
|
|
||||
|
- name: Process the grafana-base template |
||||
|
command: oc process -f '{{ tempfile.path }}/grafana/grafana-base.yaml' -p 'NAMESPACE={{ itix_prometheus_project }}' -p 'GRAFANA_ROUTE_HOSTNAME={{ itix_grafana_route }}' |
||||
|
register: oc_process |
||||
|
|
||||
|
- set_fact: |
||||
|
grafana_base: '{{ oc_process.stdout }}' |
||||
|
|
||||
|
- name: Create the objects |
||||
|
command: oc create -f - |
||||
|
args: |
||||
|
stdin: '{{ item|to_json }}' |
||||
|
register: oc |
||||
|
failed_when: oc.rc > 0 and 'Error from server (AlreadyExists):' not in oc.stderr |
||||
|
changed_when: oc.rc == 0 |
||||
|
with_items: |
||||
|
- '{{ grafana_prometheus_storage }}' |
||||
|
- '{{ grafana_prometheus }}' |
||||
|
- '{{ grafana_base }}' |
||||
|
|
||||
|
- name: Delete the temporary directory |
||||
|
file: |
||||
|
path: '{{ tempfile.path }}' |
||||
|
state: absent |
||||
Loading…
Reference in new issue