diff --git a/playbooks/deploy-prometheus.yml b/playbooks/deploy-prometheus.yml new file mode 100644 index 0000000..910c60c --- /dev/null +++ b/playbooks/deploy-prometheus.yml @@ -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 diff --git a/playbooks/site.yml b/playbooks/site.yml index 17db5d1..defebc7 100644 --- a/playbooks/site.yml +++ b/playbooks/site.yml @@ -5,13 +5,15 @@ - include: "preparation.yml" # Launch the OpenShift Installer Playbook - - include: "../openshift-ansible/playbooks/byo/openshift-clister/config.yml" + - include: "../openshift-ansible/playbooks/byo/openshift-cluster/config.yml" - include: "post-install.yml" - # Install Prometheus - - include: "../openshift-ansible/playbooks/byo/openshift-cluster/openshift-prometheus.yml" + # Update the default templates and image streams + - include: "../openshift-ansible/playbooks/byo/openshift-master/additional_config.yml" - include: "provision-global-templates-and-imagestreams.yml" + - include: "deploy-prometheus.yml" + - include: "configure-openshift-access-control.yml" diff --git a/prod.hosts b/prod.hosts index 0f0e730..00e9c7f 100644 --- a/prod.hosts +++ b/prod.hosts @@ -6,6 +6,7 @@ itix_dns_suffix=itix.fr itix_openshift_version=3.7 itix_application_templates_repo_tag=ose-v1.4.7 itix_openshift_origin_repo_tag=release-3.7 +itix_openshift_docker_images_repo_tag=master [itix:children] masters @@ -35,12 +36,6 @@ nodes etcd [OSEv3:vars] -# Deploy Prometheus -openshift_hosted_prometheus_deploy=true -openshift_prometheus_storage_type='pvc' -openshift_prometheus_alertmanager_storage_type='pvc' -openshift_prometheus_alertbuffer_storage_type='pvc' - # # Starting with 3.6, default templates and imagestreams can be left out # see https://bugzilla.redhat.com/show_bug.cgi?id=1506578