You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/02/06 04:21:40 UTC

[GitHub] dubeejw commented on a change in pull request #3206: Refactor controller role to use variables for hostname and host index

dubeejw commented on a change in pull request #3206: Refactor controller role to use variables for hostname and host index
URL: https://github.com/apache/incubator-openwhisk/pull/3206#discussion_r166184231
 
 

 ##########
 File path: ansible/roles/controller/tasks/deploy.yml
 ##########
 @@ -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 }}"]
 
 Review comment:
   @cbickel, unfortunately defining the `controller_index` as an `int` results in the variable type being `unicode`. See below.
   
   Define `controller_index` as an int:
   ```
   - name: get controller index
     set_fact:
       controller_index: "{{ groups['controllers'].index(inventory_hostname) | int }}"
   ```
   
   Attempting to add `controller_index` to an int:
   ```
   {{ controller.basePort + controller_index }}
   ```
   
   Results in this error:
   ```
   fatal: [192.168.99.100]: FAILED! => {"failed": true, "msg": "Unexpected templating type error occurred on ({{ controller.basePort + controller_index }}:8080): unsupported operand type(s) for +: 'int' and 'unicode'"}
   ```
   
   Apparently using `set_fact` always produces a string: https://github.com/ansible/ansible/issues/4170.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services