Prechádzať zdrojové kódy

Tested of refactored code

John Kwiatkoski 9 rokov pred
rodič
commit
a181c8705a

+ 0 - 4
roles/openshift_hosted_logging/files/openshift_hosted_logging_efk.yaml

@@ -1,4 +0,0 @@
-- hosts: my_master_host
-  roles:
-  - role: openshift_hosted_logging
-    openshift_hosted_logging_cleanup: no

+ 3 - 0
roles/openshift_hosted_logging/meta/main.yaml

@@ -0,0 +1,3 @@
+---
+dependencies:
+  - { role: openshift_common }

+ 17 - 30
roles/openshift_hosted_logging/tasks/cleanup_logging.yaml

@@ -4,14 +4,9 @@
     command: oc get project logging
     register: logging_project
     failed_when: "'FAILED' in logging_project.stderr"
-    tags:
-      - cleanup
 
   - name: "Changing projects"
-    command: oc project logging
-    tags:
-      - cleanup
-      - build
+    command: "{{ openshift.common.client_binary }} project logging"
 
   - name: Create temp directory for kubeconfig
     command: mktemp -d /tmp/openshift-ansible-XXXXXX
@@ -25,52 +20,44 @@
 
   - name: "Changing projects"
     command: oc project logging
-    tags:
-      - cleanup
-      - build
 
 
   - name: "Cleanup any previous logging infrastructure"
-    command: oc delete --ignore-not-found all --selector logging-infra={{ item }}
+    command: "{{ openshift.common.client_binary }} delete --ignore-not-found all --selector logging-infra={{ item }}"
     with_items:
       - kibana
       - fluentd
       - elasticsearch
     ignore_errors: yes
-    tags:
-      - cleanup
-
 
   - name: "Cleanup existing support infrastructure"
-    command: oc delete --ignore-not-found all,sa,oauthclient --selector logging-infra=support
+    command: "{{ openshift.common.client_binary }} delete --ignore-not-found all,sa,oauthclient --selector logging-infra=support"
     ignore_errors: yes
-    tags:
-      - cleanup
 
   - name: "Cleanup existing secrets"
-    command: oc delete secret logging-fluentd logging-elasticsearch logging-es-proxy logging-kibana logging-kibana-proxy logging-kibana-ops-proxy
+    command: "{{ openshift.common.client_binary }} delete secret logging-fluentd logging-elasticsearch logging-es-proxy logging-kibana logging-kibana-proxy logging-kibana-ops-proxy"
     ignore_errors: yes
     register: clean_result
     failed_when: clean_result.rc == 1 and 'not found' not in clean_result.stderr
-    tags:
-      - cleanup
 
   - name: "Cleanup existing logging deployers"
-    command: oc delete pods --all
-    tags:
-      - cleanup
+    command: "{{ openshift.common.client_binary }} delete pods --all"
+
+
+  - name: "Cleanup logging project"
+    command: "{{ openshift.common.client_binary }} delete project logging"
 
-  - name: "Make sure to remove deployer template"
-    command: oc delete template logging-deployer-template -n openshift
+
+  - name: "Remove deployer template"
+    command: "{{ openshift.common.client_binary }} delete template logging-deployer-template -n openshift"
     register: delete_ouput
     failed_when: delete_ouput.rc == 1 and 'exists' not in delete_ouput.stderr
-    tags:
-      - cleanup
+
 
   - name: Delete temp directory
-  file:
-    name: "{{ mktemp.stdout }}"
-    state: absent
-  changed_when: False
+    file:
+      name: "{{ mktemp.stdout }}"
+      state: absent
+    changed_when: False
 
   - debug: msg="Success!"

+ 33 - 35
roles/openshift_hosted_logging/tasks/deploy_logging.yaml

@@ -1,8 +1,7 @@
 ---
-
-  - fail: msg="This role requires the following vars to be defined: openshift_hosted_logging_master_public_url, openshift_hosted_logging_hostname, penshift_hosted_logging_elasticsearchs_cluster_size"
+  - fail: msg="This role requires the following vars to be defined. openshift_hosted_logging_master_public_url, openshift_hosted_logging_hostname, openshift_hosted_logging_elasticsearch_cluster_size"
     when: "openshift_hosted_logging_hostname is not defined or
-          penshift_hosted_logging_elasticsearchs_cluster_size is not defined or
+          openshift_hosted_logging_elasticsearch_cluster_size is not defined or
           openshift_hosted_logging_master_public_url is not defined"
 
   - name: Create temp directory for kubeconfig
@@ -15,17 +14,14 @@
       cp {{ openshift_master_config_dir }}/admin.kubeconfig {{ mktemp.stdout }}/admin.kubeconfig
     changed_when: False
 
-
   - name: "Create logging project"
     command: oadm new-project logging
-    when: logging_project.rc != 0
-
 
   - name: "Changing projects"
-    command: oc project logging
+    command:  "{{ openshift.common.client_binary }} project logging"
 
   - name: "Creating logging deployer secret"
-    command: oc secrets new logging-deployer {{ openshift_hosted_logging_secret_vars | default('nothing=/dev/null') }}
+    command: " {{ openshift.common.client_binary }} secrets new logging-deployer {{ openshift_hosted_logging_secret_vars | default('nothing=/dev/null') }}"
     register: secret_output
     failed_when: "secret_output.rc == 1 and 'exists' not in secret_output.stderr"
 
@@ -35,12 +31,12 @@
           force=yes
 
   - name: "Create logging-deployer service account"
-    shell: oc create -f  /tmp/logging-deployer-sa.yaml
+    command:  "{{ openshift.common.client_binary }} create -f  /tmp/logging-deployer-sa.yaml"
     register: deployer_output
     failed_when: "deployer_output.rc == 1 and 'exists' not in deployer_output.stderr"
 
   - name: "Set permissions for logging-deployer service account"
-    command: oc policy add-role-to-user edit system:serviceaccount:logging:logging-deployer
+    command:  "{{ openshift.common.client_binary }} policy add-role-to-user edit system:serviceaccount:logging:logging-deployer"
     register: permiss_output
     failed_when: "permiss_output.rc == 1 and 'exists' not in permiss_output.stderr"
 
@@ -55,53 +51,55 @@
     failed_when: "fluentd2_output.rc == 1 and 'exists' not in fluentd2_output.stderr"
 
   - name: "Create deployer template"
-    command: oc create -f /usr/share/openshift/examples/infrastructure-templates/enterprise/logging-deployer.yaml -n openshift
+    command:  "{{ openshift.common.client_binary }} create -f /usr/share/openshift/examples/infrastructure-templates/enterprise/logging-deployer.yaml -n openshift"
     register: template_output
     failed_when: "template_output.rc == 1 and 'exists' not in template_output.stderr"
 
-  - name: "Process the deployer template with an registry other than registry.access.redhat.com"
-    shell: oc process logging-deployer-template -n openshift -v {{ oc_process_values}} | oc create -f -
+  - name: "Process the deployer template"
+    shell:  "{{ openshift.common.client_binary }} process logging-deployer-template -n openshift -v {{ oc_process_values }} |  {{ openshift.common.client_binary }} create -f -"
 
   - name: "Wait for image pull and deployer pod"
-     shell: oc get pods | grep logging-deployer.*Completed
-     register: result
-     until: result.rc == 0
-     retries: 15
-     delay: 10
+    shell:  "{{ openshift.common.client_binary }} get pods | grep logging-deployer.*Completed"
+    register: result
+    until: result.rc == 0
+    retries: 15
+    delay: 10
 
   - name: "Process support template"
-    shell: oc process logging-support-template | oc create -f -
+    shell:  "{{ openshift.common.client_binary }} process logging-support-template |  {{ openshift.common.client_binary }} create -f -"
 
   - name: "Set insecured registry"
-    command: oc annotate is --all  openshift.io/image.insecureRepository=true --overwrite
+    command:  "{{ openshift.common.client_binary }} annotate is --all  openshift.io/image.insecureRepository=true --overwrite"
     when: "target_registry is defined and insecure_registry == 'true'"
 
-  - name: "Scale fluentd deployment config"
-    command: oc scale dc/logging-fluentd --replicas={{ fluentd_replicas | default('1') }}
-
   - name: "Wait for imagestreams to become available"
-    shell: oc get is | grep logging-fluentd
+    shell:  "{{ openshift.common.client_binary }} get is | grep logging-fluentd"
     register: result
     until: result.rc == 0
     failed_when: result.rc == 1 and 'not found' not in result.stderr
-    retries: 15
-    delay: 5
-
+    retries: 20
+    delay: 10
+    
   - name: "Wait for replication controllers to become available"
-    shell: oc get rc | grep logging-fluentd-1
+    shell:  "{{ openshift.common.client_binary }} get rc | grep logging-fluentd-1"
     register: result
     until: result.rc == 0
     failed_when: result.rc == 1 and 'not found' not in result.stderr
-    retries: 15
-    delay: 5
+    retries: 20
+    delay: 10
+
+
+  - name: "Scale fluentd deployment config"
+    command:  "{{ openshift.common.client_binary }} scale dc/logging-fluentd --replicas={{ fluentd_replicas | default('1') }}"
+
 
   - name: "Scale fluentd replication controller"
-    command: oc scale rc/logging-fluentd-1 --replicas={{ fluentd_replicas | default('1') }}
+    command:  "{{ openshift.common.client_binary }} scale rc/logging-fluentd-1 --replicas={{ fluentd_replicas | default('1') }}"
 
   - debug: msg="Logging components deployed. Note persistant volume for elasticsearch must be setup manually"
 
   - name: Delete temp directory
-  file:
-    name: "{{ mktemp.stdout }}"
-    state: absent
-  changed_when: False
+    file:
+      name: "{{ mktemp.stdout }}"
+      state: absent
+    changed_when: False

+ 2 - 2
roles/openshift_hosted_logging/tasks/main.yaml

@@ -1,8 +1,8 @@
 ---
 - name: Cleanup logging deployment
-  include: {{ role_path }}/tasks/cleanup_logging.yaml
+  include: "{{ role_path }}/tasks/cleanup_logging.yaml"
   when: openshift_hosted_logging_cleanup | default(false) | bool
 
 - name: Deploy logging
-  include: {{ role_path }}/tasks/deploy_logging.yaml
+  include: "{{ role_path }}/tasks/deploy_logging.yaml"
   when: not openshift_hosted_logging_cleanup | default(false) | bool

+ 5 - 4
roles/openshift_hosted_logging/vars/main.yaml

@@ -1,5 +1,6 @@
-kh_kv: KIBANA_HOSTNAME={{ openshift_hosted_logging_hostname | quote }}
-es_cs_kv: ES_CLUSTER_SIZE={{ openshift_hosted_logging_elasticsearch_cluster_size | quote }}
-pmu_kv: PUBLIC_MASTER_URL={{ openshift_hosted_logging_master_public_url | quote }}
+kh_kv: "KIBANA_HOSTNAME={{ openshift_hosted_logging_hostname | quote }}"
+es_cs_kv: "ES_CLUSTER_SIZE={{ openshift_hosted_logging_elasticsearch_cluster_size | quote }}"
+pmu_kv: "PUBLIC_MASTER_URL={{ openshift_hosted_logging_master_public_url | quote }}"
 ip_kv: "{{ 'IMAGE_PREFIX=' ~ target_registry | quote if target_registry is defined else '' }}"
-oc_process_values: "{{ kh_kv }} {{ es_cs_kv }} {{ pmu_kv }} {{ ip_kv }}"
+oc_process_values: "{{ kh_kv }},{{ es_cs_kv }},{{ pmu_kv }},{{ ip_kv }}"
+openshift_master_config_dir: "{{ openshift.common.config_base }}/master"