This is an automated email from the ASF dual-hosted git repository.

cbickel pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git


The following commit(s) were added to refs/heads/master by this push:
     new 674b26c  Refactor controller role to user variables for hostname and 
host index. (#3206)
674b26c is described below

commit 674b26cf175dd5402c6e22b0f4265fda545e1c18
Author: James Dubee <jwdu...@us.ibm.com>
AuthorDate: Thu Feb 8 10:08:08 2018 -0500

    Refactor controller role to user variables for hostname and host index. 
(#3206)
    
    - Define variables for frequently referenced operations controller role
    - Move controller.jmxremote.jvmArgs to deploy.yml
---
 ansible/group_vars/all                    |  7 ------
 ansible/roles/controller/tasks/clean.yml  | 14 ++++++++---
 ansible/roles/controller/tasks/deploy.yml | 42 ++++++++++++++++++-------------
 3 files changed, 36 insertions(+), 27 deletions(-)

diff --git a/ansible/group_vars/all b/ansible/group_vars/all
index 92b047e..6978fb9 100644
--- a/ansible/group_vars/all
+++ b/ansible/group_vars/all
@@ -43,9 +43,6 @@ limits:
   firesPerMinute: "{{ limit_fires_per_minute | default(60) }}"
   sequenceMaxLength: "{{ limit_sequence_max_length | default(50) }}"
 
-controllerHostnameFromMap: "{{ groups['controllers'] | map('extract', 
hostvars, 'ansible_host') | list | first }}"
-controllerHostname: "{{ controllerHostnameFromMap | 
default(inventory_hostname) }}"
-
 # port means outer port
 controller:
   dir:
@@ -68,10 +65,6 @@ controller:
   # We recommend to enable HA for the controllers only, if bookkeeping data 
are shared too. (localBookkeeping: false)
   ha: "{{ controller_enable_ha | default(True) and groups['controllers'] | 
length > 1 }}"
   loglevel: "{{ controller_loglevel | default(whisk_loglevel) | 
default('INFO') }}"
-  jmxremote:
-    jvmArgs:  "{% if inventory_hostname in groups['controllers'] %}
-    {{ jmx.jvmCommonArgs }} -Djava.rmi.server.hostname={{ controllerHostname 
}} -Dcom.sun.management.jmxremote.rmi.port={{ jmx.rmiBasePortController + 
groups['controllers'].index(inventory_hostname) }} 
-Dcom.sun.management.jmxremote.port={{ jmx.basePortController + 
groups['controllers'].index(inventory_hostname) }}
-    {% endif %}"
 
 jmx:
   basePortController: 15000
diff --git a/ansible/roles/controller/tasks/clean.yml 
b/ansible/roles/controller/tasks/clean.yml
index 231198a..c34b8e8 100644
--- a/ansible/roles/controller/tasks/clean.yml
+++ b/ansible/roles/controller/tasks/clean.yml
@@ -1,21 +1,29 @@
 ---
 # Remove controller containers.
 
+- name: get controller index
+  set_fact:
+    controller_index: "{{ groups['controllers'].index(inventory_hostname) }}"
+
+- name: get controller name
+  set_fact:
+    controller_name: "controller{{ controller_index }}"
+
 - name: remove controller
   docker_container:
-    name: "controller{{ groups['controllers'].index(inventory_hostname) }}"
+    name: "{{ controller_name }}"
     image: "{{ docker_registry }}{{ docker.image.prefix }}/controller:{{ 
docker.image.tag }}"
     state: absent
   ignore_errors: True
 
 - name: remove controller log directory
   file:
-    path: "{{ whisk_logs_dir }}/controller{{ 
groups['controllers'].index(inventory_hostname) }}"
+    path: "{{ whisk_logs_dir }}/{{ controller_name }}"
     state: absent
   become: "{{ logs.dir.become }}"
 
 - name: remove controller conf directory
   file:
-    path: "{{ controller.confdir }}/controller{{ 
groups['controllers'].index(inventory_hostname) }}"
+    path: "{{ controller.confdir }}/{{ controller_name }}"
     state: absent
   become: "{{ controller.dir.become }}"
diff --git a/ansible/roles/controller/tasks/deploy.yml 
b/ansible/roles/controller/tasks/deploy.yml
index e673438..8601a29 100644
--- a/ansible/roles/controller/tasks/deploy.yml
+++ b/ansible/roles/controller/tasks/deploy.yml
@@ -3,6 +3,14 @@
 
 - include: docker_login.yml
 
+- name: get controller index
+  set_fact:
+    controller_index: "{{ groups['controllers'].index(inventory_hostname) }}"
+
+- name: get controller name
+  set_fact:
+    controller_name: "controller{{ controller_index }}"
+
 - name: "pull the {{ docker.image.tag }} image of controller"
   shell: "docker pull {{ docker_registry }}{{ docker.image.prefix 
}}/controller:{{ docker.image.tag }}"
   when: docker_registry != ""
@@ -11,14 +19,14 @@
 
 - name: ensure controller log directory is created with permissions
   file:
-    path: "{{ whisk_logs_dir }}/controller{{ 
groups['controllers'].index(inventory_hostname) }}"
+    path: "{{ whisk_logs_dir }}/{{ controller_name }}"
     state: directory
     mode: 0777
   become: "{{ logs.dir.become }}"
 
 - name: ensure controller config directory is created with permissions
   file:
-    path: "{{ controller.confdir }}/controller{{ 
groups['controllers'].index(inventory_hostname) }}"
+    path: "{{ controller.confdir }}/{{ controller_name }}"
     state: directory
     mode: 0777
   become: "{{ controller.dir.become }}"
@@ -27,14 +35,14 @@
   when: jmx.enabled
   template:
     src: "jmxremote.password.j2"
-    dest: "{{ controller.confdir }}/controller{{ 
groups['controllers'].index(inventory_hostname) }}/jmxremote.password"
+    dest: "{{ controller.confdir }}/{{ controller_name }}/jmxremote.password"
     mode: 0777
 
 - name: copy jmxremote access file
   when: jmx.enabled
   template:
     src: "jmxremote.access.j2"
-    dest: "{{ controller.confdir }}/controller{{ 
groups['controllers'].index(inventory_hostname) }}/jmxremote.access"
+    dest: "{{ controller.confdir }}/{{ controller_name }}/jmxremote.access"
     mode: 0777
 
 - name: check, that required databases exist
@@ -48,17 +56,17 @@
 
 - name: prepare controller ports
   set_fact:
-    ports_to_expose: ["{{ controller.basePort + 
groups['controllers'].index(inventory_hostname) }}:8080", "{{ 
controller.akka.cluster.basePort + 
groups['controllers'].index(inventory_hostname) }}:{{ 
controller.akka.cluster.bindPort }}"]
+    ports_to_expose: ["{{ controller.basePort + (controller_index | int) 
}}:8080", "{{ controller.akka.cluster.basePort + (controller_index | int) }}:{{ 
controller.akka.cluster.bindPort }}"]
 
 - name: expose additional ports if jmxremote is enabled
   when: jmx.enabled
   set_fact:
-    ports_to_expose: "{{ ports_to_expose }} + [ \"{{ jmx.basePortController + 
groups['controllers'].index(inventory_hostname) }}:{{ jmx.basePortController + 
groups['controllers'].index(inventory_hostname) }}\" ] + [ \"{{ 
jmx.rmiBasePortController + groups['controllers'].index(inventory_hostname) 
}}:{{ jmx.rmiBasePortController + 
groups['controllers'].index(inventory_hostname) }}\" ]"
+    ports_to_expose: "{{ ports_to_expose }} + [ \"{{ jmx.basePortController + 
(controller_index | int) }}:{{ jmx.basePortController + (controller_index | 
int)}}\" ] + [ \"{{ jmx.rmiBasePortController + (controller_index | int) }}:{{ 
jmx.rmiBasePortController + (controller_index | int) }}\" ]"
 
 - name: add additional jvm params if jmxremote is enabled
   when: jmx.enabled
   set_fact:
-    controller_args: "{{ controller.arguments }} {{ 
controller.jmxremote.jvmArgs }}"
+    controller_args: "{{ controller.arguments }} {{ jmx.jvmCommonArgs }} 
-Djava.rmi.server.hostname={{ inventory_hostname }} 
-Dcom.sun.management.jmxremote.rmi.port={{ jmx.rmiBasePortController + 
(controller_index | int) }} -Dcom.sun.management.jmxremote.port={{ 
jmx.basePortController + (controller_index | int) }}"
 
 - name: create seed nodes list
   set_fact:
@@ -68,19 +76,19 @@
 
 - name: (re)start controller
   docker_container:
-    name: controller{{ groups['controllers'].index(inventory_hostname) }}
+    name: "{{ controller_name }}"
     image: "{{ docker_registry }}{{ docker.image.prefix }}/controller:{{ 
docker.image.tag }}"
     state: started
     recreate: true
     restart_policy: "{{ docker.restart.policy }}"
-    hostname: "controller{{ groups['controllers'].index(inventory_hostname) }}"
+    hostname: "{{ controller_name }}"
     env:
       "JAVA_OPTS": "-Xmx{{ controller.heap }} -XX:+CrashOnOutOfMemoryError 
-XX:+UseGCOverheadLimit -XX:ErrorFile=/logs/java_error.log 
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/logs"
       "CONTROLLER_OPTS": "{{ controller_args | default(controller.arguments) 
}}"
       "CONTROLLER_INSTANCES": "{{ controller.instances }}"
       "JMX_REMOTE": "{{ jmx.enabled }}"
 
-      "COMPONENT_NAME": "controller{{ 
groups['controllers'].index(inventory_hostname) }}"
+      "COMPONENT_NAME": "{{ controller_name }}"
       "PORT": 8080
 
       "WHISK_VERSION_NAME": "{{ whisk_version_name }}"
@@ -136,8 +144,8 @@
       "CONFIG_whisk_loadbalancer_blackboxFraction": "{{ 
controller.blackboxFraction }}"
 
       "CONFIG_akka_actor_provider": "{{ controller.akka.provider }}"
-      "CONFIG_akka_remote_netty_tcp_hostname": "{{ 
controller.akka.cluster.host[groups['controllers'].index(inventory_hostname)] 
}}"
-      "CONFIG_akka_remote_netty_tcp_port": "{{ 
controller.akka.cluster.basePort + 
groups['controllers'].index(inventory_hostname) }}"
+      "CONFIG_akka_remote_netty_tcp_hostname": "{{ 
controller.akka.cluster.host[(controller_index | int)] }}"
+      "CONFIG_akka_remote_netty_tcp_port": "{{ 
controller.akka.cluster.basePort + (controller_index | int) }}"
       "CONFIG_akka_remote_netty_tcp_bindPort": "{{ 
controller.akka.cluster.bindPort }}"
 
       "CONFIG_kamon_statsd_hostname": "{{ metrics.kamon.host }}"
@@ -149,15 +157,15 @@
 
       "CONFIG_whisk_transactions_stride": "{{ transactions.stride | default() 
}}"
     volumes:
-      - "{{ whisk_logs_dir }}/controller{{ 
groups['controllers'].index(inventory_hostname) }}:/logs"
-      - "{{ controller.confdir }}/controller{{ 
groups['controllers'].index(inventory_hostname) }}:/conf"
+      - "{{ whisk_logs_dir }}/{{ controller_name }}:/logs"
+      - "{{ controller.confdir }}/{{ controller_name }}:/conf"
     ports: "{{ ports_to_expose }}"
-    command: /bin/sh -c "exec /init.sh {{ 
groups['controllers'].index(inventory_hostname) }} >> /logs/controller{{ 
groups['controllers'].index(inventory_hostname) }}_logs.log 2>&1"
+    command: /bin/sh -c "exec /init.sh {{ controller_index }} >> /logs/{{ 
controller_name }}_logs.log 2>&1"
 
 - name: wait until the Controller in this host is up and running
   uri:
-    url: "http://{{ ansible_host }}:{{ controller.basePort + 
groups['controllers'].index(inventory_hostname) }}/ping"
+    url: "http://{{ ansible_host }}:{{ controller.basePort + (controller_index 
| int) }}/ping"
   register: result
   until: result.status == 200
   retries: 12
-  delay: 5
\ No newline at end of file
+  delay: 5

-- 
To stop receiving notification emails like this one, please contact
cbic...@apache.org.

Reply via email to